Skip to content

Commit

Permalink
feat[next]: Enable GPU tests on GTIR DaCe backend (#1741)
Browse files Browse the repository at this point in the history
DaCe v1.0.0 allows to enable GPU tests on the GTIR backend.

An issue was found in `test_double_use_scalar`. The dace gpu
transformations have a bug that produces invalid code for SDFGs
containing scalar expressions outside the field operator. A workaround
is to run the simplify pass in order to bring the SDFG to a canonical
form.

The changes in test code (`test_execution.py`) are pure cleanup.
  • Loading branch information
edopao authored Nov 19, 2024
1 parent a9a9992 commit 9dbc884
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


# regex to match the symbols for field shape and strides
FIELD_SYMBOL_RE: Final[re.Pattern] = re.compile("__.+_(size|stride)_\d+")
FIELD_SYMBOL_RE: Final[re.Pattern] = re.compile(r"__.+_(size|stride)_\d+")


def as_dace_type(type_: ts.ScalarType) -> dace.typeclass:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ def generate_sdfg(
if auto_opt:
gtx_transformations.gt_auto_optimize(sdfg, gpu=on_gpu)
elif on_gpu:
gtx_transformations.gt_gpu_transformation(sdfg, try_removing_trivial_maps=False)
# We run simplify to bring the SDFG into a canonical form that the gpu transformations
# can handle. This is a workaround for an issue with scalar expressions that are
# promoted to symbolic expressions and computed on the host (CPU), but the intermediate
# result is written to a GPU global variable (https://github.com/spcl/dace/issues/1773).
gtx_transformations.gt_simplify(sdfg)
gtx_transformations.gt_gpu_transformation(sdfg, try_removing_trivial_maps=True)

return sdfg

Expand Down
6 changes: 1 addition & 5 deletions tests/next_tests/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,7 @@ class ProgramFormatterId(_PythonObjectIdMixin, str, enum.Enum):
OptionalProgramBackendId.DACE_CPU: DACE_SKIP_TEST_LIST,
OptionalProgramBackendId.DACE_GPU: DACE_SKIP_TEST_LIST,
OptionalProgramBackendId.GTIR_DACE_CPU: GTIR_DACE_SKIP_TEST_LIST,
OptionalProgramBackendId.GTIR_DACE_GPU: GTIR_DACE_SKIP_TEST_LIST
+ [
# TODO(edopao): Enable when GPU codegen issues related to symbolic domain are fixed.
(ALL, XFAIL, UNSUPPORTED_MESSAGE),
],
OptionalProgramBackendId.GTIR_DACE_GPU: GTIR_DACE_SKIP_TEST_LIST,
ProgramBackendId.GTFN_CPU: GTFN_SKIP_TEST_LIST
+ [(USES_SCAN_NESTED, XFAIL, UNSUPPORTED_MESSAGE)],
ProgramBackendId.GTFN_CPU_IMPERATIVE: GTFN_SKIP_TEST_LIST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,14 @@
# SPDX-License-Identifier: BSD-3-Clause

from functools import reduce
from gt4py.next.otf import languages, stages, workflow
from gt4py.next.otf.binding import interface
import numpy as np
import pytest
import diskcache
from gt4py.eve import SymbolName

import gt4py.next as gtx
from gt4py.next import (
astype,
broadcast,
common,
constructors,
errors,
field_utils,
float32,
float64,
int32,
Expand All @@ -30,8 +23,6 @@
neighbor_sum,
)
from gt4py.next.ffront.experimental import as_offset
from gt4py.next.program_processors.runners import gtfn
from gt4py.next.type_system import type_specifications as ts
from gt4py.next import utils as gt_utils

from next_tests.integration_tests import cases
Expand Down Expand Up @@ -306,7 +297,7 @@ def test_double_use_scalar(cartesian_case):
# TODO(tehrengruber): This should be a regression test on ITIR level, but tracing doesn't
# work for this case.
@gtx.field_operator
def testee(a: np.int32, b: np.int32, c: cases.IField) -> cases.IField:
def testee(a: int32, b: int32, c: cases.IField) -> cases.IField:
tmp = a * b
tmp2 = tmp * tmp
# important part here is that we use the intermediate twice so that it is
Expand Down

0 comments on commit 9dbc884

Please sign in to comment.