matrixmultiply icon indicating copy to clipboard operation
matrixmultiply copied to clipboard

Give the user the ability to allocate all memory himself

Open cospectrum opened this issue 2 years ago • 4 comments

Hello! I noticed that each gemm call allocates memory on the heap for "packing buffers". So maybe there is a way to give the user the ability to pre-allocate all the necessary memory and simply pass it as an argument without using a global allocator?

For example, add helper function(s) to the public api to calculate the required memory for a particular type/shape/kernel, and then initialize aligned_alloc::Alloc struct from a pointer or something like that.

I think this feature can help use the crate in real-time programs where hidden allocations are not welcome

cospectrum avatar Sep 22 '23 19:09 cospectrum

I would like to use it in realtime as well, so +1 on that :)

steckes avatar Nov 21 '23 11:11 steckes

If anyone is interested, I created microgemm. It does not make allocations on its own. I'm trying to keep it very flexible and avoid unsafe

cospectrum avatar Dec 14 '23 05:12 cospectrum

Custom allocators would help. Maybe allocator-api2

cospectrum avatar Mar 05 '24 10:03 cospectrum

@cospectrum On microcontrollers I was using matrixmultiply already with this allocator: Buddy System Allocator. Do you think I can just use this allocator on desktop and then it is "real-time" safe, because it is taking the memory from the pre-allocated memory?

steckes avatar Mar 06 '24 10:03 steckes