I’m trying CUDA Class in c++.
However, I cannot use global in my class.
How can I use global in my class?
Here is my class code and global function.
class CUDA_TVM
{
public:
global void init(float* xbar, float* xn, float* y1, float* y2, float* img, int w, int h, int nc);
}
global
void CUDA_TVM::init(float* xbar, float* xn, float* y1, float* y2, float* img, int w, int h, int nc)
{
int x = threadIdx.x + blockDim.x * blockIdx.x;
int y = threadIdx.y + blockDim.y * blockIdx.y;
if (x < w && y < h) {
int i;
float val;
for (int z = 0; z < nc; z++) {
i = x + w * y + w * h * z;
val = img[i];
xbar[i] = val;
xn[i] = val;
y1[i] = 0.f;
y2[i] = 0.f;
}
}
}