Intel® C++ Compiler XE 13.1 User and Reference Guides

_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:

-1

This value specifies execution on the target. The runtime system chooses the specific target. Execution on the CPU is not allowed. If the correct target hardware needed to run the offloaded program is not available on the system, the program fails with an error message.

>=0

A value greater than or equal to zero specifies execution on a specific target. The number of the specific target is determined as follows:

target=target-number % number_of_targets

If the correct target hardware needed to run the offloaded program is not available on the system, the program fails with an error message.

<-1

This value is reserved.

For example, in a system with four targets:

  • specifying 2 or 6 tells the runtime systems to execute the code on target 2, because both 2 % 4 and 6 % 4 equal 2.

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

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 whether to execute the function being called on the coprocessor synchronously, or the CPU, 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 ) {
...
}

See Also