File tree Expand file tree Collapse file tree 2 files changed +8
-16
lines changed
Expand file tree Collapse file tree 2 files changed +8
-16
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ extern "C" int __kmpc_get_target_offload(void) __attribute__((weak));
2626
2727class OffloadPolicy {
2828
29- OffloadPolicy () {
29+ OffloadPolicy (PluginManager &PM ) {
3030 // TODO: Check for OpenMP.
3131 switch ((kmp_target_offload_kind_t )__kmpc_get_target_offload ()) {
3232 case tgt_disabled:
@@ -36,15 +36,6 @@ class OffloadPolicy {
3636 Kind = MANDATORY;
3737 return ;
3838 default :
39- // delay DEFAULT policy until PluginManager is ready
40- UserValue = false ;
41- return ;
42- };
43- }
44-
45- OffloadPolicy (PluginManager &PM) {
46- const OffloadPolicy &OP = get ();
47- if (!OP.UserValue ) {
4839 // User didn't specify a policy, decide
4940 // based on number of devices discovered
5041 if (PM.getNumDevices ()) {
@@ -58,13 +49,15 @@ class OffloadPolicy {
5849 }
5950 return ;
6051 }
61- Kind = OP.Kind ;
6252 }
6353
6454public:
65- static const OffloadPolicy &get () {
66- static OffloadPolicy OP;
67- return OP;
55+ static bool isOffloadDisabled () {
56+ if ((kmp_target_offload_kind_t )__kmpc_get_target_offload () ==
57+ tgt_disabled) {
58+ return true ;
59+ }
60+ return false ;
6861 }
6962
7063 static const OffloadPolicy &get (PluginManager &PM) {
@@ -75,7 +68,6 @@ class OffloadPolicy {
7568 enum OffloadPolicyKind { DISABLED, MANDATORY };
7669
7770 OffloadPolicyKind Kind = MANDATORY;
78- bool UserValue = true ;
7971};
8072
8173#endif // OMPTARGET_OFFLOAD_POLICY_H
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ void initRuntime() {
3232 if (PM == nullptr )
3333 PM = new PluginManager ();
3434
35- if (OffloadPolicy::get (). Kind == OffloadPolicy::DISABLED ) {
35+ if (OffloadPolicy::isOffloadDisabled () ) {
3636 DP (" Offload is disabled. Skipping library initialization\n " );
3737 // Do only absolutely needed initialization
3838 return ;
You can’t perform that action at this time.
0 commit comments