Skip to content

Commit 5882d68

Browse files
committed
Added DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS
THis is similar to the existing `DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS` device info, only it applies to programs rather than kernels. All of the adapters should be updated to report it correctly, and tests have been added.
1 parent c5bf8fd commit 5882d68

File tree

14 files changed

+127
-25
lines changed

14 files changed

+127
-25
lines changed

include/ur_api.h

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,28 +1632,30 @@ typedef enum ur_device_info_t {
16321632
///< available for this device.
16331633
UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS = 106, ///< [::ur_bool_t] support the ::urKernelSetSpecializationConstants entry
16341634
///< point
1635-
UR_DEVICE_INFO_MEMORY_BUS_WIDTH = 107, ///< [uint32_t][optional-query] return the width in bits of the memory bus
1635+
UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS = 107, ///< [::ur_bool_t] support the ::urProgramSetSpecializationConstants entry
1636+
///< point
1637+
UR_DEVICE_INFO_MEMORY_BUS_WIDTH = 108, ///< [uint32_t][optional-query] return the width in bits of the memory bus
16361638
///< interface of the device.
1637-
UR_DEVICE_INFO_MAX_WORK_GROUPS_3D = 108, ///< [size_t[3]] return max 3D work groups
1638-
UR_DEVICE_INFO_ASYNC_BARRIER = 109, ///< [::ur_bool_t] return true if Async Barrier is supported
1639-
UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT = 110, ///< [::ur_bool_t] return true if specifying memory channels is supported
1640-
UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED = 111, ///< [::ur_bool_t] Return true if the device supports enqueueing commands
1639+
UR_DEVICE_INFO_MAX_WORK_GROUPS_3D = 109, ///< [size_t[3]] return max 3D work groups
1640+
UR_DEVICE_INFO_ASYNC_BARRIER = 110, ///< [::ur_bool_t] return true if Async Barrier is supported
1641+
UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT = 111, ///< [::ur_bool_t] return true if specifying memory channels is supported
1642+
UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED = 112, ///< [::ur_bool_t] Return true if the device supports enqueueing commands
16411643
///< to read and write pipes from the host.
1642-
UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP = 112, ///< [uint32_t][optional-query] The maximum number of registers available
1644+
UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP = 113, ///< [uint32_t][optional-query] The maximum number of registers available
16431645
///< per block.
1644-
UR_DEVICE_INFO_IP_VERSION = 113, ///< [uint32_t][optional-query] The device IP version. The meaning of the
1646+
UR_DEVICE_INFO_IP_VERSION = 114, ///< [uint32_t][optional-query] The device IP version. The meaning of the
16451647
///< device IP version is implementation-defined, but newer devices should
16461648
///< have a higher version than older devices.
1647-
UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT = 114, ///< [::ur_bool_t] return true if the device supports virtual memory.
1648-
UR_DEVICE_INFO_ESIMD_SUPPORT = 115, ///< [::ur_bool_t] return true if the device supports ESIMD.
1649-
UR_DEVICE_INFO_COMPONENT_DEVICES = 116, ///< [::ur_device_handle_t[]][optional-query] The set of component devices
1649+
UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT = 115, ///< [::ur_bool_t] return true if the device supports virtual memory.
1650+
UR_DEVICE_INFO_ESIMD_SUPPORT = 116, ///< [::ur_bool_t] return true if the device supports ESIMD.
1651+
UR_DEVICE_INFO_COMPONENT_DEVICES = 117, ///< [::ur_device_handle_t[]][optional-query] The set of component devices
16501652
///< contained by this composite device.
1651-
UR_DEVICE_INFO_COMPOSITE_DEVICE = 117, ///< [::ur_device_handle_t][optional-query] The composite device containing
1653+
UR_DEVICE_INFO_COMPOSITE_DEVICE = 118, ///< [::ur_device_handle_t][optional-query] The composite device containing
16521654
///< this component device.
1653-
UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT = 118, ///< [::ur_bool_t] return true if the device supports the
1655+
UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT = 119, ///< [::ur_bool_t] return true if the device supports the
16541656
///< `EnqueueDeviceGlobalVariableWrite` and
16551657
///< `EnqueueDeviceGlobalVariableRead` entry points.
1656-
UR_DEVICE_INFO_USM_POOL_SUPPORT = 119, ///< [::ur_bool_t] return true if the device supports USM pooling. Pertains
1658+
UR_DEVICE_INFO_USM_POOL_SUPPORT = 120, ///< [::ur_bool_t] return true if the device supports USM pooling. Pertains
16571659
///< to the `USMPool` entry points and usage of the `pool` parameter of the
16581660
///< USM alloc entry points.
16591661
UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP = 0x1000, ///< [::ur_bool_t] Returns true if the device supports the use of
@@ -4726,6 +4728,10 @@ typedef struct ur_specialization_constant_info_t {
47264728
/// @brief Set an array of specialization constants on a Program.
47274729
///
47284730
/// @details
4731+
/// - This entry point is optional, the application should query for support
4732+
/// with device query
4733+
/// ::UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS passed to
4734+
/// ::urDeviceGetInfo.
47294735
/// - The application may call this function from simultaneous threads for
47304736
/// the same device.
47314737
/// - The implementation of this function should be thread-safe.
@@ -4745,6 +4751,8 @@ typedef struct ur_specialization_constant_info_t {
47454751
/// + `NULL == pSpecConstants`
47464752
/// - ::UR_RESULT_ERROR_INVALID_SIZE
47474753
/// + `count == 0`
4754+
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
4755+
/// + If ::UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS query is false
47484756
/// - ::UR_RESULT_ERROR_INVALID_VALUE
47494757
/// + A pSpecConstant entry contains a size that does not match that of the specialization constant in the module.
47504758
/// + A pSpecConstant entry contains a nullptr pValue.

include/ur_print.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2600,6 +2600,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) {
26002600
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
26012601
os << "UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS";
26022602
break;
2603+
case UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS:
2604+
os << "UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS";
2605+
break;
26032606
case UR_DEVICE_INFO_MEMORY_BUS_WIDTH:
26042607
os << "UR_DEVICE_INFO_MEMORY_BUS_WIDTH";
26052608
break;
@@ -3998,6 +4001,18 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, ur_device_info
39984001

39994002
os << ")";
40004003
} break;
4004+
case UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS: {
4005+
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
4006+
if (sizeof(ur_bool_t) > size) {
4007+
os << "invalid size (is: " << size << ", expected: >=" << sizeof(ur_bool_t) << ")";
4008+
return UR_RESULT_ERROR_INVALID_SIZE;
4009+
}
4010+
os << (const void *)(tptr) << " (";
4011+
4012+
os << *tptr;
4013+
4014+
os << ")";
4015+
} break;
40014016
case UR_DEVICE_INFO_MEMORY_BUS_WIDTH: {
40024017
const uint32_t *tptr = (const uint32_t *)ptr;
40034018
if (sizeof(uint32_t) > size) {

scripts/core/device.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,8 @@ etors:
417417
available for this device.
418418
- name: KERNEL_SET_SPECIALIZATION_CONSTANTS
419419
desc: "[$x_bool_t] support the $xKernelSetSpecializationConstants entry point"
420+
- name: PROGRAM_SET_SPECIALIZATION_CONSTANTS
421+
desc: "[$x_bool_t] support the $xProgramSetSpecializationConstants entry point"
420422
- name: MEMORY_BUS_WIDTH
421423
desc: "[uint32_t][optional-query] return the width in bits of the memory bus interface of the device."
422424
- name: MAX_WORK_GROUPS_3D

scripts/core/program.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ desc: "Set an array of specialization constants on a Program."
528528
class: $xProgram
529529
name: SetSpecializationConstants
530530
details:
531+
- "This entry point is optional, the application should query for support with device query $X_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS passed to $xDeviceGetInfo."
531532
- "The application may call this function from simultaneous threads for the same device."
532533
- "The implementation of this function should be thread-safe."
533534
- "`hProgram` must have been created with the $xProgramCreateWithIL entry point."
@@ -546,6 +547,8 @@ params:
546547
returns:
547548
- $X_RESULT_ERROR_INVALID_SIZE:
548549
- "`count == 0`"
550+
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
551+
- "If $X_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS query is false"
549552
- $X_RESULT_ERROR_INVALID_VALUE:
550553
- "A pSpecConstant entry contains a size that does not match that of the specialization constant in the module."
551554
- "A pSpecConstant entry contains a nullptr pValue."

source/adapters/cuda/device.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
10651065
return ReturnValue(AddressBuffer,
10661066
strnlen(AddressBuffer, AddressBufferSize - 1) + 1);
10671067
}
1068+
case UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS:
10681069
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
10691070
return ReturnValue(static_cast<ur_bool_t>(false));
10701071
// TODO: Investigate if this information is available on CUDA.

source/adapters/hip/device.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
789789
return ReturnValue(ur_bool_t{false});
790790
}
791791

792+
case UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS: {
793+
return ReturnValue(ur_bool_t{false});
794+
}
795+
792796
case UR_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES: {
793797
ur_memory_order_capability_flags_t Capabilities =
794798
UR_MEMORY_ORDER_CAPABILITY_FLAG_RELAXED |

source/adapters/level_zero/device.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,8 @@ ur_result_t urDeviceGetInfo(
11541154
// L0 does not support sampling 1D USM sampled image data.
11551155
return ReturnValue(false);
11561156
}
1157+
case UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS:
1158+
return ReturnValue(true);
11571159
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
11581160
return ReturnValue(false);
11591161
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:

source/adapters/native_cpu/device.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
428428

429429
case UR_DEVICE_INFO_LOW_POWER_EVENTS_EXP:
430430
return ReturnValue(false);
431+
432+
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
433+
case UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS:
434+
return ReturnValue(false);
435+
431436
default:
432437
DIE_NO_IMPLEMENTATION;
433438
}

source/adapters/opencl/device.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//===-----------------------------------------------------------------===//
88

99
#include "device.hpp"
10+
#include "adapter.hpp"
1011
#include "common.hpp"
1112
#include "platform.hpp"
1213

@@ -1125,6 +1126,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
11251126
return ReturnValue(UUID);
11261127
}
11271128

1129+
case UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS: {
1130+
return ReturnValue(
1131+
ur::cl::getAdapter()->clSetProgramSpecializationConstant != nullptr);
1132+
}
1133+
11281134
// We can't query to check if these are supported, they will need to be
11291135
// manually updated if support is ever implemented.
11301136
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:

source/loader/ur_libapi.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3531,6 +3531,10 @@ ur_result_t UR_APICALL urProgramGetBuildInfo(
35313531
/// @brief Set an array of specialization constants on a Program.
35323532
///
35333533
/// @details
3534+
/// - This entry point is optional, the application should query for support
3535+
/// with device query
3536+
/// ::UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS passed to
3537+
/// ::urDeviceGetInfo.
35343538
/// - The application may call this function from simultaneous threads for
35353539
/// the same device.
35363540
/// - The implementation of this function should be thread-safe.
@@ -3550,6 +3554,8 @@ ur_result_t UR_APICALL urProgramGetBuildInfo(
35503554
/// + `NULL == pSpecConstants`
35513555
/// - ::UR_RESULT_ERROR_INVALID_SIZE
35523556
/// + `count == 0`
3557+
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
3558+
/// + If ::UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS query is false
35533559
/// - ::UR_RESULT_ERROR_INVALID_VALUE
35543560
/// + A pSpecConstant entry contains a size that does not match that of the specialization constant in the module.
35553561
/// + A pSpecConstant entry contains a nullptr pValue.

0 commit comments

Comments
 (0)