Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
901b57e
fix[cartesian]: log10 percision issue
romanc May 8, 2026
1abd6c7
Expose more math functions in `dace/math.h`
romanc May 11, 2026
1eec3df
update dace (fix fmod arguments)
romanc May 11, 2026
da74589
Merge branch 'main' into romanc/fix-log10-precision
romanc May 11, 2026
9fbba0a
Merge remote-tracking branch 'GridTools/main' into romanc/fix-log10-p…
FlorianDeconinck May 11, 2026
7ba05d5
Merge branch 'main' into romanc/fix-log10-precision
romanc May 19, 2026
c186e61
Add dace:gpu_IJK backend
FlorianDeconinck May 22, 2026
3da968c
Fix GPU compiler flags when not `-O0`
FlorianDeconinck May 22, 2026
f19583f
Merge branch 'feature/dace_gpu_IJK_backend' into romanc/fix-log10-pre…
FlorianDeconinck May 22, 2026
08bb317
fixes for running GFDL_1M with orch:dace:cpu:KJI
romanc May 28, 2026
58e449e
Merge remote-tracking branch 'origin/main' into romanc/fix-log10-prec…
romanc May 28, 2026
08100b8
fix pyproject.toml & uv.lock files after merge with main
romanc May 28, 2026
d19bf89
restore cartesian/next versions for dace
romanc May 29, 2026
eca45a3
Fix failing GPU tests (dace:gpu_IJK fallout)
romanc Jun 1, 2026
210fcbd
unrelated dace update: just fixing a typo
romanc Jun 1, 2026
795e377
CFlags for device code is a list (as expected later by GT stencil com…
FlorianDeconinck Jun 5, 2026
fa099e6
Merge remote-tracking branch 'origin/main' into romanc/fix-log10-prec…
romanc Jun 9, 2026
d6449bb
dace update: unrelated typehint fix
romanc Jun 9, 2026
cdca87a
dace update: fixup for unrelated typehint change
romanc Jun 9, 2026
f0b62e5
Merge remote-tracking branch 'GridTools/main' into romanc/fix-log10-p…
FlorianDeconinck Jun 10, 2026
65299a7
Merge remote-tracking branch 'GridTools/main' into romanc/fix-log10-p…
FlorianDeconinck Jun 11, 2026
cf04c49
minor: remove unused imports from test
romanc Jun 15, 2026
ddf3cb3
dace update: unique names for loop regions
romanc Jun 17, 2026
4d6e27b
feat: descriptive map/loop names
romanc Jun 22, 2026
d568ac7
dace update: consider read-after-write in stree input_memlets
romanc Jun 22, 2026
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
13 changes: 9 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,13 @@
CodeGenTestSettings: Final[dict[str, dict[str, list[str]]]] = {
"internal": {"extras": ["jax"], "markers": ["not requires_dace"]}
}
CodeGenDaceTestSettings = CodeGenTestSettings | {
"dace": {"extras": [], "markers": ["requires_dace"]},
# Use dace-cartesian group to select the appropriate dace version
CodeGenCartesianTestSettings = CodeGenTestSettings | {
"dace": {"extras": [], "groups": ["dace-cartesian"], "markers": ["requires_dace"]},
}
# Install dace-next group to select the appropriate dace version
CodeGenNextTestSettings = CodeGenTestSettings | {
"dace": {"extras": [], "groups": ["dace-next"], "markers": ["requires_dace"]},
}


Expand Down Expand Up @@ -162,7 +167,7 @@ def test_cartesian(
) -> None:
"""Run selected 'gt4py.cartesian' tests."""

codegen_settings = CodeGenDaceTestSettings[codegen]
codegen_settings = CodeGenCartesianTestSettings[codegen]
device_settings = DeviceTestSettings[device]
extras = [
"standard",
Expand Down Expand Up @@ -245,7 +250,7 @@ def test_next(
) -> None:
"""Run selected 'gt4py.next' tests."""

codegen_settings = CodeGenDaceTestSettings[codegen]
codegen_settings = CodeGenNextTestSettings[codegen]
device_settings = DeviceTestSettings[device]
extras = [
"standard",
Expand Down
16 changes: 14 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ requires = ['cython>=3.0.0', 'setuptools>=77.0.3', 'versioningit>=3.1.1', 'wheel
# -- Dependency groups --
[dependency-groups]
build = ['cython>=3.0.0', 'pip>=22.1.1', 'setuptools>=77.0.3', 'wheel>=0.33.6']
dace-cartesian = [
'dace>=1.0.2' # refined in [tool.uv.sources]
]
dace-next = [
'dace==43!2026.04.27' # uses custom index at 'https://github.com/GridTools/pypi'
]
dev = [
{include-group = 'build'},
{include-group = 'docs'},
Expand Down Expand Up @@ -100,7 +106,6 @@ dependencies = [
'click>=8.0.0',
'cmake>=3.22',
'cytoolz>=1.0.1',
'dace>=2.0.0a3',
'deepdiff>=8.1.0',
'devtools>=0.6',
'factory-boy>=3.3.3',
Expand Down Expand Up @@ -459,6 +464,10 @@ conflicts = [
{extra = 'jax-cuda13'},
{extra = 'rocm6'},
{extra = 'rocm7'}
],
[
{group = 'dace-cartesian'},
{group = 'dace-next'}
]
]
default-groups = ["dev"]
Expand All @@ -475,9 +484,12 @@ name = 'gridtools'
url = 'https://gridtools.github.io/pypi/'

# Add the uv source below to pull dace from the gridtools index instead of PyPI:
# dace = {index = "gridtools"}
[tool.uv.sources]
atlas4py = {index = "test.pypi"}
dace = [
{git = "https://github.com/romanc/dace", branch = "romanc/math-functions", group = "dace-cartesian"},
{index = "gridtools", group = "dace-next"}
]

# -- versioningit --
[tool.versioningit]
Expand Down
21 changes: 15 additions & 6 deletions src/gt4py/cartesian/backend/dace_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def _sdfg_add_arrays_and_edges(
inputs: set[str] | dict[str, dtypes.typeclass],
outputs: set[str] | dict[str, dtypes.typeclass],
origins: dict[str, tuple[int, ...]],
domain: tuple[int, ...],
) -> None:
for name, array in inner_sdfg.arrays.items():
if array.transient:
Expand Down Expand Up @@ -129,12 +130,20 @@ def _sdfg_add_arrays_and_edges(
if axis not in axes:
continue
o = origin[index]
e = field_info[name].boundary.lower_indices[cartesian_index]
lower, upper = field_info[name].boundary[cartesian_index]
s = inner_sdfg.arrays[name].shape[index]
ranges.append(
# s - 1 because ranges are inclusive
(o - max(0, e), o - max(0, e) + s - 1, 1)
)
if axis == CartesianSpace.Axis.K.name:
d = domain[cartesian_index]
ranges.append(
# max(0, lower) because ...
# d - 1 because ranges are inclusive
(o - max(0, lower), o + upper + d - 1, 1)
)
else:
ranges.append(
# s - 1 because ranges are inclusive
(o - max(0, lower), o - max(0, lower) + s - 1, 1)
)
index += 1

# Add data dimensions to the range
Expand Down Expand Up @@ -264,7 +273,7 @@ def freeze_origin_domain_sdfg(
nsdfg = state.add_nested_sdfg(inner_sdfg, inputs, outputs)

_sdfg_add_arrays_and_edges(
field_info, wrapper_sdfg, state, inner_sdfg, nsdfg, inputs, outputs, origin
field_info, wrapper_sdfg, state, inner_sdfg, nsdfg, inputs, outputs, origin, domain
)

# in special case of empty domain, remove entire SDFG.
Expand Down
28 changes: 14 additions & 14 deletions src/gt4py/cartesian/gtc/dace/oir_to_tasklet.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,38 +226,38 @@ def visit_NativeFunction(self, node: common.NativeFunction, **_kwargs: Any) -> s
common.NativeFunction.ABS: "abs",
common.NativeFunction.MIN: "min",
common.NativeFunction.MAX: "max",
common.NativeFunction.MOD: "fmod",
common.NativeFunction.MOD: "dace.math.fmod",
common.NativeFunction.SIN: "dace.math.sin",
common.NativeFunction.COS: "dace.math.cos",
common.NativeFunction.TAN: "dace.math.tan",
common.NativeFunction.ARCSIN: "asin",
common.NativeFunction.ARCCOS: "acos",
common.NativeFunction.ARCTAN: "atan",
common.NativeFunction.ARCSIN: "dace.math.asin",
common.NativeFunction.ARCCOS: "dace.math.acos",
common.NativeFunction.ARCTAN: "dace.math.atan",
common.NativeFunction.SINH: "dace.math.sinh",
common.NativeFunction.COSH: "dace.math.cosh",
common.NativeFunction.TANH: "dace.math.tanh",
common.NativeFunction.ARCSINH: "asinh",
common.NativeFunction.ARCCOSH: "acosh",
common.NativeFunction.ARCTANH: "atanh",
common.NativeFunction.ARCSINH: "dace.math.asinh",
common.NativeFunction.ARCCOSH: "dace.math.acosh",
common.NativeFunction.ARCTANH: "dace.math.atanh",
common.NativeFunction.SQRT: "dace.math.sqrt",
common.NativeFunction.POW: "dace.math.pow",
common.NativeFunction.EXP: "dace.math.exp",
common.NativeFunction.LOG: "dace.math.log",
common.NativeFunction.LOG10: "log10",
common.NativeFunction.GAMMA: "tgamma",
common.NativeFunction.CBRT: "cbrt",
common.NativeFunction.LOG10: "dace.math.log10",
common.NativeFunction.GAMMA: "dace.math.tgamma",
common.NativeFunction.CBRT: "dace.math.cbrt",
common.NativeFunction.ISFINITE: "isfinite",
common.NativeFunction.ISINF: "isinf",
common.NativeFunction.ISNAN: "isnan",
common.NativeFunction.FLOOR: "dace.math.ifloor",
common.NativeFunction.CEIL: "ceil",
common.NativeFunction.TRUNC: "trunc",
common.NativeFunction.CEIL: "dace.math.ceil",
common.NativeFunction.TRUNC: "dace.math.trunc",
common.NativeFunction.INT32: "dace.int32",
common.NativeFunction.INT64: "dace.int64",
common.NativeFunction.FLOAT32: "dace.float32",
common.NativeFunction.FLOAT64: "dace.float64",
common.NativeFunction.ERF: "erf",
common.NativeFunction.ERFC: "erfc",
common.NativeFunction.ERF: "dace.math.erf",
common.NativeFunction.ERFC: "dace.math.erfc",
common.NativeFunction.ROUND: "nearbyint",
common.NativeFunction.ROUND_AWAY_FROM_ZERO: "round",
}
Expand Down
10 changes: 5 additions & 5 deletions src/gt4py/cartesian/gtc/dace/treeir_to_stree.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def visit_Tasklet(self, node: tir.Tasklet, ctx: Context) -> None:

def visit_HorizontalLoop(self, node: tir.HorizontalLoop, ctx: Context) -> None:
dace_map = nodes.Map(
label=f"horizontal_loop_{id(node)}",
label=f"{ctx.tree.name}__h_map_{id(node)}",
params=[tir.Axis.J.iteration_symbol(), tir.Axis.I.iteration_symbol()],
ndrange=subsets.Range(
[
Expand All @@ -87,7 +87,7 @@ def visit_HorizontalLoop(self, node: tir.HorizontalLoop, ctx: Context) -> None:
def visit_VerticalLoop(self, node: tir.VerticalLoop, ctx: Context) -> None:
# For serial loops, create a ForScope and add it to the tree
if node.loop_order != common.LoopOrder.PARALLEL:
for_scope = tn.ForScope(loop=_loop_region_for(node), children=[])
for_scope = tn.ForScope(loop=_loop_region_for(node, ctx), children=[])

with ContextPushPop(ctx, for_scope):
self.visit(node.children, ctx=ctx)
Expand All @@ -96,7 +96,7 @@ def visit_VerticalLoop(self, node: tir.VerticalLoop, ctx: Context) -> None:

# For parallel loops, create a map and add it to the tree
dace_map = nodes.Map(
label=f"vertical_loop_{id(node)}",
label=f"{ctx.tree.name}__v_map_{id(node)}",
params=[node.iteration_variable],
ndrange=subsets.Range(
# -1 because range bounds are inclusive
Expand Down Expand Up @@ -140,7 +140,7 @@ def visit_TreeRoot(self, node: tir.TreeRoot) -> tn.ScheduleTreeRoot:
return ctx.tree


def _loop_region_for(node: tir.VerticalLoop) -> LoopRegion:
def _loop_region_for(node: tir.VerticalLoop, ctx: Context) -> LoopRegion:
"""
Translates a vertical loop into a Dace LoopRegion to be used in `tn.ForScope`.

Expand All @@ -152,7 +152,7 @@ def _loop_region_for(node: tir.VerticalLoop) -> LoopRegion:
iteration_var = node.iteration_variable

return LoopRegion(
label=f"vertical_loop_{id(node)}",
label=f"{ctx.tree.name}__v_loop_{id(node)}",
loop_var=iteration_var,
initialize_expr=CodeBlock(f"{iteration_var} = {node.bounds_k.start}"),
condition_expr=CodeBlock(f"{iteration_var} {comparison} {node.bounds_k.end}"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# Please, refer to the LICENSE file in the root directory.
# SPDX-License-Identifier: BSD-3-Clause

from gt4py.eve import SymbolRef
import os
import pytest

Expand All @@ -15,7 +14,6 @@


from dace import nodes
from dace import sdfg as dace_sdfg
from dace.sdfg.state import LoopRegion
import dace.sdfg.analysis.schedule_tree.treenodes as tn

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,22 @@ def test_integer_power_of_integer() -> None:
tasklet_code = visitor.visit_NativeFuncCall(pow_call, ctx=fake_context, is_target=False)

assert "ipow" not in tasklet_code


@pytest.mark.parametrize(
"arg",
[
oir.Literal(value="2", dtype=common.DataType.FLOAT32),
oir.Literal(value="2", dtype=common.DataType.FLOAT64),
],
)
def test_log10_respects_floating_point_precision(arg: oir.Literal) -> None:
log10_call = oir.NativeFuncCall(func=common.NativeFunction.LOG10, args=[arg])

visitor = oir_to_tasklet.OIRToTasklet()
fake_context = oir_to_tasklet.Context(
code="asdf", targets=set(), inputs={}, outputs={}, tree=None, scope=None
)
tasklet_code = visitor.visit_NativeFuncCall(log10_call, ctx=fake_context, is_target=False)

assert "dace.math.log10" in tasklet_code
Loading
Loading