gilbo / ebb

DSL for physical simulation
http://ebblang.org
Other
86 stars 11 forks source link

Reducing / Field Write into part of a vector/matrix field is erroneously allowed #41

Closed gilbo closed 9 years ago

gilbo commented 9 years ago

Here's a snippet of code with the problem:

for r = 0,3 do
  t.e[i,v].stiffness[r,k] += dH[r,i]
end

So, the problem here is that the left-hand side is not correctly resolved as a field-write (actually reduction) here because the conversion of Assignment AST nodes into GlobalWrite or FieldWrite AST nodes relies on pattern matching the pattern Assignment(Global, rhs) or Assignment(FieldAccess, rhs) and rewriting the Assignment into a GlobalWrite or FieldWrite node.

However, in the above snippet of code, the immediate left hand-side of the assignment is actually a SquareIndex ast node (the indexing into the stiffness matrix).

In general, the phenomenon which will trigger this problem is trying to reduce/write into only one entry of a vector or matrix field/global value. We should either disallow this entirely (not recommended) or fix it so that this is correctly detected as a write/reduce by the typechecker (recommended).

schinmayee commented 9 years ago

Added support for reducing components of complex types (small matrices, vectors) for globals and fields -- we now have two additional ast node types globalindex and fieldaccessindex. Made a test out of the neohookean example that used to give wrong results on gpu, and verified that results are now correct on gpu. Tests that used to pass before on cpu/ gpu continue passing, and soleil and fem examples run without throwing any errors.

gilbo commented 9 years ago

woot!

On Jun 8, 2015, at 4:29 PM, chinmayeeS notifications@github.com wrote:

Closed #41.

— Reply to this email directly or view it on GitHub.