[cfe-commits] [PATCH] OpenCL error for elements in a struct

Anton Lokhmotov Anton.Lokhmotov at arm.com
Thu Jun 14 15:46:10 PDT 2012


> I agree.  Has this been reported as a defect in the specification?
I have created one, and will keep you updated.

Basically, the issue is as follows.  A struct type declaration just
specifies the
structure of memory: memory is not allocated until an instance of that
struct type is created.
Thus, declaring a struct member in one address space and then defining an
instance of
that struct in an different address space would result in having
contradictory address space  specifications.

For example:
// legal struct declaration
struct _s1 { int a; float b; }; 
__constant struct _s1 kaiser = {1, 1.0f};

// illegal struct declaration
struct _s2 {
  __constant int a; // illegal use of address space qualifier
  __private float b; // illegal use of address space qualifier
};
__kernel void entry()
{  
  __private struct _s2 king; // where would king.a go?
  __constant struct _s2 tsar = {2, 2.0f}; // where would tsar.b go?
  __local struct s2 chief; // where would chief.a and chief.b go?
}

Cheers,
Anton.







More information about the cfe-commits mailing list