Showing results for 
Search instead for 
Did you mean: 

Archives Discussions


OpenCL™ 2.0 Demystified - Generic Address Space

Check out our latest blog in the series here!

From the introduction: "In OpenCL 1.2, each pointer parameter in a function definition must have an associated address space. (The private address space is the default.) This requirement means you must create an explicit version of the function for each desired address space. OpenCL 2.0 introduces a new generic address space: although it cannot store data, a pointer to it can reference data in the private, local, or global address spaces."

As for every blog in this series, the blog discussed the example code in the Beta SDK completely so you get a solid understanding of how it works.

The blog will point you to all the necessary resources so you can be sure you're on compatible hardware, point you to the right driver, and link you to the Beta APP SDK.

Have fun, and let us know how it goes.

2 Replies
Adept II

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.