PDA

View Full Version : Dynamically allocated shared memory



DP007
11-27-2009, 03:45 AM
Hi,

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.
Daniel

jbasic
11-27-2009, 11:13 AM
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 :) .

DP007
11-30-2009, 02:17 AM
Thanks very much!!!