CUDA experts, if I have defined in the host code a new type:
struct float_3{
float x;
float y;
float z;
};
and I have transferred some data of this type to the device, can I create __device__ calls of that new type,i.e:
__device__ float_3 foo(float_3 r,float b,int a){
}
Can we create __device__ of any type? Or just int,float,dlouble,void, etc…
And is it possible to return a pointer on __device__? i.e
__device__ float_3* foo(){}
Yes, you can create
__device__of any type. It is just a qualifier that makes that function compile for running on the device and be callable from the device.And by the way, CUDA has a
float3type. I have never used it but if I recall correctly it provides the same functionality of yourfloat_3and also comes with a constructor.