max local array size?

Hi, I’m just wondering how to check for the max local array size ?

You want to know local memory size (CL_DEVICE_LOCAL_MEM_SIZE from clDevice)?

CL_DEVICE_LOCAL_MEM_SIZE for device is a good way to determine max. local memory size supported by the device. The amount of local memory that you can use can vary per kernel. To query the amount of local memory that is currently being used by a kernel you can use clGetKernelWorkGroupInfo(kernel, CL_KERNEL_LOCAL_MEM_SIZE, …). The total amount of local memory that can be used cannot exceed CL_DEVICE_LOCAL_MEM_SIZE.

“being used by a kernel” and that will be used by this kernel at execution.

u can check it by CL_DEVICE_LOCAL_MEM_SIZE argument :wink:

I think I have a similar wish but I´m not sure how to describe my problem.

My situation:
I have for example 10000 Items to be handled and I want to make use of __local memory to speed up. Therefore I create local buffer f.e. like this
__kernel void test(__global MyStruct in_MyStruct)
__local MyStruct l_SharedMemory[FIXED_SIZE]
// make calculations


FIXED_SIZE depends on the hardware I´m running. Therefore I thought get CL_KERNEL_WORK_GROUP_SIZE with clGetKernelWorkGroupInfo and use the result to find the optimal value for FIXED. Afterwards passing FIXED as a compiler option when calling clCreateKernel. Theoretically a good idea - the problem is that for clGetKernelWorkGroupInfo I need a kernel which isn´t created at that time. Any ideas how to find a correct value for fixed size?!?!?!

Why not use CL_DEVICE_LOCAL_MEM_SIZE, which doesn’t require building a kernel?

Alternatively, you can pass the local variable as a kernel argument instead of declaring it as a variable at function scope.