Open ehsantn opened 6 years ago
Right now since we don't translate A += B
to parfor, the above example should be relatively easier to handle.
But more generally, if it was written as A = A + B
, then the reduction code becomes a parfor before lowering, and then at lowering stage, it would be rather difficult to extract the set of reduction instructions.
Also, with prange it is possible to write:
for i in numba.prange(n):
A += B
C[i] = A
This is a lot more difficult to handle correctly. In general, there are a lot of restrictions on what can be safely parallelized for an arbitrary loop. We are not doing a good job at checking them.
Yes, it can get very complicated. We should check as many conditions as possible. They should be documented for sure.
We need to support reduction of arrays in the gufunc backend. Example below.