IntelLabs / numba

NumPy aware dynamic Python compiler using LLVM
http://numba.pydata.org/
BSD 2-Clause "Simplified" License
12 stars 2 forks source link

Reduction implementation simplification #51

Closed ninegua closed 6 years ago

ninegua commented 6 years ago

Add pndindex as another parallel iterator in addition to prange, mirroring the sequential counter part ndindex.

So function _convert_prange is now called _convert_loop, processes loops from inner to outer, and is no longer nested.

Simplify the implementation of reduction implementation by directly giving parallel implementations as Python functions using either pndindex or prange, which are inlined in preparfor stage.

Also pass return type as the argument to the parallel function implementors, which helps type inference.

Translate reduce(A[M]) to a single loop when M is a boolean array. The case where the actual reduction is being implemented as pndindex loop is also handled.

ninegua commented 6 years ago

All tests pass for python 3.6. There is some fusion issue with python 2.7 where some statement gets in between two parfors (in test_fusion_argmin). I think a minor fix will do, but I probably won't have time for it.

ehsantn commented 6 years ago

It looks good to me overall. We can fix the 2.7 issue later. I think more comments would help with maintenance moving forward.