Class instance with address space

C++ source, compiled as clang++ --target=amdgcn-amd-amdhsa

struct t
int v;
attribute((address_space(3))) t d;

// error: no matching constructor for initialization of 'attribute((address_space(3)))

with t() : v(0) {}, same error

with t() attribute((address_space(3))) : v(0) {},
// error: function type may not be qualified with an address space

How should I be spelling this? I’m essentially trying to replicate cuda’s shared. Ideally I’d like implicit conversions to a and from an int which is not address space qualified, but right now I’m stuck on the constructor.



Hi Jon,

There’s currently no way to qualify a method with an arbitrary address space. There is a work-in-progress patch on it:

and I have an experimental local patch that tries to alleviate some issues with the patch above, but it doesn’t really work. Parsing this pattern properly is unfortunately rather difficult. There’s also no real syntax support in C++ for qualified constructors/destructors, which is another problem.

/ Bevin

Hi Bevin,

Thanks for the link! I like the approach, though the complexity makes me nervous. I think that’s more power than my immediate problems require.

An offline discussion suggested exposing the opencl qualifiers (e.g. __local) for other languages. I haven’t written the patch yet but am cautiously optimistic.