Skip to content
Closed
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
6 changes: 3 additions & 3 deletions examples/codegen/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ std::vector<ur_adapter_handle_t>
get_supported_adapters(std::vector<ur_adapter_handle_t> &adapters) {
std::vector<ur_adapter_handle_t> supported_adapters;
for (auto adapter : adapters) {
ur_adapter_backend_t backend;
ur_backend_t backend;
ur_check(urAdapterGetInfo(adapter, UR_ADAPTER_INFO_BACKEND,
sizeof(ur_adapter_backend_t), &backend, nullptr));
sizeof(ur_backend_t), &backend, nullptr));

if (backend == UR_ADAPTER_BACKEND_LEVEL_ZERO) {
if (backend == UR_BACKEND_LEVEL_ZERO) {
supported_adapters.push_back(adapter);
}
}
Expand Down
71 changes: 25 additions & 46 deletions include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,27 @@ typedef struct ur_rect_region_t {

} ur_rect_region_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief Defines known backends.
typedef enum ur_backend_t {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it might smooth the transition to have aliases to the old names for the two enums?

I assume the numerical values are the same so its just a source change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we're at the point now where the next release this makes it into is a major one, I think we just rip the bandaid off

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, sure.

/// The backend is not a recognized one
UR_BACKEND_UNKNOWN = 0,
/// The backend is Level Zero
UR_BACKEND_LEVEL_ZERO = 1,
/// The backend is OpenCL
UR_BACKEND_OPENCL = 2,
/// The backend is CUDA
UR_BACKEND_CUDA = 3,
/// The backend is HIP
UR_BACKEND_HIP = 4,
/// The backend is Native CPU
UR_BACKEND_NATIVE_CPU = 5,
/// @cond
UR_BACKEND_FORCE_UINT32 = 0x7fffffff
/// @endcond

} ur_backend_t;

