[OpenMP] Add missing weak definitions of missing variables (#77767)

Variables `__omp_rtl_assume_teams_oversubscription` and
`__omp_rtl_assume_threads_oversubscription `are used by functions:
`__kmpc_distribute_static_loop`, `__kmpc_distribute_for_static_loop `and
`__kmpc_for_static_loop`.
This commit is contained in:
Dominik Adamski 2024-01-11 15:28:45 +01:00 committed by GitHub
parent 52613396a6
commit 18798cf972
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 7 deletions

View File

@ -30,6 +30,12 @@ uint32_t getDeviceNum();
/// Return the user choosen debug level.
uint32_t getDebugKind();
/// Return if teams oversubscription is assumed
uint32_t getAssumeTeamsOversubscription();
/// Return if threads oversubscription is assumed
uint32_t getAssumeThreadsOversubscription();
/// Return the amount of dynamic shared memory that was allocated at launch.
uint64_t getDynamicMemorySize();

View File

@ -23,6 +23,9 @@ using namespace ompx;
[[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;
[[gnu::weak]] extern const uint32_t __omp_rtl_assume_threads_oversubscription =
0;
[[gnu::weak]] extern const uint32_t __omp_rtl_assume_teams_oversubscription = 0;
// This variable should be visibile to the plugin so we override the default
// hidden visibility.
@ -30,6 +33,14 @@ using namespace ompx;
gnu::visibility("protected")]] DeviceEnvironmentTy
CONSTANT(__omp_rtl_device_environment);
uint32_t config::getAssumeTeamsOversubscription() {
return __omp_rtl_assume_teams_oversubscription;
}
uint32_t config::getAssumeThreadsOversubscription() {
return __omp_rtl_assume_threads_oversubscription;
}
uint32_t config::getDebugKind() {
return __omp_rtl_debug_kind & __omp_rtl_device_environment.DeviceDebugKind;
}

View File

@ -45,9 +45,6 @@ struct DynamicScheduleTracker {
#pragma omp begin declare target device_type(nohost)
extern int32_t __omp_rtl_assume_teams_oversubscription;
extern int32_t __omp_rtl_assume_threads_oversubscription;
// TODO: This variable is a hack inherited from the old runtime.
static uint64_t SHARED(Cnt);
@ -746,7 +743,7 @@ public:
// If we know we have more threads than iterations we can indicate that to
// avoid an outer loop.
bool OneIterationPerThread = false;
if (__omp_rtl_assume_threads_oversubscription) {
if (config::getAssumeThreadsOversubscription()) {
ASSERT(NumThreads >= NumIters, "Broken assumption");
OneIterationPerThread = true;
}
@ -788,7 +785,7 @@ public:
// If we know we have more blocks than iterations we can indicate that to
// avoid an outer loop.
bool OneIterationPerThread = false;
if (__omp_rtl_assume_teams_oversubscription) {
if (config::getAssumeTeamsOversubscription()) {
ASSERT(NumBlocks >= NumIters, "Broken assumption");
OneIterationPerThread = true;
}
@ -839,8 +836,8 @@ public:
// If we know we have more threads (across all blocks) than iterations we
// can indicate that to avoid an outer loop.
bool OneIterationPerThread = false;
if (__omp_rtl_assume_teams_oversubscription &
__omp_rtl_assume_threads_oversubscription) {
if (config::getAssumeTeamsOversubscription() &
config::getAssumeThreadsOversubscription()) {
OneIterationPerThread = true;
ASSERT(NumBlocks * NumThreads >= NumIters, "Broken assumption");
}