Skip to content

Commit

Permalink
fix[cartesian]: DaceIR bridge for DaCe v0.15 (#1373)
Browse files Browse the repository at this point in the history
* Adapt state struct codegen for indexing of dace:* stencil backend

* Add new "Default" schedule type for dace <> gt4py schedule mapping

* Missing key for make template render

* Fix typo

* Typo of the typo (tm)
  • Loading branch information
FlorianDeconinck authored Nov 30, 2023
1 parent e564cdc commit 6e13354
Show file tree
Hide file tree
Showing 2 changed files with 10 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_suffix} 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 DaCe >=0.15.x
try:
dace_state_suffix = dace.Config.get("compiler.codegen_state_struct_suffix")
except (KeyError, TypeError):
dace_state_suffix = "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_suffix=dace_state_suffix,
)
generated_code = textwrap.dedent(
f"""#include <gridtools/sid/sid_shift_origin.hpp>
Expand Down
1 change: 1 addition & 0 deletions src/gt4py/cartesian/gtc/daceir.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def from_dace_schedule(cls, schedule):
dace.ScheduleType.Default: MapSchedule.Default,
dace.ScheduleType.Sequential: MapSchedule.Sequential,
dace.ScheduleType.CPU_Multicore: MapSchedule.CPU_Multicore,
dace.ScheduleType.GPU_Default: MapSchedule.GPU_Device,
dace.ScheduleType.GPU_Device: MapSchedule.GPU_Device,
dace.ScheduleType.GPU_ThreadBlock: MapSchedule.GPU_ThreadBlock,
}[schedule]
Expand Down

0 comments on commit 6e13354

Please sign in to comment.