Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
556 commits
Select commit Hold shift + click to select a range
c8bfbc6
Fix import for ToZeroBasedIndexTransformation
msimberg Feb 11, 2026
86da004
Remove unused import
msimberg Feb 11, 2026
814814f
Rename single/multi-node to single/multi-rank
msimberg Feb 11, 2026
f7dae6e
Add missing word
msimberg Feb 11, 2026
7abfc3d
Remove todos
msimberg Feb 11, 2026
3973bfb
Remove todo
msimberg Feb 11, 2026
85b091d
Remove unused logger
msimberg Feb 11, 2026
8e85390
Small refactor in halo.py
msimberg Feb 11, 2026
9e3f0fc
Revert horizontal_size/horizontal_config rename
msimberg Feb 11, 2026
2bd04a7
Fix typo
msimberg Feb 11, 2026
2bf0d2a
Small renaming related to index offset/transformation
msimberg Feb 11, 2026
e72803b
Small simplification
msimberg Feb 11, 2026
aa54fea
Replace prints with logging in distributed tests
msimberg Feb 12, 2026
1c1247a
Update model/common/tests/common/grid/mpi_tests/test_parallel_grid_ma…
msimberg Feb 12, 2026
5248993
Update model/common/tests/common/decomposition/unit_tests/test_halo.py
msimberg Feb 12, 2026
c6ef577
Update model/common/tests/common/grid/mpi_tests/test_parallel_grid_ma…
msimberg Feb 12, 2026
cea742c
Fix typo
msimberg Feb 12, 2026
e7428e6
Fix typo
msimberg Feb 12, 2026
9d7e88a
Remove model/common/tests/common/grid/fixtures.py
msimberg Feb 12, 2026
fde16aa
Fix distributed metrics test
msimberg Feb 12, 2026
0f06c6b
Revert horizontal_size/config rename
msimberg Feb 12, 2026
fcf7821
Fix some inconsistent renames
msimberg Feb 12, 2026
6f8fcd4
Update model/common/src/icon4py/model/common/decomposition/halo.py
msimberg Feb 12, 2026
66abfe1
Update model/common/src/icon4py/model/common/decomposition/halo.py
msimberg Feb 12, 2026
fec9a29
Clean up assignment
msimberg Feb 12, 2026
de988bc
Prefix private member functions with _
msimberg Feb 12, 2026
eae8bde
Remove MPI import for type checking
msimberg Feb 12, 2026
1288824
Minor cleanup
msimberg Feb 12, 2026
1fcee72
Use field_type_aliases in compute_cell_2_vertex_interpolation.py
msimberg Feb 12, 2026
0c51fa2
Merge remote-tracking branch 'origin/main' into distributed-tests-dac…
msimberg Feb 12, 2026
3d9f018
Simplify skipping mpi tests
msimberg Feb 12, 2026
d41ea85
Remove is not None
msimberg Feb 13, 2026
cccbe97
Simplify return
msimberg Feb 13, 2026
2b6be6d
Revert "Remove is not None"
msimberg Feb 13, 2026
b5115c2
Minor consistency renaming
msimberg Feb 13, 2026
1370754
Small cleanup in grid refinement
msimberg Feb 13, 2026
822549e
Add distributed property to GridConfig
msimberg Feb 13, 2026
d01fd13
CI for standalone_driver
nfarabullini Feb 19, 2026
f3c69ff
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Feb 19, 2026
4bf1e15
edits to yamla nd toml files
nfarabullini Feb 19, 2026
de83aeb
further edits and fixes
nfarabullini Feb 19, 2026
cf19a0f
Small reordering of fields
msimberg Feb 24, 2026
54ba6b5
Add more fields to be tested in test_parallel_grid_manager.py
msimberg Feb 24, 2026
bac1faf
Change computational domain for some geometry fields
msimberg Feb 24, 2026
789a7ff
Sort geometry fields
msimberg Feb 24, 2026
b40ff92
Add more interpolation fields to parallel grid manager test
msimberg Feb 24, 2026
67e054b
Test more metrics fields
msimberg Feb 24, 2026
f864ec6
Remove unused fixture
msimberg Feb 24, 2026
0fbfb62
Fix figure reference
msimberg Feb 24, 2026
2bc143e
Merge remote-tracking branch 'origin/main' into halo_construction
msimberg Feb 24, 2026
4fb0936
Remove deleted field from test
msimberg Feb 24, 2026
203fcf9
inital conditions edits and tests
nfarabullini Feb 25, 2026
ca8d67c
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Feb 25, 2026
dfdcfcb
further edits to remove serialized constants
nfarabullini Feb 25, 2026
bdde616
Merge branch 'ci_for_standalone_driver' of https://github.com/C2SM/ic…
nfarabullini Feb 25, 2026
7234c6b
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Feb 25, 2026
5e5a6ef
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Feb 27, 2026
7290b81
Update model/common/src/icon4py/model/common/decomposition/definition…
msimberg Feb 27, 2026
135172d
Update model/common/src/icon4py/model/common/decomposition/definition…
msimberg Feb 27, 2026
171d23f
Update model/common/src/icon4py/model/common/decomposition/halo.py
msimberg Feb 27, 2026
7fa119a
Update model/common/src/icon4py/model/common/decomposition/definition…
msimberg Feb 27, 2026
5b6ddf8
Merge remote-tracking branch 'origin/main' into distributed-tests-dac…
msimberg Feb 27, 2026
18ebc10
Merge remote-tracking branch 'origin/main' into halo_construction
msimberg Feb 27, 2026
f47e5f3
Work on failing test_parallel_grid_geometry.py fields
msimberg Feb 27, 2026
20e4a8b
Comment one more field out for now
msimberg Feb 27, 2026
46014f6
further edits
nfarabullini Mar 2, 2026
1061e37
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Mar 2, 2026
02a9650
Add assertions for halo construction consistency
msimberg Mar 2, 2026
bb9ebf1
lowered tolerance in standalone driver test and ran pre-commit
nfarabullini Mar 2, 2026
5b8a448
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Mar 2, 2026
cd8ef1c
update from upstream, edits to types, and ran pre-commit
nfarabullini Mar 2, 2026
63a2520
Change implementation of array_ns_from_array
msimberg Mar 2, 2026
3eea114
some edits
nfarabullini Mar 2, 2026
c1217d5
small edit
nfarabullini Mar 2, 2026
4bf3733
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Mar 2, 2026
23d7c83
Fix inverse dual edge length and c_lin_e fields
msimberg Mar 2, 2026
cc30a62
small fix
nfarabullini Mar 2, 2026
6b1bb5f
small edit to fixture
nfarabullini Mar 2, 2026
930e167
commented out parametrization
nfarabullini Mar 2, 2026
e86051a
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Mar 2, 2026
22338bf
removed w_1
nfarabullini Mar 3, 2026
fc982cb
small test edits
nfarabullini Mar 3, 2026
5424978
Merge branch 'ci_for_standalone_driver' of https://github.com/C2SM/ic…
nfarabullini Mar 3, 2026
3fc3dbf
edited one tolerance
nfarabullini Mar 3, 2026
55836c3
further fixes for w_1
nfarabullini Mar 3, 2026
69c8ae6
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Mar 3, 2026
cfabcd3
Update diffusion.py
nfarabullini Mar 3, 2026
6cbcbad
merge with upstream
nfarabullini Mar 3, 2026
5724bc6
edits to icon4py test
nfarabullini Mar 3, 2026
961f4cd
small type hint edit
nfarabullini Mar 3, 2026
3db70c3
further edits
nfarabullini Mar 3, 2026
68e85a4
standalone driver parametrization edits
nfarabullini Mar 3, 2026
f0e14d2
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Mar 3, 2026
fa07307
adjusted standalone tolerances
nfarabullini Mar 3, 2026
f415370
Merge branch 'main' into distributed-tests-dace-gpu
nfarabullini Mar 3, 2026
ad485d0
"Fix" more parallel tests
msimberg Mar 3, 2026
d2335c1
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Mar 4, 2026
09e99d2
ran pre-commit
nfarabullini Mar 4, 2026
88ffb2f
Merge branch 'ci_for_standalone_driver' of https://github.com/C2SM/ic…
nfarabullini Mar 4, 2026
abcc29c
grid description fixture and tiny grid
jcanton Mar 4, 2026
8c83811
Add tests to check consistency of owner masks and domain bounds
msimberg Mar 4, 2026
20aed6e
change config of metric factory for JW
OngChia Mar 4, 2026
895b5b4
Fix vertex/edge decomposition ownership masks
msimberg Mar 4, 2026
88b83ba
Update compute bounds in factories now that ownership bug is fixed
msimberg Mar 4, 2026
44e3708
Add tests to check that halo levels are sorted
msimberg Mar 4, 2026
82466c1
Clean up test_halo.py and fix a few parameters
msimberg Mar 4, 2026
38be5e5
Add missing is_sorted helper function
msimberg Mar 4, 2026
7cac885
Remove todo
msimberg Mar 4, 2026
eda26ef
Clean up and enable more tests in test_parallel_grid_manager.py
msimberg Mar 4, 2026
a397e0a
Add specialized mask_prog_halo_c test
msimberg Mar 4, 2026
d0acad4
Merge remote-tracking branch 'origin/halo_construction' into halo_con…
msimberg Mar 4, 2026
d949e44
Merge remote-tracking branch 'origin/main' into halo_construction
msimberg Mar 4, 2026
d2d8faf
Update array_ns_from_array after merge
msimberg Mar 4, 2026
95a676f
Update tested fields in test_parallel_grid_manager.py after merge
msimberg Mar 4, 2026
47d0e63
Merge branch 'main' into distributed-tests-dace-gpu
nfarabullini Mar 4, 2026
ce21e8f
modified np strict references with broader array_ns
nfarabullini Mar 4, 2026
214fbe9
Simplify test_halo.py
msimberg Mar 4, 2026
0d33ee4
Remove empty pytest file
msimberg Mar 4, 2026
1f632ab
Disable r01b01 grid for testing for now
msimberg Mar 5, 2026
a62e6e3
Fix formatting
msimberg Mar 5, 2026
c367428
Ignore commented out code
msimberg Mar 5, 2026
1975443
Small cleanup refactoring in halo construction
msimberg Mar 5, 2026
19abd25
Update decomposition info with_dimension call to set_dimension
msimberg Mar 5, 2026
4bf0618
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Mar 5, 2026
0d10792
Explicitly convert np.bool_ to bool
msimberg Mar 5, 2026
cecea11
adjusted tolerances
nfarabullini Mar 5, 2026
3013e78
Merge branch 'ci_for_standalone_driver' of https://github.com/C2SM/ic…
nfarabullini Mar 5, 2026
74938f3
Merge branch 'main' into distributed-tests-dace-gpu
nfarabullini Mar 5, 2026
f6fd95f
Remove unnecessary test
msimberg Mar 5, 2026
03fb537
replaced a few more np with array_ns
nfarabullini Mar 5, 2026
878db70
Update interpolation_fields.py
nfarabullini Mar 5, 2026
c449030
ran pre-commit
nfarabullini Mar 5, 2026
9460369
removed additional but unused return val
nfarabullini Mar 5, 2026
d96956a
edit for scipy func to flexible gpu/cpu func
nfarabullini Mar 5, 2026
c343334
Constrain xfail a bit more
msimberg Mar 5, 2026
c3606ae
Update interpolation_fields.py
nfarabullini Mar 5, 2026
890166a
replaced gt4py field operator within regular function to regular pyth…
nfarabullini Mar 5, 2026
81375ca
ran pre-commit
nfarabullini Mar 5, 2026
da60b19
Add domain sizes
msimberg Mar 5, 2026
5fb0b0e
small fix to bounds
nfarabullini Mar 6, 2026
6362e62
small fix to tuple
nfarabullini Mar 6, 2026
726fd50
fix to index
nfarabullini Mar 6, 2026
356f889
introduced array_ns instead of strict numpy computation in init_w
nfarabullini Mar 6, 2026
fd0c7f0
Remove rbf interpolation todo
msimberg Mar 6, 2026
b8fa94e
Merge remote-tracking branch 'origin/main' into halo_construction
msimberg Mar 6, 2026
b47aa03
edit from asnumpy() to ndarray
nfarabullini Mar 6, 2026
1869d03
additional edit from asnumpy() to ndarray
nfarabullini Mar 6, 2026
80f1fa9
Fix second halo level cell computation
msimberg Mar 6, 2026
e9fc3fd
Merge remote-tracking branch 'origin/main' into halo_construction
msimberg Mar 6, 2026
7b3e18a
potential fix
nfarabullini Mar 6, 2026
5305e2f
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Mar 6, 2026
182a843
Increase distributed CI pipeline timelimits
msimberg Mar 6, 2026
79d65f2
Allow None for halo_levels
msimberg Mar 6, 2026
5a6cc8e
Add more tests for test_compute_domain_bounds_for_global_grid
msimberg Mar 6, 2026
8efe35c
Enable grid data download in distributed pipeline
msimberg Mar 6, 2026
be614a0
potential fix
nfarabullini Mar 6, 2026
5fc92d8
Merge branch 'ci_for_standalone_driver' of https://github.com/C2SM/ic…
nfarabullini Mar 6, 2026
b6314b6
more edits
nfarabullini Mar 8, 2026
3b95f9b
more edits
nfarabullini Mar 8, 2026
b1386d2
removed serialized exit point from internal code
nfarabullini Mar 8, 2026
50ebb90
small edit to equation to see if this works with gpu backend
nfarabullini Mar 9, 2026
6642aa2
new for loop implementaed instead of array_ns.sum
nfarabullini Mar 9, 2026
26fd7db
edits to array_ns and ran pre-commit
nfarabullini Mar 9, 2026
53a2585
edits for offset declaration potential issue
nfarabullini Mar 9, 2026
d6d9f30
small edit to change args position
nfarabullini Mar 9, 2026
56f9cef
Add xfails for wrong halo, interior, local indices with torus grid
msimberg Mar 9, 2026
c6cf66b
Check INTERIOR indices with icon4py domain decomposition
msimberg Mar 9, 2026
301c041
Update ci/distributed.yml
msimberg Mar 9, 2026
d77f5d9
Less verbose xfail
msimberg Mar 9, 2026
37b196b
Download r01b01 grid in ci
msimberg Mar 9, 2026
39703b3
Enable download again
msimberg Mar 9, 2026
c958a6e
small fix to index
nfarabullini Mar 9, 2026
6df6af6
Disable download again
msimberg Mar 9, 2026
08cc652
small edits to offset provider spec
nfarabullini Mar 9, 2026
115aec8
Explicitly set ICON4PY_TEST_DATA_PATH in github workflows
msimberg Mar 9, 2026
f204644
More explicit path
msimberg Mar 9, 2026
0279054
added cpu only marker
nfarabullini Mar 9, 2026
dc339dc
Enable grid download for grid download step
msimberg Mar 9, 2026
fd6034a
ran pre-commit
nfarabullini Mar 9, 2026
de2f7a5
edited ci time
nfarabullini Mar 10, 2026
7a8118a
removed backend customization
nfarabullini Mar 10, 2026
83de5f4
ran pre-commit
nfarabullini Mar 10, 2026
fc0a445
Remove todos
msimberg Mar 10, 2026
accedb7
Merge branch 'halo_construction' into distributed_standalone_driver
jcanton Mar 10, 2026
125e26f
remove these two
jcanton Mar 10, 2026
2e52f15
adjusted ci time and removed cp only constraint
nfarabullini Mar 10, 2026
3c7e718
increased ci time
nfarabullini Mar 10, 2026
6e900f9
Merge branch 'main' into ci_for_standalone_driver
nfarabullini Mar 10, 2026
8b5a614
increased ci time
nfarabullini Mar 10, 2026
2a71be6
Merge branch 'main' into distributed_standalone_driver
jcanton Mar 10, 2026
b36637f
Merge branch 'ci_for_standalone_driver' of https://github.com/C2SM/ic…
nfarabullini Mar 10, 2026
7b097e2
Merge branch 'ci_for_standalone_driver' into distributed_standalone_d…
jcanton Mar 10, 2026
2b9c823
Merge branch 'ci_for_standalone_driver' into distributed_standalone_d…
jcanton Mar 10, 2026
9f9765f
Merge branch 'distributed-tests-dace-gpu' into distributed_standalone…
jcanton Mar 10, 2026
cae3aba
these changes don't belong here but why not
jcanton Mar 10, 2026
b3cab13
code refactoring
nfarabullini Mar 10, 2026
71ccba5
further code refactoring
nfarabullini Mar 10, 2026
0ed42b7
Merge remote-tracking branch 'origin/main' into distributed-tests-dac…
msimberg Mar 10, 2026
fbd9775
wip
jcanton Mar 10, 2026
bf47258
move check_local_global_fields to parallel_helpers
jcanton Mar 10, 2026
e154538
small fix
nfarabullini Mar 10, 2026
e9fd355
fix type warning
jcanton Mar 10, 2026
77e0fc4
parallel standalone driver?
jcanton Mar 10, 2026
2158b61
small fix
nfarabullini Mar 10, 2026
9ab2b09
small fix
nfarabullini Mar 10, 2026
f17d6ab
ran pre-commit
nfarabullini Mar 10, 2026
82ebba2
wip2
jcanton Mar 10, 2026
dacc75d
Merge branch 'ci_for_standalone_driver' into distributed_standalone_d…
jcanton Mar 10, 2026
51eab0c
Merge branch 'distributed-tests-dace-gpu' into distributed_standalone…
jcanton Mar 10, 2026
a25e6f7
gt4py hack
jcanton Mar 11, 2026
3ee4e96
comment init_w
jcanton Mar 11, 2026
acd2217
comment tracer adv
jcanton Mar 11, 2026
79e6a41
update test
jcanton Mar 11, 2026
b564899
more verbose testing
jcanton Mar 11, 2026
9e2dbd7
no default exchange
jcanton Mar 11, 2026
3a5f51d
no single rank defaults
jcanton Mar 11, 2026
437c6c7
exchange to IC
jcanton Mar 11, 2026
1874a54
no need for dim prints
jcanton Mar 11, 2026
fd9f493
Add halo exchanges for jw initial condition
msimberg Mar 11, 2026
888c1ae
Remove unnecessary functools.partial
msimberg Mar 11, 2026
054b7ba
Add parallel jablonowski williamson initial condition test
msimberg Mar 11, 2026
f25e3e5
Slight cleanup
msimberg Mar 11, 2026
720e48f
add SingleNodeExchange warnings
jcanton Mar 11, 2026
87a23c5
remove unnecessary array_ns, we have the backend and xp from that
jcanton Mar 11, 2026
86e600b
fix typer
jcanton Mar 11, 2026
a38072b
update warning message
jcanton Mar 11, 2026
4f24d9b
forgot to remove from here
jcanton Mar 11, 2026
d1e5076
cleanup and wip on distributed serdata test
jcanton Mar 11, 2026
bab3d58
Add back assertions to local/global field checks
msimberg Mar 11, 2026
6a65619
add wip multi-rank ser_data test
jcanton Mar 11, 2026
552c118
wip2
jcanton Mar 11, 2026
f295368
I need this back
jcanton Mar 11, 2026
b4b20cb
add UV to IC test
jcanton Mar 12, 2026
45eb7f2
Fix halo exchanges for diagnostic state
msimberg Mar 16, 2026
a57d8f4
pick from #1012
jcanton Mar 18, 2026
5c15dd6
Merge branch 'main' into distributed_standalone_driver
jcanton Mar 19, 2026
db1dc99
restore some from main
jcanton Mar 19, 2026
758b96b
Try to restore exchanges to distributed standalone driver
msimberg Mar 19, 2026
5b126f7
Add missing exchange
msimberg Mar 20, 2026
3e1bb55
Comment out part of initial conditions for now
msimberg Mar 20, 2026
76a426e
Allow passing atol to check_local_global_fields
msimberg Mar 20, 2026
5107aa4
Use ghex release
msimberg Mar 20, 2026
e440a53
cupy/numpy compat
msimberg Mar 20, 2026
cfe8147
put back SingleNodeExchange defaults
jcanton Mar 20, 2026
88e97da
back to main for diffusion.py
jcanton Mar 20, 2026
81e3a1f
a couple more cleanups
jcanton Mar 20, 2026
f62de4a
put this back too
jcanton Mar 20, 2026
a4921e9
Merge branch 'main' into distributed_standalone_driver
jcanton Mar 25, 2026
29ea0b3
update uv.lock
jcanton Mar 25, 2026
9fc348b
small edit to fix init_w issue and ran pre-commit
nfarabullini Mar 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
import dataclasses
import functools
import logging
import warnings
from collections.abc import Sequence
from enum import Enum
from types import ModuleType
from typing import Any, Literal, Protocol, TypeAlias, overload, runtime_checkable
from typing import Any, ClassVar, Literal, Protocol, TypeAlias, overload, runtime_checkable

