Dynamically allocated shared memory


I just wondered if there is a possibility to allocate shared mem in opencl dynamically like in CUDA. Maybe someone can help me.

Thanks in advance.

You set your local variable as a kernel argument:

__kernel void Something(..., __local float *var, ...)

And then from host allocate the local memory with clSetKernelArg that has last parameter NULL:

clSetKernelArg(kernel, arg, localMemorySize, NULL);

To know what is the allocated size inside kernel, remember also to pass the number of elements you allocated :slight_smile: .

Thanks very much!!!