-
Notifications
You must be signed in to change notification settings - Fork 8
Global ops reduction #988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Global ops reduction #988
Changes from all commits
Commits
Show all changes
2287 commits
Select commit
Hold shift + click to select a range
2065cd0
need mp4py after all
boeschf 0ac81cf
record mpi4py version during build and warn during runtime if not equ…
boeschf 179c7ed
CI: generate requirements-test.txt dynamically; CMake: configure mpi4…
boeschf fd9e337
properly generate mpi4py header as custom command and custom target
boeschf bc5e02e
unconditionally request mpi4py for python build
boeschf dbb3905
pip: user install
boeschf 4b3b104
need ninja
boeschf f017a3e
need python-dev again?
boeschf e2a18dc
no need for action
boeschf bf60bd8
deleted too much
boeschf a632e2d
no pip upgrade
boeschf 2ec12dc
simplification: remove build dependency on MPI4PY
boeschf a1d712c
review suggestion: improve find_python_module cmake script to include…
boeschf 8f6f70c
minimum requirements
boeschf a124f54
cleanup
boeschf 7f90f33
Add support for bool, int32, int64 in python bindings
tehrengruber fa0e227
Add tests
tehrengruber 6ef0e7f
Small fix
tehrengruber c37725c
Merge pull request #176 from boeschf/bump-to-0.4.1
boeschf c08f987
Merge pull request #177 from havogt/enable_deploy_workflow
boeschf 7077201
use same version for downloading
boeschf 08ba21e
Merge pull request #179 from boeschf/fix/pypi_deploy
boeschf 20de84e
Fix clang compilation error by increasing allowed template depth
tehrengruber f7ca381
Remove superfluous include
tehrengruber 1b6453b
Fix clang compilation error by increasing allowed bracket depth
tehrengruber 37ab905
Fix issue with int64 on macOS. `py_dtype_to_cpp_name` returns "long l…
tehrengruber d55498d
Bump submodules
tehrengruber bea8237
Merge pull request #178 from tehrengruber/bindings_add_bool_int_support
boeschf b4d486f
Merge pull request #181 from tehrengruber/bump_submodules
boeschf 026cf0d
first few edits
nfarabullini ec06e95
further edits and fixes
nfarabullini 7efe19c
parallel geometry tests
nfarabullini f629c32
interpolation mpi tests
nfarabullini 158b5e2
Merge branch 'main' into parallel_impl
nfarabullini 1800282
Merge branch 'main' of https://github.com/C2SM/icon4py into parallel_…
nfarabullini c976563
Merge branch 'parallel_impl' of https://github.com/C2SM/icon4py into …
nfarabullini 3942340
small edits
nfarabullini 1ec21c4
small import edit
nfarabullini 37f6ba7
pre-commit edits
nfarabullini 69aff63
Merge branch 'main' into parallel_impl
nfarabullini 878789f
edits following review
nfarabullini 661db6e
Merge branch 'main' into parallel_impl
nfarabullini 9f87485
metrics_parallel
nfarabullini 144891b
removed import
nfarabullini d13b689
ran pre-commit
nfarabullini ea677cd
test - fixes down to assertion errors
585b584
fixes
nfarabullini 8a027dc
edits for tests and others
nfarabullini d64104e
Merge branch 'main' into parallel_impl
nfarabullini bb41cbd
pre-commit edits
nfarabullini 41caa22
import fixes and small refactoring
nfarabullini a74dd89
more edits and small refactoring
nfarabullini f43dd34
first commit lsq standalone
bb7a9c1
Merge branch 'ajocksch_lsq' of https://github.com/C2SM/icon4py into p…
nfarabullini ab3075f
edits following review
nfarabullini 8a1f7c4
further edits for fixes
nfarabullini 223af41
Merge branch 'main' into parallel_impl
nfarabullini 1fbcd7b
fixes for interpolation exchange
nfarabullini 9bce637
fixes for metrics exchange and other refactoring
nfarabullini 7db647d
small import fix
nfarabullini fda4951
Merge branch 'main' into parallel_impl
nfarabullini 2f5ac36
Merge branch 'parallel_impl' of https://github.com/C2SM/icon4py into …
nfarabullini e92056a
Merge branch 'main' into parallel_impl
nfarabullini fc6b6a0
Merge branch 'main' into parallel_impl
nfarabullini ae2274e
very small edits to fix issues
nfarabullini 76dd483
update ghex to master
b4cb52c
do exchange on FieldProviderLevel
9c9c6b1
use constants from attrs in test parametrization
7fd386e
create inplace 2d view of the field for exchange
a7aad80
Merge branch 'main' into parallel_impl
nfarabullini aebe29a
Merge branch 'main' into parallel_impl
nfarabullini 34f6e16
small typ hint edit
nfarabullini b6bf19d
revert small layout change
26ac1a5
change the local order of e2c2e to match icon, this fixes the computa…
a840479
Merge branch 'main' into fix_e_flx_average_or_e2c2c
f5cda28
Merge branch 'main' into parallel_impl
nfarabullini c8b5cd7
edits for interpolation and metrics wrt new configuration
nfarabullini bfdc370
fix explicit numpy usage
b8d7e28
Merge branch 'fix_e_flx_average_or_e2c2c' of https://github.com/C2SM/…
nfarabullini d5b528e
edits for geometry and others wrt new configuration
nfarabullini e47602d
Merge branch 'main' into parallel_impl
nfarabullini 83acedf
review fixes
15d3890
Merge branch 'main' into fix_e_flx_average_or_e2c2c
319bd21
Merge branch 'fix_e_flx_average_or_e2c2c' of https://github.com/C2SM/…
nfarabullini ced9aa7
edits for inverse geometry attrs
nfarabullini 135f863
edit to parallel metrics test
nfarabullini 36eabd8
fix numpy conversion after extraction for function
184eeff
Merge branch 'fix_e_flx_average_or_e2c2c' of https://github.com/C2SM/…
nfarabullini a700436
uv lock change wrt other PR
nfarabullini 05736f2
small edit to import construct
nfarabullini 46bfa24
further edits
nfarabullini c6f5777
reverted edit
nfarabullini b7adb35
added marker
nfarabullini 8d8ea30
some edits
nfarabullini 1015b7d
ran pre-commit
nfarabullini 7c0c0be
Merge branch 'main' into parallel_impl
nfarabullini 7e3aa22
Merge branch 'parallel_impl' of github.com:C2SM/icon4py into parallel…
13f43a5
remove domain arg from InverseFieldProvider
46cc0eb
revert wrong dimension in c_bln_avg
125335f
edits wrt main
nfarabullini 6267b7d
Merge branch 'parallel_impl' of github.com:C2SM/icon4py into parallel…
eceb021
added marker
nfarabullini 6e66193
ran pre-commit
nfarabullini 679bcef
rename fixtures use _from_savepoint instead of parallel as they could…
eeb0cbf
add halo exchange callback to compute_mass_conserving_bilinear_cell_a…
4a37438
pre-commit and typing fixes
e68d568
Merge branch 'parallel_impl' of github.com:C2SM/icon4py into parallel…
8f39203
Apply suggestion from @havogt
nfarabullini d93367d
c_bln_avg
93f5174
Merge branch 'parallel_impl' of github.com:C2SM/icon4py into parallel…
467d1fe
remove copies in c_bln_avg computation
fb126b4
edits for e_flx_avg
nfarabullini 333acc8
Merge branch 'main' into parallel_impl
nfarabullini 3f8ffd3
grg edits for regular interpolation
nfarabullini e5a84a6
grg edits for parallel interpolation
nfarabullini 8759da0
Merge branch 'main' into parallel_impl
nfarabullini 16189c1
pre-commit edits
nfarabullini 4ab4dd9
some edits
nfarabullini 3d61a96
added tests for non halo field
nfarabullini 005a996
fixes
nfarabullini cbe5703
Merge branch 'main' into parallel_impl
nfarabullini 3c7043d
other edits
nfarabullini eb1f80b
test edits
nfarabullini 7ce51e7
geometry tests
nfarabullini b3058e3
Merge branch 'parallel_impl' of https://github.com/C2SM/icon4py into …
nfarabullini 8c8fd65
Merge branch 'main' into parallel_impl
nfarabullini 9caf706
use max_over in metric_fields.py
84e9afc
edits for things to run
nfarabullini 9bd1f31
Merge branch 'main' into parallel_impl
nfarabullini 666d2e1
cleanup
nfarabullini 2ec4c41
Merge branch 'parallel_impl' of https://github.com/C2SM/icon4py into …
nfarabullini d4885ed
Merge branch 'parallel_impl' of github.com:C2SM/icon4py into parallel…
5e9223f
fix test_metrics fields
5c92430
remove halo exchange from geometry that is not needed
789e1eb
add two test cases in metrics fields
3b59991
add halo_exchange for rho_ref_me and theta_ref_me
9baea9f
remove obsolete TODO
5bd1e11
edits following review
nfarabullini 8991cd9
remove equal_nan
def072a
make geofac_grg validate - add exchange to c_lin_e
a8e6b02
move exchange_buffer function to decomposition, fix imports in defini…
d698fff
change exchange pattern for Numpy functions: geofac_n2s
62c6cb1
change exchange pattern for Numpy functions: geofac_n2s, geofac_grg
05a7fb7
change exchange pattern for Numpy functions: cell_average_weight, e_f…
1206758
edits following review
nfarabullini 09fc335
Merge branch 'main' into parallel_impl
nfarabullini d886638
ran pre-commit
nfarabullini a66d5a5
Merge branch 'parallel_impl' of https://github.com/C2SM/icon4py into …
nfarabullini 39c8afd
ran pre-commit
nfarabullini 5348e14
change exchange pattern for Numpy functions: cells_aw_verts, pos_on_t…
7c67708
change exchange pattern for Numpy functions: rbfs
9e074fd
Merge branch 'parallel_impl' of github.com:C2SM/icon4py into parallel…
3103aba
remove unused imports
abcabb8
added global min reduction
nfarabullini 4619251
made `do_exchange=True,` explicit
nfarabullini fd80c9b
ran pre--commit
nfarabullini 9e0ba60
add exchange config in geometry.py everywhere
ca7f725
add exchange config in geometry.py everywhere
0578072
merge without reductions - should go to another PR
f244461
fix metrics: change exner_exfac (WIP)
ff8cbad
fix typing
6bf6d2b
add exchange to composite FieldSource to avoid usage of default
1043c46
Revert "added global min reduction"
nfarabullini 7d9000a
added `global_min` reduction
nfarabullini 0e4068a
fix diffusion fields
0d5bbb9
Merge branch 'parallel_impl' of github.com:C2SM/icon4py into parallel…
6544cb2
fix Squence import
7085805
fix Squence import, pre-commit
6fd1b76
cleanup for dummy_exchange
nfarabullini fd808c2
Merge branch 'parallel_impl' of https://github.com/C2SM/icon4py into …
nfarabullini 6e8b868
edit to accoutn for mpi4py in global reduction
nfarabullini 13665b3
small fixings: typings, add halo exchange for z_me in compute_flat_id…
3552aad
local dummy callable import
6a145c9
merge with upstream
06b9be6
set `do_exchange` to False
nfarabullini b06a8b1
Merge branch 'parallel_impl' into global_min_reduction
nfarabullini 531832b
removed unused import
nfarabullini 7980164
handle arrays directly in exchange
690735b
edits following review
nfarabullini beff174
Merge branch 'parallel_impl' into global_min_reduction
nfarabullini 975e09c
remove duplicate
48b49a6
remove needs_exchange protocol from numpy data provider
5db8dd2
move resetting of duplicated indices to test data
c853076
Merge branch 'main' into parallel_impl
903cff7
Update model/common/src/icon4py/model/common/decomposition/mpi_decomp…
nfarabullini 5ee409b
Update model/common/src/icon4py/model/common/metrics/metric_fields.py
nfarabullini ad9e9ab
edits following review
nfarabullini 1c541ac
Update model/common/src/icon4py/model/common/decomposition/definition…
nfarabullini 963ae78
Update model/common/src/icon4py/model/common/decomposition/definition…
nfarabullini 309b374
Update model/common/src/icon4py/model/common/decomposition/definition…
nfarabullini 6482b0d
Update model/common/src/icon4py/model/common/decomposition/mpi_decomp…
nfarabullini 4ede44e
Update model/common/src/icon4py/model/common/decomposition/mpi_decomp…
nfarabullini 43af549
Update model/common/src/icon4py/model/common/decomposition/mpi_decomp…
nfarabullini 90a13c2
edits following review
nfarabullini 29f6dd4
Merge branch 'parallel_impl' into global_min_reduction
nfarabullini fb1278d
fix np / cupy issue
87ee7c7
remove unused imports
02d20fb
use gt4py program in test_mpi_decomposition.py for simply sparse fiel…
6ca8e94
delete debug print statement
3d7821b
delete debug print statement
397c581
pre-commit
6efefe7
re add local min computation
6c42b44
Merge branch 'parallel_impl' into global_min_reduction
nfarabullini cfe3f10
Merge branch 'main' into global_min_reduction
nfarabullini 62891bd
ran pre-commit
nfarabullini 30f8a98
fix for test
nfarabullini 5250ef8
edit to data type
nfarabullini 26b2d0a
Merge branch 'main' into global_min_reduction
nfarabullini 2054228
Merge branch 'main' into global_min_reduction
nfarabullini fc0720f
small edit
nfarabullini 8a83cf5
added tutorial link
nfarabullini 89d03e2
Merge branch 'main' into global_min_reduction
nfarabullini cffc977
Merge branch 'global_min_reduction' of https://github.com/C2SM/icon4p…
nfarabullini 064d838
initial commit for mpi red funcs
nfarabullini 168f10d
Merge branch 'main' into global_min_reduction
nfarabullini 7c3b7a2
eidt for global min and metric fields tests
nfarabullini 4663c34
edits to mpi decomposition and interpolation tests to account for tor…
nfarabullini 727e4f1
Merge branch 'global_min_reduction' of https://github.com/C2SM/icon4p…
nfarabullini 01c7c86
Merge branch 'main' into global_ops_reduction
nfarabullini 02f2067
Merge branch 'global_ops_reduction' of https://github.com/C2SM/icon4p…
nfarabullini 51b17d4
minor fix for parallel geometry mpi fields
nfarabullini 829c4d5
other global operations edits
nfarabullini b305eca
Merge branch 'main' into global_ops_reduction
nfarabullini 002d526
global mean implementation
nfarabullini 69b6191
global mean implementation and changes following review
nfarabullini f1126bf
further edits following review
nfarabullini 10d7904
further edits and fixes
nfarabullini 1693a66
removed breakpoint
nfarabullini 8b61ac1
Update model/common/src/icon4py/model/common/decomposition/mpi_decomp…
nfarabullini 663de2f
further edits following discussion
nfarabullini 447dd48
tests parametrization
nfarabullini d78d9cd
Update model/common/tests/common/decomposition/mpi_tests/test_mpi_dec…
nfarabullini 7e5e6f6
Update model/common/src/icon4py/model/common/decomposition/mpi_decomp…
nfarabullini 137f7b8
edits following review
nfarabullini 037964f
Merge branch 'main' into global_ops_reduction
nfarabullini 40dd268
edits in tests for errors
nfarabullini 236603a
add links to new mpi data, update old ones
jcanton 744f0ed
Update model/common/src/icon4py/model/common/decomposition/mpi_decomp…
nfarabullini 9a53f54
Update model/common/src/icon4py/model/common/decomposition/mpi_decomp…
nfarabullini 73f02e0
edits following review
nfarabullini be65852
minor edits
nfarabullini afe71ef
Update model/common/src/icon4py/model/common/grid/grid_manager.py
nfarabullini 7ab0cc8
Update model/common/src/icon4py/model/common/grid/icon.py
nfarabullini 99c1bcd
Update model/common/src/icon4py/model/common/decomposition/mpi_decomp…
nfarabullini af8800e
Update model/common/src/icon4py/model/common/decomposition/mpi_decomp…
nfarabullini 4958d64
Update model/common/src/icon4py/model/common/metrics/metric_fields.py
nfarabullini 677c051
Update model/common/src/icon4py/model/common/decomposition/mpi_decomp…
nfarabullini 3e469c0
Update model/common/tests/common/grid/mpi_tests/test_parallel_geometr…
nfarabullini 5055070
re-added import
nfarabullini 9c8ca85
small re-naming edit
nfarabullini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,10 +8,12 @@ | |
|
|
||
| from __future__ import annotations | ||
|
|
||
| import dataclasses | ||
| import functools | ||
| import logging | ||
| from collections.abc import Sequence | ||
| from collections.abc import Callable, Sequence | ||
| from dataclasses import dataclass | ||
| from types import ModuleType | ||
| from typing import TYPE_CHECKING, Any, ClassVar, Final, Union | ||
|
|
||
| import dace # type: ignore[import-untyped] | ||
|
|
@@ -20,8 +22,9 @@ | |
|
|
||
| from icon4py.model.common import dimension as dims | ||
| from icon4py.model.common.decomposition import definitions | ||
| from icon4py.model.common.decomposition.definitions import SingleNodeExchange | ||
| from icon4py.model.common.decomposition.definitions import Reductions, SingleNodeExchange | ||
| from icon4py.model.common.orchestration import halo_exchange | ||
| from icon4py.model.common.states import utils as state_utils | ||
| from icon4py.model.common.utils import data_allocation as data_alloc | ||
|
|
||
|
|
||
|
|
@@ -423,3 +426,81 @@ def create_multinode_node_exchange( | |
| return GHexMultiNodeExchange(props, decomp_info) | ||
| else: | ||
| return SingleNodeExchange() | ||
|
|
||
|
|
||
| @dataclasses.dataclass | ||
| class GlobalReductions(Reductions): | ||
| props: definitions.ProcessProperties | ||
|
|
||
| def _reduce( | ||
| self, | ||
| buffer: data_alloc.NDArray, | ||
| local_reduction: Callable[[data_alloc.NDArray], data_alloc.ScalarT], | ||
| global_reduction: mpi4py.MPI.Op, | ||
| array_ns: ModuleType = np, | ||
| ) -> state_utils.ScalarType: | ||
| local_red_val = local_reduction(buffer) | ||
| recv_buffer = array_ns.empty(1, dtype=buffer.dtype) | ||
| if hasattr( | ||
| array_ns, "cuda" | ||
| ): # https://mpi4py.readthedocs.io/en/stable/tutorial.html#gpu-aware-mpi-python-gpu-arrays | ||
| array_ns.cuda.runtime.deviceSynchronize() | ||
| self.props.comm.Allreduce(local_red_val, recv_buffer, global_reduction) | ||
| return recv_buffer.item() | ||
|
|
||
| def _calc_buffer_size( | ||
| self, | ||
| buffer: data_alloc.NDArray, | ||
| array_ns: ModuleType = np, | ||
| ) -> state_utils.ScalarType: | ||
| return self._reduce(array_ns.asarray([buffer.size]), array_ns.sum, mpi4py.MPI.SUM, array_ns) | ||
|
|
||
| def min(self, buffer: data_alloc.NDArray, array_ns: ModuleType = np) -> state_utils.ScalarType: | ||
nfarabullini marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if self._calc_buffer_size(buffer, array_ns) == 0: | ||
| raise ValueError("global_min requires a non-empty buffer") | ||
|
Comment on lines
+459
to
+460
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commenting for future reference: if we wanted to avoid this we could supply the neutral element as an initial value. No change needed now, this is fine. |
||
| return self._reduce( | ||
| buffer if buffer.size != 0 else array_ns.asarray([array_ns.inf]), | ||
| array_ns.min, | ||
| mpi4py.MPI.MIN, | ||
| array_ns, | ||
| ) | ||
|
|
||
| def max(self, buffer: data_alloc.NDArray, array_ns: ModuleType = np) -> state_utils.ScalarType: | ||
| if self._calc_buffer_size(buffer, array_ns) == 0: | ||
| raise ValueError("global_max requires a non-empty buffer") | ||
| return self._reduce( | ||
| buffer if buffer.size != 0 else array_ns.asarray([-array_ns.inf]), | ||
| array_ns.max, | ||
| mpi4py.MPI.MAX, | ||
| array_ns, | ||
| ) | ||
|
|
||
| def sum(self, buffer: data_alloc.NDArray, array_ns: ModuleType = np) -> state_utils.ScalarType: | ||
| if self._calc_buffer_size(buffer, array_ns) == 0: | ||
| raise ValueError("global_sum requires a non-empty buffer") | ||
| return self._reduce( | ||
| buffer if buffer.size != 0 else array_ns.asarray([0]), | ||
| array_ns.sum, | ||
| mpi4py.MPI.SUM, | ||
| array_ns, | ||
| ) | ||
|
|
||
| def mean(self, buffer: data_alloc.NDArray, array_ns: ModuleType = np) -> state_utils.ScalarType: | ||
| global_buffer_size = self._calc_buffer_size(buffer, array_ns) | ||
| if global_buffer_size == 0: | ||
| raise ValueError("global_mean requires a non-empty buffer") | ||
|
|
||
| return ( | ||
| self._reduce( | ||
| buffer if buffer.size != 0 else array_ns.asarray([0]), | ||
| array_ns.sum, | ||
| mpi4py.MPI.SUM, | ||
| array_ns, | ||
| ) | ||
| / global_buffer_size | ||
| ) | ||
|
|
||
|
|
||
| @definitions.create_reduction.register(MPICommProcessProperties) | ||
| def create_global_reduction(props: MPICommProcessProperties) -> Reductions: | ||
| return GlobalReductions(props) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.