Skip to content

Commit

Permalink
Alpha version of code for ODS via adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
Wee-Free-Scot committed Dec 8, 2023
1 parent 95db255 commit 22578d2
Show file tree
Hide file tree
Showing 12 changed files with 884 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ if(UR_FORMAT_CPP_STYLE)
message(STATUS "Found clang-format: ${CLANG_FORMAT} (version: ${CLANG_FORMAT_VERSION})")

set(CLANG_FORMAT_REQUIRED "15.0")
if(NOT (CLANG_FORMAT_VERSION VERSION_EQUAL CLANG_FORMAT_REQUIRED))
if(NOT (CLANG_FORMAT_VERSION VERSION_GREATER_EQUAL CLANG_FORMAT_REQUIRED))
message(FATAL_ERROR "required clang-format version is ${CLANG_FORMAT_REQUIRED}")
endif()
else()
Expand Down
1 change: 1 addition & 0 deletions include/ur.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ class ur_function_v(IntEnum):
COMMAND_BUFFER_APPEND_USM_ADVISE_EXP = 213 ## Enumerator for ::urCommandBufferAppendUSMAdviseExp
ENQUEUE_COOPERATIVE_KERNEL_LAUNCH_EXP = 214 ## Enumerator for ::urEnqueueCooperativeKernelLaunchExp
KERNEL_SUGGEST_MAX_COOPERATIVE_GROUP_COUNT_EXP = 215## Enumerator for ::urKernelSuggestMaxCooperativeGroupCountExp
DEVICE_GET_SELECTED = 300 ## Enumerator for ::urDeviceGetSelected

