Skip to content

Commit 78d0203

Browse files
authored
Merge pull request #1128 from aarongreig/aaron/clarifyQueueInfoSize
Clarify spec for QUEUE_INFO_SIZE and change testing for it accordingly.
2 parents ba369ea + 41763be commit 78d0203

File tree

11 files changed

+85
-23
lines changed

11 files changed

+85
-23
lines changed

include/ur_api.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5302,7 +5302,9 @@ typedef enum ur_queue_info_t {
53025302
///< The reference count returned should be considered immediately stale.
53035303
///< It is unsuitable for general use in applications. This feature is
53045304
///< provided for identifying memory leaks.
5305-
UR_QUEUE_INFO_SIZE = 5, ///< [uint32_t] The size of the queue
5305+
UR_QUEUE_INFO_SIZE = 5, ///< [uint32_t] The size of the queue on the device. Only a valid query
5306+
///< if the queue was created with the `ON_DEVICE` queue flag, otherwise
5307+
///< `::urQueueGetInfo` will return `::UR_RESULT_ERROR_INVALID_QUEUE`.
53065308
UR_QUEUE_INFO_EMPTY = 6, ///< [::ur_bool_t] return true if the queue was empty at the time of the
53075309
///< query
53085310
/// @cond
@@ -5317,7 +5319,8 @@ typedef uint32_t ur_queue_flags_t;
53175319
typedef enum ur_queue_flag_t {
53185320
UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE = UR_BIT(0), ///< Enable/disable out of order execution
53195321
UR_QUEUE_FLAG_PROFILING_ENABLE = UR_BIT(1), ///< Enable/disable profiling
5320-
UR_QUEUE_FLAG_ON_DEVICE = UR_BIT(2), ///< Is a device queue
5322+
UR_QUEUE_FLAG_ON_DEVICE = UR_BIT(2), ///< Is a device queue. If this is enabled `OUT_OF_ORDER_EXEC_MODE_ENABLE`
5323+
///< must also be enabled.
53215324
UR_QUEUE_FLAG_ON_DEVICE_DEFAULT = UR_BIT(3), ///< Is the default queue for a device
53225325
UR_QUEUE_FLAG_DISCARD_EVENTS = UR_BIT(4), ///< Events will be discarded
53235326
UR_QUEUE_FLAG_PRIORITY_LOW = UR_BIT(5), ///< Low priority queue
@@ -5362,7 +5365,7 @@ typedef enum ur_queue_flag_t {
53625365
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
53635366
/// + `propSize != 0 && pPropValue == NULL`
53645367
/// + `pPropValue == NULL && pPropSizeRet == NULL`
5365-
/// - ::UR_RESULT_ERROR_INVALID_QUEUE
5368+
/// - ::UR_RESULT_ERROR_INVALID_QUEUE - "If `hQueue` isn't a valid queue handle or if `propName` isn't supported by `hQueue`."
53665369
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
53675370
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
53685371
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
@@ -478,10 +478,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
478478
return ReturnValue(Capability);
479479
}
480480
case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES: {
481-
// The mandated minimum capability:
482-
ur_queue_flags_t Capability = UR_QUEUE_FLAG_PROFILING_ENABLE |
483-
UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE;
484-
return ReturnValue(Capability);
481+
return ReturnValue(0);
485482
}
486483
case UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES:
487484
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
@@ -4189,7 +4189,7 @@ ur_result_t UR_APICALL urKernelGetSuggestedLocalWorkSize(
41894189
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
41904190
/// + `propSize != 0 && pPropValue == NULL`
41914191
/// + `pPropValue == NULL && pPropSizeRet == NULL`
4192-
/// - ::UR_RESULT_ERROR_INVALID_QUEUE
4192+
/// - ::UR_RESULT_ERROR_INVALID_QUEUE - "If `hQueue` isn't a valid queue handle or if `propName` isn't supported by `hQueue`."
41934193
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
41944194
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
41954195
ur_result_t UR_APICALL urQueueGetInfo(

source/ur_api.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3556,7 +3556,7 @@ ur_result_t UR_APICALL urKernelGetSuggestedLocalWorkSize(
35563556
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
35573557
/// + `propSize != 0 && pPropValue == NULL`
35583558
/// + `pPropValue == NULL && pPropSizeRet == NULL`
3559-
/// - ::UR_RESULT_ERROR_INVALID_QUEUE
3559+
/// - ::UR_RESULT_ERROR_INVALID_QUEUE - "If `hQueue` isn't a valid queue handle or if `propName` isn't supported by `hQueue`."
35603560
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
35613561
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
35623562
ur_result_t UR_APICALL urQueueGetInfo(
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
urQueueGetInfoTestWithInfoParam.Success/AMD_HIP_BACKEND___{{.*}}___UR_QUEUE_INFO_DEVICE_DEFAULT
2-
urQueueGetInfoTestWithInfoParam.Success/AMD_HIP_BACKEND___{{.*}}___UR_QUEUE_INFO_SIZE

test/conformance/queue/queue_adapter_native_cpu.match

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@ urQueueFinishTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU_
2626
urQueueFlushTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU_
2727
urQueueGetInfoTestWithInfoParam.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_INFO_CONTEXT
2828
urQueueGetInfoTestWithInfoParam.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_INFO_DEVICE
29-
urQueueGetInfoTestWithInfoParam.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_INFO_DEVICE_DEFAULT
3029
urQueueGetInfoTestWithInfoParam.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_INFO_FLAGS
3130
urQueueGetInfoTestWithInfoParam.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_INFO_REFERENCE_COUNT
32-
urQueueGetInfoTestWithInfoParam.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_INFO_SIZE
3331
urQueueGetInfoTestWithInfoParam.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_INFO_EMPTY
32+
urQueueGetInfoDeviceQueueTestWithInfoParam.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_INFO_CONTEXT
33+
urQueueGetInfoDeviceQueueTestWithInfoParam.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_INFO_DEVICE
34+
urQueueGetInfoDeviceQueueTestWithInfoParam.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_INFO_DEVICE_DEFAULT
35+
urQueueGetInfoDeviceQueueTestWithInfoParam.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_INFO_FLAGS
36+
urQueueGetInfoDeviceQueueTestWithInfoParam.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_INFO_REFERENCE_COUNT
37+
urQueueGetInfoDeviceQueueTestWithInfoParam.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_INFO_SIZE
38+
urQueueGetInfoDeviceQueueTestWithInfoParam.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_QUEUE_INFO_EMPTY
3439
urQueueGetInfoTest.InvalidSizeSmall/SYCL_NATIVE_CPU___SYCL_Native_CPU_
3540
urQueueRetainTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU_
3641
urQueueReleaseTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU_
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: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ using urQueueGetInfoTestWithInfoParam =
2020

2121
UUR_TEST_SUITE_P(urQueueGetInfoTestWithInfoParam,
2222
::testing::Values(UR_QUEUE_INFO_CONTEXT, UR_QUEUE_INFO_DEVICE,
23-
UR_QUEUE_INFO_DEVICE_DEFAULT,
2423
UR_QUEUE_INFO_FLAGS,
2524
UR_QUEUE_INFO_REFERENCE_COUNT,
26-
UR_QUEUE_INFO_SIZE, UR_QUEUE_INFO_EMPTY),
25+
UR_QUEUE_INFO_EMPTY),
2726
uur::deviceTestWithParamPrinter<ur_queue_info_t>);
2827

2928
TEST_P(urQueueGetInfoTestWithInfoParam, Success) {
@@ -70,6 +69,65 @@ TEST_P(urQueueGetInfoTestWithInfoParam, Success) {
7069
}
7170
}
7271

72+
struct urQueueGetInfoDeviceQueueTestWithInfoParam
73+
: public uur::urContextTestWithParam<ur_queue_info_t> {
74+
void SetUp() {
75+
urContextTestWithParam<ur_queue_info_t>::SetUp();
76+
ur_queue_flags_t deviceQueueCapabilities;
77+
ASSERT_SUCCESS(
78+
urDeviceGetInfo(device, UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES,
79+
sizeof(deviceQueueCapabilities),
80+
&deviceQueueCapabilities, nullptr));
81+
if (!deviceQueueCapabilities) {
82+
GTEST_SKIP() << "Queue on device is not supported.";
83+
}
84+
ASSERT_SUCCESS(
85+
urQueueCreate(context, device, &queueProperties, &queue));
86+
}
87+
88+
void TearDown() {
89+
if (queue) {
90+
ASSERT_SUCCESS(urQueueRelease(queue));
91+
}
92+
urContextTestWithParam<ur_queue_info_t>::TearDown();
93+
}
94+
95+
ur_queue_handle_t queue = nullptr;
96+
ur_queue_properties_t queueProperties = {
97+
UR_STRUCTURE_TYPE_QUEUE_PROPERTIES, nullptr,
98+
UR_QUEUE_FLAG_ON_DEVICE | UR_QUEUE_FLAG_ON_DEVICE_DEFAULT |
99+
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+
auto result = urQueueGetInfo(queue, info_type, 0, nullptr, &size);
114+
115+
if (result == UR_RESULT_SUCCESS) {
116+
ASSERT_NE(size, 0);
117+
118+
if (const auto expected_size = queue_info_size_map.find(info_type);
119+
expected_size != queue_info_size_map.end()) {
120+
ASSERT_EQ(expected_size->second, size);
121+
}
122+
123+
std::vector<uint8_t> data(size);
124+
ASSERT_SUCCESS(
125+
urQueueGetInfo(queue, info_type, size, data.data(), nullptr));
126+
} else {
127+
ASSERT_EQ_RESULT(result, UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION);
128+
}
129+
}
130+
73131
using urQueueGetInfoTest = uur::urQueueTest;
74132
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urQueueGetInfoTest);
75133

0 commit comments

Comments
 (0)