Create local array dynamic inside OpenCL kernel

天大地大妈咪最大 提交于 2019-12-03 15:05:50

This can be achieved by adding __local array as a kernel parameter:

__kernel void test(__global int **values, __global int *result, 
    const int array_size, __local int * cache)

and providing desired size of the kernel parameter:

clSetKernelArg(kernel, 3, array_size*sizeof(int), NULL);

The local memory will be allocated upon the kernel invocation. Note, that extra checks may be necessary to ensure that required local memory size does not exceed the device limit.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!