Skip to content

Commit

Permalink
Remove test fixture for OTF backends (#403)
Browse files Browse the repository at this point in the history
Remove test fixture for OTF backends. The reason for test failure is not in the backend but in the numpy validation code, which does not work with local-area grids.
  • Loading branch information
edopao authored Mar 7, 2024
1 parent 59e757f commit dcb6ac9
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 56 deletions.
3 changes: 2 additions & 1 deletion ci/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ benchmark_model_icon_grid:
extends: .test_template
stage: benchmark
script:
- tox -r -e run_benchmarks -c model/ -- --backend=$BACKEND --grid=icon_grid_global --verbose
- tox -r -e run_benchmarks -c model/ -- --backend=$BACKEND --grid=$GRID --verbose
parallel:
matrix:
- BACKEND: [gtfn_cpu, gtfn_gpu]
GRID: [icon_grid, icon_grid_global]
3 changes: 2 additions & 1 deletion ci/dace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ benchmark_model_icon_grid:
stage: benchmark
script:
- pip install dace==$DACE_VERSION
- tox -r -e run_benchmarks -c model/ -- --backend=$BACKEND --grid=icon_grid_global --verbose
- 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]
1 change: 0 additions & 1 deletion model/atmosphere/diffusion/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@
)
from icon4py.model.common.test_utils.helpers import ( # noqa : F401 # fixtures from test_utils
backend,
uses_local_area_icon_grid_with_otf,
)
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,7 @@ def reference(
return dict(theta_v=theta_v, exner=exner)

@pytest.fixture
def input_data(self, grid, uses_local_area_icon_grid_with_otf):
if uses_local_area_icon_grid_with_otf:
pytest.skip(
"Execution domain needs to be restricted or boundary taken into account in stencil."
)

def input_data(self, grid):
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 @@ -97,12 +97,7 @@ def reference(
return dict(vn=vn)

@pytest.fixture
def input_data(self, grid, uses_local_area_icon_grid_with_otf):
if uses_local_area_icon_grid_with_otf:
pytest.skip(
"Execution domain needs to be restricted or boundary taken into account in stencil."
)

def input_data(self, grid):
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 @@ -54,12 +54,7 @@ def reference(
return dict(z_nabla2_e=z_nabla2_e)

@pytest.fixture
def input_data(self, grid, uses_local_area_icon_grid_with_otf):
if uses_local_area_icon_grid_with_otf:
pytest.skip(
"Execution domain needs to be restricted or boundary taken into account in stencil."
)

def input_data(self, grid):
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
1 change: 0 additions & 1 deletion model/atmosphere/dycore/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@
)
from icon4py.model.common.test_utils.helpers import ( # noqa : F401 # fixtures from test_utils
backend,
uses_local_area_icon_grid_with_otf,
)
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,7 @@ def reference(
return dict(ddt_vn_apc=ddt_vn_apc)

@pytest.fixture
def input_data(self, grid, uses_local_area_icon_grid_with_otf):
if uses_local_area_icon_grid_with_otf:
pytest.skip(
"Execution domain needs to be restricted or boundary taken into account in stencil."
)

def input_data(self, grid):
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 @@ -203,14 +203,10 @@ def reference(
)

@pytest.fixture
def input_data(self, grid, uses_local_area_icon_grid_with_otf):
def input_data(self, grid):
pytest.skip(
"Verification of z_v_grad_w currently not working, because numpy version incorrect."
)
if uses_local_area_icon_grid_with_otf:
pytest.skip(
"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
23 changes: 0 additions & 23 deletions model/common/src/icon4py/model/common/test_utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from gt4py.next.ffront.decorator import Program

from ..grid.base import BaseGrid
from ..grid.icon import IconGrid
from ..type_alias import wpfloat


Expand Down Expand Up @@ -246,27 +245,5 @@ def __init_subclass__(cls, **kwargs):
setattr(cls, f"test_{cls.__name__}_benchmark", _test_execution_benchmark)


@pytest.fixture
def uses_local_area_icon_grid_with_otf(backend, grid):
"""Check whether we are using a compiled backend with a limited_area icon_grid.
Is needed to skip certain stencils where the execution domain needs to be restricted or boundary taken into account.
"""
if hasattr(backend, "executor") and isinstance(grid, IconGrid):
if grid.limited_area:
if isinstance(
backend.executor, gt4py.next.program_processors.modular_executor.ModularExecutor
):
return True
try:
from gt4py.next.program_processors.runners import dace_iterator

if backend in {dace_iterator.run_dace_cpu, dace_iterator.run_dace_gpu}:
return True
except ImportError:
pass
return False


def reshape(arr: np.array, shape: tuple[int, ...]):
return np.reshape(arr, shape)

0 comments on commit dcb6ac9

Please sign in to comment.