Skip to content
Merged
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
5 changes: 4 additions & 1 deletion include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,9 @@ typedef enum ur_adapter_info_t {
///< 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_ADAPTER_INFO_VERSION = 2, ///< [uint32_t] Specifies the adapter version, initial value of 1 and
///< incremented unpon major changes, e.g. when multiple versions of an
///< adapter may exist in parallel.
/// @cond
UR_ADAPTER_INFO_FORCE_UINT32 = 0x7fffffff
/// @endcond
Expand All @@ -988,7 +991,7 @@ typedef enum ur_adapter_info_t {
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hAdapter`
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
/// + `::UR_ADAPTER_INFO_REFERENCE_COUNT < propName`
/// + `::UR_ADAPTER_INFO_VERSION < propName`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
/// + If `propName` is not supported by the adapter.
/// - ::UR_RESULT_ERROR_INVALID_SIZE
Expand Down
15 changes: 15 additions & 0 deletions include/ur_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1922,6 +1922,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_adapter_info_t value)
case UR_ADAPTER_INFO_REFERENCE_COUNT:
os << "UR_ADAPTER_INFO_REFERENCE_COUNT";
break;
case UR_ADAPTER_INFO_VERSION:
os << "UR_ADAPTER_INFO_VERSION";
break;
default:
os << "unknown enumerator";
break;
Expand Down Expand Up @@ -1962,6 +1965,18 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, ur_adapter_inf

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

os << *tptr;

os << ")";
} break;
default:
os << "unknown enumerator";
return UR_RESULT_ERROR_INVALID_ENUMERATION;
Expand Down
5 changes: 5 additions & 0 deletions scripts/core/adapter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ etors:
[uint32_t] Reference count of the adapter.
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.
- name: VERSION
desc: >
[uint32_t] Specifies the adapter version, initial value of 1 and
incremented unpon major changes, e.g. when multiple versions of an
adapter may exist in parallel.
--- #--------------------------------------------------------------------------
type: function
desc: "Retrieves information about the adapter"
Expand Down
2 changes: 2 additions & 0 deletions source/adapters/cuda/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetInfo(ur_adapter_handle_t,
return ReturnValue(UR_ADAPTER_BACKEND_CUDA);
case UR_ADAPTER_INFO_REFERENCE_COUNT:
return ReturnValue(adapter.RefCount.load());
case UR_ADAPTER_INFO_VERSION:
return ReturnValue(uint32_t{1});
default:
return UR_RESULT_ERROR_INVALID_ENUMERATION;
}
Expand Down
2 changes: 2 additions & 0 deletions source/adapters/hip/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetInfo(ur_adapter_handle_t,
return ReturnValue(UR_ADAPTER_BACKEND_HIP);
case UR_ADAPTER_INFO_REFERENCE_COUNT:
return ReturnValue(adapter.RefCount.load());
case UR_ADAPTER_INFO_VERSION:
return ReturnValue(uint32_t{1});
default:
return UR_RESULT_ERROR_INVALID_ENUMERATION;
}
Expand Down
8 changes: 8 additions & 0 deletions source/adapters/level_zero/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,14 @@ ur_result_t urAdapterGetInfo(ur_adapter_handle_t, ur_adapter_info_t PropName,
return ReturnValue(UR_ADAPTER_BACKEND_LEVEL_ZERO);
case UR_ADAPTER_INFO_REFERENCE_COUNT:
return ReturnValue(GlobalAdapter->RefCount.load());
case UR_ADAPTER_INFO_VERSION: {
#ifdef UR_ADAPTER_LEVEL_ZERO_V2
uint32_t adapterVersion = 2;
#else
uint32_t adapterVersion = 1;
#endif
return ReturnValue(adapterVersion);
}
default:
return UR_RESULT_ERROR_INVALID_ENUMERATION;
}
Expand Down
2 changes: 2 additions & 0 deletions source/adapters/native_cpu/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetInfo(ur_adapter_handle_t,
return ReturnValue(UR_ADAPTER_BACKEND_NATIVE_CPU);
case UR_ADAPTER_INFO_REFERENCE_COUNT:
return ReturnValue(Adapter.RefCount.load());
case UR_ADAPTER_INFO_VERSION:
return ReturnValue(uint32_t{1});
default:
return UR_RESULT_ERROR_INVALID_ENUMERATION;
}
Expand Down
2 changes: 2 additions & 0 deletions source/adapters/opencl/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetInfo(ur_adapter_handle_t,
return ReturnValue(UR_ADAPTER_BACKEND_OPENCL);
case UR_ADAPTER_INFO_REFERENCE_COUNT:
return ReturnValue(adapter->RefCount.load());
case UR_ADAPTER_INFO_VERSION:
return ReturnValue(uint32_t{1});
default:
return UR_RESULT_ERROR_INVALID_ENUMERATION;
}
Expand Down
2 changes: 1 addition & 1 deletion source/loader/layers/validation/ur_valddi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ __urdlllocal ur_result_t UR_APICALL urAdapterGetInfo(
return UR_RESULT_ERROR_INVALID_NULL_POINTER;
}

if (UR_ADAPTER_INFO_REFERENCE_COUNT < propName) {
if (UR_ADAPTER_INFO_VERSION < propName) {
return UR_RESULT_ERROR_INVALID_ENUMERATION;
}

Expand Down
2 changes: 1 addition & 1 deletion source/loader/ur_libapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ ur_result_t UR_APICALL urAdapterGetLastError(
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hAdapter`
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
/// + `::UR_ADAPTER_INFO_REFERENCE_COUNT < propName`
/// + `::UR_ADAPTER_INFO_VERSION < propName`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
/// + If `propName` is not supported by the adapter.
/// - ::UR_RESULT_ERROR_INVALID_SIZE
Expand Down
2 changes: 1 addition & 1 deletion source/ur_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ ur_result_t UR_APICALL urAdapterGetLastError(
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hAdapter`
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
/// + `::UR_ADAPTER_INFO_REFERENCE_COUNT < propName`
/// + `::UR_ADAPTER_INFO_VERSION < propName`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
/// + If `propName` is not supported by the adapter.
/// - ::UR_RESULT_ERROR_INVALID_SIZE
Expand Down
4 changes: 3 additions & 1 deletion test/conformance/adapter/urAdapterGetInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ struct urAdapterGetInfoTest : uur::runtime::urAdapterTest,

std::unordered_map<ur_adapter_info_t, size_t> adapter_info_size_map = {
{UR_ADAPTER_INFO_BACKEND, sizeof(ur_adapter_backend_t)},
{UR_ADAPTER_INFO_VERSION, sizeof(uint32_t)},
{UR_ADAPTER_INFO_REFERENCE_COUNT, sizeof(uint32_t)},
};

INSTANTIATE_TEST_SUITE_P(
urAdapterGetInfo, urAdapterGetInfoTest,
::testing::Values(UR_ADAPTER_INFO_BACKEND, UR_ADAPTER_INFO_REFERENCE_COUNT),
::testing::Values(UR_ADAPTER_INFO_BACKEND, UR_ADAPTER_INFO_VERSION,
UR_ADAPTER_INFO_REFERENCE_COUNT),
[](const ::testing::TestParamInfo<ur_adapter_info_t> &info) {
std::stringstream ss;
ss << info.param;
Expand Down
2 changes: 2 additions & 0 deletions tools/urinfo/urinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ inline void printAdapterInfos(ur_adapter_handle_t hAdapter,
std::string_view prefix = " ") {
std::cout << prefix;
printAdapterInfo<ur_adapter_backend_t>(hAdapter, UR_ADAPTER_INFO_BACKEND);
std::cout << prefix;
printAdapterInfo<uint32_t>(hAdapter, UR_ADAPTER_INFO_VERSION);
}

inline void printPlatformInfos(ur_platform_handle_t hPlatform,
Expand Down
Loading