diff --git a/unified-runtime/include/ur_api.h b/unified-runtime/include/ur_api.h index a3c2816a2036c..5303610161b4b 100644 --- a/unified-runtime/include/ur_api.h +++ b/unified-runtime/include/ur_api.h @@ -489,6 +489,28 @@ typedef enum ur_function_t { UR_FUNCTION_PROGRAM_DYNAMIC_LINK_EXP = 294, /// Enumerator for ::urEnqueueKernelLaunchWithArgsExp UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH_WITH_ARGS_EXP = 295, + /// Enumerator for ::urGraphCreateExp + UR_FUNCTION_GRAPH_CREATE_EXP = 296, + /// Enumerator for ::urQueueBeginGraphCaptureExp + UR_FUNCTION_QUEUE_BEGIN_GRAPH_CAPTURE_EXP = 297, + /// Enumerator for ::urQueueBeginCaptureIntoGraphExp + UR_FUNCTION_QUEUE_BEGIN_CAPTURE_INTO_GRAPH_EXP = 298, + /// Enumerator for ::urQueueEndGraphCaptureExp + UR_FUNCTION_QUEUE_END_GRAPH_CAPTURE_EXP = 299, + /// Enumerator for ::urQueueAppendGraphExp + UR_FUNCTION_QUEUE_APPEND_GRAPH_EXP = 301, + /// Enumerator for ::urGraphDestroyExp + UR_FUNCTION_GRAPH_DESTROY_EXP = 302, + /// Enumerator for ::urGraphExecutableGraphDestroyExp + UR_FUNCTION_GRAPH_EXECUTABLE_GRAPH_DESTROY_EXP = 303, + /// Enumerator for ::urQueueIsGraphCaptureEnabledExp + UR_FUNCTION_QUEUE_IS_GRAPH_CAPTURE_ENABLED_EXP = 304, + /// Enumerator for ::urGraphIsEmptyExp + UR_FUNCTION_GRAPH_IS_EMPTY_EXP = 305, + /// Enumerator for ::urGraphDumpContentsExp + UR_FUNCTION_GRAPH_DUMP_CONTENTS_EXP = 306, + /// Enumerator for ::urGraphInstantiateGraphExp + UR_FUNCTION_GRAPH_INSTANTIATE_GRAPH_EXP = 307, /// @cond UR_FUNCTION_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -900,6 +922,8 @@ typedef enum ur_result_t { UR_RESULT_ERROR_DEVICE_NOT_AVAILABLE = 69, /// A specialization constant identifier is not valid. UR_RESULT_ERROR_INVALID_SPEC_ID = 70, + /// A graph object is not valid. + UR_RESULT_ERROR_INVALID_GRAPH = 71, /// Invalid Command-Buffer UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP = 0x1000, /// Sync point is not valid for the command-buffer @@ -13467,6 +13491,260 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueNativeCommandExp( /// array. ur_event_handle_t *phEvent); +#if !defined(__GNUC__) +#pragma endregion +#endif +// Intel 'oneAPI' Unified Runtime Experimental APIs for Graph Record and Replay +#if !defined(__GNUC__) +#pragma region graph_(experimental) +#endif +/////////////////////////////////////////////////////////////////////////////// +/// @brief Handle of record & replay graph object +typedef struct ur_exp_graph_handle_t_ *ur_exp_graph_handle_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Handle of record & replay executable graph object +typedef struct ur_exp_executable_graph_handle_t_ + *ur_exp_executable_graph_handle_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Create a new record & replay graph instance explicitly. +/// +/// @details +/// - Create a new record & replay graph instance explicitly. +/// +/// @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 == hContext` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phGraph` +/// + `NULL == pNext` +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +UR_APIEXPORT ur_result_t UR_APICALL urGraphCreateExp( + /// [in] Handle of the context object. + ur_context_handle_t hContext, + /// [out][alloc] Pointer to the handle of the created graph object. + ur_exp_graph_handle_t *phGraph, + /// [out] Pointer to extension-specific structure. + void *pNext); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Begin graph capture on the specified immediate queue. +/// +/// @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 == hQueue` +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +UR_APIEXPORT ur_result_t UR_APICALL urQueueBeginGraphCaptureExp( + /// [in] Handle of the queue on which to begin graph capture. + ur_queue_handle_t hQueue, + /// [in][optional] Pointer to extension-specific structure. + void *pNext); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Begin capturing commands into an existing graph on the specified +/// immediate queue. +/// +/// @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 == hQueue` +/// + `NULL == hGraph` +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +UR_APIEXPORT ur_result_t UR_APICALL urQueueBeginCaptureIntoGraphExp( + /// [in] Handle of the queue on which to begin graph capture. + ur_queue_handle_t hQueue, + /// [in] Handle of the graph object to capture into. + ur_exp_graph_handle_t hGraph, + /// [in][optional] Pointer to extension-specific structure. + void *pNext); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief End graph capture on the specified immediate queue. +/// +/// @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 == hQueue` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phGraph` +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +UR_APIEXPORT ur_result_t UR_APICALL urQueueEndGraphCaptureExp( + /// [in] Handle of the queue on which to end graph capture. + ur_queue_handle_t hQueue, + /// [out] Pointer to the handle of the recorded graph object. If + /// ::urQueueBeginCaptureIntoGraphExp was used to begin the capture, then + /// phGraph will contain the same graph that was passed to it. + ur_exp_graph_handle_t *phGraph, + /// [out][optional] Pointer to extension-specific structure. + void *pNext); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Instantiate an executable graph from a recorded graph. +/// +/// @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 == phExecGraph` +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +UR_APIEXPORT ur_result_t UR_APICALL urGraphInstantiateGraphExp( + /// [in] Handle of the recorded graph to instantiate. + ur_exp_graph_handle_t hGraph, + /// [out] Pointer to the handle of the instantiated executable graph. + ur_exp_executable_graph_handle_t *phExecGraph, + /// [out][optional] Pointer to extension-specific structure. + void *pNext); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Append an executable graph to the queue. +/// +/// @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 == hQueue` +/// + `NULL == hGraph` +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +UR_APIEXPORT ur_result_t UR_APICALL urQueueAppendGraphExp( + /// [in] Handle of the queue to append the graph to. + ur_queue_handle_t hQueue, + /// [in] Handle of the executable graph to append. + ur_exp_executable_graph_handle_t hGraph, + /// [in][optional] Pointer to extension-specific structure. + void *pNext, + /// [in][optional] Event to be signaled on completion. + ur_event_handle_t hSignalEvent, + /// [in][optional] Number of events to wait on before executing. + uint32_t numWaitEvents, + /// [in][optional][range(0, numWaitEvents)] Handle of the events to wait + /// on before launching. + ur_event_handle_t *phWaitEvents); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Destroy a recorded graph object. All executable graph instances +/// created from this recorded graph must be destroyed before calling +/// this function. +/// +/// @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_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +UR_APIEXPORT ur_result_t UR_APICALL urGraphDestroyExp( + /// [in] Handle of the graph object to destroy. + ur_exp_graph_handle_t hGraph); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Destroy an instantiated executable graph object. The graph instance +/// must not be executing on any queue. +/// +/// @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_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +UR_APIEXPORT ur_result_t UR_APICALL urGraphExecutableGraphDestroyExp( + /// [in] Handle of the executable graph object to destroy. + ur_exp_executable_graph_handle_t hExecutableGraph); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Query whether graph capture is currently enabled on the given queue. +/// +/// @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 == hQueue` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == hResult` +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +UR_APIEXPORT ur_result_t UR_APICALL urQueueIsGraphCaptureEnabledExp( + /// [in] Native queue to query. + ur_queue_handle_t hQueue, + /// [out] Pointer to a boolean where the result will be stored. + bool *hResult); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Return whether the given recorded graph contains any nodes. +/// +/// @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 == hResult` +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +UR_APIEXPORT ur_result_t UR_APICALL urGraphIsEmptyExp( + /// [in] Handle of the graph to query. + ur_exp_graph_handle_t hGraph, + /// [out] Pointer to a boolean where the result will be stored. + bool *hResult); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Dump the contents of the recorded graph to the provided file path. +/// +/// @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 == filePath` +/// - ::UR_RESULT_ERROR_INVALID_VALUE +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +UR_APIEXPORT ur_result_t UR_APICALL urGraphDumpContentsExp( + /// [in] Handle of the graph to dump. + ur_exp_graph_handle_t hGraph, + /// [in] Path to the file to write the dumped graph contents. + const char *filePath, + /// [in][optional] Pointer to extension-specific structure. + void *pNext); + #if !defined(__GNUC__) #pragma endregion #endif @@ -14286,6 +14564,57 @@ typedef struct ur_queue_flush_params_t { ur_queue_handle_t *phQueue; } ur_queue_flush_params_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urQueueBeginGraphCaptureExp +/// @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_queue_begin_graph_capture_exp_params_t { + ur_queue_handle_t *phQueue; + void **ppNext; +} ur_queue_begin_graph_capture_exp_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urQueueBeginCaptureIntoGraphExp +/// @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_queue_begin_capture_into_graph_exp_params_t { + ur_queue_handle_t *phQueue; + ur_exp_graph_handle_t *phGraph; + void **ppNext; +} ur_queue_begin_capture_into_graph_exp_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urQueueEndGraphCaptureExp +/// @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_queue_end_graph_capture_exp_params_t { + ur_queue_handle_t *phQueue; + ur_exp_graph_handle_t **pphGraph; + void **ppNext; +} ur_queue_end_graph_capture_exp_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urQueueAppendGraphExp +/// @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_queue_append_graph_exp_params_t { + ur_queue_handle_t *phQueue; + ur_exp_executable_graph_handle_t *phGraph; + void **ppNext; + ur_event_handle_t *phSignalEvent; + uint32_t *pnumWaitEvents; + ur_event_handle_t **pphWaitEvents; +} ur_queue_append_graph_exp_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urQueueIsGraphCaptureEnabledExp +/// @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_queue_is_graph_capture_enabled_exp_params_t { + ur_queue_handle_t *phQueue; + bool **phResult; +} ur_queue_is_graph_capture_enabled_exp_params_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Function parameters for urSamplerCreate /// @details Each entry is a pointer to the parameter passed to the function; @@ -15892,6 +16221,61 @@ typedef struct ur_command_buffer_get_native_handle_exp_params_t { ur_native_handle_t **pphNativeCommandBuffer; } ur_command_buffer_get_native_handle_exp_params_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urGraphCreateExp +/// @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_create_exp_params_t { + ur_context_handle_t *phContext; + ur_exp_graph_handle_t **pphGraph; + void **ppNext; +} ur_graph_create_exp_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urGraphInstantiateGraphExp +/// @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_instantiate_graph_exp_params_t { + ur_exp_graph_handle_t *phGraph; + ur_exp_executable_graph_handle_t **pphExecGraph; + void **ppNext; +} ur_graph_instantiate_graph_exp_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urGraphDestroyExp +/// @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_destroy_exp_params_t { + ur_exp_graph_handle_t *phGraph; +} ur_graph_destroy_exp_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urGraphExecutableGraphDestroyExp +/// @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_destroy_exp_params_t { + ur_exp_executable_graph_handle_t *phExecutableGraph; +} ur_graph_executable_graph_destroy_exp_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urGraphIsEmptyExp +/// @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_is_empty_exp_params_t { + ur_exp_graph_handle_t *phGraph; + bool **phResult; +} ur_graph_is_empty_exp_params_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function parameters for urGraphDumpContentsExp +/// @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_dump_contents_exp_params_t { + ur_exp_graph_handle_t *phGraph; + const char **pfilePath; + void **ppNext; +} ur_graph_dump_contents_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/ur_api_funcs.def b/unified-runtime/include/ur_api_funcs.def index 35c90887cf29f..9deb1baf0b193 100644 --- a/unified-runtime/include/ur_api_funcs.def +++ b/unified-runtime/include/ur_api_funcs.def @@ -88,6 +88,11 @@ _UR_API(urQueueGetNativeHandle) _UR_API(urQueueCreateWithNativeHandle) _UR_API(urQueueFinish) _UR_API(urQueueFlush) +_UR_API(urQueueBeginGraphCaptureExp) +_UR_API(urQueueBeginCaptureIntoGraphExp) +_UR_API(urQueueEndGraphCaptureExp) +_UR_API(urQueueAppendGraphExp) +_UR_API(urQueueIsGraphCaptureEnabledExp) _UR_API(urSamplerCreate) _UR_API(urSamplerRetain) _UR_API(urSamplerRelease) @@ -208,6 +213,12 @@ _UR_API(urCommandBufferUpdateSignalEventExp) _UR_API(urCommandBufferUpdateWaitEventsExp) _UR_API(urCommandBufferGetInfoExp) _UR_API(urCommandBufferGetNativeHandleExp) +_UR_API(urGraphCreateExp) +_UR_API(urGraphInstantiateGraphExp) +_UR_API(urGraphDestroyExp) +_UR_API(urGraphExecutableGraphDestroyExp) +_UR_API(urGraphIsEmptyExp) +_UR_API(urGraphDumpContentsExp) _UR_API(urIPCGetMemHandleExp) _UR_API(urIPCPutMemHandleExp) _UR_API(urIPCOpenMemHandleExp) diff --git a/unified-runtime/include/ur_ddi.h b/unified-runtime/include/ur_ddi.h index d2e96edf0dba6..2cd80f3162171 100644 --- a/unified-runtime/include/ur_ddi.h +++ b/unified-runtime/include/ur_ddi.h @@ -683,6 +683,62 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetQueueProcAddrTable( typedef ur_result_t(UR_APICALL *ur_pfnGetQueueProcAddrTable_t)( ur_api_version_t, ur_queue_dditable_t *); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urQueueBeginGraphCaptureExp +typedef ur_result_t(UR_APICALL *ur_pfnQueueBeginGraphCaptureExp_t)( + ur_queue_handle_t, void *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urQueueBeginCaptureIntoGraphExp +typedef ur_result_t(UR_APICALL *ur_pfnQueueBeginCaptureIntoGraphExp_t)( + ur_queue_handle_t, ur_exp_graph_handle_t, void *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urQueueEndGraphCaptureExp +typedef ur_result_t(UR_APICALL *ur_pfnQueueEndGraphCaptureExp_t)( + ur_queue_handle_t, ur_exp_graph_handle_t *, void *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urQueueAppendGraphExp +typedef ur_result_t(UR_APICALL *ur_pfnQueueAppendGraphExp_t)( + ur_queue_handle_t, ur_exp_executable_graph_handle_t, void *, + ur_event_handle_t, uint32_t, ur_event_handle_t *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urQueueIsGraphCaptureEnabledExp +typedef ur_result_t(UR_APICALL *ur_pfnQueueIsGraphCaptureEnabledExp_t)( + ur_queue_handle_t, bool *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Table of QueueExp functions pointers +typedef struct ur_queue_exp_dditable_t { + ur_pfnQueueBeginGraphCaptureExp_t pfnBeginGraphCaptureExp; + ur_pfnQueueBeginCaptureIntoGraphExp_t pfnBeginCaptureIntoGraphExp; + ur_pfnQueueEndGraphCaptureExp_t pfnEndGraphCaptureExp; + ur_pfnQueueAppendGraphExp_t pfnAppendGraphExp; + ur_pfnQueueIsGraphCaptureEnabledExp_t pfnIsGraphCaptureEnabledExp; +} ur_queue_exp_dditable_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's QueueExp 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 urGetQueueExpProcAddrTable( + /// [in] API version requested + ur_api_version_t version, + /// [in,out] pointer to table of DDI function pointers + ur_queue_exp_dditable_t *pDdiTable); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urGetQueueExpProcAddrTable +typedef ur_result_t(UR_APICALL *ur_pfnGetQueueExpProcAddrTable_t)( + ur_api_version_t, ur_queue_exp_dditable_t *); + /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urSamplerCreate typedef ur_result_t(UR_APICALL *ur_pfnSamplerCreate_t)( @@ -1803,6 +1859,67 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetCommandBufferExpProcAddrTable( typedef ur_result_t(UR_APICALL *ur_pfnGetCommandBufferExpProcAddrTable_t)( ur_api_version_t, ur_command_buffer_exp_dditable_t *); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urGraphCreateExp +typedef ur_result_t(UR_APICALL *ur_pfnGraphCreateExp_t)(ur_context_handle_t, + ur_exp_graph_handle_t *, + void *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urGraphInstantiateGraphExp +typedef ur_result_t(UR_APICALL *ur_pfnGraphInstantiateGraphExp_t)( + ur_exp_graph_handle_t, ur_exp_executable_graph_handle_t *, void *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urGraphDestroyExp +typedef ur_result_t(UR_APICALL *ur_pfnGraphDestroyExp_t)(ur_exp_graph_handle_t); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urGraphExecutableGraphDestroyExp +typedef ur_result_t(UR_APICALL *ur_pfnGraphExecutableGraphDestroyExp_t)( + ur_exp_executable_graph_handle_t); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urGraphIsEmptyExp +typedef ur_result_t(UR_APICALL *ur_pfnGraphIsEmptyExp_t)(ur_exp_graph_handle_t, + bool *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urGraphDumpContentsExp +typedef ur_result_t(UR_APICALL *ur_pfnGraphDumpContentsExp_t)( + ur_exp_graph_handle_t, const char *, void *); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Table of GraphExp functions pointers +typedef struct ur_graph_exp_dditable_t { + ur_pfnGraphCreateExp_t pfnCreateExp; + ur_pfnGraphInstantiateGraphExp_t pfnInstantiateGraphExp; + ur_pfnGraphDestroyExp_t pfnDestroyExp; + ur_pfnGraphExecutableGraphDestroyExp_t pfnExecutableGraphDestroyExp; + ur_pfnGraphIsEmptyExp_t pfnIsEmptyExp; + ur_pfnGraphDumpContentsExp_t pfnDumpContentsExp; +} ur_graph_exp_dditable_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's GraphExp 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 urGetGraphExpProcAddrTable( + /// [in] API version requested + ur_api_version_t version, + /// [in,out] pointer to table of DDI function pointers + ur_graph_exp_dditable_t *pDdiTable); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for urGetGraphExpProcAddrTable +typedef ur_result_t(UR_APICALL *ur_pfnGetGraphExpProcAddrTable_t)( + ur_api_version_t, ur_graph_exp_dditable_t *); + /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for urIPCGetMemHandleExp typedef ur_result_t(UR_APICALL *ur_pfnIPCGetMemHandleExp_t)(ur_context_handle_t, @@ -2136,6 +2253,7 @@ typedef struct ur_dditable_t { ur_program_exp_dditable_t ProgramExp; ur_kernel_dditable_t Kernel; ur_queue_dditable_t Queue; + ur_queue_exp_dditable_t QueueExp; ur_sampler_dditable_t Sampler; ur_mem_dditable_t Mem; ur_physical_mem_dditable_t PhysicalMem; @@ -2145,6 +2263,7 @@ typedef struct ur_dditable_t { ur_usm_exp_dditable_t USMExp; ur_bindless_images_exp_dditable_t BindlessImagesExp; ur_command_buffer_exp_dditable_t CommandBufferExp; + ur_graph_exp_dditable_t GraphExp; 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/ur_print.h b/unified-runtime/include/ur_print.h index f9e1904d94c0c..9671d7e72a21e 100644 --- a/unified-runtime/include/ur_print.h +++ b/unified-runtime/include/ur_print.h @@ -2291,6 +2291,56 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintQueueFlushParams(const struct ur_queue_flush_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_queue_begin_graph_capture_exp_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL urPrintQueueBeginGraphCaptureExpParams( + const struct ur_queue_begin_graph_capture_exp_params_t *params, + char *buffer, const size_t buff_size, size_t *out_size); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_queue_begin_capture_into_graph_exp_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL urPrintQueueBeginCaptureIntoGraphExpParams( + const struct ur_queue_begin_capture_into_graph_exp_params_t *params, + char *buffer, const size_t buff_size, size_t *out_size); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_queue_end_graph_capture_exp_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL urPrintQueueEndGraphCaptureExpParams( + const struct ur_queue_end_graph_capture_exp_params_t *params, char *buffer, + const size_t buff_size, size_t *out_size); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_queue_append_graph_exp_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL urPrintQueueAppendGraphExpParams( + const struct ur_queue_append_graph_exp_params_t *params, char *buffer, + const size_t buff_size, size_t *out_size); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_queue_is_graph_capture_enabled_exp_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL urPrintQueueIsGraphCaptureEnabledExpParams( + const struct ur_queue_is_graph_capture_enabled_exp_params_t *params, + char *buffer, const size_t buff_size, size_t *out_size); + /////////////////////////////////////////////////////////////////////////////// /// @brief Print ur_sampler_create_params_t struct /// @returns @@ -3560,6 +3610,66 @@ urPrintCommandBufferGetNativeHandleExpParams( const struct ur_command_buffer_get_native_handle_exp_params_t *params, char *buffer, const size_t buff_size, size_t *out_size); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_graph_create_exp_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL urPrintGraphCreateExpParams( + const struct ur_graph_create_exp_params_t *params, char *buffer, + const size_t buff_size, size_t *out_size); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_graph_instantiate_graph_exp_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL urPrintGraphInstantiateGraphExpParams( + const struct ur_graph_instantiate_graph_exp_params_t *params, char *buffer, + const size_t buff_size, size_t *out_size); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_graph_destroy_exp_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL urPrintGraphDestroyExpParams( + const struct ur_graph_destroy_exp_params_t *params, char *buffer, + const size_t buff_size, size_t *out_size); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_graph_executable_graph_destroy_exp_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL urPrintGraphExecutableGraphDestroyExpParams( + const struct ur_graph_executable_graph_destroy_exp_params_t *params, + char *buffer, const size_t buff_size, size_t *out_size); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_graph_is_empty_exp_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL urPrintGraphIsEmptyExpParams( + const struct ur_graph_is_empty_exp_params_t *params, char *buffer, + const size_t buff_size, size_t *out_size); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_graph_dump_contents_exp_params_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +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_ipc_get_mem_handle_exp_params_t struct /// @returns diff --git a/unified-runtime/include/ur_print.hpp b/unified-runtime/include/ur_print.hpp index 1c355eb194244..7127348321391 100644 --- a/unified-runtime/include/ur_print.hpp +++ b/unified-runtime/include/ur_print.hpp @@ -42,6 +42,9 @@ template <> struct is_handle : std::true_type {}; template <> struct is_handle : std::true_type {}; +template <> struct is_handle : std::true_type {}; +template <> +struct is_handle : std::true_type {}; template inline constexpr bool is_handle_v = is_handle::value; template inline ur_result_t printPtr(std::ostream &os, const T *ptr); @@ -1317,6 +1320,39 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value) { case UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH_WITH_ARGS_EXP: os << "UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH_WITH_ARGS_EXP"; break; + case UR_FUNCTION_GRAPH_CREATE_EXP: + os << "UR_FUNCTION_GRAPH_CREATE_EXP"; + break; + case UR_FUNCTION_QUEUE_BEGIN_GRAPH_CAPTURE_EXP: + os << "UR_FUNCTION_QUEUE_BEGIN_GRAPH_CAPTURE_EXP"; + break; + case UR_FUNCTION_QUEUE_BEGIN_CAPTURE_INTO_GRAPH_EXP: + os << "UR_FUNCTION_QUEUE_BEGIN_CAPTURE_INTO_GRAPH_EXP"; + break; + case UR_FUNCTION_QUEUE_END_GRAPH_CAPTURE_EXP: + os << "UR_FUNCTION_QUEUE_END_GRAPH_CAPTURE_EXP"; + break; + case UR_FUNCTION_QUEUE_APPEND_GRAPH_EXP: + os << "UR_FUNCTION_QUEUE_APPEND_GRAPH_EXP"; + break; + case UR_FUNCTION_GRAPH_DESTROY_EXP: + os << "UR_FUNCTION_GRAPH_DESTROY_EXP"; + break; + case UR_FUNCTION_GRAPH_EXECUTABLE_GRAPH_DESTROY_EXP: + os << "UR_FUNCTION_GRAPH_EXECUTABLE_GRAPH_DESTROY_EXP"; + break; + case UR_FUNCTION_QUEUE_IS_GRAPH_CAPTURE_ENABLED_EXP: + os << "UR_FUNCTION_QUEUE_IS_GRAPH_CAPTURE_ENABLED_EXP"; + break; + case UR_FUNCTION_GRAPH_IS_EMPTY_EXP: + os << "UR_FUNCTION_GRAPH_IS_EMPTY_EXP"; + break; + case UR_FUNCTION_GRAPH_DUMP_CONTENTS_EXP: + os << "UR_FUNCTION_GRAPH_DUMP_CONTENTS_EXP"; + break; + case UR_FUNCTION_GRAPH_INSTANTIATE_GRAPH_EXP: + os << "UR_FUNCTION_GRAPH_INSTANTIATE_GRAPH_EXP"; + break; default: os << "unknown enumerator"; break; @@ -2034,6 +2070,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_result_t value) { case UR_RESULT_ERROR_INVALID_SPEC_ID: os << "UR_RESULT_ERROR_INVALID_SPEC_ID"; break; + case UR_RESULT_ERROR_INVALID_GRAPH: + os << "UR_RESULT_ERROR_INVALID_GRAPH"; + break; case UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP: os << "UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP"; break; @@ -15114,6 +15153,153 @@ operator<<(std::ostream &os, return os; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_queue_begin_graph_capture_exp_params_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<( + std::ostream &os, + [[maybe_unused]] const struct ur_queue_begin_graph_capture_exp_params_t + *params) { + + os << ".hQueue = "; + + ur::details::printPtr(os, *(params->phQueue)); + + os << ", "; + os << ".pNext = "; + + ur::details::printStruct(os, *(params->ppNext)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_queue_begin_capture_into_graph_exp_params_t +/// type +/// @returns +/// std::ostream & +inline std::ostream &operator<<( + std::ostream &os, + [[maybe_unused]] const struct ur_queue_begin_capture_into_graph_exp_params_t + *params) { + + os << ".hQueue = "; + + ur::details::printPtr(os, *(params->phQueue)); + + os << ", "; + os << ".hGraph = "; + + ur::details::printPtr(os, *(params->phGraph)); + + os << ", "; + os << ".pNext = "; + + ur::details::printStruct(os, *(params->ppNext)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_queue_end_graph_capture_exp_params_t type +/// @returns +/// std::ostream & +inline std::ostream & +operator<<(std::ostream &os, + [[maybe_unused]] const struct ur_queue_end_graph_capture_exp_params_t + *params) { + + os << ".hQueue = "; + + ur::details::printPtr(os, *(params->phQueue)); + + os << ", "; + os << ".phGraph = "; + + ur::details::printPtr(os, *(params->pphGraph)); + + os << ", "; + os << ".pNext = "; + + ur::details::printStruct(os, *(params->ppNext)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_queue_append_graph_exp_params_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<( + std::ostream &os, + [[maybe_unused]] const struct ur_queue_append_graph_exp_params_t *params) { + + os << ".hQueue = "; + + ur::details::printPtr(os, *(params->phQueue)); + + os << ", "; + os << ".hGraph = "; + + ur::details::printPtr(os, *(params->phGraph)); + + os << ", "; + os << ".pNext = "; + + ur::details::printStruct(os, *(params->ppNext)); + + os << ", "; + os << ".hSignalEvent = "; + + ur::details::printPtr(os, *(params->phSignalEvent)); + + os << ", "; + os << ".numWaitEvents = "; + + os << *(params->pnumWaitEvents); + + os << ", "; + os << ".phWaitEvents = "; + ur::details::printPtr( + os, reinterpret_cast(*(params->pphWaitEvents))); + if (*(params->pphWaitEvents) != NULL) { + os << " {"; + for (size_t i = 0; i < *params->pnumWaitEvents; ++i) { + if (i != 0) { + os << ", "; + } + + ur::details::printPtr(os, (*(params->pphWaitEvents))[i]); + } + os << "}"; + } + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_queue_is_graph_capture_enabled_exp_params_t +/// type +/// @returns +/// std::ostream & +inline std::ostream &operator<<( + std::ostream &os, + [[maybe_unused]] const struct ur_queue_is_graph_capture_enabled_exp_params_t + *params) { + + os << ".hQueue = "; + + ur::details::printPtr(os, *(params->phQueue)); + + os << ", "; + os << ".hResult = "; + + ur::details::printPtr(os, *(params->phResult)); + + return os; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Print operator for the ur_sampler_create_params_t type /// @returns @@ -20783,6 +20969,134 @@ operator<<(std::ostream &os, [[maybe_unused]] const struct return os; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_graph_create_exp_params_t type +/// @returns +/// std::ostream & +inline std::ostream & +operator<<(std::ostream &os, + [[maybe_unused]] const struct ur_graph_create_exp_params_t *params) { + + os << ".hContext = "; + + ur::details::printPtr(os, *(params->phContext)); + + os << ", "; + os << ".phGraph = "; + + ur::details::printPtr(os, *(params->pphGraph)); + + os << ", "; + os << ".pNext = "; + + ur::details::printStruct(os, *(params->ppNext)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_graph_instantiate_graph_exp_params_t type +/// @returns +/// std::ostream & +inline std::ostream & +operator<<(std::ostream &os, + [[maybe_unused]] const struct ur_graph_instantiate_graph_exp_params_t + *params) { + + os << ".hGraph = "; + + ur::details::printPtr(os, *(params->phGraph)); + + os << ", "; + os << ".phExecGraph = "; + + ur::details::printPtr(os, *(params->pphExecGraph)); + + os << ", "; + os << ".pNext = "; + + ur::details::printStruct(os, *(params->ppNext)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_graph_destroy_exp_params_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<( + std::ostream &os, + [[maybe_unused]] const struct ur_graph_destroy_exp_params_t *params) { + + os << ".hGraph = "; + + ur::details::printPtr(os, *(params->phGraph)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_graph_executable_graph_destroy_exp_params_t +/// type +/// @returns +/// std::ostream & +inline std::ostream &operator<<( + std::ostream &os, + [[maybe_unused]] const struct ur_graph_executable_graph_destroy_exp_params_t + *params) { + + os << ".hExecutableGraph = "; + + ur::details::printPtr(os, *(params->phExecutableGraph)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_graph_is_empty_exp_params_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<( + std::ostream &os, + [[maybe_unused]] const struct ur_graph_is_empty_exp_params_t *params) { + + os << ".hGraph = "; + + ur::details::printPtr(os, *(params->phGraph)); + + os << ", "; + os << ".hResult = "; + + ur::details::printPtr(os, *(params->phResult)); + + return os; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_graph_dump_contents_exp_params_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<( + std::ostream &os, + [[maybe_unused]] const struct ur_graph_dump_contents_exp_params_t *params) { + + os << ".hGraph = "; + + ur::details::printPtr(os, *(params->phGraph)); + + os << ", "; + os << ".filePath = "; + + ur::details::printPtr(os, *(params->pfilePath)); + + os << ", "; + os << ".pNext = "; + + ur::details::printStruct(os, *(params->ppNext)); + + return os; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Print operator for the ur_ipc_get_mem_handle_exp_params_t type /// @returns @@ -21987,6 +22301,21 @@ inline ur_result_t UR_APICALL printFunctionParams(std::ostream &os, case UR_FUNCTION_QUEUE_FLUSH: { os << (const struct ur_queue_flush_params_t *)params; } break; + case UR_FUNCTION_QUEUE_BEGIN_GRAPH_CAPTURE_EXP: { + os << (const struct ur_queue_begin_graph_capture_exp_params_t *)params; + } break; + case UR_FUNCTION_QUEUE_BEGIN_CAPTURE_INTO_GRAPH_EXP: { + os << (const struct ur_queue_begin_capture_into_graph_exp_params_t *)params; + } break; + case UR_FUNCTION_QUEUE_END_GRAPH_CAPTURE_EXP: { + os << (const struct ur_queue_end_graph_capture_exp_params_t *)params; + } break; + case UR_FUNCTION_QUEUE_APPEND_GRAPH_EXP: { + os << (const struct ur_queue_append_graph_exp_params_t *)params; + } break; + case UR_FUNCTION_QUEUE_IS_GRAPH_CAPTURE_ENABLED_EXP: { + os << (const struct ur_queue_is_graph_capture_enabled_exp_params_t *)params; + } break; case UR_FUNCTION_SAMPLER_CREATE: { os << (const struct ur_sampler_create_params_t *)params; } break; @@ -22394,6 +22723,24 @@ inline ur_result_t UR_APICALL printFunctionParams(std::ostream &os, os << (const struct ur_command_buffer_get_native_handle_exp_params_t *) params; } break; + case UR_FUNCTION_GRAPH_CREATE_EXP: { + os << (const struct ur_graph_create_exp_params_t *)params; + } break; + case UR_FUNCTION_GRAPH_INSTANTIATE_GRAPH_EXP: { + os << (const struct ur_graph_instantiate_graph_exp_params_t *)params; + } break; + case UR_FUNCTION_GRAPH_DESTROY_EXP: { + os << (const struct ur_graph_destroy_exp_params_t *)params; + } break; + case UR_FUNCTION_GRAPH_EXECUTABLE_GRAPH_DESTROY_EXP: { + os << (const struct ur_graph_executable_graph_destroy_exp_params_t *)params; + } break; + case UR_FUNCTION_GRAPH_IS_EMPTY_EXP: { + os << (const struct ur_graph_is_empty_exp_params_t *)params; + } break; + case UR_FUNCTION_GRAPH_DUMP_CONTENTS_EXP: { + os << (const struct ur_graph_dump_contents_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/common.yml b/unified-runtime/scripts/core/common.yml index 6d43d52fdc936..cbd241dadc534 100644 --- a/unified-runtime/scripts/core/common.yml +++ b/unified-runtime/scripts/core/common.yml @@ -284,6 +284,8 @@ etors: desc: "Device in question has `$X_DEVICE_INFO_AVAILABLE == false`" - name: ERROR_INVALID_SPEC_ID desc: "A specialization constant identifier is not valid." + - name: ERROR_INVALID_GRAPH + desc: "A graph object is not valid." - name: ERROR_UNKNOWN value: "0x7ffffffe" desc: "Unknown or internal error" diff --git a/unified-runtime/scripts/core/exp-graph.yml b/unified-runtime/scripts/core/exp-graph.yml new file mode 100644 index 0000000000000..80f7f5d7e23c7 --- /dev/null +++ b/unified-runtime/scripts/core/exp-graph.yml @@ -0,0 +1,216 @@ +# +# Copyright (C) 2025 Intel Corporation +# +# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +# See LICENSE.TXT +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# +# See YaML.md for syntax definition +# +# TODO: +# ZE_RESULT_ERROR_INVALID_GRAPH +# ZE_RESULT_QUERY_TRUE +# ZE_RESULT_QUERY_FALSE +# +--- #-------------------------------------------------------------------------- +type: header +desc: "Intel $OneApi Unified Runtime Experimental APIs for Graph Record and Replay" +--- #-------------------------------------------------------------------------- +type: handle +desc: "Handle of record & replay graph object" +name: "$x_exp_graph_handle_t" +--- #-------------------------------------------------------------------------- +type: handle +desc: "Handle of record & replay executable graph object" +name: "$x_exp_executable_graph_handle_t" +--- #-------------------------------------------------------------------------- +type: function +desc: "Create a new record & replay graph instance explicitly." +class: $xGraph +name: CreateExp +decl: static +details: + - "Create a new record & replay graph instance explicitly." +params: + - type: $x_context_handle_t + name: hContext + desc: "[in] Handle of the context object." + - type: $x_exp_graph_handle_t* + name: phGraph + desc: "[out][alloc] Pointer to the handle of the created graph object." + - type: void* + name: pNext + desc: "[out] Pointer to extension-specific structure." +returns: + - $X_RESULT_SUCCESS + - $X_RESULT_ERROR_INVALID_ARGUMENT +--- #------------------------------------------k-------------------------------- +type: function +desc: "Begin graph capture on the specified immediate queue." +class: $xQueue +name: BeginGraphCaptureExp +params: + - type: $x_queue_handle_t + name: hQueue + desc: "[in] Handle of the queue on which to begin graph capture." + - type: void* + name: pNext + desc: "[in][optional] Pointer to extension-specific structure." +returns: + - $X_RESULT_SUCCESS + - $X_RESULT_ERROR_INVALID_ARGUMENT +--- #-------------------------------------------------------------------------- +type: function +desc: "Begin capturing commands into an existing graph on the specified immediate queue." +class: $xQueue +name: BeginCaptureIntoGraphExp +params: + - type: $x_queue_handle_t + name: hQueue + desc: "[in] Handle of the queue on which to begin graph capture." + - type: $x_exp_graph_handle_t + name: hGraph + desc: "[in] Handle of the graph object to capture into." + - type: void* + name: pNext + desc: "[in][optional] Pointer to extension-specific structure." +returns: + - $X_RESULT_SUCCESS + - $X_RESULT_ERROR_INVALID_ARGUMENT +--- #-------------------------------------------------------------------------- +type: function +desc: "End graph capture on the specified immediate queue." +class: $xQueue +name: EndGraphCaptureExp +params: + - type: $x_queue_handle_t + name: hQueue + desc: "[in] Handle of the queue on which to end graph capture." + - type: $x_exp_graph_handle_t* + name: phGraph + desc: "[out] Pointer to the handle of the recorded graph object. If $xQueueBeginCaptureIntoGraphExp + was used to begin the capture, then phGraph will contain the same graph that was passed to it." + - type: void* + name: pNext + desc: "[out][optional] Pointer to extension-specific structure." +returns: + - $X_RESULT_SUCCESS + - $X_RESULT_ERROR_INVALID_ARGUMENT +--- #-------------------------------------------------------------------------- +type: function +desc: "Instantiate an executable graph from a recorded graph." +class: $xGraph +name: InstantiateGraphExp +params: + - type: $x_exp_graph_handle_t + name: hGraph + desc: "[in] Handle of the recorded graph to instantiate." + - type: $x_exp_executable_graph_handle_t* + name: phExecGraph + desc: "[out] Pointer to the handle of the instantiated executable graph." + - type: void* + name: pNext + desc: "[out][optional] Pointer to extension-specific structure." +returns: + - $X_RESULT_SUCCESS + - $X_RESULT_ERROR_INVALID_ARGUMENT +--- #-------------------------------------------------------------------------- +type: function +desc: "Append an executable graph to the queue." +class: $xQueue +name: AppendGraphExp +params: + - type: $x_queue_handle_t + name: hQueue + desc: "[in] Handle of the queue to append the graph to." + - type: $x_exp_executable_graph_handle_t + name: hGraph + desc: "[in] Handle of the executable graph to append." + - type: void* + name: pNext + desc: "[in][optional] Pointer to extension-specific structure." + - type: $x_event_handle_t + name: hSignalEvent + desc: "[in][optional] Event to be signaled on completion." + - type: uint32_t + name: numWaitEvents + desc: "[in][optional] Number of events to wait on before executing." + - type: $x_event_handle_t* + name: phWaitEvents + desc: "[in][optional][range(0, numWaitEvents)] Handle of the events to wait on before launching." +returns: + - $X_RESULT_SUCCESS + - $X_RESULT_ERROR_INVALID_ARGUMENT +--- #-------------------------------------------------------------------------- +type: function +desc: "Destroy a recorded graph object. All executable graph instances created from this recorded graph must be destroyed before calling this function." +class: $xGraph +name: DestroyExp +params: + - type: $x_exp_graph_handle_t + name: hGraph + desc: "[in] Handle of the graph object to destroy." +returns: + - $X_RESULT_SUCCESS + - $X_RESULT_ERROR_INVALID_ARGUMENT +--- #-------------------------------------------------------------------------- +type: function +desc: "Destroy an instantiated executable graph object. The graph instance must not be executing on any queue." +class: $xGraph +name: ExecutableGraphDestroyExp +params: + - type: $x_exp_executable_graph_handle_t + name: hExecutableGraph + desc: "[in] Handle of the executable graph object to destroy." +returns: + - $X_RESULT_SUCCESS + - $X_RESULT_ERROR_INVALID_ARGUMENT +--- #-------------------------------------------------------------------------- +type: function +desc: "Query whether graph capture is currently enabled on the given queue." +class: $xQueue +name: IsGraphCaptureEnabledExp +params: + - type: $x_queue_handle_t + name: hQueue + desc: "[in] Native queue to query." + - type: bool* + name: hResult + desc: "[out] Pointer to a boolean where the result will be stored." +returns: + - $X_RESULT_SUCCESS + - $X_RESULT_ERROR_INVALID_ARGUMENT +--- #-------------------------------------------------------------------------- +type: function +desc: "Return whether the given recorded graph contains any nodes." +class: $xGraph +name: IsEmptyExp +params: + - type: $x_exp_graph_handle_t + name: hGraph + desc: "[in] Handle of the graph to query." + - type: bool* + name: hResult + desc: "[out] Pointer to a boolean where the result will be stored." +returns: + - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY + - $X_RESULT_ERROR_OUT_OF_RESOURCES +--- #-------------------------------------------------------------------------- +type: function +desc: "Dump the contents of the recorded graph to the provided file path." +class: $xGraph +name: DumpContentsExp +params: + - type: $x_exp_graph_handle_t + name: hGraph + desc: "[in] Handle of the graph to dump." + - type: const char* + name: filePath + desc: "[in] Path to the file to write the dumped graph contents." + - type: void* + name: pNext + desc: "[in][optional] Pointer to extension-specific structure." +returns: + - $X_RESULT_ERROR_INVALID_VALUE + - $X_RESULT_ERROR_OUT_OF_HOST_MEMORY + - $X_RESULT_ERROR_OUT_OF_RESOURCES diff --git a/unified-runtime/scripts/core/registry.yml b/unified-runtime/scripts/core/registry.yml index ce969c39abf33..2b1c972d7ad29 100644 --- a/unified-runtime/scripts/core/registry.yml +++ b/unified-runtime/scripts/core/registry.yml @@ -691,7 +691,40 @@ etors: - name: ENQUEUE_KERNEL_LAUNCH_WITH_ARGS_EXP desc: Enumerator for $xEnqueueKernelLaunchWithArgsExp value: '295' -max_id: '295' +- name: GRAPH_CREATE_EXP + desc: Enumerator for $xGraphCreateExp + value: '296' +- name: QUEUE_BEGIN_GRAPH_CAPTURE_EXP + desc: Enumerator for $xQueueBeginGraphCaptureExp + value: '297' +- name: QUEUE_BEGIN_CAPTURE_INTO_GRAPH_EXP + desc: Enumerator for $xQueueBeginCaptureIntoGraphExp + value: '298' +- name: QUEUE_END_GRAPH_CAPTURE_EXP + desc: Enumerator for $xQueueEndGraphCaptureExp + value: '299' +- name: QUEUE_APPEND_GRAPH_EXP + desc: Enumerator for $xQueueAppendGraphExp + value: '301' +- name: GRAPH_DESTROY_EXP + desc: Enumerator for $xGraphDestroyExp + value: '302' +- name: GRAPH_EXECUTABLE_GRAPH_DESTROY_EXP + desc: Enumerator for $xGraphExecutableGraphDestroyExp + value: '303' +- name: QUEUE_IS_GRAPH_CAPTURE_ENABLED_EXP + desc: Enumerator for $xQueueIsGraphCaptureEnabledExp + value: '304' +- name: GRAPH_IS_EMPTY_EXP + desc: Enumerator for $xGraphIsEmptyExp + value: '305' +- name: GRAPH_DUMP_CONTENTS_EXP + desc: Enumerator for $xGraphDumpContentsExp + value: '306' +- name: GRAPH_INSTANTIATE_GRAPH_EXP + desc: Enumerator for $xGraphInstantiateGraphExp + value: '307' +max_id: '307' --- type: enum desc: Defines structure types diff --git a/unified-runtime/source/adapters/adapter.def.in b/unified-runtime/source/adapters/adapter.def.in index 3427b250394a3..51b2c228036c3 100644 --- a/unified-runtime/source/adapters/adapter.def.in +++ b/unified-runtime/source/adapters/adapter.def.in @@ -7,6 +7,7 @@ EXPORTS urGetEnqueueProcAddrTable urGetEnqueueExpProcAddrTable urGetEventProcAddrTable + urGetGraphExpProcAddrTable urGetIPCExpProcAddrTable urGetKernelProcAddrTable urGetMemProcAddrTable @@ -16,6 +17,7 @@ EXPORTS urGetProgramProcAddrTable urGetProgramExpProcAddrTable urGetQueueProcAddrTable + urGetQueueExpProcAddrTable urGetSamplerProcAddrTable urGetUSMProcAddrTable urGetUSMExpProcAddrTable diff --git a/unified-runtime/source/adapters/adapter.map.in b/unified-runtime/source/adapters/adapter.map.in index 9015676619cda..18beaa3e6ce38 100644 --- a/unified-runtime/source/adapters/adapter.map.in +++ b/unified-runtime/source/adapters/adapter.map.in @@ -7,6 +7,7 @@ urGetEnqueueProcAddrTable; urGetEnqueueExpProcAddrTable; urGetEventProcAddrTable; + urGetGraphExpProcAddrTable; urGetIPCExpProcAddrTable; urGetKernelProcAddrTable; urGetMemProcAddrTable; @@ -16,6 +17,7 @@ urGetProgramProcAddrTable; urGetProgramExpProcAddrTable; urGetQueueProcAddrTable; + urGetQueueExpProcAddrTable; urGetSamplerProcAddrTable; urGetUSMProcAddrTable; urGetUSMExpProcAddrTable; diff --git a/unified-runtime/source/adapters/level_zero/CMakeLists.txt b/unified-runtime/source/adapters/level_zero/CMakeLists.txt index 54f303a7823c9..9f843a37b0ec2 100644 --- a/unified-runtime/source/adapters/level_zero/CMakeLists.txt +++ b/unified-runtime/source/adapters/level_zero/CMakeLists.txt @@ -52,6 +52,7 @@ if(UR_BUILD_ADAPTER_L0) ${CMAKE_CURRENT_SOURCE_DIR}/sampler.cpp ${CMAKE_CURRENT_SOURCE_DIR}/image.cpp ${CMAKE_CURRENT_SOURCE_DIR}/image_common.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/graph.cpp ${CMAKE_CURRENT_SOURCE_DIR}/helpers/kernel_helpers.cpp ${CMAKE_CURRENT_SOURCE_DIR}/helpers/memory_helpers.cpp ${CMAKE_CURRENT_SOURCE_DIR}/helpers/mutable_helpers.cpp @@ -148,6 +149,7 @@ if(UR_BUILD_ADAPTER_L0_V2) ${CMAKE_CURRENT_SOURCE_DIR}/physical_mem.cpp ${CMAKE_CURRENT_SOURCE_DIR}/program.cpp ${CMAKE_CURRENT_SOURCE_DIR}/helpers/kernel_helpers.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/graph.cpp ${CMAKE_CURRENT_SOURCE_DIR}/helpers/memory_helpers.cpp ${CMAKE_CURRENT_SOURCE_DIR}/helpers/mutable_helpers.cpp ${CMAKE_CURRENT_SOURCE_DIR}/usm_p2p.cpp diff --git a/unified-runtime/source/adapters/level_zero/graph.cpp b/unified-runtime/source/adapters/level_zero/graph.cpp new file mode 100644 index 0000000000000..681b24c98db22 --- /dev/null +++ b/unified-runtime/source/adapters/level_zero/graph.cpp @@ -0,0 +1,84 @@ +//===--------- graph.cpp - Level Zero Adapter -----------------------------===// +// +// Copyright (C) 2023 Intel Corporation +// +// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM +// Exceptions. See LICENSE.TXT +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "common.hpp" +#include "ur_interface_loader.hpp" +#include "ur_level_zero.hpp" + +namespace ur::level_zero { + +// Graph experimental functions - not yet supported +ur_result_t urGraphCreateExp(ur_context_handle_t hContext, + ur_exp_graph_handle_t *phGraph, + void *pProperties) { + std::ignore = hContext; + std::ignore = pProperties; + if (phGraph) + *phGraph = nullptr; + UR_LOG_LEGACY(ERR, + logger::LegacyMessage("[UR][L0] {} function not implemented!"), + "{} function not implemented!", __FUNCTION__); + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +ur_result_t urGraphDestroyExp(ur_exp_graph_handle_t hGraph) { + std::ignore = hGraph; + UR_LOG_LEGACY(ERR, + logger::LegacyMessage("[UR][L0] {} function not implemented!"), + "{} function not implemented!", __FUNCTION__); + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +ur_result_t urGraphExecutableGraphDestroyExp( + ur_exp_executable_graph_handle_t hExecutableGraph) { + std::ignore = hExecutableGraph; + UR_LOG_LEGACY(ERR, + logger::LegacyMessage("[UR][L0] {} function not implemented!"), + "{} function not implemented!", __FUNCTION__); + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +ur_result_t urGraphIsEmptyExp(ur_exp_graph_handle_t hGraph, bool *pIsEmpty) { + std::ignore = hGraph; + if (pIsEmpty) + *pIsEmpty = false; + UR_LOG_LEGACY(ERR, + logger::LegacyMessage("[UR][L0] {} function not implemented!"), + "{} function not implemented!", __FUNCTION__); + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +ur_result_t urGraphDumpContentsExp(ur_exp_graph_handle_t hGraph, + const char *pDotFilePath, + void *pProperties) { + std::ignore = hGraph; + std::ignore = pDotFilePath; + std::ignore = pProperties; + UR_LOG_LEGACY(ERR, + logger::LegacyMessage("[UR][L0] {} function not implemented!"), + "{} function not implemented!", __FUNCTION__); + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +ur_result_t +urGraphInstantiateGraphExp(ur_exp_graph_handle_t hGraph, + ur_exp_executable_graph_handle_t *phExecutableGraph, + void *pProperties) { + std::ignore = hGraph; + std::ignore = pProperties; + if (phExecutableGraph) + *phExecutableGraph = nullptr; + 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/queue.cpp b/unified-runtime/source/adapters/level_zero/queue.cpp index 4dcd745eec0ac..e6293fbd336b4 100644 --- a/unified-runtime/source/adapters/level_zero/queue.cpp +++ b/unified-runtime/source/adapters/level_zero/queue.cpp @@ -930,6 +930,68 @@ ur_result_t urQueueFlush( return Queue->executeAllOpenCommandLists(); } +ur_result_t urQueueBeginGraphCaptureExp(ur_queue_handle_t hQueue, void *pNext) { + std::ignore = hQueue; + std::ignore = pNext; + UR_LOG_LEGACY(ERR, + logger::LegacyMessage("[UR][L0] {} function not implemented!"), + "{} function not implemented!", __FUNCTION__); + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +ur_result_t urQueueBeginCaptureIntoGraphExp(ur_queue_handle_t hQueue, + ur_exp_graph_handle_t hGraph, + void *pNext) { + std::ignore = hQueue; + std::ignore = hGraph; + std::ignore = pNext; + UR_LOG_LEGACY(ERR, + logger::LegacyMessage("[UR][L0] {} function not implemented!"), + "{} function not implemented!", __FUNCTION__); + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +ur_result_t urQueueEndGraphCaptureExp(ur_queue_handle_t hQueue, + ur_exp_graph_handle_t *phGraph, + void *pNext) { + std::ignore = hQueue; + std::ignore = pNext; + if (phGraph) + *phGraph = nullptr; + UR_LOG_LEGACY(ERR, + logger::LegacyMessage("[UR][L0] {} function not implemented!"), + "{} function not implemented!", __FUNCTION__); + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +ur_result_t urQueueAppendGraphExp(ur_queue_handle_t hQueue, + ur_exp_executable_graph_handle_t hGraph, + void *pNext, ur_event_handle_t hSignalEvent, + uint32_t numWaitEvents, + ur_event_handle_t *phWaitEvents) { + std::ignore = hQueue; + std::ignore = hGraph; + std::ignore = pNext; + std::ignore = hSignalEvent; + std::ignore = numWaitEvents; + std::ignore = phWaitEvents; + UR_LOG_LEGACY(ERR, + logger::LegacyMessage("[UR][L0] {} function not implemented!"), + "{} function not implemented!", __FUNCTION__); + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +ur_result_t urQueueIsGraphCaptureEnabledExp(ur_queue_handle_t hQueue, + bool *hResult) { + std::ignore = hQueue; + if (hResult) + *hResult = false; + 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 // Configuration of the command-list batching. 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 2f340c97a188a..435e7cb80fa73 100644 --- a/unified-runtime/source/adapters/level_zero/ur_interface_loader.cpp +++ b/unified-runtime/source/adapters/level_zero/ur_interface_loader.cpp @@ -259,6 +259,25 @@ UR_APIEXPORT ur_result_t UR_APICALL urGetEventProcAddrTable( return result; } +UR_APIEXPORT ur_result_t UR_APICALL urGetGraphExpProcAddrTable( + ur_api_version_t version, ur_graph_exp_dditable_t *pDdiTable) { + auto result = validateProcInputs(version, pDdiTable); + if (UR_RESULT_SUCCESS != result) { + return result; + } + + pDdiTable->pfnCreateExp = ur::level_zero::urGraphCreateExp; + pDdiTable->pfnInstantiateGraphExp = + ur::level_zero::urGraphInstantiateGraphExp; + pDdiTable->pfnDestroyExp = ur::level_zero::urGraphDestroyExp; + pDdiTable->pfnExecutableGraphDestroyExp = + ur::level_zero::urGraphExecutableGraphDestroyExp; + pDdiTable->pfnIsEmptyExp = ur::level_zero::urGraphIsEmptyExp; + pDdiTable->pfnDumpContentsExp = ur::level_zero::urGraphDumpContentsExp; + + return result; +} + UR_APIEXPORT ur_result_t UR_APICALL urGetIPCExpProcAddrTable( ur_api_version_t version, ur_ipc_exp_dditable_t *pDdiTable) { auto result = validateProcInputs(version, pDdiTable); @@ -443,6 +462,25 @@ UR_APIEXPORT ur_result_t UR_APICALL urGetQueueProcAddrTable( return result; } +UR_APIEXPORT ur_result_t UR_APICALL urGetQueueExpProcAddrTable( + ur_api_version_t version, ur_queue_exp_dditable_t *pDdiTable) { + auto result = validateProcInputs(version, pDdiTable); + if (UR_RESULT_SUCCESS != result) { + return result; + } + + pDdiTable->pfnBeginGraphCaptureExp = + ur::level_zero::urQueueBeginGraphCaptureExp; + pDdiTable->pfnBeginCaptureIntoGraphExp = + ur::level_zero::urQueueBeginCaptureIntoGraphExp; + pDdiTable->pfnEndGraphCaptureExp = ur::level_zero::urQueueEndGraphCaptureExp; + pDdiTable->pfnAppendGraphExp = ur::level_zero::urQueueAppendGraphExp; + pDdiTable->pfnIsGraphCaptureEnabledExp = + ur::level_zero::urQueueIsGraphCaptureEnabledExp; + + return result; +} + UR_APIEXPORT ur_result_t UR_APICALL urGetSamplerProcAddrTable( ur_api_version_t version, ur_sampler_dditable_t *pDdiTable) { auto result = validateProcInputs(version, pDdiTable); @@ -625,6 +663,10 @@ ur_result_t populateDdiTable(ur_dditable_t *ddi) { NAMESPACE_::urGetEventProcAddrTable(UR_API_VERSION_CURRENT, &ddi->Event); if (result != UR_RESULT_SUCCESS) return result; + result = NAMESPACE_::urGetGraphExpProcAddrTable(UR_API_VERSION_CURRENT, + &ddi->GraphExp); + if (result != UR_RESULT_SUCCESS) + return result; result = NAMESPACE_::urGetIPCExpProcAddrTable(UR_API_VERSION_CURRENT, &ddi->IPCExp); if (result != UR_RESULT_SUCCESS) @@ -660,6 +702,10 @@ ur_result_t populateDdiTable(ur_dditable_t *ddi) { NAMESPACE_::urGetQueueProcAddrTable(UR_API_VERSION_CURRENT, &ddi->Queue); if (result != UR_RESULT_SUCCESS) return result; + result = NAMESPACE_::urGetQueueExpProcAddrTable(UR_API_VERSION_CURRENT, + &ddi->QueueExp); + if (result != UR_RESULT_SUCCESS) + return result; result = NAMESPACE_::urGetSamplerProcAddrTable(UR_API_VERSION_CURRENT, &ddi->Sampler); if (result != UR_RESULT_SUCCESS) 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 838f1a7c1353f..89f36db06944d 100644 --- a/unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp +++ b/unified-runtime/source/adapters/level_zero/ur_interface_loader.hpp @@ -844,6 +844,32 @@ ur_result_t urEnqueueNativeCommandExp( const ur_exp_enqueue_native_command_properties_t *pProperties, uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList, ur_event_handle_t *phEvent); +ur_result_t urGraphCreateExp(ur_context_handle_t hContext, + ur_exp_graph_handle_t *phGraph, void *pNext); +ur_result_t urQueueBeginGraphCaptureExp(ur_queue_handle_t hQueue, void *pNext); +ur_result_t urQueueBeginCaptureIntoGraphExp(ur_queue_handle_t hQueue, + ur_exp_graph_handle_t hGraph, + void *pNext); +ur_result_t urQueueEndGraphCaptureExp(ur_queue_handle_t hQueue, + ur_exp_graph_handle_t *phGraph, + void *pNext); +ur_result_t +urGraphInstantiateGraphExp(ur_exp_graph_handle_t hGraph, + ur_exp_executable_graph_handle_t *phExecGraph, + void *pNext); +ur_result_t urQueueAppendGraphExp(ur_queue_handle_t hQueue, + ur_exp_executable_graph_handle_t hGraph, + void *pNext, ur_event_handle_t hSignalEvent, + uint32_t numWaitEvents, + ur_event_handle_t *phWaitEvents); +ur_result_t urGraphDestroyExp(ur_exp_graph_handle_t hGraph); +ur_result_t urGraphExecutableGraphDestroyExp( + ur_exp_executable_graph_handle_t hExecutableGraph); +ur_result_t urQueueIsGraphCaptureEnabledExp(ur_queue_handle_t hQueue, + bool *hResult); +ur_result_t urGraphIsEmptyExp(ur_exp_graph_handle_t hGraph, bool *hResult); +ur_result_t urGraphDumpContentsExp(ur_exp_graph_handle_t hGraph, + const char *filePath, void *pNext); #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/queue_api.cpp b/unified-runtime/source/adapters/level_zero/v2/queue_api.cpp index 29a8bf7114862..a6e99453ec33d 100644 --- a/unified-runtime/source/adapters/level_zero/v2/queue_api.cpp +++ b/unified-runtime/source/adapters/level_zero/v2/queue_api.cpp @@ -481,4 +481,40 @@ ur_result_t urEnqueueNativeCommandExp( } catch (...) { return exceptionToResult(std::current_exception()); } +ur_result_t urQueueBeginGraphCaptureExp(ur_queue_handle_t hQueue, + void *pNext) try { + return hQueue->get().queueBeginGraphCapteExp(pNext); +} catch (...) { + return exceptionToResult(std::current_exception()); +} +ur_result_t urQueueBeginCaptureIntoGraphExp(ur_queue_handle_t hQueue, + ur_exp_graph_handle_t hGraph, + void *pNext) try { + return hQueue->get().queueBeginCapteIntoGraphExp(hGraph, pNext); +} catch (...) { + return exceptionToResult(std::current_exception()); +} +ur_result_t urQueueEndGraphCaptureExp(ur_queue_handle_t hQueue, + ur_exp_graph_handle_t *phGraph, + void *pNext) try { + return hQueue->get().queueEndGraphCapteExp(phGraph, pNext); +} catch (...) { + return exceptionToResult(std::current_exception()); +} +ur_result_t urQueueAppendGraphExp(ur_queue_handle_t hQueue, + ur_exp_executable_graph_handle_t hGraph, + void *pNext, ur_event_handle_t hSignalEvent, + uint32_t numWaitEvents, + ur_event_handle_t *phWaitEvents) try { + return hQueue->get().queueAppendGraphExp(hGraph, pNext, hSignalEvent, + numWaitEvents, phWaitEvents); +} catch (...) { + return exceptionToResult(std::current_exception()); +} +ur_result_t urQueueIsGraphCaptureEnabledExp(ur_queue_handle_t hQueue, + bool *hResult) try { + return hQueue->get().queueIsGraphCapteEnabledExp(hResult); +} catch (...) { + return exceptionToResult(std::current_exception()); +} } // namespace ur::level_zero diff --git a/unified-runtime/source/adapters/level_zero/v2/queue_api.hpp b/unified-runtime/source/adapters/level_zero/v2/queue_api.hpp index 530897288f0fa..8b38ea91adf5f 100644 --- a/unified-runtime/source/adapters/level_zero/v2/queue_api.hpp +++ b/unified-runtime/source/adapters/level_zero/v2/queue_api.hpp @@ -178,4 +178,13 @@ struct ur_queue_t_ { const ur_exp_enqueue_native_command_properties_t *, uint32_t, const ur_event_handle_t *, ur_event_handle_t *) = 0; + virtual ur_result_t queueBeginGraphCapteExp(void *) = 0; + virtual ur_result_t queueBeginCapteIntoGraphExp(ur_exp_graph_handle_t, + void *) = 0; + virtual ur_result_t queueEndGraphCapteExp(ur_exp_graph_handle_t *, + void *) = 0; + virtual ur_result_t queueAppendGraphExp(ur_exp_executable_graph_handle_t, + void *, ur_event_handle_t, uint32_t, + ur_event_handle_t *) = 0; + virtual ur_result_t queueIsGraphCapteEnabledExp(bool *) = 0; }; diff --git a/unified-runtime/source/adapters/level_zero/v2/queue_immediate_in_order.hpp b/unified-runtime/source/adapters/level_zero/v2/queue_immediate_in_order.hpp index 7f40d9139d63a..bfe4b4d130c28 100644 --- a/unified-runtime/source/adapters/level_zero/v2/queue_immediate_in_order.hpp +++ b/unified-runtime/source/adapters/level_zero/v2/queue_immediate_in_order.hpp @@ -470,6 +470,40 @@ struct ur_queue_immediate_in_order_t : ur_object, ur_queue_t_ { createEventIfRequested(eventPool.get(), phEvent, this)); } + // Graph capture experimental APIs - not supported on Level Zero adapter v2 + ur_result_t queueBeginGraphCapteExp(void *pNext) override { + (void)pNext; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + ur_result_t queueBeginCapteIntoGraphExp(ur_exp_graph_handle_t hGraph, + void *pNext) override { + (void)hGraph; + (void)pNext; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + ur_result_t queueEndGraphCapteExp(ur_exp_graph_handle_t *phGraph, + void *pNext) override { + (void)phGraph; + (void)pNext; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + ur_result_t queueAppendGraphExp(ur_exp_executable_graph_handle_t hGraph, + void *pNext, ur_event_handle_t hSignalEvent, + uint32_t numWaitEvents, + ur_event_handle_t *phWaitEvents) override { + (void)hGraph; + (void)pNext; + (void)hSignalEvent; + (void)numWaitEvents; + (void)phWaitEvents; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + ur_result_t queueIsGraphCapteEnabledExp(bool *pResult) override { + if (pResult) + *pResult = false; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + ur::RefCount RefCount; }; diff --git a/unified-runtime/source/adapters/level_zero/v2/queue_immediate_out_of_order.hpp b/unified-runtime/source/adapters/level_zero/v2/queue_immediate_out_of_order.hpp index 564c0472edb81..129c94a865ea3 100644 --- a/unified-runtime/source/adapters/level_zero/v2/queue_immediate_out_of_order.hpp +++ b/unified-runtime/source/adapters/level_zero/v2/queue_immediate_out_of_order.hpp @@ -524,6 +524,40 @@ struct ur_queue_immediate_out_of_order_t : ur_object, ur_queue_t_ { createEventIfRequested(eventPool.get(), phEvent, this)); } + // Graph capture experimental APIs - not supported on Level Zero adapter v2 + ur_result_t queueBeginGraphCapteExp(void *pNext) override { + (void)pNext; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + ur_result_t queueBeginCapteIntoGraphExp(ur_exp_graph_handle_t hGraph, + void *pNext) override { + (void)hGraph; + (void)pNext; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + ur_result_t queueEndGraphCapteExp(ur_exp_graph_handle_t *phGraph, + void *pNext) override { + (void)phGraph; + (void)pNext; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + ur_result_t queueAppendGraphExp(ur_exp_executable_graph_handle_t hGraph, + void *pNext, ur_event_handle_t hSignalEvent, + uint32_t numWaitEvents, + ur_event_handle_t *phWaitEvents) override { + (void)hGraph; + (void)pNext; + (void)hSignalEvent; + (void)numWaitEvents; + (void)phWaitEvents; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + ur_result_t queueIsGraphCapteEnabledExp(bool *pResult) override { + if (pResult) + *pResult = false; + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + ur::RefCount RefCount; }; diff --git a/unified-runtime/source/adapters/mock/ur_mockddi.cpp b/unified-runtime/source/adapters/mock/ur_mockddi.cpp index 3193e111084cc..3f050cbcc4fb9 100644 --- a/unified-runtime/source/adapters/mock/ur_mockddi.cpp +++ b/unified-runtime/source/adapters/mock/ur_mockddi.cpp @@ -12449,6 +12449,519 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueNativeCommandExp( return exceptionToResult(std::current_exception()); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphCreateExp +__urdlllocal ur_result_t UR_APICALL urGraphCreateExp( + /// [in] Handle of the context object. + ur_context_handle_t hContext, + /// [out][alloc] Pointer to the handle of the created graph object. + ur_exp_graph_handle_t *phGraph, + /// [out] Pointer to extension-specific structure. + void *pNext) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_graph_create_exp_params_t params = {&hContext, &phGraph, &pNext}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback("urGraphCreateExp")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback("urGraphCreateExp")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback("urGraphCreateExp")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urQueueBeginGraphCaptureExp +__urdlllocal ur_result_t UR_APICALL urQueueBeginGraphCaptureExp( + /// [in] Handle of the queue on which to begin graph capture. + ur_queue_handle_t hQueue, + /// [in][optional] Pointer to extension-specific structure. + void *pNext) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_queue_begin_graph_capture_exp_params_t params = {&hQueue, &pNext}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback("urQueueBeginGraphCaptureExp")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback("urQueueBeginGraphCaptureExp")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback("urQueueBeginGraphCaptureExp")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urQueueBeginCaptureIntoGraphExp +__urdlllocal ur_result_t UR_APICALL urQueueBeginCaptureIntoGraphExp( + /// [in] Handle of the queue on which to begin graph capture. + ur_queue_handle_t hQueue, + /// [in] Handle of the graph object to capture into. + ur_exp_graph_handle_t hGraph, + /// [in][optional] Pointer to extension-specific structure. + void *pNext) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_queue_begin_capture_into_graph_exp_params_t params = {&hQueue, &hGraph, + &pNext}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback( + "urQueueBeginCaptureIntoGraphExp")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback( + "urQueueBeginCaptureIntoGraphExp")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback( + "urQueueBeginCaptureIntoGraphExp")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urQueueEndGraphCaptureExp +__urdlllocal ur_result_t UR_APICALL urQueueEndGraphCaptureExp( + /// [in] Handle of the queue on which to end graph capture. + ur_queue_handle_t hQueue, + /// [out] Pointer to the handle of the recorded graph object. If + /// ::urQueueBeginCaptureIntoGraphExp was used to begin the capture, then + /// phGraph will contain the same graph that was passed to it. + ur_exp_graph_handle_t *phGraph, + /// [out][optional] Pointer to extension-specific structure. + void *pNext) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_queue_end_graph_capture_exp_params_t params = {&hQueue, &phGraph, &pNext}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback("urQueueEndGraphCaptureExp")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback("urQueueEndGraphCaptureExp")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback("urQueueEndGraphCaptureExp")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphInstantiateGraphExp +__urdlllocal ur_result_t UR_APICALL urGraphInstantiateGraphExp( + /// [in] Handle of the recorded graph to instantiate. + ur_exp_graph_handle_t hGraph, + /// [out] Pointer to the handle of the instantiated executable graph. + ur_exp_executable_graph_handle_t *phExecGraph, + /// [out][optional] Pointer to extension-specific structure. + void *pNext) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_graph_instantiate_graph_exp_params_t params = {&hGraph, &phExecGraph, + &pNext}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback("urGraphInstantiateGraphExp")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback("urGraphInstantiateGraphExp")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback("urGraphInstantiateGraphExp")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urQueueAppendGraphExp +__urdlllocal ur_result_t UR_APICALL urQueueAppendGraphExp( + /// [in] Handle of the queue to append the graph to. + ur_queue_handle_t hQueue, + /// [in] Handle of the executable graph to append. + ur_exp_executable_graph_handle_t hGraph, + /// [in][optional] Pointer to extension-specific structure. + void *pNext, + /// [in][optional] Event to be signaled on completion. + ur_event_handle_t hSignalEvent, + /// [in][optional] Number of events to wait on before executing. + uint32_t numWaitEvents, + /// [in][optional][range(0, numWaitEvents)] Handle of the events to wait + /// on before launching. + ur_event_handle_t *phWaitEvents) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_queue_append_graph_exp_params_t params = { + &hQueue, &hGraph, &pNext, &hSignalEvent, &numWaitEvents, &phWaitEvents}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback("urQueueAppendGraphExp")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback("urQueueAppendGraphExp")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback("urQueueAppendGraphExp")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphDestroyExp +__urdlllocal ur_result_t UR_APICALL urGraphDestroyExp( + /// [in] Handle of the graph object to destroy. + ur_exp_graph_handle_t hGraph) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_graph_destroy_exp_params_t params = {&hGraph}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback("urGraphDestroyExp")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback("urGraphDestroyExp")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback("urGraphDestroyExp")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphExecutableGraphDestroyExp +__urdlllocal ur_result_t UR_APICALL urGraphExecutableGraphDestroyExp( + /// [in] Handle of the executable graph object to destroy. + ur_exp_executable_graph_handle_t hExecutableGraph) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_graph_executable_graph_destroy_exp_params_t params = {&hExecutableGraph}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback( + "urGraphExecutableGraphDestroyExp")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback( + "urGraphExecutableGraphDestroyExp")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback( + "urGraphExecutableGraphDestroyExp")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urQueueIsGraphCaptureEnabledExp +__urdlllocal ur_result_t UR_APICALL urQueueIsGraphCaptureEnabledExp( + /// [in] Native queue to query. + ur_queue_handle_t hQueue, + /// [out] Pointer to a boolean where the result will be stored. + bool *hResult) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_queue_is_graph_capture_enabled_exp_params_t params = {&hQueue, &hResult}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback( + "urQueueIsGraphCaptureEnabledExp")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback( + "urQueueIsGraphCaptureEnabledExp")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback( + "urQueueIsGraphCaptureEnabledExp")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphIsEmptyExp +__urdlllocal ur_result_t UR_APICALL urGraphIsEmptyExp( + /// [in] Handle of the graph to query. + ur_exp_graph_handle_t hGraph, + /// [out] Pointer to a boolean where the result will be stored. + bool *hResult) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_graph_is_empty_exp_params_t params = {&hGraph, &hResult}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback("urGraphIsEmptyExp")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback("urGraphIsEmptyExp")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback("urGraphIsEmptyExp")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphDumpContentsExp +__urdlllocal ur_result_t UR_APICALL urGraphDumpContentsExp( + /// [in] Handle of the graph to dump. + ur_exp_graph_handle_t hGraph, + /// [in] Path to the file to write the dumped graph contents. + const char *filePath, + /// [in][optional] Pointer to extension-specific structure. + void *pNext) try { + ur_result_t result = UR_RESULT_SUCCESS; + + ur_graph_dump_contents_exp_params_t params = {&hGraph, &filePath, &pNext}; + + auto beforeCallback = reinterpret_cast( + mock::getCallbacks().get_before_callback("urGraphDumpContentsExp")); + if (beforeCallback) { + result = beforeCallback(¶ms); + if (result != UR_RESULT_SUCCESS) { + return result; + } + } + + auto replaceCallback = reinterpret_cast( + mock::getCallbacks().get_replace_callback("urGraphDumpContentsExp")); + if (replaceCallback) { + result = replaceCallback(¶ms); + } else { + + result = UR_RESULT_SUCCESS; + } + + if (result != UR_RESULT_SUCCESS) { + return result; + } + + auto afterCallback = reinterpret_cast( + mock::getCallbacks().get_after_callback("urGraphDumpContentsExp")); + if (afterCallback) { + return afterCallback(¶ms); + } + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + } // namespace driver extern "C" { @@ -12873,6 +13386,45 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetEventProcAddrTable( return exceptionToResult(std::current_exception()); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's GraphExp table +/// with current process' addresses +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION +UR_DLLEXPORT ur_result_t UR_APICALL urGetGraphExpProcAddrTable( + /// [in] API version requested + ur_api_version_t version, + /// [in,out] pointer to table of DDI function pointers + ur_graph_exp_dditable_t *pDdiTable) try { + if (nullptr == pDdiTable) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (driver::d_context.version < version) + return UR_RESULT_ERROR_UNSUPPORTED_VERSION; + + ur_result_t result = UR_RESULT_SUCCESS; + + pDdiTable->pfnCreateExp = driver::urGraphCreateExp; + + pDdiTable->pfnInstantiateGraphExp = driver::urGraphInstantiateGraphExp; + + pDdiTable->pfnDestroyExp = driver::urGraphDestroyExp; + + pDdiTable->pfnExecutableGraphDestroyExp = + driver::urGraphExecutableGraphDestroyExp; + + pDdiTable->pfnIsEmptyExp = driver::urGraphIsEmptyExp; + + pDdiTable->pfnDumpContentsExp = driver::urGraphDumpContentsExp; + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's IPCExp table /// with current process' addresses @@ -13259,6 +13811,44 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetQueueProcAddrTable( return exceptionToResult(std::current_exception()); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's QueueExp table +/// with current process' addresses +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION +UR_DLLEXPORT ur_result_t UR_APICALL urGetQueueExpProcAddrTable( + /// [in] API version requested + ur_api_version_t version, + /// [in,out] pointer to table of DDI function pointers + ur_queue_exp_dditable_t *pDdiTable) try { + if (nullptr == pDdiTable) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (driver::d_context.version < version) + return UR_RESULT_ERROR_UNSUPPORTED_VERSION; + + ur_result_t result = UR_RESULT_SUCCESS; + + pDdiTable->pfnBeginGraphCaptureExp = driver::urQueueBeginGraphCaptureExp; + + pDdiTable->pfnBeginCaptureIntoGraphExp = + driver::urQueueBeginCaptureIntoGraphExp; + + pDdiTable->pfnEndGraphCaptureExp = driver::urQueueEndGraphCaptureExp; + + pDdiTable->pfnAppendGraphExp = driver::urQueueAppendGraphExp; + + pDdiTable->pfnIsGraphCaptureEnabledExp = + driver::urQueueIsGraphCaptureEnabledExp; + + return result; +} catch (...) { + return exceptionToResult(std::current_exception()); +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's Sampler table /// with current process' addresses diff --git a/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp b/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp index 5bcdfbc6f8bb2..06a904338a752 100644 --- a/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp +++ b/unified-runtime/source/loader/layers/tracing/ur_trcddi.cpp @@ -10554,6 +10554,435 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueNativeCommandExp( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphCreateExp +__urdlllocal ur_result_t UR_APICALL urGraphCreateExp( + /// [in] Handle of the context object. + ur_context_handle_t hContext, + /// [out][alloc] Pointer to the handle of the created graph object. + ur_exp_graph_handle_t *phGraph, + /// [out] Pointer to extension-specific structure. + void *pNext) { + auto pfnCreateExp = getContext()->urDdiTable.GraphExp.pfnCreateExp; + + if (nullptr == pfnCreateExp) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_graph_create_exp_params_t params = {&hContext, &phGraph, &pNext}; + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_GRAPH_CREATE_EXP, + "urGraphCreateExp", ¶ms); + + auto &logger = getContext()->logger; + UR_LOG_L(logger, INFO, " ---> urGraphCreateExp\n"); + + ur_result_t result = pfnCreateExp(hContext, phGraph, pNext); + + getContext()->notify_end(UR_FUNCTION_GRAPH_CREATE_EXP, "urGraphCreateExp", + ¶ms, &result, instance); + + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams(args_str, UR_FUNCTION_GRAPH_CREATE_EXP, + ¶ms); + UR_LOG_L(logger, INFO, " <--- urGraphCreateExp({}) -> {};\n", + args_str.str(), result); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urQueueBeginGraphCaptureExp +__urdlllocal ur_result_t UR_APICALL urQueueBeginGraphCaptureExp( + /// [in] Handle of the queue on which to begin graph capture. + ur_queue_handle_t hQueue, + /// [in][optional] Pointer to extension-specific structure. + void *pNext) { + auto pfnBeginGraphCaptureExp = + getContext()->urDdiTable.QueueExp.pfnBeginGraphCaptureExp; + + if (nullptr == pfnBeginGraphCaptureExp) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_queue_begin_graph_capture_exp_params_t params = {&hQueue, &pNext}; + uint64_t instance = + getContext()->notify_begin(UR_FUNCTION_QUEUE_BEGIN_GRAPH_CAPTURE_EXP, + "urQueueBeginGraphCaptureExp", ¶ms); + + auto &logger = getContext()->logger; + UR_LOG_L(logger, INFO, " ---> urQueueBeginGraphCaptureExp\n"); + + ur_result_t result = pfnBeginGraphCaptureExp(hQueue, pNext); + + getContext()->notify_end(UR_FUNCTION_QUEUE_BEGIN_GRAPH_CAPTURE_EXP, + "urQueueBeginGraphCaptureExp", ¶ms, &result, + instance); + + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams( + args_str, UR_FUNCTION_QUEUE_BEGIN_GRAPH_CAPTURE_EXP, ¶ms); + UR_LOG_L(logger, INFO, " <--- urQueueBeginGraphCaptureExp({}) -> {};\n", + args_str.str(), result); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urQueueBeginCaptureIntoGraphExp +__urdlllocal ur_result_t UR_APICALL urQueueBeginCaptureIntoGraphExp( + /// [in] Handle of the queue on which to begin graph capture. + ur_queue_handle_t hQueue, + /// [in] Handle of the graph object to capture into. + ur_exp_graph_handle_t hGraph, + /// [in][optional] Pointer to extension-specific structure. + void *pNext) { + auto pfnBeginCaptureIntoGraphExp = + getContext()->urDdiTable.QueueExp.pfnBeginCaptureIntoGraphExp; + + if (nullptr == pfnBeginCaptureIntoGraphExp) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_queue_begin_capture_into_graph_exp_params_t params = {&hQueue, &hGraph, + &pNext}; + uint64_t instance = + getContext()->notify_begin(UR_FUNCTION_QUEUE_BEGIN_CAPTURE_INTO_GRAPH_EXP, + "urQueueBeginCaptureIntoGraphExp", ¶ms); + + auto &logger = getContext()->logger; + UR_LOG_L(logger, INFO, " ---> urQueueBeginCaptureIntoGraphExp\n"); + + ur_result_t result = pfnBeginCaptureIntoGraphExp(hQueue, hGraph, pNext); + + getContext()->notify_end(UR_FUNCTION_QUEUE_BEGIN_CAPTURE_INTO_GRAPH_EXP, + "urQueueBeginCaptureIntoGraphExp", ¶ms, &result, + instance); + + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams( + args_str, UR_FUNCTION_QUEUE_BEGIN_CAPTURE_INTO_GRAPH_EXP, ¶ms); + UR_LOG_L(logger, INFO, + " <--- urQueueBeginCaptureIntoGraphExp({}) -> {};\n", + args_str.str(), result); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urQueueEndGraphCaptureExp +__urdlllocal ur_result_t UR_APICALL urQueueEndGraphCaptureExp( + /// [in] Handle of the queue on which to end graph capture. + ur_queue_handle_t hQueue, + /// [out] Pointer to the handle of the recorded graph object. If + /// ::urQueueBeginCaptureIntoGraphExp was used to begin the capture, then + /// phGraph will contain the same graph that was passed to it. + ur_exp_graph_handle_t *phGraph, + /// [out][optional] Pointer to extension-specific structure. + void *pNext) { + auto pfnEndGraphCaptureExp = + getContext()->urDdiTable.QueueExp.pfnEndGraphCaptureExp; + + if (nullptr == pfnEndGraphCaptureExp) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_queue_end_graph_capture_exp_params_t params = {&hQueue, &phGraph, &pNext}; + uint64_t instance = + getContext()->notify_begin(UR_FUNCTION_QUEUE_END_GRAPH_CAPTURE_EXP, + "urQueueEndGraphCaptureExp", ¶ms); + + auto &logger = getContext()->logger; + UR_LOG_L(logger, INFO, " ---> urQueueEndGraphCaptureExp\n"); + + ur_result_t result = pfnEndGraphCaptureExp(hQueue, phGraph, pNext); + + getContext()->notify_end(UR_FUNCTION_QUEUE_END_GRAPH_CAPTURE_EXP, + "urQueueEndGraphCaptureExp", ¶ms, &result, + instance); + + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams( + args_str, UR_FUNCTION_QUEUE_END_GRAPH_CAPTURE_EXP, ¶ms); + UR_LOG_L(logger, INFO, " <--- urQueueEndGraphCaptureExp({}) -> {};\n", + args_str.str(), result); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphInstantiateGraphExp +__urdlllocal ur_result_t UR_APICALL urGraphInstantiateGraphExp( + /// [in] Handle of the recorded graph to instantiate. + ur_exp_graph_handle_t hGraph, + /// [out] Pointer to the handle of the instantiated executable graph. + ur_exp_executable_graph_handle_t *phExecGraph, + /// [out][optional] Pointer to extension-specific structure. + void *pNext) { + auto pfnInstantiateGraphExp = + getContext()->urDdiTable.GraphExp.pfnInstantiateGraphExp; + + if (nullptr == pfnInstantiateGraphExp) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_graph_instantiate_graph_exp_params_t params = {&hGraph, &phExecGraph, + &pNext}; + uint64_t instance = + getContext()->notify_begin(UR_FUNCTION_GRAPH_INSTANTIATE_GRAPH_EXP, + "urGraphInstantiateGraphExp", ¶ms); + + auto &logger = getContext()->logger; + UR_LOG_L(logger, INFO, " ---> urGraphInstantiateGraphExp\n"); + + ur_result_t result = pfnInstantiateGraphExp(hGraph, phExecGraph, pNext); + + getContext()->notify_end(UR_FUNCTION_GRAPH_INSTANTIATE_GRAPH_EXP, + "urGraphInstantiateGraphExp", ¶ms, &result, + instance); + + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams( + args_str, UR_FUNCTION_GRAPH_INSTANTIATE_GRAPH_EXP, ¶ms); + UR_LOG_L(logger, INFO, " <--- urGraphInstantiateGraphExp({}) -> {};\n", + args_str.str(), result); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urQueueAppendGraphExp +__urdlllocal ur_result_t UR_APICALL urQueueAppendGraphExp( + /// [in] Handle of the queue to append the graph to. + ur_queue_handle_t hQueue, + /// [in] Handle of the executable graph to append. + ur_exp_executable_graph_handle_t hGraph, + /// [in][optional] Pointer to extension-specific structure. + void *pNext, + /// [in][optional] Event to be signaled on completion. + ur_event_handle_t hSignalEvent, + /// [in][optional] Number of events to wait on before executing. + uint32_t numWaitEvents, + /// [in][optional][range(0, numWaitEvents)] Handle of the events to wait + /// on before launching. + ur_event_handle_t *phWaitEvents) { + auto pfnAppendGraphExp = getContext()->urDdiTable.QueueExp.pfnAppendGraphExp; + + if (nullptr == pfnAppendGraphExp) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_queue_append_graph_exp_params_t params = { + &hQueue, &hGraph, &pNext, &hSignalEvent, &numWaitEvents, &phWaitEvents}; + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_QUEUE_APPEND_GRAPH_EXP, "urQueueAppendGraphExp", ¶ms); + + auto &logger = getContext()->logger; + UR_LOG_L(logger, INFO, " ---> urQueueAppendGraphExp\n"); + + ur_result_t result = pfnAppendGraphExp(hQueue, hGraph, pNext, hSignalEvent, + numWaitEvents, phWaitEvents); + + getContext()->notify_end(UR_FUNCTION_QUEUE_APPEND_GRAPH_EXP, + "urQueueAppendGraphExp", ¶ms, &result, instance); + + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams( + args_str, UR_FUNCTION_QUEUE_APPEND_GRAPH_EXP, ¶ms); + UR_LOG_L(logger, INFO, " <--- urQueueAppendGraphExp({}) -> {};\n", + args_str.str(), result); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphDestroyExp +__urdlllocal ur_result_t UR_APICALL urGraphDestroyExp( + /// [in] Handle of the graph object to destroy. + ur_exp_graph_handle_t hGraph) { + auto pfnDestroyExp = getContext()->urDdiTable.GraphExp.pfnDestroyExp; + + if (nullptr == pfnDestroyExp) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_graph_destroy_exp_params_t params = {&hGraph}; + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_GRAPH_DESTROY_EXP, + "urGraphDestroyExp", ¶ms); + + auto &logger = getContext()->logger; + UR_LOG_L(logger, INFO, " ---> urGraphDestroyExp\n"); + + ur_result_t result = pfnDestroyExp(hGraph); + + getContext()->notify_end(UR_FUNCTION_GRAPH_DESTROY_EXP, "urGraphDestroyExp", + ¶ms, &result, instance); + + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams(args_str, UR_FUNCTION_GRAPH_DESTROY_EXP, + ¶ms); + UR_LOG_L(logger, INFO, " <--- urGraphDestroyExp({}) -> {};\n", + args_str.str(), result); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphExecutableGraphDestroyExp +__urdlllocal ur_result_t UR_APICALL urGraphExecutableGraphDestroyExp( + /// [in] Handle of the executable graph object to destroy. + ur_exp_executable_graph_handle_t hExecutableGraph) { + auto pfnExecutableGraphDestroyExp = + getContext()->urDdiTable.GraphExp.pfnExecutableGraphDestroyExp; + + if (nullptr == pfnExecutableGraphDestroyExp) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_graph_executable_graph_destroy_exp_params_t params = {&hExecutableGraph}; + uint64_t instance = + getContext()->notify_begin(UR_FUNCTION_GRAPH_EXECUTABLE_GRAPH_DESTROY_EXP, + "urGraphExecutableGraphDestroyExp", ¶ms); + + auto &logger = getContext()->logger; + UR_LOG_L(logger, INFO, " ---> urGraphExecutableGraphDestroyExp\n"); + + ur_result_t result = pfnExecutableGraphDestroyExp(hExecutableGraph); + + getContext()->notify_end(UR_FUNCTION_GRAPH_EXECUTABLE_GRAPH_DESTROY_EXP, + "urGraphExecutableGraphDestroyExp", ¶ms, &result, + instance); + + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams( + args_str, UR_FUNCTION_GRAPH_EXECUTABLE_GRAPH_DESTROY_EXP, ¶ms); + UR_LOG_L(logger, INFO, + " <--- urGraphExecutableGraphDestroyExp({}) -> {};\n", + args_str.str(), result); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urQueueIsGraphCaptureEnabledExp +__urdlllocal ur_result_t UR_APICALL urQueueIsGraphCaptureEnabledExp( + /// [in] Native queue to query. + ur_queue_handle_t hQueue, + /// [out] Pointer to a boolean where the result will be stored. + bool *hResult) { + auto pfnIsGraphCaptureEnabledExp = + getContext()->urDdiTable.QueueExp.pfnIsGraphCaptureEnabledExp; + + if (nullptr == pfnIsGraphCaptureEnabledExp) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_queue_is_graph_capture_enabled_exp_params_t params = {&hQueue, &hResult}; + uint64_t instance = + getContext()->notify_begin(UR_FUNCTION_QUEUE_IS_GRAPH_CAPTURE_ENABLED_EXP, + "urQueueIsGraphCaptureEnabledExp", ¶ms); + + auto &logger = getContext()->logger; + UR_LOG_L(logger, INFO, " ---> urQueueIsGraphCaptureEnabledExp\n"); + + ur_result_t result = pfnIsGraphCaptureEnabledExp(hQueue, hResult); + + getContext()->notify_end(UR_FUNCTION_QUEUE_IS_GRAPH_CAPTURE_ENABLED_EXP, + "urQueueIsGraphCaptureEnabledExp", ¶ms, &result, + instance); + + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams( + args_str, UR_FUNCTION_QUEUE_IS_GRAPH_CAPTURE_ENABLED_EXP, ¶ms); + UR_LOG_L(logger, INFO, + " <--- urQueueIsGraphCaptureEnabledExp({}) -> {};\n", + args_str.str(), result); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphIsEmptyExp +__urdlllocal ur_result_t UR_APICALL urGraphIsEmptyExp( + /// [in] Handle of the graph to query. + ur_exp_graph_handle_t hGraph, + /// [out] Pointer to a boolean where the result will be stored. + bool *hResult) { + auto pfnIsEmptyExp = getContext()->urDdiTable.GraphExp.pfnIsEmptyExp; + + if (nullptr == pfnIsEmptyExp) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_graph_is_empty_exp_params_t params = {&hGraph, &hResult}; + uint64_t instance = getContext()->notify_begin(UR_FUNCTION_GRAPH_IS_EMPTY_EXP, + "urGraphIsEmptyExp", ¶ms); + + auto &logger = getContext()->logger; + UR_LOG_L(logger, INFO, " ---> urGraphIsEmptyExp\n"); + + ur_result_t result = pfnIsEmptyExp(hGraph, hResult); + + getContext()->notify_end(UR_FUNCTION_GRAPH_IS_EMPTY_EXP, "urGraphIsEmptyExp", + ¶ms, &result, instance); + + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams(args_str, UR_FUNCTION_GRAPH_IS_EMPTY_EXP, + ¶ms); + UR_LOG_L(logger, INFO, " <--- urGraphIsEmptyExp({}) -> {};\n", + args_str.str(), result); + } + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphDumpContentsExp +__urdlllocal ur_result_t UR_APICALL urGraphDumpContentsExp( + /// [in] Handle of the graph to dump. + ur_exp_graph_handle_t hGraph, + /// [in] Path to the file to write the dumped graph contents. + const char *filePath, + /// [in][optional] Pointer to extension-specific structure. + void *pNext) { + auto pfnDumpContentsExp = + getContext()->urDdiTable.GraphExp.pfnDumpContentsExp; + + if (nullptr == pfnDumpContentsExp) + return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ur_graph_dump_contents_exp_params_t params = {&hGraph, &filePath, &pNext}; + uint64_t instance = getContext()->notify_begin( + UR_FUNCTION_GRAPH_DUMP_CONTENTS_EXP, "urGraphDumpContentsExp", ¶ms); + + auto &logger = getContext()->logger; + UR_LOG_L(logger, INFO, " ---> urGraphDumpContentsExp\n"); + + ur_result_t result = pfnDumpContentsExp(hGraph, filePath, pNext); + + getContext()->notify_end(UR_FUNCTION_GRAPH_DUMP_CONTENTS_EXP, + "urGraphDumpContentsExp", ¶ms, &result, + instance); + + if (logger.getLevel() <= UR_LOGGER_LEVEL_INFO) { + std::ostringstream args_str; + ur::extras::printFunctionParams( + args_str, UR_FUNCTION_GRAPH_DUMP_CONTENTS_EXP, ¶ms); + UR_LOG_L(logger, INFO, " <--- urGraphDumpContentsExp({}) -> {};\n", + args_str.str(), result); + } + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's Adapter table /// with current process' addresses @@ -11122,6 +11551,55 @@ __urdlllocal ur_result_t UR_APICALL urGetEventProcAddrTable( return result; } /////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's GraphExp table +/// with current process' addresses +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION +__urdlllocal ur_result_t UR_APICALL urGetGraphExpProcAddrTable( + /// [in] API version requested + ur_api_version_t version, + /// [in,out] pointer to table of DDI function pointers + ur_graph_exp_dditable_t *pDdiTable) { + auto &dditable = ur_tracing_layer::getContext()->urDdiTable.GraphExp; + + if (nullptr == pDdiTable) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != + UR_MAJOR_VERSION(version) || + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > + UR_MINOR_VERSION(version)) + return UR_RESULT_ERROR_UNSUPPORTED_VERSION; + + ur_result_t result = UR_RESULT_SUCCESS; + + dditable.pfnCreateExp = pDdiTable->pfnCreateExp; + pDdiTable->pfnCreateExp = ur_tracing_layer::urGraphCreateExp; + + dditable.pfnInstantiateGraphExp = pDdiTable->pfnInstantiateGraphExp; + pDdiTable->pfnInstantiateGraphExp = + ur_tracing_layer::urGraphInstantiateGraphExp; + + dditable.pfnDestroyExp = pDdiTable->pfnDestroyExp; + pDdiTable->pfnDestroyExp = ur_tracing_layer::urGraphDestroyExp; + + dditable.pfnExecutableGraphDestroyExp = + pDdiTable->pfnExecutableGraphDestroyExp; + pDdiTable->pfnExecutableGraphDestroyExp = + ur_tracing_layer::urGraphExecutableGraphDestroyExp; + + dditable.pfnIsEmptyExp = pDdiTable->pfnIsEmptyExp; + pDdiTable->pfnIsEmptyExp = ur_tracing_layer::urGraphIsEmptyExp; + + dditable.pfnDumpContentsExp = pDdiTable->pfnDumpContentsExp; + pDdiTable->pfnDumpContentsExp = ur_tracing_layer::urGraphDumpContentsExp; + + return result; +} +/////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's IPCExp table /// with current process' addresses /// @@ -11605,6 +12083,53 @@ __urdlllocal ur_result_t UR_APICALL urGetQueueProcAddrTable( return result; } /////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's QueueExp table +/// with current process' addresses +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION +__urdlllocal ur_result_t UR_APICALL urGetQueueExpProcAddrTable( + /// [in] API version requested + ur_api_version_t version, + /// [in,out] pointer to table of DDI function pointers + ur_queue_exp_dditable_t *pDdiTable) { + auto &dditable = ur_tracing_layer::getContext()->urDdiTable.QueueExp; + + if (nullptr == pDdiTable) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (UR_MAJOR_VERSION(ur_tracing_layer::getContext()->version) != + UR_MAJOR_VERSION(version) || + UR_MINOR_VERSION(ur_tracing_layer::getContext()->version) > + UR_MINOR_VERSION(version)) + return UR_RESULT_ERROR_UNSUPPORTED_VERSION; + + ur_result_t result = UR_RESULT_SUCCESS; + + dditable.pfnBeginGraphCaptureExp = pDdiTable->pfnBeginGraphCaptureExp; + pDdiTable->pfnBeginGraphCaptureExp = + ur_tracing_layer::urQueueBeginGraphCaptureExp; + + dditable.pfnBeginCaptureIntoGraphExp = pDdiTable->pfnBeginCaptureIntoGraphExp; + pDdiTable->pfnBeginCaptureIntoGraphExp = + ur_tracing_layer::urQueueBeginCaptureIntoGraphExp; + + dditable.pfnEndGraphCaptureExp = pDdiTable->pfnEndGraphCaptureExp; + pDdiTable->pfnEndGraphCaptureExp = + ur_tracing_layer::urQueueEndGraphCaptureExp; + + dditable.pfnAppendGraphExp = pDdiTable->pfnAppendGraphExp; + pDdiTable->pfnAppendGraphExp = ur_tracing_layer::urQueueAppendGraphExp; + + dditable.pfnIsGraphCaptureEnabledExp = pDdiTable->pfnIsGraphCaptureEnabledExp; + pDdiTable->pfnIsGraphCaptureEnabledExp = + ur_tracing_layer::urQueueIsGraphCaptureEnabledExp; + + return result; +} +/////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's Sampler table /// with current process' addresses /// @@ -12003,6 +12528,11 @@ ur_result_t context_t::init(ur_dditable_t *dditable, &dditable->Event); } + if (UR_RESULT_SUCCESS == result) { + result = ur_tracing_layer::urGetGraphExpProcAddrTable( + UR_API_VERSION_CURRENT, &dditable->GraphExp); + } + if (UR_RESULT_SUCCESS == result) { result = ur_tracing_layer::urGetIPCExpProcAddrTable(UR_API_VERSION_CURRENT, &dditable->IPCExp); @@ -12048,6 +12578,11 @@ ur_result_t context_t::init(ur_dditable_t *dditable, &dditable->Queue); } + if (UR_RESULT_SUCCESS == result) { + result = ur_tracing_layer::urGetQueueExpProcAddrTable( + UR_API_VERSION_CURRENT, &dditable->QueueExp); + } + if (UR_RESULT_SUCCESS == result) { result = ur_tracing_layer::urGetSamplerProcAddrTable(UR_API_VERSION_CURRENT, &dditable->Sampler); diff --git a/unified-runtime/source/loader/layers/validation/ur_valddi.cpp b/unified-runtime/source/loader/layers/validation/ur_valddi.cpp index 8b5dae8f1c2d3..6ee8409dff5be 100644 --- a/unified-runtime/source/loader/layers/validation/ur_valddi.cpp +++ b/unified-runtime/source/loader/layers/validation/ur_valddi.cpp @@ -11363,6 +11363,346 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueNativeCommandExp( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphCreateExp +__urdlllocal ur_result_t UR_APICALL urGraphCreateExp( + /// [in] Handle of the context object. + ur_context_handle_t hContext, + /// [out][alloc] Pointer to the handle of the created graph object. + ur_exp_graph_handle_t *phGraph, + /// [out] Pointer to extension-specific structure. + void *pNext) { + auto pfnCreateExp = getContext()->urDdiTable.GraphExp.pfnCreateExp; + + if (nullptr == pfnCreateExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == phGraph) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL == pNext) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL == hContext) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hContext)) { + URLOG_CTX_INVALID_REFERENCE(hContext); + } + + ur_result_t result = pfnCreateExp(hContext, phGraph, pNext); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urQueueBeginGraphCaptureExp +__urdlllocal ur_result_t UR_APICALL urQueueBeginGraphCaptureExp( + /// [in] Handle of the queue on which to begin graph capture. + ur_queue_handle_t hQueue, + /// [in][optional] Pointer to extension-specific structure. + void *pNext) { + auto pfnBeginGraphCaptureExp = + getContext()->urDdiTable.QueueExp.pfnBeginGraphCaptureExp; + + if (nullptr == pfnBeginGraphCaptureExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == hQueue) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hQueue)) { + URLOG_CTX_INVALID_REFERENCE(hQueue); + } + + ur_result_t result = pfnBeginGraphCaptureExp(hQueue, pNext); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urQueueBeginCaptureIntoGraphExp +__urdlllocal ur_result_t UR_APICALL urQueueBeginCaptureIntoGraphExp( + /// [in] Handle of the queue on which to begin graph capture. + ur_queue_handle_t hQueue, + /// [in] Handle of the graph object to capture into. + ur_exp_graph_handle_t hGraph, + /// [in][optional] Pointer to extension-specific structure. + void *pNext) { + auto pfnBeginCaptureIntoGraphExp = + getContext()->urDdiTable.QueueExp.pfnBeginCaptureIntoGraphExp; + + if (nullptr == pfnBeginCaptureIntoGraphExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == hQueue) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + + if (NULL == hGraph) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hQueue)) { + URLOG_CTX_INVALID_REFERENCE(hQueue); + } + + ur_result_t result = pfnBeginCaptureIntoGraphExp(hQueue, hGraph, pNext); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urQueueEndGraphCaptureExp +__urdlllocal ur_result_t UR_APICALL urQueueEndGraphCaptureExp( + /// [in] Handle of the queue on which to end graph capture. + ur_queue_handle_t hQueue, + /// [out] Pointer to the handle of the recorded graph object. If + /// ::urQueueBeginCaptureIntoGraphExp was used to begin the capture, then + /// phGraph will contain the same graph that was passed to it. + ur_exp_graph_handle_t *phGraph, + /// [out][optional] Pointer to extension-specific structure. + void *pNext) { + auto pfnEndGraphCaptureExp = + getContext()->urDdiTable.QueueExp.pfnEndGraphCaptureExp; + + if (nullptr == pfnEndGraphCaptureExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == phGraph) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL == hQueue) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hQueue)) { + URLOG_CTX_INVALID_REFERENCE(hQueue); + } + + ur_result_t result = pfnEndGraphCaptureExp(hQueue, phGraph, pNext); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphInstantiateGraphExp +__urdlllocal ur_result_t UR_APICALL urGraphInstantiateGraphExp( + /// [in] Handle of the recorded graph to instantiate. + ur_exp_graph_handle_t hGraph, + /// [out] Pointer to the handle of the instantiated executable graph. + ur_exp_executable_graph_handle_t *phExecGraph, + /// [out][optional] Pointer to extension-specific structure. + void *pNext) { + auto pfnInstantiateGraphExp = + getContext()->urDdiTable.GraphExp.pfnInstantiateGraphExp; + + if (nullptr == pfnInstantiateGraphExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == phExecGraph) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL == hGraph) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + ur_result_t result = pfnInstantiateGraphExp(hGraph, phExecGraph, pNext); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urQueueAppendGraphExp +__urdlllocal ur_result_t UR_APICALL urQueueAppendGraphExp( + /// [in] Handle of the queue to append the graph to. + ur_queue_handle_t hQueue, + /// [in] Handle of the executable graph to append. + ur_exp_executable_graph_handle_t hGraph, + /// [in][optional] Pointer to extension-specific structure. + void *pNext, + /// [in][optional] Event to be signaled on completion. + ur_event_handle_t hSignalEvent, + /// [in][optional] Number of events to wait on before executing. + uint32_t numWaitEvents, + /// [in][optional][range(0, numWaitEvents)] Handle of the events to wait + /// on before launching. + ur_event_handle_t *phWaitEvents) { + auto pfnAppendGraphExp = getContext()->urDdiTable.QueueExp.pfnAppendGraphExp; + + if (nullptr == pfnAppendGraphExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == hQueue) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + + if (NULL == hGraph) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hQueue)) { + URLOG_CTX_INVALID_REFERENCE(hQueue); + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hSignalEvent)) { + URLOG_CTX_INVALID_REFERENCE(hSignalEvent); + } + + ur_result_t result = pfnAppendGraphExp(hQueue, hGraph, pNext, hSignalEvent, + numWaitEvents, phWaitEvents); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphDestroyExp +__urdlllocal ur_result_t UR_APICALL urGraphDestroyExp( + /// [in] Handle of the graph object to destroy. + ur_exp_graph_handle_t hGraph) { + auto pfnDestroyExp = getContext()->urDdiTable.GraphExp.pfnDestroyExp; + + if (nullptr == pfnDestroyExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == hGraph) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + ur_result_t result = pfnDestroyExp(hGraph); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphExecutableGraphDestroyExp +__urdlllocal ur_result_t UR_APICALL urGraphExecutableGraphDestroyExp( + /// [in] Handle of the executable graph object to destroy. + ur_exp_executable_graph_handle_t hExecutableGraph) { + auto pfnExecutableGraphDestroyExp = + getContext()->urDdiTable.GraphExp.pfnExecutableGraphDestroyExp; + + if (nullptr == pfnExecutableGraphDestroyExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == hExecutableGraph) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + ur_result_t result = pfnExecutableGraphDestroyExp(hExecutableGraph); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urQueueIsGraphCaptureEnabledExp +__urdlllocal ur_result_t UR_APICALL urQueueIsGraphCaptureEnabledExp( + /// [in] Native queue to query. + ur_queue_handle_t hQueue, + /// [out] Pointer to a boolean where the result will be stored. + bool *hResult) { + auto pfnIsGraphCaptureEnabledExp = + getContext()->urDdiTable.QueueExp.pfnIsGraphCaptureEnabledExp; + + if (nullptr == pfnIsGraphCaptureEnabledExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == hResult) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL == hQueue) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + if (getContext()->enableLifetimeValidation && + !getContext()->refCountContext->isReferenceValid(hQueue)) { + URLOG_CTX_INVALID_REFERENCE(hQueue); + } + + ur_result_t result = pfnIsGraphCaptureEnabledExp(hQueue, hResult); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphIsEmptyExp +__urdlllocal ur_result_t UR_APICALL urGraphIsEmptyExp( + /// [in] Handle of the graph to query. + ur_exp_graph_handle_t hGraph, + /// [out] Pointer to a boolean where the result will be stored. + bool *hResult) { + auto pfnIsEmptyExp = getContext()->urDdiTable.GraphExp.pfnIsEmptyExp; + + if (nullptr == pfnIsEmptyExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == hResult) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL == hGraph) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + ur_result_t result = pfnIsEmptyExp(hGraph, hResult); + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphDumpContentsExp +__urdlllocal ur_result_t UR_APICALL urGraphDumpContentsExp( + /// [in] Handle of the graph to dump. + ur_exp_graph_handle_t hGraph, + /// [in] Path to the file to write the dumped graph contents. + const char *filePath, + /// [in][optional] Pointer to extension-specific structure. + void *pNext) { + auto pfnDumpContentsExp = + getContext()->urDdiTable.GraphExp.pfnDumpContentsExp; + + if (nullptr == pfnDumpContentsExp) { + return UR_RESULT_ERROR_UNINITIALIZED; + } + + if (getContext()->enableParameterValidation) { + if (NULL == filePath) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (NULL == hGraph) + return UR_RESULT_ERROR_INVALID_NULL_HANDLE; + } + + ur_result_t result = pfnDumpContentsExp(hGraph, filePath, pNext); + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's Adapter table /// with current process' addresses @@ -11944,6 +12284,56 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetEventProcAddrTable( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's GraphExp table +/// with current process' addresses +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION +UR_DLLEXPORT ur_result_t UR_APICALL urGetGraphExpProcAddrTable( + /// [in] API version requested + ur_api_version_t version, + /// [in,out] pointer to table of DDI function pointers + ur_graph_exp_dditable_t *pDdiTable) { + auto &dditable = ur_validation_layer::getContext()->urDdiTable.GraphExp; + + if (nullptr == pDdiTable) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != + UR_MAJOR_VERSION(version) || + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > + UR_MINOR_VERSION(version)) + return UR_RESULT_ERROR_UNSUPPORTED_VERSION; + + ur_result_t result = UR_RESULT_SUCCESS; + + dditable.pfnCreateExp = pDdiTable->pfnCreateExp; + pDdiTable->pfnCreateExp = ur_validation_layer::urGraphCreateExp; + + dditable.pfnInstantiateGraphExp = pDdiTable->pfnInstantiateGraphExp; + pDdiTable->pfnInstantiateGraphExp = + ur_validation_layer::urGraphInstantiateGraphExp; + + dditable.pfnDestroyExp = pDdiTable->pfnDestroyExp; + pDdiTable->pfnDestroyExp = ur_validation_layer::urGraphDestroyExp; + + dditable.pfnExecutableGraphDestroyExp = + pDdiTable->pfnExecutableGraphDestroyExp; + pDdiTable->pfnExecutableGraphDestroyExp = + ur_validation_layer::urGraphExecutableGraphDestroyExp; + + dditable.pfnIsEmptyExp = pDdiTable->pfnIsEmptyExp; + pDdiTable->pfnIsEmptyExp = ur_validation_layer::urGraphIsEmptyExp; + + dditable.pfnDumpContentsExp = pDdiTable->pfnDumpContentsExp; + pDdiTable->pfnDumpContentsExp = ur_validation_layer::urGraphDumpContentsExp; + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's IPCExp table /// with current process' addresses @@ -12440,6 +12830,54 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetQueueProcAddrTable( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's QueueExp table +/// with current process' addresses +/// +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::UR_RESULT_ERROR_UNSUPPORTED_VERSION +UR_DLLEXPORT ur_result_t UR_APICALL urGetQueueExpProcAddrTable( + /// [in] API version requested + ur_api_version_t version, + /// [in,out] pointer to table of DDI function pointers + ur_queue_exp_dditable_t *pDdiTable) { + auto &dditable = ur_validation_layer::getContext()->urDdiTable.QueueExp; + + if (nullptr == pDdiTable) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (UR_MAJOR_VERSION(ur_validation_layer::getContext()->version) != + UR_MAJOR_VERSION(version) || + UR_MINOR_VERSION(ur_validation_layer::getContext()->version) > + UR_MINOR_VERSION(version)) + return UR_RESULT_ERROR_UNSUPPORTED_VERSION; + + ur_result_t result = UR_RESULT_SUCCESS; + + dditable.pfnBeginGraphCaptureExp = pDdiTable->pfnBeginGraphCaptureExp; + pDdiTable->pfnBeginGraphCaptureExp = + ur_validation_layer::urQueueBeginGraphCaptureExp; + + dditable.pfnBeginCaptureIntoGraphExp = pDdiTable->pfnBeginCaptureIntoGraphExp; + pDdiTable->pfnBeginCaptureIntoGraphExp = + ur_validation_layer::urQueueBeginCaptureIntoGraphExp; + + dditable.pfnEndGraphCaptureExp = pDdiTable->pfnEndGraphCaptureExp; + pDdiTable->pfnEndGraphCaptureExp = + ur_validation_layer::urQueueEndGraphCaptureExp; + + dditable.pfnAppendGraphExp = pDdiTable->pfnAppendGraphExp; + pDdiTable->pfnAppendGraphExp = ur_validation_layer::urQueueAppendGraphExp; + + dditable.pfnIsGraphCaptureEnabledExp = pDdiTable->pfnIsGraphCaptureEnabledExp; + pDdiTable->pfnIsGraphCaptureEnabledExp = + ur_validation_layer::urQueueIsGraphCaptureEnabledExp; + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's Sampler table /// with current process' addresses @@ -12862,6 +13300,11 @@ ur_result_t context_t::init(ur_dditable_t *dditable, UR_API_VERSION_CURRENT, &dditable->Event); } + if (UR_RESULT_SUCCESS == result) { + result = ur_validation_layer::urGetGraphExpProcAddrTable( + UR_API_VERSION_CURRENT, &dditable->GraphExp); + } + if (UR_RESULT_SUCCESS == result) { result = ur_validation_layer::urGetIPCExpProcAddrTable( UR_API_VERSION_CURRENT, &dditable->IPCExp); @@ -12907,6 +13350,11 @@ ur_result_t context_t::init(ur_dditable_t *dditable, UR_API_VERSION_CURRENT, &dditable->Queue); } + if (UR_RESULT_SUCCESS == result) { + result = ur_validation_layer::urGetQueueExpProcAddrTable( + UR_API_VERSION_CURRENT, &dditable->QueueExp); + } + if (UR_RESULT_SUCCESS == result) { result = ur_validation_layer::urGetSamplerProcAddrTable( UR_API_VERSION_CURRENT, &dditable->Sampler); diff --git a/unified-runtime/source/loader/loader.def.in b/unified-runtime/source/loader/loader.def.in index 2940e77998695..61cfa61f5a509 100644 --- a/unified-runtime/source/loader/loader.def.in +++ b/unified-runtime/source/loader/loader.def.in @@ -121,6 +121,7 @@ EXPORTS urGetEnqueueExpProcAddrTable urGetEnqueueProcAddrTable urGetEventProcAddrTable + urGetGraphExpProcAddrTable urGetIPCExpProcAddrTable urGetKernelProcAddrTable urGetMemProcAddrTable @@ -129,12 +130,19 @@ EXPORTS urGetPlatformProcAddrTable urGetProgramExpProcAddrTable urGetProgramProcAddrTable + urGetQueueExpProcAddrTable urGetQueueProcAddrTable urGetSamplerProcAddrTable urGetUSMExpProcAddrTable urGetUSMProcAddrTable urGetUsmP2PExpProcAddrTable urGetVirtualMemProcAddrTable + urGraphCreateExp + urGraphDestroyExp + urGraphDumpContentsExp + urGraphExecutableGraphDestroyExp + urGraphInstantiateGraphExp + urGraphIsEmptyExp urIPCCloseMemHandleExp urIPCGetMemHandleExp urIPCOpenMemHandleExp @@ -371,6 +379,12 @@ EXPORTS urPrintExpWin32Handle urPrintFunction urPrintFunctionParams + urPrintGraphCreateExpParams + urPrintGraphDestroyExpParams + urPrintGraphDumpContentsExpParams + urPrintGraphExecutableGraphDestroyExpParams + urPrintGraphInstantiateGraphExpParams + urPrintGraphIsEmptyExpParams urPrintImageChannelOrder urPrintImageChannelType urPrintImageDesc @@ -485,8 +499,12 @@ EXPORTS urPrintProgramReleaseParams urPrintProgramRetainParams urPrintProgramSetSpecializationConstantsParams + urPrintQueueAppendGraphExpParams + urPrintQueueBeginCaptureIntoGraphExpParams + urPrintQueueBeginGraphCaptureExpParams urPrintQueueCreateParams urPrintQueueCreateWithNativeHandleParams + urPrintQueueEndGraphCaptureExpParams urPrintQueueFinishParams urPrintQueueFlags urPrintQueueFlushParams @@ -494,6 +512,7 @@ EXPORTS urPrintQueueGetNativeHandleParams urPrintQueueIndexProperties urPrintQueueInfo + urPrintQueueIsGraphCaptureEnabledExpParams urPrintQueueNativeDesc urPrintQueueNativeProperties urPrintQueueProperties @@ -582,12 +601,17 @@ EXPORTS urProgramRelease urProgramRetain urProgramSetSpecializationConstants + urQueueAppendGraphExp + urQueueBeginCaptureIntoGraphExp + urQueueBeginGraphCaptureExp urQueueCreate urQueueCreateWithNativeHandle + urQueueEndGraphCaptureExp urQueueFinish urQueueFlush urQueueGetInfo urQueueGetNativeHandle + urQueueIsGraphCaptureEnabledExp urQueueRelease urQueueRetain urSamplerCreate diff --git a/unified-runtime/source/loader/loader.map.in b/unified-runtime/source/loader/loader.map.in index 7839a53f218dc..910878f4f6bcb 100644 --- a/unified-runtime/source/loader/loader.map.in +++ b/unified-runtime/source/loader/loader.map.in @@ -121,6 +121,7 @@ urGetEnqueueExpProcAddrTable; urGetEnqueueProcAddrTable; urGetEventProcAddrTable; + urGetGraphExpProcAddrTable; urGetIPCExpProcAddrTable; urGetKernelProcAddrTable; urGetMemProcAddrTable; @@ -129,12 +130,19 @@ urGetPlatformProcAddrTable; urGetProgramExpProcAddrTable; urGetProgramProcAddrTable; + urGetQueueExpProcAddrTable; urGetQueueProcAddrTable; urGetSamplerProcAddrTable; urGetUSMExpProcAddrTable; urGetUSMProcAddrTable; urGetUsmP2PExpProcAddrTable; urGetVirtualMemProcAddrTable; + urGraphCreateExp; + urGraphDestroyExp; + urGraphDumpContentsExp; + urGraphExecutableGraphDestroyExp; + urGraphInstantiateGraphExp; + urGraphIsEmptyExp; urIPCCloseMemHandleExp; urIPCGetMemHandleExp; urIPCOpenMemHandleExp; @@ -371,6 +379,12 @@ urPrintExpWin32Handle; urPrintFunction; urPrintFunctionParams; + urPrintGraphCreateExpParams; + urPrintGraphDestroyExpParams; + urPrintGraphDumpContentsExpParams; + urPrintGraphExecutableGraphDestroyExpParams; + urPrintGraphInstantiateGraphExpParams; + urPrintGraphIsEmptyExpParams; urPrintImageChannelOrder; urPrintImageChannelType; urPrintImageDesc; @@ -485,8 +499,12 @@ urPrintProgramReleaseParams; urPrintProgramRetainParams; urPrintProgramSetSpecializationConstantsParams; + urPrintQueueAppendGraphExpParams; + urPrintQueueBeginCaptureIntoGraphExpParams; + urPrintQueueBeginGraphCaptureExpParams; urPrintQueueCreateParams; urPrintQueueCreateWithNativeHandleParams; + urPrintQueueEndGraphCaptureExpParams; urPrintQueueFinishParams; urPrintQueueFlags; urPrintQueueFlushParams; @@ -494,6 +512,7 @@ urPrintQueueGetNativeHandleParams; urPrintQueueIndexProperties; urPrintQueueInfo; + urPrintQueueIsGraphCaptureEnabledExpParams; urPrintQueueNativeDesc; urPrintQueueNativeProperties; urPrintQueueProperties; @@ -582,12 +601,17 @@ urProgramRelease; urProgramRetain; urProgramSetSpecializationConstants; + urQueueAppendGraphExp; + urQueueBeginCaptureIntoGraphExp; + urQueueBeginGraphCaptureExp; urQueueCreate; urQueueCreateWithNativeHandle; + urQueueEndGraphCaptureExp; urQueueFinish; urQueueFlush; urQueueGetInfo; urQueueGetNativeHandle; + urQueueIsGraphCaptureEnabledExp; urQueueRelease; urQueueRetain; urSamplerCreate; diff --git a/unified-runtime/source/loader/ur_ldrddi.cpp b/unified-runtime/source/loader/ur_ldrddi.cpp index e36be9ec49cab..cd05ab9dac3de 100644 --- a/unified-runtime/source/loader/ur_ldrddi.cpp +++ b/unified-runtime/source/loader/ur_ldrddi.cpp @@ -6000,6 +6000,225 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueNativeCommandExp( phEventWaitList, phEvent); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphCreateExp +__urdlllocal ur_result_t UR_APICALL urGraphCreateExp( + /// [in] Handle of the context object. + ur_context_handle_t hContext, + /// [out][alloc] Pointer to the handle of the created graph object. + ur_exp_graph_handle_t *phGraph, + /// [out] Pointer to extension-specific structure. + void *pNext) { + + auto *dditable = *reinterpret_cast(hContext); + + auto *pfnCreateExp = dditable->GraphExp.pfnCreateExp; + if (nullptr == pfnCreateExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + // forward to device-platform + return pfnCreateExp(hContext, phGraph, pNext); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urQueueBeginGraphCaptureExp +__urdlllocal ur_result_t UR_APICALL urQueueBeginGraphCaptureExp( + /// [in] Handle of the queue on which to begin graph capture. + ur_queue_handle_t hQueue, + /// [in][optional] Pointer to extension-specific structure. + void *pNext) { + + auto *dditable = *reinterpret_cast(hQueue); + + auto *pfnBeginGraphCaptureExp = dditable->QueueExp.pfnBeginGraphCaptureExp; + if (nullptr == pfnBeginGraphCaptureExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + // forward to device-platform + return pfnBeginGraphCaptureExp(hQueue, pNext); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urQueueBeginCaptureIntoGraphExp +__urdlllocal ur_result_t UR_APICALL urQueueBeginCaptureIntoGraphExp( + /// [in] Handle of the queue on which to begin graph capture. + ur_queue_handle_t hQueue, + /// [in] Handle of the graph object to capture into. + ur_exp_graph_handle_t hGraph, + /// [in][optional] Pointer to extension-specific structure. + void *pNext) { + + auto *dditable = *reinterpret_cast(hQueue); + + auto *pfnBeginCaptureIntoGraphExp = + dditable->QueueExp.pfnBeginCaptureIntoGraphExp; + if (nullptr == pfnBeginCaptureIntoGraphExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + // forward to device-platform + return pfnBeginCaptureIntoGraphExp(hQueue, hGraph, pNext); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urQueueEndGraphCaptureExp +__urdlllocal ur_result_t UR_APICALL urQueueEndGraphCaptureExp( + /// [in] Handle of the queue on which to end graph capture. + ur_queue_handle_t hQueue, + /// [out] Pointer to the handle of the recorded graph object. If + /// ::urQueueBeginCaptureIntoGraphExp was used to begin the capture, then + /// phGraph will contain the same graph that was passed to it. + ur_exp_graph_handle_t *phGraph, + /// [out][optional] Pointer to extension-specific structure. + void *pNext) { + + auto *dditable = *reinterpret_cast(hQueue); + + auto *pfnEndGraphCaptureExp = dditable->QueueExp.pfnEndGraphCaptureExp; + if (nullptr == pfnEndGraphCaptureExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + // forward to device-platform + return pfnEndGraphCaptureExp(hQueue, phGraph, pNext); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphInstantiateGraphExp +__urdlllocal ur_result_t UR_APICALL urGraphInstantiateGraphExp( + /// [in] Handle of the recorded graph to instantiate. + ur_exp_graph_handle_t hGraph, + /// [out] Pointer to the handle of the instantiated executable graph. + ur_exp_executable_graph_handle_t *phExecGraph, + /// [out][optional] Pointer to extension-specific structure. + void *pNext) { + + auto *dditable = *reinterpret_cast(hGraph); + + auto *pfnInstantiateGraphExp = dditable->GraphExp.pfnInstantiateGraphExp; + if (nullptr == pfnInstantiateGraphExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + // forward to device-platform + return pfnInstantiateGraphExp(hGraph, phExecGraph, pNext); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urQueueAppendGraphExp +__urdlllocal ur_result_t UR_APICALL urQueueAppendGraphExp( + /// [in] Handle of the queue to append the graph to. + ur_queue_handle_t hQueue, + /// [in] Handle of the executable graph to append. + ur_exp_executable_graph_handle_t hGraph, + /// [in][optional] Pointer to extension-specific structure. + void *pNext, + /// [in][optional] Event to be signaled on completion. + ur_event_handle_t hSignalEvent, + /// [in][optional] Number of events to wait on before executing. + uint32_t numWaitEvents, + /// [in][optional][range(0, numWaitEvents)] Handle of the events to wait + /// on before launching. + ur_event_handle_t *phWaitEvents) { + + auto *dditable = *reinterpret_cast(hQueue); + + auto *pfnAppendGraphExp = dditable->QueueExp.pfnAppendGraphExp; + if (nullptr == pfnAppendGraphExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + // forward to device-platform + return pfnAppendGraphExp(hQueue, hGraph, pNext, hSignalEvent, numWaitEvents, + phWaitEvents); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphDestroyExp +__urdlllocal ur_result_t UR_APICALL urGraphDestroyExp( + /// [in] Handle of the graph object to destroy. + ur_exp_graph_handle_t hGraph) { + + auto *dditable = *reinterpret_cast(hGraph); + + auto *pfnDestroyExp = dditable->GraphExp.pfnDestroyExp; + if (nullptr == pfnDestroyExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + // forward to device-platform + return pfnDestroyExp(hGraph); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphExecutableGraphDestroyExp +__urdlllocal ur_result_t UR_APICALL urGraphExecutableGraphDestroyExp( + /// [in] Handle of the executable graph object to destroy. + ur_exp_executable_graph_handle_t hExecutableGraph) { + + auto *dditable = *reinterpret_cast(hExecutableGraph); + + auto *pfnExecutableGraphDestroyExp = + dditable->GraphExp.pfnExecutableGraphDestroyExp; + if (nullptr == pfnExecutableGraphDestroyExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + // forward to device-platform + return pfnExecutableGraphDestroyExp(hExecutableGraph); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urQueueIsGraphCaptureEnabledExp +__urdlllocal ur_result_t UR_APICALL urQueueIsGraphCaptureEnabledExp( + /// [in] Native queue to query. + ur_queue_handle_t hQueue, + /// [out] Pointer to a boolean where the result will be stored. + bool *hResult) { + + auto *dditable = *reinterpret_cast(hQueue); + + auto *pfnIsGraphCaptureEnabledExp = + dditable->QueueExp.pfnIsGraphCaptureEnabledExp; + if (nullptr == pfnIsGraphCaptureEnabledExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + // forward to device-platform + return pfnIsGraphCaptureEnabledExp(hQueue, hResult); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphIsEmptyExp +__urdlllocal ur_result_t UR_APICALL urGraphIsEmptyExp( + /// [in] Handle of the graph to query. + ur_exp_graph_handle_t hGraph, + /// [out] Pointer to a boolean where the result will be stored. + bool *hResult) { + + auto *dditable = *reinterpret_cast(hGraph); + + auto *pfnIsEmptyExp = dditable->GraphExp.pfnIsEmptyExp; + if (nullptr == pfnIsEmptyExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + // forward to device-platform + return pfnIsEmptyExp(hGraph, hResult); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Intercept function for urGraphDumpContentsExp +__urdlllocal ur_result_t UR_APICALL urGraphDumpContentsExp( + /// [in] Handle of the graph to dump. + ur_exp_graph_handle_t hGraph, + /// [in] Path to the file to write the dumped graph contents. + const char *filePath, + /// [in][optional] Pointer to extension-specific structure. + void *pNext) { + + auto *dditable = *reinterpret_cast(hGraph); + + auto *pfnDumpContentsExp = dditable->GraphExp.pfnDumpContentsExp; + if (nullptr == pfnDumpContentsExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + // forward to device-platform + return pfnDumpContentsExp(hGraph, filePath, pNext); +} + } // namespace ur_loader extern "C" { @@ -6513,6 +6732,64 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetEventProcAddrTable( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's GraphExp 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 urGetGraphExpProcAddrTable( + /// [in] API version requested + ur_api_version_t version, + /// [in,out] pointer to table of DDI function pointers + ur_graph_exp_dditable_t *pDdiTable) { + if (nullptr == pDdiTable) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (ur_loader::getContext()->version < version) + return UR_RESULT_ERROR_UNSUPPORTED_VERSION; + + ur_result_t result = UR_RESULT_SUCCESS; + + // Load the device-platform DDI tables + for (auto &platform : ur_loader::getContext()->platforms) { + // statically linked adapter inside of the loader + if (platform.handle == nullptr) + continue; + + if (platform.initStatus != UR_RESULT_SUCCESS) + continue; + auto getTable = reinterpret_cast( + ur_loader::LibLoader::getFunctionPtr(platform.handle.get(), + "urGetGraphExpProcAddrTable")); + if (!getTable) + continue; + platform.initStatus = getTable(version, &platform.dditable.GraphExp); + } + + if (UR_RESULT_SUCCESS == result) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { + // return pointers to loader's DDIs + pDdiTable->pfnCreateExp = ur_loader::urGraphCreateExp; + pDdiTable->pfnInstantiateGraphExp = ur_loader::urGraphInstantiateGraphExp; + pDdiTable->pfnDestroyExp = ur_loader::urGraphDestroyExp; + pDdiTable->pfnExecutableGraphDestroyExp = + ur_loader::urGraphExecutableGraphDestroyExp; + pDdiTable->pfnIsEmptyExp = ur_loader::urGraphIsEmptyExp; + pDdiTable->pfnDumpContentsExp = ur_loader::urGraphDumpContentsExp; + } else { + // return pointers directly to platform's DDIs + *pDdiTable = ur_loader::getContext()->platforms.front().dditable.GraphExp; + } + } + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's IPCExp table /// with current process' addresses @@ -7059,6 +7336,65 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetQueueProcAddrTable( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's QueueExp 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 urGetQueueExpProcAddrTable( + /// [in] API version requested + ur_api_version_t version, + /// [in,out] pointer to table of DDI function pointers + ur_queue_exp_dditable_t *pDdiTable) { + if (nullptr == pDdiTable) + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + + if (ur_loader::getContext()->version < version) + return UR_RESULT_ERROR_UNSUPPORTED_VERSION; + + ur_result_t result = UR_RESULT_SUCCESS; + + // Load the device-platform DDI tables + for (auto &platform : ur_loader::getContext()->platforms) { + // statically linked adapter inside of the loader + if (platform.handle == nullptr) + continue; + + if (platform.initStatus != UR_RESULT_SUCCESS) + continue; + auto getTable = reinterpret_cast( + ur_loader::LibLoader::getFunctionPtr(platform.handle.get(), + "urGetQueueExpProcAddrTable")); + if (!getTable) + continue; + platform.initStatus = getTable(version, &platform.dditable.QueueExp); + } + + if (UR_RESULT_SUCCESS == result) { + if (ur_loader::getContext()->platforms.size() != 1 || + ur_loader::getContext()->forceIntercept) { + // return pointers to loader's DDIs + pDdiTable->pfnBeginGraphCaptureExp = + ur_loader::urQueueBeginGraphCaptureExp; + pDdiTable->pfnBeginCaptureIntoGraphExp = + ur_loader::urQueueBeginCaptureIntoGraphExp; + pDdiTable->pfnEndGraphCaptureExp = ur_loader::urQueueEndGraphCaptureExp; + pDdiTable->pfnAppendGraphExp = ur_loader::urQueueAppendGraphExp; + pDdiTable->pfnIsGraphCaptureEnabledExp = + ur_loader::urQueueIsGraphCaptureEnabledExp; + } else { + // return pointers directly to platform's DDIs + *pDdiTable = ur_loader::getContext()->platforms.front().dditable.QueueExp; + } + } + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's Sampler table /// with current process' addresses diff --git a/unified-runtime/source/loader/ur_libapi.cpp b/unified-runtime/source/loader/ur_libapi.cpp index 5965c9c67c9c1..0720149d2d84b 100644 --- a/unified-runtime/source/loader/ur_libapi.cpp +++ b/unified-runtime/source/loader/ur_libapi.cpp @@ -11022,4 +11022,339 @@ ur_result_t UR_APICALL urEnqueueNativeCommandExp( return exceptionToResult(std::current_exception()); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Create a new record & replay graph instance explicitly. +/// +/// @details +/// - Create a new record & replay graph instance explicitly. +/// +/// @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 == hContext` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phGraph` +/// + `NULL == pNext` +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +ur_result_t UR_APICALL urGraphCreateExp( + /// [in] Handle of the context object. + ur_context_handle_t hContext, + /// [out][alloc] Pointer to the handle of the created graph object. + ur_exp_graph_handle_t *phGraph, + /// [out] Pointer to extension-specific structure. + void *pNext) try { + auto pfnCreateExp = ur_lib::getContext()->urDdiTable.GraphExp.pfnCreateExp; + if (nullptr == pfnCreateExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnCreateExp(hContext, phGraph, pNext); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Begin graph capture on the specified immediate queue. +/// +/// @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 == hQueue` +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +ur_result_t UR_APICALL urQueueBeginGraphCaptureExp( + /// [in] Handle of the queue on which to begin graph capture. + ur_queue_handle_t hQueue, + /// [in][optional] Pointer to extension-specific structure. + void *pNext) try { + auto pfnBeginGraphCaptureExp = + ur_lib::getContext()->urDdiTable.QueueExp.pfnBeginGraphCaptureExp; + if (nullptr == pfnBeginGraphCaptureExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnBeginGraphCaptureExp(hQueue, pNext); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Begin capturing commands into an existing graph on the specified +/// immediate queue. +/// +/// @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 == hQueue` +/// + `NULL == hGraph` +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +ur_result_t UR_APICALL urQueueBeginCaptureIntoGraphExp( + /// [in] Handle of the queue on which to begin graph capture. + ur_queue_handle_t hQueue, + /// [in] Handle of the graph object to capture into. + ur_exp_graph_handle_t hGraph, + /// [in][optional] Pointer to extension-specific structure. + void *pNext) try { + auto pfnBeginCaptureIntoGraphExp = + ur_lib::getContext()->urDdiTable.QueueExp.pfnBeginCaptureIntoGraphExp; + if (nullptr == pfnBeginCaptureIntoGraphExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnBeginCaptureIntoGraphExp(hQueue, hGraph, pNext); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief End graph capture on the specified immediate queue. +/// +/// @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 == hQueue` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phGraph` +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +ur_result_t UR_APICALL urQueueEndGraphCaptureExp( + /// [in] Handle of the queue on which to end graph capture. + ur_queue_handle_t hQueue, + /// [out] Pointer to the handle of the recorded graph object. If + /// ::urQueueBeginCaptureIntoGraphExp was used to begin the capture, then + /// phGraph will contain the same graph that was passed to it. + ur_exp_graph_handle_t *phGraph, + /// [out][optional] Pointer to extension-specific structure. + void *pNext) try { + auto pfnEndGraphCaptureExp = + ur_lib::getContext()->urDdiTable.QueueExp.pfnEndGraphCaptureExp; + if (nullptr == pfnEndGraphCaptureExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnEndGraphCaptureExp(hQueue, phGraph, pNext); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Instantiate an executable graph from a recorded graph. +/// +/// @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 == phExecGraph` +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +ur_result_t UR_APICALL urGraphInstantiateGraphExp( + /// [in] Handle of the recorded graph to instantiate. + ur_exp_graph_handle_t hGraph, + /// [out] Pointer to the handle of the instantiated executable graph. + ur_exp_executable_graph_handle_t *phExecGraph, + /// [out][optional] Pointer to extension-specific structure. + void *pNext) try { + auto pfnInstantiateGraphExp = + ur_lib::getContext()->urDdiTable.GraphExp.pfnInstantiateGraphExp; + if (nullptr == pfnInstantiateGraphExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnInstantiateGraphExp(hGraph, phExecGraph, pNext); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Append an executable graph to the queue. +/// +/// @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 == hQueue` +/// + `NULL == hGraph` +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +ur_result_t UR_APICALL urQueueAppendGraphExp( + /// [in] Handle of the queue to append the graph to. + ur_queue_handle_t hQueue, + /// [in] Handle of the executable graph to append. + ur_exp_executable_graph_handle_t hGraph, + /// [in][optional] Pointer to extension-specific structure. + void *pNext, + /// [in][optional] Event to be signaled on completion. + ur_event_handle_t hSignalEvent, + /// [in][optional] Number of events to wait on before executing. + uint32_t numWaitEvents, + /// [in][optional][range(0, numWaitEvents)] Handle of the events to wait + /// on before launching. + ur_event_handle_t *phWaitEvents) try { + auto pfnAppendGraphExp = + ur_lib::getContext()->urDdiTable.QueueExp.pfnAppendGraphExp; + if (nullptr == pfnAppendGraphExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnAppendGraphExp(hQueue, hGraph, pNext, hSignalEvent, numWaitEvents, + phWaitEvents); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Destroy a recorded graph object. All executable graph instances +/// created from this recorded graph must be destroyed before calling +/// this function. +/// +/// @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_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +ur_result_t UR_APICALL urGraphDestroyExp( + /// [in] Handle of the graph object to destroy. + ur_exp_graph_handle_t hGraph) try { + auto pfnDestroyExp = ur_lib::getContext()->urDdiTable.GraphExp.pfnDestroyExp; + if (nullptr == pfnDestroyExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnDestroyExp(hGraph); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Destroy an instantiated executable graph object. The graph instance +/// must not be executing on any queue. +/// +/// @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_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +ur_result_t UR_APICALL urGraphExecutableGraphDestroyExp( + /// [in] Handle of the executable graph object to destroy. + ur_exp_executable_graph_handle_t hExecutableGraph) try { + auto pfnExecutableGraphDestroyExp = + ur_lib::getContext()->urDdiTable.GraphExp.pfnExecutableGraphDestroyExp; + if (nullptr == pfnExecutableGraphDestroyExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnExecutableGraphDestroyExp(hExecutableGraph); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Query whether graph capture is currently enabled on the given queue. +/// +/// @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 == hQueue` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == hResult` +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +ur_result_t UR_APICALL urQueueIsGraphCaptureEnabledExp( + /// [in] Native queue to query. + ur_queue_handle_t hQueue, + /// [out] Pointer to a boolean where the result will be stored. + bool *hResult) try { + auto pfnIsGraphCaptureEnabledExp = + ur_lib::getContext()->urDdiTable.QueueExp.pfnIsGraphCaptureEnabledExp; + if (nullptr == pfnIsGraphCaptureEnabledExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnIsGraphCaptureEnabledExp(hQueue, hResult); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Return whether the given recorded graph contains any nodes. +/// +/// @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 == hResult` +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +ur_result_t UR_APICALL urGraphIsEmptyExp( + /// [in] Handle of the graph to query. + ur_exp_graph_handle_t hGraph, + /// [out] Pointer to a boolean where the result will be stored. + bool *hResult) try { + auto pfnIsEmptyExp = ur_lib::getContext()->urDdiTable.GraphExp.pfnIsEmptyExp; + if (nullptr == pfnIsEmptyExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnIsEmptyExp(hGraph, hResult); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Dump the contents of the recorded graph to the provided file path. +/// +/// @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 == filePath` +/// - ::UR_RESULT_ERROR_INVALID_VALUE +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +ur_result_t UR_APICALL urGraphDumpContentsExp( + /// [in] Handle of the graph to dump. + ur_exp_graph_handle_t hGraph, + /// [in] Path to the file to write the dumped graph contents. + const char *filePath, + /// [in][optional] Pointer to extension-specific structure. + void *pNext) try { + auto pfnDumpContentsExp = + ur_lib::getContext()->urDdiTable.GraphExp.pfnDumpContentsExp; + if (nullptr == pfnDumpContentsExp) + return UR_RESULT_ERROR_UNINITIALIZED; + + return pfnDumpContentsExp(hGraph, filePath, pNext); +} catch (...) { + return exceptionToResult(std::current_exception()); +} + } // extern "C" diff --git a/unified-runtime/source/loader/ur_libddi.cpp b/unified-runtime/source/loader/ur_libddi.cpp index 17014c613d3f3..2040904d79618 100644 --- a/unified-runtime/source/loader/ur_libddi.cpp +++ b/unified-runtime/source/loader/ur_libddi.cpp @@ -56,6 +56,11 @@ __urdlllocal ur_result_t context_t::ddiInit() { result = urGetEventProcAddrTable(UR_API_VERSION_CURRENT, &urDdiTable.Event); } + if (UR_RESULT_SUCCESS == result) { + result = urGetGraphExpProcAddrTable(UR_API_VERSION_CURRENT, + &urDdiTable.GraphExp); + } + if (UR_RESULT_SUCCESS == result) { result = urGetIPCExpProcAddrTable(UR_API_VERSION_CURRENT, &urDdiTable.IPCExp); @@ -99,6 +104,11 @@ __urdlllocal ur_result_t context_t::ddiInit() { result = urGetQueueProcAddrTable(UR_API_VERSION_CURRENT, &urDdiTable.Queue); } + if (UR_RESULT_SUCCESS == result) { + result = urGetQueueExpProcAddrTable(UR_API_VERSION_CURRENT, + &urDdiTable.QueueExp); + } + if (UR_RESULT_SUCCESS == result) { result = urGetSamplerProcAddrTable(UR_API_VERSION_CURRENT, &urDdiTable.Sampler); diff --git a/unified-runtime/source/loader/ur_print.cpp b/unified-runtime/source/loader/ur_print.cpp index 4608b6bb86333..43b437410ab80 100644 --- a/unified-runtime/source/loader/ur_print.cpp +++ b/unified-runtime/source/loader/ur_print.cpp @@ -2049,6 +2049,56 @@ ur_result_t urPrintEventSetCallbackParams( return str_copy(&ss, buffer, buff_size, out_size); } +ur_result_t +urPrintGraphCreateExpParams(const struct ur_graph_create_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 urPrintGraphInstantiateGraphExpParams( + const struct ur_graph_instantiate_graph_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 +urPrintGraphDestroyExpParams(const struct ur_graph_destroy_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 urPrintGraphExecutableGraphDestroyExpParams( + const struct ur_graph_executable_graph_destroy_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 urPrintGraphIsEmptyExpParams( + const struct ur_graph_is_empty_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 urPrintGraphDumpContentsExpParams( + const struct ur_graph_dump_contents_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) { @@ -2707,6 +2757,46 @@ urPrintQueueFlushParams(const struct ur_queue_flush_params_t *params, return str_copy(&ss, buffer, buff_size, out_size); } +ur_result_t urPrintQueueBeginGraphCaptureExpParams( + const struct ur_queue_begin_graph_capture_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 urPrintQueueBeginCaptureIntoGraphExpParams( + const struct ur_queue_begin_capture_into_graph_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 urPrintQueueEndGraphCaptureExpParams( + const struct ur_queue_end_graph_capture_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 urPrintQueueAppendGraphExpParams( + const struct ur_queue_append_graph_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 urPrintQueueIsGraphCaptureEnabledExpParams( + const struct ur_queue_is_graph_capture_enabled_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 urPrintSamplerCreateParams(const struct ur_sampler_create_params_t *params, char *buffer, const size_t buff_size, diff --git a/unified-runtime/source/ur_api.cpp b/unified-runtime/source/ur_api.cpp index d463fef9410bd..69135961524ce 100644 --- a/unified-runtime/source/ur_api.cpp +++ b/unified-runtime/source/ur_api.cpp @@ -9590,3 +9590,274 @@ ur_result_t UR_APICALL urEnqueueNativeCommandExp( ur_result_t result = UR_RESULT_SUCCESS; return result; } + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Create a new record & replay graph instance explicitly. +/// +/// @details +/// - Create a new record & replay graph instance explicitly. +/// +/// @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 == hContext` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phGraph` +/// + `NULL == pNext` +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +ur_result_t UR_APICALL urGraphCreateExp( + /// [in] Handle of the context object. + ur_context_handle_t hContext, + /// [out][alloc] Pointer to the handle of the created graph object. + ur_exp_graph_handle_t *phGraph, + /// [out] Pointer to extension-specific structure. + void *pNext) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Begin graph capture on the specified immediate queue. +/// +/// @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 == hQueue` +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +ur_result_t UR_APICALL urQueueBeginGraphCaptureExp( + /// [in] Handle of the queue on which to begin graph capture. + ur_queue_handle_t hQueue, + /// [in][optional] Pointer to extension-specific structure. + void *pNext) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Begin capturing commands into an existing graph on the specified +/// immediate queue. +/// +/// @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 == hQueue` +/// + `NULL == hGraph` +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +ur_result_t UR_APICALL urQueueBeginCaptureIntoGraphExp( + /// [in] Handle of the queue on which to begin graph capture. + ur_queue_handle_t hQueue, + /// [in] Handle of the graph object to capture into. + ur_exp_graph_handle_t hGraph, + /// [in][optional] Pointer to extension-specific structure. + void *pNext) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief End graph capture on the specified immediate queue. +/// +/// @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 == hQueue` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phGraph` +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +ur_result_t UR_APICALL urQueueEndGraphCaptureExp( + /// [in] Handle of the queue on which to end graph capture. + ur_queue_handle_t hQueue, + /// [out] Pointer to the handle of the recorded graph object. If + /// ::urQueueBeginCaptureIntoGraphExp was used to begin the capture, then + /// phGraph will contain the same graph that was passed to it. + ur_exp_graph_handle_t *phGraph, + /// [out][optional] Pointer to extension-specific structure. + void *pNext) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Instantiate an executable graph from a recorded graph. +/// +/// @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 == phExecGraph` +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +ur_result_t UR_APICALL urGraphInstantiateGraphExp( + /// [in] Handle of the recorded graph to instantiate. + ur_exp_graph_handle_t hGraph, + /// [out] Pointer to the handle of the instantiated executable graph. + ur_exp_executable_graph_handle_t *phExecGraph, + /// [out][optional] Pointer to extension-specific structure. + void *pNext) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Append an executable graph to the queue. +/// +/// @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 == hQueue` +/// + `NULL == hGraph` +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +ur_result_t UR_APICALL urQueueAppendGraphExp( + /// [in] Handle of the queue to append the graph to. + ur_queue_handle_t hQueue, + /// [in] Handle of the executable graph to append. + ur_exp_executable_graph_handle_t hGraph, + /// [in][optional] Pointer to extension-specific structure. + void *pNext, + /// [in][optional] Event to be signaled on completion. + ur_event_handle_t hSignalEvent, + /// [in][optional] Number of events to wait on before executing. + uint32_t numWaitEvents, + /// [in][optional][range(0, numWaitEvents)] Handle of the events to wait + /// on before launching. + ur_event_handle_t *phWaitEvents) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Destroy a recorded graph object. All executable graph instances +/// created from this recorded graph must be destroyed before calling +/// this function. +/// +/// @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_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +ur_result_t UR_APICALL urGraphDestroyExp( + /// [in] Handle of the graph object to destroy. + ur_exp_graph_handle_t hGraph) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Destroy an instantiated executable graph object. The graph instance +/// must not be executing on any queue. +/// +/// @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_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +ur_result_t UR_APICALL urGraphExecutableGraphDestroyExp( + /// [in] Handle of the executable graph object to destroy. + ur_exp_executable_graph_handle_t hExecutableGraph) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Query whether graph capture is currently enabled on the given queue. +/// +/// @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 == hQueue` +/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == hResult` +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_ARGUMENT +ur_result_t UR_APICALL urQueueIsGraphCaptureEnabledExp( + /// [in] Native queue to query. + ur_queue_handle_t hQueue, + /// [out] Pointer to a boolean where the result will be stored. + bool *hResult) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Return whether the given recorded graph contains any nodes. +/// +/// @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 == hResult` +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +ur_result_t UR_APICALL urGraphIsEmptyExp( + /// [in] Handle of the graph to query. + ur_exp_graph_handle_t hGraph, + /// [out] Pointer to a boolean where the result will be stored. + bool *hResult) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Dump the contents of the recorded graph to the provided file path. +/// +/// @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 == filePath` +/// - ::UR_RESULT_ERROR_INVALID_VALUE +/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES +ur_result_t UR_APICALL urGraphDumpContentsExp( + /// [in] Handle of the graph to dump. + ur_exp_graph_handle_t hGraph, + /// [in] Path to the file to write the dumped graph contents. + const char *filePath, + /// [in][optional] Pointer to extension-specific structure. + void *pNext) { + ur_result_t result = UR_RESULT_SUCCESS; + return result; +}