#if !defined(__GNUC__)
#pragma endregion
#endif
Expand Down Expand Up @@ -1308,8 +1329,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetLastError(
///////////////////////////////////////////////////////////////////////////////
/// @brief Supported adapter info
typedef enum ur_adapter_info_t {
/// [::ur_adapter_backend_t] Identifies the native backend supported by
/// the adapter.
/// [::ur_backend_t] Identifies the native backend supported by the
/// adapter.
UR_ADAPTER_INFO_BACKEND = 0,
/// [uint32_t] Reference count of the adapter.
/// The reference count returned should be considered immediately stale.
Expand Down Expand Up @@ -1370,27 +1391,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetInfo(
/// pPropValue.
size_t *pPropSizeRet);

///////////////////////////////////////////////////////////////////////////////
/// @brief Identifies backend of the adapter
typedef enum ur_adapter_backend_t {
/// The backend is not a recognized one
UR_ADAPTER_BACKEND_UNKNOWN = 0,
/// The backend is Level Zero
UR_ADAPTER_BACKEND_LEVEL_ZERO = 1,
/// The backend is OpenCL
UR_ADAPTER_BACKEND_OPENCL = 2,
/// The backend is CUDA
UR_ADAPTER_BACKEND_CUDA = 3,
/// The backend is HIP
UR_ADAPTER_BACKEND_HIP = 4,
/// The backend is Native CPU
UR_ADAPTER_BACKEND_NATIVE_CPU = 5,
/// @cond
UR_ADAPTER_BACKEND_FORCE_UINT32 = 0x7fffffff
/// @endcond

} ur_adapter_backend_t;

#if !defined(__GNUC__)
#pragma endregion
#endif
Expand Down Expand Up @@ -1457,8 +1457,8 @@ typedef enum ur_platform_info_t {
/// [char[]] The string denoting profile of the platform. The size of the
/// info needs to be dynamically queried.
UR_PLATFORM_INFO_PROFILE = 5,
/// [::ur_platform_backend_t] The backend of the platform. Identifies the
/// native backend adapter implementing this platform.
/// [::ur_backend_t] The backend of the platform. Identifies the native
/// backend adapter implementing this platform.
UR_PLATFORM_INFO_BACKEND = 6,
/// [::ur_adapter_handle_t] The adapter handle associated with the
/// platform.
Expand Down Expand Up @@ -1677,27 +1677,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urPlatformGetBackendOption(
/// the frontend option.
const char **ppPlatformOption);

///////////////////////////////////////////////////////////////////////////////
/// @brief Identifies native backend adapters
typedef enum ur_platform_backend_t {
/// The backend is not a recognized one
UR_PLATFORM_BACKEND_UNKNOWN = 0,
/// The backend is Level Zero
UR_PLATFORM_BACKEND_LEVEL_ZERO = 1,
/// The backend is OpenCL
UR_PLATFORM_BACKEND_OPENCL = 2,
/// The backend is CUDA
UR_PLATFORM_BACKEND_CUDA = 3,
/// The backend is HIP
UR_PLATFORM_BACKEND_HIP = 4,
/// The backend is Native CPU
UR_PLATFORM_BACKEND_NATIVE_CPU = 5,
/// @cond
UR_PLATFORM_BACKEND_FORCE_UINT32 = 0x7fffffff
/// @endcond

} ur_platform_backend_t;

#if !defined(__GNUC__)
#pragma endregion
#endif
Expand Down
31 changes: 11 additions & 20 deletions include/ur_print.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ UR_APIEXPORT ur_result_t UR_APICALL
urPrintRectRegion(const struct ur_rect_region_t params, char *buffer,
const size_t buff_size, size_t *out_size);

///////////////////////////////////////////////////////////////////////////////
/// @brief Print ur_backend_t enum
/// @returns
/// - ::UR_RESULT_SUCCESS
/// - ::UR_RESULT_ERROR_INVALID_SIZE
/// - `buff_size < out_size`
UR_APIEXPORT ur_result_t UR_APICALL urPrintBackend(enum ur_backend_t value,
char *buffer,
const size_t buff_size,
size_t *out_size);

///////////////////////////////////////////////////////////////////////////////
/// @brief Print ur_device_init_flag_t enum
/// @returns
Expand Down Expand Up @@ -132,16 +143,6 @@ UR_APIEXPORT ur_result_t UR_APICALL
urPrintAdapterInfo(enum ur_adapter_info_t value, char *buffer,
const size_t buff_size, size_t *out_size);

///////////////////////////////////////////////////////////////////////////////
/// @brief Print ur_adapter_backend_t enum
/// @returns
/// - ::UR_RESULT_SUCCESS
/// - ::UR_RESULT_ERROR_INVALID_SIZE
/// - `buff_size < out_size`
UR_APIEXPORT ur_result_t UR_APICALL
urPrintAdapterBackend(enum ur_adapter_backend_t value, char *buffer,
const size_t buff_size, size_t *out_size);

///////////////////////////////////////////////////////////////////////////////
/// @brief Print ur_platform_info_t enum
/// @returns
Expand Down Expand Up @@ -172,16 +173,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintPlatformNativeProperties(
const struct ur_platform_native_properties_t params, char *buffer,
const size_t buff_size, size_t *out_size);

///////////////////////////////////////////////////////////////////////////////
/// @brief Print ur_platform_backend_t enum
/// @returns
/// - ::UR_RESULT_SUCCESS
/// - ::UR_RESULT_ERROR_INVALID_SIZE
/// - `buff_size < out_size`
UR_APIEXPORT ur_result_t UR_APICALL
urPrintPlatformBackend(enum ur_platform_backend_t value, char *buffer,
const size_t buff_size, size_t *out_size);

///////////////////////////////////////////////////////////////////////////////
/// @brief Print ur_device_binary_t struct
/// @returns
Expand Down
109 changes: 37 additions & 72 deletions include/ur_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ operator<<(std::ostream &os,
inline std::ostream &
operator<<(std::ostream &os,
[[maybe_unused]] const struct ur_rect_region_t params);
inline std::ostream &operator<<(std::ostream &os, enum ur_backend_t value);
inline std::ostream &operator<<(std::ostream &os,
enum ur_device_init_flag_t value);
inline std::ostream &operator<<(std::ostream &os,
Expand All @@ -285,16 +286,12 @@ inline std::ostream &
operator<<(std::ostream &os,
[[maybe_unused]] const struct ur_code_location_t params);
inline std::ostream &operator<<(std::ostream &os, enum ur_adapter_info_t value);
inline std::ostream &operator<<(std::ostream &os,
enum ur_adapter_backend_t value);
inline std::ostream &operator<<(std::ostream &os,
enum ur_platform_info_t value);
inline std::ostream &operator<<(std::ostream &os, enum ur_api_version_t value);
inline std::ostream &operator<<(
std::ostream &os,
[[maybe_unused]] const struct ur_platform_native_properties_t params);
inline std::ostream &operator<<(std::ostream &os,
enum ur_platform_backend_t value);
inline std::ostream &
operator<<(std::ostream &os,
[[maybe_unused]] const struct ur_device_binary_t params);
Expand Down Expand Up @@ -1982,6 +1979,36 @@ inline std::ostream &operator<<(std::ostream &os,
return os;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Print operator for the ur_backend_t type
/// @returns
/// std::ostream &
inline std::ostream &operator<<(std::ostream &os, enum ur_backend_t value) {
switch (value) {
case UR_BACKEND_UNKNOWN:
os << "UR_BACKEND_UNKNOWN";
break;
case UR_BACKEND_LEVEL_ZERO:
os << "UR_BACKEND_LEVEL_ZERO";
break;
case UR_BACKEND_OPENCL:
os << "UR_BACKEND_OPENCL";
break;
case UR_BACKEND_CUDA:
os << "UR_BACKEND_CUDA";
break;
case UR_BACKEND_HIP:
os << "UR_BACKEND_HIP";
break;
case UR_BACKEND_NATIVE_CPU:
os << "UR_BACKEND_NATIVE_CPU";
break;
default:
os << "unknown enumerator";
break;
}
return os;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Print operator for the ur_device_init_flag_t type
/// @returns
/// std::ostream &
Expand Down Expand Up @@ -2200,10 +2227,10 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr,

switch (value) {
case UR_ADAPTER_INFO_BACKEND: {
const ur_adapter_backend_t *tptr = (const ur_adapter_backend_t *)ptr;
if (sizeof(ur_adapter_backend_t) > size) {
const ur_backend_t *tptr = (const ur_backend_t *)ptr;
if (sizeof(ur_backend_t) > size) {
os << "invalid size (is: " << size
<< ", expected: >=" << sizeof(ur_adapter_backend_t) << ")";
<< ", expected: >=" << sizeof(ur_backend_t) << ")";
return UR_RESULT_ERROR_INVALID_SIZE;
}
os << (const void *)(tptr) << " (";
Expand Down Expand Up @@ -2246,37 +2273,6 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr,
}
} // namespace ur::details

///////////////////////////////////////////////////////////////////////////////
/// @brief Print operator for the ur_adapter_backend_t type
/// @returns
/// std::ostream &
inline std::ostream &operator<<(std::ostream &os,
enum ur_adapter_backend_t value) {
switch (value) {
case UR_ADAPTER_BACKEND_UNKNOWN:
os << "UR_ADAPTER_BACKEND_UNKNOWN";
break;
case UR_ADAPTER_BACKEND_LEVEL_ZERO:
os << "UR_ADAPTER_BACKEND_LEVEL_ZERO";
break;
case UR_ADAPTER_BACKEND_OPENCL:
os << "UR_ADAPTER_BACKEND_OPENCL";
break;
case UR_ADAPTER_BACKEND_CUDA:
os << "UR_ADAPTER_BACKEND_CUDA";
break;
case UR_ADAPTER_BACKEND_HIP:
os << "UR_ADAPTER_BACKEND_HIP";
break;
case UR_ADAPTER_BACKEND_NATIVE_CPU:
os << "UR_ADAPTER_BACKEND_NATIVE_CPU";
break;
default:
os << "unknown enumerator";
break;
}
return os;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Print operator for the ur_platform_info_t type
/// @returns
Expand Down Expand Up @@ -2348,10 +2344,10 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr,
printPtr(os, tptr);
} break;
case UR_PLATFORM_INFO_BACKEND: {
const ur_platform_backend_t *tptr = (const ur_platform_backend_t *)ptr;
if (sizeof(ur_platform_backend_t) > size) {
const ur_backend_t *tptr = (const ur_backend_t *)ptr;
if (sizeof(ur_backend_t) > size) {
os << "invalid size (is: " << size
<< ", expected: >=" << sizeof(ur_platform_backend_t) << ")";
<< ", expected: >=" << sizeof(ur_backend_t) << ")";
return UR_RESULT_ERROR_INVALID_SIZE;
}
os << (const void *)(tptr) << " (";
Expand Down Expand Up @@ -2416,37 +2412,6 @@ operator<<(std::ostream &os,
return os;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Print operator for the ur_platform_backend_t type
/// @returns
/// std::ostream &
inline std::ostream &operator<<(std::ostream &os,
enum ur_platform_backend_t value) {
switch (value) {
case UR_PLATFORM_BACKEND_UNKNOWN:
os << "UR_PLATFORM_BACKEND_UNKNOWN";
break;
case UR_PLATFORM_BACKEND_LEVEL_ZERO:
os << "UR_PLATFORM_BACKEND_LEVEL_ZERO";
break;
case UR_PLATFORM_BACKEND_OPENCL:
os << "UR_PLATFORM_BACKEND_OPENCL";
break;
case UR_PLATFORM_BACKEND_CUDA:
os << "UR_PLATFORM_BACKEND_CUDA";
break;
case UR_PLATFORM_BACKEND_HIP:
os << "UR_PLATFORM_BACKEND_HIP";
break;
case UR_PLATFORM_BACKEND_NATIVE_CPU:
os << "UR_PLATFORM_BACKEND_NATIVE_CPU";
break;
default:
os << "unknown enumerator";
break;
}
return os;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Print operator for the ur_device_binary_t type
/// @returns
/// std::ostream &
Expand Down
26 changes: 1 addition & 25 deletions scripts/core/adapter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ name: $x_adapter_info_t
typed_etors: True
etors:
- name: BACKEND
desc: "[$x_adapter_backend_t] Identifies the native backend supported by the adapter."
desc: "[$x_backend_t] Identifies the native backend supported by the adapter."
- name: REFERENCE_COUNT
desc: |
[uint32_t] Reference count of the adapter.
Expand Down Expand Up @@ -182,27 +182,3 @@ returns:
- "`pPropValue == NULL && pPropSizeRet == NULL`"
- $X_RESULT_ERROR_OUT_OF_RESOURCES
- $X_RESULT_ERROR_OUT_OF_HOST_MEMORY
--- #--------------------------------------------------------------------------
type: enum
desc: "Identifies backend of the adapter"
class: $x
name: $x_adapter_backend_t
etors:
- name: UNKNOWN
value: "0"
desc: "The backend is not a recognized one"
- name: LEVEL_ZERO
value: "1"
desc: "The backend is Level Zero"
- name: OPENCL
value: "2"
desc: "The backend is OpenCL"
- name: CUDA
value: "3"
desc: "The backend is CUDA"
- name: HIP
value: "4"
desc: "The backend is HIP"
- name: NATIVE_CPU
value: "5"
desc: "The backend is Native CPU"
Loading