Skip to content

Commit

Permalink
Inter-state edge assignment race test (#1672)
Browse files Browse the repository at this point in the history
Add a validation test for race conditions induced by assigning and
reading the same value in a single interstate edge. For example: `i = j
+ 1; j = ...`
  • Loading branch information
tbennun authored Oct 3, 2024
1 parent 51871a7 commit 6525bc5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dace/sdfg/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ def validate_control_flow_region(sdfg: 'SDFG',
f'Trying to read an inaccessible data container "{container}" '
f'(Storage: {sdfg.arrays[container].storage}) in host code interstate edge', sdfg, eid)

# Check for race conditions on edge assignments
for aname, aval in edge.data.assignments.items():
syms = symbolic.free_symbols_and_functions(aval)
also_assigned = (syms & edge.data.assignments.keys()) - {aname}
if also_assigned:
eid = region.edge_id(edge)
raise InvalidSDFGInterstateEdgeError(f'Race condition: inter-state assignment {aname} = {aval} uses '
f'variables {also_assigned}, which are also modified in the same '
'edge.', sdfg, eid)

# Add edge symbols into defined symbols
symbols.update(issyms)

Expand Down

0 comments on commit 6525bc5

Please sign in to comment.