Skip to content

Commit

Permalink
use default stream and make 1D copy async
Browse files Browse the repository at this point in the history
  • Loading branch information
cppchedy committed Mar 1, 2024
1 parent 549d56d commit aa04d5d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions source/adapters/cuda/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(

try {
ScopedContext Active(hQueue->getContext());
CUstream Stream = hQueue->getNextTransferStream();
CUstream Stream = 0;
enqueueEventsWait(hQueue, Stream, numEventsInWaitList, phEventWaitList);

// We have to use a different copy function for each image dimensionality.
Expand Down Expand Up @@ -817,9 +817,18 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
}
} else {
if (pImageDesc->type == UR_MEM_TYPE_IMAGE1D) {
UR_CHECK_ERROR(cuMemcpyAtoA((CUarray)pDst, dstOffset.x * PixelSizeBytes,
(CUarray)pSrc, 0,
PixelSizeBytes * copyExtent.width));
CUDA_MEMCPY2D cpy_desc = {};
cpy_desc.srcXInBytes = srcOffset.x;
cpy_desc.srcY = 0;
cpy_desc.dstXInBytes = dstOffset.x;
cpy_desc.dstY = 0;
cpy_desc.srcMemoryType = CUmemorytype_enum::CU_MEMORYTYPE_ARRAY;
cpy_desc.srcArray = (CUarray)pSrc;
cpy_desc.dstMemoryType = CUmemorytype_enum::CU_MEMORYTYPE_ARRAY;
cpy_desc.dstArray = (CUarray)pDst;
cpy_desc.WidthInBytes = PixelSizeBytes * copyExtent.width;
cpy_desc.Height = 1;
UR_CHECK_ERROR(cuMemcpy2DAsync(&cpy_desc, Stream));
} else if (pImageDesc->type == UR_MEM_TYPE_IMAGE2D) {
CUDA_MEMCPY2D cpy_desc = {};
cpy_desc.srcXInBytes = srcOffset.x;
Expand Down

0 comments on commit aa04d5d

Please sign in to comment.