Skip to content

[SYCL] Fuse zeCommandListAppendWaitOnEvents into subsequent memory copy command #7807

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 16, 2022
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
35 changes: 9 additions & 26 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7101,19 +7101,15 @@ enqueueMemCopyHelper(pi_command_type CommandType, pi_queue Queue, void *Dst,

const auto &ZeCommandList = CommandList->first;
const auto &WaitList = (*Event)->WaitList;
if (WaitList.Length) {

ZE_CALL(zeCommandListAppendWaitOnEvents,
(ZeCommandList, WaitList.Length, WaitList.ZeEventList));
}

zePrint("calling zeCommandListAppendMemoryCopy() with\n"
" ZeEvent %#lx\n",
pi_cast<std::uintptr_t>(ZeEvent));
printZeEventList(WaitList);

ZE_CALL(zeCommandListAppendMemoryCopy,
(ZeCommandList, Dst, Src, Size, ZeEvent, 0, nullptr));
(ZeCommandList, Dst, Src, Size, ZeEvent, WaitList.Length,
WaitList.ZeEventList));

if (auto Res =
Queue->executeCommandList(CommandList, BlockingWrite, OkToBatch))
Expand Down Expand Up @@ -7165,10 +7161,6 @@ static pi_result enqueueMemCopyRectHelper(
const auto &ZeCommandList = CommandList->first;
const auto &WaitList = (*Event)->WaitList;

if (WaitList.Length) {
ZE_CALL(zeCommandListAppendWaitOnEvents,
(ZeCommandList, WaitList.Length, WaitList.ZeEventList));
}
zePrint("calling zeCommandListAppendMemoryCopy() with\n"
" ZeEvent %#lx\n",
pi_cast<std::uintptr_t>(ZeEvent));
Expand Down Expand Up @@ -7207,8 +7199,8 @@ static pi_result enqueueMemCopyRectHelper(

ZE_CALL(zeCommandListAppendMemoryCopyRegion,
(ZeCommandList, DstBuffer, &ZeDstRegion, DstPitch, DstSlicePitch,
SrcBuffer, &ZeSrcRegion, SrcPitch, SrcSlicePitch, nullptr, 0,
nullptr));
SrcBuffer, &ZeSrcRegion, SrcPitch, SrcSlicePitch, nullptr,
WaitList.Length, WaitList.ZeEventList));

zePrint("calling zeCommandListAppendMemoryCopyRegion()\n");

Expand Down Expand Up @@ -7422,14 +7414,9 @@ enqueueMemFillHelper(pi_command_type CommandType, pi_queue Queue, void *Ptr,
const auto &ZeCommandList = CommandList->first;
const auto &WaitList = (*Event)->WaitList;

if (WaitList.Length) {
ZE_CALL(zeCommandListAppendWaitOnEvents,
(ZeCommandList, WaitList.Length, WaitList.ZeEventList));
}

ZE_CALL(
zeCommandListAppendMemoryFill,
(ZeCommandList, Ptr, Pattern, PatternSize, Size, ZeEvent, 0, nullptr));
ZE_CALL(zeCommandListAppendMemoryFill,
(ZeCommandList, Ptr, Pattern, PatternSize, Size, ZeEvent,
WaitList.Length, WaitList.ZeEventList));

zePrint("calling zeCommandListAppendMemoryFill() with\n"
" ZeEvent %#lx\n",
Expand Down Expand Up @@ -7841,10 +7828,6 @@ static pi_result enqueueMemImageCommandHelper(
const auto &ZeCommandList = CommandList->first;
const auto &WaitList = (*Event)->WaitList;

if (WaitList.Length) {
ZE_CALL(zeCommandListAppendWaitOnEvents,
(ZeCommandList, WaitList.Length, WaitList.ZeEventList));
}
if (CommandType == PI_COMMAND_TYPE_IMAGE_READ) {
pi_mem SrcMem = pi_cast<pi_mem>(const_cast<void *>(Src));

Expand Down Expand Up @@ -7881,7 +7864,7 @@ static pi_result enqueueMemImageCommandHelper(
SrcMem->getZeHandle(ZeHandleSrc, _pi_mem::read_only, Queue->Device));
ZE_CALL(zeCommandListAppendImageCopyToMemory,
(ZeCommandList, Dst, pi_cast<ze_image_handle_t>(ZeHandleSrc),
&ZeSrcRegion, ZeEvent, 0, nullptr));
&ZeSrcRegion, ZeEvent, WaitList.Length, WaitList.ZeEventList));
} else if (CommandType == PI_COMMAND_TYPE_IMAGE_WRITE) {
pi_mem DstMem = pi_cast<pi_mem>(Dst);
ze_image_region_t ZeDstRegion;
Expand Down Expand Up @@ -7915,7 +7898,7 @@ static pi_result enqueueMemImageCommandHelper(
DstMem->getZeHandle(ZeHandleDst, _pi_mem::write_only, Queue->Device));
ZE_CALL(zeCommandListAppendImageCopyFromMemory,
(ZeCommandList, pi_cast<ze_image_handle_t>(ZeHandleDst), Src,
&ZeDstRegion, ZeEvent, 0, nullptr));
&ZeDstRegion, ZeEvent, WaitList.Length, WaitList.ZeEventList));
} else if (CommandType == PI_COMMAND_TYPE_IMAGE_COPY) {
pi_mem SrcImage = pi_cast<pi_mem>(const_cast<void *>(Src));
pi_mem DstImage = pi_cast<pi_mem>(Dst);
Expand Down