xtensor icon indicating copy to clipboard operation
xtensor copied to clipboard

Memory pool for Xtensor

Open spectre-ns opened this issue 1 year ago • 6 comments

I would like to use xtensor in a real time computing application and I need to avoid allocations from new and delete while computing the data with all the allocations occurring prior to computation starting. I can use std::pmr to accomplish this is there any way to pin xtensor to this memory object?

spectre-ns avatar Aug 17 '22 12:08 spectre-ns

I think you can use your own allocator as an argument in the template.

wolfv avatar Aug 17 '22 14:08 wolfv

@wolfv thanks! I have been able to use the polymorphic_allocator<> to get xtensor working from a pool. Would there be anyway to pass it the resource like std::pmr:vector does so I don't have to set the global resource pointer?

spectre-ns avatar Aug 17 '22 15:08 spectre-ns

This requires to update the constructors of the xtensor and xarray classes, so they accept an additional argument and forward it to the storage container. This is definitely a PR that we would accept, I can provide some guidance if needed.

JohanMabille avatar Aug 22 '22 09:08 JohanMabille

@JohanMabille I have another pull request on my queue right now. After I complete that I might work on this. Is QuantStack still adding features to xtensor as well or are their other priorities right now?

spectre-ns avatar Aug 23 '22 00:08 spectre-ns

Both, xtensor is not funded at this time, so we are maintaining it on our free time, but we still have ideas and a plan for xtensor ;)

JohanMabille avatar Aug 23 '22 06:08 JohanMabille

@JohanMabille I think making xtensor work with pmr would require C++17.

spectre-ns avatar Oct 03 '22 22:10 spectre-ns