Is there a way to declare a Thrust Vector Pointer without actually allocating a vector? I need to use this pointer as a member variable in a class. Since I do not actually know the size of the vector beforehand, I cannot statically allocate the vector as a member variable.
You can use:
#include <thrust/device_ptr.h>
#include <thrust/device_vector.h>
template <typename T>
class my_thrust_class
{
public:
thrust::device_ptr<T> my_dptr;
}
to declare a device pointer that can then be initialized to the start of whatever device_vector you want it to refer to:
thrust::device_vector<float> my_vec(3);
my_thrust_class<float> A;
A.my_dptr = my_vec.data();