-
Notifications
You must be signed in to change notification settings - Fork 796
[SYCL] optimize enqueueImpKernel by inlining #20681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -105,20 +105,7 @@ void GlobalHandler::TraceEventXPTI(const char *Message) { | |
| #endif | ||
| } | ||
|
|
||
| GlobalHandler *&GlobalHandler::getInstancePtr() { | ||
| static GlobalHandler *RTGlobalObjHandler = new GlobalHandler(); | ||
| return RTGlobalObjHandler; | ||
| } | ||
|
|
||
| GlobalHandler &GlobalHandler::instance() { | ||
| GlobalHandler *RTGlobalObjHandler = GlobalHandler::getInstancePtr(); | ||
| assert(RTGlobalObjHandler && "Handler must not be deallocated earlier"); | ||
| return *RTGlobalObjHandler; | ||
| } | ||
|
|
||
| bool GlobalHandler::isInstanceAlive() { | ||
| return GlobalHandler::getInstancePtr(); | ||
| } | ||
| GlobalHandler *GlobalHandler::RTGlobalObjHandler = new GlobalHandler(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if this was meant to be NFC changes, but technically this changes when the first object is created. Previously it would only be created if
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is on purpose to avoid slower access to static variables declared inside a method as we discussed in this comment of original PR.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't feel strongly against doing this, but I wonder if it would be cleaner to do it in a separate PR and mark this "[NFCI]". That way, if there are unforeseen issues with doing the initialization earlier, it should hopefully be easier to isolate the cause when bisecting.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've updated summary to not miss this change when doing "git log" later. Can we leave as it? All CI already passed. |
||
|
|
||
| template <typename T, typename... Types> | ||
| T &GlobalHandler::getOrCreate(InstWithLock<T> &IWL, Types &&...Args) { | ||
|
|
@@ -331,8 +318,7 @@ void GlobalHandler::drainThreadPool() { | |
| // 2) when process is being terminated | ||
| void shutdown_early(bool CanJoinThreads = true) { | ||
| const LockGuard Lock{GlobalHandler::MSyclGlobalHandlerProtector}; | ||
| GlobalHandler *&Handler = GlobalHandler::getInstancePtr(); | ||
| if (!Handler) | ||
| if (!GlobalHandler::RTGlobalObjHandler) | ||
| return; | ||
|
|
||
| #if defined(XPTI_ENABLE_INSTRUMENTATION) && defined(_WIN32) | ||
|
|
@@ -342,26 +328,26 @@ void shutdown_early(bool CanJoinThreads = true) { | |
| #endif | ||
|
|
||
| // Now that we are shutting down, we will no longer defer MemObj releases. | ||
| Handler->endDeferredRelease(); | ||
| GlobalHandler::RTGlobalObjHandler->endDeferredRelease(); | ||
|
|
||
| // Ensure neither host task is working so that no default context is accessed | ||
| // upon its release | ||
| Handler->prepareSchedulerToRelease(true); | ||
| GlobalHandler::RTGlobalObjHandler->prepareSchedulerToRelease(true); | ||
|
|
||
| if (Handler->MHostTaskThreadPool.Inst) { | ||
| Handler->MHostTaskThreadPool.Inst->finishAndWait(CanJoinThreads); | ||
| Handler->MHostTaskThreadPool.Inst.reset(nullptr); | ||
| if (GlobalHandler::RTGlobalObjHandler->MHostTaskThreadPool.Inst) { | ||
| GlobalHandler::RTGlobalObjHandler->MHostTaskThreadPool.Inst->finishAndWait( | ||
| CanJoinThreads); | ||
| GlobalHandler::RTGlobalObjHandler->MHostTaskThreadPool.Inst.reset(nullptr); | ||
| } | ||
|
|
||
| // This releases OUR reference to the default context, but | ||
| // other may yet have refs | ||
| Handler->releaseDefaultContexts(); | ||
| GlobalHandler::RTGlobalObjHandler->releaseDefaultContexts(); | ||
| } | ||
|
|
||
| void shutdown_late() { | ||
| const LockGuard Lock{GlobalHandler::MSyclGlobalHandlerProtector}; | ||
| GlobalHandler *&Handler = GlobalHandler::getInstancePtr(); | ||
| if (!Handler) | ||
| if (!GlobalHandler::RTGlobalObjHandler) | ||
| return; | ||
|
|
||
| #if defined(XPTI_ENABLE_INSTRUMENTATION) && defined(_WIN32) | ||
|
|
@@ -371,26 +357,27 @@ void shutdown_late() { | |
| #endif | ||
|
|
||
| // First, release resources, that may access adapters. | ||
| Handler->MPlatformCache.Inst.reset(nullptr); | ||
| Handler->MScheduler.Inst.reset(nullptr); | ||
| Handler->MProgramManager.Inst.reset(nullptr); | ||
| GlobalHandler::RTGlobalObjHandler->MPlatformCache.Inst.reset(nullptr); | ||
| GlobalHandler::RTGlobalObjHandler->MScheduler.Inst.reset(nullptr); | ||
| GlobalHandler::RTGlobalObjHandler->MProgramManager.Inst.reset(nullptr); | ||
|
|
||
| #ifndef __INTEL_PREVIEW_BREAKING_CHANGES | ||
| // Kernel cache, which is part of device kernel info, | ||
| // stores handles to the adapter, so clear it before releasing adapters. | ||
| Handler->MDeviceKernelInfoStorage.Inst.reset(nullptr); | ||
| GlobalHandler::RTGlobalObjHandler->MDeviceKernelInfoStorage.Inst.reset( | ||
| nullptr); | ||
| #endif | ||
|
|
||
| // Clear the adapters and reset the instance if it was there. | ||
| Handler->unloadAdapters(); | ||
| if (Handler->MAdapters.Inst) | ||
| Handler->MAdapters.Inst.reset(nullptr); | ||
| GlobalHandler::RTGlobalObjHandler->unloadAdapters(); | ||
| if (GlobalHandler::RTGlobalObjHandler->MAdapters.Inst) | ||
| GlobalHandler::RTGlobalObjHandler->MAdapters.Inst.reset(nullptr); | ||
|
|
||
| Handler->MXPTIRegistry.Inst.reset(nullptr); | ||
| GlobalHandler::RTGlobalObjHandler->MXPTIRegistry.Inst.reset(nullptr); | ||
|
|
||
| // Release the rest of global resources. | ||
| delete Handler; | ||
| Handler = nullptr; | ||
| delete GlobalHandler::RTGlobalObjHandler; | ||
| GlobalHandler::RTGlobalObjHandler = nullptr; | ||
| } | ||
|
|
||
| #ifdef _WIN32 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.