In this step, you will look at the code section defined to run on both the host and target.
Find the following code:
!DIR$ OFFLOAD BEGIN target(mic) mandatory &
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 block finds the first ten even numbers and then stores those numbers into an array. At the start and end of the code block is the OFFLOAD directive. The compiler interprets this directive to compile the following code block to run on both the host and target.
While the instruction sets are similar, the host and targets do not share the same system memory. Therefore, the variables used by the code block must exist in both the host and target. To ensure that the variable exist on both the host and target, the directive uses parameter specifiers to define the variables to copy between the host and target.
The in specifier defines the variable as strictly an input to the target. The variable is only copied to the target and is not copied back to the host.
The out specifier defines the variable as strictly an output of the target. The variable is not copied from the host to the target. The variable is only copied from the target to the host.
The inout specifier defines the variable that is both copied to and from the host and target.
Although the compiler by default compiles the code into an application that runs on both the host and target, you can also compile the same code into an application that runs on just the host only. In the next step, you will compile the source code into and application that runs on the host only.