File tree Expand file tree Collapse file tree 4 files changed +21
-21
lines changed Expand file tree Collapse file tree 4 files changed +21
-21
lines changed Original file line number Diff line number Diff line change 13
13
#ifndef OMPTARGET_OPENMP_MAPPING_H
14
14
#define OMPTARGET_OPENMP_MAPPING_H
15
15
16
+ #include " Shared/EnvironmentVar.h"
16
17
#include " omptarget.h"
17
18
18
19
#include < cstdint>
@@ -26,6 +27,24 @@ class AsyncInfoTy;
26
27
27
28
using map_var_info_t = void *;
28
29
30
+ class MappingConfig {
31
+
32
+ MappingConfig () {
33
+ BoolEnvar ForceAtomic = BoolEnvar (" LIBOMPTARGET_MAP_FORCE_ATOMIC" , true );
34
+ UseEventsForAtomicTransfers = ForceAtomic;
35
+ }
36
+
37
+ public:
38
+ static const MappingConfig &get () {
39
+ static MappingConfig MP;
40
+ return MP;
41
+ };
42
+
43
+ // / Flag to indicate if we use events to ensure the atomicity of
44
+ // / map clauses or not. Can be modified with an environment variable.
45
+ bool UseEventsForAtomicTransfers = true ;
46
+ };
47
+
29
48
// / Information about shadow pointers.
30
49
struct ShadowPtrInfoTy {
31
50
void **HstPtrAddr = nullptr ;
Original file line number Diff line number Diff line change @@ -93,9 +93,6 @@ struct PluginAdaptorManagerTy {
93
93
94
94
// / Struct for the data required to handle plugins
95
95
struct PluginManager {
96
- PluginManager (bool UseEventsForAtomicTransfers)
97
- : UseEventsForAtomicTransfers(UseEventsForAtomicTransfers) {}
98
-
99
96
// / RTLs identified on the host
100
97
PluginAdaptorManagerTy RTLs;
101
98
@@ -121,10 +118,6 @@ struct PluginManager {
121
118
kmp_target_offload_kind_t TargetOffloadPolicy = tgt_default;
122
119
std::mutex TargetOffloadMtx; // /< For TargetOffloadPolicy
123
120
124
- // / Flag to indicate if we use events to ensure the atomicity of
125
- // / map clauses or not. Can be modified with an environment variable.
126
- const bool UseEventsForAtomicTransfers;
127
-
128
121
// Work around for plugins that call dlopen on shared libraries that call
129
122
// tgt_register_lib during their initialisation. Stash the pointers in a
130
123
// vector until the plugins are all initialised and then register them.
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ using namespace llvm::omp::target::ompt;
35
35
int HostDataToTargetTy::addEventIfNecessary (DeviceTy &Device,
36
36
AsyncInfoTy &AsyncInfo) const {
37
37
// First, check if the user disabled atomic map transfer/malloc/dealloc.
38
- if (!PM-> UseEventsForAtomicTransfers )
38
+ if (!MappingConfig::get (). UseEventsForAtomicTransfers )
39
39
return OFFLOAD_SUCCESS;
40
40
41
41
void *Event = getEvent ();
Original file line number Diff line number Diff line change @@ -48,19 +48,7 @@ extern void ompt::connectLibrary();
48
48
__attribute__ ((constructor(101 ))) void init() {
49
49
DP (" Init target library!\n " );
50
50
51
- bool UseEventsForAtomicTransfers = true ;
52
- if (const char *ForceAtomicMap = getenv (" LIBOMPTARGET_MAP_FORCE_ATOMIC" )) {
53
- std::string ForceAtomicMapStr (ForceAtomicMap);
54
- if (ForceAtomicMapStr == " false" || ForceAtomicMapStr == " FALSE" )
55
- UseEventsForAtomicTransfers = false ;
56
- else if (ForceAtomicMapStr != " true" && ForceAtomicMapStr != " TRUE" )
57
- fprintf (stderr,
58
- " Warning: 'LIBOMPTARGET_MAP_FORCE_ATOMIC' accepts only "
59
- " 'true'/'TRUE' or 'false'/'FALSE' as options, '%s' ignored\n " ,
60
- ForceAtomicMap);
61
- }
62
-
63
- PM = new PluginManager (UseEventsForAtomicTransfers);
51
+ PM = new PluginManager ();
64
52
65
53
#ifdef OMPT_SUPPORT
66
54
// Initialize OMPT first
You can’t perform that action at this time.
0 commit comments