Skip to content

[Bindless][Exp] Add const-qualifier to Src param in urBindlessImagesImageCopyExp #1743

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
Jul 16, 2024
Merged
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
4 changes: 2 additions & 2 deletions include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -7773,7 +7773,7 @@ UR_APIEXPORT ur_result_t UR_APICALL
urBindlessImagesImageCopyExp(
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
void *pDst, ///< [in] location the data will be copied to
void *pSrc, ///< [in] location the data will be copied from
const void *pSrc, ///< [in] location the data will be copied from
const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification
const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description
ur_exp_image_copy_flags_t imageCopyFlags, ///< [in] flags describing copy direction e.g. H2D or D2H
Expand Down Expand Up @@ -11139,7 +11139,7 @@ typedef struct ur_bindless_images_sampled_image_create_exp_params_t {
typedef struct ur_bindless_images_image_copy_exp_params_t {
ur_queue_handle_t *phQueue;
void **ppDst;
void **ppSrc;
const void **ppSrc;
const ur_image_format_t **ppImageFormat;
const ur_image_desc_t **ppImageDesc;
ur_exp_image_copy_flags_t *pimageCopyFlags;
Expand Down
2 changes: 1 addition & 1 deletion include/ur_ddi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesSampledImageCreateExp_t)(
typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImageCopyExp_t)(
ur_queue_handle_t,
void *,
void *,
const void *,
const ur_image_format_t *,
const ur_image_desc_t *,
ur_exp_image_copy_flags_t,
Expand Down
2 changes: 1 addition & 1 deletion scripts/core/exp-bindless-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ params:
- type: void*
name: pDst
desc: "[in] location the data will be copied to"
- type: void*
- type: const void*
name: pSrc
desc: "[in] location the data will be copied from"
- type: "const $x_image_format_t*"
Expand Down
30 changes: 17 additions & 13 deletions source/adapters/cuda/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
}

UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
ur_queue_handle_t hQueue, void *pDst, void *pSrc,
ur_queue_handle_t hQueue, void *pDst, const void *pSrc,
const ur_image_format_t *pImageFormat, const ur_image_desc_t *pImageDesc,
ur_exp_image_copy_flags_t imageCopyFlags, ur_rect_offset_t srcOffset,
ur_rect_offset_t dstOffset, ur_rect_region_t copyExtent,
Expand Down Expand Up @@ -676,18 +676,21 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
(CUdeviceptr)pDst) != CUDA_SUCCESS;

size_t CopyExtentBytes = PixelSizeBytes * copyExtent.width;
char *SrcWithOffset = (char *)pSrc + (srcOffset.x * PixelSizeBytes);
const char *SrcWithOffset =
static_cast<const char *>(pSrc) + (srcOffset.x * PixelSizeBytes);

if (isCudaArray) {
UR_CHECK_ERROR(cuMemcpyHtoAAsync(
(CUarray)pDst, dstOffset.x * PixelSizeBytes,
(void *)SrcWithOffset, CopyExtentBytes, Stream));
UR_CHECK_ERROR(
cuMemcpyHtoAAsync((CUarray)pDst, dstOffset.x * PixelSizeBytes,
static_cast<const void *>(SrcWithOffset),
CopyExtentBytes, Stream));
} else if (memType == CU_MEMORYTYPE_DEVICE) {
void *DstWithOffset =
(void *)((char *)pDst + (PixelSizeBytes * dstOffset.x));
UR_CHECK_ERROR(cuMemcpyHtoDAsync((CUdeviceptr)DstWithOffset,
(void *)SrcWithOffset,
CopyExtentBytes, Stream));
void *DstWithOffset = static_cast<void *>(
static_cast<char *>(pDst) + (PixelSizeBytes * dstOffset.x));
UR_CHECK_ERROR(
cuMemcpyHtoDAsync((CUdeviceptr)DstWithOffset,
static_cast<const void *>(SrcWithOffset),
CopyExtentBytes, Stream));
} else {
// This should be unreachable.
return UR_RESULT_ERROR_INVALID_VALUE;
Expand Down Expand Up @@ -763,15 +766,16 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
(CUdeviceptr)pSrc) != CUDA_SUCCESS;

size_t CopyExtentBytes = PixelSizeBytes * copyExtent.width;
void *DstWithOffset =
(void *)((char *)pDst + (PixelSizeBytes * dstOffset.x));
void *DstWithOffset = static_cast<void *>(
static_cast<char *>(pDst) + (PixelSizeBytes * dstOffset.x));

if (isCudaArray) {
UR_CHECK_ERROR(cuMemcpyAtoHAsync(DstWithOffset, (CUarray)pSrc,
PixelSizeBytes * srcOffset.x,
CopyExtentBytes, Stream));
} else if (memType == CU_MEMORYTYPE_DEVICE) {
char *SrcWithOffset = (char *)pSrc + (srcOffset.x * PixelSizeBytes);
const char *SrcWithOffset =
static_cast<const char *>(pSrc) + (srcOffset.x * PixelSizeBytes);
UR_CHECK_ERROR(cuMemcpyDtoHAsync(DstWithOffset,
(CUdeviceptr)SrcWithOffset,
CopyExtentBytes, Stream));
Expand Down
2 changes: 1 addition & 1 deletion source/adapters/hip/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(

UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
[[maybe_unused]] ur_queue_handle_t hQueue, [[maybe_unused]] void *pDst,
[[maybe_unused]] void *pSrc,
[[maybe_unused]] const void *pSrc,
[[maybe_unused]] const ur_image_format_t *pImageFormat,
[[maybe_unused]] const ur_image_desc_t *pImageDesc,
[[maybe_unused]] ur_exp_image_copy_flags_t imageCopyFlags,
Expand Down
11 changes: 6 additions & 5 deletions source/adapters/level_zero/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
}

ur_result_t ur_queue_handle_legacy_t_::bindlessImagesImageCopyExp(
void *pDst, void *pSrc, const ur_image_format_t *pImageFormat,
void *pDst, const void *pSrc, const ur_image_format_t *pImageFormat,
const ur_image_desc_t *pImageDesc, ur_exp_image_copy_flags_t imageCopyFlags,
ur_rect_offset_t srcOffset, ur_rect_offset_t dstOffset,
ur_rect_region_t copyExtent, ur_rect_region_t hostExtent,
Expand Down Expand Up @@ -813,8 +813,9 @@ ur_result_t ur_queue_handle_legacy_t_::bindlessImagesImageCopyExp(
UR_CALL(getImageRegionHelper(ZeImageDesc, &dstOffset, &copyExtent,
DstRegion));
auto *UrImage = static_cast<_ur_image *>(pDst);
char *SrcPtr = static_cast<char *>(pSrc) + srcOffset.z * SrcSlicePitch +
srcOffset.y * SrcRowPitch + srcOffset.x * PixelSizeInBytes;
const char *SrcPtr =
static_cast<const char *>(pSrc) + srcOffset.z * SrcSlicePitch +
srcOffset.y * SrcRowPitch + srcOffset.x * PixelSizeInBytes;
ZE2UR_CALL(zeCommandListAppendImageCopyFromMemoryExt,
(ZeCommandList, UrImage->ZeImage, SrcPtr, &DstRegion,
SrcRowPitch, SrcSlicePitch, ZeEvent, WaitList.Length,
Expand Down Expand Up @@ -844,7 +845,7 @@ ur_result_t ur_queue_handle_legacy_t_::bindlessImagesImageCopyExp(
ze_image_region_t SrcRegion;
UR_CALL(getImageRegionHelper(ZeImageDesc, &srcOffset, &copyExtent,
SrcRegion));
auto *UrImage = static_cast<_ur_image *>(pSrc);
auto *UrImage = static_cast<const _ur_image *>(pSrc);
char *DstPtr = static_cast<char *>(pDst) + dstOffset.z * DstSlicePitch +
dstOffset.y * DstRowPitch + dstOffset.x * PixelSizeInBytes;
ZE2UR_CALL(zeCommandListAppendImageCopyToMemoryExt,
Expand Down Expand Up @@ -876,7 +877,7 @@ ur_result_t ur_queue_handle_legacy_t_::bindlessImagesImageCopyExp(
UR_CALL(
getImageRegionHelper(ZeImageDesc, &srcOffset, &copyExtent, SrcRegion));
auto *UrImageDst = static_cast<_ur_image *>(pDst);
auto *UrImageSrc = static_cast<_ur_image *>(pSrc);
auto *UrImageSrc = static_cast<const _ur_image *>(pSrc);
ZE2UR_CALL(zeCommandListAppendImageCopyRegion,
(ZeCommandList, UrImageDst->ZeImage, UrImageSrc->ZeImage,
&DstRegion, &SrcRegion, ZeEvent, WaitList.Length,
Expand Down
2 changes: 1 addition & 1 deletion source/adapters/level_zero/queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ struct ur_queue_handle_legacy_t_ : _ur_object, public ur_queue_handle_t_ {
const ur_event_handle_t *phEventWaitList,
ur_event_handle_t *phEvent) override;
ur_result_t bindlessImagesImageCopyExp(
void *pDst, void *pSrc, const ur_image_format_t *pImageFormat,
void *pDst, const void *pSrc, const ur_image_format_t *pImageFormat,
const ur_image_desc_t *pImageDesc,
ur_exp_image_copy_flags_t imageCopyFlags, ur_rect_offset_t srcOffset,
ur_rect_offset_t dstOffset, ur_rect_region_t copyExtent,
Expand Down
2 changes: 1 addition & 1 deletion source/adapters/level_zero/queue_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueWriteHostPipe(
phEventWaitList, phEvent);
}
UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
ur_queue_handle_t hQueue, void *pDst, void *pSrc,
ur_queue_handle_t hQueue, void *pDst, const void *pSrc,
const ur_image_format_t *pImageFormat, const ur_image_desc_t *pImageDesc,
ur_exp_image_copy_flags_t imageCopyFlags, ur_rect_offset_t srcOffset,
ur_rect_offset_t dstOffset, ur_rect_region_t copyExtent,
Expand Down
2 changes: 1 addition & 1 deletion source/adapters/level_zero/queue_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ struct ur_queue_handle_t_ {
const ur_event_handle_t *,
ur_event_handle_t *) = 0;
virtual ur_result_t bindlessImagesImageCopyExp(
void *, void *, const ur_image_format_t *, const ur_image_desc_t *,
void *, const void *, const ur_image_format_t *, const ur_image_desc_t *,
ur_exp_image_copy_flags_t, ur_rect_offset_t, ur_rect_offset_t,
ur_rect_region_t, ur_rect_region_t, uint32_t, const ur_event_handle_t *,
ur_event_handle_t *) = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ ur_result_t ur_queue_immediate_in_order_t::enqueueWriteHostPipe(
}

ur_result_t ur_queue_immediate_in_order_t::bindlessImagesImageCopyExp(
void *pDst, void *pSrc, const ur_image_format_t *pImageFormat,
void *pDst, const void *pSrc, const ur_image_format_t *pImageFormat,
const ur_image_desc_t *pImageDesc, ur_exp_image_copy_flags_t imageCopyFlags,
ur_rect_offset_t srcOffset, ur_rect_offset_t dstOffset,
ur_rect_region_t copyExtent, ur_rect_region_t hostExtent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ struct ur_queue_immediate_in_order_t : _ur_object, public ur_queue_handle_t_ {
const ur_event_handle_t *phEventWaitList,
ur_event_handle_t *phEvent) override;
ur_result_t bindlessImagesImageCopyExp(
void *pDst, void *pSrc, const ur_image_format_t *pImageFormat,
void *pDst, const void *pSrc, const ur_image_format_t *pImageFormat,
const ur_image_desc_t *pImageDesc,
ur_exp_image_copy_flags_t imageCopyFlags, ur_rect_offset_t srcOffset,
ur_rect_offset_t dstOffset, ur_rect_region_t copyExtent,
Expand Down
2 changes: 1 addition & 1 deletion source/adapters/mock/ur_mockddi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7454,7 +7454,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
__urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
void *pDst, ///< [in] location the data will be copied to
void *pSrc, ///< [in] location the data will be copied from
const void *pSrc, ///< [in] location the data will be copied from
const ur_image_format_t
*pImageFormat, ///< [in] pointer to image format specification
const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description
Expand Down
2 changes: 1 addition & 1 deletion source/adapters/native_cpu/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(

UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
[[maybe_unused]] ur_queue_handle_t hQueue, [[maybe_unused]] void *pDst,
[[maybe_unused]] void *pSrc,
[[maybe_unused]] const void *pSrc,
[[maybe_unused]] const ur_image_format_t *pImageFormat,
[[maybe_unused]] const ur_image_desc_t *pImageDesc,
[[maybe_unused]] ur_exp_image_copy_flags_t imageCopyFlags,
Expand Down
2 changes: 1 addition & 1 deletion source/adapters/opencl/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(

UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
[[maybe_unused]] ur_queue_handle_t hQueue, [[maybe_unused]] void *pDst,
[[maybe_unused]] void *pSrc,
[[maybe_unused]] const void *pSrc,
[[maybe_unused]] const ur_image_format_t *pImageFormat,
[[maybe_unused]] const ur_image_desc_t *pImageDesc,
[[maybe_unused]] ur_exp_image_copy_flags_t imageCopyFlags,
Expand Down
2 changes: 1 addition & 1 deletion source/loader/layers/tracing/ur_trcddi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5770,7 +5770,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
__urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
void *pDst, ///< [in] location the data will be copied to
void *pSrc, ///< [in] location the data will be copied from
const void *pSrc, ///< [in] location the data will be copied from
const ur_image_format_t
*pImageFormat, ///< [in] pointer to image format specification
const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description
Expand Down
2 changes: 1 addition & 1 deletion source/loader/layers/validation/ur_valddi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7194,7 +7194,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
__urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
void *pDst, ///< [in] location the data will be copied to
void *pSrc, ///< [in] location the data will be copied from
const void *pSrc, ///< [in] location the data will be copied from
const ur_image_format_t
*pImageFormat, ///< [in] pointer to image format specification
const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description
Expand Down
2 changes: 1 addition & 1 deletion source/loader/ur_ldrddi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6364,7 +6364,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
__urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
void *pDst, ///< [in] location the data will be copied to
void *pSrc, ///< [in] location the data will be copied from
const void *pSrc, ///< [in] location the data will be copied from
const ur_image_format_t
*pImageFormat, ///< [in] pointer to image format specification
const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description
Expand Down
2 changes: 1 addition & 1 deletion source/loader/ur_libapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6856,7 +6856,7 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
void *pDst, ///< [in] location the data will be copied to
void *pSrc, ///< [in] location the data will be copied from
const void *pSrc, ///< [in] location the data will be copied from
const ur_image_format_t
*pImageFormat, ///< [in] pointer to image format specification
const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description
Expand Down
2 changes: 1 addition & 1 deletion source/ur_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5847,7 +5847,7 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
void *pDst, ///< [in] location the data will be copied to
void *pSrc, ///< [in] location the data will be copied from
const void *pSrc, ///< [in] location the data will be copied from
const ur_image_format_t
*pImageFormat, ///< [in] pointer to image format specification
const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description
Expand Down
Loading