From 8ad8e38cd0852987e3bbf3c82f037bff6554b37f Mon Sep 17 00:00:00 2001 From: Sean Stirling Date: Tue, 21 May 2024 14:11:39 +0100 Subject: [PATCH] [Bindless][Exp] Add const-qualifier to Src param in urBindlessImagesImageCopyExp Add const-qualifier to Src parameter in urBindlessImagesImageCopyExp. --- include/ur_api.h | 4 +-- include/ur_ddi.h | 2 +- scripts/core/exp-bindless-images.yml | 2 +- source/adapters/cuda/image.cpp | 30 +++++++++++-------- source/adapters/hip/image.cpp | 2 +- source/adapters/level_zero/image.cpp | 11 +++---- source/adapters/level_zero/queue.hpp | 2 +- source/adapters/level_zero/queue_api.cpp | 2 +- source/adapters/level_zero/queue_api.hpp | 2 +- .../v2/queue_immediate_in_order.cpp | 2 +- .../v2/queue_immediate_in_order.hpp | 2 +- source/adapters/mock/ur_mockddi.cpp | 2 +- source/adapters/native_cpu/image.cpp | 2 +- source/adapters/opencl/image.cpp | 2 +- source/loader/layers/tracing/ur_trcddi.cpp | 2 +- source/loader/layers/validation/ur_valddi.cpp | 2 +- source/loader/ur_ldrddi.cpp | 2 +- source/loader/ur_libapi.cpp | 2 +- source/ur_api.cpp | 2 +- 19 files changed, 41 insertions(+), 36 deletions(-) diff --git a/include/ur_api.h b/include/ur_api.h index 56a6f8f00c..ca256d967b 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -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 @@ -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; diff --git a/include/ur_ddi.h b/include/ur_ddi.h index 5dfcbbe7d0..f8a84765b7 100644 --- a/include/ur_ddi.h +++ b/include/ur_ddi.h @@ -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, diff --git a/scripts/core/exp-bindless-images.yml b/scripts/core/exp-bindless-images.yml index a55c42d0ff..65b67d6648 100644 --- a/scripts/core/exp-bindless-images.yml +++ b/scripts/core/exp-bindless-images.yml @@ -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*" diff --git a/source/adapters/cuda/image.cpp b/source/adapters/cuda/image.cpp index 4b39a9ea61..4887b40a77 100644 --- a/source/adapters/cuda/image.cpp +++ b/source/adapters/cuda/image.cpp @@ -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, @@ -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(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(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( + static_cast(pDst) + (PixelSizeBytes * dstOffset.x)); + UR_CHECK_ERROR( + cuMemcpyHtoDAsync((CUdeviceptr)DstWithOffset, + static_cast(SrcWithOffset), + CopyExtentBytes, Stream)); } else { // This should be unreachable. return UR_RESULT_ERROR_INVALID_VALUE; @@ -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( + static_cast(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(pSrc) + (srcOffset.x * PixelSizeBytes); UR_CHECK_ERROR(cuMemcpyDtoHAsync(DstWithOffset, (CUdeviceptr)SrcWithOffset, CopyExtentBytes, Stream)); diff --git a/source/adapters/hip/image.cpp b/source/adapters/hip/image.cpp index e1115e39a6..1de52c1e18 100644 --- a/source/adapters/hip/image.cpp +++ b/source/adapters/hip/image.cpp @@ -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, diff --git a/source/adapters/level_zero/image.cpp b/source/adapters/level_zero/image.cpp index c04a062218..843b9d4f15 100644 --- a/source/adapters/level_zero/image.cpp +++ b/source/adapters/level_zero/image.cpp @@ -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, @@ -813,8 +813,9 @@ ur_result_t ur_queue_handle_legacy_t_::bindlessImagesImageCopyExp( UR_CALL(getImageRegionHelper(ZeImageDesc, &dstOffset, ©Extent, DstRegion)); auto *UrImage = static_cast<_ur_image *>(pDst); - char *SrcPtr = static_cast(pSrc) + srcOffset.z * SrcSlicePitch + - srcOffset.y * SrcRowPitch + srcOffset.x * PixelSizeInBytes; + const char *SrcPtr = + static_cast(pSrc) + srcOffset.z * SrcSlicePitch + + srcOffset.y * SrcRowPitch + srcOffset.x * PixelSizeInBytes; ZE2UR_CALL(zeCommandListAppendImageCopyFromMemoryExt, (ZeCommandList, UrImage->ZeImage, SrcPtr, &DstRegion, SrcRowPitch, SrcSlicePitch, ZeEvent, WaitList.Length, @@ -844,7 +845,7 @@ ur_result_t ur_queue_handle_legacy_t_::bindlessImagesImageCopyExp( ze_image_region_t SrcRegion; UR_CALL(getImageRegionHelper(ZeImageDesc, &srcOffset, ©Extent, SrcRegion)); - auto *UrImage = static_cast<_ur_image *>(pSrc); + auto *UrImage = static_cast(pSrc); char *DstPtr = static_cast(pDst) + dstOffset.z * DstSlicePitch + dstOffset.y * DstRowPitch + dstOffset.x * PixelSizeInBytes; ZE2UR_CALL(zeCommandListAppendImageCopyToMemoryExt, @@ -876,7 +877,7 @@ ur_result_t ur_queue_handle_legacy_t_::bindlessImagesImageCopyExp( UR_CALL( getImageRegionHelper(ZeImageDesc, &srcOffset, ©Extent, SrcRegion)); auto *UrImageDst = static_cast<_ur_image *>(pDst); - auto *UrImageSrc = static_cast<_ur_image *>(pSrc); + auto *UrImageSrc = static_cast(pSrc); ZE2UR_CALL(zeCommandListAppendImageCopyRegion, (ZeCommandList, UrImageDst->ZeImage, UrImageSrc->ZeImage, &DstRegion, &SrcRegion, ZeEvent, WaitList.Length, diff --git a/source/adapters/level_zero/queue.hpp b/source/adapters/level_zero/queue.hpp index d06bbc5820..f016955932 100644 --- a/source/adapters/level_zero/queue.hpp +++ b/source/adapters/level_zero/queue.hpp @@ -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, diff --git a/source/adapters/level_zero/queue_api.cpp b/source/adapters/level_zero/queue_api.cpp index 622000a07f..31d875cefd 100644 --- a/source/adapters/level_zero/queue_api.cpp +++ b/source/adapters/level_zero/queue_api.cpp @@ -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, diff --git a/source/adapters/level_zero/queue_api.hpp b/source/adapters/level_zero/queue_api.hpp index 3c76901176..f2bfa22c2d 100644 --- a/source/adapters/level_zero/queue_api.hpp +++ b/source/adapters/level_zero/queue_api.hpp @@ -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; diff --git a/source/adapters/level_zero/v2/queue_immediate_in_order.cpp b/source/adapters/level_zero/v2/queue_immediate_in_order.cpp index 4428c34aa0..6d7c380ec7 100644 --- a/source/adapters/level_zero/v2/queue_immediate_in_order.cpp +++ b/source/adapters/level_zero/v2/queue_immediate_in_order.cpp @@ -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, diff --git a/source/adapters/level_zero/v2/queue_immediate_in_order.hpp b/source/adapters/level_zero/v2/queue_immediate_in_order.hpp index 2e3553028f..09f99b07c6 100644 --- a/source/adapters/level_zero/v2/queue_immediate_in_order.hpp +++ b/source/adapters/level_zero/v2/queue_immediate_in_order.hpp @@ -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, diff --git a/source/adapters/mock/ur_mockddi.cpp b/source/adapters/mock/ur_mockddi.cpp index f00aa19b53..5669c67dc4 100644 --- a/source/adapters/mock/ur_mockddi.cpp +++ b/source/adapters/mock/ur_mockddi.cpp @@ -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 diff --git a/source/adapters/native_cpu/image.cpp b/source/adapters/native_cpu/image.cpp index 091ae179aa..e0687a5dd1 100644 --- a/source/adapters/native_cpu/image.cpp +++ b/source/adapters/native_cpu/image.cpp @@ -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, diff --git a/source/adapters/opencl/image.cpp b/source/adapters/opencl/image.cpp index 2cb095818e..d20b6dc0e7 100644 --- a/source/adapters/opencl/image.cpp +++ b/source/adapters/opencl/image.cpp @@ -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, diff --git a/source/loader/layers/tracing/ur_trcddi.cpp b/source/loader/layers/tracing/ur_trcddi.cpp index 71742f1364..46e1ec4080 100644 --- a/source/loader/layers/tracing/ur_trcddi.cpp +++ b/source/loader/layers/tracing/ur_trcddi.cpp @@ -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 diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index 369c6c1e58..5a1845ed73 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -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 diff --git a/source/loader/ur_ldrddi.cpp b/source/loader/ur_ldrddi.cpp index 1ae7aed535..282e625aa0 100644 --- a/source/loader/ur_ldrddi.cpp +++ b/source/loader/ur_ldrddi.cpp @@ -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 diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 89fc540dd3..d285e816a0 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -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 diff --git a/source/ur_api.cpp b/source/ur_api.cpp index 7fc87f9eae..492a6a856a 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -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