Redundant Array Removal is too Strict with Storage
Opened this issue · 1 comments
philip-paul-mueller commented
Consider the following SDFG
where a
is copied into t
then into p
and finally into b
.
One would expect that simplify (RedundantArrayRemoval
in particular) could remove these copies.
However, this is only the case if t
and p
have the same storage type, since those are transients, one should expect that DaCe would do this.
However, if p
is a register, as it is below in the code, then p
is maintained.
Furthermore, we the subsets would be changed to 0:80
for example, then it would also not work.
import dace
sdfg = dace.SDFG("test")
state = sdfg.add_state(is_start_block=True)
sdfg.add_array(
"a",
shape=(100,),
transient=False,
dtype=dace.float64,
)
sdfg.add_array(
"t",
shape=(100,),
transient=True,
dtype=dace.float64,
)
sdfg.add_array(
"p",
shape=(100,),
transient=True,
dtype=dace.float64,
# If `p` is a register, it can not be optimized away
# but if it is, then it can be removed.
storage=dace.StorageType.Register,
)
sdfg.add_array(
"b",
shape=(100,),
transient=False,
dtype=dace.float64,
)
a, t, p, b = (state.add_access(n) for n in "atpb")
state.add_nedge(
a,
t,
dace.Memlet("a[0:100] -> [0:100]"),
)
state.add_nedge(
t,
p,
dace.Memlet("t[0:100] -> [0:100]"),
)
state.add_nedge(
p,
b,
dace.Memlet("p[0:100] -> [0:100]"),
)
sdfg.validate()
sdfg.simplify()
sdfg.validate()
tbennun commented
For most cases, it’s important to preserve the copies. For other cases, this is why we have permissive=True