Skip to content

Commit

Permalink
Fix a bunch of minor issues with query implementations.
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongreig committed Sep 19, 2024
1 parent 3665e00 commit ff51624
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 25 deletions.
1 change: 1 addition & 0 deletions source/adapters/cuda/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 8 additions & 3 deletions source/adapters/hip/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
7 changes: 4 additions & 3 deletions source/adapters/level_zero/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down Expand Up @@ -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<ur_bool_t>(false));
default:
logger::error("Unsupported ParamName in urGetDeviceInfo");
logger::error("ParamNameParamName={}(0x{})", ParamName,
Expand Down
2 changes: 1 addition & 1 deletion source/adapters/level_zero/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ ur_result_t urEventGetInfo(
}
case UR_EVENT_INFO_COMMAND_TYPE: {
std::shared_lock<ur_shared_mutex> EventLock(Event->Mutex);
return ReturnValue(ur_cast<uint64_t>(Event->CommandType));
return ReturnValue(ur_cast<ur_command_t>(Event->CommandType));
}
case UR_EVENT_INFO_COMMAND_EXECUTION_STATUS: {
// Check to see if the event's Queue has an open command list due to
Expand Down
2 changes: 1 addition & 1 deletion source/adapters/level_zero/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 10 additions & 8 deletions source/adapters/opencl/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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:
Expand All @@ -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;
}

Expand Down
19 changes: 10 additions & 9 deletions test/conformance/usm/urUSMGetMemAllocInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
// See LICENSE.TXT
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <map>
#include <uur/fixtures.h>

struct urUSMGetMemAllocInfoTest
struct urUSMAllocInfoTest
: uur::urUSMDeviceAllocTestWithParam<ur_usm_alloc_info_t> {
void SetUp() override {
use_pool = getParam() == UR_USM_ALLOC_INFO_POOL;
Expand All @@ -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,
Expand All @@ -30,7 +31,7 @@ static std::unordered_map<ur_usm_alloc_info_t, size_t> 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(
Expand Down Expand Up @@ -79,34 +80,34 @@ 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,
sizeof(ur_usm_type_t), &USMType,
nullptr));
}

TEST_P(urUSMGetMemAllocInfoNegativeTest, InvalidNullPointerMem) {
TEST_P(urUSMGetMemAllocInfoTest, InvalidNullPointerMem) {
ur_usm_type_t USMType;
ASSERT_EQ_RESULT(
UR_RESULT_ERROR_INVALID_NULL_POINTER,
urUSMGetMemAllocInfo(context, nullptr, UR_USM_ALLOC_INFO_TYPE,
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,
urUSMGetMemAllocInfo(context, ptr, UR_USM_ALLOC_INFO_FORCE_UINT32,
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,
Expand Down

0 comments on commit ff51624

Please sign in to comment.