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

Add support for optional dace backend #335

Merged
merged 4 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
38 changes: 37 additions & 1 deletion ci/cscs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,26 @@ test_model_job_roundtrip_simple_grid:
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
edopao marked this conversation as resolved.
Show resolved Hide resolved
- 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
- 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
Expand All @@ -68,11 +88,27 @@ test_tools_job:
script:
- tox -r -c tools/ --verbose

benchmark_model_dace_cpu_simple_grid:
extends: .test_template
stage: benchmark
script:
- pip install dace
- tox -r -e stencil_tests -c model/ --verbose -- --benchmark-only --backend=dace_cpu --grid=simple_grid
when: manual

benchmark_model_dace_gpu_simple_grid:
extends: .test_template
stage: benchmark
script:
- pip install dace
- tox -r -e stencil_tests -c model/ --verbose -- --benchmark-only --backend=dace_gpu --grid=simple_grid
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
- 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
Expand Down
50 changes: 29 additions & 21 deletions model/common/src/icon4py/model/common/test_utils/pytest_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def pytest_addoption(parser):
pass

try:
# TODO (samkellerhals): set embedded to default as soon as all tests run in embedded mode
parser.addoption(
"--backend",
action="store",
Expand Down Expand Up @@ -80,33 +81,40 @@ def pytest_generate_tests(metafunc):
if "backend" in metafunc.fixturenames:
backend_option = metafunc.config.getoption("backend")

params = []
ids = []
backends = {
"embedded": None,
"roundtrip": run_roundtrip,
"gtfn_cpu": run_gtfn,
"gtfn_gpu": run_gtfn_gpu,
}

if (
backend_option == "None"
): # TODO (samkellerhals): set None to default as soon as all tests run in embedded mode
params.append(None)
ids.append("embedded")

elif backend_option == "gtfn_cpu":
params.append(run_gtfn)
ids.append("backend=gtfn_cpu")

elif backend_option == "roundtrip":
params.append(run_roundtrip)
ids.append("backend=roundtrip")
try:
from gt4py.next.program_processors.runners.dace_iterator import (
run_dace_cpu,
run_dace_gpu,
)

elif backend_option == "gtfn_gpu":
params.append(run_gtfn_gpu)
ids.append("backend=gtfn_gpu")
backends.update(
{
"dace_cpu": run_dace_cpu,
"dace_gpu": run_dace_gpu,
}
)
except ImportError:
# dace module not installed, ignore dace backends
pass

if len(params) < 1:
if backend_option not in backends:
available_backends = ", ".join([f"'{k}'" for k in backends.keys()])
raise Exception(
f"Selected backend: '{backend_option}' is not supported. Select from: 'embedded', 'gtfn_cpu', 'gtfn_gpu'."
"Need to select a backend. Select from: ["
+ available_backends
+ "] and pass it as an argument to --backend when invoking pytest."
)

metafunc.parametrize("backend", params, ids=ids)
metafunc.parametrize(
"backend", [backends[backend_option]], ids=[f"backend={backend_option}"]
)

# parametrise grid
if "grid" in metafunc.fixturenames:
Expand Down