simit
simit copied to clipboard
Assembly functions should use `+=`
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:
- Keep element matrices on the stack, and only write them to the system matrix at the end of local assembly, or
- 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..
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