以下代码给出了一个错误,我看不出有任何原因。有人可以让我知道我做错了什么。
__global__ void thekernel(float *device_a, int CELLS, int LVLS) {
int t_id = threadIdx.x + blockDim.x * blockIdx.x;
int INR = CELLS - 1;
int col = INR - (threadIdx.x % CELLS);
int row = t_id / CELLS;
float power = (row / pow((float)LVLS, col)) % LVLS;
device_a[t_id] = power;
}
编译错误状态:
cudaMain.cu(11): error: expression must have integral or enum type
这是表达式:
float power = (row / pow((float)LVLS, col)) % LVLS;
如果我从此表达式中删除“% LVLS” ,则代码编译时不会出现任何错误。编译字符串为:
nvcc -G -g -O0 -gencode arch=compute_20,code=sm_20 -odir "" -M -o "cudaMain.d" "../cudaMain.cu"
nvcc --compile -G -O0 -g -gencode arch=compute_20,code=compute_20 -gencode arch=compute_20,code=sm_20 -x cu -o "cudaMain.o" "../cudaMain.cu"
硬件
我的 GPU 卡是:计算能力 2.0 的 Quadro 6000