[Numpy-discussion] numpy arrays, data allocation and SIMD alignement

David Cournapeau david at ar.media.kyoto-u.ac.jp
Thu Aug 9 03:52:38 EDT 2007

Charles R Harris wrote:
> Well, what you want might be very easy to do in python, we just need 
> to check the default alignments for doubles and floats for some of the 
> other compilers, architectures, and OS's out there. On the other hand, 
> you might not be able to request a c malloc that is aligned in a 
> portable way without resorting to the same tricks as you do in python. 
> So why not use python and get the reference counting and garbage 
> collection along with it?
First, doing it in python means that I cannot use the facility from C 
easily. But this is exactly where I need it, and where I would guess 
most people need it. People want to interface numpy with the mkl ? They 
will do it in C, right ? And maybe I am just too dumb to see the 
problem, but I don't see the need for garbage collection and so on :) 
Again, what is needed is:
    - aligned allocator -> we can use the one from Steven Johnson, used 
in fftw, which support more or less the same archs than numpy
    - Refactor the array creation functions in C such as the 
implementation takes one additional alignement argument, and the 
original functions are kept identical to before
    - Add a few utilities function to check whether it is SSE aligned, 
arbitrary aligned, etc...

The only non trivial point is 2 . Actually, when I first thought about 
it, I thought about fixing alignement at compile time, which would have 
made it totally avoidable: it would have been a simple change of the 
definition of PyDataMem_New to an aligned malloc with a constant. I have 
already the code for this, and besides aligned malloc code, it is like a 
5 lines change of numpy code, nothing terrible, really.


More information about the NumPy-Discussion mailing list