Skip to content

Commit 51900ae

Browse files
aarongreigkbenzie
authored andcommitted
Clarify spec for QUEUE_INFO_SIZE and change testing for it accordingly.
Also correctly report lack of queue on device support in cuda and hip adapters.
1 parent 7a6622f commit 51900ae

File tree

10 files changed

+72
-19
lines changed

10 files changed

+72
-19
lines changed

include/ur_api.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5250,7 +5250,9 @@ typedef enum ur_queue_info_t {
52505250
///< The reference count returned should be considered immediately stale.
52515251
///< It is unsuitable for general use in applications. This feature is
52525252
///< provided for identifying memory leaks.
5253-
UR_QUEUE_INFO_SIZE = 5, ///< [uint32_t] The size of the queue
5253+
UR_QUEUE_INFO_SIZE = 5, ///< [uint32_t] The size of the queue on the device. Only a valid query
5254+
///< if the queue was created with the `ON_DEVICE` queue flag, otherwise
5255+
///< `::urQueueGetInfo` will return `::UR_RESULT_ERROR_INVALID_QUEUE`.
52545256
UR_QUEUE_INFO_EMPTY = 6, ///< [::ur_bool_t] return true if the queue was empty at the time of the
52555257
///< query
52565258
/// @cond
@@ -5265,7 +5267,8 @@ typedef uint32_t ur_queue_flags_t;
52655267
typedef enum ur_queue_flag_t {
52665268
UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE = UR_BIT(0), ///< Enable/disable out of order execution
52675269
UR_QUEUE_FLAG_PROFILING_ENABLE = UR_BIT(1), ///< Enable/disable profiling
5268-
UR_QUEUE_FLAG_ON_DEVICE = UR_BIT(2), ///< Is a device queue
5270+
UR_QUEUE_FLAG_ON_DEVICE = UR_BIT(2), ///< Is a device queue. If this is enabled `OUT_OF_ORDER_EXEC_MODE_ENABLE`
5271+
///< must also be enabled.
52695272
UR_QUEUE_FLAG_ON_DEVICE_DEFAULT = UR_BIT(3), ///< Is the default queue for a device
52705273
UR_QUEUE_FLAG_DISCARD_EVENTS = UR_BIT(4), ///< Events will be discarded
52715274
UR_QUEUE_FLAG_PRIORITY_LOW = UR_BIT(5), ///< Low priority queue
@@ -5310,7 +5313,7 @@ typedef enum ur_queue_flag_t {
53105313
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
53115314
/// + `propSize != 0 && pPropValue == NULL`
53125315
/// + `pPropValue == NULL && pPropSizeRet == NULL`
5313-
/// - ::UR_RESULT_ERROR_INVALID_QUEUE
5316+
/// - ::UR_RESULT_ERROR_INVALID_QUEUE - "If `hQueue` isn't a valid queue handle or if `propName` isn't supported by `hQueue`."
53145317
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
53155318
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
53165319
UR_APIEXPORT ur_result_t UR_APICALL

scripts/core/queue.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ etors:
3232
The reference count returned should be considered immediately stale.
3333
It is unsuitable for general use in applications. This feature is provided for identifying memory leaks.
3434
- name: SIZE
35-
desc: "[uint32_t] The size of the queue"
35+
desc: |
36+
[uint32_t] The size of the queue on the device. Only a valid query
37+
if the queue was created with the `ON_DEVICE` queue flag, otherwise
38+
`$xQueueGetInfo` will return `$X_RESULT_ERROR_INVALID_QUEUE`.
3639
- name: EMPTY
3740
desc: "[$x_bool_t] return true if the queue was empty at the time of the query"
3841
--- #--------------------------------------------------------------------------
@@ -49,7 +52,7 @@ etors:
4952
desc: "Enable/disable profiling"
5053
- name: ON_DEVICE
5154
value: "$X_BIT(2)"
52-
desc: "Is a device queue"
55+
desc: "Is a device queue. If this is enabled `OUT_OF_ORDER_EXEC_MODE_ENABLE` must also be enabled."
5356
- name: ON_DEVICE_DEFAULT
5457
value: "$X_BIT(3)"
5558
desc: "Is the default queue for a device"
@@ -108,6 +111,7 @@ returns:
108111
- "`propSize != 0 && pPropValue == NULL`"
109112
- "`pPropValue == NULL && pPropSizeRet == NULL`"
110113
- $X_RESULT_ERROR_INVALID_QUEUE
114+
- "If `hQueue` isn't a valid queue handle or if `propName` isn't supported by `hQueue`."
111115
- $X_RESULT_ERROR_OUT_OF_HOST_MEMORY
112116
- $X_RESULT_ERROR_OUT_OF_RESOURCES
113117
--- #--------------------------------------------------------------------------

source/adapters/cuda/device.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,10 +569,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
569569
ur_queue_flag_t(UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE |
570570
UR_QUEUE_FLAG_PROFILING_ENABLE));
571571
case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES: {
572-
// The mandated minimum capability:
573-
ur_queue_flags_t Capability = UR_QUEUE_FLAG_PROFILING_ENABLE |
574-
UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE;
575-
return ReturnValue(Capability);
572+
return ReturnValue(0);
576573
}
577574
case UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES: {
578575
// The mandated minimum capability:

source/adapters/hip/device.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
465465
return ReturnValue(Capability);
466466
}
467467
case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES: {
468-
// The mandated minimum capability:
469-
ur_queue_flags_t Capability = UR_QUEUE_FLAG_PROFILING_ENABLE |
470-
UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE;
471-
return ReturnValue(Capability);
468+
return ReturnValue(0);
472469
}
473470
case UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES:
474471
case UR_DEVICE_INFO_QUEUE_PROPERTIES: {

source/adapters/opencl/common.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ ur_result_t mapCLErrorToUR(cl_int Result) {
8787
return UR_RESULT_ERROR_DEVICE_NOT_AVAILABLE;
8888
case CL_INVALID_KERNEL_ARGS:
8989
return UR_RESULT_ERROR_INVALID_KERNEL_ARGS;
90+
case CL_INVALID_COMMAND_QUEUE:
91+
return UR_RESULT_ERROR_INVALID_QUEUE;
9092
default:
9193
return UR_RESULT_ERROR_UNKNOWN;
9294
}

source/loader/ur_libapi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4120,7 +4120,7 @@ ur_result_t UR_APICALL urKernelCreateWithNativeHandle(
41204120
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
41214121
/// + `propSize != 0 && pPropValue == NULL`
41224122
/// + `pPropValue == NULL && pPropSizeRet == NULL`
4123-
/// - ::UR_RESULT_ERROR_INVALID_QUEUE
4123+
/// - ::UR_RESULT_ERROR_INVALID_QUEUE - "If `hQueue` isn't a valid queue handle or if `propName` isn't supported by `hQueue`."
41244124
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
41254125
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
41264126
ur_result_t UR_APICALL urQueueGetInfo(

source/ur_api.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3496,7 +3496,7 @@ ur_result_t UR_APICALL urKernelCreateWithNativeHandle(
34963496
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
34973497
/// + `propSize != 0 && pPropValue == NULL`
34983498
/// + `pPropValue == NULL && pPropSizeRet == NULL`
3499-
/// - ::UR_RESULT_ERROR_INVALID_QUEUE
3499+
/// - ::UR_RESULT_ERROR_INVALID_QUEUE - "If `hQueue` isn't a valid queue handle or if `propName` isn't supported by `hQueue`."
35003500
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
35013501
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
35023502
ur_result_t UR_APICALL urQueueGetInfo(
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
urQueueGetInfoTestWithInfoParam.Success/AMD_HIP_BACKEND___{{.*}}___UR_QUEUE_INFO_DEVICE_DEFAULT
2-
urQueueGetInfoTestWithInfoParam.Success/AMD_HIP_BACKEND___{{.*}}___UR_QUEUE_INFO_SIZE
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
urQueueGetInfoTestWithInfoParam.Success/Intel_R__OpenCL___{{.*}}___UR_QUEUE_INFO_DEVICE_DEFAULT
2-
urQueueGetInfoTestWithInfoParam.Success/Intel_R__OpenCL___{{.*}}___UR_QUEUE_INFO_SIZE

test/conformance/queue/urQueueGetInfo.cpp

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ UUR_TEST_SUITE_P(urQueueGetInfoTestWithInfoParam,
2323
UR_QUEUE_INFO_DEVICE_DEFAULT,
2424
UR_QUEUE_INFO_FLAGS,
2525
UR_QUEUE_INFO_REFERENCE_COUNT,
26-
UR_QUEUE_INFO_SIZE, UR_QUEUE_INFO_EMPTY),
26+
UR_QUEUE_INFO_EMPTY),
2727
uur::deviceTestWithParamPrinter<ur_queue_info_t>);
2828

2929
TEST_P(urQueueGetInfoTestWithInfoParam, Success) {
@@ -70,6 +70,59 @@ TEST_P(urQueueGetInfoTestWithInfoParam, Success) {
7070
}
7171
}
7272

73+
struct urQueueGetInfoDeviceQueueTestWithInfoParam
74+
: public uur::urContextTestWithParam<ur_queue_info_t> {
75+
void SetUp() {
76+
urContextTestWithParam<ur_queue_info_t>::SetUp();
77+
ur_queue_flags_t deviceQueueCapabilities;
78+
ASSERT_SUCCESS(
79+
urDeviceGetInfo(device, UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES,
80+
sizeof(deviceQueueCapabilities),
81+
&deviceQueueCapabilities, nullptr));
82+
if (!deviceQueueCapabilities) {
83+
GTEST_SKIP() << "Queue on device is not supported.";
84+
}
85+
ASSERT_SUCCESS(
86+
urQueueCreate(context, device, &queueProperties, &queue));
87+
}
88+
89+
void TearDown() {
90+
if (queue) {
91+
ASSERT_SUCCESS(urQueueRelease(queue));
92+
}
93+
urContextTestWithParam<ur_queue_info_t>::TearDown();
94+
}
95+
96+
ur_queue_handle_t queue = nullptr;
97+
ur_queue_properties_t queueProperties = {
98+
UR_STRUCTURE_TYPE_QUEUE_PROPERTIES, nullptr,
99+
UR_QUEUE_FLAG_ON_DEVICE | UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE};
100+
};
101+
102+
UUR_TEST_SUITE_P(urQueueGetInfoDeviceQueueTestWithInfoParam,
103+
::testing::Values(UR_QUEUE_INFO_CONTEXT, UR_QUEUE_INFO_DEVICE,
104+
UR_QUEUE_INFO_DEVICE_DEFAULT,
105+
UR_QUEUE_INFO_FLAGS,
106+
UR_QUEUE_INFO_REFERENCE_COUNT,
107+
UR_QUEUE_INFO_SIZE, UR_QUEUE_INFO_EMPTY),
108+
uur::deviceTestWithParamPrinter<ur_queue_info_t>);
109+
110+
TEST_P(urQueueGetInfoDeviceQueueTestWithInfoParam, Success) {
111+
ur_queue_info_t info_type = getParam();
112+
size_t size = 0;
113+
ASSERT_SUCCESS(urQueueGetInfo(queue, info_type, 0, nullptr, &size));
114+
ASSERT_NE(size, 0);
115+
116+
if (const auto expected_size = queue_info_size_map.find(info_type);
117+
expected_size != queue_info_size_map.end()) {
118+
ASSERT_EQ(expected_size->second, size);
119+
}
120+
121+
std::vector<uint8_t> data(size);
122+
ASSERT_SUCCESS(
123+
urQueueGetInfo(queue, info_type, size, data.data(), nullptr));
124+
}
125+
73126
using urQueueGetInfoTest = uur::urQueueTest;
74127
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urQueueGetInfoTest);
75128

0 commit comments

Comments
 (0)