\pagebreak
\section{Target Offload}
\label{sec:target_offload}
\index{environment variables!OMP_TARGET_OFFLOAD@\scode{OMP_TARGET_OFFLOAD}}
\index{OMP_TARGET_OFFLOAD@\scode{OMP_TARGET_OFFLOAD}}

In the OpenMP 5.0 implementation the \code{OMP\_TARGET\_OFFLOAD}
environment variable was defined to change \plc{default} offload behavior. 
By \plc{default} the target code (region) is executed on the host if the target device 
does not exist or the implementation does not support the target device.  
%Last sentence uses words of the 5.0 spec pg. 21 lines 7-8

In an OpenMP 5.0 compliant implementation, setting the 
\code{OMP\_TARGET\_OFFLOAD} variable to \code{MANDATORY} will 
force the program to terminate execution when a \code{target} 
construct is encountered and the target device is not supported or is not available.
With a value \code{DEFAULT} the target region will execute on a device if the 
device exists and is supported by the implementation,
otherwise it will execute on the host.
Support for the \code{DISABLED}
value is optional; when it is supported the behavior is as if only the 
host device exists (other devices are considered non-existent to the runtime), 
and target regions are executed on the host.  

The following example reports execution behavior for different 
values of the \code{OMP\_TARGET\_OFFLOAD} variable. A handy routine 
for extracting the \code{OMP\_TARGET\_OFFLOAD} environment variable
value is deployed here, because the OpenMP API does not have a routine 
for obtaining the value. %(\texit{yet}).

Note: 
The example issues a warning when a pre-5.0 implementation is used,
indicating that the \code{OMP\_TARGET\_OFFLOAD} is ignored.
The value of the \code{OMP\_TARGET\_OFFLOAD} variable is reported 
when the \code{OMP\_DISPLAY\_ENV} 
environment variable is set to \code{TRUE} or \code{VERBOSE}.

%\pagebreak
\cexample[5.0]{target_offload_control}{1}[1]

%\pagebreak
\ffreeexample[5.0]{target_offload_control}{1}[1]


% OMP 4.5 target offload  15:9-11
%If the target device does not exist or the
%implementation does not support the target device, all target regions associated with that device
%execute on the host device.
