diff options
author | Chung-Lin Tang <cltang@codesourcery.com> | 2021-08-05 23:29:03 +0800 |
---|---|---|
committer | Chung-Lin Tang <cltang@codesourcery.com> | 2021-08-05 23:29:03 +0800 |
commit | 0bac793ed6bad2c0c13cd1e93a1aa5808467afc8 (patch) | |
tree | 4f956146f4b129e344b00fa47e0326b831ef9928 /libgomp/libgomp-plugin.h | |
parent | 8dec72aeb54e98643c0fb3d53768cdb96cf1342a (diff) | |
download | gcc-0bac793ed6bad2c0c13cd1e93a1aa5808467afc8.zip gcc-0bac793ed6bad2c0c13cd1e93a1aa5808467afc8.tar.gz gcc-0bac793ed6bad2c0c13cd1e93a1aa5808467afc8.tar.bz2 |
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.
Diffstat (limited to 'libgomp/libgomp-plugin.h')
-rw-r--r-- | libgomp/libgomp-plugin.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/libgomp/libgomp-plugin.h b/libgomp/libgomp-plugin.h index 62645ce..cf24a2b 100644 --- a/libgomp/libgomp-plugin.h +++ b/libgomp/libgomp-plugin.h @@ -102,6 +102,12 @@ struct addr_pair uintptr_t end; }; +/* This symbol is to name a target side variable that holds the designated + 'device number' of the target device. The symbol needs to be available to + libgomp code and the offload plugin (which in the latter case must be + stringified). */ +#define GOMP_DEVICE_NUM_VAR __gomp_device_num + /* Miscellaneous functions. */ extern void *GOMP_PLUGIN_malloc (size_t) __attribute__ ((malloc)); extern void *GOMP_PLUGIN_malloc_cleared (size_t) __attribute__ ((malloc)); |