Skip to content

Commit

Permalink
[Libomptarget] Make the DeviceRTL configuration globals weak (#68220)
Browse files Browse the repository at this point in the history
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 definition 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
behavior was that it would not link so that is an improvement.
    
Depends on: #68215
  • Loading branch information
jhuber6 committed Oct 4, 2023
1 parent 49d8a55 commit 2d4d8c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions openmp/libomptarget/DeviceRTL/src/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ using namespace ompx;

#pragma omp begin declare target device_type(nohost)

// defined by CGOpenMPRuntimeGPU
extern uint32_t __omp_rtl_debug_kind;
extern uint32_t __omp_rtl_assume_no_thread_state;
extern uint32_t __omp_rtl_assume_no_nested_parallelism;
// Weak definitions will be overridden by CGOpenmpRuntimeGPU if enabled.
[[gnu::weak]] extern const uint32_t __omp_rtl_debug_kind = 0;
[[gnu::weak]] extern const uint32_t __omp_rtl_assume_no_thread_state = 0;
[[gnu::weak]] extern const uint32_t __omp_rtl_assume_no_nested_parallelism = 0;

// This variable should be visibile to the plugin so we override the default
// hidden visibility.
Expand Down
4 changes: 4 additions & 0 deletions openmp/libomptarget/DeviceRTL/src/exports
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ ompx_*
*llvm_*
__kmpc_*

__omp_rtl_debug_kind
__omp_rtl_assume_no_thread_state
__omp_rtl_assume_no_nested_parallelism

_ZN4ompx*

IsSPMDMode
Expand Down

0 comments on commit 2d4d8c8

Please sign in to comment.