Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit e6866fa

Browse files
authored
[SYCL] Lock mutex only for critical region in interop-level-zero-thread.cpp (#1418)
1 parent 2aa315f commit e6866fa

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

SYCL/Plugin/interop-level-zero-thread.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,19 @@ ze_event_handle_t getEvent() {
110110
}
111111

112112
void worker() {
113-
std::unique_lock<std::mutex> lk(mt);
114-
115113
while (true) {
116-
cv.wait(lk, []() { return ops.size() > 0 || stop_worker; });
117-
if (stop_worker)
118-
return;
119-
auto op = ops.front();
120-
ops.pop_front();
121114

115+
operation op;
116+
{
117+
118+
std::unique_lock<std::mutex> lk(mt);
119+
cv.wait(lk, []() { return ops.size() > 0 || stop_worker; });
120+
if (stop_worker)
121+
return;
122+
123+
op = ops.front();
124+
ops.pop_front();
125+
}
122126
for (auto dep : op.deps) {
123127
// Wait for dependencies to complete
124128
while (dep.get_info<sycl::info::event::command_execution_status>() !=

0 commit comments

Comments
 (0)