mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-14 17:06:38 +00:00
[OFFLOAD] Stricter enforcement of user offload disable (#133470)
If user specifies offload is disabled (e.g., OMP_TARGET_OFFLOAD=disable), disable library almost completely. This reduces resources spent to a minimum and ensures all APIs behave as if the only available device is the host device. Currently some of the APIs behave as if there were devices avaible for offload even when under OMP_TARGET_OFFLOAD=disable. --------- Co-authored-by: Joseph Huber <huberjn@outlook.com>
This commit is contained in:
parent
5a073f1f3a
commit
021a1f6974
@ -46,10 +46,15 @@ class OffloadPolicy {
|
||||
Kind = DISABLED;
|
||||
}
|
||||
return;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
static bool isOffloadDisabled() {
|
||||
return static_cast<kmp_target_offload_kind_t>(
|
||||
__kmpc_get_target_offload()) == tgt_disabled;
|
||||
}
|
||||
|
||||
static const OffloadPolicy &get(PluginManager &PM) {
|
||||
static OffloadPolicy OP(PM);
|
||||
return OP;
|
||||
|
@ -11,6 +11,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "PluginManager.h"
|
||||
#include "OffloadPolicy.h"
|
||||
#include "Shared/Debug.h"
|
||||
#include "Shared/Profile.h"
|
||||
#include "device.h"
|
||||
@ -30,6 +31,11 @@ PluginManager *PM = nullptr;
|
||||
|
||||
void PluginManager::init() {
|
||||
TIMESCOPE();
|
||||
if (OffloadPolicy::isOffloadDisabled()) {
|
||||
DP("Offload is disabled. Skipping plugin initialization\n");
|
||||
return;
|
||||
}
|
||||
|
||||
DP("Loading RTLs...\n");
|
||||
|
||||
// Attempt to create an instance of each supported plugin.
|
||||
|
Loading…
x
Reference in New Issue
Block a user