From 0e0f34189be33ead53f1eed29f3b0c828b0e1ef0 Mon Sep 17 00:00:00 2001 From: Krzysztof Filipek Date: Thu, 21 May 2026 12:49:45 +0200 Subject: [PATCH 1/4] [spec] add urGraphGetNativeHandleExp and urGraphExecutableGraphGetNativeHandleExp Introduce two experimental APIs to retrieve native graph handles from ur_exp_graph_handle_t and ur_exp_executable_graph_handle_t. --- .../include/unified-runtime/ur_api.h | 70 ++++++++++++ .../include/unified-runtime/ur_api_funcs.def | 2 + .../include/unified-runtime/ur_ddi.h | 13 +++ .../include/unified-runtime/ur_print.h | 22 ++++ .../include/unified-runtime/ur_print.hpp | 55 ++++++++++ unified-runtime/scripts/core/exp-graph.yml | 38 +++++++ unified-runtime/scripts/core/registry.yml | 8 +- .../scripts/templates/mockddi.cpp.mako | 6 +- .../source/adapters/level_zero/graph.cpp | 18 ++++ .../level_zero/ur_interface_loader.cpp | 3 + .../level_zero/ur_interface_loader.hpp | 5 + .../source/adapters/level_zero/v2/graph.cpp | 12 +++ .../source/adapters/mock/ur_mockddi.cpp | 100 ++++++++++++++++++ .../loader/layers/tracing/ur_trcddi.cpp | 89 ++++++++++++++++ .../loader/layers/validation/ur_valddi.cpp | 64 +++++++++++ unified-runtime/source/loader/loader.def.in | 4 + unified-runtime/source/loader/loader.map.in | 4 + unified-runtime/source/loader/ur_ldrddi.cpp | 41 +++++++ unified-runtime/source/loader/ur_libapi.cpp | 68 ++++++++++++ unified-runtime/source/loader/ur_print.cpp | 17 +++ unified-runtime/source/ur_api.cpp | 54 ++++++++++ 21 files changed, 691 insertions(+), 2 deletions(-) diff --git a/unified-runtime/include/unified-runtime/ur_api.h b/unified-runtime/include/unified-runtime/ur_api.h index ce889941d39c6..08148032f0a50 100644 --- a/unified-runtime/include/unified-runtime/ur_api.h +++ b/unified-runtime/include/unified-runtime/ur_api.h @@ -510,6 +510,10 @@ typedef enum ur_function_t { UR_FUNCTION_USM_HOST_ALLOC_UNREGISTER_EXP = 313, /// Enumerator for ::urQueueGetGraphExp UR_FUNCTION_QUEUE_GET_GRAPH_EXP = 314, + /// Enumerator for ::urGraphGetNativeHandleExp + UR_FUNCTION_GRAPH_GET_NATIVE_HANDLE_EXP = 315, + /// Enumerator for ::urGraphExecutableGraphGetNativeHandleExp + UR_FUNCTION_GRAPH_EXECUTABLE_GRAPH_GET_NATIVE_HANDLE_EXP = 316, /// @cond UR_FUNCTION_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -13892,6 +13896,54 @@ UR_APIEXPORT ur_result_t UR_APICALL urGraphDumpContentsExp( /// [in] Path to the file to write the dumped graph contents. const char *filePath); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Return platform native graph handle. +/// +/// @details +/// - Retrieved native handle can be used for direct interaction with the +/// native platform driver. +/// +/// @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 == hGraph` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phNativeGraph` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. +UR_APIEXPORT ur_result_t UR_APICALL urGraphGetNativeHandleExp( + /// [in] Handle of the graph. + ur_exp_graph_handle_t hGraph, + /// [out] A pointer to the native handle of the graph. + ur_native_handle_t *phNativeGraph); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Return platform native executable graph handle. +/// +/// @details +/// - Retrieved native handle can be used for direct interaction with the +/// native platform driver. +/// +/// @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 == hExecutableGraph` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phNativeExecutableGraph` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. +UR_APIEXPORT ur_result_t UR_APICALL urGraphExecutableGraphGetNativeHandleExp( + /// [in] Handle of the executable graph. + ur_exp_executable_graph_handle_t hExecutableGraph, + /// [out] A pointer to the native handle of the executable graph. + ur_native_handle_t *phNativeExecutableGraph); + #if !defined(__GNUC__) #pragma endregion #endif @@ -16423,6 +16475,24 @@ typedef struct ur_graph_dump_contents_exp_params_t { const char **pfilePath; } ur_graph_dump_contents_exp_params_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urGraphGetNativeHandleExp +/// @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_graph_get_native_handle_exp_params_t { + ur_exp_graph_handle_t *phGraph; + ur_native_handle_t **pphNativeGraph; +} ur_graph_get_native_handle_exp_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urGraphExecutableGraphGetNativeHandleExp +/// @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_graph_executable_graph_get_native_handle_exp_params_t { + ur_exp_executable_graph_handle_t *phExecutableGraph; + ur_native_handle_t **pphNativeExecutableGraph; +} ur_graph_executable_graph_get_native_handle_exp_params_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Function parameters for urIPCGetMemHandleExp /// @details Each entry is a pointer to the parameter passed to the function; diff --git a/unified-runtime/include/unified-runtime/ur_api_funcs.def b/unified-runtime/include/unified-runtime/ur_api_funcs.def index c73c88213600f..40341cdaca05a 100644 --- a/unified-runtime/include/unified-runtime/ur_api_funcs.def +++ b/unified-runtime/include/unified-runtime/ur_api_funcs.def @@ -218,6 +218,8 @@ _UR_API(urGraphDestroyExp) _UR_API(urGraphExecutableGraphDestroyExp) _UR_API(urGraphIsEmptyExp) _UR_API(urGraphDumpContentsExp) +_UR_API(urGraphGetNativeHandleExp) +_UR_API(urGraphExecutableGraphGetNativeHandleExp) _UR_API(urIPCGetMemHandleExp) _UR_API(urIPCPutMemHandleExp) _UR_API(urIPCOpenMemHandleExp) diff --git a/unified-runtime/include/unified-runtime/ur_ddi.h b/unified-runtime/include/unified-runtime/ur_ddi.h index 2fda5130c0ed8..92c4aa0e82dbe 100644 --- a/unified-runtime/include/unified-runtime/ur_ddi.h +++ b/unified-runtime/include/unified-runtime/ur_ddi.h @@ -1892,6 +1892,16 @@ typedef ur_result_t(UR_APICALL *ur_pfnGraphIsEmptyExp_t)(ur_exp_graph_handle_t, typedef ur_result_t(UR_APICALL *ur_pfnGraphDumpContentsExp_t)( ur_exp_graph_handle_t, const char *); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urGraphGetNativeHandleExp +typedef ur_result_t(UR_APICALL *ur_pfnGraphGetNativeHandleExp_t)( + ur_exp_graph_handle_t, ur_native_handle_t *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urGraphExecutableGraphGetNativeHandleExp +typedef ur_result_t(UR_APICALL *ur_pfnGraphExecutableGraphGetNativeHandleExp_t)( + ur_exp_executable_graph_handle_t, ur_native_handle_t *); + /////////////////////////////////////////////////////////////////////////////// /// @brief Table of GraphExp functions pointers typedef struct ur_graph_exp_dditable_t { @@ -1901,6 +1911,9 @@ typedef struct ur_graph_exp_dditable_t { ur_pfnGraphExecutableGraphDestroyExp_t pfnExecutableGraphDestroyExp; ur_pfnGraphIsEmptyExp_t pfnIsEmptyExp; ur_pfnGraphDumpContentsExp_t pfnDumpContentsExp; + ur_pfnGraphGetNativeHandleExp_t pfnGetNativeHandleExp; + ur_pfnGraphExecutableGraphGetNativeHandleExp_t + pfnExecutableGraphGetNativeHandleExp; } ur_graph_exp_dditable_t; /////////////////////////////////////////////////////////////////////////////// diff --git a/unified-runtime/include/unified-runtime/ur_print.h b/unified-runtime/include/unified-runtime/ur_print.h index f309275767a0f..05a0310e1be09 100644 --- a/unified-runtime/include/unified-runtime/ur_print.h +++ b/unified-runtime/include/unified-runtime/ur_print.h @@ -3735,6 +3735,28 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintGraphDumpContentsExpParams( const struct ur_graph_dump_contents_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_graph_get_native_handle_exp_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL urPrintGraphGetNativeHandleExpParams( + const struct ur_graph_get_native_handle_exp_params_t *params, char *buffer, + const size_t buff_size, size_t *out_size); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_graph_executable_graph_get_native_handle_exp_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL +urPrintGraphExecutableGraphGetNativeHandleExpParams( + const struct ur_graph_executable_graph_get_native_handle_exp_params_t + *params, + char *buffer, const size_t buff_size, size_t *out_size); + /////////////////////////////////////////////////////////////////////////////// /// @brief Print ur_ipc_get_mem_handle_exp_params_t struct /// @returns diff --git a/unified-runtime/include/unified-runtime/ur_print.hpp b/unified-runtime/include/unified-runtime/ur_print.hpp index fba0340dea515..28d02aa08dba6 100644 --- a/unified-runtime/include/unified-runtime/ur_print.hpp +++ b/unified-runtime/include/unified-runtime/ur_print.hpp @@ -1377,6 +1377,12 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value) { case UR_FUNCTION_QUEUE_GET_GRAPH_EXP: os << "UR_FUNCTION_QUEUE_GET_GRAPH_EXP"; break; + case UR_FUNCTION_GRAPH_GET_NATIVE_HANDLE_EXP: + os << "UR_FUNCTION_GRAPH_GET_NATIVE_HANDLE_EXP"; + break; + case UR_FUNCTION_GRAPH_EXECUTABLE_GRAPH_GET_NATIVE_HANDLE_EXP: + os << "UR_FUNCTION_GRAPH_EXECUTABLE_GRAPH_GET_NATIVE_HANDLE_EXP"; + break; default: os << "unknown enumerator"; break; @@ -21588,6 +21594,48 @@ inline std::ostream &operator<<( return os; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_graph_get_native_handle_exp_params_t type +/// @returns +/// std::ostream & +inline std::ostream & +operator<<(std::ostream &os, + [[maybe_unused]] const struct ur_graph_get_native_handle_exp_params_t + *params) { + + os << ".hGraph = "; + + ur::details::printPtr(os, *(params->phGraph)); + + os << ", "; + os << ".phNativeGraph = "; + + ur::details::printPtr(os, *(params->pphNativeGraph)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the +/// ur_graph_executable_graph_get_native_handle_exp_params_t type +/// @returns +/// std::ostream & +inline std::ostream & +operator<<(std::ostream &os, [[maybe_unused]] const struct + ur_graph_executable_graph_get_native_handle_exp_params_t *params) { + + os << ".hExecutableGraph = "; + + ur::details::printPtr(os, *(params->phExecutableGraph)); + + os << ", "; + os << ".phNativeExecutableGraph = "; + + ur::details::printPtr(os, *(params->pphNativeExecutableGraph)); + + return os; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Print operator for the ur_ipc_get_mem_handle_exp_params_t type /// @returns @@ -23235,6 +23283,13 @@ inline ur_result_t UR_APICALL printFunctionParams(std::ostream &os, case UR_FUNCTION_GRAPH_DUMP_CONTENTS_EXP: { os << (const struct ur_graph_dump_contents_exp_params_t *)params; } break; + case UR_FUNCTION_GRAPH_GET_NATIVE_HANDLE_EXP: { + os << (const struct ur_graph_get_native_handle_exp_params_t *)params; + } break; + case UR_FUNCTION_GRAPH_EXECUTABLE_GRAPH_GET_NATIVE_HANDLE_EXP: { + os << (const struct ur_graph_executable_graph_get_native_handle_exp_params_t + *)params; + } break; case UR_FUNCTION_IPC_GET_MEM_HANDLE_EXP: { os << (const struct ur_ipc_get_mem_handle_exp_params_t *)params; } break; diff --git a/unified-runtime/scripts/core/exp-graph.yml b/unified-runtime/scripts/core/exp-graph.yml index c01465825b6c0..340fb76771568 100644 --- a/unified-runtime/scripts/core/exp-graph.yml +++ b/unified-runtime/scripts/core/exp-graph.yml @@ -198,3 +198,41 @@ params: - type: const char* name: filePath desc: "[in] Path to the file to write the dumped graph contents." +--- #-------------------------------------------------------------------------- +type: function +desc: "Return platform native graph handle." +class: $xGraph +name: GetNativeHandleExp +details: + - "Retrieved native handle can be used for direct interaction with the native platform driver." +params: + - type: "$x_exp_graph_handle_t" + name: hGraph + desc: | + [in] Handle of the graph. + - type: $x_native_handle_t* + name: phNativeGraph + desc: | + [out] A pointer to the native handle of the graph. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." +--- #-------------------------------------------------------------------------- +type: function +desc: "Return platform native executable graph handle." +class: $xGraph +name: ExecutableGraphGetNativeHandleExp +details: + - "Retrieved native handle can be used for direct interaction with the native platform driver." +params: + - type: "$x_exp_executable_graph_handle_t" + name: hExecutableGraph + desc: | + [in] Handle of the executable graph. + - type: $x_native_handle_t* + name: phNativeExecutableGraph + desc: | + [out] A pointer to the native handle of the executable graph. +returns: + - $X_RESULT_ERROR_UNSUPPORTED_FEATURE: + - "If the adapter has no underlying equivalent handle." diff --git a/unified-runtime/scripts/core/registry.yml b/unified-runtime/scripts/core/registry.yml index 6c039b80e41d9..5410e954e276c 100644 --- a/unified-runtime/scripts/core/registry.yml +++ b/unified-runtime/scripts/core/registry.yml @@ -724,7 +724,13 @@ etors: - name: QUEUE_GET_GRAPH_EXP desc: Enumerator for $xQueueGetGraphExp value: '314' -max_id: '314' +- name: GRAPH_GET_NATIVE_HANDLE_EXP + desc: Enumerator for $xGraphGetNativeHandleExp + value: '315' +- name: GRAPH_EXECUTABLE_GRAPH_GET_NATIVE_HANDLE_EXP + desc: Enumerator for $xGraphExecutableGraphGetNativeHandleExp + value: '316' +max_id: '316' --- type: enum desc: Defines structure types diff --git a/unified-runtime/scripts/templates/mockddi.cpp.mako b/unified-runtime/scripts/templates/mockddi.cpp.mako index f362d85d04645..37ce59e18ed43 100644 --- a/unified-runtime/scripts/templates/mockddi.cpp.mako +++ b/unified-runtime/scripts/templates/mockddi.cpp.mako @@ -73,7 +73,11 @@ namespace driver *ph${func_class} = reinterpret_cast(hNative${func_class}); mock::retainDummyHandle(*ph${func_class}); %else: - *phNative${func_class} = reinterpret_cast(h${func_class}); + <% + native_out = th.find_param_name("^phNative.*", n, tags, obj) + obj_in = th.find_param_name("^h(?!Native).*", n, tags, obj) + %> + *${native_out} = reinterpret_cast(${obj_in}); %endif ## These special cases handle memory stuff. Use verbose regex matching ## to limit the possibility of unintentional stuff getting generated for diff --git a/unified-runtime/source/adapters/level_zero/graph.cpp b/unified-runtime/source/adapters/level_zero/graph.cpp index 58b010549b26e..19faf917e92f4 100644 --- a/unified-runtime/source/adapters/level_zero/graph.cpp +++ b/unified-runtime/source/adapters/level_zero/graph.cpp @@ -61,4 +61,22 @@ ur_result_t urGraphInstantiateGraphExp( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } +ur_result_t +urGraphGetNativeHandleExp(ur_exp_graph_handle_t /* hGraph */, + ur_native_handle_t * /* phNativeGraph */) { + UR_LOG_LEGACY(ERR, + logger::LegacyMessage("[UR][L0] {} function not implemented!"), + "{} function not implemented!", __FUNCTION__); + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +ur_result_t urGraphExecutableGraphGetNativeHandleExp( + ur_exp_executable_graph_handle_t /* hExecutableGraph */, + ur_native_handle_t * /* phNativeExecutableGraph */) { + UR_LOG_LEGACY(ERR, + logger::LegacyMessage("[UR][L0] {} function not implemented!"), + "{} function not implemented!", __FUNCTION__); + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + } // namespace ur::level_zero diff --git a/unified-runtime/source/adapters/level_zero/ur_interface_loader.cpp b/unified-runtime/source/adapters/level_zero/ur_interface_loader.cpp index 877a4d199c44a..2e74045b67aec 100644 --- a/unified-runtime/source/adapters/level_zero/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/level_zero/ur_interface_loader.cpp @@ -276,6 +276,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urGetGraphExpProcAddrTable( ur::level_zero::urGraphExecutableGraphDestroyExp; pDdiTable->pfnIsEmptyExp = ur::level_zero::urGraphIsEmptyExp; pDdiTable->pfnDumpContentsExp = ur::level_zero::urGraphDumpContentsExp; + pDdiTable->pfnGetNativeHandleExp = ur::level_zero::urGraphGetNativeHandleExp; + pDdiTable->pfnExecutableGraphGetNativeHandleExp = + ur::level_zero::urGraphExecutableGraphGetNativeHandleExp; return result; } diff --git a/unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp b/unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp index a4a9e9819a95e..924ede83d9f4c 100644 --- a/unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp +++ b/unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp @@ -867,6 +867,11 @@ ur_result_t urQueueGetGraphExp(ur_queue_handle_t hQueue, ur_result_t urGraphIsEmptyExp(ur_exp_graph_handle_t hGraph, bool *pResult); ur_result_t urGraphDumpContentsExp(ur_exp_graph_handle_t hGraph, const char *filePath); +ur_result_t urGraphGetNativeHandleExp(ur_exp_graph_handle_t hGraph, + ur_native_handle_t *phNativeGraph); +ur_result_t urGraphExecutableGraphGetNativeHandleExp( + ur_exp_executable_graph_handle_t hExecutableGraph, + ur_native_handle_t *phNativeExecutableGraph); #ifdef UR_STATIC_ADAPTER_LEVEL_ZERO ur_result_t urAdapterGetDdiTables(ur_dditable_t *ddi); #endif diff --git a/unified-runtime/source/adapters/level_zero/v2/graph.cpp b/unified-runtime/source/adapters/level_zero/v2/graph.cpp index f05da04ccd3b0..650c49f7421a9 100644 --- a/unified-runtime/source/adapters/level_zero/v2/graph.cpp +++ b/unified-runtime/source/adapters/level_zero/v2/graph.cpp @@ -142,4 +142,16 @@ ur_result_t urGraphDumpContentsExp(ur_exp_graph_handle_t hGraph, return UR_RESULT_SUCCESS; } +ur_result_t +urGraphGetNativeHandleExp(ur_exp_graph_handle_t /* hGraph */, + ur_native_handle_t * /* phNativeGraph */) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +ur_result_t urGraphExecutableGraphGetNativeHandleExp( + ur_exp_executable_graph_handle_t /* hExecutableGraph */, + ur_native_handle_t * /* phNativeExecutableGraph */) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + } // namespace ur::level_zero diff --git a/unified-runtime/source/adapters/mock/ur_mockddi.cpp b/unified-runtime/source/adapters/mock/ur_mockddi.cpp index 00145e81d7afc..685e1c17a38c0 100644 --- a/unified-runtime/source/adapters/mock/ur_mockddi.cpp +++ b/unified-runtime/source/adapters/mock/ur_mockddi.cpp @@ -12995,6 +12995,101 @@ __urdlllocal ur_result_t UR_APICALL urGraphDumpContentsExp( return exceptionToResult(std::current_exception()); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphGetNativeHandleExp +__urdlllocal ur_result_t UR_APICALL urGraphGetNativeHandleExp( + /// [in] Handle of the graph. + ur_exp_graph_handle_t hGraph, + /// [out] A pointer to the native handle of the graph. + ur_native_handle_t *phNativeGraph) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_graph_get_native_handle_exp_params_t params = {&hGraph, &phNativeGraph}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback("urGraphGetNativeHandleExp")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback("urGraphGetNativeHandleExp")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + *phNativeGraph = reinterpret_cast(hGraph); + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback("urGraphGetNativeHandleExp")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphExecutableGraphGetNativeHandleExp +__urdlllocal ur_result_t UR_APICALL urGraphExecutableGraphGetNativeHandleExp( + /// [in] Handle of the executable graph. + ur_exp_executable_graph_handle_t hExecutableGraph, + /// [out] A pointer to the native handle of the executable graph. + ur_native_handle_t *phNativeExecutableGraph) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_graph_executable_graph_get_native_handle_exp_params_t params = { + &hExecutableGraph, &phNativeExecutableGraph}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback( + "urGraphExecutableGraphGetNativeHandleExp")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback( + "urGraphExecutableGraphGetNativeHandleExp")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + *phNativeExecutableGraph = + reinterpret_cast(hExecutableGraph); + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback( + "urGraphExecutableGraphGetNativeHandleExp")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + } // namespace driver extern "C" { @@ -13458,6 +13553,11 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGraphExpProcAddrTable( pDdiTable->pfnDumpContentsExp = driver::urGraphDumpContentsExp; + pDdiTable->pfnGetNativeHandleExp = driver::urGraphGetNativeHandleExp; + + pDdiTable->pfnExecutableGraphGetNativeHandleExp = + driver::urGraphExecutableGraphGetNativeHandleExp; + return result; } catch (...) { return exceptionToResult(std::current_exception()); diff --git a/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp b/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp index 6d6ac7919f4d8..bd5073e400a24 100644 --- a/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp +++ b/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp @@ -11019,6 +11019,86 @@ __urdlllocal ur_result_t UR_APICALL urGraphDumpContentsExp( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphGetNativeHandleExp +__urdlllocal ur_result_t UR_APICALL urGraphGetNativeHandleExp( + /// [in] Handle of the graph. + ur_exp_graph_handle_t hGraph, + /// [out] A pointer to the native handle of the graph. + ur_native_handle_t *phNativeGraph) { + auto pfnGetNativeHandleExp = + getContext()->urDdiTable.GraphExp.pfnGetNativeHandleExp; + + if (nullptr == pfnGetNativeHandleExp) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_graph_get_native_handle_exp_params_t params = {&hGraph, &phNativeGraph}; + uint64_t instance = + getContext()->notify_begin(UR_FUNCTION_GRAPH_GET_NATIVE_HANDLE_EXP, + "urGraphGetNativeHandleExp", ¶ms); + + auto &logger = getContext()->logger; + UR_LOG_L(logger, INFO, " ---> urGraphGetNativeHandleExp\n"); + + ur_result_t result = pfnGetNativeHandleExp(hGraph, phNativeGraph); + + getContext()->notify_end(UR_FUNCTION_GRAPH_GET_NATIVE_HANDLE_EXP, + "urGraphGetNativeHandleExp", ¶ms, &result, + instance); + + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams( + args_str, UR_FUNCTION_GRAPH_GET_NATIVE_HANDLE_EXP, ¶ms); + UR_LOG_L(logger, INFO, " <--- urGraphGetNativeHandleExp({}) -> {};\n", + args_str.str(), result); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphExecutableGraphGetNativeHandleExp +__urdlllocal ur_result_t UR_APICALL urGraphExecutableGraphGetNativeHandleExp( + /// [in] Handle of the executable graph. + ur_exp_executable_graph_handle_t hExecutableGraph, + /// [out] A pointer to the native handle of the executable graph. + ur_native_handle_t *phNativeExecutableGraph) { + auto pfnExecutableGraphGetNativeHandleExp = + getContext()->urDdiTable.GraphExp.pfnExecutableGraphGetNativeHandleExp; + + if (nullptr == pfnExecutableGraphGetNativeHandleExp) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_graph_executable_graph_get_native_handle_exp_params_t params = { + &hExecutableGraph, &phNativeExecutableGraph}; + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_GRAPH_EXECUTABLE_GRAPH_GET_NATIVE_HANDLE_EXP, + "urGraphExecutableGraphGetNativeHandleExp", ¶ms); + + auto &logger = getContext()->logger; + UR_LOG_L(logger, INFO, " ---> urGraphExecutableGraphGetNativeHandleExp\n"); + + ur_result_t result = pfnExecutableGraphGetNativeHandleExp( + hExecutableGraph, phNativeExecutableGraph); + + getContext()->notify_end( + UR_FUNCTION_GRAPH_EXECUTABLE_GRAPH_GET_NATIVE_HANDLE_EXP, + "urGraphExecutableGraphGetNativeHandleExp", ¶ms, &result, instance); + + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams( + args_str, UR_FUNCTION_GRAPH_EXECUTABLE_GRAPH_GET_NATIVE_HANDLE_EXP, + ¶ms); + UR_LOG_L(logger, INFO, + " <--- urGraphExecutableGraphGetNativeHandleExp({}) -> {};\n", + args_str.str(), result); + } + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's Adapter table /// with current process' addresses @@ -11641,6 +11721,15 @@ __urdlllocal ur_result_t UR_APICALL urGetGraphExpProcAddrTable( dditable.pfnDumpContentsExp = pDdiTable->pfnDumpContentsExp; pDdiTable->pfnDumpContentsExp = ur_tracing_layer::urGraphDumpContentsExp; + dditable.pfnGetNativeHandleExp = pDdiTable->pfnGetNativeHandleExp; + pDdiTable->pfnGetNativeHandleExp = + ur_tracing_layer::urGraphGetNativeHandleExp; + + dditable.pfnExecutableGraphGetNativeHandleExp = + pDdiTable->pfnExecutableGraphGetNativeHandleExp; + pDdiTable->pfnExecutableGraphGetNativeHandleExp = + ur_tracing_layer::urGraphExecutableGraphGetNativeHandleExp; + return result; } /////////////////////////////////////////////////////////////////////////////// diff --git a/unified-runtime/source/loader/layers/validation/ur_valddi.cpp b/unified-runtime/source/loader/layers/validation/ur_valddi.cpp index 7b9a2f5b0982d..2af428ba597a7 100644 --- a/unified-runtime/source/loader/layers/validation/ur_valddi.cpp +++ b/unified-runtime/source/loader/layers/validation/ur_valddi.cpp @@ -11788,6 +11788,61 @@ __urdlllocal ur_result_t UR_APICALL urGraphDumpContentsExp( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphGetNativeHandleExp +__urdlllocal ur_result_t UR_APICALL urGraphGetNativeHandleExp( + /// [in] Handle of the graph. + ur_exp_graph_handle_t hGraph, + /// [out] A pointer to the native handle of the graph. + ur_native_handle_t *phNativeGraph) { + auto pfnGetNativeHandleExp = + getContext()->urDdiTable.GraphExp.pfnGetNativeHandleExp; + + if (nullptr == pfnGetNativeHandleExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == phNativeGraph) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL == hGraph) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + ur_result_t result = pfnGetNativeHandleExp(hGraph, phNativeGraph); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphExecutableGraphGetNativeHandleExp +__urdlllocal ur_result_t UR_APICALL urGraphExecutableGraphGetNativeHandleExp( + /// [in] Handle of the executable graph. + ur_exp_executable_graph_handle_t hExecutableGraph, + /// [out] A pointer to the native handle of the executable graph. + ur_native_handle_t *phNativeExecutableGraph) { + auto pfnExecutableGraphGetNativeHandleExp = + getContext()->urDdiTable.GraphExp.pfnExecutableGraphGetNativeHandleExp; + + if (nullptr == pfnExecutableGraphGetNativeHandleExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == phNativeExecutableGraph) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL == hExecutableGraph) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + ur_result_t result = pfnExecutableGraphGetNativeHandleExp( + hExecutableGraph, phNativeExecutableGraph); + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's Adapter table /// with current process' addresses @@ -12424,6 +12479,15 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGraphExpProcAddrTable( dditable.pfnDumpContentsExp = pDdiTable->pfnDumpContentsExp; pDdiTable->pfnDumpContentsExp = ur_validation_layer::urGraphDumpContentsExp; + dditable.pfnGetNativeHandleExp = pDdiTable->pfnGetNativeHandleExp; + pDdiTable->pfnGetNativeHandleExp = + ur_validation_layer::urGraphGetNativeHandleExp; + + dditable.pfnExecutableGraphGetNativeHandleExp = + pDdiTable->pfnExecutableGraphGetNativeHandleExp; + pDdiTable->pfnExecutableGraphGetNativeHandleExp = + ur_validation_layer::urGraphExecutableGraphGetNativeHandleExp; + return result; } diff --git a/unified-runtime/source/loader/loader.def.in b/unified-runtime/source/loader/loader.def.in index 8faa938b745f0..0e4016885dab7 100644 --- a/unified-runtime/source/loader/loader.def.in +++ b/unified-runtime/source/loader/loader.def.in @@ -143,6 +143,8 @@ EXPORTS urGraphDestroyExp urGraphDumpContentsExp urGraphExecutableGraphDestroyExp + urGraphExecutableGraphGetNativeHandleExp + urGraphGetNativeHandleExp urGraphInstantiateGraphExp urGraphIsEmptyExp urIPCCloseMemHandleExp @@ -387,6 +389,8 @@ EXPORTS urPrintGraphDestroyExpParams urPrintGraphDumpContentsExpParams urPrintGraphExecutableGraphDestroyExpParams + urPrintGraphExecutableGraphGetNativeHandleExpParams + urPrintGraphGetNativeHandleExpParams urPrintGraphInstantiateGraphExpParams urPrintGraphIsEmptyExpParams urPrintImageChannelOrder diff --git a/unified-runtime/source/loader/loader.map.in b/unified-runtime/source/loader/loader.map.in index b7f9f3428a5f5..f52719cac2de3 100644 --- a/unified-runtime/source/loader/loader.map.in +++ b/unified-runtime/source/loader/loader.map.in @@ -143,6 +143,8 @@ urGraphDestroyExp; urGraphDumpContentsExp; urGraphExecutableGraphDestroyExp; + urGraphExecutableGraphGetNativeHandleExp; + urGraphGetNativeHandleExp; urGraphInstantiateGraphExp; urGraphIsEmptyExp; urIPCCloseMemHandleExp; @@ -387,6 +389,8 @@ urPrintGraphDestroyExpParams; urPrintGraphDumpContentsExpParams; urPrintGraphExecutableGraphDestroyExpParams; + urPrintGraphExecutableGraphGetNativeHandleExpParams; + urPrintGraphGetNativeHandleExpParams; urPrintGraphInstantiateGraphExpParams; urPrintGraphIsEmptyExpParams; urPrintImageChannelOrder; diff --git a/unified-runtime/source/loader/ur_ldrddi.cpp b/unified-runtime/source/loader/ur_ldrddi.cpp index 7ac726f9c9cb1..09b5f11bdb8e2 100644 --- a/unified-runtime/source/loader/ur_ldrddi.cpp +++ b/unified-runtime/source/loader/ur_ldrddi.cpp @@ -6245,6 +6245,44 @@ __urdlllocal ur_result_t UR_APICALL urGraphDumpContentsExp( return pfnDumpContentsExp(hGraph, filePath); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphGetNativeHandleExp +__urdlllocal ur_result_t UR_APICALL urGraphGetNativeHandleExp( + /// [in] Handle of the graph. + ur_exp_graph_handle_t hGraph, + /// [out] A pointer to the native handle of the graph. + ur_native_handle_t *phNativeGraph) { + + auto *dditable = *reinterpret_cast(hGraph); + + auto *pfnGetNativeHandleExp = dditable->GraphExp.pfnGetNativeHandleExp; + if (nullptr == pfnGetNativeHandleExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + // forward to device-platform + return pfnGetNativeHandleExp(hGraph, phNativeGraph); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphExecutableGraphGetNativeHandleExp +__urdlllocal ur_result_t UR_APICALL urGraphExecutableGraphGetNativeHandleExp( + /// [in] Handle of the executable graph. + ur_exp_executable_graph_handle_t hExecutableGraph, + /// [out] A pointer to the native handle of the executable graph. + ur_native_handle_t *phNativeExecutableGraph) { + + auto *dditable = *reinterpret_cast(hExecutableGraph); + + auto *pfnExecutableGraphGetNativeHandleExp = + dditable->GraphExp.pfnExecutableGraphGetNativeHandleExp; + if (nullptr == pfnExecutableGraphGetNativeHandleExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + // forward to device-platform + return pfnExecutableGraphGetNativeHandleExp(hExecutableGraph, + phNativeExecutableGraph); +} + } // namespace ur_loader extern "C" { @@ -6818,6 +6856,9 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGraphExpProcAddrTable( ur_loader::urGraphExecutableGraphDestroyExp; pDdiTable->pfnIsEmptyExp = ur_loader::urGraphIsEmptyExp; pDdiTable->pfnDumpContentsExp = ur_loader::urGraphDumpContentsExp; + pDdiTable->pfnGetNativeHandleExp = ur_loader::urGraphGetNativeHandleExp; + pDdiTable->pfnExecutableGraphGetNativeHandleExp = + ur_loader::urGraphExecutableGraphGetNativeHandleExp; } else { // return pointers directly to platform's DDIs *pDdiTable = ur_loader::getContext()->platforms.front().dditable.GraphExp; diff --git a/unified-runtime/source/loader/ur_libapi.cpp b/unified-runtime/source/loader/ur_libapi.cpp index 51f6ca8ee556f..bf43cc40d97f4 100644 --- a/unified-runtime/source/loader/ur_libapi.cpp +++ b/unified-runtime/source/loader/ur_libapi.cpp @@ -11373,4 +11373,72 @@ ur_result_t UR_APICALL urGraphDumpContentsExp( return exceptionToResult(std::current_exception()); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Return platform native graph handle. +/// +/// @details +/// - Retrieved native handle can be used for direct interaction with the +/// native platform driver. +/// +/// @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 == hGraph` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phNativeGraph` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. +ur_result_t UR_APICALL urGraphGetNativeHandleExp( + /// [in] Handle of the graph. + ur_exp_graph_handle_t hGraph, + /// [out] A pointer to the native handle of the graph. + ur_native_handle_t *phNativeGraph) try { + auto pfnGetNativeHandleExp = + ur_lib::getContext()->urDdiTable.GraphExp.pfnGetNativeHandleExp; + if (nullptr == pfnGetNativeHandleExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnGetNativeHandleExp(hGraph, phNativeGraph); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Return platform native executable graph handle. +/// +/// @details +/// - Retrieved native handle can be used for direct interaction with the +/// native platform driver. +/// +/// @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 == hExecutableGraph` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phNativeExecutableGraph` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. +ur_result_t UR_APICALL urGraphExecutableGraphGetNativeHandleExp( + /// [in] Handle of the executable graph. + ur_exp_executable_graph_handle_t hExecutableGraph, + /// [out] A pointer to the native handle of the executable graph. + ur_native_handle_t *phNativeExecutableGraph) try { + auto pfnExecutableGraphGetNativeHandleExp = + ur_lib::getContext() + ->urDdiTable.GraphExp.pfnExecutableGraphGetNativeHandleExp; + if (nullptr == pfnExecutableGraphGetNativeHandleExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnExecutableGraphGetNativeHandleExp(hExecutableGraph, + phNativeExecutableGraph); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + } // extern "C" diff --git a/unified-runtime/source/loader/ur_print.cpp b/unified-runtime/source/loader/ur_print.cpp index f500efa52e864..4278ebb613d81 100644 --- a/unified-runtime/source/loader/ur_print.cpp +++ b/unified-runtime/source/loader/ur_print.cpp @@ -2163,6 +2163,23 @@ ur_result_t urPrintGraphDumpContentsExpParams( return str_copy(&ss, buffer, buff_size, out_size); } +ur_result_t urPrintGraphGetNativeHandleExpParams( + const struct ur_graph_get_native_handle_exp_params_t *params, char *buffer, + const size_t buff_size, size_t *out_size) { + std::stringstream ss; + ss << params; + return str_copy(&ss, buffer, buff_size, out_size); +} + +ur_result_t urPrintGraphExecutableGraphGetNativeHandleExpParams( + const struct ur_graph_executable_graph_get_native_handle_exp_params_t + *params, + char *buffer, const size_t buff_size, size_t *out_size) { + std::stringstream ss; + ss << params; + return str_copy(&ss, buffer, buff_size, out_size); +} + ur_result_t urPrintIpcGetMemHandleExpParams( const struct ur_ipc_get_mem_handle_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size) { diff --git a/unified-runtime/source/ur_api.cpp b/unified-runtime/source/ur_api.cpp index 81dcda1a4fcb6..fa282d9db600e 100644 --- a/unified-runtime/source/ur_api.cpp +++ b/unified-runtime/source/ur_api.cpp @@ -9870,3 +9870,57 @@ ur_result_t UR_APICALL urGraphDumpContentsExp( ur_result_t result = UR_RESULT_SUCCESS; return result; } + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Return platform native graph handle. +/// +/// @details +/// - Retrieved native handle can be used for direct interaction with the +/// native platform driver. +/// +/// @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 == hGraph` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phNativeGraph` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. +ur_result_t UR_APICALL urGraphGetNativeHandleExp( + /// [in] Handle of the graph. + ur_exp_graph_handle_t hGraph, + /// [out] A pointer to the native handle of the graph. + ur_native_handle_t *phNativeGraph) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Return platform native executable graph handle. +/// +/// @details +/// - Retrieved native handle can be used for direct interaction with the +/// native platform driver. +/// +/// @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 == hExecutableGraph` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phNativeExecutableGraph` +/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + If the adapter has no underlying equivalent handle. +ur_result_t UR_APICALL urGraphExecutableGraphGetNativeHandleExp( + /// [in] Handle of the executable graph. + ur_exp_executable_graph_handle_t hExecutableGraph, + /// [out] A pointer to the native handle of the executable graph. + ur_native_handle_t *phNativeExecutableGraph) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} From f3ecffcaf48f5925ca3eab2d9a7d3af18143670b Mon Sep 17 00:00:00 2001 From: Krzysztof Filipek Date: Thu, 21 May 2026 12:50:39 +0200 Subject: [PATCH 2/4] [L0v2] implement urGraphGetNativeHandleExp and urGraphExecutableGraphGetNativeHandleExp --- .../source/adapters/level_zero/v2/graph.cpp | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/unified-runtime/source/adapters/level_zero/v2/graph.cpp b/unified-runtime/source/adapters/level_zero/v2/graph.cpp index 650c49f7421a9..f94207ad6c3db 100644 --- a/unified-runtime/source/adapters/level_zero/v2/graph.cpp +++ b/unified-runtime/source/adapters/level_zero/v2/graph.cpp @@ -142,16 +142,30 @@ ur_result_t urGraphDumpContentsExp(ur_exp_graph_handle_t hGraph, return UR_RESULT_SUCCESS; } -ur_result_t -urGraphGetNativeHandleExp(ur_exp_graph_handle_t /* hGraph */, - ur_native_handle_t * /* phNativeGraph */) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +ur_result_t urGraphGetNativeHandleExp(ur_exp_graph_handle_t hGraph, + ur_native_handle_t *phNativeGraph) try { + ur_context_handle_t hContext = hGraph->getContext(); + if (!checkGraphExtensionSupport(hContext)) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + *phNativeGraph = reinterpret_cast(hGraph->getZeHandle()); + return UR_RESULT_SUCCESS; +} catch (...) { + return exceptionToResult(std::current_exception()); } ur_result_t urGraphExecutableGraphGetNativeHandleExp( - ur_exp_executable_graph_handle_t /* hExecutableGraph */, - ur_native_handle_t * /* phNativeExecutableGraph */) { - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + ur_exp_executable_graph_handle_t hExecutableGraph, + ur_native_handle_t *phNativeExecutableGraph) try { + ur_context_handle_t hContext = hExecutableGraph->getContext(); + if (!checkGraphExtensionSupport(hContext)) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + *phNativeExecutableGraph = + reinterpret_cast(hExecutableGraph->getZeHandle()); + return UR_RESULT_SUCCESS; +} catch (...) { + return exceptionToResult(std::current_exception()); } } // namespace ur::level_zero From 1707340c34252294bb69ce368551cd62a367b66f Mon Sep 17 00:00:00 2001 From: Krzysztof Filipek Date: Thu, 21 May 2026 12:53:09 +0200 Subject: [PATCH 3/4] [adapters] Implement stubs urGraph*GetNativeHandleExp in non-L0 adapters --- unified-runtime/source/adapters/cuda/graph.cpp | 12 ++++++++++++ .../source/adapters/cuda/ur_interface_loader.cpp | 3 +++ unified-runtime/source/adapters/hip/graph.cpp | 12 ++++++++++++ .../source/adapters/hip/ur_interface_loader.cpp | 3 +++ .../source/adapters/native_cpu/graph.cpp | 14 ++++++++++++++ .../adapters/native_cpu/ur_interface_loader.cpp | 3 +++ unified-runtime/source/adapters/offload/graph.cpp | 12 ++++++++++++ .../adapters/offload/ur_interface_loader.cpp | 3 +++ unified-runtime/source/adapters/opencl/graph.cpp | 12 ++++++++++++ .../source/adapters/opencl/ur_interface_loader.cpp | 3 +++ 10 files changed, 77 insertions(+) diff --git a/unified-runtime/source/adapters/cuda/graph.cpp b/unified-runtime/source/adapters/cuda/graph.cpp index f7526b4d0a590..91526bc90ba29 100644 --- a/unified-runtime/source/adapters/cuda/graph.cpp +++ b/unified-runtime/source/adapters/cuda/graph.cpp @@ -39,3 +39,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urGraphInstantiateGraphExp( ur_exp_executable_graph_handle_t * /* phExecutableGraph */) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } + +UR_APIEXPORT ur_result_t UR_APICALL urGraphGetNativeHandleExp( + ur_exp_graph_handle_t /* hGraph */, + ur_native_handle_t * /* phNativeGraph */) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t UR_APICALL urGraphExecutableGraphGetNativeHandleExp( + ur_exp_executable_graph_handle_t /* hExecutableGraph */, + ur_native_handle_t * /* phNativeExecutableGraph */) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} diff --git a/unified-runtime/source/adapters/cuda/ur_interface_loader.cpp b/unified-runtime/source/adapters/cuda/ur_interface_loader.cpp index cfff918f90302..33ee40c13835b 100644 --- a/unified-runtime/source/adapters/cuda/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/cuda/ur_interface_loader.cpp @@ -90,6 +90,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urGetGraphExpProcAddrTable( pDdiTable->pfnExecutableGraphDestroyExp = urGraphExecutableGraphDestroyExp; pDdiTable->pfnIsEmptyExp = urGraphIsEmptyExp; pDdiTable->pfnDumpContentsExp = urGraphDumpContentsExp; + pDdiTable->pfnGetNativeHandleExp = urGraphGetNativeHandleExp; + pDdiTable->pfnExecutableGraphGetNativeHandleExp = + urGraphExecutableGraphGetNativeHandleExp; return UR_RESULT_SUCCESS; } diff --git a/unified-runtime/source/adapters/hip/graph.cpp b/unified-runtime/source/adapters/hip/graph.cpp index 48f9271ce8726..a218b00084223 100644 --- a/unified-runtime/source/adapters/hip/graph.cpp +++ b/unified-runtime/source/adapters/hip/graph.cpp @@ -39,3 +39,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urGraphInstantiateGraphExp( ur_exp_executable_graph_handle_t * /* phExecutableGraph */) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } + +UR_APIEXPORT ur_result_t UR_APICALL urGraphGetNativeHandleExp( + ur_exp_graph_handle_t /* hGraph */, + ur_native_handle_t * /* phNativeGraph */) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t UR_APICALL urGraphExecutableGraphGetNativeHandleExp( + ur_exp_executable_graph_handle_t /* hExecutableGraph */, + ur_native_handle_t * /* phNativeExecutableGraph */) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} diff --git a/unified-runtime/source/adapters/hip/ur_interface_loader.cpp b/unified-runtime/source/adapters/hip/ur_interface_loader.cpp index 8152546927bf5..007838a35d4ed 100644 --- a/unified-runtime/source/adapters/hip/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/hip/ur_interface_loader.cpp @@ -90,6 +90,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urGetGraphExpProcAddrTable( pDdiTable->pfnExecutableGraphDestroyExp = urGraphExecutableGraphDestroyExp; pDdiTable->pfnIsEmptyExp = urGraphIsEmptyExp; pDdiTable->pfnDumpContentsExp = urGraphDumpContentsExp; + pDdiTable->pfnGetNativeHandleExp = urGraphGetNativeHandleExp; + pDdiTable->pfnExecutableGraphGetNativeHandleExp = + urGraphExecutableGraphGetNativeHandleExp; return UR_RESULT_SUCCESS; } diff --git a/unified-runtime/source/adapters/native_cpu/graph.cpp b/unified-runtime/source/adapters/native_cpu/graph.cpp index 9135921bb567c..f368c259815ff 100644 --- a/unified-runtime/source/adapters/native_cpu/graph.cpp +++ b/unified-runtime/source/adapters/native_cpu/graph.cpp @@ -45,3 +45,17 @@ UR_APIEXPORT ur_result_t UR_APICALL urGraphInstantiateGraphExp( DIE_NO_IMPLEMENTATION; } + +UR_APIEXPORT ur_result_t UR_APICALL urGraphGetNativeHandleExp( + ur_exp_graph_handle_t /* hGraph */, + ur_native_handle_t * /* phNativeGraph */) { + + DIE_NO_IMPLEMENTATION; +} + +UR_APIEXPORT ur_result_t UR_APICALL urGraphExecutableGraphGetNativeHandleExp( + ur_exp_executable_graph_handle_t /* hExecutableGraph */, + ur_native_handle_t * /* phNativeExecutableGraph */) { + + DIE_NO_IMPLEMENTATION; +} diff --git a/unified-runtime/source/adapters/native_cpu/ur_interface_loader.cpp b/unified-runtime/source/adapters/native_cpu/ur_interface_loader.cpp index bc1183e1c9ce4..8400f7cf34e3d 100644 --- a/unified-runtime/source/adapters/native_cpu/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/native_cpu/ur_interface_loader.cpp @@ -90,6 +90,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urGetGraphExpProcAddrTable( pDdiTable->pfnExecutableGraphDestroyExp = urGraphExecutableGraphDestroyExp; pDdiTable->pfnIsEmptyExp = urGraphIsEmptyExp; pDdiTable->pfnDumpContentsExp = urGraphDumpContentsExp; + pDdiTable->pfnGetNativeHandleExp = urGraphGetNativeHandleExp; + pDdiTable->pfnExecutableGraphGetNativeHandleExp = + urGraphExecutableGraphGetNativeHandleExp; return UR_RESULT_SUCCESS; } diff --git a/unified-runtime/source/adapters/offload/graph.cpp b/unified-runtime/source/adapters/offload/graph.cpp index a1346eed7cba2..8eba0bfdd64a7 100644 --- a/unified-runtime/source/adapters/offload/graph.cpp +++ b/unified-runtime/source/adapters/offload/graph.cpp @@ -39,3 +39,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urGraphInstantiateGraphExp( ur_exp_executable_graph_handle_t * /* phExecutableGraph */) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } + +UR_APIEXPORT ur_result_t UR_APICALL urGraphGetNativeHandleExp( + ur_exp_graph_handle_t /* hGraph */, + ur_native_handle_t * /* phNativeGraph */) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t UR_APICALL urGraphExecutableGraphGetNativeHandleExp( + ur_exp_executable_graph_handle_t /* hExecutableGraph */, + ur_native_handle_t * /* phNativeExecutableGraph */) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} diff --git a/unified-runtime/source/adapters/offload/ur_interface_loader.cpp b/unified-runtime/source/adapters/offload/ur_interface_loader.cpp index 69d9aafaf4a69..c9ed4f44d9da1 100644 --- a/unified-runtime/source/adapters/offload/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/offload/ur_interface_loader.cpp @@ -90,6 +90,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urGetGraphExpProcAddrTable( pDdiTable->pfnExecutableGraphDestroyExp = urGraphExecutableGraphDestroyExp; pDdiTable->pfnIsEmptyExp = urGraphIsEmptyExp; pDdiTable->pfnDumpContentsExp = urGraphDumpContentsExp; + pDdiTable->pfnGetNativeHandleExp = urGraphGetNativeHandleExp; + pDdiTable->pfnExecutableGraphGetNativeHandleExp = + urGraphExecutableGraphGetNativeHandleExp; return UR_RESULT_SUCCESS; } diff --git a/unified-runtime/source/adapters/opencl/graph.cpp b/unified-runtime/source/adapters/opencl/graph.cpp index 158dbb9617c47..4b8043b20ecf8 100644 --- a/unified-runtime/source/adapters/opencl/graph.cpp +++ b/unified-runtime/source/adapters/opencl/graph.cpp @@ -39,3 +39,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urGraphInstantiateGraphExp( ur_exp_executable_graph_handle_t * /* phExecutableGraph */) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } + +UR_APIEXPORT ur_result_t UR_APICALL urGraphGetNativeHandleExp( + ur_exp_graph_handle_t /* hGraph */, + ur_native_handle_t * /* phNativeGraph */) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +UR_APIEXPORT ur_result_t UR_APICALL urGraphExecutableGraphGetNativeHandleExp( + ur_exp_executable_graph_handle_t /* hExecutableGraph */, + ur_native_handle_t * /* phNativeExecutableGraph */) { + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} diff --git a/unified-runtime/source/adapters/opencl/ur_interface_loader.cpp b/unified-runtime/source/adapters/opencl/ur_interface_loader.cpp index 8e1c9ee94b8c3..b3f54f66b3862 100644 --- a/unified-runtime/source/adapters/opencl/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/opencl/ur_interface_loader.cpp @@ -505,6 +505,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urGetGraphExpProcAddrTable( pDdiTable->pfnExecutableGraphDestroyExp = urGraphExecutableGraphDestroyExp; pDdiTable->pfnIsEmptyExp = urGraphIsEmptyExp; pDdiTable->pfnDumpContentsExp = urGraphDumpContentsExp; + pDdiTable->pfnGetNativeHandleExp = urGraphGetNativeHandleExp; + pDdiTable->pfnExecutableGraphGetNativeHandleExp = + urGraphExecutableGraphGetNativeHandleExp; return UR_RESULT_SUCCESS; } From 6713213396cb16e093cf551e405ab6cebca74a55 Mon Sep 17 00:00:00 2001 From: Krzysztof Filipek Date: Fri, 22 May 2026 16:33:17 +0200 Subject: [PATCH 4/4] Alignment to code formatting rules Co-authored-by: Cursor --- .../include/unified-runtime/ur_api.h | 12 +++--- .../include/unified-runtime/ur_api_funcs.def | 2 +- .../include/unified-runtime/ur_ddi.h | 39 +++++++++++++++---- .../include/unified-runtime/ur_print.h | 7 ++-- .../include/unified-runtime/ur_print.hpp | 14 +++---- unified-runtime/scripts/core/exp-graph.yml | 4 +- unified-runtime/scripts/core/registry.yml | 4 +- .../scripts/templates/mockddi.cpp.mako | 6 +-- .../source/adapters/cuda/graph.cpp | 6 +-- unified-runtime/source/adapters/hip/graph.cpp | 6 +-- .../source/adapters/native_cpu/graph.cpp | 6 +-- .../source/adapters/offload/graph.cpp | 6 +-- .../source/adapters/opencl/graph.cpp | 6 +-- unified-runtime/source/ur_api.cpp | 2 +- 14 files changed, 70 insertions(+), 50 deletions(-) diff --git a/unified-runtime/include/unified-runtime/ur_api.h b/unified-runtime/include/unified-runtime/ur_api.h index 08148032f0a50..8aadc23285552 100644 --- a/unified-runtime/include/unified-runtime/ur_api.h +++ b/unified-runtime/include/unified-runtime/ur_api.h @@ -512,8 +512,8 @@ typedef enum ur_function_t { UR_FUNCTION_QUEUE_GET_GRAPH_EXP = 314, /// Enumerator for ::urGraphGetNativeHandleExp UR_FUNCTION_GRAPH_GET_NATIVE_HANDLE_EXP = 315, - /// Enumerator for ::urGraphExecutableGraphGetNativeHandleExp - UR_FUNCTION_GRAPH_EXECUTABLE_GRAPH_GET_NATIVE_HANDLE_EXP = 316, + /// Enumerator for ::urExecutableGraphGetNativeHandleExp + UR_FUNCTION_EXECUTABLE_GRAPH_GET_NATIVE_HANDLE_EXP = 316, /// @cond UR_FUNCTION_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -13938,7 +13938,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urGraphGetNativeHandleExp( /// + `NULL == phNativeExecutableGraph` /// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE /// + If the adapter has no underlying equivalent handle. -UR_APIEXPORT ur_result_t UR_APICALL urGraphExecutableGraphGetNativeHandleExp( +UR_APIEXPORT ur_result_t UR_APICALL urExecutableGraphGetNativeHandleExp( /// [in] Handle of the executable graph. ur_exp_executable_graph_handle_t hExecutableGraph, /// [out] A pointer to the native handle of the executable graph. @@ -16485,13 +16485,13 @@ typedef struct ur_graph_get_native_handle_exp_params_t { } ur_graph_get_native_handle_exp_params_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Function parameters for urGraphExecutableGraphGetNativeHandleExp +/// @brief Function parameters for urExecutableGraphGetNativeHandleExp /// @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_graph_executable_graph_get_native_handle_exp_params_t { +typedef struct ur_executable_graph_get_native_handle_exp_params_t { ur_exp_executable_graph_handle_t *phExecutableGraph; ur_native_handle_t **pphNativeExecutableGraph; -} ur_graph_executable_graph_get_native_handle_exp_params_t; +} ur_executable_graph_get_native_handle_exp_params_t; /////////////////////////////////////////////////////////////////////////////// /// @brief Function parameters for urIPCGetMemHandleExp diff --git a/unified-runtime/include/unified-runtime/ur_api_funcs.def b/unified-runtime/include/unified-runtime/ur_api_funcs.def index 40341cdaca05a..4f2a6dc3fddb5 100644 --- a/unified-runtime/include/unified-runtime/ur_api_funcs.def +++ b/unified-runtime/include/unified-runtime/ur_api_funcs.def @@ -219,7 +219,7 @@ _UR_API(urGraphExecutableGraphDestroyExp) _UR_API(urGraphIsEmptyExp) _UR_API(urGraphDumpContentsExp) _UR_API(urGraphGetNativeHandleExp) -_UR_API(urGraphExecutableGraphGetNativeHandleExp) +_UR_API(urExecutableGraphGetNativeHandleExp) _UR_API(urIPCGetMemHandleExp) _UR_API(urIPCPutMemHandleExp) _UR_API(urIPCOpenMemHandleExp) diff --git a/unified-runtime/include/unified-runtime/ur_ddi.h b/unified-runtime/include/unified-runtime/ur_ddi.h index 92c4aa0e82dbe..d602118aa1703 100644 --- a/unified-runtime/include/unified-runtime/ur_ddi.h +++ b/unified-runtime/include/unified-runtime/ur_ddi.h @@ -1897,11 +1897,6 @@ typedef ur_result_t(UR_APICALL *ur_pfnGraphDumpContentsExp_t)( typedef ur_result_t(UR_APICALL *ur_pfnGraphGetNativeHandleExp_t)( ur_exp_graph_handle_t, ur_native_handle_t *); -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for urGraphExecutableGraphGetNativeHandleExp -typedef ur_result_t(UR_APICALL *ur_pfnGraphExecutableGraphGetNativeHandleExp_t)( - ur_exp_executable_graph_handle_t, ur_native_handle_t *); - /////////////////////////////////////////////////////////////////////////////// /// @brief Table of GraphExp functions pointers typedef struct ur_graph_exp_dditable_t { @@ -1912,8 +1907,6 @@ typedef struct ur_graph_exp_dditable_t { ur_pfnGraphIsEmptyExp_t pfnIsEmptyExp; ur_pfnGraphDumpContentsExp_t pfnDumpContentsExp; ur_pfnGraphGetNativeHandleExp_t pfnGetNativeHandleExp; - ur_pfnGraphExecutableGraphGetNativeHandleExp_t - pfnExecutableGraphGetNativeHandleExp; } ur_graph_exp_dditable_t; /////////////////////////////////////////////////////////////////////////////// @@ -1936,6 +1929,37 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGraphExpProcAddrTable( typedef ur_result_t(UR_APICALL *ur_pfnGetGraphExpProcAddrTable_t)( ur_api_version_t, ur_graph_exp_dditable_t *); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urExecutableGraphGetNativeHandleExp +typedef ur_result_t(UR_APICALL *ur_pfnExecutableGraphGetNativeHandleExp_t)( + ur_exp_executable_graph_handle_t, ur_native_handle_t *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Table of ExecutableGraphExp functions pointers +typedef struct ur_executable_graph_exp_dditable_t { + ur_pfnExecutableGraphGetNativeHandleExp_t pfnGetNativeHandleExp; +} ur_executable_graph_exp_dditable_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's ExecutableGraphExp table +/// with current process' addresses +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_UNINITIALIZED +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION +UR_DLLEXPORT ur_result_t UR_APICALL urGetExecutableGraphExpProcAddrTable( + /// [in] API version requested + ur_api_version_t version, + /// [in,out] pointer to table of DDI function pointers + ur_executable_graph_exp_dditable_t *pDdiTable); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urGetExecutableGraphExpProcAddrTable +typedef ur_result_t(UR_APICALL *ur_pfnGetExecutableGraphExpProcAddrTable_t)( + ur_api_version_t, ur_executable_graph_exp_dditable_t *); + /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urIPCGetMemHandleExp typedef ur_result_t(UR_APICALL *ur_pfnIPCGetMemHandleExp_t)(ur_context_handle_t, @@ -2280,6 +2304,7 @@ typedef struct ur_dditable_t { ur_bindless_images_exp_dditable_t BindlessImagesExp; ur_command_buffer_exp_dditable_t CommandBufferExp; ur_graph_exp_dditable_t GraphExp; + ur_executable_graph_exp_dditable_t ExecutableGraphExp; ur_ipc_exp_dditable_t IPCExp; ur_memory_export_exp_dditable_t MemoryExportExp; ur_usm_p2p_exp_dditable_t UsmP2PExp; diff --git a/unified-runtime/include/unified-runtime/ur_print.h b/unified-runtime/include/unified-runtime/ur_print.h index 05a0310e1be09..4ace0c54ccff3 100644 --- a/unified-runtime/include/unified-runtime/ur_print.h +++ b/unified-runtime/include/unified-runtime/ur_print.h @@ -3746,15 +3746,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintGraphGetNativeHandleExpParams( const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// -/// @brief Print ur_graph_executable_graph_get_native_handle_exp_params_t struct +/// @brief Print ur_executable_graph_get_native_handle_exp_params_t struct /// @returns /// - ::UR_RESULT_SUCCESS /// - ::UR_RESULT_ERROR_INVALID_SIZE /// - `buff_size < out_size` UR_APIEXPORT ur_result_t UR_APICALL -urPrintGraphExecutableGraphGetNativeHandleExpParams( - const struct ur_graph_executable_graph_get_native_handle_exp_params_t - *params, +urPrintExecutableGraphGetNativeHandleExpParams( + const struct ur_executable_graph_get_native_handle_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); /////////////////////////////////////////////////////////////////////////////// diff --git a/unified-runtime/include/unified-runtime/ur_print.hpp b/unified-runtime/include/unified-runtime/ur_print.hpp index 28d02aa08dba6..d3e69187ed3c5 100644 --- a/unified-runtime/include/unified-runtime/ur_print.hpp +++ b/unified-runtime/include/unified-runtime/ur_print.hpp @@ -1380,8 +1380,8 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value) { case UR_FUNCTION_GRAPH_GET_NATIVE_HANDLE_EXP: os << "UR_FUNCTION_GRAPH_GET_NATIVE_HANDLE_EXP"; break; - case UR_FUNCTION_GRAPH_EXECUTABLE_GRAPH_GET_NATIVE_HANDLE_EXP: - os << "UR_FUNCTION_GRAPH_EXECUTABLE_GRAPH_GET_NATIVE_HANDLE_EXP"; + case UR_FUNCTION_EXECUTABLE_GRAPH_GET_NATIVE_HANDLE_EXP: + os << "UR_FUNCTION_EXECUTABLE_GRAPH_GET_NATIVE_HANDLE_EXP"; break; default: os << "unknown enumerator"; @@ -21617,12 +21617,12 @@ operator<<(std::ostream &os, /////////////////////////////////////////////////////////////////////////////// /// @brief Print operator for the -/// ur_graph_executable_graph_get_native_handle_exp_params_t type +/// ur_executable_graph_get_native_handle_exp_params_t type /// @returns /// std::ostream & inline std::ostream & operator<<(std::ostream &os, [[maybe_unused]] const struct - ur_graph_executable_graph_get_native_handle_exp_params_t *params) { + ur_executable_graph_get_native_handle_exp_params_t *params) { os << ".hExecutableGraph = "; @@ -23286,9 +23286,9 @@ inline ur_result_t UR_APICALL printFunctionParams(std::ostream &os, case UR_FUNCTION_GRAPH_GET_NATIVE_HANDLE_EXP: { os << (const struct ur_graph_get_native_handle_exp_params_t *)params; } break; - case UR_FUNCTION_GRAPH_EXECUTABLE_GRAPH_GET_NATIVE_HANDLE_EXP: { - os << (const struct ur_graph_executable_graph_get_native_handle_exp_params_t - *)params; + case UR_FUNCTION_EXECUTABLE_GRAPH_GET_NATIVE_HANDLE_EXP: { + os << (const struct ur_executable_graph_get_native_handle_exp_params_t *) + params; } break; case UR_FUNCTION_IPC_GET_MEM_HANDLE_EXP: { os << (const struct ur_ipc_get_mem_handle_exp_params_t *)params; diff --git a/unified-runtime/scripts/core/exp-graph.yml b/unified-runtime/scripts/core/exp-graph.yml index 340fb76771568..75a5e0e209df3 100644 --- a/unified-runtime/scripts/core/exp-graph.yml +++ b/unified-runtime/scripts/core/exp-graph.yml @@ -220,8 +220,8 @@ returns: --- #-------------------------------------------------------------------------- type: function desc: "Return platform native executable graph handle." -class: $xGraph -name: ExecutableGraphGetNativeHandleExp +class: $xExecutableGraph +name: GetNativeHandleExp details: - "Retrieved native handle can be used for direct interaction with the native platform driver." params: diff --git a/unified-runtime/scripts/core/registry.yml b/unified-runtime/scripts/core/registry.yml index 5410e954e276c..2a4d853a001e9 100644 --- a/unified-runtime/scripts/core/registry.yml +++ b/unified-runtime/scripts/core/registry.yml @@ -727,8 +727,8 @@ etors: - name: GRAPH_GET_NATIVE_HANDLE_EXP desc: Enumerator for $xGraphGetNativeHandleExp value: '315' -- name: GRAPH_EXECUTABLE_GRAPH_GET_NATIVE_HANDLE_EXP - desc: Enumerator for $xGraphExecutableGraphGetNativeHandleExp +- name: EXECUTABLE_GRAPH_GET_NATIVE_HANDLE_EXP + desc: Enumerator for $xExecutableGraphGetNativeHandleExp value: '316' max_id: '316' --- diff --git a/unified-runtime/scripts/templates/mockddi.cpp.mako b/unified-runtime/scripts/templates/mockddi.cpp.mako index 37ce59e18ed43..f362d85d04645 100644 --- a/unified-runtime/scripts/templates/mockddi.cpp.mako +++ b/unified-runtime/scripts/templates/mockddi.cpp.mako @@ -73,11 +73,7 @@ namespace driver *ph${func_class} = reinterpret_cast(hNative${func_class}); mock::retainDummyHandle(*ph${func_class}); %else: - <% - native_out = th.find_param_name("^phNative.*", n, tags, obj) - obj_in = th.find_param_name("^h(?!Native).*", n, tags, obj) - %> - *${native_out} = reinterpret_cast(${obj_in}); + *phNative${func_class} = reinterpret_cast(h${func_class}); %endif ## These special cases handle memory stuff. Use verbose regex matching ## to limit the possibility of unintentional stuff getting generated for diff --git a/unified-runtime/source/adapters/cuda/graph.cpp b/unified-runtime/source/adapters/cuda/graph.cpp index 91526bc90ba29..7d4eca8d4258e 100644 --- a/unified-runtime/source/adapters/cuda/graph.cpp +++ b/unified-runtime/source/adapters/cuda/graph.cpp @@ -40,9 +40,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urGraphInstantiateGraphExp( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } -UR_APIEXPORT ur_result_t UR_APICALL urGraphGetNativeHandleExp( - ur_exp_graph_handle_t /* hGraph */, - ur_native_handle_t * /* phNativeGraph */) { +UR_APIEXPORT ur_result_t UR_APICALL +urGraphGetNativeHandleExp(ur_exp_graph_handle_t /* hGraph */, + ur_native_handle_t * /* phNativeGraph */) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/unified-runtime/source/adapters/hip/graph.cpp b/unified-runtime/source/adapters/hip/graph.cpp index a218b00084223..dbbfd0fb54ac3 100644 --- a/unified-runtime/source/adapters/hip/graph.cpp +++ b/unified-runtime/source/adapters/hip/graph.cpp @@ -40,9 +40,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urGraphInstantiateGraphExp( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } -UR_APIEXPORT ur_result_t UR_APICALL urGraphGetNativeHandleExp( - ur_exp_graph_handle_t /* hGraph */, - ur_native_handle_t * /* phNativeGraph */) { +UR_APIEXPORT ur_result_t UR_APICALL +urGraphGetNativeHandleExp(ur_exp_graph_handle_t /* hGraph */, + ur_native_handle_t * /* phNativeGraph */) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/unified-runtime/source/adapters/native_cpu/graph.cpp b/unified-runtime/source/adapters/native_cpu/graph.cpp index f368c259815ff..1bce83048b05b 100644 --- a/unified-runtime/source/adapters/native_cpu/graph.cpp +++ b/unified-runtime/source/adapters/native_cpu/graph.cpp @@ -46,9 +46,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urGraphInstantiateGraphExp( DIE_NO_IMPLEMENTATION; } -UR_APIEXPORT ur_result_t UR_APICALL urGraphGetNativeHandleExp( - ur_exp_graph_handle_t /* hGraph */, - ur_native_handle_t * /* phNativeGraph */) { +UR_APIEXPORT ur_result_t UR_APICALL +urGraphGetNativeHandleExp(ur_exp_graph_handle_t /* hGraph */, + ur_native_handle_t * /* phNativeGraph */) { DIE_NO_IMPLEMENTATION; } diff --git a/unified-runtime/source/adapters/offload/graph.cpp b/unified-runtime/source/adapters/offload/graph.cpp index 8eba0bfdd64a7..5428f1ce8066e 100644 --- a/unified-runtime/source/adapters/offload/graph.cpp +++ b/unified-runtime/source/adapters/offload/graph.cpp @@ -40,9 +40,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urGraphInstantiateGraphExp( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } -UR_APIEXPORT ur_result_t UR_APICALL urGraphGetNativeHandleExp( - ur_exp_graph_handle_t /* hGraph */, - ur_native_handle_t * /* phNativeGraph */) { +UR_APIEXPORT ur_result_t UR_APICALL +urGraphGetNativeHandleExp(ur_exp_graph_handle_t /* hGraph */, + ur_native_handle_t * /* phNativeGraph */) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/unified-runtime/source/adapters/opencl/graph.cpp b/unified-runtime/source/adapters/opencl/graph.cpp index 4b8043b20ecf8..a1d7e12a1ba5c 100644 --- a/unified-runtime/source/adapters/opencl/graph.cpp +++ b/unified-runtime/source/adapters/opencl/graph.cpp @@ -40,9 +40,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urGraphInstantiateGraphExp( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } -UR_APIEXPORT ur_result_t UR_APICALL urGraphGetNativeHandleExp( - ur_exp_graph_handle_t /* hGraph */, - ur_native_handle_t * /* phNativeGraph */) { +UR_APIEXPORT ur_result_t UR_APICALL +urGraphGetNativeHandleExp(ur_exp_graph_handle_t /* hGraph */, + ur_native_handle_t * /* phNativeGraph */) { return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/unified-runtime/source/ur_api.cpp b/unified-runtime/source/ur_api.cpp index fa282d9db600e..ec434e5ee976c 100644 --- a/unified-runtime/source/ur_api.cpp +++ b/unified-runtime/source/ur_api.cpp @@ -9916,7 +9916,7 @@ ur_result_t UR_APICALL urGraphGetNativeHandleExp( /// + `NULL == phNativeExecutableGraph` /// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE /// + If the adapter has no underlying equivalent handle. -ur_result_t UR_APICALL urGraphExecutableGraphGetNativeHandleExp( +ur_result_t UR_APICALL urExecutableGraphGetNativeHandleExp( /// [in] Handle of the executable graph. ur_exp_executable_graph_handle_t hExecutableGraph, /// [out] A pointer to the native handle of the executable graph.