I am using Thrust vectors for cuda kernels and i have created my own struct so i can pass in all of the data together, when i initialise a host vector of my custom type i get a build error from thrust.
initialisation of the vector:
host_vector<PhysicsData> physicsDataVector(numPeople + 1, 0);
custom data type:
__device__ __host__ struct PhysicsData {
vector3 position;
vector3 velocity;
vector3 acceleration;
vector3 force;
float massInvert = 1.f;
float drag = 1.f;
bool dead = false;
__device__ __host__ PhysicsData(){
massInvert = 1.f;
drag = 1.f;
dead = false;
position = vector3();
velocity = vector3();
acceleration = vector3();
force = vector3();
};
};
Error:
Severity Code Description Project File Line Suppression State
Error C2664 'void thrust::detail::vector_base<T,Alloc>::fill_init(unsigned __int64,const T &)': cannot convert argument 2 from 'IteratorOrIntegralType' to 'const T &' DefinitelyNotGodzillaCuda C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include\thrust\detail\vector_base.inl 208
The issue was I was using the wrong constructor for the vector, I for some reason had a
, 0in my constructor so changing it to this fixed it