diff options
author | Tobias Burnus <tburnus@baylibre.com> | 2025-06-06 16:22:06 +0200 |
---|---|---|
committer | Tobias Burnus <tburnus@baylibre.com> | 2025-06-06 16:39:53 +0200 |
commit | 5f56185a23e4e6d417091ba21f9eac4d0b4da239 (patch) | |
tree | 7d0496b175aaf7bd95d453e5b79bc9790940f311 /gcc/dwarf2ctf.cc | |
parent | c8963f01ac813346f543ae118e702df8c28cd884 (diff) | |
download | gcc-5f56185a23e4e6d417091ba21f9eac4d0b4da239.zip gcc-5f56185a23e4e6d417091ba21f9eac4d0b4da239.tar.gz gcc-5f56185a23e4e6d417091ba21f9eac4d0b4da239.tar.bz2 |
OpenMP: Add omp_get_initial_device/omp_get_num_devices builtins
By adding omp_get_initial_device and omp_get_num_devices builtins for
C, C++, and Fortran, the following can be achieved:
* By making them pure, multiple calls can be avoiding in some cases.
* Some comparisons can be optimized at compile time.
omp_get_initial_device will be converted to omp_get_num_devices for
consistency; note that OpenMP 6 also permits omp_initial_device (== -1)
as value.
If GCC has not been configure for offloading, either intrinsic will
leads to 0 - and on the offload side, -1 (= omp_initial_device) is
returned for omp_initial_device.
gcc/fortran/ChangeLog:
* f95-lang.cc (ATTR_PURE_NOTHROW_LIST): Define.
* trans-expr.cc (get_builtin_fn): Handle omp_get_num_devices
and omp_get_intrinsic_device.
* gfortran.h (gfc_option_t): Add disable_omp_... for them.
* options.cc (gfc_handle_option): Handle them with
-fno-builtin-.
gcc/ChangeLog:
* gimple-fold.cc (gimple_fold_builtin_omp_get_initial_device,
gimple_fold_builtin_omp_get_num_devices): New.
(gimple_fold_builtin): Call them.
* omp-builtins.def (BUILT_IN_OMP_GET_INITIAL_DEVICE): Add
(BUILT_IN_OMP_GET_NUM_DEVICES): Make uservisible + pure.
libgomp/ChangeLog:
* libgomp.texi (omp_get_num_devices, omp_get_intrinsic_device):
Document builtin handling.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/omp_get_num_devices_initial_device-2.c: New test.
* c-c++-common/gomp/omp_get_num_devices_initial_device.c: New test.
* gfortran.dg/gomp/omp_get_num_devices_initial_device-2.f90: New test.
* gfortran.dg/gomp/omp_get_num_devices_initial_device.f90: New test.
Co-authored-by: Sandra Loosemore <sloosemore@baylibre.com>
(cherry picked from commit 387209938d2c476a67966c6ddbdbf817626f24a2)
Diffstat (limited to 'gcc/dwarf2ctf.cc')
0 files changed, 0 insertions, 0 deletions