How to declare local memory in OpenCL?

后端 未结 3 1386
醉梦人生
醉梦人生 2020-12-15 07:53

I\'m running the OpenCL kernel below with a two-dimensional global work size of 1000000 x 100 and a local work size of 1 x 100.

__kernel void myKernel(
              


        
3条回答
  •  情歌与酒
    2020-12-15 08:09

    You could also declare your arrays like this:

    __local float LP[LENGTH];
    

    And pass the LENGTH as a define in your kernel compile.

    int lp_size = 128; // this is an example; could be dynamically calculated
    char compileArgs[64];
    sprintf(compileArgs, "-DLENGTH=%d", lp_size);
    clBuildProgram(program, 0, NULL, compileArgs, NULL, NULL);
    

提交回复
热议问题