From 0b113cb1c621ee69b873f9fd785c857bac99994e Mon Sep 17 00:00:00 2001 From: edopao Date: Thu, 7 Mar 2024 19:24:00 +0100 Subject: [PATCH] Enable test on local-area icon grid (#407) --- ci/benchmark.yml | 2 +- ci/dace.yml | 39 ++++++++++--------- ci/default.yml | 22 +++++++---- ...test_apply_diffusion_to_theta_and_exner.py | 6 +++ .../test_apply_diffusion_to_vn.py | 6 +++ .../test_calculate_nabla2_for_z.py | 6 +++ ...sed_velocity_advection_stencil_19_to_20.py | 6 +++ ...fused_velocity_advection_stencil_1_to_7.py | 5 +++ .../src/icon4py/model/common/grid/base.py | 1 - .../src/icon4py/model/common/grid/utils.py | 8 +--- 10 files changed, 65 insertions(+), 36 deletions(-) diff --git a/ci/benchmark.yml b/ci/benchmark.yml index 03db9fbfd3..b3bfff0744 100644 --- a/ci/benchmark.yml +++ b/ci/benchmark.yml @@ -4,7 +4,7 @@ include: build: extends: .build_template -benchmark_model_icon_grid: +benchmark_model_stencils: extends: .test_template stage: benchmark script: diff --git a/ci/dace.yml b/ci/dace.yml index 267598294e..15ffffeff1 100644 --- a/ci/dace.yml +++ b/ci/dace.yml @@ -7,23 +7,24 @@ variables: build: extends: .build_template -test_model_simple_grid: - extends: .test_template - stage: test - script: - - pip install dace==$DACE_VERSION - - tox -r -e run_stencil_tests -c model/ -- --backend=$BACKEND --verbose - parallel: - matrix: - - BACKEND: [dace_cpu, dace_gpu] +test_model_stencils: + extends: .test_template + stage: test + script: + - pip install dace==$DACE_VERSION + - tox -r -e run_stencil_tests -c model/ -- --backend=$BACKEND --grid=$GRID --verbose + parallel: + matrix: + - BACKEND: [dace_cpu, dace_gpu] + GRID: [simple_grid, icon_grid] -benchmark_model_icon_grid: - extends: .test_template - stage: benchmark - script: - - pip install dace==$DACE_VERSION - - tox -r -e run_benchmarks -c model/ -- --backend=$BACKEND --grid=$GRID --verbose - parallel: - matrix: - - BACKEND: [dace_cpu, dace_gpu] - GRID: [icon_grid, icon_grid_global] +benchmark_model_stencils: + extends: .test_template + stage: benchmark + script: + - pip install dace==$DACE_VERSION + - tox -r -e run_benchmarks -c model/ -- --backend=$BACKEND --grid=$GRID --verbose + parallel: + matrix: + - BACKEND: [dace_cpu, dace_gpu] + GRID: [icon_grid, icon_grid_global] diff --git a/ci/default.yml b/ci/default.yml index c99b71768a..2eed087173 100644 --- a/ci/default.yml +++ b/ci/default.yml @@ -4,14 +4,20 @@ include: build: extends: .build_template -test_model_simple_grid: - extends: .test_template - stage: test - script: - - tox -r -e run_stencil_tests -c model/ --verbose -- --backend=$BACKEND - parallel: - matrix: - - BACKEND: [gtfn_cpu, gtfn_gpu, roundtrip] +test_model_stencils: + extends: .test_template + stage: test + script: + - tox -r -e run_stencil_tests -c model/ -- --backend=$BACKEND --grid=$GRID --verbose + parallel: + matrix: + - BACKEND: [gtfn_cpu, gtfn_gpu, roundtrip] + GRID: [simple_grid, icon_grid] + rules: + # exclude slow test configurations + - if: $BACKEND == "roundtrip" && $GRID == "icon_grid" + when: never + - when: always test_tools: extends: .test_template diff --git a/model/atmosphere/diffusion/tests/diffusion_stencil_tests/test_apply_diffusion_to_theta_and_exner.py b/model/atmosphere/diffusion/tests/diffusion_stencil_tests/test_apply_diffusion_to_theta_and_exner.py index fa1e392aa0..8733253480 100644 --- a/model/atmosphere/diffusion/tests/diffusion_stencil_tests/test_apply_diffusion_to_theta_and_exner.py +++ b/model/atmosphere/diffusion/tests/diffusion_stencil_tests/test_apply_diffusion_to_theta_and_exner.py @@ -19,6 +19,7 @@ apply_diffusion_to_theta_and_exner, ) from icon4py.model.common.dimension import C2E2CDim, CECDim, CEDim, CellDim, EdgeDim, KDim +from icon4py.model.common.grid.icon import IconGrid from icon4py.model.common.test_utils.helpers import ( StencilTest, flatten_first_two_dims, @@ -82,6 +83,11 @@ def reference( @pytest.fixture def input_data(self, grid): + if isinstance(grid, IconGrid) and grid.limited_area: + pytest.xfail( + "Execution domain needs to be restricted or boundary taken into account in stencil." + ) + kh_smag_e = random_field(grid, EdgeDim, KDim) inv_dual_edge_length = random_field(grid, EdgeDim) theta_v_in = random_field(grid, CellDim, KDim) diff --git a/model/atmosphere/diffusion/tests/diffusion_stencil_tests/test_apply_diffusion_to_vn.py b/model/atmosphere/diffusion/tests/diffusion_stencil_tests/test_apply_diffusion_to_vn.py index 7c53e90c99..74972cb73c 100644 --- a/model/atmosphere/diffusion/tests/diffusion_stencil_tests/test_apply_diffusion_to_vn.py +++ b/model/atmosphere/diffusion/tests/diffusion_stencil_tests/test_apply_diffusion_to_vn.py @@ -18,6 +18,7 @@ from icon4py.model.atmosphere.diffusion.stencils.apply_diffusion_to_vn import apply_diffusion_to_vn from icon4py.model.atmosphere.dycore.state_utils.utils import indices_field from icon4py.model.common.dimension import E2C2VDim, ECVDim, EdgeDim, KDim, VertexDim +from icon4py.model.common.grid.icon import IconGrid from icon4py.model.common.test_utils.helpers import StencilTest, as_1D_sparse_field, random_field from .test_apply_nabla2_and_nabla4_global_to_vn import apply_nabla2_and_nabla4_global_to_vn_numpy @@ -98,6 +99,11 @@ def reference( @pytest.fixture def input_data(self, grid): + if isinstance(grid, IconGrid) and grid.limited_area: + pytest.xfail( + "Execution domain needs to be restricted or boundary taken into account in stencil." + ) + edge = indices_field(EdgeDim, grid, is_halfdim=False, dtype=int32) u_vert = random_field(grid, VertexDim, KDim) diff --git a/model/atmosphere/diffusion/tests/diffusion_stencil_tests/test_calculate_nabla2_for_z.py b/model/atmosphere/diffusion/tests/diffusion_stencil_tests/test_calculate_nabla2_for_z.py index 187816b6de..2f062d616d 100644 --- a/model/atmosphere/diffusion/tests/diffusion_stencil_tests/test_calculate_nabla2_for_z.py +++ b/model/atmosphere/diffusion/tests/diffusion_stencil_tests/test_calculate_nabla2_for_z.py @@ -19,6 +19,7 @@ calculate_nabla2_for_z, ) from icon4py.model.common.dimension import CellDim, E2CDim, EdgeDim, KDim +from icon4py.model.common.grid.icon import IconGrid from icon4py.model.common.test_utils.helpers import StencilTest, random_field from icon4py.model.common.type_alias import vpfloat, wpfloat @@ -55,6 +56,11 @@ def reference( @pytest.fixture def input_data(self, grid): + if isinstance(grid, IconGrid) and grid.limited_area: + pytest.xfail( + "Execution domain needs to be restricted or boundary taken into account in stencil." + ) + kh_smag_e = random_field(grid, EdgeDim, KDim, dtype=vpfloat) inv_dual_edge_length = random_field(grid, EdgeDim, dtype=wpfloat) theta_v = random_field(grid, CellDim, KDim, dtype=wpfloat) diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_19_to_20.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_19_to_20.py index 80e541dde2..4e61e846f6 100644 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_19_to_20.py +++ b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_19_to_20.py @@ -28,6 +28,7 @@ V2EDim, VertexDim, ) +from icon4py.model.common.grid.icon import IconGrid from icon4py.model.common.test_utils.helpers import ( StencilTest, as_1D_sparse_field, @@ -121,6 +122,11 @@ def reference( @pytest.fixture def input_data(self, grid): + if isinstance(grid, IconGrid) and grid.limited_area: + pytest.xfail( + "Execution domain needs to be restricted or boundary taken into account in stencil." + ) + z_kin_hor_e = random_field(grid, EdgeDim, KDim) coeff_gradekin = random_field(grid, EdgeDim, E2CDim) coeff_gradekin_new = as_1D_sparse_field(coeff_gradekin, ECDim) diff --git a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_1_to_7.py b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_1_to_7.py index e50c452e7f..a3883c57a5 100644 --- a/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_1_to_7.py +++ b/model/atmosphere/dycore/tests/dycore_stencil_tests/test_fused_velocity_advection_stencil_1_to_7.py @@ -20,6 +20,7 @@ ) from icon4py.model.atmosphere.dycore.state_utils.utils import indices_field from icon4py.model.common.dimension import CellDim, E2C2EDim, EdgeDim, KDim, V2CDim, VertexDim +from icon4py.model.common.grid.icon import IconGrid from icon4py.model.common.test_utils.helpers import StencilTest, random_field, zero_field from .test_compute_contravariant_correction import compute_contravariant_correction_numpy @@ -207,6 +208,10 @@ def input_data(self, grid): pytest.skip( "Verification of z_v_grad_w currently not working, because numpy version incorrect." ) + if isinstance(grid, IconGrid) and grid.limited_area: + pytest.xfail( + "Execution domain needs to be restricted or boundary taken into account in stencil." + ) c_intp = random_field(grid, VertexDim, V2CDim) vn = random_field(grid, EdgeDim, KDim) diff --git a/model/common/src/icon4py/model/common/grid/base.py b/model/common/src/icon4py/model/common/grid/base.py index 69dd2a3e86..1373c9c25b 100644 --- a/model/common/src/icon4py/model/common/grid/base.py +++ b/model/common/src/icon4py/model/common/grid/base.py @@ -143,7 +143,6 @@ def _get_offset_provider_for_sparse_fields(self, dim, from_dim, to_dim): self.connectivities[dim].shape, from_dim, to_dim, - on_gpu=self.config.on_gpu, has_skip_values=self._has_skip_values(dim), ) diff --git a/model/common/src/icon4py/model/common/grid/utils.py b/model/common/src/icon4py/model/common/grid/utils.py index 37c54dd687..840d60f32e 100644 --- a/model/common/src/icon4py/model/common/grid/utils.py +++ b/model/common/src/icon4py/model/common/grid/utils.py @@ -19,15 +19,9 @@ def neighbortable_offset_provider_for_1d_sparse_fields( old_shape: tuple[int, int], origin_axis: Dimension, neighbor_axis: Dimension, - on_gpu: bool, has_skip_values: bool, ): - if on_gpu: - import cupy as xp - else: - xp = np - - table = xp.arange(old_shape[0] * old_shape[1]).reshape(old_shape) + table = np.arange(old_shape[0] * old_shape[1]).reshape(old_shape) return NeighborTableOffsetProvider( table, origin_axis,