@@ -85,10 +85,13 @@ void GlobalHandler::InitXPTI() {
85
85
}
86
86
87
87
void GlobalHandler::TraceEventXPTI (const char *Message) {
88
- #ifdef XPTI_ENABLE_INSTRUMENTATION
89
88
if (!Message)
90
89
return ;
90
+ #ifdef XPTI_ENABLE_INSTRUMENTATION
91
+ static std::once_flag InitXPTIFlag;
91
92
if (xptiTraceEnabled ()) {
93
+ std::call_once (InitXPTIFlag, [&]() { InitXPTI (); });
94
+
92
95
// We have to handle the cases where: (1) we may have just the code location
93
96
// set and not UID and (2) UID set
94
97
detail::tls_code_loc_t Tls;
@@ -122,13 +125,6 @@ GlobalHandler *&GlobalHandler::getInstancePtr() {
122
125
GlobalHandler &GlobalHandler::instance () {
123
126
GlobalHandler *RTGlobalObjHandler = GlobalHandler::getInstancePtr ();
124
127
assert (RTGlobalObjHandler && " Handler must not be deallocated earlier" );
125
-
126
- #ifdef XPTI_ENABLE_INSTRUMENTATION
127
- static std::once_flag InitXPTIFlag;
128
- if (xptiTraceEnabled ()) {
129
- std::call_once (InitXPTIFlag, [&]() { RTGlobalObjHandler->InitXPTI (); });
130
- }
131
- #endif
132
128
return *RTGlobalObjHandler;
133
129
}
134
130
@@ -289,13 +285,13 @@ void GlobalHandler::drainThreadPool() {
289
285
}
290
286
291
287
#ifdef _WIN32
292
- // because of something not-yet-understood on Windows
293
- // threads may be shutdown once the end of main() is reached
294
- // making an orderly shutdown difficult. Fortunately, Windows
295
- // itself is very aggressive about reclaiming memory. Thus,
296
- // we focus solely on unloading the plugins, so as to not
297
- // accidentally retain device handles. etc
298
- void shutdown (){
288
+ // because of something not-yet-understood on Windows
289
+ // threads may be shutdown once the end of main() is reached
290
+ // making an orderly shutdown difficult. Fortunately, Windows
291
+ // itself is very aggressive about reclaiming memory. Thus,
292
+ // we focus solely on unloading the plugins, so as to not
293
+ // accidentally retain device handles. etc
294
+ void shutdown () {
299
295
GlobalHandler *&Handler = GlobalHandler::getInstancePtr ();
300
296
Handler->unloadPlugins ();
301
297
}
@@ -356,7 +352,7 @@ extern "C" __SYCL_EXPORT BOOL WINAPI DllMain(HINSTANCE hinstDLL,
356
352
#ifdef XPTI_ENABLE_INSTRUMENTATION
357
353
if (xptiTraceEnabled ())
358
354
return TRUE ; // When doing xpti tracing, we can't safely call shutdown.
359
- // TODO: figure out what XPTI is doing that prevents release.
355
+ // TODO: figure out what XPTI is doing that prevents release.
360
356
#endif
361
357
362
358
shutdown ();
0 commit comments