Skip to content

Add provenance tracking for array cells#129

Open
CT075 wants to merge 4 commits intoTiarkRompf:masterfrom
CT075:cell-provenance
Open

Add provenance tracking for array cells#129
CT075 wants to merge 4 commits intoTiarkRompf:masterfrom
CT075:cell-provenance

Conversation

@CT075
Copy link
Copy Markdown

@CT075 CT075 commented Jul 18, 2023

This PR improves tracking of alias information for nested mutable arrays.

Currently, writes to nested mutable structures are extremely likely to be incorrectly marked as dead code. This is because the current means of effect tracking only tracks one "parent" at a time. That is, in the following snippet:

// a : Rep[Array[Array[Int]]]
val a0 = a(0)
a0(0) = 2
return a

the write to a0(0) is correctly associated with the cell a0, but that write is not propagated to the parent array a, leaving LMS to conclude that the writes are unobservable and can be optimized out.

This PR seeks to fix this by adding a new parameter to the Wrap class, provenance, holding the set of all cells from which the wrapped node originated. For example, the value a0 has provenance [a]. Now, when writing to a0(0), we can properly mark the write as also affecting a.

Presumably, in the future, this change can be subsumed by a more general mechanism like reachability types, but for now this is a simple mechanism that fixes a bug right now.

CT075 added 4 commits July 16, 2023 04:50
Signed-off-by: Cameron Wong <cam@camdar.io>
Signed-off-by: Cameron Wong <cam@camdar.io>
Signed-off-by: Cameron Wong <cam@camdar.io>
Signed-off-by: Cameron Wong <cam@camdar.io>
@namin
Copy link
Copy Markdown
Contributor

namin commented Nov 20, 2023

@Kraks -- any thoughts on this?

@TiarkRompf
Copy link
Copy Markdown
Owner

This seems useful, but I think I would indeed prefer to see this done in a more general way based on reachability types.

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

Successfully merging this pull request may close these issues.

3 participants