Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add device info query to report support for native asserts. #2269

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,8 @@ typedef enum ur_device_info_t {
UR_DEVICE_INFO_USM_POOL_SUPPORT = 119, ///< [::ur_bool_t] return true if the device supports USM pooling. Pertains
///< to the `USMPool` entry points and usage of the `pool` parameter of the
///< USM alloc entry points.
UR_DEVICE_INFO_USE_NATIVE_ASSERT = 120, ///< [::ur_bool_t] return true if the device has a native assert
///< implementation.
UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP = 0x1000, ///< [::ur_bool_t] Returns true if the device supports the use of
///< command-buffers.
UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_CAPABILITIES_EXP = 0x1001, ///< [::ur_device_command_buffer_update_capability_flags_t] Command-buffer
Expand Down
15 changes: 15 additions & 0 deletions include/ur_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2553,6 +2553,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) {
case UR_DEVICE_INFO_USM_POOL_SUPPORT:
os << "UR_DEVICE_INFO_USM_POOL_SUPPORT";
break;
case UR_DEVICE_INFO_USE_NATIVE_ASSERT:
os << "UR_DEVICE_INFO_USE_NATIVE_ASSERT";
break;
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP:
os << "UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP";
break;
Expand Down Expand Up @@ -4067,6 +4070,18 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, ur_device_info

os << ")";
} break;
case UR_DEVICE_INFO_USE_NATIVE_ASSERT: {
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
if (sizeof(ur_bool_t) > size) {
os << "invalid size (is: " << size << ", expected: >=" << sizeof(ur_bool_t) << ")";
return UR_RESULT_ERROR_INVALID_SIZE;
}
os << (const void *)(tptr) << " (";

os << *tptr;

os << ")";
} break;
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP: {
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
if (sizeof(ur_bool_t) > size) {
Expand Down
2 changes: 2 additions & 0 deletions scripts/core/device.yml
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,8 @@ etors:
desc: "[$x_bool_t] return true if the device supports the `EnqueueDeviceGlobalVariableWrite` and `EnqueueDeviceGlobalVariableRead` entry points."
- name: USM_POOL_SUPPORT
desc: "[$x_bool_t] return true if the device supports USM pooling. Pertains to the `USMPool` entry points and usage of the `pool` parameter of the USM alloc entry points."
- name: USE_NATIVE_ASSERT
desc: "[$x_bool_t] return true if the device has a native assert implementation."
--- #--------------------------------------------------------------------------
type: function
desc: "Retrieves various information about device"
Expand Down
3 changes: 2 additions & 1 deletion source/adapters/cuda/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
case UR_DEVICE_INFO_EXTENSIONS: {

std::string SupportedExtensions = "cl_khr_fp64 cl_khr_subgroups ";
SupportedExtensions += "cl_intel_devicelib_assert ";
// Return supported for the UR command-buffer experimental feature
SupportedExtensions += "ur_exp_command_buffer ";
SupportedExtensions += "ur_exp_usm_p2p ";
Expand Down Expand Up @@ -1107,6 +1106,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR) >= 9;
return ReturnValue(static_cast<bool>(Value));
}
case UR_DEVICE_INFO_USE_NATIVE_ASSERT:
return ReturnValue(true);

default:
break;
Expand Down
7 changes: 2 additions & 5 deletions source/adapters/hip/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,12 +543,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
return ReturnValue("");
}
case UR_DEVICE_INFO_EXTENSIONS: {
// TODO: Remove comment when HIP support native asserts.
// DEVICELIB_ASSERT extension is set so fallback assert
// postprocessing is NOP. HIP 4.3 docs indicate support for
// native asserts are in progress
std::string SupportedExtensions = "";
SupportedExtensions += "cl_intel_devicelib_assert ";
SupportedExtensions += "ur_exp_usm_p2p ";

int RuntimeVersion = 0;
Expand Down Expand Up @@ -935,6 +930,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
}
case UR_DEVICE_INFO_COMMAND_BUFFER_EVENT_SUPPORT_EXP:
return ReturnValue(false);
case UR_DEVICE_INFO_USE_NATIVE_ASSERT:
return ReturnValue(true);
default:
break;
}
Expand Down
2 changes: 2 additions & 0 deletions source/adapters/level_zero/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,8 @@ ur_result_t urDeviceGetInfo(
return ReturnValue(true);
case UR_DEVICE_INFO_USM_POOL_SUPPORT:
return ReturnValue(true);
case UR_DEVICE_INFO_USE_NATIVE_ASSERT:
return ReturnValue(false);
default:
logger::error("Unsupported ParamName in urGetDeviceInfo");
logger::error("ParamNameParamName={}(0x{})", ParamName,
Expand Down
2 changes: 2 additions & 0 deletions source/adapters/native_cpu/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,

case UR_DEVICE_INFO_USM_POOL_SUPPORT:
return ReturnValue(false);
case UR_DEVICE_INFO_USE_NATIVE_ASSERT:
return ReturnValue(false);

default:
DIE_NO_IMPLEMENTATION;
Expand Down
7 changes: 7 additions & 0 deletions source/adapters/opencl/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
}
case UR_DEVICE_INFO_COMMAND_BUFFER_EVENT_SUPPORT_EXP:
return ReturnValue(false);
case UR_DEVICE_INFO_USE_NATIVE_ASSERT: {
bool Supported = false;
UR_RETURN_ON_FAILURE(cl_adapter::checkDeviceExtensions(
cl_adapter::cast<cl_device_id>(hDevice), {"cl_intel_devicelib_assert"},
Supported));
return ReturnValue(Supported);
}
default: {
return UR_RESULT_ERROR_INVALID_ENUMERATION;
}
Expand Down
6 changes: 4 additions & 2 deletions test/conformance/device/urDeviceGetInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ static std::unordered_map<ur_device_info_t, size_t> device_info_size_map = {
{UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP, sizeof(uint32_t)},
{UR_DEVICE_INFO_COMPONENT_DEVICES, sizeof(uint32_t)},
{UR_DEVICE_INFO_COMPOSITE_DEVICE, sizeof(ur_device_handle_t)},
{UR_DEVICE_INFO_USM_POOL_SUPPORT, sizeof(ur_bool_t)}};
{UR_DEVICE_INFO_USM_POOL_SUPPORT, sizeof(ur_bool_t)},
{UR_DEVICE_INFO_USE_NATIVE_ASSERT, sizeof(ur_bool_t)}};

struct urDeviceGetInfoTest : uur::urAllDevicesTest,
::testing::WithParamInterface<ur_device_info_t> {
Expand Down Expand Up @@ -237,7 +238,8 @@ INSTANTIATE_TEST_SUITE_P(
UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP, //
UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT, //
UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS, //
UR_DEVICE_INFO_USM_POOL_SUPPORT //
UR_DEVICE_INFO_USM_POOL_SUPPORT, //
UR_DEVICE_INFO_USE_NATIVE_ASSERT //
),
[](const ::testing::TestParamInfo<ur_device_info_t> &info) {
std::stringstream ss;
Expand Down
2 changes: 2 additions & 0 deletions tools/urinfo/urinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ inline void printDeviceInfos(ur_device_handle_t hDevice,
std::cout << prefix;
printDeviceInfo<ur_bool_t>(hDevice, UR_DEVICE_INFO_USM_POOL_SUPPORT);
std::cout << prefix;
printDeviceInfo<ur_bool_t>(hDevice, UR_DEVICE_INFO_USE_NATIVE_ASSERT);
std::cout << prefix;
printDeviceInfo<ur_bool_t>(hDevice,
UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP);
std::cout << prefix;
Expand Down
Loading