Skip to content

Commit b517076

Browse files
Dan Holmeskbenzie
authored andcommitted
Alpha version of code for ODS via adapters
1 parent 78ef1ca commit b517076

File tree

13 files changed

+891
-2
lines changed

13 files changed

+891
-2
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ if(UR_FORMAT_CPP_STYLE)
166166
message(STATUS "Found clang-format: ${CLANG_FORMAT} (version: ${CLANG_FORMAT_VERSION})")
167167

168168
set(CLANG_FORMAT_REQUIRED "15.0")
169-
if(NOT (CLANG_FORMAT_VERSION VERSION_EQUAL CLANG_FORMAT_REQUIRED))
169+
if(NOT (CLANG_FORMAT_VERSION VERSION_GREATER_EQUAL CLANG_FORMAT_REQUIRED))
170170
message(FATAL_ERROR "required clang-format version is ${CLANG_FORMAT_REQUIRED}")
171171
endif()
172172
else()

include/ur_api.h

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ typedef enum ur_function_t {
220220
UR_FUNCTION_COMMAND_BUFFER_RELEASE_COMMAND_EXP = 217, ///< Enumerator for ::urCommandBufferReleaseCommandExp
221221
UR_FUNCTION_COMMAND_BUFFER_GET_INFO_EXP = 218, ///< Enumerator for ::urCommandBufferGetInfoExp
222222
UR_FUNCTION_COMMAND_BUFFER_COMMAND_GET_INFO_EXP = 219, ///< Enumerator for ::urCommandBufferCommandGetInfoExp
223+
UR_FUNCTION_DEVICE_GET_SELECTED = 220, ///< Enumerator for ::urDeviceGetSelected
223224
/// @cond
224225
UR_FUNCTION_FORCE_UINT32 = 0x7fffffff
225226
/// @endcond
@@ -1387,6 +1388,46 @@ urDeviceGet(
13871388
///< pNumDevices will be updated with the total number of devices available.
13881389
);
13891390

1391+
///////////////////////////////////////////////////////////////////////////////
1392+
/// @brief Retrieves devices within a platform selected by ONEAPI_DEVICE_SELECTOR
1393+
///
1394+
/// @details
1395+
/// - Multiple calls to this function will return identical device handles,
1396+
/// in the same order.
1397+
/// - The number and order of handles returned from this function will be
1398+
/// affected by environment variables that filter or select which devices
1399+
/// are exposed through this API.
1400+
/// - A reference is taken for each returned device and must be released
1401+
/// with a subsequent call to ::urDeviceRelease.
1402+
/// - The application may call this function from simultaneous threads, the
1403+
/// implementation must be thread-safe.
1404+
///
1405+
/// @returns
1406+
/// - ::UR_RESULT_SUCCESS
1407+
/// - ::UR_RESULT_ERROR_UNINITIALIZED
1408+
/// - ::UR_RESULT_ERROR_DEVICE_LOST
1409+
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
1410+
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
1411+
/// + `NULL == hPlatform`
1412+
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
1413+
/// + `::UR_DEVICE_TYPE_VPU < DeviceType`
1414+
/// - ::UR_RESULT_ERROR_INVALID_VALUE
1415+
UR_APIEXPORT ur_result_t UR_APICALL
1416+
urDeviceGetSelected(
1417+
ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance
1418+
ur_device_type_t DeviceType, ///< [in] the type of the devices.
1419+
uint32_t NumEntries, ///< [in] the number of devices to be added to phDevices.
1420+
///< If phDevices in not NULL then NumEntries should be greater than zero,
1421+
///< otherwise ::UR_RESULT_ERROR_INVALID_VALUE,
1422+
///< will be returned.
1423+
ur_device_handle_t *phDevices, ///< [out][optional][range(0, NumEntries)] array of handle of devices.
1424+
///< If NumEntries is less than the number of devices available, then only
1425+
///< that number of devices will be retrieved.
1426+
uint32_t *pNumDevices ///< [out][optional] pointer to the number of devices.
1427+
///< pNumDevices will be updated with the total number of selected devices
1428+
///< available for the given platform.
1429+
);
1430+
13901431
///////////////////////////////////////////////////////////////////////////////
13911432
/// @brief Supported device info
13921433
typedef enum ur_device_info_t {
@@ -11148,6 +11189,18 @@ typedef struct ur_device_get_params_t {
1114811189
uint32_t **ppNumDevices;
1114911190
} ur_device_get_params_t;
1115011191

11192+
///////////////////////////////////////////////////////////////////////////////
11193+
/// @brief Function parameters for urDeviceGetSelected
11194+
/// @details Each entry is a pointer to the parameter passed to the function;
11195+
/// allowing the callback the ability to modify the parameter's value
11196+
typedef struct ur_device_get_selected_params_t {
11197+
ur_platform_handle_t *phPlatform;
11198+
ur_device_type_t *pDeviceType;
11199+
uint32_t *pNumEntries;
11200+
ur_device_handle_t **pphDevices;
11201+
uint32_t **ppNumDevices;
11202+
} ur_device_get_selected_params_t;
11203+
1115111204
///////////////////////////////////////////////////////////////////////////////
1115211205
/// @brief Function parameters for urDeviceGetInfo
1115311206
/// @details Each entry is a pointer to the parameter passed to the function;

include/ur_print.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2450,6 +2450,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintVirtualMemGetInfoParams(const struct
24502450
/// - `buff_size < out_size`
24512451
UR_APIEXPORT ur_result_t UR_APICALL urPrintDeviceGetParams(const struct ur_device_get_params_t *params, char *buffer, const size_t buff_size, size_t *out_size);
24522452

2453+
///////////////////////////////////////////////////////////////////////////////
2454+
/// @brief Print ur_device_get_selected_params_t struct
2455+
/// @returns
2456+
/// - ::UR_RESULT_SUCCESS
2457+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
2458+
/// - `buff_size < out_size`
2459+
UR_APIEXPORT ur_result_t UR_APICALL urPrintDeviceGetSelectedParams(const struct ur_device_get_selected_params_t *params, char *buffer, const size_t buff_size, size_t *out_size);
2460+
24532461
///////////////////////////////////////////////////////////////////////////////
24542462
/// @brief Print ur_device_get_info_params_t struct
24552463
/// @returns

include/ur_print.hpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,9 @@ inline std::ostream &operator<<(std::ostream &os, ur_function_t value) {
909909
case UR_FUNCTION_COMMAND_BUFFER_COMMAND_GET_INFO_EXP:
910910
os << "UR_FUNCTION_COMMAND_BUFFER_COMMAND_GET_INFO_EXP";
911911
break;
912+
case UR_FUNCTION_DEVICE_GET_SELECTED:
913+
os << "UR_FUNCTION_DEVICE_GET_SELECTED";
914+
break;
912915
default:
913916
os << "unknown enumerator";
914917
break;
@@ -16282,6 +16285,48 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
1628216285
return os;
1628316286
}
1628416287

16288+
///////////////////////////////////////////////////////////////////////////////
16289+
/// @brief Print operator for the ur_device_get_selected_params_t type
16290+
/// @returns
16291+
/// std::ostream &
16292+
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_device_get_selected_params_t *params) {
16293+
16294+
os << ".hPlatform = ";
16295+
16296+
ur::details::printPtr(os,
16297+
*(params->phPlatform));
16298+
16299+
os << ", ";
16300+
os << ".DeviceType = ";
16301+
16302+
os << *(params->pDeviceType);
16303+
16304+
os << ", ";
16305+
os << ".NumEntries = ";
16306+
16307+
os << *(params->pNumEntries);
16308+
16309+
os << ", ";
16310+
os << ".phDevices = {";
16311+
for (size_t i = 0; *(params->pphDevices) != NULL && i < *params->pNumEntries; ++i) {
16312+
if (i != 0) {
16313+
os << ", ";
16314+
}
16315+
16316+
ur::details::printPtr(os,
16317+
(*(params->pphDevices))[i]);
16318+
}
16319+
os << "}";
16320+
16321+
os << ", ";
16322+
os << ".pNumDevices = ";
16323+
16324+
ur::details::printPtr(os,
16325+
*(params->ppNumDevices));
16326+
16327+
return os;
16328+
}
16329+
1628516330
///////////////////////////////////////////////////////////////////////////////
1628616331
/// @brief Print operator for the ur_device_get_info_params_t type
1628716332
/// @returns
@@ -17080,6 +17125,9 @@ inline ur_result_t UR_APICALL printFunctionParams(std::ostream &os, ur_function_
1708017125
case UR_FUNCTION_DEVICE_GET: {
1708117126
os << (const struct ur_device_get_params_t *)params;
1708217127
} break;
17128+
case UR_FUNCTION_DEVICE_GET_SELECTED: {
17129+
os << (const struct ur_device_get_selected_params_t *)params;
17130+
} break;
1708317131
case UR_FUNCTION_DEVICE_GET_INFO: {
1708417132
os << (const struct ur_device_get_info_params_t *)params;
1708517133
} break;

scripts/core/device.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,45 @@ returns:
150150
- "`NumEntries > 0 && phDevices == NULL`"
151151
- $X_RESULT_ERROR_INVALID_VALUE
152152
--- #--------------------------------------------------------------------------
153+
type: function
154+
desc: "Retrieves devices within a platform selected by ONEAPI_DEVICE_SELECTOR"
155+
class: $xDevice
156+
loader_only: True
157+
name: GetSelected
158+
decl: static
159+
ordinal: "0"
160+
details:
161+
- "Multiple calls to this function will return identical device handles, in the same order."
162+
- "The number and order of handles returned from this function will be affected by environment variables that filter or select which devices are exposed through this API."
163+
- "A reference is taken for each returned device and must be released with a subsequent call to $xDeviceRelease."
164+
- "The application may call this function from simultaneous threads, the implementation must be thread-safe."
165+
params:
166+
- type: $x_platform_handle_t
167+
name: hPlatform
168+
desc: "[in] handle of the platform instance"
169+
- type: "$x_device_type_t"
170+
name: DeviceType
171+
desc: |
172+
[in] the type of the devices.
173+
- type: "uint32_t"
174+
name: NumEntries
175+
desc: |
176+
[in] the number of devices to be added to phDevices.
177+
If phDevices in not NULL then NumEntries should be greater than zero, otherwise $X_RESULT_ERROR_INVALID_VALUE,
178+
will be returned.
179+
- type: "$x_device_handle_t*"
180+
name: phDevices
181+
desc: |
182+
[out][optional][range(0, NumEntries)] array of handle of devices.
183+
If NumEntries is less than the number of devices available, then only that number of devices will be retrieved.
184+
- type: "uint32_t*"
185+
name: pNumDevices
186+
desc: |
187+
[out][optional] pointer to the number of devices.
188+
pNumDevices will be updated with the total number of selected devices available for the given platform.
189+
returns:
190+
- $X_RESULT_ERROR_INVALID_VALUE
191+
--- #--------------------------------------------------------------------------
153192
type: enum
154193
desc: "Supported device info"
155194
class: $xDevice

scripts/core/registry.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,9 @@ etors:
574574
- name: COMMAND_BUFFER_COMMAND_GET_INFO_EXP
575575
desc: Enumerator for $xCommandBufferCommandGetInfoExp
576576
value: '219'
577+
- name: DEVICE_GET_SELECTED
578+
desc: Enumerator for $xDeviceGetSelected
579+
value: '220'
577580
---
578581
type: enum
579582
desc: Defines structure types

0 commit comments

Comments
 (0)