_Cilk_shared

Shares a variable or function. This keyword only applies to Intel® MIC Architecture.

Syntax

_Cilk_shared type variable(s)

_Cilk_shared type func_def

Arguments

type

The type of the variable or variables being declared.

variable(s)

One or more variables.

func_def

A function definition or declaration.

Description

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.

Examples: Variables

A shared declaration:

_Cilk_shared int x, y, z;

A shared typedef:

typedef _Cilk_shared str_type shr_str_type;
 shr_str_type a;

Examples: Pointers

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;

Examples: Functions

A shared function definition:

_Cilk_shared void func() {
x = y + z;
}

A shared function declaration:

_Cilk_shared int bar();

Examples: Functions

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();
For more complete information about compiler optimizations, see our Optimization Notice.