Skip to content

Commit 2530994

Browse files
JackAKirkSeanst98ProGTXsteffenlarsen
authored andcommitted
gather_image extension doc and impl (#17322)
This PR presents a portable `gather_image` API for the bindless images extension, with an initial cuda implementation for 2D images only. Cubemap support is also possible but not yet added at this stage, since - it is unclear whether this can map to the spirv cube case. - l0 doesn't yet even support cubemaps anyway For 2D images the mapping to `__spirv_SampledImageGather` is straightforward and unambiguous. For complete details see the extension documentation in this PR. --------- Signed-off-by: JackAKirk <[email protected]> Co-authored-by: Sean Stirling <[email protected]> Co-authored-by: Peter Žužek <[email protected]> Co-authored-by: Steffen Larsen <[email protected]>
1 parent 6e393d1 commit 2530994

File tree

10 files changed

+59
-1
lines changed

10 files changed

+59
-1
lines changed

include/ur_api.h

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

include/ur_print.hpp

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/core/EXP-BINDLESS-IMAGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ Enums
9999
* ${X}_DEVICE_INFO_BINDLESS_UNIQUE_ADDRESSING_PER_DIM_EXP
100100
* ${X}_DEVICE_INFO_BINDLESS_SAMPLE_1D_USM_EXP
101101
* ${X}_DEVICE_INFO_BINDLESS_SAMPLE_2D_USM_EXP
102+
* ${X}_DEVICE_INFO_BINDLESS_IMAGES_GATHER_EXP
102103

103104
* ${x}_command_t
104105
* ${X}_COMMAND_EXTERNAL_SEMAPHORE_WAIT_EXP
@@ -148,6 +149,7 @@ Enums
148149

149150
* ${x}_mem_type_t
150151
* ${X}_MEM_TYPE_IMAGE_CUBEMAP_EXP
152+
* ${X}_MEM_TYPE_IMAGE_GATHER_EXP
151153

152154
Types
153155
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

scripts/core/exp-bindless-images.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ etors:
113113
- name: BINDLESS_SAMPLE_2D_USM_EXP
114114
value: "0x201C"
115115
desc: "[$x_bool_t] returns true if the device supports sampling USM backed 2D sampled image data."
116+
- name: BINDLESS_IMAGES_GATHER_EXP
117+
value: "0x201D"
118+
desc: "[$x_bool_t] returns true if the device supports sampled image gather."
116119
--- #--------------------------------------------------------------------------
117120
type: enum
118121
extend: true
@@ -180,6 +183,15 @@ etors:
180183
desc: "Experimental cubemap image object"
181184
--- #--------------------------------------------------------------------------
182185
type: enum
186+
extend: True
187+
desc: "Memory types"
188+
name: $x_mem_type_t
189+
etors:
190+
- name: IMAGE_GATHER_EXP
191+
value: "0x2001"
192+
desc: "Experimental gather image object"
193+
--- #--------------------------------------------------------------------------
194+
type: enum
183195
desc: "Sampler cubemap seamless filtering mode."
184196
class: $xBindlessImages
185197
name: $x_exp_sampler_cubemap_filter_mode_t

source/adapters/cuda/device.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
932932
// CUDA does support sampling 1D USM sampled image data.
933933
return ReturnValue(static_cast<ur_bool_t>(true));
934934
}
935+
case UR_DEVICE_INFO_BINDLESS_IMAGES_GATHER_EXP: {
936+
// CUDA does support sampled image gather.
937+
return ReturnValue(static_cast<ur_bool_t>(true));
938+
}
935939
case UR_DEVICE_INFO_TIMESTAMP_RECORDING_SUPPORT_EXP: {
936940
// CUDA supports recording timestamp events.
937941
return ReturnValue(static_cast<ur_bool_t>(true));

source/adapters/cuda/image.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageAllocateExp(
370370
array_desc.Depth = pImageDesc->arraySize; // Should be 6 ONLY
371371
array_desc.Flags |= CUDA_ARRAY3D_CUBEMAP;
372372
break;
373+
case UR_MEM_TYPE_IMAGE_GATHER_EXP:
374+
array_desc.Height = pImageDesc->height;
375+
array_desc.Depth = pImageDesc->arraySize;
376+
array_desc.Flags |= CUDA_ARRAY3D_TEXTURE_GATHER;
377+
break;
373378
default:
374379
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
375380
}

source/adapters/hip/device.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
891891
return ReturnValue(
892892
static_cast<ur_bool_t>(hDevice->supportsHardwareImages()));
893893
}
894-
894+
case UR_DEVICE_INFO_BINDLESS_IMAGES_GATHER_EXP: {
895+
// HIP doesn't support sampled image gather.
896+
return ReturnValue(static_cast<ur_bool_t>(false));
897+
}
895898
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS: {
896899
return ReturnValue(ur_bool_t{false});
897900
}

source/adapters/level_zero/device.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,10 @@ ur_result_t urDeviceGetInfo(
11651165
// L0 does not support sampling 2D USM sampled image data.
11661166
return ReturnValue(false);
11671167
}
1168+
case UR_DEVICE_INFO_BINDLESS_IMAGES_GATHER_EXP: {
1169+
// L0 doesn't support sampled image gather.
1170+
return ReturnValue(static_cast<ur_bool_t>(false));
1171+
}
11681172
case UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS:
11691173
return ReturnValue(true);
11701174
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:

source/adapters/opencl/device.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
15891589
case UR_DEVICE_INFO_BINDLESS_UNIQUE_ADDRESSING_PER_DIM_EXP:
15901590
case UR_DEVICE_INFO_BINDLESS_SAMPLE_1D_USM_EXP:
15911591
case UR_DEVICE_INFO_BINDLESS_SAMPLE_2D_USM_EXP:
1592+
case UR_DEVICE_INFO_BINDLESS_IMAGES_GATHER_EXP:
15921593
return ReturnValue(false);
15931594
case UR_DEVICE_INFO_IMAGE_PITCH_ALIGN_EXP:
15941595
case UR_DEVICE_INFO_MAX_IMAGE_LINEAR_WIDTH_EXP:

tools/urinfo/urinfo.hpp

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)