Skip to content

Commit

Permalink
Fixed a bug.
Browse files Browse the repository at this point in the history
I was using the `symetric_difference()` instead of the `difference()` function to handle the inter state edges.
However, this also lead to a clarification and a stricter handling of interstate edges.
I.e. as soon as data is accessed on an interstate edge, it can never be exclusive.
Furthermore, now not only the read symbols but all free symbols are used.
  • Loading branch information
philip-paul-mueller committed Jan 27, 2025
1 parent 2ad4b98 commit d2d9f50
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions dace/transformation/passes/analysis/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ class FindExclusiveData(ppl.Pass):
This means that for every data descriptor there exists exactly one AccessNode that
refers to that data. In addition to this the following rules applies as well:
- If the data is also read on an inter state edge it will not be classified as exclusive.
- If the data is read by at least one interstate edge it will not be classified as exclusive.
- If there is no reference to a data descriptor, i.e. it exists inside `SDFG.arrays`
but there is no AccessNode, then it is _not_ classified as exclusive.
"""
Expand Down Expand Up @@ -391,10 +391,11 @@ def _find_exclusive_data_in_sdfg(self, sdfg: SDFG) -> Set[str]:
# Compute the set of all data that is accessed, i.e. read, by the edges.
interstate_read_symbols: Set[str] = set()
for edge in sdfg.edges():
interstate_read_symbols.update(edge.data.read_symbols())
interstate_read_symbols.update(edge.data.free_symbols)

# Data can only be exclusive, if it is also _not_ accessed on an interstate edge.
return exclusive_data.symmetric_difference(interstate_read_symbols)
# Enforces the first rule, "if data is accessed by an interstate edge it will
# not be classified as exclusive".
return exclusive_data.difference(interstate_read_symbols)


@properties.make_properties
Expand Down
10 changes: 5 additions & 5 deletions tests/passes/find_exclusive_data_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,11 @@ def test_access_only_on_interstate_edge():
sdfg = _make_access_only_on_interstate_edge_sdfg()
assert len(sdfg.arrays) == 5

# `e` is part of the exclusive set, because it is only accessed on an interstate edge.
expected_exclusive_set = sdfg.arrays.keys()
# `e` is only accessed on the interstate edge. So it is technically an exclusive
# data. But by definition we handle this case as non exclusive.
expected_exclusive_set = {aname for aname in sdfg.arrays.keys() if aname != 'e'}
exclusive_set = perform_scan(sdfg)
assert len(exclusive_set[sdfg]) == 5
assert len(exclusive_set[sdfg]) == 4
assert exclusive_set[sdfg] == expected_exclusive_set


Expand Down Expand Up @@ -247,8 +248,7 @@ def test_additional_access_on_interstate_edge():
sdfg = _make_additional_access_on_interstate_edge_sdfg()
assert len(sdfg.arrays) == 6

# In this test `e` is not part of the exclusive set as it was in `test_access_only_on_interstate_edge`.
# The reason is because now there exists an AccessNode for `e`.
# As in `test_access_only_on_interstate_edge` `e` is not part of the exclusive set.
expected_exclusive_set = {aname for aname in sdfg.arrays.keys() if aname != 'e'}
exclusive_set = perform_scan(sdfg)
assert len(exclusive_set[sdfg]) == 5
Expand Down

0 comments on commit d2d9f50

Please sign in to comment.