From ff5162454800510499348bf8623c17dd86898b1b Mon Sep 17 00:00:00 2001 From: Aaron Greig Date: Mon, 12 Feb 2024 15:13:13 +0000 Subject: [PATCH] Fix a bunch of minor issues with query implementations. --- source/adapters/cuda/device.cpp | 1 + source/adapters/hip/device.cpp | 11 ++++++++--- source/adapters/level_zero/device.cpp | 7 ++++--- source/adapters/level_zero/event.cpp | 2 +- source/adapters/level_zero/queue.cpp | 2 +- source/adapters/opencl/device.cpp | 18 ++++++++++-------- test/conformance/usm/urUSMGetMemAllocInfo.cpp | 19 ++++++++++--------- 7 files changed, 35 insertions(+), 25 deletions(-) diff --git a/source/adapters/cuda/device.cpp b/source/adapters/cuda/device.cpp index 9c8a0c807c..95da76daa5 100644 --- a/source/adapters/cuda/device.cpp +++ b/source/adapters/cuda/device.cpp @@ -1085,6 +1085,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, case UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE: case UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE: case UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU: + case UR_DEVICE_INFO_IP_VERSION: return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP: diff --git a/source/adapters/hip/device.cpp b/source/adapters/hip/device.cpp index 3ae98e929d..2309dd6444 100644 --- a/source/adapters/hip/device.cpp +++ b/source/adapters/hip/device.cpp @@ -889,6 +889,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT: return ReturnValue(false); + case UR_DEVICE_INFO_BFLOAT16: + return ReturnValue(true); + case UR_DEVICE_INFO_ASYNC_BARRIER: + return ReturnValue(false); + case UR_DEVICE_INFO_IL_VERSION: + return ReturnValue(""); + // TODO: Investigate if this information is available on HIP. case UR_DEVICE_INFO_COMPONENT_DEVICES: case UR_DEVICE_INFO_COMPOSITE_DEVICE: @@ -899,9 +906,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, case UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE: case UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU: case UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH: - case UR_DEVICE_INFO_BFLOAT16: - case UR_DEVICE_INFO_IL_VERSION: - case UR_DEVICE_INFO_ASYNC_BARRIER: + case UR_DEVICE_INFO_IP_VERSION: return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP: diff --git a/source/adapters/level_zero/device.cpp b/source/adapters/level_zero/device.cpp index e6cb650420..24fc7680bd 100644 --- a/source/adapters/level_zero/device.cpp +++ b/source/adapters/level_zero/device.cpp @@ -848,9 +848,6 @@ ur_result_t urDeviceGetInfo( return ReturnValue(uint32_t{Device->ZeDeviceProperties->numEUsPerSubslice}); case UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU: return ReturnValue(uint32_t{Device->ZeDeviceProperties->numThreadsPerEU}); - case UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH: - // currently not supported in level zero runtime - return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; case UR_DEVICE_INFO_BFLOAT16: { // bfloat16 math functions are not yet supported on Intel GPUs. return ReturnValue(ur_bool_t{false}); @@ -1104,6 +1101,10 @@ ur_result_t urDeviceGetInfo( return ReturnValue(false); case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT: return ReturnValue(true); + case UR_DEVICE_INFO_ASYNC_BARRIER: + return ReturnValue(false); + case UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED: + return ReturnValue(static_cast(false)); default: logger::error("Unsupported ParamName in urGetDeviceInfo"); logger::error("ParamNameParamName={}(0x{})", ParamName, diff --git a/source/adapters/level_zero/event.cpp b/source/adapters/level_zero/event.cpp index f58db37753..9c3782c25e 100644 --- a/source/adapters/level_zero/event.cpp +++ b/source/adapters/level_zero/event.cpp @@ -421,7 +421,7 @@ ur_result_t urEventGetInfo( } case UR_EVENT_INFO_COMMAND_TYPE: { std::shared_lock EventLock(Event->Mutex); - return ReturnValue(ur_cast(Event->CommandType)); + return ReturnValue(ur_cast(Event->CommandType)); } case UR_EVENT_INFO_COMMAND_EXECUTION_STATUS: { // Check to see if the event's Queue has an open command list due to diff --git a/source/adapters/level_zero/queue.cpp b/source/adapters/level_zero/queue.cpp index 978547df10..ed816a936f 100644 --- a/source/adapters/level_zero/queue.cpp +++ b/source/adapters/level_zero/queue.cpp @@ -451,7 +451,7 @@ ur_result_t urQueueGetInfo( logger::error( "Unsupported ParamName in urQueueGetInfo: ParamName=ParamName={}(0x{})", ParamName, logger::toHex(ParamName)); - return UR_RESULT_ERROR_INVALID_VALUE; + return UR_RESULT_ERROR_INVALID_ENUMERATION; } return UR_RESULT_SUCCESS; diff --git a/source/adapters/opencl/device.cpp b/source/adapters/opencl/device.cpp index 6cdfb3a97d..f5af2b1cdf 100644 --- a/source/adapters/opencl/device.cpp +++ b/source/adapters/opencl/device.cpp @@ -770,9 +770,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, return ReturnValue(true); } - case UR_DEVICE_INFO_BFLOAT16: { - return ReturnValue(false); - } case UR_DEVICE_INFO_ATOMIC_64: { bool Supported = false; UR_RETURN_ON_FAILURE(cl_adapter::checkDeviceExtensions( @@ -1045,15 +1042,21 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, return ReturnValue(UUID); } - case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS: { + case UR_DEVICE_INFO_COMPONENT_DEVICES: + case UR_DEVICE_INFO_COMPOSITE_DEVICE: + // These two are exclusive to L0. + return ReturnValue(0); + // We can't query to check if these are supported, they will need to be + // manually updated if support is ever implemented. + case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS: + case UR_DEVICE_INFO_BFLOAT16: + case UR_DEVICE_INFO_ASYNC_BARRIER: { return ReturnValue(false); } /* TODO: Check regularly to see if support is enabled in OpenCL. Intel GPU * EU device-specific information extensions. Some of the queries are * enabled by cl_intel_device_attribute_query extension, but it's not yet in * the Registry. */ - case UR_DEVICE_INFO_COMPONENT_DEVICES: - case UR_DEVICE_INFO_COMPOSITE_DEVICE: case UR_DEVICE_INFO_PCI_ADDRESS: case UR_DEVICE_INFO_GPU_EU_COUNT: case UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH: @@ -1066,8 +1069,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, case UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP: case UR_DEVICE_INFO_GLOBAL_MEM_FREE: case UR_DEVICE_INFO_MEMORY_CLOCK_RATE: - case UR_DEVICE_INFO_MEMORY_BUS_WIDTH: - case UR_DEVICE_INFO_ASYNC_BARRIER: { + case UR_DEVICE_INFO_MEMORY_BUS_WIDTH: { return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; } diff --git a/test/conformance/usm/urUSMGetMemAllocInfo.cpp b/test/conformance/usm/urUSMGetMemAllocInfo.cpp index 181e1d08b3..3a26236219 100644 --- a/test/conformance/usm/urUSMGetMemAllocInfo.cpp +++ b/test/conformance/usm/urUSMGetMemAllocInfo.cpp @@ -3,9 +3,10 @@ // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +#include #include -struct urUSMGetMemAllocInfoTest +struct urUSMAllocInfoTest : uur::urUSMDeviceAllocTestWithParam { void SetUp() override { use_pool = getParam() == UR_USM_ALLOC_INFO_POOL; @@ -14,7 +15,7 @@ struct urUSMGetMemAllocInfoTest } }; -UUR_TEST_SUITE_P(urUSMGetMemAllocInfoTest, +UUR_TEST_SUITE_P(urUSMAllocInfoTest, ::testing::Values(UR_USM_ALLOC_INFO_TYPE, UR_USM_ALLOC_INFO_BASE_PTR, UR_USM_ALLOC_INFO_SIZE, @@ -30,7 +31,7 @@ static std::unordered_map usm_info_size_map = { {UR_USM_ALLOC_INFO_POOL, sizeof(ur_usm_pool_handle_t)}, }; -TEST_P(urUSMGetMemAllocInfoTest, Success) { +TEST_P(urUSMAllocInfoTest, Success) { size_t size = 0; auto alloc_info = getParam(); ASSERT_SUCCESS( @@ -79,10 +80,10 @@ TEST_P(urUSMGetMemAllocInfoTest, Success) { } } -using urUSMGetMemAllocInfoNegativeTest = uur::urUSMDeviceAllocTest; -UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urUSMGetMemAllocInfoNegativeTest); +using urUSMGetMemAllocInfoTest = uur::urUSMDeviceAllocTest; +UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urUSMGetMemAllocInfoTest); -TEST_P(urUSMGetMemAllocInfoNegativeTest, InvalidNullHandleContext) { +TEST_P(urUSMGetMemAllocInfoTest, InvalidNullHandleContext) { ur_usm_type_t USMType; ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, urUSMGetMemAllocInfo(nullptr, ptr, UR_USM_ALLOC_INFO_TYPE, @@ -90,7 +91,7 @@ TEST_P(urUSMGetMemAllocInfoNegativeTest, InvalidNullHandleContext) { nullptr)); } -TEST_P(urUSMGetMemAllocInfoNegativeTest, InvalidNullPointerMem) { +TEST_P(urUSMGetMemAllocInfoTest, InvalidNullPointerMem) { ur_usm_type_t USMType; ASSERT_EQ_RESULT( UR_RESULT_ERROR_INVALID_NULL_POINTER, @@ -98,7 +99,7 @@ TEST_P(urUSMGetMemAllocInfoNegativeTest, InvalidNullPointerMem) { sizeof(ur_usm_type_t), &USMType, nullptr)); } -TEST_P(urUSMGetMemAllocInfoNegativeTest, InvalidEnumeration) { +TEST_P(urUSMGetMemAllocInfoTest, InvalidEnumeration) { ur_usm_type_t USMType; ASSERT_EQ_RESULT( UR_RESULT_ERROR_INVALID_ENUMERATION, @@ -106,7 +107,7 @@ TEST_P(urUSMGetMemAllocInfoNegativeTest, InvalidEnumeration) { sizeof(ur_usm_type_t), &USMType, nullptr)); } -TEST_P(urUSMGetMemAllocInfoNegativeTest, InvalidValuePropSize) { +TEST_P(urUSMGetMemAllocInfoTest, InvalidValuePropSize) { ur_usm_type_t USMType; ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_SIZE, urUSMGetMemAllocInfo(context, ptr, UR_USM_ALLOC_INFO_TYPE,