我有类似下面的代码:
__device__ unsigned char* device_func(unsigned char* var_sh, unsigned char param){
if (var_sh[0] == param)
return var_sh + param;
else return 0;
}
__global__ void global_func(uchar parameters){
extern __shared__ unsigned char var_sh[];
//just copying things from global to shared memory:
for(int i = blockIndex; i < size; i += blockDim.x * gridDim.x){
var_sh[i] = rla->initial[i];
}
var_sh = device_func(var_sh, parameters);
}
这个全局函数是这样调用的:
global_func<<< blocks,threads,shared_size >>>(parameters);
但是当我尝试编译时,编译器在“var_sh = device_func(var_sh, parameters);”行返回以下错误:
“错误:表达式必须是可修改的左值”
不知道为什么,谁能解释一下?