Skip to content

Commit 45e5678

Browse files
committed
[Libomptarget] Make the DeviceRTL configuration globals weak
Summary: This patch applies weak linkage to the config globals by the name `__omp_rtl...`. This is because when passing `-nogpulib` we will not link in or create these globals. This allows the OpenMP device RTL to be self contained without requiring the additional definitions from the `clang` compiler. In the standard case, this should not affect the current behavior, this is because the strong defintiion coming from the compiler should always override the weak definition we default to here. In the case that these are not defined by the compiler, these will remain weak. This will impact optimizations somewhat, but the previous behaviour was that it would not link so that is an improvement. Depends on: #68215
1 parent 452fa6b commit 45e5678

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

openmp/libomptarget/DeviceRTL/src/Configuration.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ using namespace ompx;
2020

2121
#pragma omp begin declare target device_type(nohost)
2222

23-
// defined by CGOpenMPRuntimeGPU
24-
extern uint32_t __omp_rtl_debug_kind;
25-
extern uint32_t __omp_rtl_assume_no_thread_state;
26-
extern uint32_t __omp_rtl_assume_no_nested_parallelism;
23+
// Weak definitions will be overridden by CGOpenmpRuntimeGPU if enabled.
24+
[[gnu::weak]] extern const uint32_t __omp_rtl_debug_kind = 0;
25+
[[gnu::weak]] extern const uint32_t __omp_rtl_assume_no_thread_state = 0;
26+
[[gnu::weak]] extern const uint32_t __omp_rtl_assume_no_nested_parallelism = 0;
2727

2828
// This variable should be visibile to the plugin so we override the default
2929
// hidden visibility.

openmp/libomptarget/DeviceRTL/src/exports

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ ompx_*
33
*llvm_*
44
__kmpc_*
55

6+
__omp_rtl_debug_kind
7+
__omp_rtl_assume_no_thread_state
8+
__omp_rtl_assume_no_nested_parallelism
9+
610
_ZN4ompx*
711

812
IsSPMDMode

0 commit comments

Comments
 (0)