Forum Discussion
Altera_Forum
Honored Contributor
8 years agoThe answer to your problem is right in the same section in the OpenCL specification:
--- Quote Start --- All program scope variables must be declared in the __constant address space. --- Quote End --- The specification allows to you declare __global pointers inside of a kernel (which can point to an existing __global address space passed onto the kernel as a __global pointer). You cannot have program scope __global variables that are shared between multiple kernels, simply beucase you cannot allocate memory inside the kernel or share data between kernels in OpenCL (unless you use explicit point-to-point communication via channels/pipes). You can, however, have program scope __constant variables that are initialized. As to why it works when you only declare one of the variables: it is likely because the variable is optimized out of the code. I'm not sure why the same thing does not happen when two variables are declared, though. Note that autorun kernels cannot have an interface to host or memory; if you are trying to read data from global memory in an autorun kernel, it is not going to work. You have to read it in a non-autorun kernel and pass it to the autorun kernel using channels.