forked from OpenMP/Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExamples_target_offload.tex
46 lines (38 loc) · 1.99 KB
/
Examples_target_offload.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
\pagebreak
\section{Target Offload}
\label{sec: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}
%\pagebreak
\ffreeexample[5.0]{target_offload_control}{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.