simit icon indicating copy to clipboard operation
simit copied to clipboard

Assembly functions should use `+=`

Open fredrikbk opened this issue 8 years ago • 1 comments

Assembly functions currently use = to assign to their element matrix. This causes issue with code generation, because our current backends rewrites the assignments to plus-assign directly into the system matrix. If the user assigns to the same location twice, the result is that the values are accumulated, instead of overwritten. To avoid this, we can either:

  1. Keep element matrices on the stack, and only write them to the system matrix at the end of local assembly, or
  2. Force assembly functions to use +=, which makes the behavior match what happens right now.

I think we should do 2 for now, and add support for = later iff it's needed. Keeping element matrices on the stack and copying them may have performance implications. Due to improved locality these could actually go either way..

fredrikbk avatar Aug 03 '16 17:08 fredrikbk

When += is added the example in the "Apply Stencil Update Function" language section should be updated to use it. It's currently:

func move(inout p : Point)
  p.x(0) = p.x(0) + 1.0;
end

fredrikbk avatar Aug 16 '16 15:08 fredrikbk