Skip to content

Commit 06c0c30

Browse files
committed
reverted moving the lock in the front due to conflict in piEventsWait
Signed-off-by: Byoungro So <[email protected]>
1 parent 180f435 commit 06c0c30

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4311,10 +4311,10 @@ pi_result piEnqueueMemBufferMap(pi_queue Queue, pi_mem Buffer,
43114311
ze_fence_handle_t ZeFence = nullptr;
43124312
ze_event_handle_t ZeEvent = nullptr;
43134313

4314-
// Lock automatically releases when this goes out of scope.
4315-
std::lock_guard<std::mutex> lock(Queue->PiQueueMutex);
4316-
43174314
if (Event) {
4315+
// Lock automatically releases when this goes out of scope.
4316+
std::lock_guard<std::mutex> lock(Queue->PiQueueMutex);
4317+
43184318
auto Res = createEventAndAssociateQueue(
43194319
Queue, Event, PI_COMMAND_TYPE_MEM_BUFFER_MAP, ZeCommandList);
43204320
if (Res != PI_SUCCESS)
@@ -4352,6 +4352,9 @@ pi_result piEnqueueMemBufferMap(pi_queue Queue, pi_mem Buffer,
43524352
return Buffer->addMapping(*RetMap, Offset, Size);
43534353
}
43544354

4355+
// Lock automatically releases when this goes out of scope.
4356+
std::lock_guard<std::mutex> lock(Queue->PiQueueMutex);
4357+
43554358
// For discrete devices we need a command list
43564359
if (auto Res = Queue->Device->getAvailableCommandList(Queue, &ZeCommandList,
43574360
&ZeFence))
@@ -4406,10 +4409,10 @@ pi_result piEnqueueMemUnmap(pi_queue Queue, pi_mem MemObj, void *MappedPtr,
44064409

44074410
ze_event_handle_t ZeEvent = nullptr;
44084411

4409-
// Lock automatically releases when this goes out of scope.
4410-
std::lock_guard<std::mutex> lock(Queue->PiQueueMutex);
4411-
44124412
if (Event) {
4413+
// Lock automatically releases when this goes out of scope.
4414+
std::lock_guard<std::mutex> lock(Queue->PiQueueMutex);
4415+
44134416
auto Res = createEventAndAssociateQueue(
44144417
Queue, Event, PI_COMMAND_TYPE_MEM_BUFFER_UNMAP, ZeCommandList);
44154418
if (Res != PI_SUCCESS)
@@ -4445,6 +4448,9 @@ pi_result piEnqueueMemUnmap(pi_queue Queue, pi_mem MemObj, void *MappedPtr,
44454448
return PI_SUCCESS;
44464449
}
44474450

4451+
// Lock automatically releases when this goes out of scope.
4452+
std::lock_guard<std::mutex> lock(Queue->PiQueueMutex);
4453+
44484454
if (auto Res = Queue->Device->getAvailableCommandList(Queue, &ZeCommandList,
44494455
&ZeFence))
44504456
return Res;

0 commit comments

Comments
 (0)