Skip to content

Commit

Permalink
Adapt state struct codegen for indexing of dace:* stencil backend
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianDeconinck committed Nov 28, 2023
1 parent 91307b1 commit ceef1d6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/gt4py/cartesian/backend/dace_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ class DaCeComputationCodegen:
const int __I = domain[0];
const int __J = domain[1];
const int __K = domain[2];
${name}_t dace_handle;
${name}_{state_prefix} dace_handle;
${backend_specifics}
auto allocator = gt::sid::cached_allocator(&${allocator}<char[]>);
${"\\n".join(tmp_allocs)}
Expand Down Expand Up @@ -561,13 +561,21 @@ def apply(cls, stencil_ir: gtir.Stencil, builder: "StencilBuilder", sdfg: dace.S
else:
omp_threads = ""
omp_header = ""

# Backward compatible state struct name change in dave >=0.15.x
try:
dace_state_prefix = dace.Config.get("compiler.codegen_state_struct_suffix")
except (KeyError, TypeError):
dace_state_prefix = "t" # old structure name

interface = cls.template.definition.render(
name=sdfg.name,
backend_specifics=omp_threads,
dace_args=self.generate_dace_args(stencil_ir, sdfg),
functor_args=self.generate_functor_args(sdfg),
tmp_allocs=self.generate_tmp_allocs(sdfg),
allocator="gt::cuda_util::cuda_malloc" if is_gpu else "std::make_unique",
state_prefix=dace_state_prefix,
)
generated_code = textwrap.dedent(
f"""#include <gridtools/sid/sid_shift_origin.hpp>
Expand Down

0 comments on commit ceef1d6

Please sign in to comment.