Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No-View Nested SDFGs #1696

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 4 additions & 3 deletions dace/codegen/targets/cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ def emit_memlet_reference(dispatcher: 'TargetDispatcher',
ancestor: int = 1,
is_write: bool = None,
device_code: bool = False,
decouple_array_interfaces: bool = False) -> Tuple[str, str, str]:
decouple_array_interfaces: bool = False,
use_offset: bool = False) -> Tuple[str, str, str]:
"""
Returns a tuple of three strings with a definition of a reference to an
existing memlet. Used in nested SDFG arguments.
Expand All @@ -289,7 +290,7 @@ def emit_memlet_reference(dispatcher: 'TargetDispatcher',
"""
desc = sdfg.arrays[memlet.data]
typedef = conntype.ctype
offset = cpp_offset_expr(desc, memlet.subset)
offset = cpp_offset_expr(desc, memlet.subset) if use_offset else '0'
offset_expr = '[' + offset + ']'
is_scalar = not isinstance(conntype, dtypes.pointer)
ptrname = ptr(memlet.data, desc, sdfg, dispatcher.frame)
Expand Down Expand Up @@ -368,7 +369,7 @@ def make_const(expr: str) -> str:
is_scalar = True
elif defined_type == DefinedType.StreamArray:
# Stream array to stream (reference)
if memlet.subset.num_elements() == 1:
if use_offset and memlet.subset.num_elements() == 1:
ref = '&'
typedef = defined_ctype
is_scalar = True # Avoid "&" in expression below
Expand Down
3 changes: 2 additions & 1 deletion dace/codegen/targets/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ def allocate_view(self, sdfg: SDFG, cfg: ControlFlowRegion, dfg: SDFGState, stat
name,
dtypes.pointer(nodedesc.dtype),
ancestor=0,
is_write=is_write)
is_write=is_write,
use_offset=True)

# Test for views of container arrays and structs
if isinstance(sdfg.arrays[viewed_dnode.data], (data.Structure, data.ContainerArray, data.ContainerView)):
Expand Down
6 changes: 4 additions & 2 deletions dace/codegen/targets/intel_fpga.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,15 +921,17 @@ def allocate_view(self, sdfg: dace.SDFG, cfg: ControlFlowRegion, dfg: SDFGState,
name,
dtypes.pointer(nodedesc.dtype),
ancestor=0,
device_code=self._in_device_code)
device_code=self._in_device_code,
use_offset=True)
else:
qualifier = ""
atype, aname, value = cpp.emit_memlet_reference(self._dispatcher,
sdfg,
edge.data,
name,
dtypes.pointer(nodedesc.dtype),
ancestor=0)
ancestor=0,
use_offset=True)
declaration_stream.write(f'{qualifier}{atype} {aname} = {value};', cfg, state_id, node)

def generate_memlet_definition(self, sdfg, cfg, dfg, state_id, src_node, dst_node, edge, callsite_stream):
Expand Down
Loading