Arrays in the cl program

I am having trouble getting arrays in the cl program without using #define arraysize and making static arrays with array[arraysize].

I know dynamic arrays are not allowed, but is there any way to pass a global constant integer through __kernel? From what I understand __kernel only allows pointers for things with class __global. And if I pass a non global integer as my arraysize, the program tells me it is a dynamic array and thus not allowed.

I have also tried passing pre made arrays through __kernel. However when I do it with __global and __local there are memory sharing problems. I think I need things with __private as the class so that memory is not shared between threads, but __kernel doesn’t allow you to pass __private according to the OpenCL handbook. I am not exactly sure I understand how to use __private either.

Right. To quote the spec in section 6.8.d “Variable length arrays and structures with flexible (or unsized) arrays are not supported”.

No. From a kernel perspective, how would that differ from a dynamic / variable length array, if the array length may vary with each kernel execution?

Maybe having a look at this thread will help you to understand how to use __private. The kernel in that example basically passes variable length arrays mA and mB as __global pointers to the kernel, with lengths widthA and widthB each.

What is your Use Case? Dynamic arrays are not allowed indeed but nothing prevents you from compiling kernel with array size defined through #define (or -D option of the compiler, but this option has its drawback).

I don’t know what a Use Case is.

I can get my program to run when using #define to set the size of the arrays. However, my program counts the number entries in the rows (M) of the .csv file I read in. I want to somehow be able to get this number M inside the .cl file so that I can use this number M to create temporary arrays that are of size M. Is it basically impossible without using #define?