Thrust pinned memory in CUDA 12.0

Up to CUDA 11.7 one coud use something like:

#include “thrust/system/cuda/experimental/pinned_allocator.h”

thrust::host_vector<float,thrust::cuda::experimental::pinned_allocator> a(100);

In the thrust release for CUDA 12 the include file is not present. I suspect pinned memory is not experimental any more, but I can’t figure out what to do instead. Could you please provide and example. I am using Windows 10 x64. Thanks

4 Likes

We’re about to update to CUDA 12, but our library currently relies on “thrust::cuda::experimental::pinned_allocator”. As for rea1 I can’t locate the corresponding header file in CUDA 12. Any help is appreciated.

It should be something like the following for current Thrust versions.

using mr = thrust::system::cuda::universal_host_pinned_memory_resource;
using pinned_allocator = thrust::mr::stateless_resource_allocator<T, mr >;
1 Like

I think the ::system is not needed bu other than that it should work.

For reference see thrust/system/cuda/memory_resource.h.