Skip to content

Commit

Permalink
Add function signature for urDeviceGetSelected into ur_lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Wee-Free-Scot committed Aug 30, 2023
1 parent cc6e781 commit 8ace849
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 145 deletions.
3 changes: 0 additions & 3 deletions scripts/templates/ldrddi.cpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ namespace ur_loader
if( ${X}_RESULT_SUCCESS == result && ${obj['params'][4]['name']} != nullptr )
*${obj['params'][4]['name']} = total_platform_handle_count;

%elif re.match(r"\w+GetSelected$", th.make_func_name(n, tags, obj)):
/* DAN was here */

%else:
<%param_replacements={}%>
%for i, item in enumerate(th.get_loader_prologue(n, tags, obj, meta)):
Expand Down
38 changes: 0 additions & 38 deletions source/adapters/null/ur_nullddi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,44 +350,6 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGet(
return exceptionToResult(std::current_exception());
}

///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for urDeviceGetSelected
__urdlllocal 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.
) try {
ur_result_t result = UR_RESULT_SUCCESS;

// if the driver has created a custom function, then call it instead of using the generic path
auto pfnGetSelected = d_context.urDdiTable.Device.pfnGetSelected;
if (nullptr != pfnGetSelected) {
result = pfnGetSelected(hPlatform, DeviceType, NumEntries, phDevices,
pNumDevices);
} else {
// generic implementation
for (size_t i = 0; (nullptr != phDevices) && (i < NumEntries); ++i) {
phDevices[i] =
reinterpret_cast<ur_device_handle_t>(d_context.get());
}
}

return result;
} catch (...) {
return exceptionToResult(std::current_exception());
}

///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for urDeviceGetInfo
__urdlllocal ur_result_t UR_APICALL urDeviceGetInfo(
Expand Down
1 change: 0 additions & 1 deletion source/common/ur_params.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,6 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value) {
case UR_FUNCTION_DEVICE_GET_SELECTED:
os << "UR_FUNCTION_DEVICE_GET_SELECTED";
break;

default:
os << "unknown enumerator";
break;
Expand Down
38 changes: 0 additions & 38 deletions source/loader/layers/tracing/ur_trcddi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,44 +387,6 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGet(
return result;
}

///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for urDeviceGetSelected
__urdlllocal 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.
) {
auto pfnGetSelected = context.urDdiTable.Device.pfnGetSelected;

if (nullptr == pfnGetSelected) {
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

ur_device_get_selected_params_t params = {
&hPlatform, &DeviceType, &NumEntries, &phDevices, &pNumDevices};
uint64_t instance = context.notify_begin(UR_FUNCTION_DEVICE_GET_SELECTED,
"urDeviceGetSelected", &params);

ur_result_t result = pfnGetSelected(hPlatform, DeviceType, NumEntries,
phDevices, pNumDevices);

context.notify_end(UR_FUNCTION_DEVICE_GET_SELECTED, "urDeviceGetSelected",
&params, &result, instance);

return result;
}

///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for urDeviceGetInfo
__urdlllocal ur_result_t UR_APICALL urDeviceGetInfo(
Expand Down
40 changes: 0 additions & 40 deletions source/loader/layers/validation/ur_valddi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,46 +430,6 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGet(
return result;
}

///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for urDeviceGetSelected
__urdlllocal 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.
) {
auto pfnGetSelected = context.urDdiTable.Device.pfnGetSelected;

if (nullptr == pfnGetSelected) {
return UR_RESULT_ERROR_UNINITIALIZED;
}

if (context.enableParameterValidation) {
if (NULL == hPlatform) {
return UR_RESULT_ERROR_INVALID_NULL_HANDLE;
}

if (UR_DEVICE_TYPE_VPU < DeviceType) {
return UR_RESULT_ERROR_INVALID_ENUMERATION;
}
}

ur_result_t result = pfnGetSelected(hPlatform, DeviceType, NumEntries,
phDevices, pNumDevices);

return result;
}

///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for urDeviceGetInfo
__urdlllocal ur_result_t UR_APICALL urDeviceGetInfo(
Expand Down
25 changes: 0 additions & 25 deletions source/loader/ur_ldrddi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,31 +483,6 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGet(
return result;
}

///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for urDeviceGetSelected
__urdlllocal 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.
) {
ur_result_t result = UR_RESULT_SUCCESS;

/* DAN was here */

return result;
}

///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for urDeviceGetInfo
__urdlllocal ur_result_t UR_APICALL urDeviceGetInfo(
Expand Down
7 changes: 7 additions & 0 deletions source/loader/ur_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,11 @@ ur_result_t urLoaderTearDown() {

return UR_RESULT_SUCCESS;
}
ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform,
ur_device_type_t DeviceType,
uint32_t NumEntries,
ur_device_handle_t *phDevices,
uint32_t *pNumDevices) {
return UR_RESULT_SUCCESS;
}
} // namespace ur_lib
5 changes: 5 additions & 0 deletions source/loader/ur_lib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,10 @@ ur_result_t urLoaderConfigGetInfo(ur_loader_config_handle_t hLoaderConfig,
ur_result_t urLoaderConfigEnableLayer(ur_loader_config_handle_t hLoaderConfig,
const char *pLayerName);
ur_result_t urLoaderTearDown();
ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform,
ur_device_type_t DeviceType,
uint32_t NumEntries,
ur_device_handle_t *phDevices,
uint32_t *pNumDevices);
} // namespace ur_lib
#endif /* UR_LOADER_LIB_H */

0 comments on commit 8ace849

Please sign in to comment.