Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CUDA __device__ of type struct

Tags:

cuda

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(){}

like image 984
Manolete Avatar asked Jul 08 '11 14:07

Manolete


1 Answers

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.

like image 85
jmsu Avatar answered Oct 03 '22 06:10

jmsu