Intel® Fortran Compiler 17.0 Developer Guide and Reference
OFFLOAD Compiler Directive: Initiates asynchronous data transfer, or initiates and completes synchronous data transfer. The action performed depends on the whether SIGNAL is specified. This directive only applies to Intel® MIC Architecture.
!DIR$ OFFLOAD_TRANSFER clause[[,] clause...]
clause |
Can be any of the following:
|
The following arguments are used in the above clause items:
target-name |
Is an identifier that represents the target. The only allowable target name is MIC. |
|||||||||||||||
target-number |
(Required for SIGNAL and WAIT) Is an integer expression whose value is interpreted as shown in the following table. When target-number is specified, the implicit MANDATORY offload is overridden and execution on the CPU is allowed when either the OPTIONAL clause is also specified or optional is also specified in option [q or Q]offload.
If you don't specify the target-number argument, the runtime system executes the code on the coprocessor, and if multiple coprocessors are available, on which coprocessor. If no coprocessor is available, the program fails with an error message. For example, in a system with 4 coprocessors:
|
|||||||||||||||
if-specifier |
Is a Boolean expression. If the expression evaluates to true, then the data transfer specified by the directive occurs. If the specified target coprocessor is absent from the system or not available at that time because it is fully loaded, then no action is taken. If the expression evaluates to false, then no action is taken and none of the other offload clauses have any effect. |
|||||||||||||||
tag |
Is a scalar integer expression. Its value is used to coordinate an asynchronous computation or an asynchronous data transfer. When used with SIGNAL, tag is an integer value associated with an asynchronous computation or an asynchronous data transfer. tag can be used in subsequent WAIT clauses in other OFFLOAD, OFFLOAD_TRANSFER, or OFFLOAD_WAIT directives. When used with WAIT, tag is an integer value associated with a previously initiated asynchronous computation or asynchronous data transfer. Use the same tag that you specified in the SIGNAL clause that started the asynchronous computation or data transfer with the OFFLOAD or OFFLOAD_TRANSFER directive. |
|||||||||||||||
offload-parameter |
Can be any of the following data movement clauses:
When a program runs in a heterogeneous environment, program variables are copied back and forth between the CPU and the target. The offload-parameter is a specification for controlling the direction in which variables are copied, and for pointers, the amount of data that is copied.
This clause is required. It must not contain both an IN clause and an OUT clause. An IN or OUT element-count-expr expression (see description below within modifier) is evaluated at a point in the program before the statement or clause in which it is used. An array variable whose size is known from its declaration is copied in its entirety. If a subset of an array is to be processed, use the name of the starting element of the subset and the element-count-expr to transfer the array subset. |
|||||||||||||||
identifier |
Is a variable, a subscripted variable, an array slice, or a component reference. The variable or the component reference may have the ALLOCATABLE or POINTER attribute. An array slice may be contiguous or non-contiguous. |
|||||||||||||||
modifier |
Is one of the following:
|
This directive initiates asynchronous data transfer if SIGNAL is specified. If SIGNAL is not specified, it initiates and completes synchronous data transfer.
You can choose whether to offload a statement based on runtime conditions, such as the size of a data set. The IF (if-specifier) clause lets you specify the condition.
Use SIGNAL (tag) to start the asynchronous computation.
The SIGNAL and WAIT clauses refer to a specific target device, so you must specify target-number in the TARGET clause. If you query a signal before the signal has been initiated, it results in undefined behavior and a runtime abort of the application. For example, if you query a signal (SIG1) on target device 0 that was initiated for target device 1, it results in a runtime abort of the application. This is because the signal (SIG1) was initiated for target device 1, so there is no signal (SIG1) associated with target device 0.
If the if-specifier evaluates to false and a SIGNAL (tag) clause is used in the directive, then the SIGNAL is undefined and any WAIT on this SIGNAL has undefined behavior.
When you specify the STATUS clause, it affects the behavior of optional and mandatory offloads differently when the offload request is not successful:
For an optional offload, the computation is performed on the CPU and the status variable has an appropriate value.
For a mandatory offload, there is no CPU fallback. The program does not terminate. You must examine the value of the status variable, determine the reason the offload failed, and decide what action to take.
See Example 2 in the OFFLOAD Examples section for an example showing how to use offload_status to identify the target-number value when using -1, or when target-number is not specified.
For both optional and mandatory offloads, when offload is successful, the status variable has the value OFFLOAD_SUCCESS.
In the data movement clauses (IN, OUT, INOUT, and NOCOPY) and the modifiers ALLOC and INTO, you can specify an array slice of any rank. For an assumed-size dummy array, you can specify the following syntax, interchangeably:
var:length(k), where k is a scalar integer expression computed at runtime representing the number of elements of var to be moved.
var( section-subscript-list ), where section-subscript-list is a comma-separated list of subscript triplets of the form [ subscript ] : [ subscript ] [ : stride ]
See the examples in OFFLOAD.