Skip to content

Commit

Permalink
Clarify spec for QUEUE_INFO_SIZE and change testing for it accordingly.
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongreig committed Nov 27, 2023
1 parent 41228d3 commit aa7c7f5
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 7 deletions.
4 changes: 3 additions & 1 deletion include/ur.py
Original file line number Diff line number Diff line change
Expand Up @@ -1914,7 +1914,9 @@ class ur_queue_info_v(IntEnum):
## The reference count returned should be considered immediately stale.
## It is unsuitable for general use in applications. This feature is
## provided for identifying memory leaks.
SIZE = 5 ## [uint32_t] The size of the queue
SIZE = 5 ## [uint32_t] The size of the queue on the device. Only a valid query
## if the queue was created with the `ON_DEVICE` queue flag, otherwise
## `::urQueueGetInfo` will return `::UR_RESULT_ERROR_INVALID_QUEUE`.
EMPTY = 6 ## [::ur_bool_t] return true if the queue was empty at the time of the
## query

Expand Down
6 changes: 4 additions & 2 deletions include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -5012,7 +5012,9 @@ typedef enum ur_queue_info_t {
///< The reference count returned should be considered immediately stale.
///< It is unsuitable for general use in applications. This feature is
///< provided for identifying memory leaks.
UR_QUEUE_INFO_SIZE = 5, ///< [uint32_t] The size of the queue
UR_QUEUE_INFO_SIZE = 5, ///< [uint32_t] The size of the queue on the device. Only a valid query
///< if the queue was created with the `ON_DEVICE` queue flag, otherwise
///< `::urQueueGetInfo` will return `::UR_RESULT_ERROR_INVALID_QUEUE`.
UR_QUEUE_INFO_EMPTY = 6, ///< [::ur_bool_t] return true if the queue was empty at the time of the
///< query
/// @cond
Expand Down Expand Up @@ -5072,7 +5074,7 @@ typedef enum ur_queue_flag_t {
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `propSize != 0 && pPropValue == NULL`
/// + `pPropValue == NULL && pPropSizeRet == NULL`
/// - ::UR_RESULT_ERROR_INVALID_QUEUE
/// - ::UR_RESULT_ERROR_INVALID_QUEUE - "If `hQueue` isn't a valid queue handle or if `propName` isn't supported by `hQueue`."
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
UR_APIEXPORT ur_result_t UR_APICALL
Expand Down
6 changes: 5 additions & 1 deletion scripts/core/queue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ etors:
The reference count returned should be considered immediately stale.
It is unsuitable for general use in applications. This feature is provided for identifying memory leaks.
- name: SIZE
desc: "[uint32_t] The size of the queue"
desc: |
[uint32_t] The size of the queue on the device. Only a valid query
if the queue was created with the `ON_DEVICE` queue flag, otherwise
`$xQueueGetInfo` will return `$X_RESULT_ERROR_INVALID_QUEUE`.
- name: EMPTY
desc: "[$x_bool_t] return true if the queue was empty at the time of the query"
--- #--------------------------------------------------------------------------
Expand Down Expand Up @@ -108,6 +111,7 @@ returns:
- "`propSize != 0 && pPropValue == NULL`"
- "`pPropValue == NULL && pPropSizeRet == NULL`"
- $X_RESULT_ERROR_INVALID_QUEUE
- "If `hQueue` isn't a valid queue handle or if `propName` isn't supported by `hQueue`."
- $X_RESULT_ERROR_OUT_OF_HOST_MEMORY
- $X_RESULT_ERROR_OUT_OF_RESOURCES
--- #--------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions source/adapters/opencl/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ ur_result_t mapCLErrorToUR(cl_int Result) {
return UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP;
case CL_INVALID_SYNC_POINT_WAIT_LIST_KHR:
return UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_WAIT_LIST_EXP;
case CL_INVALID_COMMAND_QUEUE:
return UR_RESULT_ERROR_INVALID_QUEUE;
default:
return UR_RESULT_ERROR_UNKNOWN;
}
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 @@ -3963,7 +3963,7 @@ ur_result_t UR_APICALL urKernelCreateWithNativeHandle(
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `propSize != 0 && pPropValue == NULL`
/// + `pPropValue == NULL && pPropSizeRet == NULL`
/// - ::UR_RESULT_ERROR_INVALID_QUEUE
/// - ::UR_RESULT_ERROR_INVALID_QUEUE - "If `hQueue` isn't a valid queue handle or if `propName` isn't supported by `hQueue`."
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
ur_result_t UR_APICALL urQueueGetInfo(
Expand Down
2 changes: 1 addition & 1 deletion source/ur_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3343,7 +3343,7 @@ ur_result_t UR_APICALL urKernelCreateWithNativeHandle(
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `propSize != 0 && pPropValue == NULL`
/// + `pPropValue == NULL && pPropSizeRet == NULL`
/// - ::UR_RESULT_ERROR_INVALID_QUEUE
/// - ::UR_RESULT_ERROR_INVALID_QUEUE - "If `hQueue` isn't a valid queue handle or if `propName` isn't supported by `hQueue`."
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
ur_result_t UR_APICALL urQueueGetInfo(
Expand Down
54 changes: 53 additions & 1 deletion test/conformance/queue/urQueueGetInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ UUR_TEST_SUITE_P(urQueueGetInfoTestWithInfoParam,
UR_QUEUE_INFO_DEVICE_DEFAULT,
UR_QUEUE_INFO_FLAGS,
UR_QUEUE_INFO_REFERENCE_COUNT,
UR_QUEUE_INFO_SIZE, UR_QUEUE_INFO_EMPTY),
UR_QUEUE_INFO_EMPTY),
uur::deviceTestWithParamPrinter<ur_queue_info_t>);

TEST_P(urQueueGetInfoTestWithInfoParam, Success) {
Expand All @@ -42,6 +42,58 @@ TEST_P(urQueueGetInfoTestWithInfoParam, Success) {
urQueueGetInfo(queue, info_type, size, data.data(), nullptr));
}

struct urQueueGetInfoDeviceQueueTestWithInfoParam
: public uur::urContextTestWithParam<ur_queue_info_t> {
void SetUp() {
urContextTestWithParam<ur_queue_info_t>::SetUp();
ur_queue_flags_t deviceQueueCapabilities;
ASSERT_SUCCESS(
urDeviceGetInfo(device, UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES,
sizeof(deviceQueueCapabilities),
&deviceQueueCapabilities, nullptr));
if (!deviceQueueCapabilities) {
GTEST_SKIP() << "Queue on device is not supported.";
}
ASSERT_SUCCESS(
urQueueCreate(context, device, &queueProperties, &queue));
}

void TearDown() {
if (queue) {
ASSERT_SUCCESS(urQueueRelease(queue));
}
urContextTestWithParam<ur_queue_info_t>::TearDown();
}

ur_queue_handle_t queue = nullptr;
ur_queue_properties_t queueProperties = {UR_STRUCTURE_TYPE_QUEUE_PROPERTIES,
nullptr, UR_QUEUE_FLAG_ON_DEVICE};
};

UUR_TEST_SUITE_P(urQueueGetInfoDeviceQueueTestWithInfoParam,
::testing::Values(UR_QUEUE_INFO_CONTEXT, UR_QUEUE_INFO_DEVICE,
UR_QUEUE_INFO_DEVICE_DEFAULT,
UR_QUEUE_INFO_FLAGS,
UR_QUEUE_INFO_REFERENCE_COUNT,
UR_QUEUE_INFO_SIZE, UR_QUEUE_INFO_EMPTY),
uur::deviceTestWithParamPrinter<ur_queue_info_t>);

TEST_P(urQueueGetInfoDeviceQueueTestWithInfoParam, Success) {
ur_queue_info_t info_type = getParam();
size_t size = 0;
ASSERT_SUCCESS(urQueueGetInfo(queue, info_type, 0, nullptr, &size));
ASSERT_NE(size, 0);

if (const auto expected_size = queue_info_size_map.find(info_type);
expected_size != queue_info_size_map.end()) {
ASSERT_EQ(expected_size->second, size);
}

std::vector<uint8_t> data(size);
ASSERT_SUCCESS(
urQueueGetInfo(queue, info_type, size, data.data(), nullptr));
}

using urQueueGetInfoTest = uur::urQueueTest;
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urQueueGetInfoTest);

Expand Down

0 comments on commit aa7c7f5

Please sign in to comment.