[L0v2] Add retrieval of native graph handle#22097
Draft
KFilipek wants to merge 4 commits into
Draft
Conversation
…iveHandleExp Introduce two experimental APIs to retrieve native graph handles from ur_exp_graph_handle_t and ur_exp_executable_graph_handle_t.
…GetNativeHandleExp
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds two new experimental Unified Runtime (UR) Graph entry points to retrieve the underlying native graph/executable-graph handle, enabling direct interop with the backend driver (implemented for Level Zero v2, stubbed elsewhere) and plumbed through the loader and its layers.
Changes:
- Introduces
urGraphGetNativeHandleExpandurGraphExecutableGraphGetNativeHandleExpacross the public API, DDI tables, loader exports, and tracing/validation layers. - Implements native handle retrieval in the Level Zero v2 adapter; other adapters expose the functions as unsupported/not implemented.
- Updates printing/logging and code-generation inputs/templates to recognize and format the new APIs.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| unified-runtime/source/ur_api.cpp | Adds stub API entry points for graph native-handle retrieval. |
| unified-runtime/source/loader/ur_print.cpp | Adds parameter-print helpers for the new graph APIs. |
| unified-runtime/source/loader/ur_libapi.cpp | Adds loader dispatch for the new graph native-handle APIs. |
| unified-runtime/source/loader/ur_ldrddi.cpp | Adds loader intercept/DDI wiring for the new graph native-handle APIs. |
| unified-runtime/source/loader/loader.map.in | Exports new loader symbols for the graph native-handle APIs and their print helpers. |
| unified-runtime/source/loader/loader.def.in | Exports new loader symbols for Windows builds. |
| unified-runtime/source/loader/layers/validation/ur_valddi.cpp | Adds validation-layer intercepts and parameter checks for the new APIs. |
| unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp | Adds tracing-layer intercepts, logging, and callbacks for the new APIs. |
| unified-runtime/source/adapters/opencl/ur_interface_loader.cpp | Wires new function pointers into the OpenCL adapter’s GraphExp proc table. |
| unified-runtime/source/adapters/opencl/graph.cpp | Adds OpenCL stubs returning unsupported for the new APIs. |
| unified-runtime/source/adapters/offload/ur_interface_loader.cpp | Wires new function pointers into the offload adapter’s GraphExp proc table. |
| unified-runtime/source/adapters/offload/graph.cpp | Adds offload stubs returning unsupported for the new APIs. |
| unified-runtime/source/adapters/native_cpu/ur_interface_loader.cpp | Wires new function pointers into the native_cpu adapter’s GraphExp proc table. |
| unified-runtime/source/adapters/native_cpu/graph.cpp | Adds native_cpu stubs (DIE_NO_IMPLEMENTATION) for the new APIs. |
| unified-runtime/source/adapters/mock/ur_mockddi.cpp | Adds mock-layer intercepts for the new graph native-handle APIs. |
| unified-runtime/source/adapters/level_zero/v2/graph.cpp | Implements native handle retrieval for Level Zero v2 graphs/executable graphs. |
| unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp | Declares Level Zero adapter entry points for the new APIs. |
| unified-runtime/source/adapters/level_zero/ur_interface_loader.cpp | Wires Level Zero adapter function pointers for the new APIs. |
| unified-runtime/source/adapters/level_zero/graph.cpp | Adds Level Zero (non-v2) stubs returning unsupported for the new APIs. |
| unified-runtime/source/adapters/hip/ur_interface_loader.cpp | Wires HIP adapter function pointers for the new APIs. |
| unified-runtime/source/adapters/hip/graph.cpp | Adds HIP stubs returning unsupported for the new APIs. |
| unified-runtime/source/adapters/cuda/ur_interface_loader.cpp | Wires CUDA adapter function pointers for the new APIs. |
| unified-runtime/source/adapters/cuda/graph.cpp | Adds CUDA stubs returning unsupported for the new APIs. |
| unified-runtime/scripts/templates/mockddi.cpp.mako | Generalizes mock native-handle generation for output/input parameter naming. |
| unified-runtime/scripts/core/registry.yml | Adds new ur_function_t enumerators for tracing/callback identification. |
| unified-runtime/scripts/core/exp-graph.yml | Defines the new experimental Graph API functions for code generation. |
| unified-runtime/include/unified-runtime/ur_print.hpp | Adds enum printing + params-struct printing for the new APIs. |
| unified-runtime/include/unified-runtime/ur_print.h | Declares new print helper functions for params structs. |
| unified-runtime/include/unified-runtime/ur_ddi.h | Extends GraphExp DDI table with new function pointers. |
| unified-runtime/include/unified-runtime/ur_api.h | Declares the new APIs, new ur_function_t enumerators, and callback params structs. |
| unified-runtime/include/unified-runtime/ur_api_funcs.def | Registers the new APIs in the function list used for generation/export. |
Comment on lines
+9892
to
+9899
| 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; | ||
| } |
Comment on lines
+9919
to
+9926
| 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. | ||
| ur_native_handle_t *phNativeExecutableGraph) { | ||
| ur_result_t result = UR_RESULT_SUCCESS; | ||
| return result; | ||
| } |
Comment on lines
+13917
to
+13945
| 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 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. | ||
| ur_native_handle_t *phNativeExecutableGraph); |
Co-authored-by: Cursor <cursoragent@cursor.com>
23587ef to
6713213
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces two new experimental entry points to expose the underlying
native graph handle from a UR graph.