我是 OpenCL 的新手,我遇到了问题。在我的程序中,我需要一个二维数组。我将一维数组复制到显卡。因为我不需要一维数组,所以我编写了一个方法来初始化所有需要的值。二维数组应该是 __global --- 我只对这个数组进行了读取操作。
这是我的代码
typedef struct{
unsigned char r;
unsigned char g;
unsigned char b;
unsigned char a;
} ColorRGBA;
__constant ColorRGBA array[4096];
__kernel void marchingCubes(__global unsigned char* output)
{
// DO SOMETHING WITH array
}
__kernel void initValues(__global unsigned char* input){
// FILL array MAKE 1-dimensional to 2-dimensional (4096,4)
array = (ColorRGBA*) input;
}
编译 OpenCL 程序时,出现以下错误:
:28:8: error: array type 'ColorRGBA __attribute__((address_space(2))) [4096]' is not assignable
array = (ColorRGBA*) input;
我怎样才能访问每个线程中的重塑数组?
谢谢格莱西恩