On 8/3/07, David Cournapeau <david@ar.media.kyoto-u.ac.jp> wrote:
> Here is what I can think of:
> - adding an API to know whether a given PyArrayObject has its data
> buffer 16 bytes aligned, and requesting a 16 bytes aligned
> PyArrayObject. Something like NPY_ALIGNED, basically.
> - forcing data allocation to be 16 bytes aligned in numpy (eg
> define PyDataMem_Mem to a 16 bytes aligned allocator instead of malloc).
All this sounds pretty similar to sdt::allocator we can found in C++
STL (http://www.sgi.com/tech/stl/Allocators.html). Perhaps a NumPy
array could be associated with an instance of an 'allocator' object
(surely written in C, perhaps subclassable in Python) providing
appropriate methos for
alloc/dealloc(/realloc?/initialize(memset)?/copy(memcpy)?) memory.
This would be really nice, as it is extensible (you could even write a
custom allocator, perhaps making use of a preallocated,static pool;
use of C++ new/delete; use of any C++ std::allocator, shared memory,
etc. etc.). I think this is the direction to go but no idea how much
difficult it could be to implement.
--
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594