Skip to content

Commit 6c2329e

Browse files
authored
Merge pull request #1743 from Seanst98/sean/copy-const-qualifiers
[Bindless][Exp] Add const-qualifier to Src param in urBindlessImagesImageCopyExp
2 parents 6025fee + 8ad8e38 commit 6c2329e

19 files changed

+41
-36
lines changed

include/ur_api.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -7773,7 +7773,7 @@ UR_APIEXPORT ur_result_t UR_APICALL
77737773
urBindlessImagesImageCopyExp(
77747774
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
77757775
void *pDst, ///< [in] location the data will be copied to
7776-
void *pSrc, ///< [in] location the data will be copied from
7776+
const void *pSrc, ///< [in] location the data will be copied from
77777777
const ur_image_format_t *pImageFormat, ///< [in] pointer to image format specification
77787778
const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description
77797779
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 {
1113911139
typedef struct ur_bindless_images_image_copy_exp_params_t {
1114011140
ur_queue_handle_t *phQueue;
1114111141
void **ppDst;
11142-
void **ppSrc;
11142+
const void **ppSrc;
1114311143
const ur_image_format_t **ppImageFormat;
1114411144
const ur_image_desc_t **ppImageDesc;
1114511145
ur_exp_image_copy_flags_t *pimageCopyFlags;

include/ur_ddi.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,7 @@ typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesSampledImageCreateExp_t)(
15821582
typedef ur_result_t(UR_APICALL *ur_pfnBindlessImagesImageCopyExp_t)(
15831583
ur_queue_handle_t,
15841584
void *,
1585-
void *,
1585+
const void *,
15861586
const ur_image_format_t *,
15871587
const ur_image_desc_t *,
15881588
ur_exp_image_copy_flags_t,

scripts/core/exp-bindless-images.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ params:
527527
- type: void*
528528
name: pDst
529529
desc: "[in] location the data will be copied to"
530-
- type: void*
530+
- type: const void*
531531
name: pSrc
532532
desc: "[in] location the data will be copied from"
533533
- type: "const $x_image_format_t*"

source/adapters/cuda/image.cpp

+17-13
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
634634
}
635635

636636
UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
637-
ur_queue_handle_t hQueue, void *pDst, void *pSrc,
637+
ur_queue_handle_t hQueue, void *pDst, const void *pSrc,
638638
const ur_image_format_t *pImageFormat, const ur_image_desc_t *pImageDesc,
639639
ur_exp_image_copy_flags_t imageCopyFlags, ur_rect_offset_t srcOffset,
640640
ur_rect_offset_t dstOffset, ur_rect_region_t copyExtent,
@@ -676,18 +676,21 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
676676
(CUdeviceptr)pDst) != CUDA_SUCCESS;
677677

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

681682
if (isCudaArray) {
682-
UR_CHECK_ERROR(cuMemcpyHtoAAsync(
683-
(CUarray)pDst, dstOffset.x * PixelSizeBytes,
684-
(void *)SrcWithOffset, CopyExtentBytes, Stream));
683+
UR_CHECK_ERROR(
684+
cuMemcpyHtoAAsync((CUarray)pDst, dstOffset.x * PixelSizeBytes,
685+
static_cast<const void *>(SrcWithOffset),
686+
CopyExtentBytes, Stream));
685687
} else if (memType == CU_MEMORYTYPE_DEVICE) {
686-
void *DstWithOffset =
687-
(void *)((char *)pDst + (PixelSizeBytes * dstOffset.x));
688-
UR_CHECK_ERROR(cuMemcpyHtoDAsync((CUdeviceptr)DstWithOffset,
689-
(void *)SrcWithOffset,
690-
CopyExtentBytes, Stream));
688+
void *DstWithOffset = static_cast<void *>(
689+
static_cast<char *>(pDst) + (PixelSizeBytes * dstOffset.x));
690+
UR_CHECK_ERROR(
691+
cuMemcpyHtoDAsync((CUdeviceptr)DstWithOffset,
692+
static_cast<const void *>(SrcWithOffset),
693+
CopyExtentBytes, Stream));
691694
} else {
692695
// This should be unreachable.
693696
return UR_RESULT_ERROR_INVALID_VALUE;
@@ -763,15 +766,16 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
763766
(CUdeviceptr)pSrc) != CUDA_SUCCESS;
764767

765768
size_t CopyExtentBytes = PixelSizeBytes * copyExtent.width;
766-
void *DstWithOffset =
767-
(void *)((char *)pDst + (PixelSizeBytes * dstOffset.x));
769+
void *DstWithOffset = static_cast<void *>(
770+
static_cast<char *>(pDst) + (PixelSizeBytes * dstOffset.x));
768771

769772
if (isCudaArray) {
770773
UR_CHECK_ERROR(cuMemcpyAtoHAsync(DstWithOffset, (CUarray)pSrc,
771774
PixelSizeBytes * srcOffset.x,
772775
CopyExtentBytes, Stream));
773776
} else if (memType == CU_MEMORYTYPE_DEVICE) {
774-
char *SrcWithOffset = (char *)pSrc + (srcOffset.x * PixelSizeBytes);
777+
const char *SrcWithOffset =
778+
static_cast<const char *>(pSrc) + (srcOffset.x * PixelSizeBytes);
775779
UR_CHECK_ERROR(cuMemcpyDtoHAsync(DstWithOffset,
776780
(CUdeviceptr)SrcWithOffset,
777781
CopyExtentBytes, Stream));

source/adapters/hip/image.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
7676

7777
UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
7878
[[maybe_unused]] ur_queue_handle_t hQueue, [[maybe_unused]] void *pDst,
79-
[[maybe_unused]] void *pSrc,
79+
[[maybe_unused]] const void *pSrc,
8080
[[maybe_unused]] const ur_image_format_t *pImageFormat,
8181
[[maybe_unused]] const ur_image_desc_t *pImageDesc,
8282
[[maybe_unused]] ur_exp_image_copy_flags_t imageCopyFlags,

source/adapters/level_zero/image.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
751751
}
752752

753753
ur_result_t ur_queue_handle_legacy_t_::bindlessImagesImageCopyExp(
754-
void *pDst, void *pSrc, const ur_image_format_t *pImageFormat,
754+
void *pDst, const void *pSrc, const ur_image_format_t *pImageFormat,
755755
const ur_image_desc_t *pImageDesc, ur_exp_image_copy_flags_t imageCopyFlags,
756756
ur_rect_offset_t srcOffset, ur_rect_offset_t dstOffset,
757757
ur_rect_region_t copyExtent, ur_rect_region_t hostExtent,
@@ -813,8 +813,9 @@ ur_result_t ur_queue_handle_legacy_t_::bindlessImagesImageCopyExp(
813813
UR_CALL(getImageRegionHelper(ZeImageDesc, &dstOffset, &copyExtent,
814814
DstRegion));
815815
auto *UrImage = static_cast<_ur_image *>(pDst);
816-
char *SrcPtr = static_cast<char *>(pSrc) + srcOffset.z * SrcSlicePitch +
817-
srcOffset.y * SrcRowPitch + srcOffset.x * PixelSizeInBytes;
816+
const char *SrcPtr =
817+
static_cast<const char *>(pSrc) + srcOffset.z * SrcSlicePitch +
818+
srcOffset.y * SrcRowPitch + srcOffset.x * PixelSizeInBytes;
818819
ZE2UR_CALL(zeCommandListAppendImageCopyFromMemoryExt,
819820
(ZeCommandList, UrImage->ZeImage, SrcPtr, &DstRegion,
820821
SrcRowPitch, SrcSlicePitch, ZeEvent, WaitList.Length,
@@ -844,7 +845,7 @@ ur_result_t ur_queue_handle_legacy_t_::bindlessImagesImageCopyExp(
844845
ze_image_region_t SrcRegion;
845846
UR_CALL(getImageRegionHelper(ZeImageDesc, &srcOffset, &copyExtent,
846847
SrcRegion));
847-
auto *UrImage = static_cast<_ur_image *>(pSrc);
848+
auto *UrImage = static_cast<const _ur_image *>(pSrc);
848849
char *DstPtr = static_cast<char *>(pDst) + dstOffset.z * DstSlicePitch +
849850
dstOffset.y * DstRowPitch + dstOffset.x * PixelSizeInBytes;
850851
ZE2UR_CALL(zeCommandListAppendImageCopyToMemoryExt,
@@ -876,7 +877,7 @@ ur_result_t ur_queue_handle_legacy_t_::bindlessImagesImageCopyExp(
876877
UR_CALL(
877878
getImageRegionHelper(ZeImageDesc, &srcOffset, &copyExtent, SrcRegion));
878879
auto *UrImageDst = static_cast<_ur_image *>(pDst);
879-
auto *UrImageSrc = static_cast<_ur_image *>(pSrc);
880+
auto *UrImageSrc = static_cast<const _ur_image *>(pSrc);
880881
ZE2UR_CALL(zeCommandListAppendImageCopyRegion,
881882
(ZeCommandList, UrImageDst->ZeImage, UrImageSrc->ZeImage,
882883
&DstRegion, &SrcRegion, ZeEvent, WaitList.Length,

source/adapters/level_zero/queue.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ struct ur_queue_handle_legacy_t_ : _ur_object, public ur_queue_handle_t_ {
381381
const ur_event_handle_t *phEventWaitList,
382382
ur_event_handle_t *phEvent) override;
383383
ur_result_t bindlessImagesImageCopyExp(
384-
void *pDst, void *pSrc, const ur_image_format_t *pImageFormat,
384+
void *pDst, const void *pSrc, const ur_image_format_t *pImageFormat,
385385
const ur_image_desc_t *pImageDesc,
386386
ur_exp_image_copy_flags_t imageCopyFlags, ur_rect_offset_t srcOffset,
387387
ur_rect_offset_t dstOffset, ur_rect_region_t copyExtent,

source/adapters/level_zero/queue_api.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueWriteHostPipe(
255255
phEventWaitList, phEvent);
256256
}
257257
UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
258-
ur_queue_handle_t hQueue, void *pDst, void *pSrc,
258+
ur_queue_handle_t hQueue, void *pDst, const void *pSrc,
259259
const ur_image_format_t *pImageFormat, const ur_image_desc_t *pImageDesc,
260260
ur_exp_image_copy_flags_t imageCopyFlags, ur_rect_offset_t srcOffset,
261261
ur_rect_offset_t dstOffset, ur_rect_region_t copyExtent,

source/adapters/level_zero/queue_api.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ struct ur_queue_handle_t_ {
123123
const ur_event_handle_t *,
124124
ur_event_handle_t *) = 0;
125125
virtual ur_result_t bindlessImagesImageCopyExp(
126-
void *, void *, const ur_image_format_t *, const ur_image_desc_t *,
126+
void *, const void *, const ur_image_format_t *, const ur_image_desc_t *,
127127
ur_exp_image_copy_flags_t, ur_rect_offset_t, ur_rect_offset_t,
128128
ur_rect_region_t, ur_rect_region_t, uint32_t, const ur_event_handle_t *,
129129
ur_event_handle_t *) = 0;

source/adapters/level_zero/v2/queue_immediate_in_order.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ ur_result_t ur_queue_immediate_in_order_t::enqueueWriteHostPipe(
435435
}
436436

437437
ur_result_t ur_queue_immediate_in_order_t::bindlessImagesImageCopyExp(
438-
void *pDst, void *pSrc, const ur_image_format_t *pImageFormat,
438+
void *pDst, const void *pSrc, const ur_image_format_t *pImageFormat,
439439
const ur_image_desc_t *pImageDesc, ur_exp_image_copy_flags_t imageCopyFlags,
440440
ur_rect_offset_t srcOffset, ur_rect_offset_t dstOffset,
441441
ur_rect_region_t copyExtent, ur_rect_region_t hostExtent,

source/adapters/level_zero/v2/queue_immediate_in_order.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ struct ur_queue_immediate_in_order_t : _ur_object, public ur_queue_handle_t_ {
162162
const ur_event_handle_t *phEventWaitList,
163163
ur_event_handle_t *phEvent) override;
164164
ur_result_t bindlessImagesImageCopyExp(
165-
void *pDst, void *pSrc, const ur_image_format_t *pImageFormat,
165+
void *pDst, const void *pSrc, const ur_image_format_t *pImageFormat,
166166
const ur_image_desc_t *pImageDesc,
167167
ur_exp_image_copy_flags_t imageCopyFlags, ur_rect_offset_t srcOffset,
168168
ur_rect_offset_t dstOffset, ur_rect_region_t copyExtent,

source/adapters/mock/ur_mockddi.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7454,7 +7454,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
74547454
__urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
74557455
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
74567456
void *pDst, ///< [in] location the data will be copied to
7457-
void *pSrc, ///< [in] location the data will be copied from
7457+
const void *pSrc, ///< [in] location the data will be copied from
74587458
const ur_image_format_t
74597459
*pImageFormat, ///< [in] pointer to image format specification
74607460
const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description

source/adapters/native_cpu/image.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
7676

7777
UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
7878
[[maybe_unused]] ur_queue_handle_t hQueue, [[maybe_unused]] void *pDst,
79-
[[maybe_unused]] void *pSrc,
79+
[[maybe_unused]] const void *pSrc,
8080
[[maybe_unused]] const ur_image_format_t *pImageFormat,
8181
[[maybe_unused]] const ur_image_desc_t *pImageDesc,
8282
[[maybe_unused]] ur_exp_image_copy_flags_t imageCopyFlags,

source/adapters/opencl/image.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
7676

7777
UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
7878
[[maybe_unused]] ur_queue_handle_t hQueue, [[maybe_unused]] void *pDst,
79-
[[maybe_unused]] void *pSrc,
79+
[[maybe_unused]] const void *pSrc,
8080
[[maybe_unused]] const ur_image_format_t *pImageFormat,
8181
[[maybe_unused]] const ur_image_desc_t *pImageDesc,
8282
[[maybe_unused]] ur_exp_image_copy_flags_t imageCopyFlags,

source/loader/layers/tracing/ur_trcddi.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5770,7 +5770,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
57705770
__urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
57715771
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
57725772
void *pDst, ///< [in] location the data will be copied to
5773-
void *pSrc, ///< [in] location the data will be copied from
5773+
const void *pSrc, ///< [in] location the data will be copied from
57745774
const ur_image_format_t
57755775
*pImageFormat, ///< [in] pointer to image format specification
57765776
const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description

source/loader/layers/validation/ur_valddi.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7194,7 +7194,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
71947194
__urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
71957195
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
71967196
void *pDst, ///< [in] location the data will be copied to
7197-
void *pSrc, ///< [in] location the data will be copied from
7197+
const void *pSrc, ///< [in] location the data will be copied from
71987198
const ur_image_format_t
71997199
*pImageFormat, ///< [in] pointer to image format specification
72007200
const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description

source/loader/ur_ldrddi.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6364,7 +6364,7 @@ __urdlllocal ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
63646364
__urdlllocal ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
63656365
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
63666366
void *pDst, ///< [in] location the data will be copied to
6367-
void *pSrc, ///< [in] location the data will be copied from
6367+
const void *pSrc, ///< [in] location the data will be copied from
63686368
const ur_image_format_t
63696369
*pImageFormat, ///< [in] pointer to image format specification
63706370
const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description

source/loader/ur_libapi.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6856,7 +6856,7 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
68566856
ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
68576857
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
68586858
void *pDst, ///< [in] location the data will be copied to
6859-
void *pSrc, ///< [in] location the data will be copied from
6859+
const void *pSrc, ///< [in] location the data will be copied from
68606860
const ur_image_format_t
68616861
*pImageFormat, ///< [in] pointer to image format specification
68626862
const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description

source/ur_api.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5847,7 +5847,7 @@ ur_result_t UR_APICALL urBindlessImagesSampledImageCreateExp(
58475847
ur_result_t UR_APICALL urBindlessImagesImageCopyExp(
58485848
ur_queue_handle_t hQueue, ///< [in] handle of the queue object
58495849
void *pDst, ///< [in] location the data will be copied to
5850-
void *pSrc, ///< [in] location the data will be copied from
5850+
const void *pSrc, ///< [in] location the data will be copied from
58515851
const ur_image_format_t
58525852
*pImageFormat, ///< [in] pointer to image format specification
58535853
const ur_image_desc_t *pImageDesc, ///< [in] pointer to image description

0 commit comments

Comments
 (0)