variable length array declaration not allowed in OpenCL - why?

后端 未结 2 1760
我寻月下人不归
我寻月下人不归 2021-01-12 04:02

I want to create a local array inside my OpenCL kernel, whose size depends on a parameter of the kernel. It seems that\'s not allowed - at least with AMD APP.

Is you

2条回答
  •  萌比男神i
    2021-01-12 04:55

    Not sure why people are saying you can't do this as it is something many people do with OpenCL (Yes, I understand it's not exactly the same but it works well enough for many cases).

    Since OpenCL kernels are compiled at runtime and, just like text, you can just simply set the size to whatever size you want and then recompile your kernel. This obviously won't be perfect in cases where you have huge variability in sizes but usually I compile several different sizes at startup and then just call the correct one as needed (in your case based on the kernel argument). If I get a new size I don't have a kernel for I will compile it right then and cache the kernel in case it comes up again.

提交回复
热议问题