Intel® Fortran Compiler XE 13.1 User and Reference Guides

Initiating an Offload

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

You can place the OFFLOAD directive before a subroutine call statement, a function call statement of the form x = func() or an OpenMP* parallel directive.

For example:

  !DIR$ OFFLOAD BEGIN target(mic : target_id) &
                             inout(numEs) in(all_Vals) out(E_vals)
      do k = 1, MAXSZ
         if ( MODULO(all_Vals(k),2) == 0 ) then
             numEs = numEs + 1
             E_vals(numEs) = all_Vals(k)
         endif
      enddo
  !DIR$ END OFFLOAD

This code excerpt finds the first ten even numbers and then puts those numbers into an array. At the start and end of the code excerpt is the OFFLOAD directive. The compiler builds the code block to run on both the CPU and coprocessor.

While the instruction sets for the host CPU and coprocessors are similar, they do not share the same system memory. This means that the variables used by the code block must exist on both the host CPU and coprocessor. To ensure that they do, the directives use specifiers to define the variables to copy between the host CPU and coprocessor.

The directive also has the target (mic:target_number) specifier to direct the code to a specific coprocessor in a system with multiple coprocessors.

Although by default the compiler builds an application that runs on both the host CPU and coprocessor, you can also build the same source code to run on just the CPU, using the -no-offload compiler option.

See Also


Submit feedback on this help topic