amrex icon indicating copy to clipboard operation
amrex copied to clipboard

ParticleContainer: Allocator Could be Runtime?

Open ax3l opened this issue 2 years ago • 2 comments

The allocator in the ParticleContainer classes is a template argument, as in low level C++ objects like std::vector et al.

I think this is a bit of a design issue, impacting at least for me:

  • compile-time
  • link-time
  • maintainability
  • extensibility

in downstream codes and pyAMReX, because every template argument needs to be specialized, compiled, linked, etc.

@WeiqunZhang @atmyers do you think that long-term, we could make the PC classes using the allocator as a runtime argument, as we do in MultiFabs? This would simplify a lot for me downstream.

ax3l avatar Nov 27 '23 22:11 ax3l

This can already be done by setting the templated allocator to amrex::PolymorphicArenaAllocator. The question is if this should be the default or maybe even the only allocator?

Currently with amrex::PolymorphicArenaAllocator one has to loop over all components of all particle tiles to set the arena. It would be nice if there were some helper functions for this, while also keeping the flexibility of having different allocators for different components.

AlexanderSinn avatar Nov 28 '23 00:11 AlexanderSinn

Thanks @AlexanderSinn, I was not aware of that. I chatted with @WeiqunZhang confirming that we should be good to use the amrex::PolymorphicArenaAllocator for all our classes in BLAST codes, simplifying build times.

Yes, let's add a helper for setting all components at once.

ax3l avatar Dec 01 '23 23:12 ax3l