Hello -
I was hopeful someone could help me understand the syntax of address space qualifiers that I have seen in the metal standard library. I have seen the qualifiers used on constructors and on functions such as the following:
struct A {
A() thread : { }
A() device : { }
void do_it() thread { device int& param } // 1
void do_it() thread { thread int& param } // 2
void do_it() device { device int& param } // 3
void do_it() device { thread int& param } // 4
}
What do the address qualifiers mean in this context exactly? Are these overloads depending on where A resides in memory? For example:
kernel void process_data(device A& d_var, device uint& d_out ) {
thread A p_var { }; // OK
threadgroup A t_var { }; // ERROR?
thread int p_out = 0;
threadgroup int t_out = 0;
p_var.do_it(d_out); // calls 1?
p_var.do_it(p_out); // calls 2?
p_var.do_it(t_out); // Error?
d_var.do_it(d_out); // calls 3?
d_var.do_it(p_out); // calls 4?
d_var.do_it(t_out); // Error?
}
Or does this mean something else entirely? Would it be valid to add an address space qualifier to a global function? For example:
void do_it() device; // declared in program scope
If so, what does it mean for a function to be in (e.g.) device memory? Thank you for helping me understanding this better.