Skip to content

Commit

Permalink
Enable test on local-area icon grid (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
edopao authored Mar 7, 2024
1 parent dcb6ac9 commit 0b113cb
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 36 deletions.
2 changes: 1 addition & 1 deletion ci/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include:
build:
extends: .build_template

benchmark_model_icon_grid:
benchmark_model_stencils:
extends: .test_template
stage: benchmark
script:
Expand Down
39 changes: 20 additions & 19 deletions ci/dace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
22 changes: 14 additions & 8 deletions ci/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion model/common/src/icon4py/model/common/grid/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)

Expand Down
8 changes: 1 addition & 7 deletions model/common/src/icon4py/model/common/grid/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0b113cb

Please sign in to comment.