import dace # type: ignore[import-untyped]
import gt4py.next as gtx
Expand Down Expand Up @@ -408,12 +409,25 @@ def __str__(self) -> str:

@dataclasses.dataclass
class SingleNodeExchange(ExchangeRuntime):
_warning_emitted: ClassVar[bool] = False

@classmethod
def _warn_if_used(cls, *, stacklevel: int = 3) -> None:
if not cls._warning_emitted:
warnings.warn(
"***** SingleNodeExchange is in use; HALO EXCHANGE IS RUNNING IN SINGLE-NODE *****",
RuntimeWarning,
stacklevel=stacklevel,
)
cls._warning_emitted = True
Comment on lines +412 to +422
Copy link
Contributor Author

@jcanton jcanton Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: remove before merging? or disable somehow? talk with @msimberg


def start(
self,
dim: gtx.Dimension,
*fields: gtx.Field | data_alloc.NDArray,
stream: StreamLike = DEFAULT_STREAM,
) -> ExchangeResult:
self._warn_if_used()
return SingleNodeResult()

def my_rank(self) -> int:
Expand Down
4 changes: 2 additions & 2 deletions model/common/src/icon4py/model/common/grid/grid_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def __call__(
allocator: gtx_typing.Allocator | None,
keep_skip_values: bool,
decomposer: decomp.Decomposer = _single_node_decomposer,
run_properties=_single_process_props,
):
run_properties: decomposition.ProcessProperties = _single_process_props,
) -> None:
if not run_properties.is_single_rank() and isinstance(
decomposer, decomp.SingleNodeDecomposer
):
Expand Down
11 changes: 5 additions & 6 deletions model/common/src/icon4py/model/common/grid/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@
#
# Please, refer to the LICENSE file in the root directory.
# SPDX-License-Identifier: BSD-3-Clause
from types import ModuleType

