cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

nooploop
Journeyman III

Different address space elements in structs/unions

Hello,

reading the restrictions of OpenCL i came across this:

Elements of a struct or union must belong to the same address space. Declaring a struct or union whose elements are in different address spaces is illegal.

So i went and tried the attached code. And the compiler didnt complained. Shouldn't this code be rejected, or atleast shouldn't i get a warning? Or i'm completly wrong and missing something?

 

union glp { __local int *l; __global int *g; }; struct sglp { __local int *l; __global int *g; }; __kernel void func() { struct sglp x; x.l = 0; x.g = 0; union glp y; y.l = 0; y.g = 0; }

0 Likes
2 Replies
nou
Exemplar

try wihout *.

EDIT: ust tryed

/tmp/OCLr2eqzX.cl(7): error: field type cannot be qualified with named address
          space
  __global int a;

you have struct of pointers which point into different address space. so it is somehow valid as that pointers are in same address space.

0 Likes

nou is correct. The pointers are in the same address space, but they point to data in different address spaces.
0 Likes