]> git.ipfire.org Git - thirdparty/gcc.git/commit - libgomp/omp_lib.h.in
openmp: Implement omp_get_device_num routine
authorChung-Lin Tang <cltang@codesourcery.com>
Thu, 5 Aug 2021 15:29:03 +0000 (23:29 +0800)
committerChung-Lin Tang <cltang@codesourcery.com>
Thu, 5 Aug 2021 15:29:03 +0000 (23:29 +0800)
commit0bac793ed6bad2c0c13cd1e93a1aa5808467afc8
tree4f956146f4b129e344b00fa47e0326b831ef9928
parent8dec72aeb54e98643c0fb3d53768cdb96cf1342a
openmp: Implement omp_get_device_num routine

This patch implements the omp_get_device_num library routine, specified in
OpenMP 5.0.

GOMP_DEVICE_NUM_VAR is a macro symbol which defines name of a "device number"
variable, is defined on the device-side libgomp, has it's address returned to
host-side libgomp during device initialization, and the host libgomp then
sets its value to the designated device number.

libgomp/ChangeLog:

* icv-device.c (omp_get_device_num): New API function, host side.
* fortran.c (omp_get_device_num_): New interface function.
* libgomp-plugin.h (GOMP_DEVICE_NUM_VAR): Define macro symbol.
* libgomp.map (OMP_5.0.2): New version space with omp_get_device_num,
omp_get_device_num_.
* libgomp.texi (omp_get_device_num): Add documentation for new API
function.
* omp.h.in (omp_get_device_num): Add declaration.
* omp_lib.f90.in (omp_get_device_num): Likewise.
* omp_lib.h.in (omp_get_device_num): Likewise.
* target.c (gomp_load_image_to_device): If additional entry for device
number exists at end of returned entries from 'load_image_func' hook,
copy the assigned device number over to the device variable.

* config/gcn/icv-device.c (GOMP_DEVICE_NUM_VAR): Define static global.
(omp_get_device_num): New API function, device side.
* plugin/plugin-gcn.c ("symcat.h"): Add include.
(GOMP_OFFLOAD_load_image): Add addresses of device GOMP_DEVICE_NUM_VAR
at end of returned 'target_table' entries.

* config/nvptx/icv-device.c (GOMP_DEVICE_NUM_VAR): Define static global.
(omp_get_device_num): New API function, device side.
* plugin/plugin-nvptx.c ("symcat.h"): Add include.
(GOMP_OFFLOAD_load_image): Add addresses of device GOMP_DEVICE_NUM_VAR
at end of returned 'target_table' entries.

* testsuite/lib/libgomp.exp
(check_effective_target_offload_target_intelmic): New function for
testing for intelmic offloading.
* testsuite/libgomp.c-c++-common/target-45.c: New test.
* testsuite/libgomp.fortran/target10.f90: New test.
16 files changed:
libgomp/config/gcn/icv-device.c
libgomp/config/nvptx/icv-device.c
libgomp/fortran.c
libgomp/icv-device.c
libgomp/libgomp-plugin.h
libgomp/libgomp.map
libgomp/libgomp.texi
libgomp/omp.h.in
libgomp/omp_lib.f90.in
libgomp/omp_lib.h.in
libgomp/plugin/plugin-gcn.c
libgomp/plugin/plugin-nvptx.c
libgomp/target.c
libgomp/testsuite/lib/libgomp.exp
libgomp/testsuite/libgomp.c-c++-common/target-45.c [new file with mode: 0644]
libgomp/testsuite/libgomp.fortran/target10.f90 [new file with mode: 0644]