spcl / spcl/dace

Redundant Array Removal is too Strict with Storage

Open
#1,763 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
593
Forks
163
Avg merge
2d 23h
Merged PRs (30d)
60

Description

Consider the following SDFG

![2024-11-15-132815_420x1042_scrot](https://github.com/user-attachments/assets/cbd2f02e-8dcd-4f91-92da-3c7a1e20da22)

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()
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.