Skip to content

Commit

Permalink
Fix redefinition of interstate edge type in code generator (spcl#1490)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbennun authored Jan 4, 2024
1 parent 4d49452 commit e427617
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dace/codegen/targets/framecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,8 +887,9 @@ def generate_code(self,

# NOTE: NestedSDFGs frequently contain tautologies in their symbol mapping, e.g., `'i': i`. Do not
# redefine the symbols in such cases.
if (not is_top_level and isvarName in sdfg.parent_nsdfg_node.symbol_mapping
and str(sdfg.parent_nsdfg_node.symbol_mapping[isvarName]) == str(isvarName)):
# Additionally, do not redefine a symbol with its type if it was already defined
# as part of the function's arguments
if not is_top_level and isvarName in sdfg.parent_nsdfg_node.symbol_mapping:
continue
isvar = data.Scalar(isvarType)
callsite_stream.write('%s;\n' % (isvar.as_arg(with_types=True, name=isvarName)), sdfg)
Expand Down
14 changes: 14 additions & 0 deletions tests/codegen/symbol_arguments_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,21 @@ def tester(A: dace.float64[N, N]):
assert 'N' in sdfg.arglist()


def test_nested_sdfg_redefinition():
sdfg = dace.SDFG('tester')
nsdfg = dace.SDFG('nester')
state = sdfg.add_state()
nnode = state.add_nested_sdfg(nsdfg, None, {}, {}, symbol_mapping=dict(sym=0))

nstate = nsdfg.add_state()
nstate.add_tasklet('nothing', {}, {}, 'a = sym')
nstate2 = nsdfg.add_state()
nsdfg.add_edge(nstate, nstate2, dace.InterstateEdge(assignments=dict(sym=1)))
sdfg.compile()


if __name__ == '__main__':
test_global_sizes()
test_global_sizes_used()
test_global_sizes_multidim()
test_nested_sdfg_redefinition()

0 comments on commit e427617

Please sign in to comment.