Skip to content

Commit

Permalink
set limited_area correctly for experiments (#434)
Browse files Browse the repository at this point in the history
Fix for test execution on ICON global grids:
* set limited_area correctly for experiments
* Force benchmark execution on xfail tests
* Update gt4py stable version

---------

Co-authored-by: Edoardo Paone <[email protected]>
  • Loading branch information
2 people authored and iomaganaris committed Jun 18, 2024
1 parent 4f54dd5 commit 4eb7d42
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 14 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_stencils:
extends: .test_template
stage: benchmark
script:
- tox -r -e run_benchmarks -c model/ -- --backend=$BACKEND --grid=$GRID --verbose
# force execution of tests where validation is expected to fail, because the reason for failure is wrong numpy reference
- tox -r -e run_benchmarks -c model/ -- --backend=$BACKEND --grid=$GRID --runxfail --verbose
parallel:
matrix:
- BACKEND: [gtfn_cpu, gtfn_gpu]
Expand Down
3 changes: 2 additions & 1 deletion ci/dace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ benchmark_model_stencils:
# TODO(edopao): wait for next dace release to fix the inline_sdfgs simplify step
# - pip install dace==$DACE_VERSION
- pip install git+https://github.com/spcl/dace.git@$DACE_VERSION
- tox -r -e run_benchmarks -c model/ -- --backend=$BACKEND --grid=$GRID --verbose
# force execution of tests where validation is expected to fail, because the reason for failure is wrong numpy reference
- tox -r -e run_benchmarks -c model/ -- --backend=$BACKEND --grid=$GRID --runxfail --verbose
parallel:
matrix:
- BACKEND: [dace_cpu, dace_gpu]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def reference(

@pytest.fixture
def input_data(self, grid):
pytest.skip(
pytest.xfail(
"Verification of z_v_grad_w currently not working, because numpy version incorrect."
)
if isinstance(grid, IconGrid) and grid.limited_area:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def reference(

@pytest.fixture
def input_data(self, grid):
pytest.skip(
pytest.xfail(
"Verification of w_concorr_c currently not working, because numpy version is incorrect."
)
z_kin_hor_e = random_field(grid, EdgeDim, KDim)
Expand Down
17 changes: 11 additions & 6 deletions model/common/src/icon4py/model/common/grid/grid_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ def __init__(
self._grid: Optional[IconGrid] = None
self._file_name = grid_file

def __call__(self, on_gpu: bool = False):
def __call__(self, on_gpu: bool = False, limited_area=True):
dataset = self._read_gridfile(self._file_name)
_, grid = self._constuct_grid(dataset, on_gpu=on_gpu)
_, grid = self._constuct_grid(dataset, on_gpu=on_gpu, limited_area=limited_area)
self._grid = grid

def _read_gridfile(self, fname: str) -> Dataset:
Expand Down Expand Up @@ -330,9 +330,11 @@ def _get_index(self, dim: Dimension, start_marker: int, index_dict):
self._log.error(msg)
raise IconGridError(msg) from err

def _constuct_grid(self, dataset: Dataset, on_gpu: bool) -> tuple[UUID, IconGrid]:
def _constuct_grid(
self, dataset: Dataset, on_gpu: bool, limited_area: bool
) -> tuple[UUID, IconGrid]:
grid_id = UUID(dataset.getncattr(GridFile.PropertyName.GRID_ID))
return grid_id, self._from_grid_dataset(dataset, on_gpu=on_gpu)
return grid_id, self._from_grid_dataset(dataset, on_gpu=on_gpu, limited_area=limited_area)

def get_size(self, dim: Dimension):
if dim == VertexDim:
Expand All @@ -358,7 +360,7 @@ def _get_index_field(
field = field + self._transformation.get_offset_for_index_field(field)
return field

def _from_grid_dataset(self, dataset: Dataset, on_gpu: bool) -> IconGrid:
def _from_grid_dataset(self, dataset: Dataset, on_gpu: bool, limited_area=True) -> IconGrid:
reader = GridFile(dataset)
num_cells = reader.dimension(GridFile.DimensionName.CELL_NAME)
num_edges = reader.dimension(GridFile.DimensionName.EDGE_NAME)
Expand Down Expand Up @@ -390,7 +392,10 @@ def _from_grid_dataset(self, dataset: Dataset, on_gpu: bool) -> IconGrid:
) = self._read_grid_refinement_information(dataset)

config = GridConfig(
horizontal_config=grid_size, vertical_config=self._config, on_gpu=on_gpu
horizontal_config=grid_size,
vertical_config=self._config,
on_gpu=on_gpu,
limited_area=limited_area,
)
icon_grid = (
IconGrid()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,23 @@ def get_icon_grid_from_gridfile(experiment: str, on_gpu: bool = False) -> IconGr
"icon_grid_0013_R02B04_R.nc",
num_levels=GLOBAL_NUM_LEVELS,
on_gpu=on_gpu,
limited_area=False,
)
elif experiment == REGIONAL_EXPERIMENT:
return _load_from_gridfile(
REGIONAL_EXPERIMENT,
"grid.nc",
num_levels=MCH_CH_R04B09_LEVELS,
on_gpu=on_gpu,
limited_area=True,
)
else:
raise ValueError(f"Unknown experiment: {experiment}")


def _load_from_gridfile(file_path: str, filename: str, num_levels: int, on_gpu: bool) -> IconGrid:
def _load_from_gridfile(
file_path: str, filename: str, num_levels: int, on_gpu: bool, limited_area: bool
) -> IconGrid:
grid_file = GRIDS_PATH.joinpath(file_path, filename)
if not grid_file.exists():
from icon4py.model.common.test_utils.data_handling import download_and_extract
Expand All @@ -66,7 +70,7 @@ def _load_from_gridfile(file_path: str, filename: str, num_levels: int, on_gpu:
str(grid_file),
VerticalGridSize(num_levels),
)
gm(on_gpu=on_gpu)
gm(on_gpu=on_gpu, limited_area=limited_area)
return gm.get_grid()


Expand Down
4 changes: 2 additions & 2 deletions spack/gt4py-stable/spack.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
spack:
specs:
- py-icon4py@main%[email protected] ^[email protected].5%[email protected]
- py-icon4py@main%[email protected] ^[email protected].6%[email protected]
view: false
concretizer:
unify: true
develop:
py-icon4py:
spec: py-icon4py@main%[email protected] ^[email protected].5%[email protected]
spec: py-icon4py@main%[email protected] ^[email protected].6%[email protected]
path: ../../

0 comments on commit 4eb7d42

Please sign in to comment.