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
3 changes: 3 additions & 0 deletions include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -2193,6 +2193,9 @@ typedef enum ur_device_info_t {
/// [::ur_bool_t] support the ::urProgramSetSpecializationConstants entry
/// point
UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS = 121,
/// [::ur_bool_t] return true if the device has a native assert
/// implementation.
UR_DEVICE_INFO_USE_NATIVE_ASSERT = 122,
/// [::ur_bool_t] Returns true if the device supports the use of
/// command-buffers.
UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP = 0x1000,
Expand Down
16 changes: 16 additions & 0 deletions include/ur_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2876,6 +2876,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) {
case UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS:
os << "UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS";
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 @@ -4533,6 +4536,19 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr,

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 @@ -447,6 +447,8 @@ etors:
desc: "[uint32_t] the number of compute units for specific backend."
- name: PROGRAM_SET_SPECIALIZATION_CONSTANTS
desc: "[$x_bool_t] support the $xProgramSetSpecializationConstants entry point"
- 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
4 changes: 3 additions & 1 deletion source/adapters/cuda/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,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 @@ -1114,6 +1113,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
}
case UR_DEVICE_INFO_LOW_POWER_EVENTS_EXP:
return ReturnValue(false);
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 @@ -557,12 +557,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 @@ -968,6 +963,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
case UR_DEVICE_INFO_LOW_POWER_EVENTS_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 @@ -1198,6 +1198,8 @@ ur_result_t urDeviceGetInfo(
return ReturnValue(false);
case UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED:
return ReturnValue(false);
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 @@ -426,6 +426,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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like we should support something like this? If there a specification for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the adapter never reported support for the cl_intel_devicelib_assert extension so this isn't a change in behaviour, you can see on the sycl side it's a straight change from checking for the extension string to checking for this query https://github.com/intel/llvm/pull/15929/files#diff-d0057c737493e4ed04a7761d08fbd154866eb67f5763bfbc032e5ff550214066L76


case UR_DEVICE_INFO_LOW_POWER_EVENTS_EXP:
return ReturnValue(false);
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 @@ -1227,6 +1227,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
return ReturnValue(false);
case UR_DEVICE_INFO_LOW_POWER_EVENTS_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 @@ -129,7 +129,8 @@ static std::unordered_map<ur_device_info_t, size_t> device_info_size_map = {
{UR_DEVICE_INFO_ESIMD_SUPPORT, sizeof(ur_bool_t)},
{UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t)},
{UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT, sizeof(ur_bool_t)},
{UR_DEVICE_INFO_NUM_COMPUTE_UNITS, sizeof(uint32_t)}};
{UR_DEVICE_INFO_NUM_COMPUTE_UNITS, sizeof(uint32_t)},
{UR_DEVICE_INFO_USE_NATIVE_ASSERT, sizeof(ur_bool_t)}};

using urDeviceGetInfoTest = uur::urDeviceTestWithParam<ur_device_info_t>;

Expand Down Expand Up @@ -255,7 +256,8 @@ UUR_DEVICE_TEST_SUITE_WITH_PARAM(
UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_HALF, //
UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_INT, //
UR_DEVICE_INFO_NUM_COMPUTE_UNITS, //
UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS //
UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS, //
UR_DEVICE_INFO_USE_NATIVE_ASSERT //
),
uur::deviceTestWithParamPrinter<ur_device_info_t>);

Expand Down
2 changes: 2 additions & 0 deletions tools/urinfo/urinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ inline void printDeviceInfos(ur_device_handle_t hDevice,
printDeviceInfo<ur_bool_t>(
hDevice, UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS);
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