Skip to content

Commit

Permalink
Add icon_grid benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
samkellerhals committed Dec 14, 2023
1 parent 7872ae3 commit 390721c
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 89 deletions.
142 changes: 71 additions & 71 deletions ci/cscs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,78 +48,78 @@ variables:
build_job:
extends: .build_template

#test_model_job_roundtrip_simple_grid:
# extends: .test_template
# stage: test
# script:
# - tox -r -c model/ --verbose -- --benchmark-skip -n auto
#
#test_model_job_dace_cpu_simple_grid:
# extends: .test_template
# stage: test
# script:
# - pip install dace==$DACE_VERSION
# - tox -r -e stencil_tests -c model/ --verbose -- --benchmark-skip -n auto --backend=dace_cpu
# only:
# - main
# allow_failure: true
#
#test_model_job_dace_gpu_simple_grid:
# extends: .test_template
# stage: test
# script:
# - pip install dace==$DACE_VERSION
# - tox -r -e stencil_tests -c model/ --verbose -- --benchmark-skip -n auto --backend=dace_gpu
# only:
# - main
# allow_failure: true
#
test_model_job_roundtrip_simple_grid:
extends: .test_template
stage: test
script:
- tox -r -c model/ --verbose -- --benchmark-skip -n auto

test_model_job_dace_cpu_simple_grid:
extends: .test_template
stage: test
script:
- pip install dace==$DACE_VERSION
- tox -r -e stencil_tests -c model/ --verbose -- --benchmark-skip -n auto --backend=dace_cpu
only:
- main
allow_failure: true

test_model_job_dace_gpu_simple_grid:
extends: .test_template
stage: test
script:
- pip install dace==$DACE_VERSION
- tox -r -e stencil_tests -c model/ --verbose -- --benchmark-skip -n auto --backend=dace_gpu
only:
- main
allow_failure: true

test_model_job_gtfn_cpu_simple_grid:
extends: .test_template
stage: test
script:
- tox -r -e stencil_tests -c model/ --verbose -- --benchmark-skip -n auto --backend=gtfn_cpu --grid=icon_grid

#test_model_job_gtfn_gpu_simple_grid:
# extends: .test_template
# stage: test
# script:
# - tox -r -e stencil_tests -c model/ --verbose -- --benchmark-skip -n auto --backend=gtfn_gpu
#
#test_tools_job:
# extends: .test_template
# stage: test
# script:
# - tox -r -c tools/ --verbose
#
#benchmark_model_dace_cpu_simple_grid:
# extends: .test_template
# stage: benchmark
# script:
# - pip install dace==$DACE_VERSION
# - tox -r -e stencil_tests -c model/ --verbose -- --benchmark-only --backend=dace_cpu --grid=simple_grid
# only:
# - main
# when: manual
#
#benchmark_model_dace_gpu_simple_grid:
# extends: .test_template
# stage: benchmark
# script:
# - pip install dace==$DACE_VERSION
# - tox -r -e stencil_tests -c model/ --verbose -- --benchmark-only --backend=dace_gpu --grid=simple_grid
# only:
# - main
# when: manual
#
#benchmark_model_gtfn_cpu_simple_grid:
# extends: .test_template
# stage: benchmark
# script:
# - tox -r -e stencil_tests -c model/ --verbose -- --benchmark-only --backend=gtfn_cpu --grid=simple_grid
#
#benchmark_model_gtfn_gpu_simple_grid:
# extends: .test_template
# stage: benchmark
# script:
# - tox -r -e stencil_tests -c model/ --verbose -- --benchmark-only --backend=gtfn_gpu --grid=simple_grid
- tox -r -e stencil_tests -c model/ --verbose -- --benchmark-skip -n auto --backend=gtfn_cpu

test_model_job_gtfn_gpu_simple_grid:
extends: .test_template
stage: test
script:
- tox -r -e stencil_tests -c model/ --verbose -- --benchmark-skip -n auto --backend=gtfn_gpu

test_tools_job:
extends: .test_template
stage: test
script:
- tox -r -c tools/ --verbose

benchmark_model_dace_cpu_icon_grid:
extends: .test_template
stage: benchmark
script:
- pip install dace==$DACE_VERSION
- tox -r -e stencil_tests -c model/ --verbose -- --benchmark-only --backend=dace_cpu --grid=icon_grid
only:
- main
when: manual

benchmark_model_dace_gpu_icon_grid:
extends: .test_template
stage: benchmark
script:
- pip install dace==$DACE_VERSION
- tox -r -e stencil_tests -c model/ --verbose -- --benchmark-only --backend=dace_gpu --grid=icon_grid
only:
- main
when: manual

benchmark_model_gtfn_cpu_icon_grid:
extends: .test_template
stage: benchmark
script:
- tox -r -e stencil_tests -c model/ --verbose -- --benchmark-only --backend=gtfn_cpu --grid=icon_grid

benchmark_model_gtfn_gpu_icon_grid:
extends: .test_template
stage: benchmark
script:
- tox -r -e stencil_tests -c model/ --verbose -- --benchmark-only --backend=gtfn_gpu --grid=icon_grid
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
random_mask,
unflatten_first_two_dims,
zero_field,
uses_icon_grid_with_otf
)

