stanford-ppl / spatial

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

Bias for scatter/gather API #164

Closed mattfel1 closed 5 years ago

mattfel1 commented 5 years ago

One request is to be able to include an offset value for all data read from a memory, for things like manual buffering of scatter/gather. Here is a meaningless example:

val d = DRAM(4096)
...
Accel {
  val s = SRAM(64) // 
  Foreach(N by 1){i => 
    val bias = mux(i % 2 == 0, 0, 2048)
    ...
    d(s + bias) scatter s            <-----------------
    OR
    d(s, ofs = bias) scatter s     <-----------------
}

The second option is so much easier to implement, but the first option looks prettier and could be used in other places I think. Maybe if we change Views slightly we can have an API for mem/memview + Bits[T]. Then maybe we can do things like sram1 store (sram2 + 5) to copy all of sram2 into sram1 and add 5 to each (some people seem really adamant about syntax for copying from sram to sram even though I haven't seen a case yet where it is actually a good idea or necessary)

mattfel1 commented 5 years ago

This exists now. See ScatterGather_Bias app. Ex:

          addrs load srcAddrs(i::i + numscats par P)
          sram gather inData(addrs par P, numscats.to[I64], origin = bias)
          scatterResult(addrs par P, numscats.to[I64], origin = bias) scatter sram