相关疑难解决方法(0)

如何在OpenCL中声明本地内存?

我正在运行下面的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
}
Run Code Online (Sandbox Code Playgroud)

然而,这种拒绝编译,因为参数lengthheight在编译时不知道.但我根本不清楚如何正确地做到这一点.我应该使用memalloc指针吗?如何以一种只为整个工作组分配一次内存而不是每个工作项分配一次的方式来处理这个问题?

我需要的只是2个浮点数组,1个int和1个布尔值,它们在整个工作组之间共享(所以所有100个工作项).但我没有找到任何正确做到这一点的方法......

memory opencl

15
推荐指数
1
解决办法
2万
查看次数

标签 统计

memory ×1

opencl ×1