class ur_function_t(c_int):
def __str__(self):
Expand Down
53 changes: 53 additions & 0 deletions include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ typedef enum ur_function_t {
UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_ADVISE_EXP = 213, ///< Enumerator for ::urCommandBufferAppendUSMAdviseExp
UR_FUNCTION_ENQUEUE_COOPERATIVE_KERNEL_LAUNCH_EXP = 214, ///< Enumerator for ::urEnqueueCooperativeKernelLaunchExp
UR_FUNCTION_KERNEL_SUGGEST_MAX_COOPERATIVE_GROUP_COUNT_EXP = 215, ///< Enumerator for ::urKernelSuggestMaxCooperativeGroupCountExp
UR_FUNCTION_DEVICE_GET_SELECTED = 300, ///< Enumerator for ::urDeviceGetSelected
/// @cond
UR_FUNCTION_FORCE_UINT32 = 0x7fffffff
/// @endcond
Expand Down Expand Up @@ -1376,6 +1377,46 @@ urDeviceGet(
///< pNumDevices will be updated with the total number of devices available.
);

///////////////////////////////////////////////////////////////////////////////
/// @brief Retrieves devices within a platform selected by ONEAPI_DEVICE_SELECTOR
///
/// @details
/// - Multiple calls to this function will return identical device handles,
/// in the same order.
/// - 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.
/// - A reference is taken for each returned device and must be released
/// with a subsequent call to ::urDeviceRelease.
/// - The application may call this function from simultaneous threads, the
/// implementation must be thread-safe.
///
/// @returns
/// - ::UR_RESULT_SUCCESS
/// - ::UR_RESULT_ERROR_UNINITIALIZED
/// - ::UR_RESULT_ERROR_DEVICE_LOST
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hPlatform`
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
/// + `::UR_DEVICE_TYPE_VPU < DeviceType`
/// - ::UR_RESULT_ERROR_INVALID_VALUE
UR_APIEXPORT ur_result_t UR_APICALL
urDeviceGetSelected(
ur_platform_handle_t hPlatform, ///< [in] handle of the platform instance
ur_device_type_t DeviceType, ///< [in] the type of the devices.
uint32_t NumEntries, ///< [in] the number of devices to be added to phDevices.
///< If phDevices in not NULL then NumEntries should be greater than zero,
///< otherwise ::UR_RESULT_ERROR_INVALID_VALUE,
///< will be returned.
ur_device_handle_t *phDevices, ///< [out][optional][range(0, NumEntries)] array of handle of devices.
///< If NumEntries is less than the number of devices available, then only
///< that number of devices will be retrieved.
uint32_t *pNumDevices ///< [out][optional] pointer to the number of devices.
///< pNumDevices will be updated with the total number of selected devices
///< available for the given platform.
);

///////////////////////////////////////////////////////////////////////////////
/// @brief Supported device info
typedef enum ur_device_info_t {
Expand Down Expand Up @@ -10814,6 +10855,18 @@ typedef struct ur_device_get_params_t {
uint32_t **ppNumDevices;
} ur_device_get_params_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief Function parameters for urDeviceGetSelected
/// @details Each entry is a pointer to the parameter passed to the function;
/// allowing the callback the ability to modify the parameter's value
typedef struct ur_device_get_selected_params_t {
ur_platform_handle_t *phPlatform;
ur_device_type_t *pDeviceType;
uint32_t *pNumEntries;
ur_device_handle_t **pphDevices;
uint32_t **ppNumDevices;
} ur_device_get_selected_params_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief Function parameters for urDeviceGetInfo
/// @details Each entry is a pointer to the parameter passed to the function;
Expand Down
46 changes: 46 additions & 0 deletions include/ur_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,9 @@ inline std::ostream &operator<<(std::ostream &os, ur_function_t value) {
case UR_FUNCTION_KERNEL_SUGGEST_MAX_COOPERATIVE_GROUP_COUNT_EXP:
os << "UR_FUNCTION_KERNEL_SUGGEST_MAX_COOPERATIVE_GROUP_COUNT_EXP";
break;
case UR_FUNCTION_DEVICE_GET_SELECTED:
os << "UR_FUNCTION_DEVICE_GET_SELECTED";
break;
default:
os << "unknown enumerator";
break;
Expand Down Expand Up @@ -15623,6 +15626,46 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
return os;
}

///////////////////////////////////////////////////////////////////////////////
/// @brief Print operator for the ur_device_get_selected_params_t type
/// @returns
/// std::ostream &
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_device_get_selected_params_t *params) {

os << ".hPlatform = ";

ur::details::printPtr(os, *(params->phPlatform));

os << ", ";
os << ".DeviceType = ";

os << *(params->pDeviceType);

os << ", ";
os << ".NumEntries = ";

os << *(params->pNumEntries);

os << ", ";
os << ".phDevices = {";
for (size_t i = 0;
*(params->pphDevices) != NULL && i < *params->pNumEntries; ++i) {
if (i != 0) {
os << ", ";
}

ur::details::printPtr(os, (*(params->pphDevices))[i]);
}
os << "}";

os << ", ";
os << ".pNumDevices = ";

ur::details::printPtr(os, *(params->ppNumDevices));

return os;
}

///////////////////////////////////////////////////////////////////////////////
/// @brief Print operator for the ur_device_get_info_params_t type
/// @returns
Expand Down Expand Up @@ -16406,6 +16449,9 @@ inline ur_result_t UR_APICALL printFunctionParams(std::ostream &os, ur_function_
case UR_FUNCTION_DEVICE_GET: {
os << (const struct ur_device_get_params_t *)params;
} break;
case UR_FUNCTION_DEVICE_GET_SELECTED: {
os << (const struct ur_device_get_selected_params_t *)params;
} break;
case UR_FUNCTION_DEVICE_GET_INFO: {
os << (const struct ur_device_get_info_params_t *)params;
} break;
Expand Down
39 changes: 39 additions & 0 deletions scripts/core/device.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,45 @@ returns:
- "`NumEntries > 0 && phDevices == NULL`"
- $X_RESULT_ERROR_INVALID_VALUE
--- #--------------------------------------------------------------------------
type: function
desc: "Retrieves devices within a platform selected by ONEAPI_DEVICE_SELECTOR"
class: $xDevice
loader_only: True
name: GetSelected
decl: static
ordinal: "0"
details:
- "Multiple calls to this function will return identical device handles, in the same order."
- "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."
- "A reference is taken for each returned device and must be released with a subsequent call to $xDeviceRelease."
- "The application may call this function from simultaneous threads, the implementation must be thread-safe."
params:
- type: $x_platform_handle_t
name: hPlatform
desc: "[in] handle of the platform instance"
- type: "$x_device_type_t"
name: DeviceType
desc: |
[in] the type of the devices.
- type: "uint32_t"
name: NumEntries
desc: |
[in] the number of devices to be added to phDevices.
If phDevices in not NULL then NumEntries should be greater than zero, otherwise $X_RESULT_ERROR_INVALID_VALUE,
will be returned.
- type: "$x_device_handle_t*"
name: phDevices
desc: |
[out][optional][range(0, NumEntries)] array of handle of devices.
If NumEntries is less than the number of devices available, then only that number of devices will be retrieved.
- type: "uint32_t*"
name: pNumDevices
desc: |
[out][optional] pointer to the number of devices.
pNumDevices will be updated with the total number of selected devices available for the given platform.
returns:
- $X_RESULT_ERROR_INVALID_VALUE
--- #--------------------------------------------------------------------------
type: enum
desc: "Supported device info"
class: $xDevice
Expand Down
3 changes: 3 additions & 0 deletions scripts/core/registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,9 @@ etors:
- name: KERNEL_SUGGEST_MAX_COOPERATIVE_GROUP_COUNT_EXP
desc: Enumerator for $xKernelSuggestMaxCooperativeGroupCountExp
value: '215'
- name: DEVICE_GET_SELECTED
desc: Enumerator for $xDeviceGetSelected
value: '300'
---
type: enum
desc: Defines structure types
Expand Down
Loading

0 comments on commit 22578d2

Please sign in to comment.