Hi,
I need in a kernel to allocate a local memory zone :
__local int chunck[get_local_size(0)];
Unfortunately, it is forbidden.
So, what is the best way to do this ?
Remarks: I think that it is simple to allocate a buffer on the host side and declare it local in the kernel. Right ?
Thanks
You need not allocate a buffer for __local memory. All you need is when you set kernel arguments, you specify the size you wish, and give a NULL for data. Inside the kernel you decalre the given kernel argument to be __local int* chunck.
TADAA, you got your fixed size __local array.
It is what I say in my "remarks" lol 😄
But thanks for the confirmation 😉
My main problem is to check how the "local buffer allocation" has an impact on the ideal work-group size !!!! 😛
Beware that statically allocated memory from host will not affect preferred workgroup size, as at compile time the API has no knowledge of how much will you allocate with clSetKernelArg(). Because of this you can allocate practically infinite amount of local without pref. WGS being changed, and excess local memory will reside in VRAM. You will still access it via the __local memoryspace, but the speed will be much slower. If you start allocating local from host, you will have to start keeping track of how much memory you allocated.
I know that physically it is limited, but I was very much surprised that I was running simulations very well with a kernel that used 48kB of local memory on a HD5970. Then I was told that the excess memory will reside on VRAM. If this is not the case, then there was true black magic going on.