Skip to content

Commit

Permalink
Emulate USMFill2D with USMFill
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaomaosu committed Jan 8, 2025
1 parent 29e078f commit 430dc2b
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions source/loader/layers/sanitizer/msan/msan_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,20 @@ ur_result_t EnqueueMemCopyRectHelper(
NumEventsInWaitList, EventWaitList, &NewEvent));
Events.push_back(NewEvent);
} else if (IsDstDeviceUSM && !IsSrcDeviceUSM) {
NewEvent = nullptr;
uptr DstShadowAddr = DeviceInfo->Shadow->MemToShadow(
(uptr)DstOrigin + (i * DstSlicePitch));
const char Val = 0;
UR_CALL(getContext()->urDdiTable.Enqueue.pfnUSMFill2D(
Queue, (void *)DstShadowAddr, DstRowPitch, 1, &Val,
Region.width, Region.height, NumEventsInWaitList, EventWaitList,
&NewEvent));
Events.push_back(NewEvent);
// opencl & l0 adapter doesn't implement urEnqueueUSMFill2D, so
// emulate the operation with urEnqueueUSMFill.
for (size_t HeightIndex = 0; HeightIndex < Region.height;
HeightIndex++) {
NewEvent = nullptr;
UR_CALL(getContext()->urDdiTable.Enqueue.pfnUSMFill(
Queue, (void *)(DstShadowAddr + HeightIndex * DstRowPitch),
1, &Val, Region.width, NumEventsInWaitList, EventWaitList,
&NewEvent));
Events.push_back(NewEvent);
}
}
}

Expand Down

0 comments on commit 430dc2b

Please sign in to comment.