_Cilk_offload

Controls synchronous and asynchronous execution of functions on the CPU and coprocessor. This keyword only applies to Intel® MIC Architecture.

Syntax

lvalue = _Cilk_offload func_name ( rvalue )

lvalue = _Cilk_offload_to ( target-number ) func_name ( rvalue )

lvalue = _Cilk_spawn _Cilk_offload func_name ( rvalue )

lvalue = _Cilk_spawn _Cilk_offload_to ( target-number ) func_name ( rvalue )

_Cilk_offload _Cilk_for ( init-expr ; test-expr ; incr-expr )

_Cilk_offload_to ( target-number ) _Cilk_for ( init-expr ; test-expr ; incr-expr )

Arguments

lvalue

An expression that designates an object.

rvalue

An expression that represents a value.

func_name

A function name.

target-number

An expression whose value is interpreted as follows:

>=0

Executes the statement on a specified target according to the following formula:

target = target-number % number_of_targets

For example, in a system with four targets:

  • Specifying 2 or 6 tells the runtime systems to execute the code on target 2, because the result of 2 % 4 and 6 % 4 is 2.

  • Specifying 1000 tells the runtime systems to execute the code on target 0, because the result of 1000 % 4 is 0.

-1 or no value

Executes the statements on a target selected by the runtime system.

<-1

Reserved.

init-expr

An initialization expression for a _Cilk_for loop.

test-expr

A test expression for a _Cilk_for loop.

incr-expr

An increment expression for a _Cilk_for loop.

Description

_Cilk_offload before a function call indicates that the runtime system chooses to execute the function being called either on the host, or on the coprocessor synchronously, and if multiple coprocessors are available, on which coprocessor.

Placing the keyword _Cilk_offload between a _Cilk_spawn keyword and a call results in asynchronous execution on the CPU using the normal Intel® Cilk™ Plus rules, and a synchronous offload of the function by an Intel® Cilk™ Plus task, effectively doing an asynchronous offload. Just as in normal Intel® Cilk™ Plus usage, you need a _Cilk_sync keyword before the CPU can use the results of the offloaded function.

_Cilk_offload before a _Cilk_for loop specifies that the entire loop be executed on the coprocessor.

_Cilk_offload_to (target-number) specifies mandatory offload to a coprocessor. target-number determines the specific coprocessor.

Example

Offload function calls:

z =  _Cilk_offload func(a);
z =  _Cilk_spawn _Cilk_offload func(a);

Offload _Cilk_for loop:

_Cilk_offload _Cilk_for ( init-expr; test-expr; incr-expr ) {
...
}
For more complete information about compiler optimizations, see our Optimization Notice.