Intel® C++ Compiler 19.0 Developer Guide and Reference
Shares a variable or function. This keyword only applies to Intel® MIC Architecture.
_Cilk_shared type variable(s) _Cilk_shared type func_def |
The type of the variable or variables being declared.
One or more variables.
A function definition or declaration.
Using _Cilk_shared with a variable allocates the variable to shared memory.
Using _Cilk_shared with a function definition or declaration makes the function available to the CPU and the coprocessor.
A shared declaration:
_Cilk_shared int x, y, z;
A shared typedef:
typedef _Cilk_shared str_type shr_str_type;
shr_str_type a;
p is a pointer to a shared int, but the pointer itself is not shared:
int _Cilk_shared *p;
p is itself in shared memory:
int * _Cilk_shared p;
A shared function definition:
_Cilk_shared void func() {
x = y + z;
}
A shared function declaration:
_Cilk_shared int bar();
Using pragma offload-attribute to apply this attribute to multiple declarations:
#pragma offload_attribute(push, _Cilk_shared)
#include <math.h>
void function_1();
void function_2();
#pragma offload_attribute(pop)
void function_3();
int main(){
_Cilk_offload function_1();
function_3();
_Cilk_offload function_2();
}
_Cilk_shared int bar();