cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

awkehwe82397rfaowUI
Journeyman III

Global program variables

I have a question about global program variables in OpenCL. Not the __global type, but real C-type global program variables. Please look at the attached code to see an example of what I mean. 

Basically, I'm trying to use global variables in a C-like manner so that other functions in my OpenCL program can access the data (both read AND write) without me having to pass around a whole punch of pointers to each function.

However, when I run my example code, I get a warning from the compiler that says: "warning: global variable must be declared in addrSpace constant, other qualifiers ignored" for the __global real* independentDataTest; declaration.

The example works just fine even with this warning and the global variable being in the __global address space.

My question is if this is an okay technique for using C-like global variables in OpenCL or will it break down the line with a new SDK?

I'm using the ATI Stream SDK 2.0 Beta4 at the moment. 

__global float* independentDataTest; __kernel void testK1(__global float* independentData, const uint numData) { if (get_global_id(0) == 0) { independentDataTest = independentData; for (int i = 0; i < numData; i++) { independentDataTest = (float)(i); } } }

0 Likes
1 Reply
genaganna
Journeyman III

It might be a error in future releases.  As per the spec, you are not allowed to create memory in kernel code so you need to pass pointers around as a function parameter and should be initialized with same addressSpace pointer.

0 Likes