Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redundant Array Removal is too Strict with Storage #1763

Open
philip-paul-mueller opened this issue Nov 15, 2024 · 1 comment
Open

Redundant Array Removal is too Strict with Storage #1763

philip-paul-mueller opened this issue Nov 15, 2024 · 1 comment

Comments

@philip-paul-mueller
Copy link
Collaborator

Consider the following SDFG

2024-11-15-132815_420x1042_scrot

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
Copy link
Collaborator

tbennun commented Nov 15, 2024

For most cases, it’s important to preserve the copies. For other cases, this is why we have permissive=True

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants