Program scope variables seem like a very useful feature. Especially combined with device-side enqueue. One thing that seems a bit limiting about them is that they need to be of constant size. This is why I have the following question:
Is it possible to have a program scope pointer-to-global variable, that can be set to a buffer. So that you can do something like this (pardon if this is not 100% correct OpenCL C):
global int *pB;
kernel void set_buffer(global int *B)
pB = B;
kernel void init_buffer()
pB[get_global_id(0)] = get_global_id(0);
According to OpenCL 2.0 C Spec [section: 6.5.1 __global (or global) or page __global]:
"Variables defined at program scope and static variables inside a function can also be declared in the global address space. They can be defined with any valid OpenCL C data type except for those in table 6.3. In particular, such program scope variables may be of any user-defined type, or a pointer to a user-defined type."
So, it possible to have a program scope pointer-to-global variable. For detail, please see the examples in that section/page. You can find that "global int *pB" is not a valid syntax for that purpose.