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

In the OpenMP 5.0 implementation the \kcode{OMP_TARGET_OFFLOAD}
environment variable was defined to change default offload behavior.
By 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 
\kcode{OMP_TARGET_OFFLOAD} variable to \vcode{MANDATORY} will 
force the program to terminate execution when a \kcode{target} 
construct is encountered and the target device is not supported or is not available.
With a value \vcode{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 \vcode{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 \kcode{OMP_TARGET_OFFLOAD} variable. A handy routine 
for extracting the \kcode{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 \kcode{OMP_TARGET_OFFLOAD} is ignored.
The value of the \kcode{OMP_TARGET_OFFLOAD} variable is reported 
when the \kcode{OMP_DISPLAY_ENV} 
environment variable is set to \vcode{TRUE} or \vcode{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.
