Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sycl/source/detail/global_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ Scheduler &GlobalHandler::getScheduler() {
return *MScheduler.Inst;
}

bool GlobalHandler::isSchedulerAlive() const { return MScheduler.Inst.get(); }

void GlobalHandler::registerSchedulerUsage(bool ModifyCounter) {
thread_local ObjectUsageCounter SchedulerCounter(ModifyCounter);
}
Expand Down
1 change: 1 addition & 0 deletions sycl/source/detail/global_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class GlobalHandler {

void registerSchedulerUsage(bool ModifyCounter = true);
Scheduler &getScheduler();
bool isSchedulerAlive() const;
ProgramManager &getProgramManager();
Sync &getSync();
std::vector<PlatformImplPtr> &getPlatformCache();
Expand Down
4 changes: 3 additions & 1 deletion sycl/source/detail/queue_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,9 @@ pi_native_handle queue_impl::getNative(int32_t &NativeHandleDesc) const {
}

void queue_impl::cleanup_fusion_cmd() {
detail::Scheduler::getInstance().cleanUpCmdFusion(this);
// Clean up only if a scheduler instance exits.
if (detail::Scheduler::isInstanceAlive())
detail::Scheduler::getInstance().cleanUpCmdFusion(this);
}

bool queue_impl::ext_oneapi_empty() const {
Expand Down
4 changes: 4 additions & 0 deletions sycl/source/detail/scheduler/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ Scheduler &Scheduler::getInstance() {
return GlobalHandler::instance().getScheduler();
}

bool Scheduler::isInstanceAlive() {
return GlobalHandler::instance().isSchedulerAlive();
}

void Scheduler::waitForEvent(const EventImplPtr &Event) {
ReadLockT Lock = acquireReadLock();
// It's fine to leave the lock unlocked upon return from waitForEvent as
Expand Down
2 changes: 2 additions & 0 deletions sycl/source/detail/scheduler/scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ class Scheduler {

/// \return an instance of the scheduler object.
static Scheduler &getInstance();
/// \return true if an instance of the scheduler object exists.
static bool isInstanceAlive();

QueueImplPtr getDefaultHostQueue() { return DefaultHostQueue; }

Expand Down