import numpy as np

from icon4py.model.common.grid import gridfile


def revert_repeated_index_to_invalid(offset: np.ndarray, array_ns: ModuleType):
def revert_repeated_index_to_invalid(offset: np.ndarray):
num_elements = offset.shape[0]
for i in range(num_elements):
# convert repeated indices back into -1
for val in array_ns.flip(offset[i, :]):
if array_ns.count_nonzero(val == offset[i, :]) > 1:
unique_values, counts = array_ns.unique(offset[i, :], return_counts=True)
for val in np.flip(offset[i, :]):
if np.count_nonzero(val == offset[i, :]) > 1:
unique_values, counts = np.unique(offset[i, :], return_counts=True)
rep_values = unique_values[counts > 1]
rep_indices = array_ns.where(array_ns.isin(offset[i, :], rep_values))[0]
rep_indices = np.where(np.isin(offset[i, :], rep_values))[0]
offset[i, rep_indices[1:]] = gridfile.GridFile.INVALID_INDEX
return offset
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ def test_exchange_on_dummy_data(

@pytest.mark.mpi
@pytest.mark.datatest
@pytest.mark.embedded_only
@pytest.mark.parametrize("processor_props", [False], indirect=True)
def test_halo_exchange_for_sparse_field(
interpolation_savepoint: serialbox.InterpolationSavepoint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
# Please, refer to the LICENSE file in the root directory.
# SPDX-License-Identifier: BSD-3-Clause

import sys
import warnings

import gt4py.next as gtx
import numpy as np
import pytest
from gt4py.next import common as gtx_common

import icon4py.model.common.dimension as dims
import icon4py.model.common.utils.data_allocation as data_alloc
from icon4py.model.common import dimension as dims
from icon4py.model.common.decomposition import definitions
from icon4py.model.common.decomposition.definitions import (
DecompositionInfo,
Expand Down Expand Up @@ -94,3 +98,57 @@ def test_decomposition_info_is_distributed(flag, expected) -> None:
np.ones((mesh.num_cells,)) * flag,
)
assert decomp.is_distributed() == expected


def test_single_node_exchange_warns_on_first_use(monkeypatch):
monkeypatch.setattr(SingleNodeExchange, "_warning_emitted", False)

exchange = SingleNodeExchange()

with pytest.warns(RuntimeWarning, match="SingleNodeExchange"):
exchange.start(dims.CellDim)


def test_single_node_exchange_does_not_warn_on_construction_or_repeat_use(monkeypatch):
monkeypatch.setattr(SingleNodeExchange, "_warning_emitted", False)

with warnings.catch_warnings(record=True) as recorded_warnings:
warnings.simplefilter("always")
exchange = SingleNodeExchange()

assert len(recorded_warnings) == 0

with pytest.warns(RuntimeWarning, match="SingleNodeExchange"):
exchange.exchange(dims.CellDim)

with warnings.catch_warnings(record=True) as repeated_warnings:
warnings.simplefilter("always")
exchange.start(dims.CellDim)

assert len(repeated_warnings) == 0


def _assert_warning_points_to_call_site(monkeypatch, func, expected_line):
monkeypatch.setattr(SingleNodeExchange, "_warning_emitted", False)

with warnings.catch_warnings(record=True) as caught_warnings:
warnings.simplefilter("always")
func()

assert len(caught_warnings) == 1
assert caught_warnings[0].filename == __file__
assert caught_warnings[0].lineno == expected_line


def test_single_node_exchange_warning_points_to_call_site(monkeypatch):
exchange = SingleNodeExchange()

exchange_line = sys._getframe().f_lineno + 1
_assert_warning_points_to_call_site(
monkeypatch, lambda: exchange.start(dims.CellDim), exchange_line
)

wait_line = sys._getframe().f_lineno + 1
_assert_warning_points_to_call_site(
monkeypatch, lambda: exchange.exchange(dims.CellDim), wait_line
)
118 changes: 9 additions & 109 deletions model/common/tests/common/grid/mpi_tests/test_parallel_grid_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
#
# Please, refer to the LICENSE file in the root directory.
# SPDX-License-Identifier: BSD-3-Clause
import functools
import logging
import operator

import numpy as np
import pytest
Expand All @@ -33,7 +31,7 @@
from icon4py.model.common.metrics import metrics_attributes, metrics_factory
from icon4py.model.common.states import utils as state_utils
from icon4py.model.common.utils import data_allocation as data_alloc
from icon4py.model.testing import definitions as test_defs, grid_utils, test_utils
from icon4py.model.testing import definitions as test_defs, grid_utils, parallel_helpers, test_utils
from icon4py.model.testing.fixtures.datatest import (
backend,
experiment,
Expand All @@ -57,7 +55,7 @@ def test_grid_manager_validate_decomposer(
processor_props: decomp_defs.ProcessProperties,
experiment: test_defs.Experiment,
) -> None:
if experiment == test_defs.Experiments.MCH_CH_R04B09:
if experiment.grid.params.limited_area:
pytest.xfail("Limited-area grids not yet supported")

file = grid_utils.resolve_full_grid_file_name(experiment.grid)
Expand Down Expand Up @@ -85,104 +83,6 @@ def _get_neighbor_tables(grid: base.Grid) -> dict:
}


def gather_field(field: np.ndarray, props: decomp_defs.ProcessProperties) -> tuple:
constant_dims = tuple(field.shape[1:])
_log.info(f"gather_field on rank={props.rank} - gathering field of local shape {field.shape}")
# Because of sparse indexing the field may have a non-contigous layout,
# which Gatherv doesn't support. Make sure the field is contiguous.
field = np.ascontiguousarray(field)
constant_length = functools.reduce(operator.mul, constant_dims, 1)
local_sizes = np.array(props.comm.gather(field.size, root=0))
if props.rank == 0:
recv_buffer = np.empty(np.sum(local_sizes), dtype=field.dtype)
_log.info(
f"gather_field on rank = {props.rank} - setup receive buffer with size {sum(local_sizes)} on rank 0"
)
else:
recv_buffer = None

props.comm.Gatherv(sendbuf=field, recvbuf=(recv_buffer, local_sizes), root=0)
if props.rank == 0:
local_first_dim = tuple(sz // constant_length for sz in local_sizes)
_log.info(
f" gather_field on rank = 0: computed local dims {local_first_dim} - constant dims {constant_dims}"
)
gathered_field = recv_buffer.reshape((-1, *constant_dims)) # type: ignore [union-attr]
else:
gathered_field = None
local_first_dim = field.shape
return local_first_dim, gathered_field


def check_local_global_field(
decomposition_info: decomp_defs.DecompositionInfo,
processor_props: decomp_defs.ProcessProperties, # F811 # fixture
dim: gtx.Dimension,
global_reference_field: np.ndarray,
local_field: np.ndarray,
check_halos: bool,
) -> None:
if dim == dims.KDim:
test_utils.assert_dallclose(global_reference_field, local_field)
return

_log.info(
f" rank= {processor_props.rank}/{processor_props.comm_size}----exchanging field of main dim {dim}"
)
assert (
local_field.shape[0]
== decomposition_info.global_index(dim, decomp_defs.DecompositionInfo.EntryType.ALL).shape[
0
]
)

# Compare halo against global reference field
if check_halos:
test_utils.assert_dallclose(
global_reference_field[
decomposition_info.global_index(dim, decomp_defs.DecompositionInfo.EntryType.HALO)
],
local_field[
decomposition_info.local_index(dim, decomp_defs.DecompositionInfo.EntryType.HALO)
],
atol=1e-9,
verbose=True,
)

# Compare owned local field, excluding halos, against global reference
# field, by gathering owned entries to the first rank. This ensures that in
# total we have the full global field distributed on all ranks.
owned_entries = local_field[
decomposition_info.local_index(dim, decomp_defs.DecompositionInfo.EntryType.OWNED)
]
gathered_sizes, gathered_field = gather_field(owned_entries, processor_props)

global_index_sizes, gathered_global_indices = gather_field(
decomposition_info.global_index(dim, decomp_defs.DecompositionInfo.EntryType.OWNED),
processor_props,
)

if processor_props.rank == 0:
_log.info(f"rank = {processor_props.rank}: asserting gathered fields: ")

assert np.all(
gathered_sizes == global_index_sizes
), f"gathered field sizes do not match: {dim} {gathered_sizes} - {global_index_sizes}"
_log.info(
f"rank = {processor_props.rank}: Checking field size on dim ={dim}: --- gathered sizes {gathered_sizes} = {sum(gathered_sizes)}"
)
_log.info(
f"rank = {processor_props.rank}: --- gathered field has size {gathered_sizes}"
)
sorted_ = np.zeros(global_reference_field.shape, dtype=gtx.float64) # type: ignore [attr-defined]
sorted_[gathered_global_indices] = gathered_field
_log.info(
f" rank = {processor_props.rank}: SHAPES: global reference field {global_reference_field.shape}, gathered = {gathered_field.shape}"
)

test_utils.assert_dallclose(sorted_, global_reference_field, atol=1e-9, verbose=True)


# These fields can't be computed with the embedded backend for one reason or
# another, so we declare them here for xfailing.
embedded_broken_fields = {
Expand Down Expand Up @@ -316,7 +216,7 @@ def test_geometry_fields_compare_single_multi_rank(
field = multi_rank_geometry.get(attrs_name)
dim = field_ref.domain.dims[0]

check_local_global_field(
parallel_helpers.check_local_global_field(
decomposition_info=multi_rank_grid_manager.decomposition_info,
processor_props=processor_props,
dim=dim,
Expand Down Expand Up @@ -361,7 +261,7 @@ def test_interpolation_fields_compare_single_multi_rank(
experiment: test_defs.Experiment,
attrs_name: str,
) -> None:
if experiment == test_defs.Experiments.MCH_CH_R04B09:
if experiment.grid.params.limited_area:
pytest.xfail("Limited-area grids not yet supported")

if attrs_name in embedded_broken_fields and test_utils.is_embedded(backend):
Expand Down Expand Up @@ -430,7 +330,7 @@ def test_interpolation_fields_compare_single_multi_rank(
field = multi_rank_interpolation.get(attrs_name)
dim = field_ref.domain.dims[0]

check_local_global_field(
parallel_helpers.check_local_global_field(
decomposition_info=multi_rank_grid_manager.decomposition_info,
processor_props=processor_props,
dim=dim,
Expand Down Expand Up @@ -503,7 +403,7 @@ def test_metrics_fields_compare_single_multi_rank(
experiment: test_defs.Experiment,
attrs_name: str,
) -> None:
if experiment == test_defs.Experiments.MCH_CH_R04B09:
if experiment.grid.params.limited_area:
pytest.xfail("Limited-area grids not yet supported")

if attrs_name in embedded_broken_fields and test_utils.is_embedded(backend):
Expand Down Expand Up @@ -660,7 +560,7 @@ def test_metrics_fields_compare_single_multi_rank(
assert isinstance(field, state_utils.ScalarType)
assert pytest.approx(field) == field_ref
else:
check_local_global_field(
parallel_helpers.check_local_global_field(
decomposition_info=multi_rank_grid_manager.decomposition_info,
processor_props=processor_props,
dim=field_ref.domain.dims[0],
Expand All @@ -682,7 +582,7 @@ def test_metrics_mask_prog_halo_c(
backend: gtx_typing.Backend | None,
experiment: test_defs.Experiment,
) -> None:
if experiment == test_defs.Experiments.MCH_CH_R04B09:
if experiment.grid.params.limited_area:
pytest.xfail("Limited-area grids not yet supported")

file = grid_utils.resolve_full_grid_file_name(experiment.grid)
Expand Down Expand Up @@ -813,7 +713,7 @@ def test_validate_skip_values_in_distributed_connectivities(
processor_props: decomp_defs.ProcessProperties,
experiment: test_defs.Experiment,
) -> None:
if experiment == test_defs.Experiments.MCH_CH_R04B09:
if experiment.grid.params.limited_area:
pytest.xfail("Limited-area grids not yet supported")

file = grid_utils.resolve_full_grid_file_name(experiment.grid)
Expand Down
Loading