ParallelAccelerator.jl
ParallelAccelerator.jl copied to clipboard
array broadcast rules in PA
Array equivalence analysis treats all arrays in element-wise expressions as having equivalent shape. However, dimensions with size 1 can be broadcast. The example below gives incorrect result instead of throwing an error.
One solution is to specialize to array size dimensions having 1; it will be part of the type in some sort semantically. We could also mention this limitation in documentation and live with it.
using ParallelAccelerator
ParallelAccelerator.ParallelIR.set_debug_level(3)
@acc function btest(A,B,C)
D1 = A.+B
D2 = B.+C
D1.+D2
end
A = ones(2,2)
B = ones(1,2)
C = ones(3,1)
println(btest(A,B,C))
[4.0 3.0; 4.0 1.0]
This was partly discussed in #35
In short, we do not support Julia's semantics of broadcast, and personally I don't think we can. We should amend our documentation to reflect this.