12.5.2 Define Variables Within an External Space
The external
space attribute is also used to assign
individual variables to the space. This requires that the memory space declaration to be
present. Given the declarations in the previous subsection, the following variable
declarations can be made:
__external__ int external_array[256]
__attribute__((space(external(external_memory))));
external_array
will be allocated in the previous
declared memory external_memory
.
Note that, like managed PSV objects, we have qualified the variable with
a new type qualifier __external__
. When attached to a variable or
pointer target, it instructs the compiler to generate the correct sequence to access
these objects.
Once an external memory variable has been declared, it may be accessed using normal C syntax. The compiler will generate code to access the variable via special helper functions that the programmer must define. These are covered in the next subsection.