]> git.ipfire.org Git - thirdparty/gcc.git/commit
openmp: Implement support for OMP_TARGET_OFFLOAD environment variable
authorKwok Cheung Yeung <kcy@codesourcery.com>
Tue, 20 Oct 2020 11:15:59 +0000 (04:15 -0700)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Wed, 11 Nov 2020 21:32:13 +0000 (13:32 -0800)
commit5c4ffe3a19aa42d85d9f54735d7e1284bce79919
treecc30d37886226dc28bcfbc1bba37789a9d76ffc6
parent28c4af5f39bbceba04c67acdf6c771f5375ad52c
openmp: Implement support for OMP_TARGET_OFFLOAD environment variable

This implements support for the OMP_TARGET_OFFLOAD environment variable
introduced in the OpenMP 5.0 standard, which controls how offloading
is handled.  It may be set to MANDATORY (abort if offloading cannot be
performed), DISABLED (no offloading to devices) or DEFAULT (offload to
device if possible, fall back to host if not).

This is a backport from mainline (commits
1bfc07d150790fae93184a79a7cce897655cb37b,
35f258f4bbba7fa044f90b4f14d1bc942db58089 and
121a8812c45b3155ccbd268b000ad00a778e81e8).

2020-10-20  Kwok Cheung Yeung  <kcy@codesourcery.com>
    Jakub Jelinek  <jakub@redhat.com>

libgomp/
* env.c (gomp_target_offload_var): New.
(parse_target_offload): New.
(handle_omp_display_env): Print value of OMP_TARGET_OFFLOAD.
(initialize_env): Parse OMP_TARGET_OFFLOAD.
* libgomp.h (gomp_target_offload_t): New.
(gomp_target_offload_var): New.
* libgomp.texi (OMP_TARGET_OFFLOAD): New section.
* target.c (resolve_device): Generate error if device not found and
offloading is mandatory.
(gomp_target_fallback): Generate error if offloading is mandatory.
(GOMP_target): Add argument in call to gomp_target_fallback.
(GOMP_target_ext): Likewise.
(gomp_target_data_fallback): Generate error if offloading is mandatory.
(GOMP_target_data): Add argument in call to gomp_target_data_fallback.
(GOMP_target_data_ext): Likewise.
(gomp_target_task_fn): Add argument in call to gomp_target_fallback.
(gomp_target_init): Return early if offloading is disabled.
Inside of the function, use automatic
variables corresponding to num_devices, num_devices_openmp and devices
global variables and update the globals only at the end of the
function.
libgomp/ChangeLog.omp
libgomp/env.c
libgomp/libgomp.h
libgomp/libgomp.texi
libgomp/target.c