diff --git a/include/ur_api.h b/include/ur_api.h index 0403e2b306..cf53a1a838 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -5103,14 +5103,17 @@ typedef enum ur_queue_info_t { UR_QUEUE_INFO_CONTEXT = 0, ///< [::ur_queue_handle_t] context associated with this queue. UR_QUEUE_INFO_DEVICE = 1, ///< [::ur_device_handle_t] device associated with this queue. UR_QUEUE_INFO_DEVICE_DEFAULT = 2, ///< [::ur_queue_handle_t] the current default queue of the underlying - ///< device. + ///< device. Only returns a value if a queue associated with the + ///< underlying device has been created with `::UR_ON_DEVICE_DEFAULT`. UR_QUEUE_INFO_FLAGS = 3, ///< [::ur_queue_flags_t] the properties associated with ///< ::ur_queue_properties_t::flags. UR_QUEUE_INFO_REFERENCE_COUNT = 4, ///< [uint32_t] Reference count of the queue object. ///< 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 @@ -5125,7 +5128,8 @@ typedef uint32_t ur_queue_flags_t; typedef enum ur_queue_flag_t { UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE = UR_BIT(0), ///< Enable/disable out of order execution UR_QUEUE_FLAG_PROFILING_ENABLE = UR_BIT(1), ///< Enable/disable profiling - UR_QUEUE_FLAG_ON_DEVICE = UR_BIT(2), ///< Is a device queue + UR_QUEUE_FLAG_ON_DEVICE = UR_BIT(2), ///< Is a device queue. If this is enabled + ///< `::UR_OUT_OF_ORDER_EXEC_MODE_ENABLE` must also be enabled. UR_QUEUE_FLAG_ON_DEVICE_DEFAULT = UR_BIT(3), ///< Is the default queue for a device UR_QUEUE_FLAG_DISCARD_EVENTS = UR_BIT(4), ///< Events will be discarded UR_QUEUE_FLAG_PRIORITY_LOW = UR_BIT(5), ///< Low priority queue @@ -5170,7 +5174,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 diff --git a/scripts/core/queue.yml b/scripts/core/queue.yml index 15934c0e2f..a0d33785ad 100644 --- a/scripts/core/queue.yml +++ b/scripts/core/queue.yml @@ -23,16 +23,23 @@ etors: - name: DEVICE desc: "[$x_device_handle_t] device associated with this queue." - name: DEVICE_DEFAULT - desc: "[$x_queue_handle_t] the current default queue of the underlying device." + desc: | + [$x_queue_handle_t] the current default queue of the underlying + device. Only returns a value if a queue associated with the + underlying device has been created with `$X_ON_DEVICE_DEFAULT`. - name: FLAGS desc: "[$x_queue_flags_t] the properties associated with $x_queue_properties_t::flags." - name: REFERENCE_COUNT desc: | [uint32_t] Reference count of the queue object. 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. + 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" --- #-------------------------------------------------------------------------- @@ -49,7 +56,7 @@ etors: desc: "Enable/disable profiling" - name: ON_DEVICE value: "$X_BIT(2)" - desc: "Is a device queue" + desc: "Is a device queue. If this is enabled `$X_OUT_OF_ORDER_EXEC_MODE_ENABLE` must also be enabled." - name: ON_DEVICE_DEFAULT value: "$X_BIT(3)" desc: "Is the default queue for a device" @@ -108,6 +115,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 --- #-------------------------------------------------------------------------- diff --git a/source/adapters/cuda/device.cpp b/source/adapters/cuda/device.cpp index 0723cfe4e7..23429808ba 100644 --- a/source/adapters/cuda/device.cpp +++ b/source/adapters/cuda/device.cpp @@ -554,10 +554,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, ur_queue_flag_t(UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE | UR_QUEUE_FLAG_PROFILING_ENABLE)); case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES: { - // The mandated minimum capability: - ur_queue_flags_t Capability = UR_QUEUE_FLAG_PROFILING_ENABLE | - UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE; - return ReturnValue(Capability); + return ReturnValue(0); } case UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES: { // The mandated minimum capability: diff --git a/source/adapters/hip/device.cpp b/source/adapters/hip/device.cpp index e40470f9aa..02ee4a38e2 100644 --- a/source/adapters/hip/device.cpp +++ b/source/adapters/hip/device.cpp @@ -465,10 +465,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, return ReturnValue(Capability); } case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES: { - // The mandated minimum capability: - ur_queue_flags_t Capability = UR_QUEUE_FLAG_PROFILING_ENABLE | - UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE; - return ReturnValue(Capability); + return ReturnValue(0); } case UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES: case UR_DEVICE_INFO_QUEUE_PROPERTIES: { diff --git a/source/adapters/opencl/common.cpp b/source/adapters/opencl/common.cpp index 4fe8bed408..e7fb09eeda 100644 --- a/source/adapters/opencl/common.cpp +++ b/source/adapters/opencl/common.cpp @@ -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; } diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 4b7525d92f..461414ccf9 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -4007,7 +4007,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( diff --git a/source/ur_api.cpp b/source/ur_api.cpp index eeca6c0c95..e0f85fb4a0 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -3394,7 +3394,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( diff --git a/test/conformance/queue/queue_adapter_hip.match b/test/conformance/queue/queue_adapter_hip.match index d39b30aa73..e69de29bb2 100644 --- a/test/conformance/queue/queue_adapter_hip.match +++ b/test/conformance/queue/queue_adapter_hip.match @@ -1,2 +0,0 @@ -urQueueGetInfoTestWithInfoParam.Success/AMD_HIP_BACKEND___{{.*}}___UR_QUEUE_INFO_DEVICE_DEFAULT -urQueueGetInfoTestWithInfoParam.Success/AMD_HIP_BACKEND___{{.*}}___UR_QUEUE_INFO_SIZE diff --git a/test/conformance/queue/queue_adapter_opencl.match b/test/conformance/queue/queue_adapter_opencl.match index a374e0b4b1..e69de29bb2 100644 --- a/test/conformance/queue/queue_adapter_opencl.match +++ b/test/conformance/queue/queue_adapter_opencl.match @@ -1,2 +0,0 @@ -urQueueGetInfoTestWithInfoParam.Success/Intel_R__OpenCL___{{.*}}___UR_QUEUE_INFO_DEVICE_DEFAULT -urQueueGetInfoTestWithInfoParam.Success/Intel_R__OpenCL___{{.*}}___UR_QUEUE_INFO_SIZE diff --git a/test/conformance/queue/urQueueGetInfo.cpp b/test/conformance/queue/urQueueGetInfo.cpp index 9269e4de30..a29a1e5f5a 100644 --- a/test/conformance/queue/urQueueGetInfo.cpp +++ b/test/conformance/queue/urQueueGetInfo.cpp @@ -2,7 +2,7 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include +#include #include std::unordered_map queue_info_size_map = { @@ -19,6 +19,64 @@ using urQueueGetInfoTestWithInfoParam = uur::urQueueTestWithParam; UUR_TEST_SUITE_P(urQueueGetInfoTestWithInfoParam, + ::testing::Values(UR_QUEUE_INFO_CONTEXT, UR_QUEUE_INFO_DEVICE, + UR_QUEUE_INFO_FLAGS, + UR_QUEUE_INFO_REFERENCE_COUNT, + UR_QUEUE_INFO_EMPTY), + uur::deviceTestWithParamPrinter); + +TEST_P(urQueueGetInfoTestWithInfoParam, Success) { + ur_queue_info_t info_type = getParam(); + size_t size = 0; + auto result = urQueueGetInfo(queue, info_type, 0, nullptr, &size); + + if (result == UR_RESULT_SUCCESS) { + 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 data(size); + ASSERT_SUCCESS( + urQueueGetInfo(queue, info_type, size, data.data(), nullptr)); + } else { + ASSERT_EQ_RESULT(result, UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION); + } +} + +struct urQueueGetInfoDeviceQueueTestWithInfoParam + : public uur::urContextTestWithParam { + void SetUp() { + urContextTestWithParam::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::TearDown(); + } + + ur_queue_handle_t queue = nullptr; + ur_queue_properties_t queueProperties = { + UR_STRUCTURE_TYPE_QUEUE_PROPERTIES, nullptr, + UR_QUEUE_FLAG_ON_DEVICE | UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE | + UR_QUEUE_FLAG_ON_DEVICE_DEFAULT}; +}; + +UUR_TEST_SUITE_P(urQueueGetInfoDeviceQueueTestWithInfoParam, ::testing::Values(UR_QUEUE_INFO_CONTEXT, UR_QUEUE_INFO_DEVICE, UR_QUEUE_INFO_DEVICE_DEFAULT, UR_QUEUE_INFO_FLAGS, @@ -26,7 +84,7 @@ UUR_TEST_SUITE_P(urQueueGetInfoTestWithInfoParam, UR_QUEUE_INFO_SIZE, UR_QUEUE_INFO_EMPTY), uur::deviceTestWithParamPrinter); -TEST_P(urQueueGetInfoTestWithInfoParam, Success) { +TEST_P(urQueueGetInfoDeviceQueueTestWithInfoParam, Success) { ur_queue_info_t info_type = getParam(); size_t size = 0; auto result = urQueueGetInfo(queue, info_type, 0, nullptr, &size);