Skip to content

Commit

Permalink
[Bindless][Exp] Add device queries for sampled image fetch
Browse files Browse the repository at this point in the history
Added the following queries for device capabilities of fetching sampled
images:

- DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_USM
- DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D
- DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D_USM
- DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D
- DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D_USM
- DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D
  • Loading branch information
przemektmalon committed Jan 19, 2024
1 parent 5d58871 commit aa442a3
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 4 deletions.
14 changes: 13 additions & 1 deletion include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -1562,6 +1562,18 @@ typedef enum ur_device_info_t {
///< semaphore resources
UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP = 0x200F, ///< [::ur_bool_t] returns true if the device supports exporting internal
///< event resources
UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_USM = 0x2010, ///< [::ur_bool_t] returns true if the device is capable of fetching USM
///< backed 1D sampled image data.
UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D = 0x2011, ///< [::ur_bool_t] returns true if the device is capable of fetching
///< non-USM backed 1D sampled image data.
UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D_USM = 0x2012, ///< [::ur_bool_t] returns true if the device is capable of fetching USM
///< backed 2D sampled image data.
UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D = 0x2013, ///< [::ur_bool_t] returns true if the device is capable of fetching
///< non-USM backed 2D sampled image data.
UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D_USM = 0x2014, ///< [::ur_bool_t] returns true if the device is capable of fetching USM
///< backed 3D sampled image data.
UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D = 0x2015, ///< [::ur_bool_t] returns true if the device is capable of fetching
///< non-USM backed 3D sampled image data.
/// @cond
UR_DEVICE_INFO_FORCE_UINT32 = 0x7fffffff
/// @endcond
Expand All @@ -1587,7 +1599,7 @@ typedef enum ur_device_info_t {
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hDevice`
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
/// + `::UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP < propName`
/// + `::UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D < propName`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
/// + If `propName` is not supported by the adapter.
/// - ::UR_RESULT_ERROR_INVALID_SIZE
Expand Down
90 changes: 90 additions & 0 deletions include/ur_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2449,6 +2449,24 @@ inline std::ostream &operator<<(std::ostream &os, ur_device_info_t value) {
case UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP:
os << "UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP";
break;
case UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_USM:
os << "UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_USM";
break;
case UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D:
os << "UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D";
break;
case UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D_USM:
os << "UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D_USM";
break;
case UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D:
os << "UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D";
break;
case UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D_USM:
os << "UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D_USM";
break;
case UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D:
os << "UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D";
break;
default:
os << "unknown enumerator";
break;
Expand Down Expand Up @@ -4001,6 +4019,78 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, ur_device_info

os << ")";
} break;
case UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_USM: {
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
if (sizeof(ur_bool_t) > size) {
os << "invalid size (is: " << size << ", expected: >=" << sizeof(ur_bool_t) << ")";
return UR_RESULT_ERROR_INVALID_SIZE;
}
os << (const void *)(tptr) << " (";

os << *tptr;

os << ")";
} break;
case UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D: {
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
if (sizeof(ur_bool_t) > size) {
os << "invalid size (is: " << size << ", expected: >=" << sizeof(ur_bool_t) << ")";
return UR_RESULT_ERROR_INVALID_SIZE;
}
os << (const void *)(tptr) << " (";

os << *tptr;

os << ")";
} break;
case UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D_USM: {
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
if (sizeof(ur_bool_t) > size) {
os << "invalid size (is: " << size << ", expected: >=" << sizeof(ur_bool_t) << ")";
return UR_RESULT_ERROR_INVALID_SIZE;
}
os << (const void *)(tptr) << " (";

os << *tptr;

os << ")";
} break;
case UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D: {
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
if (sizeof(ur_bool_t) > size) {
os << "invalid size (is: " << size << ", expected: >=" << sizeof(ur_bool_t) << ")";
return UR_RESULT_ERROR_INVALID_SIZE;
}
os << (const void *)(tptr) << " (";

os << *tptr;

os << ")";
} break;
case UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D_USM: {
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
if (sizeof(ur_bool_t) > size) {
os << "invalid size (is: " << size << ", expected: >=" << sizeof(ur_bool_t) << ")";
return UR_RESULT_ERROR_INVALID_SIZE;
}
os << (const void *)(tptr) << " (";

os << *tptr;

os << ")";
} break;
case UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D: {
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
if (sizeof(ur_bool_t) > size) {
os << "invalid size (is: " << size << ", expected: >=" << sizeof(ur_bool_t) << ")";
return UR_RESULT_ERROR_INVALID_SIZE;
}
os << (const void *)(tptr) << " (";

os << *tptr;

os << ")";
} break;
default:
os << "unknown enumerator";
return UR_RESULT_ERROR_INVALID_ENUMERATION;
Expand Down
8 changes: 8 additions & 0 deletions scripts/core/EXP-BINDLESS-IMAGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ Enums
* ${X}_DEVICE_INFO_INTEROP_MEMORY_EXPORT_SUPPORT_EXP
* ${X}_DEVICE_INFO_INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP
* ${X}_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP
* ${X}_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_USM
* ${X}_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D
* ${X}_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D_USM
* ${X}_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D
* ${X}_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D_USM
* ${X}_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D

* ${x}_command_t
* ${X}_COMMAND_INTEROP_SEMAPHORE_WAIT_EXP
Expand Down Expand Up @@ -184,6 +190,8 @@ Changelog
+------------------------------------------------------------------------+
| 9.0 | Remove layered image properties struct. |
+------------------------------------------------------------------------+
| 10.0 | Added device queries for sampled image fetch capabilities. |
+----------+-------------------------------------------------------------+

Contributors
--------------------------------------------------------------------------------
Expand Down
18 changes: 18 additions & 0 deletions scripts/core/exp-bindless-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,24 @@ etors:
- name: INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP
value: "0x200F"
desc: "[$x_bool_t] returns true if the device supports exporting internal event resources"
- name: BINDLESS_SAMPLED_IMAGE_FETCH_1D_USM
value: "0x2010"
desc: "[$x_bool_t] returns true if the device is capable of fetching USM backed 1D sampled image data."
- name: BINDLESS_SAMPLED_IMAGE_FETCH_1D
value: "0x2011"
desc: "[$x_bool_t] returns true if the device is capable of fetching non-USM backed 1D sampled image data."
- name: BINDLESS_SAMPLED_IMAGE_FETCH_2D_USM
value: "0x2012"
desc: "[$x_bool_t] returns true if the device is capable of fetching USM backed 2D sampled image data."
- name: BINDLESS_SAMPLED_IMAGE_FETCH_2D
value: "0x2013"
desc: "[$x_bool_t] returns true if the device is capable of fetching non-USM backed 2D sampled image data."
- name: BINDLESS_SAMPLED_IMAGE_FETCH_3D_USM
value: "0x2014"
desc: "[$x_bool_t] returns true if the device is capable of fetching USM backed 3D sampled image data."
- name: BINDLESS_SAMPLED_IMAGE_FETCH_3D
value: "0x2015"
desc: "[$x_bool_t] returns true if the device is capable of fetching non-USM backed 3D sampled image data."
--- #--------------------------------------------------------------------------
type: enum
extend: true
Expand Down
24 changes: 24 additions & 0 deletions source/adapters/cuda/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,30 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
// CUDA does not support exporting semaphores or events.
return ReturnValue(false);
}
case UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_USM: {
// CUDA does support fetching 1D USM sampled image data.
return ReturnValue(true);
}
case UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D: {
// CUDA does not support fetching 1D non-USM sampled image data.
return ReturnValue(false);
}
case UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D_USM: {
// CUDA does support fetching 2D USM sampled image data.
return ReturnValue(true);
}
case UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D: {
// CUDA does support fetching 2D non-USM sampled image data.
return ReturnValue(true);
}
case UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D_USM: {
// CUDA does not support 3D USM sampled textures
return ReturnValue(false);
}
case UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D: {
// CUDA does support fetching 3D non-USM sampled image data.
return ReturnValue(true);
}
case UR_DEVICE_INFO_DEVICE_ID: {
int Value = 0;
UR_CHECK_ERROR(cuDeviceGetAttribute(
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 @@ -477,7 +477,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetInfo(
return UR_RESULT_ERROR_INVALID_NULL_POINTER;
}

if (UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP < propName) {
if (UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D < propName) {
return UR_RESULT_ERROR_INVALID_ENUMERATION;
}

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 @@ -796,7 +796,7 @@ ur_result_t UR_APICALL urDeviceGet(
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hDevice`
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
/// + `::UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP < propName`
/// + `::UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D < propName`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
/// + If `propName` is not supported by the adapter.
/// - ::UR_RESULT_ERROR_INVALID_SIZE
Expand Down
2 changes: 1 addition & 1 deletion source/ur_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ ur_result_t UR_APICALL urDeviceGet(
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hDevice`
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
/// + `::UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP < propName`
/// + `::UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D < propName`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
/// + If `propName` is not supported by the adapter.
/// - ::UR_RESULT_ERROR_INVALID_SIZE
Expand Down
18 changes: 18 additions & 0 deletions tools/urinfo/urinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,5 +366,23 @@ inline void printDeviceInfos(ur_device_handle_t hDevice,
std::cout << prefix;
printDeviceInfo<ur_bool_t>(
hDevice, UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP);
std::cout << prefix;
printDeviceInfo<ur_bool_t>(
hDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D_USM);
std::cout << prefix;
printDeviceInfo<ur_bool_t>(hDevice,
UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_1D);
std::cout << prefix;
printDeviceInfo<ur_bool_t>(
hDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D_USM);
std::cout << prefix;
printDeviceInfo<ur_bool_t>(hDevice,
UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_2D);
std::cout << prefix;
printDeviceInfo<ur_bool_t>(
hDevice, UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D_USM);
std::cout << prefix;
printDeviceInfo<ur_bool_t>(hDevice,
UR_DEVICE_INFO_BINDLESS_SAMPLED_IMAGE_FETCH_3D);
}
} // namespace urinfo

0 comments on commit aa442a3

Please sign in to comment.