Skip to content

Commit 11d3408

Browse files
committed
fix the bug.
Signed-off-by: rbegam <[email protected]>
1 parent 727b8e6 commit 11d3408

File tree

1 file changed

+12
-26
lines changed

1 file changed

+12
-26
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4824,9 +4824,7 @@ pi_result piEnqueueMemBufferMap(pi_queue Queue, pi_mem Buffer,
48244824
{
48254825
// Lock automatically releases when this goes out of scope.
48264826
std::lock_guard<std::mutex> lock(Queue->PiQueueMutex);
4827-
if (Queue->LastCommandEvent != nullptr) {
4828-
TmpLastCommandEvent = Queue->LastCommandEvent;
4829-
}
4827+
TmpLastCommandEvent = Queue->LastCommandEvent;
48304828
}
48314829

48324830
if (TmpLastCommandEvent != nullptr) {
@@ -4842,12 +4840,6 @@ pi_result piEnqueueMemBufferMap(pi_queue Queue, pi_mem Buffer,
48424840
*RetMap = pi_cast<char *>(Buffer->getZeHandle()) + Offset;
48434841
}
48444842

4845-
{
4846-
// Lock automatically releases when this goes out of scope.
4847-
std::lock_guard<std::mutex> lock(Queue->PiQueueMutex);
4848-
Queue->LastCommandEvent = *Event;
4849-
}
4850-
48514843
// Signal this event
48524844
ZE_CALL(zeEventHostSignal, (ZeEvent));
48534845

@@ -4950,30 +4942,24 @@ pi_result piEnqueueMemUnmap(pi_queue Queue, pi_mem MemObj, void *MappedPtr,
49504942
// Wait on incoming events before doing the copy
49514943
PI_CALL(piEventsWait(NumEventsInWaitList, EventWaitList));
49524944

4953-
if (Queue->isInOrderQueue()) {
4954-
pi_event TmpLastCommandEvent = nullptr;
4955-
{
4956-
// Lock automatically releases when this goes out of scope.
4957-
std::lock_guard<std::mutex> lock(Queue->PiQueueMutex);
4958-
if (Queue->LastCommandEvent != nullptr) {
4959-
TmpLastCommandEvent = Queue->LastCommandEvent;
4960-
}
4961-
}
4962-
if (TmpLastCommandEvent != nullptr) {
4945+
if (Queue->isInOrderQueue()) {
4946+
pi_event TmpLastCommandEvent = nullptr;
4947+
4948+
{
4949+
// Lock automatically releases when this goes out of scope.
4950+
std::lock_guard<std::mutex> lock(Queue->PiQueueMutex);
4951+
TmpLastCommandEvent = Queue->LastCommandEvent;
4952+
}
4953+
4954+
if (TmpLastCommandEvent != nullptr) {
49634955
PI_CALL(piEventsWait(1, &TmpLastCommandEvent));
4964-
}
49654956
}
4957+
}
49664958

49674959
if (MemObj->MapHostPtr)
49684960
memcpy(pi_cast<char *>(MemObj->getZeHandle()) + MapInfo.Offset, MappedPtr,
49694961
MapInfo.Size);
49704962

4971-
{
4972-
// Lock automatically releases when this goes out of scope.
4973-
std::lock_guard<std::mutex> lock(Queue->PiQueueMutex);
4974-
Queue->LastCommandEvent = *Event;
4975-
}
4976-
49774963
// Signal this event
49784964
ZE_CALL(zeEventHostSignal, (ZeEvent));
49794965

0 commit comments

Comments
 (0)