diff options
author | Thomas Schwinge <tschwinge@baylibre.com> | 2024-06-05 12:40:50 +0200 |
---|---|---|
committer | Thomas Schwinge <tschwinge@baylibre.com> | 2024-06-06 13:41:47 +0200 |
commit | 5bbe5350a0932c78d4ffce292ba4104a6fe6ef96 (patch) | |
tree | 85f53058f83c4185c39ff6a1a132545b9cb5045a /libgcc | |
parent | b4e68dd9084e48ee3e83c11d7f27548d8cca7066 (diff) | |
download | gcc-5bbe5350a0932c78d4ffce292ba4104a6fe6ef96.zip gcc-5bbe5350a0932c78d4ffce292ba4104a6fe6ef96.tar.gz gcc-5bbe5350a0932c78d4ffce292ba4104a6fe6ef96.tar.bz2 |
nvptx offloading: Global constructor, destructor support, via nvptx-tools 'ld'
This extends commit d9c90c82d900fdae95df4499bf5f0a4ecb903b53
"nvptx target: Global constructor, destructor support, via nvptx-tools 'ld'"
for offloading.
libgcc/
* config/nvptx/gbl-ctors.c ["mgomp"]
(__do_global_ctors__entry__mgomp)
(__do_global_dtors__entry__mgomp): New.
[!"mgomp"] (__do_global_ctors__entry, __do_global_dtors__entry):
New.
libgomp/
* plugin/plugin-nvptx.c (nvptx_do_global_cdtors): New.
(nvptx_close_device, GOMP_OFFLOAD_load_image)
(GOMP_OFFLOAD_unload_image): Call it.
Diffstat (limited to 'libgcc')
-rw-r--r-- | libgcc/config/nvptx/gbl-ctors.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/libgcc/config/nvptx/gbl-ctors.c b/libgcc/config/nvptx/gbl-ctors.c index a2ca053..a56d64f 100644 --- a/libgcc/config/nvptx/gbl-ctors.c +++ b/libgcc/config/nvptx/gbl-ctors.c @@ -68,6 +68,61 @@ __gbl_ctors (void) } +/* For nvptx offloading configurations, need '.entry' wrappers. */ + +# if defined(__nvptx_softstack__) && defined(__nvptx_unisimt__) + +/* OpenMP */ + +/* See 'crt0.c', 'mgomp.c'. */ +extern void *__nvptx_stacks[32] __attribute__((shared,nocommon)); +extern unsigned __nvptx_uni[32] __attribute__((shared,nocommon)); + +__attribute__((kernel)) void __do_global_ctors__entry__mgomp (void *); + +void +__do_global_ctors__entry__mgomp (void *nvptx_stacks_0) +{ + __nvptx_stacks[0] = nvptx_stacks_0; + __nvptx_uni[0] = 0; + + __static_do_global_ctors (); +} + +__attribute__((kernel)) void __do_global_dtors__entry__mgomp (void *); + +void +__do_global_dtors__entry__mgomp (void *nvptx_stacks_0) +{ + __nvptx_stacks[0] = nvptx_stacks_0; + __nvptx_uni[0] = 0; + + __static_do_global_dtors (); +} + +# else + +/* OpenACC */ + +__attribute__((kernel)) void __do_global_ctors__entry (void); + +void +__do_global_ctors__entry (void) +{ + __static_do_global_ctors (); +} + +__attribute__((kernel)) void __do_global_dtors__entry (void); + +void +__do_global_dtors__entry (void) +{ + __static_do_global_dtors (); +} + +# endif + + /* The following symbol just provides a means for the nvptx-tools 'ld' to trigger linking in this file. */ |