Intel® Fortran Compiler 18.0 Developer Guide and Reference

OFFLOAD_WAIT

OFFLOAD Compiler Directive: Specifies a wait for a previously initiated asynchronous activity. This directive only applies when targeting Intel® Xeon Phi™ products.

!DIR$ OFFLOAD_WAIT clause[[,] clause...]

clause

Can be any of the following:

  • TARGET (target-name :target-number)

  • IF (if-specifier)

    An optional clause. Include it to allow a test at execution time for whether or not the executable should try to offload the statement.

    Use the IF clause to control whether the offload is enabled. All OFFLOAD directives that have data dependencies should use the IF clause in a coordinated fashion, so that either all or none of the related offloads are enabled.

  • WAIT (tag [, tag, ...])

    A required clause. It specifies a wait until a previously initiated asynchronous data transfer or asynchronous computation is completed.

    WAIT is device specific; if you use this clause, you must specify a target-number >=0 in the TARGET clause.

  • STATUS (var)

    An optional clause. Include it to determine the status of the execution of an offloading construct.

    var is of derived type offload_status defined in mic_lib.mod. This status variable can be queried for details about the offload. The module mic_lib.mod is provided and contains the following definitions:

    use, intrinsic :: iso_c_binding
     
    enum , bind (C)
     enumerator :: OFFLOAD_SUCCESS         = 0
     enumerator :: OFFLOAD_DISABLED        = 1  ! offload is disabled
     enumerator :: OFFLOAD_UNAVAILABLE     = 2  ! card is not available
     enumerator :: OFFLOAD_OUT_OF_MEMORY   = 3  ! not enough memory on device
     enumerator :: OFFLOAD_PROCESS_DIED    = 4  ! target process has died
     enumerator :: OFFLOAD_ERROR           = 5  ! unspecified error
    end enum
     
    type, bind (C) :: offload_status
     integer(kind=c_int) ::  result        = OFFLOAD_DISABLED   ! result, see enum above
     integer(kind=c_int) ::  device_number = -1  ! device number
     integer(kind=c_int) ::  data_sent     =  0  ! number of bytes sent to the target
     integer(kind=c_int) ::  data_received =  0  ! number of bytes received by host
    end type offload_status

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

Is a required integer expression whose value is interpreted as follows:

>= 0

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

processor = MOD (target-number, number_of_coprocs)

<= -1

These values are reserved.

For example, in a system with 4 processors:

  • Specifying 2 or 6 tells the runtime systems to use processor 2 for the transfer, because both MOD(2,4) and MOD(6,4) equal 2.

  • Specifying 1000 tells the runtime systems to use processor 0 for the transfer, because MOD(1000,4) = 0.

if-specifier

Is a Boolean expression.

If the expression evaluates to true, then execution waits for the completion of a previously initiated asynchronous data transfer or asynchronous computation. If the specified target processor 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 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.

The OFFLOAD_WAIT directive specifies a wait for the completion of a previously initiated asynchronous data transfer performed by the OFFLOAD_TRANSFER directive, or an asynchronous computation and return data transfer, if any, performed by the OFFLOAD directive.

The WAIT clause refers to a specific target device, so you must specify target-number in the TARGET clause.

The signal associated with tag is cleared following completion of the previously initiated asynchronous data transfer or asynchronous computation. 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.

When you specify the STATUS clause, it affects the behavior of optional and mandatory offloads differently when the offload request is not successful:

For both optional and mandatory offloads, when offload is successful, the status variable has the value OFFLOAD_SUCCESS.

Example

See the examples in OFFLOAD.

See Also