from .test_calculate_nabla2_for_z import calculate_nabla2_for_z_numpy
Expand Down Expand Up @@ -81,7 +82,10 @@ def reference(
return dict(theta_v=theta_v, exner=exner)

@pytest.fixture
def input_data(self, grid):
def input_data(self, grid, uses_icon_grid_with_otf):
if uses_icon_grid_with_otf:
pytest.skip("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 @@ -13,13 +13,12 @@

import numpy as np
import pytest
from gt4py.next.ffront.fbuiltins import int32

from gt4py.next.ffront.fbuiltins import int32
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.test_utils.helpers import StencilTest, as_1D_sparse_field, random_field

from icon4py.model.common.test_utils.helpers import StencilTest, as_1D_sparse_field, random_field, uses_icon_grid_with_otf
from .test_apply_nabla2_and_nabla4_global_to_vn import apply_nabla2_and_nabla4_global_to_vn_numpy
from .test_apply_nabla2_and_nabla4_to_vn import apply_nabla2_and_nabla4_to_vn_numpy
from .test_apply_nabla2_to_vn_in_lateral_boundary import (
Expand Down Expand Up @@ -98,7 +97,10 @@ def reference(
return dict(vn=vn)

@pytest.fixture
def input_data(self, grid):
def input_data(self, grid, uses_icon_grid_with_otf):
if uses_icon_grid_with_otf:
pytest.skip("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 @@ -13,14 +13,13 @@

import numpy as np
import pytest
from gt4py.next.ffront.fbuiltins import int32
from gt4py.next.program_processors.otf_compile_executor import OTFCompileExecutor

from gt4py.next.ffront.fbuiltins import int32
from icon4py.model.atmosphere.diffusion.stencils.calculate_nabla2_for_z import (
calculate_nabla2_for_z,
)
from icon4py.model.common.dimension import CellDim, E2CDim, EdgeDim, KDim
from icon4py.model.common.test_utils.helpers import StencilTest, random_field
from icon4py.model.common.test_utils.helpers import StencilTest, random_field, uses_icon_grid_with_otf
from icon4py.model.common.type_alias import vpfloat, wpfloat


Expand Down Expand Up @@ -55,12 +54,10 @@ def reference(
return dict(z_nabla2_e=z_nabla2_e)

@pytest.fixture
def input_data(self, grid, backend):
if hasattr(backend, 'executor'):
if isinstance(backend.executor, OTFCompileExecutor):
pytest.skip(
"Execution domain needs to be restricted or boundary taken into account in stencil."
)
def input_data(self, grid, uses_icon_grid_with_otf):
if uses_icon_grid_with_otf:
pytest.skip("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 @@ -34,6 +34,7 @@
random_field,
random_mask,
zero_field,
uses_icon_grid_with_otf
)

from .test_mo_math_divrot_rot_vertex_ri_dsl import mo_math_divrot_rot_vertex_ri_dsl_numpy
Expand Down Expand Up @@ -116,7 +117,10 @@ def reference(
return dict(ddt_vn_apc=ddt_vn_apc)

@pytest.fixture
def input_data(self, grid):
def input_data(self, grid, uses_icon_grid_with_otf):
if uses_icon_grid_with_otf:
pytest.skip("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,7 +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.test_utils.helpers import StencilTest, random_field, zero_field
from icon4py.model.common.test_utils.helpers import StencilTest, random_field, zero_field, uses_icon_grid_with_otf

from .test_mo_icon_interpolation_scalar_cells2verts_scalar_ri_dsl import (
mo_icon_interpolation_scalar_cells2verts_scalar_ri_dsl_numpy,
Expand Down Expand Up @@ -192,7 +192,10 @@ def reference(
)

@pytest.fixture
def input_data(self, grid):
def input_data(self, grid, uses_icon_grid_with_otf):
if uses_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)
rbf_vec_coeff_e = random_field(grid, EdgeDim, E2C2EDim)
Expand Down
14 changes: 13 additions & 1 deletion model/common/src/icon4py/model/common/test_utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
from gt4py.next import common as gt_common
from gt4py.next import constructors
from gt4py.next.ffront.decorator import Program
from gt4py.next.program_processors.otf_compile_executor import OTFCompileExecutor

from ..grid.base import BaseGrid

from ..grid.icon import IconGrid

try:
import pytest_benchmark
Expand Down Expand Up @@ -219,3 +220,14 @@ def __init_subclass__(cls, **kwargs):
super().__init_subclass__(**kwargs)
setattr(cls, f"test_{cls.__name__}", _test_validation)
setattr(cls, f"test_{cls.__name__}_benchmark", _test_execution_benchmark)


@pytest.fixture
def uses_icon_grid_with_otf(backend, grid):
"""Checks whether we are using a compiled backend with the 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 isinstance(backend.executor, OTFCompileExecutor):
return True
return False

0 comments on commit 390721c

Please sign in to comment.