while i m converting my cuda cpp code to cuda,i m having some vector variables in the cpp code .how to transfer it to the cuda…and the header files also contain vector structures ,i m getting error “type is not defined” while using this vector variables
If you have a custom class type let say class A
with method let say foo()
and attributes fee
. You have to do this.
class A {
void foo();
bool fee;
};
- Write
extern "C" __global__ class A
- Before every function write
__host__
if you want to use it in host device or__device__
if you want to use it on device. You can use both at once too. - Write
__global__
before every attributes.
extern "C" __global__ class A {
__host__ __device__ void foo();
__global__ bool fee;
};
What?
__global__
is not a valid decorator for a struct, class, or variable. There is also no reason such a thing needs to be extern "C"
.