Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion offload/include/OffloadPolicy.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ 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;
Expand Down
7 changes: 7 additions & 0 deletions offload/libomptarget/OffloadRTL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//
//===----------------------------------------------------------------------===//

#include "OffloadPolicy.h"
#include "OpenMP/OMPT/Callback.h"
#include "PluginManager.h"

Expand All @@ -31,6 +32,12 @@ void initRuntime() {
if (PM == nullptr)
PM = new PluginManager();

if (OffloadPolicy::isOffloadDisabled()) {
DP("Offload is disabled. Skipping library initialization\n");
// Do only absolutely needed initialization
return;
}

RefCount++;
if (RefCount == 1) {
DP("Init offload library!\n");
Expand Down