Skip to content

Commit 5991b3f

Browse files
committed
Merge branch 'main' into num_compute_units
2 parents 105d4e8 + dbb5613 commit 5991b3f

File tree

15 files changed

+109
-24
lines changed

15 files changed

+109
-24
lines changed

include/ur_api.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,8 +2198,9 @@ typedef enum ur_device_info_t {
21982198
/// to the `USMPool` entry points and usage of the `pool` parameter of the
21992199
/// USM alloc entry points.
22002200
UR_DEVICE_INFO_USM_POOL_SUPPORT = 119,
2201-
/// [uint32_t] the number of compute units for specific backend.
2202-
UR_DEVICE_INFO_NUM_COMPUTE_UNITS = 120,
2201+
/// [::ur_bool_t] support the ::urProgramSetSpecializationConstants entry
2202+
/// point
2203+
UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS = 120,
22032204
/// [::ur_bool_t] Returns true if the device supports the use of
22042205
/// command-buffers.
22052206
UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP = 0x1000,
@@ -5741,6 +5742,10 @@ typedef struct ur_specialization_constant_info_t {
57415742
/// @brief Set an array of specialization constants on a Program.
57425743
///
57435744
/// @details
5745+
/// - This entry point is optional, the application should query for support
5746+
/// with device query
5747+
/// ::UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS passed to
5748+
/// ::urDeviceGetInfo.
57445749
/// - The application may call this function from simultaneous threads for
57455750
/// the same device.
57465751
/// - The implementation of this function should be thread-safe.
@@ -5760,6 +5765,9 @@ typedef struct ur_specialization_constant_info_t {
57605765
/// + `NULL == pSpecConstants`
57615766
/// - ::UR_RESULT_ERROR_INVALID_SIZE
57625767
/// + `count == 0`
5768+
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
5769+
/// + If ::UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS query is
5770+
/// false
57635771
/// - ::UR_RESULT_ERROR_INVALID_VALUE
57645772
/// + A pSpecConstant entry contains a size that does not match that of
57655773
/// the specialization constant in the module.

include/ur_print.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2917,8 +2917,8 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) {
29172917
case UR_DEVICE_INFO_USM_POOL_SUPPORT:
29182918
os << "UR_DEVICE_INFO_USM_POOL_SUPPORT";
29192919
break;
2920-
case UR_DEVICE_INFO_NUM_COMPUTE_UNITS:
2921-
os << "UR_DEVICE_INFO_NUM_COMPUTE_UNITS";
2920+
case UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS:
2921+
os << "UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS";
29222922
break;
29232923
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP:
29242924
os << "UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP";
@@ -4551,11 +4551,11 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr,
45514551

45524552
os << ")";
45534553
} break;
4554-
case UR_DEVICE_INFO_NUM_COMPUTE_UNITS: {
4555-
const uint32_t *tptr = (const uint32_t *)ptr;
4556-
if (sizeof(uint32_t) > size) {
4557-
os << "invalid size (is: " << size << ", expected: >=" << sizeof(uint32_t)
4558-
<< ")";
4554+
case UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS: {
4555+
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
4556+
if (sizeof(ur_bool_t) > size) {
4557+
os << "invalid size (is: " << size
4558+
<< ", expected: >=" << sizeof(ur_bool_t) << ")";
45594559
return UR_RESULT_ERROR_INVALID_SIZE;
45604560
}
45614561
os << (const void *)(tptr) << " (";

scripts/core/device.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,8 @@ etors:
445445
desc: "[$x_bool_t] return true if the device supports USM pooling. Pertains to the `USMPool` entry points and usage of the `pool` parameter of the USM alloc entry points."
446446
- name: NUM_COMPUTE_UNITS
447447
desc: "[uint32_t] the number of compute units for specific backend."
448+
- name: PROGRAM_SET_SPECIALIZATION_CONSTANTS
449+
desc: "[$x_bool_t] support the $xProgramSetSpecializationConstants entry point"
448450
--- #--------------------------------------------------------------------------
449451
type: function
450452
desc: "Retrieves various information about device"

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
@@ -1066,6 +1066,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
10661066
return ReturnValue(AddressBuffer,
10671067
strnlen(AddressBuffer, AddressBufferSize - 1) + 1);
10681068
}
1069+
case UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS:
10691070
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
10701071
return ReturnValue(static_cast<ur_bool_t>(false));
10711072
// 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
@@ -790,6 +790,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
790790
return ReturnValue(ur_bool_t{false});
791791
}
792792

793+
case UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS: {
794+
return ReturnValue(ur_bool_t{false});
795+
}
796+
793797
case UR_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES: {
794798
ur_memory_order_capability_flags_t Capabilities =
795799
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
@@ -1162,6 +1162,8 @@ ur_result_t urDeviceGetInfo(
11621162
// L0 does not support sampling 1D USM sampled image data.
11631163
return ReturnValue(false);
11641164
}
1165+
case UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS:
1166+
return ReturnValue(true);
11651167
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
11661168
return ReturnValue(false);
11671169
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
@@ -429,6 +429,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
429429

430430
case UR_DEVICE_INFO_LOW_POWER_EVENTS_EXP:
431431
return ReturnValue(false);
432+
433+
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
434+
case UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS:
435+
return ReturnValue(false);
436+
432437
default:
433438
DIE_NO_IMPLEMENTATION;
434439
}

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

@@ -1157,6 +1158,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
11571158
return ReturnValue(UUID);
11581159
}
11591160

1161+
case UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS: {
1162+
return ReturnValue(
1163+
ur::cl::getAdapter()->clSetProgramSpecializationConstant != nullptr);
1164+
}
1165+
11601166
// We can't query to check if these are supported, they will need to be
11611167
// manually updated if support is ever implemented.
11621168
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:

source/loader/layers/sanitizer/asan/asan_buffer.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ struct MemBuffer {
2929

3030
// Sub-buffer constructor
3131
MemBuffer(std::shared_ptr<MemBuffer> Parent, size_t Origin, size_t Size)
32-
: Context(Parent->Context), Size(Size), SubBuffer{{Parent, Origin}} {}
32+
: Context(Parent->Context), Size(Size),
33+
SubBuffer{{std::move(Parent), Origin}} {}
3334

3435
ur_result_t getHandle(ur_device_handle_t Device, char *&Handle);
3536

0 commit comments

Comments
 (0)