Skip to content
Merged
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
8 changes: 7 additions & 1 deletion sycl/source/detail/scheduler/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
#include <detail/scheduler/scheduler.hpp>
#include <detail/stream_impl.hpp>

#include <chrono>
#include <memory>
#include <mutex>
#include <set>
#include <thread>
#include <vector>

__SYCL_INLINE_NAMESPACE(cl) {
Expand Down Expand Up @@ -268,7 +270,11 @@ void Scheduler::lockSharedTimedMutex(
// TODO: after switching to C++17, change std::shared_timed_mutex to
// std::shared_mutex and use std::lock_guard here both for Windows and Linux.
while (!Lock.owns_lock()) {
Lock.try_lock();
Lock.try_lock_for(std::chrono::milliseconds(10));
// Without yield while loop acts like endless while loop and occupies the
// whole CPU when multiple command groups are created in multiple host
// threads
std::this_thread::yield();
}
#else
// It is a deadlock on UNIX in implementation of lock and lock_shared, if
Expand Down