Skip to content

Commit 62b9856

Browse files
committed
applied review comments
1 parent 43f6771 commit 62b9856

File tree

3 files changed

+22
-24
lines changed

3 files changed

+22
-24
lines changed

sycl/source/detail/device_kernel_info.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class DeviceKernelInfo : public CompileTimeKernelInfoTy {
117117
return MUsesAssert;
118118
}
119119

120-
const std::optional<int> &getImplicitLocalArgPos() {
120+
std::optional<int> getImplicitLocalArgPos() const {
121121
assertInitialized();
122122
return MImplicitLocalArgPos;
123123
}

sycl/source/detail/global_handler.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,7 @@ void GlobalHandler::drainThreadPool() {
318318
// 2) when process is being terminated
319319
void shutdown_early(bool CanJoinThreads = true) {
320320
const LockGuard Lock{GlobalHandler::MSyclGlobalHandlerProtector};
321-
GlobalHandler *&Handler = GlobalHandler::getInstancePtr();
322-
if (!Handler)
321+
if (!GlobalHandler::RTGlobalObjHandler)
323322
return;
324323

325324
#if defined(XPTI_ENABLE_INSTRUMENTATION) && defined(_WIN32)
@@ -329,26 +328,26 @@ void shutdown_early(bool CanJoinThreads = true) {
329328
#endif
330329

331330
// Now that we are shutting down, we will no longer defer MemObj releases.
332-
Handler->endDeferredRelease();
331+
GlobalHandler::RTGlobalObjHandler->endDeferredRelease();
333332

334333
// Ensure neither host task is working so that no default context is accessed
335334
// upon its release
336-
Handler->prepareSchedulerToRelease(true);
335+
GlobalHandler::RTGlobalObjHandler->prepareSchedulerToRelease(true);
337336

338-
if (Handler->MHostTaskThreadPool.Inst) {
339-
Handler->MHostTaskThreadPool.Inst->finishAndWait(CanJoinThreads);
340-
Handler->MHostTaskThreadPool.Inst.reset(nullptr);
337+
if (GlobalHandler::RTGlobalObjHandler->MHostTaskThreadPool.Inst) {
338+
GlobalHandler::RTGlobalObjHandler->MHostTaskThreadPool.Inst->finishAndWait(
339+
CanJoinThreads);
340+
GlobalHandler::RTGlobalObjHandler->MHostTaskThreadPool.Inst.reset(nullptr);
341341
}
342342

343343
// This releases OUR reference to the default context, but
344344
// other may yet have refs
345-
Handler->releaseDefaultContexts();
345+
GlobalHandler::RTGlobalObjHandler->releaseDefaultContexts();
346346
}
347347

348348
void shutdown_late() {
349349
const LockGuard Lock{GlobalHandler::MSyclGlobalHandlerProtector};
350-
GlobalHandler *&Handler = GlobalHandler::getInstancePtr();
351-
if (!Handler)
350+
if (!GlobalHandler::RTGlobalObjHandler)
352351
return;
353352

354353
#if defined(XPTI_ENABLE_INSTRUMENTATION) && defined(_WIN32)
@@ -358,26 +357,27 @@ void shutdown_late() {
358357
#endif
359358

360359
// First, release resources, that may access adapters.
361-
Handler->MPlatformCache.Inst.reset(nullptr);
362-
Handler->MScheduler.Inst.reset(nullptr);
363-
Handler->MProgramManager.Inst.reset(nullptr);
360+
GlobalHandler::RTGlobalObjHandler->MPlatformCache.Inst.reset(nullptr);
361+
GlobalHandler::RTGlobalObjHandler->MScheduler.Inst.reset(nullptr);
362+
GlobalHandler::RTGlobalObjHandler->MProgramManager.Inst.reset(nullptr);
364363

365364
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
366365
// Kernel cache, which is part of device kernel info,
367366
// stores handles to the adapter, so clear it before releasing adapters.
368-
Handler->MDeviceKernelInfoStorage.Inst.reset(nullptr);
367+
GlobalHandler::RTGlobalObjHandler->MDeviceKernelInfoStorage.Inst.reset(
368+
nullptr);
369369
#endif
370370

371371
// Clear the adapters and reset the instance if it was there.
372-
Handler->unloadAdapters();
373-
if (Handler->MAdapters.Inst)
374-
Handler->MAdapters.Inst.reset(nullptr);
372+
GlobalHandler::RTGlobalObjHandler->unloadAdapters();
373+
if (GlobalHandler::RTGlobalObjHandler->MAdapters.Inst)
374+
GlobalHandler::RTGlobalObjHandler->MAdapters.Inst.reset(nullptr);
375375

376-
Handler->MXPTIRegistry.Inst.reset(nullptr);
376+
GlobalHandler::RTGlobalObjHandler->MXPTIRegistry.Inst.reset(nullptr);
377377

378378
// Release the rest of global resources.
379-
delete Handler;
380-
Handler = nullptr;
379+
delete GlobalHandler::RTGlobalObjHandler;
380+
GlobalHandler::RTGlobalObjHandler = nullptr;
381381
}
382382

383383
#ifdef _WIN32

sycl/source/detail/global_handler.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ class GlobalHandler {
5454
/// `__attribute__((destructor))` is called).
5555
static GlobalHandler &instance() { return *RTGlobalObjHandler; }
5656

57-
static GlobalHandler *&getInstancePtr() { return RTGlobalObjHandler; }
58-
5957
GlobalHandler(const GlobalHandler &) = delete;
6058
GlobalHandler(GlobalHandler &&) = delete;
6159
GlobalHandler &operator=(const GlobalHandler &) = delete;
@@ -94,12 +92,12 @@ class GlobalHandler {
9492
// For testing purposes only
9593
void attachScheduler(Scheduler *Scheduler);
9694

95+
private:
9796
// Constructor and destructor are declared out-of-line to allow incomplete
9897
// types as template arguments to unique_ptr.
9998
GlobalHandler();
10099
~GlobalHandler();
101100

102-
private:
103101
bool OkToDefer = true;
104102

105103
friend void shutdown_early(bool);

0 commit comments

Comments
 (0)