Intel® Fortran Compiler 17.0 Developer Guide and Reference

Initiating an Offload

This topic only applies when targeting 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 even numbers and then puts those numbers into an array. The code excerpt begins with !DIR$ OFFLOAD BEGIN , and ends with !DIR$ END OFFLOAD. The compiler builds the code block to run on both the host and target

While the instruction sets for the host and targets 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 and the target. To ensure that they do, the directives use specifiers to define the variables to copy between the host and target.

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

When the main program has offload constructs, by default the compiler builds an application that runs on both the host and target. However, you can also build the same source code to run on just the CPU, using the negative form of the [Q]offload compiler option.

See Also