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

Charles R Harris charlesr.harris@gmail....
Thu Aug 9 03:05:03 CDT 2007


On 8/9/07, David Cournapeau <david@ar.media.kyoto-u.ac.jp> wrote:
>
> 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.


Ah, you want it in C. Well, I think it would not be too difficult to change
PyDataMem_New, however, the function signature would change and all the code
that used it would break. That is pretty drastic. Better to define
PyDataMem_New_Aligned, then redefine PyDataMem_New to use the new function.
That way nothing breaks and you get the function you need. I don't think
Travis would get upset if you added such a function and documented it.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070809/24e4e522/attachment.html 


More information about the Numpy-discussion mailing list