Skip to content

Commit cf44d5e

Browse files
[SYCL] Move xpti stream init (exception trace) to the first usage (#8907)
Move it from GlobalHandler::instance to avoid framework loading there since it is called from __sycl_register_lib first Signed-off-by: Tikhomirova, Kseniya <kseniya.tikhomirova@intel.com>
1 parent 6daa993 commit cf44d5e

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

sycl/source/detail/global_handler.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,13 @@ void GlobalHandler::InitXPTI() {
8585
}
8686

8787
void GlobalHandler::TraceEventXPTI(const char *Message) {
88-
#ifdef XPTI_ENABLE_INSTRUMENTATION
8988
if (!Message)
9089
return;
90+
#ifdef XPTI_ENABLE_INSTRUMENTATION
91+
static std::once_flag InitXPTIFlag;
9192
if (xptiTraceEnabled()) {
93+
std::call_once(InitXPTIFlag, [&]() { InitXPTI(); });
94+
9295
// We have to handle the cases where: (1) we may have just the code location
9396
// set and not UID and (2) UID set
9497
detail::tls_code_loc_t Tls;
@@ -122,13 +125,6 @@ GlobalHandler *&GlobalHandler::getInstancePtr() {
122125
GlobalHandler &GlobalHandler::instance() {
123126
GlobalHandler *RTGlobalObjHandler = GlobalHandler::getInstancePtr();
124127
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
132128
return *RTGlobalObjHandler;
133129
}
134130

@@ -289,13 +285,13 @@ void GlobalHandler::drainThreadPool() {
289285
}
290286

291287
#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() {
299295
GlobalHandler *&Handler = GlobalHandler::getInstancePtr();
300296
Handler->unloadPlugins();
301297
}
@@ -356,7 +352,7 @@ extern "C" __SYCL_EXPORT BOOL WINAPI DllMain(HINSTANCE hinstDLL,
356352
#ifdef XPTI_ENABLE_INSTRUMENTATION
357353
if (xptiTraceEnabled())
358354
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.
360356
#endif
361357

362358
shutdown();

0 commit comments

Comments
 (0)