Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set limited_area correctly for experiments #434

Merged
merged 7 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 @@ -240,9 +240,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 @@ -326,9 +326,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 @@ -354,7 +356,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 @@ -386,7 +388,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: ../../
Loading