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

Stencil benchmarking & Test refactoring #220

Merged
merged 28 commits into from
Jun 13, 2023
Merged

Conversation

samkellerhals
Copy link
Contributor

@samkellerhals samkellerhals commented Jun 1, 2023

Enables stencil by stencil benchmarking for different gt4py backends and meshes in unit tests. Benchmarks can be disabled by passing --benchmark-disable to pytest.

Edit (@tehrengruber):
As part of this PR many tests have been refactored to use the new StencilTest base class for writing test cases.

Example (pseudo-code):

class TestMultiplyByTwo(StencilTest): # doctest: +SKIP
    PROGRAM = multiply_by_two  # noqa: F821
    OUTPUTS = ("some_output",)

    @pytest.fixture
    def input_data(self):
        return {"some_input": ..., "some_output": ...}

    @staticmethod
    def reference(some_input, **kwargs):
        return dict(some_output=np.asarray(some_input)*2)

Test cases still to be refactored:

Sparse Field Tests (need more work):

  • test_calculate_nabla2_of_theta
  • test_calculate_nabla4
  • test_mo_advection_traj_btraj_compute_o1_dsl.py
  • mo_velocity_advection_stencil_19.py

Custom test patterns:

  • test_mo_nh_diffusion_stencil_15.py
  • test_mo_solve_nonhydro_stencil_20.py
  • test_mo_solve_nonhydro_stencil_21.py
  • mo_velocity_advection_stencil_02.py
  • mo_velocity_advection_stencil_16.py

np.roll stencils:

  • mo_velocity_advection_stencil_03.py
  • mo_velocity_advection_stencil_06.py
  • mo_velocity_advection_stencil_10.py
  • mo_velocity_advection_stencil_20.py
  • test_mo_solve_nonhydro_stencil_05.py
  • test_mo_solve_nonhydro_stencil_08.py
  • test_mo_solve_nonhydro_stencil_09.py
  • test_mo_solve_nonhydro_stencil_10.py
  • test_mo_solve_nonhydro_stencil_11_upper.py
  • test_mo_solve_nonhydro_stencil_36.py
  • test_mo_solve_nonhydro_stencil_38.py
  • test_mo_solve_nonhydro_stencil_39.py
  • test_mo_solve_nonhydro_stencil_40.py
  • test_mo_solve_nonhydro_stencil_51.py

more complex cases:

  • test_mo_solve_nonhydro_stencil_16_fused_btraj_traj_o1.py
  • test_mo_solve_nonhydro_stencil_52.py
  • test_truly_horizontal_diffusion_nabla_of_theta_over_steep_points.py

@samkellerhals samkellerhals marked this pull request as draft June 1, 2023 13:44
@samkellerhals samkellerhals requested a review from egparedes June 5, 2023 10:55
@tehrengruber tehrengruber self-requested a review June 5, 2023 12:43
@samkellerhals samkellerhals requested a review from halungge June 6, 2023 12:00
Copy link
Contributor

@tehrengruber tehrengruber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just small things.

atm_dyn_iconam/tests/conftest.py Outdated Show resolved Hide resolved
pytest.ini Outdated Show resolved Hide resolved
atm_dyn_iconam/tests/conftest.py Show resolved Hide resolved
samkellerhals and others added 2 commits June 9, 2023 15:50
Co-authored-by: Till Ehrengruber <t.ehrengruber@me.com>
@tehrengruber tehrengruber marked this pull request as ready for review June 13, 2023 02:08
@tehrengruber tehrengruber changed the title Stencil benchmarking Stencil benchmarking & Test refactoring Jun 13, 2023
@tehrengruber tehrengruber merged commit a1b5eb8 into main Jun 13, 2023
@samkellerhals samkellerhals deleted the stencil-benchmarking branch December 20, 2024 08:35
OngChia pushed a commit that referenced this pull request Jan 14, 2025
Enables stencil by stencil benchmarking for different `gt4py` backends and meshes in unit tests. Benchmarks can be disabled by passing `--benchmark-disable` to `pytest`.

As part of this PR many tests have been refactored to use the new `StencilTest` base class for writing test cases.

Example (pseudo-code):
```python
class TestMultiplyByTwo(StencilTest): # doctest: +SKIP
    PROGRAM = multiply_by_two  # noqa: F821
    OUTPUTS = ("some_output",)

    @pytest.fixture
    def input_data(self):
        return {"some_input": ..., "some_output": ...}

    @staticmethod
    def reference(some_input, **kwargs):
        return dict(some_output=np.asarray(some_input)*2)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants