Skip to content

Draft: Add Numpy allocator and de-allocator

Ralph Urlus requested to merge RUrlus/armadillo-code:carma_10.5.x into 10.5.x

This, draft, PR enables the usage of the Numpy allocator and de-alloctor with Armadillo under a compile time definition (ARMA_USE_NUMPY_ALLOC) like exists for MKL (ARMA_USE_MKL_ALLOC).

This enables users to hand-over control of the memory between Numpy arrays and Armadillo matrices. It's currently used in CARMA to allow Armadillo to properly take ownership of memory without raising Heap violations on Windows.

Numpy uses malloc/calloc to acquire the memory. A thin wrapper around the allocator has been added in armadillo_bit/numpy_alloc.hpp. Numpy's uses static allocated functions in their API, hence we need to import array API.

Code has been tested through CARMA's test suite but proper tests should be added. If you are open to including the Numpy allocator I will write the tests for Armadillo.

Merge request reports