numba/numba — pull request #851 by gmarkall (2014-11-03 17:38:41+00:00)
Title: [WIP] Local array allocation

I'm opening this PR for feedback on the general design/idea of allowing local arrays to be created inside nopython functions, with a view to supporting it on CPU and GPU targets and for ufuncs and gufuncs as well. This PR is opened with the hope that I can get the design right and it be something that everyone is happy with before I go too far down thoroughly implementing and testing it.

This is the smallest example of an implementation, which has some limitations:

- it only works on the CPU,
- it only works for 1D arrays,
- it is not tested thoroughly - there are some unit tests demonstrating its use, but they are not thorough.

Local arrays are created using `numba.local_array.new(shape, dtype)` inside a jitted function. This is macro-expanded to an instance of an `AllocateArray` IR node, which is added in this PR as well. Typing of the `AllocateArray` IR node works in the same way as typing of an `Intrinsic` node. In lowering, an `ArrayTemplate` struct is created and populated with the relevant data, as well as a pointer to newly-allocated space for the array data. The array data space is allocated using an `alloca` instruction.

My thoughts about where to proceed next include creating more thorough tests for operations on local arrays, and expanding the lowering implementation to handle multidimensional arrays, after making revisions to the design/idea based on any feedback.

Any thoughts/feedback appreciated!