Programming with OpenMP device constructs
IBM® XL Fortran for Linux, V16.1 partially supports the OpenMP Application Program Interface Version 4.5 specification. You can offload compute-intensive parts of an application and associated data to the NVIDIA GPUs by using these supported device constructs.
Supported device constructs
- TARGET DATA
- TARGET ENTER DATA
- TARGET EXIT DATA
- TARGET
- TARGET UPDATE
- DECLARE TARGET
- TEAMS
- DISTRIBUTE
- DISTRIBUTE PARALLEL DO
- DISTRIBUTE PARALLEL DO SIMD
- DISTRIBUTE SIMD
For example, you can use the TARGET directive to define a target region, which is a block of computation that operates within a distinct data environment and is intended to be offloaded onto a parallel computation device during execution. For more information about the OpenMP directives, see Parallelization directives.
You can also use other OpenMP constructs with these OpenMP device constructs to exert finer control on parallelization, such as the combined constructs that are listed in OpenMP combined constructs.
GPU-related compiler options
You must specify the -qoffload option to enable the support for offloading OpenMP target regions to NVIDIA GPUs. For -qoffload to take effect, you must also specify the -qsmp option to enable support for OpenMP target regions. For more information, see -qoffload.
You can also use the -qtgtarch option to specify real or virtual GPU architectures where the code may run. For more information, see -qtgtarch.
GPU-related environment variables
- XLSMPOPTS=target={mandatory | default | disabled} controls which device to execute target regions on.
- XLSMPOPTS=cudamemcheckfriendly={off | on} controls whether to disable the check for pinned memory in the runtime and allow the program to be executed under the cuda-memcheck tool from the NVIDIA CUDA Toolkit.
For more information, see XLSMPOPTS.
GPU-related runtime routines
- omp_get_default_device
- omp_get_initial_device
- omp_get_num_devices
- omp_get_num_teams
- omp_get_team_num
- omp_is_initial_device


