Skip to content

Commit

Permalink
Move transient lifetime into OirSDFGBuilder
Browse files Browse the repository at this point in the history
Transients are added in OirSDFGBuilder, where no array lifetime is
configured. After building that SDFG, the lifetime of all transients is
manually set to `Persistent` (which is an optimization leading to less
frequent memory allocation in case a kernel is called multiple times).
In this commit we directly specify the transient's lifetime when
building the SDFG.
  • Loading branch information
romanc committed Feb 3, 2025
1 parent 58656ba commit c7aba86
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
4 changes: 0 additions & 4 deletions src/gt4py/cartesian/backend/dace_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,6 @@ def _pre_expand_transformations(gtir_pipeline: GtirPipeline, sdfg: dace.SDFG, la
sdfg.add_state(gtir_pipeline.gtir.name)
return sdfg

for array in sdfg.arrays.values():
if array.transient:
array.lifetime = dace.AllocationLifetime.Persistent

sdfg.simplify(validate=False)

_set_expansion_orders(sdfg)
Expand Down
1 change: 1 addition & 0 deletions src/gt4py/cartesian/gtc/dace/oir_to_dace.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def visit_Stencil(self, node: oir.Stencil):
],
dtype=data_type_to_dace_typeclass(decl.dtype),
transient=True,
lifetime=dace.AllocationLifetime.Persistent,
debuginfo=get_dace_debuginfo(decl),
)
self.generic_visit(node, ctx=ctx)
Expand Down

0 comments on commit c7aba86

Please sign in to comment.