pnumpy icon indicating copy to clipboard operation
pnumpy copied to clipboard

would like numpy to add a hook when it allocates arrays

Open tdimitri opened this issue 5 years ago • 5 comments

This issue may belong in another place but for tracking purposes I added it here. It would be nice if numpy not only allocated on 32byte or 64byte boundaries, but did so in an official way (often leaving magic markers to the memory just behind the original pointer) that could be hooked. This would allow a new array memory allocator to hook how numpy arrays are allocated offering features such as array recycling or numa node allocations.

In the future it could be used to allocate arrays that span multiple computers.

tdimitri avatar Sep 29 '20 13:09 tdimitri

numpy/numpy#17467

mattip avatar Oct 06 '20 13:10 mattip

Now has a PR numpy/numpy#17582, please check that it has the desired features.

mattip avatar Oct 19 '20 06:10 mattip

The current API allows overriding alloc/calloc/free/realloc. Is there a reason to add memcpy overrides for host2obj, obj2obj, obj2host? Do you see a reason this would ever not be memcpy? I don't think GPU arrays are in scope at this time.

mattip avatar Oct 19 '20 19:10 mattip

The upcoming 1.22 release of NumPy will include configurable allocators.

mattip avatar Oct 27 '21 06:10 mattip

Thanks for pushing the idea and helping with the design.

mattip avatar Oct 27 '21 06:10 mattip