1 year ago

#284224

test-img

alfC

What is the correct way to rebind a thrust pointer in thrust 11.5

I am using the CUDA thrust library inside a heavily templated library that depends a lot in template metafunctions to deduce related types.

In thrust 11.3, type thrust::cuda::allocator<T>::pointer yields thrust::cuda_cub::pointer<T>, for any T (for example double).

In turn I can use rebind to obtain the const version. That is, type std::pointer_traits<thrust::cuda_cub::pointer<T>>::rebind<T const> yields thrust::cuda_cub::pointer<T const>.

No surprises so far.

In thrust 11.5, thrust::cuda::allocator<T>::pointer yields a more complicated type thrust::pointer<T, thrust::cuda_cub::tag, thrust::tagged_reference<T, thrust::cuda_cub::tag>, thrust::use_default>, which is presumably equivalent to the old type.

The problem is that I cannot obtain the const version of this pointer in the usual way, because std::pointer_traits<thrust::pointer<T, thrust::cuda_cub::tag, thrust::tagged_reference<T, thrust::cuda_cub::tag>, thrust::use_default>::rebind<T const> yields what I know (by other means) that is an incorrect type: thrust::pointer<T const, thrust::cuda_cub::tag, thrust::tagged_reference<T, thrust::cuda_cub::tag>, thrust::use_default>.

(the tagged reference type should be T const).

What is the correct way to obtain the const version of a thrust 11.5 pointer using rebind?

EDIT: I opened and issue https://github.com/NVIDIA/thrust/issues/1629#issuecomment-1066331885

c++

pointers

typetraits

thrust

0 Answers

Your Answer

Accepted video resources