stanford-ppl / spatial

Spatial: "Specify Parameterized Accelerators Through Inordinately Abstract Language"
https://spatial.stanford.edu
MIT License
274 stars 32 forks source link

Mutable Aliasing #7

Closed dkoeplin closed 6 years ago

dkoeplin commented 6 years ago

In part due to its roots in LMS, argon currently disallows mutable aliases of data structures. However, we're now regularly violating this due to the way DRAM views are created.

val x = DRAM[Int](32)
val y = x(0::16)

becomes:

x1 = DRAMNew[Int](32)
x2 = MemDenseAlias[Int,DRAM1,DRAM1](Seq(true), Seq(x1), Seq(Seq(0::16)) )

in the above example, y is a mutable view of a slice of the mutable DRAM x.

Statically resolvable mutable aliases shouldn't be too much of an issue, as a write to an symbol can be considered a write to all of its static aliases. Since Spatial is generating hardware, all aliases have to be statically resolvable anyway.

Long story short we need to rewrite, at least in part, the way we handle write effects / aliasing in argon to correctly handle these cases. @raghup17 @mattfel1 let me know if you have any thoughts on the design.

dkoeplin commented 6 years ago

After discussion with Arvind, there will be a DSL-based configuration flag for enabling/disabling mutable aliases. Spatial will be enabled by default. In the future we may also want to make this type-specific, e.g. the staged type has an "allowMutableAliases" flag.

dkoeplin commented 6 years ago

Added in 7d1fb58acb6675ae93afc87e1e550336df6093e2