Intel® Fortran Compiler 16.0 User and Reference Guide

Calling Functions on the CPU to Modify the Coprocessor's Execution Environment

This topic only applies to Intel® Many Integrated Core Architecture (Intel® MIC Architecture).

Some CPU APIs have offload equivalents, each of which take two additional arguments to specify the target type and target number, defined by the following arguments:

target_type

target_type is static. It is recommended to use the following pre-defined default:

default_target_type

target_number

The specific coprocessor to target.

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.

The mic_lib.f90 header file defines all the function calls that can be made from the CPU to affect the coprocessor's environment.

This topic uses the CPU API omp_set_num_threads and its offload variations as an example. See also the topics listed below for more CPU APIs.

Example

CPU API
subroutine omp_set_num_threads (num_threads)                    &
           bind (C, name = "omp_set_num_threads")
  import :: c_int
  integer (kind=c_int), value :: num_threads
end subroutine omp_set_num_threads
Offload API
subroutine omp_set_num_threads_target (target_type,                    &
                                       target_number,                  &
                                       num_threads)                    &
           bind (C, name = "omp_set_num_threads_target")
  import :: c_int
  integer (kind=c_int), value :: target_type, target_number, num_threads
end subroutine omp_set_num_threads_target
use mic_lib
use omp_lib

integer :: result, value

value = 66
call omp_set_num_threads_target &
         (TARGET_MIC, 0, value)
!DIR$ OMP OFFLOAD target(mic) out(result)
!$omp parallel
!$omp master
result = omp_get_num_threads()
!$omp end master
!$omp end parallel
print "(A, I)", "Number of threads on target", result
stop
end

See Also