Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
12 changes: 11 additions & 1 deletion offload/include/OffloadPolicy.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class OffloadPolicy {
Kind = MANDATORY;
return;
default:
// User didn't specify a policy, decide
// based on number of devices discovered
if (PM.getNumDevices()) {
DP("Default TARGET OFFLOAD policy is now mandatory "
"(devices were found)\n");
Expand All @@ -46,10 +48,18 @@ class OffloadPolicy {
Kind = DISABLED;
}
return;
};
}
}

public:
static bool isOffloadDisabled() {
if((kmp_target_offload_kind_t)__kmpc_get_target_offload() ==
tgt_disabled) {
return true;
}
return false;
}

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
Loading