Intel® Fortran Compiler 16.0 User and Reference Guide
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 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 in specifier defines a variable as strictly an input to the target. The value is not copied back to the host.
The out specifier defines a variable as strictly an output of the target. The host does not copy the variable to the target.
The inout specifier defines a variable that is both copied from the host to the target and back from the target to the host.
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.