我使用以下OpenCL内核,采用二维全局工作大小为1000000 x 100和本地工作大小为1 x 100。
__kernel void myKernel(
const int length,
const int height,
and a bunch of other parameters) {
//declare some local arrays to be shared by all 100 work item in this group
__local float LP [length];
__local float LT [height];
__local int bitErrors = 0;
__local bool failed = false;
//here come my actual computations which utilize the space in LP and LT
}
然而,由于参数 length
和 height
在编译时不知道,所以这个代码无法编译。但我完全不清楚如何正确地解决这个问题。我应该使用 memalloc 来进行指针操作吗?如何处理才能使内存只在整个工作组中分配一次,而不是每个工作项都分配一次?
我需要的仅仅是两个浮点数数组、1 个整数和 1 个布尔值,它们在整个工作组(即所有 100 个工作项)之间共享。但我未能找到任何正确处理这种情况的方法...