Skip to content

Commit c1b9c80

Browse files
authored
refactor[cartesian]: Avoid dummy DebugInfo in favor of configuration (#2581)
## Description DaCe now comes with a configuration option whether or not to inspect the python stack in case debug information (e.g. line number) is missing. We previously used a fake `DebugInfo` object to prevent the call to `inspect()`. With the new configuration option, we can remove those fake objects again and just configure the desired behavior. A word of caution: until spcl/dace#2344 or something similar is merged, DaCe will output a ton of deprecation warnings caused by the addition of the new config option. ## Requirements - [ ] All fixes and/or new features come with corresponding tests. N/A - [ ] Important design decisions have been documented in the appropriate ADR inside the [docs/development/ADRs/](docs/development/ADRs/README.md) folder. N/A
1 parent 0d4599a commit c1b9c80

2 files changed

Lines changed: 13 additions & 21 deletions

File tree

src/gt4py/cartesian/backend/dace_backend.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import re
1515
from typing import TYPE_CHECKING, ClassVar
1616

17-
from dace import SDFG, DebugInfo, Memlet, SDFGState, config, data, dtypes, nodes, subsets, symbolic
17+
from dace import SDFG, Memlet, SDFGState, config, data, dtypes, nodes, subsets, symbolic
1818
from dace.codegen import codeobject
1919
from dace.sdfg.analysis.schedule_tree import treenodes as tn
2020
from dace.sdfg.utils import inline_sdfgs
@@ -146,10 +146,7 @@ def _sdfg_add_arrays_and_edges(
146146

147147
if name in inputs:
148148
state.add_edge(
149-
state.add_read(
150-
name,
151-
DebugInfo(123456), # fake DebugInfo to avoid calls to `inspect`
152-
),
149+
state.add_read(name),
153150
None,
154151
nsdfg,
155152
name,
@@ -159,10 +156,7 @@ def _sdfg_add_arrays_and_edges(
159156
state.add_edge(
160157
nsdfg,
161158
name,
162-
state.add_write(
163-
name,
164-
DebugInfo(123456), # fake DebugInfo to avoid calls to `inspect`
165-
),
159+
state.add_write(name),
166160
None,
167161
Memlet(name, subset=subsets.Range(ranges)),
168162
)
@@ -175,10 +169,7 @@ def _sdfg_add_arrays_and_edges(
175169
)
176170
if name in inputs:
177171
state.add_edge(
178-
state.add_read(
179-
name,
180-
DebugInfo(123456), # fake DebugInfo to avoid calls to `inspect`
181-
),
172+
state.add_read(name),
182173
None,
183174
nsdfg,
184175
name,
@@ -188,10 +179,7 @@ def _sdfg_add_arrays_and_edges(
188179
state.add_edge(
189180
nsdfg,
190181
name,
191-
state.add_write(
192-
name,
193-
DebugInfo(123456), # fake DebugInfo to avoid calls to `inspect`
194-
),
182+
state.add_write(name),
195183
None,
196184
Memlet(name),
197185
)
@@ -273,8 +261,7 @@ def freeze_origin_domain_sdfg(
273261
inputs = set(filter(lambda name: not inner_sdfg.arrays[name].transient, inputs))
274262
outputs = set(filter(lambda name: not inner_sdfg.arrays[name].transient, outputs))
275263

276-
# fake DebugInfo to avoid calls to `inspect`
277-
nsdfg = state.add_nested_sdfg(inner_sdfg, inputs, outputs, debuginfo=DebugInfo(123456))
264+
nsdfg = state.add_nested_sdfg(inner_sdfg, inputs, outputs)
278265

279266
_sdfg_add_arrays_and_edges(
280267
field_info, wrapper_sdfg, state, inner_sdfg, nsdfg, inputs, outputs, origin
@@ -608,6 +595,11 @@ def apply(cls, builder: StencilBuilder, sdfg: SDFG) -> str:
608595
value=gt_config.DACE_DEFAULT_BLOCK_SIZE,
609596
)
610597
config.Config.set("compiler", "cpu", "openmp_sections", value=False)
598+
# The default, "inspect", will inspect the python stack for every object that's added
599+
# to the SDFG, which doesn't provide a DebugInfo object. Those calls add up over time
600+
# and - in our case - end up with line information pointing to the GT4Py-DaCe bridge.
601+
# We thus decided to turn off lineinfo in the DaCe config.
602+
config.Config.set("compiler", "lineinfo", value="none")
611603
code_objects = sdfg.generate_code()
612604
is_gpu = "CUDA" in {co.title for co in code_objects}
613605

uv.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)