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 float3
type. I have never used it but if I recall correctly it provides the same functionality of your float_3
and also comes with a constructor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With