Skip to content

[UR][L0] Implement support for device to device copy #19106

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

Draft
wants to merge 4 commits into
base: sycl
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// REQUIRES: aspect-ext_oneapi_bindless_images
// REQUIRES: cuda

// UNSUPPORTED: target-amd
// UNSUPPORTED-INTENDED: currently not supporting amd for bindless image d2d
// copy
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// REQUIRES: aspect-ext_oneapi_bindless_images
// REQUIRES: cuda
// UNSUPPORTED: target-amd
// UNSUPPORTED-INTENDED: currently not supporting amd for bindless image d2d
// copy

// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// REQUIRES: aspect-ext_oneapi_bindless_images
// REQUIRES: cuda

// UNSUPPORTED: target-amd
// UNSUPPORTED-INTENDED: currently not supporting amd for bindless image d2d
// copy
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// REQUIRES: aspect-ext_oneapi_bindless_images
// REQUIRES: aspect-ext_oneapi_bindless_images_2d_usm
// REQUIRES: cuda
//
// UNSUPPORTED: cuda
// UNSUPPORTED: target-amd
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/17231

// RUN: %{build} -o %t.out
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// REQUIRES: aspect-ext_oneapi_bindless_images
// REQUIRES: aspect-ext_oneapi_bindless_images_2d_usm
// REQUIRES: cuda

// UNSUPPORTED: target-amd
// UNSUPPORTED-INTENDED: currently not supporting amd for bindless image d2d
// copy
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out

Expand Down
68 changes: 53 additions & 15 deletions unified-runtime/source/adapters/level_zero/image_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,21 +867,59 @@ ur_result_t bindlessImagesHandleCopyFlags(
return UR_RESULT_SUCCESS;
};
case UR_EXP_IMAGE_COPY_FLAG_DEVICE_TO_DEVICE: {
ze_image_region_t DstRegion;
UR_CALL(getImageRegionHelper(zeSrcImageDesc, &pCopyRegion->dstOffset,
&pCopyRegion->copyExtent, DstRegion));
ze_image_region_t SrcRegion;
UR_CALL(getImageRegionHelper(zeSrcImageDesc, &pCopyRegion->srcOffset,
&pCopyRegion->copyExtent, SrcRegion));

auto *urImgSrc = reinterpret_cast<const ur_bindless_mem_handle_t *>(pSrc);
auto *urImgDst = reinterpret_cast<ur_bindless_mem_handle_t *>(pDst);

ZE2UR_CALL(zeCommandListAppendImageCopyRegion,
(ZeCommandList, urImgDst->getZeImage(), urImgSrc->getZeImage(),
&DstRegion, &SrcRegion, zeSignalEvent, numWaitEvents,
phWaitEvents));

if (pSrcImageDesc->rowPitch != 0 && pDstImageDesc->rowPitch != 0) {
// Copy from pitched USM memory to pitched USM memory
uint32_t SrcRowPitch = pSrcImageDesc->rowPitch;
uint32_t DstRowPitch = pDstImageDesc->rowPitch;
ze_copy_region_t ZeDstRegion = {(uint32_t)pCopyRegion->dstOffset.x,
(uint32_t)pCopyRegion->dstOffset.y,
(uint32_t)pCopyRegion->dstOffset.z,
DstRowPitch,
(uint32_t)pCopyRegion->copyExtent.height,
(uint32_t)pCopyRegion->copyExtent.depth};
uint32_t DstSlicePitch = 0;
uint32_t SrcSlicePitch = 0;
ze_copy_region_t ZeSrcRegion = {(uint32_t)pCopyRegion->srcOffset.x,
(uint32_t)pCopyRegion->srcOffset.y,
(uint32_t)pCopyRegion->srcOffset.z,
SrcRowPitch,
(uint32_t)pCopyRegion->copyExtent.height,
(uint32_t)pCopyRegion->copyExtent.depth};
ZE2UR_CALL(zeCommandListAppendMemoryCopyRegion,
(ZeCommandList, pDst, &ZeDstRegion, DstRowPitch, DstSlicePitch,
pSrc, &ZeSrcRegion, SrcRowPitch, SrcSlicePitch, zeSignalEvent,
numWaitEvents, phWaitEvents));
} else if (pSrcImageDesc->rowPitch == 0 && pDstImageDesc->rowPitch == 0) {
// Copy from Non-USM memory to Non-USM memory
ze_image_region_t DstRegion;
UR_CALL(getImageRegionHelper(zeSrcImageDesc, &pCopyRegion->dstOffset,
&pCopyRegion->copyExtent, DstRegion));
ze_image_region_t SrcRegion;
UR_CALL(getImageRegionHelper(zeSrcImageDesc, &pCopyRegion->srcOffset,
&pCopyRegion->copyExtent, SrcRegion));
auto *UrImageDst = static_cast<ur_bindless_mem_handle_t *>(pDst);
auto *UrImageSrc = static_cast<const ur_bindless_mem_handle_t *>(pSrc);
ZE2UR_CALL(zeCommandListAppendImageCopyRegion,
(ZeCommandList, UrImageDst->getZeImage(),
UrImageSrc->getZeImage(), &DstRegion, &SrcRegion,
zeSignalEvent, numWaitEvents, phWaitEvents));
} else {
// Copy from Non-USM/pitched USM memory to pitched USM/Non-USM memory
// Note: This might be the same procedure as pitched USM to
// pitched USM. Need further testing.
ze_image_region_t DstRegion;
UR_CALL(getImageRegionHelper(zeSrcImageDesc, &pCopyRegion->dstOffset,
&pCopyRegion->copyExtent, DstRegion));
ze_image_region_t SrcRegion;
UR_CALL(getImageRegionHelper(zeSrcImageDesc, &pCopyRegion->srcOffset,
&pCopyRegion->copyExtent, SrcRegion));
auto *UrImageDst = static_cast<ur_bindless_mem_handle_t *>(pDst);
auto *UrImageSrc = static_cast<const ur_bindless_mem_handle_t *>(pSrc);
ZE2UR_CALL(zeCommandListAppendImageCopyRegion,
(ZeCommandList, UrImageDst->getZeImage(),
UrImageSrc->getZeImage(), &DstRegion, &SrcRegion,
zeSignalEvent, numWaitEvents, phWaitEvents));
}
return UR_RESULT_SUCCESS;
};
default:
Expand Down
Loading