Designing a std::pmr-like vector for device memory using Thrust

3 weeks ago 24
ARTICLE AD BOX

I want to implement a container similar to std::pmr::vector, but backed by CUDA device memory, with usage semantics close to std::pmr::vector / thrust::device_vector.

Requirements:

PMR-style interface

Allocation via a polymorphic memory resource

Users must not be able to pass a host memory resource

I considered using thrust::mr::device_memory_resource, but it is final, so I cannot derive from it to restrict resource types.

Questions:

How can I enforce that only device memory resources are accepted, while keeping the API simple and PMR-like?

Why is thrust::mr::memory_resource a template, unlike std::pmr::memory_resource?

Why does thrust::mr::allocator tries to get pointer of MR instead of following the STL allocator model?

Any guidance on the intended Thrust design or best practices would be appreciated.

Read Entire Article