diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b52a0d1..ffc9003a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Level zero loader changelog +## v1.18.0 +* v1.11 Spec Changes for the L0 Loader +* Wrap linker flags on Windows for IntelLLVM +* Ensure validation_layer::context has init before usage +* Replace exception with error string return in zello_log.h ## v1.17.45 * windows: do not exclude DN_NEED_RESTART drivers if LevelZeroStagedDriverPath is set ## v1.17.44 diff --git a/CMakeLists.txt b/CMakeLists.txt index fe570847..a5eeb664 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ message(FATAL_ERROR "Visual Studio Compiler Version >= 1900 Required to build.") endif() # This project follows semantic versioning (https://semver.org/) -project(level-zero VERSION 1.17.45) +project(level-zero VERSION 1.18.0) include(GNUInstallDirs) diff --git a/include/layers/zel_tracing_register_cb.h b/include/layers/zel_tracing_register_cb.h index f54dbed8..2b73c3ce 100644 --- a/include/layers/zel_tracing_register_cb.h +++ b/include/layers/zel_tracing_register_cb.h @@ -27,6 +27,33 @@ typedef struct _zel_tracer_handle_t *zel_tracer_handle_t; /// Callback definitions for all API released in LevelZero spec 1.1 or newer /// Callbacks for APIs included in spec 1.0 are contained in ze_api.helper +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function parameters for zeInitDrivers +/// @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 _ze_init_drivers_params_t +{ + uint32_t** ppCount; + ze_driver_handle_t** pphDrivers; + ze_init_driver_type_desc_t** pdesc; +} ze_init_drivers_params_t; + + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function-pointer for zeInitDrivers +/// @param[in] params Parameters passed to this instance +/// @param[in] result Return value +/// @param[in] pTracerUserData Per-Tracer user data +/// @param[in,out] ppTracerInstanceUserData Per-Tracer, Per-Instance user data + +typedef void (ZE_APICALL *ze_pfnInitDriversCb_t)( + ze_init_drivers_params_t* params, + ze_result_t result, + void* pTracerUserData, + void** ppTracerInstanceUserData + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Callback function parameters for zeRTASBuilderCreateExp /// @details Each entry is a pointer to the parameter passed to the function; @@ -563,6 +590,116 @@ typedef void (ZE_APICALL *ze_pfnCommandQueueGetIndexCb_t)( void** ppTracerInstanceUserData ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function parameters for zeCommandListGetNextCommandIdWithKernelsExp +/// @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 _ze_command_list_get_next_command_id_with_kernels_exp_params_t +{ + ze_command_list_handle_t* phCommandList; + const ze_mutable_command_id_exp_desc_t** pdesc; + uint32_t* pnumKernels; + ze_kernel_handle_t** pphKernels; + uint64_t** ppCommandId; +} ze_command_list_get_next_command_id_with_kernels_exp_params_t; + + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function-pointer for zeCommandListGetNextCommandIdWithKernelsExp +/// @param[in] params Parameters passed to this instance +/// @param[in] result Return value +/// @param[in] pTracerUserData Per-Tracer user data +/// @param[in,out] ppTracerInstanceUserData Per-Tracer, Per-Instance user data + +typedef void (ZE_APICALL *ze_pfnCommandListGetNextCommandIdWithKernelsExpCb_t)( + ze_command_list_get_next_command_id_with_kernels_exp_params_t* params, + ze_result_t result, + void* pTracerUserData, + void** ppTracerInstanceUserData + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function parameters for zeCommandListUpdateMutableCommandsExp +/// @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 _ze_command_list_update_mutable_commands_exp_params_t +{ + ze_command_list_handle_t* phCommandList; + const ze_mutable_commands_exp_desc_t** pdesc; +} ze_command_list_update_mutable_commands_exp_params_t; + + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function-pointer for zeCommandListUpdateMutableCommandsExp +/// @param[in] params Parameters passed to this instance +/// @param[in] result Return value +/// @param[in] pTracerUserData Per-Tracer user data +/// @param[in,out] ppTracerInstanceUserData Per-Tracer, Per-Instance user data + +typedef void (ZE_APICALL *ze_pfnCommandListUpdateMutableCommandsExpCb_t)( + ze_command_list_update_mutable_commands_exp_params_t* params, + ze_result_t result, + void* pTracerUserData, + void** ppTracerInstanceUserData + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function parameters for zeCommandListUpdateMutableCommandSignalEventExp +/// @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 _ze_command_list_update_mutable_command_signal_event_exp_params_t +{ + ze_command_list_handle_t* phCommandList; + uint64_t* pcommandId; + ze_event_handle_t* phSignalEvent; +} ze_command_list_update_mutable_command_signal_event_exp_params_t; + + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function-pointer for zeCommandListUpdateMutableCommandSignalEventExp +/// @param[in] params Parameters passed to this instance +/// @param[in] result Return value +/// @param[in] pTracerUserData Per-Tracer user data +/// @param[in,out] ppTracerInstanceUserData Per-Tracer, Per-Instance user data + +typedef void (ZE_APICALL *ze_pfnCommandListUpdateMutableCommandSignalEventExpCb_t)( + ze_command_list_update_mutable_command_signal_event_exp_params_t* params, + ze_result_t result, + void* pTracerUserData, + void** ppTracerInstanceUserData + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function parameters for zeCommandListUpdateMutableCommandKernelsExp +/// @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 _ze_command_list_update_mutable_command_kernels_exp_params_t +{ + ze_command_list_handle_t* phCommandList; + uint32_t* pnumKernels; + uint64_t** ppCommandId; + ze_kernel_handle_t** pphKernels; +} ze_command_list_update_mutable_command_kernels_exp_params_t; + + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function-pointer for zeCommandListUpdateMutableCommandKernelsExp +/// @param[in] params Parameters passed to this instance +/// @param[in] result Return value +/// @param[in] pTracerUserData Per-Tracer user data +/// @param[in,out] ppTracerInstanceUserData Per-Tracer, Per-Instance user data + +typedef void (ZE_APICALL *ze_pfnCommandListUpdateMutableCommandKernelsExpCb_t)( + ze_command_list_update_mutable_command_kernels_exp_params_t* params, + ze_result_t result, + void* pTracerUserData, + void** ppTracerInstanceUserData + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Callback function parameters for zeCommandListAppendImageCopyToMemoryExt /// @details Each entry is a pointer to the parameter passed to the function; @@ -811,36 +948,6 @@ typedef void (ZE_APICALL *ze_pfnCommandListIsImmediateCb_t)( void** ppTracerInstanceUserData ); -/////////////////////////////////////////////////////////////////////////////// -/// @brief Callback function parameters for zeCommandListImmediateAppendCommandListsExp -/// @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 _ze_command_list_immediate_append_command_lists_exp_params_t -{ - ze_command_list_handle_t* phCommandListImmediate; - uint32_t* pnumCommandLists; - ze_command_list_handle_t** pphCommandLists; - ze_event_handle_t* phSignalEvent; - uint32_t* pnumWaitEvents; - ze_event_handle_t** pphWaitEvents; -} ze_command_list_immediate_append_command_lists_exp_params_t; - - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Callback function-pointer for zeCommandListImmediateAppendCommandListsExp -/// @param[in] params Parameters passed to this instance -/// @param[in] result Return value -/// @param[in] pTracerUserData Per-Tracer user data -/// @param[in,out] ppTracerInstanceUserData Per-Tracer, Per-Instance user data - -typedef void (ZE_APICALL *ze_pfnCommandListImmediateAppendCommandListsExpCb_t)( - ze_command_list_immediate_append_command_lists_exp_params_t* params, - ze_result_t result, - void* pTracerUserData, - void** ppTracerInstanceUserData - ); - /////////////////////////////////////////////////////////////////////////////// /// @brief Callback function parameters for zeCommandListGetNextCommandIdExp /// @details Each entry is a pointer to the parameter passed to the function; @@ -869,81 +976,58 @@ typedef void (ZE_APICALL *ze_pfnCommandListGetNextCommandIdExpCb_t)( ); /////////////////////////////////////////////////////////////////////////////// -/// @brief Callback function parameters for zeCommandListUpdateMutableCommandsExp -/// @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 _ze_command_list_update_mutable_commands_exp_params_t -{ - ze_command_list_handle_t* phCommandList; - const ze_mutable_commands_exp_desc_t** pdesc; -} ze_command_list_update_mutable_commands_exp_params_t; - - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Callback function-pointer for zeCommandListUpdateMutableCommandsExp -/// @param[in] params Parameters passed to this instance -/// @param[in] result Return value -/// @param[in] pTracerUserData Per-Tracer user data -/// @param[in,out] ppTracerInstanceUserData Per-Tracer, Per-Instance user data - -typedef void (ZE_APICALL *ze_pfnCommandListUpdateMutableCommandsExpCb_t)( - ze_command_list_update_mutable_commands_exp_params_t* params, - ze_result_t result, - void* pTracerUserData, - void** ppTracerInstanceUserData - ); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Callback function parameters for zeCommandListUpdateMutableCommandSignalEventExp +/// @brief Callback function parameters for zeCommandListUpdateMutableCommandWaitEventsExp /// @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 _ze_command_list_update_mutable_command_signal_event_exp_params_t +typedef struct _ze_command_list_update_mutable_command_wait_events_exp_params_t { ze_command_list_handle_t* phCommandList; uint64_t* pcommandId; - ze_event_handle_t* phSignalEvent; -} ze_command_list_update_mutable_command_signal_event_exp_params_t; + uint32_t* pnumWaitEvents; + ze_event_handle_t** pphWaitEvents; +} ze_command_list_update_mutable_command_wait_events_exp_params_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Callback function-pointer for zeCommandListUpdateMutableCommandSignalEventExp +/// @brief Callback function-pointer for zeCommandListUpdateMutableCommandWaitEventsExp /// @param[in] params Parameters passed to this instance /// @param[in] result Return value /// @param[in] pTracerUserData Per-Tracer user data /// @param[in,out] ppTracerInstanceUserData Per-Tracer, Per-Instance user data -typedef void (ZE_APICALL *ze_pfnCommandListUpdateMutableCommandSignalEventExpCb_t)( - ze_command_list_update_mutable_command_signal_event_exp_params_t* params, +typedef void (ZE_APICALL *ze_pfnCommandListUpdateMutableCommandWaitEventsExpCb_t)( + ze_command_list_update_mutable_command_wait_events_exp_params_t* params, ze_result_t result, void* pTracerUserData, void** ppTracerInstanceUserData ); /////////////////////////////////////////////////////////////////////////////// -/// @brief Callback function parameters for zeCommandListUpdateMutableCommandWaitEventsExp +/// @brief Callback function parameters for zeCommandListImmediateAppendCommandListsExp /// @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 _ze_command_list_update_mutable_command_wait_events_exp_params_t +typedef struct _ze_command_list_immediate_append_command_lists_exp_params_t { - ze_command_list_handle_t* phCommandList; - uint64_t* pcommandId; + ze_command_list_handle_t* phCommandListImmediate; + uint32_t* pnumCommandLists; + ze_command_list_handle_t** pphCommandLists; + ze_event_handle_t* phSignalEvent; uint32_t* pnumWaitEvents; ze_event_handle_t** pphWaitEvents; -} ze_command_list_update_mutable_command_wait_events_exp_params_t; +} ze_command_list_immediate_append_command_lists_exp_params_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Callback function-pointer for zeCommandListUpdateMutableCommandWaitEventsExp +/// @brief Callback function-pointer for zeCommandListImmediateAppendCommandListsExp /// @param[in] params Parameters passed to this instance /// @param[in] result Return value /// @param[in] pTracerUserData Per-Tracer user data /// @param[in,out] ppTracerInstanceUserData Per-Tracer, Per-Instance user data -typedef void (ZE_APICALL *ze_pfnCommandListUpdateMutableCommandWaitEventsExpCb_t)( - ze_command_list_update_mutable_command_wait_events_exp_params_t* params, +typedef void (ZE_APICALL *ze_pfnCommandListImmediateAppendCommandListsExpCb_t)( + ze_command_list_immediate_append_command_lists_exp_params_t* params, ze_result_t result, void* pTracerUserData, void** ppTracerInstanceUserData @@ -1787,6 +1871,14 @@ zelTracerDriverGetRegisterCallback( ); +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerInitDriversRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnInitDriversCb_t pfnInitDriversCb + ); + + ZE_APIEXPORT ze_result_t ZE_APICALL zelTracerDriverGetApiVersionRegisterCallback( zel_tracer_handle_t hTracer, @@ -2931,6 +3023,54 @@ zelTracerKernelSetGlobalOffsetExpRegisterCallback( ); +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerCommandListGetNextCommandIdExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListGetNextCommandIdExpCb_t pfnGetNextCommandIdExpCb + ); + + +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerCommandListGetNextCommandIdWithKernelsExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListGetNextCommandIdWithKernelsExpCb_t pfnGetNextCommandIdWithKernelsExpCb + ); + + +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerCommandListUpdateMutableCommandsExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListUpdateMutableCommandsExpCb_t pfnUpdateMutableCommandsExpCb + ); + + +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerCommandListUpdateMutableCommandSignalEventExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListUpdateMutableCommandSignalEventExpCb_t pfnUpdateMutableCommandSignalEventExpCb + ); + + +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerCommandListUpdateMutableCommandWaitEventsExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListUpdateMutableCommandWaitEventsExpCb_t pfnUpdateMutableCommandWaitEventsExpCb + ); + + +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerCommandListUpdateMutableCommandKernelsExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListUpdateMutableCommandKernelsExpCb_t pfnUpdateMutableCommandKernelsExpCb + ); + + ZE_APIEXPORT ze_result_t ZE_APICALL zelTracerDeviceReserveCacheExtRegisterCallback( zel_tracer_handle_t hTracer, @@ -3211,38 +3351,6 @@ zelTracerCommandListImmediateAppendCommandListsExpRegisterCallback( ); -ZE_APIEXPORT ze_result_t ZE_APICALL -zelTracerCommandListGetNextCommandIdExpRegisterCallback( - zel_tracer_handle_t hTracer, - zel_tracer_reg_t callback_type, - ze_pfnCommandListGetNextCommandIdExpCb_t pfnGetNextCommandIdExpCb - ); - - -ZE_APIEXPORT ze_result_t ZE_APICALL -zelTracerCommandListUpdateMutableCommandsExpRegisterCallback( - zel_tracer_handle_t hTracer, - zel_tracer_reg_t callback_type, - ze_pfnCommandListUpdateMutableCommandsExpCb_t pfnUpdateMutableCommandsExpCb - ); - - -ZE_APIEXPORT ze_result_t ZE_APICALL -zelTracerCommandListUpdateMutableCommandSignalEventExpRegisterCallback( - zel_tracer_handle_t hTracer, - zel_tracer_reg_t callback_type, - ze_pfnCommandListUpdateMutableCommandSignalEventExpCb_t pfnUpdateMutableCommandSignalEventExpCb - ); - - -ZE_APIEXPORT ze_result_t ZE_APICALL -zelTracerCommandListUpdateMutableCommandWaitEventsExpRegisterCallback( - zel_tracer_handle_t hTracer, - zel_tracer_reg_t callback_type, - ze_pfnCommandListUpdateMutableCommandWaitEventsExpCb_t pfnUpdateMutableCommandWaitEventsExpCb - ); - - ZE_APIEXPORT ze_result_t ZE_APICALL zelTracerResetAllCallbacks(zel_tracer_handle_t hTracer); diff --git a/include/ze.py b/include/ze.py index 3804d982..a16e8e5d 100644 --- a/include/ze.py +++ b/include/ze.py @@ -4,7 +4,7 @@ SPDX-License-Identifier: MIT @file ze.py - @version v1.9-r1.9.3 + @version v1.11-r1.11.0 """ import platform @@ -218,6 +218,7 @@ class ze_result_v(IntEnum): ERROR_OVERLAPPING_REGIONS = 0x7800001a ## [Validation] copy operations do not support overlapping regions of ## memory WARNING_ACTION_REQUIRED = 0x7800001b ## [Sysman] an action is required to complete the desired operation + ERROR_INVALID_KERNEL_HANDLE = 0x7800001c ## [Core, Validation] kernel handle is invalid for the operation ERROR_UNKNOWN = 0x7ffffffe ## [Core] unknown or internal error class ze_result_t(c_int): @@ -313,6 +314,8 @@ class ze_structure_type_v(IntEnum): PITCHED_ALLOC_DEVICE_EXP_PROPERTIES = 0x0002001D ## ::ze_device_pitched_alloc_exp_properties_t BINDLESS_IMAGE_EXP_DESC = 0x0002001E ## ::ze_image_bindless_exp_desc_t PITCHED_IMAGE_EXP_DESC = 0x0002001F ## ::ze_image_pitched_exp_desc_t + MUTABLE_GRAPH_ARGUMENT_EXP_DESC = 0x00020020 ## ::ze_mutable_graph_argument_exp_desc_t + INIT_DRIVER_TYPE_DESC = 0x00020021 ## ::ze_init_driver_type_desc_t class ze_structure_type_t(c_int): def __str__(self): @@ -426,6 +429,43 @@ def __str__(self): return hex(self.value) +############################################################################### +## @brief Supported driver initialization type flags +## +## @details +## - Bit Field which details the driver types to be initialized and +## returned to the user. +## - Value Definition: +## - 0, do not init or retrieve any drivers. +## - ZE_INIT_DRIVER_TYPE_FLAG_GPU, GPU Drivers are Init and driver handles +## retrieved. +## - ZE_INIT_DRIVER_TYPE_FLAG_NPU, NPU Drivers are Init and driver handles +## retrieved. +## - ZE_INIT_DRIVER_TYPE_FLAG_GPU | ZE_INIT_DRIVER_TYPE_FLAG_NPU, NPU & GPU +## Drivers are Init and driver handles retrieved. +## - UINT32_MAX All Drivers of any type are Init and driver handles +## retrieved. +class ze_init_driver_type_flags_v(IntEnum): + GPU = ZE_BIT(0) ## initialize and retrieve GPU drivers + NPU = ZE_BIT(1) ## initialize and retrieve NPU drivers + +class ze_init_driver_type_flags_t(c_int): + def __str__(self): + return hex(self.value) + + +############################################################################### +## @brief Init Driver Type descriptor +class ze_init_driver_type_desc_t(Structure): + _fields_ = [ + ("stype", ze_structure_type_t), ## [in] type of this structure + ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific + ## structure (i.e. contains stype and pNext). + ("flags", ze_init_driver_type_flags_t) ## [in] driver type init flags. + ## must be a valid combination of ::ze_init_driver_type_flag_t or UINT32_MAX; + ## driver types are init and retrieved based on these init flags in zeInitDrivers(). + ] + ############################################################################### ## @brief Supported API versions ## @@ -443,13 +483,19 @@ class ze_api_version_v(IntEnum): _1_7 = ZE_MAKE_VERSION( 1, 7 ) ## version 1.7 _1_8 = ZE_MAKE_VERSION( 1, 8 ) ## version 1.8 _1_9 = ZE_MAKE_VERSION( 1, 9 ) ## version 1.9 - CURRENT = ZE_MAKE_VERSION( 1, 9 ) ## latest known version + _1_10 = ZE_MAKE_VERSION( 1, 10 ) ## version 1.10 + _1_11 = ZE_MAKE_VERSION( 1, 11 ) ## version 1.11 + CURRENT = ZE_MAKE_VERSION( 1, 11 ) ## latest known version class ze_api_version_t(c_int): def __str__(self): return str(ze_api_version_v(self.value)) +############################################################################### +## @brief Current API version as a macro +ZE_API_VERSION_CURRENT_M = ZE_MAKE_VERSION( 1, 11 ) + ############################################################################### ## @brief Maximum driver universal unique id (UUID) size in bytes ZE_MAX_DRIVER_UUID_SIZE = 16 @@ -1935,7 +1981,8 @@ def __str__(self): ############################################################################### ## @brief Supported physical memory creation flags class ze_physical_mem_flags_v(IntEnum): - TBD = ZE_BIT(0) ## reserved for future use. + ALLOCATE_ON_DEVICE = ZE_BIT(0) ## [default] allocate physical device memory. + ALLOCATE_ON_HOST = ZE_BIT(1) ## Allocate physical host memory instead. class ze_physical_mem_flags_t(c_int): def __str__(self): @@ -1950,7 +1997,8 @@ class ze_physical_mem_desc_t(Structure): ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific ## structure (i.e. contains stype and pNext). ("flags", ze_physical_mem_flags_t), ## [in] creation flags. - ## must be 0 (default) or a valid combination of ::ze_physical_mem_flag_t. + ## must be 0 (default) or a valid combination of + ## ::ze_physical_mem_flag_t; default is to create physical device memory. ("size", c_size_t) ## [in] size in bytes to reserve; must be page aligned. ] @@ -2018,6 +2066,157 @@ def __str__(self): return str(ze_global_offset_exp_version_v(self.value)) +############################################################################### +## @brief Mutable Command List Extension Name +ZE_MUTABLE_COMMAND_LIST_EXP_NAME = "ZE_experimental_mutable_command_list" + +############################################################################### +## @brief Mutable Command List Extension Version(s) +class ze_mutable_command_list_exp_version_v(IntEnum): + _1_0 = ZE_MAKE_VERSION( 1, 0 ) ## version 1.0 + _1_1 = ZE_MAKE_VERSION( 1, 1 ) ## version 1.1 + CURRENT = ZE_MAKE_VERSION( 1, 1 ) ## latest known version + +class ze_mutable_command_list_exp_version_t(c_int): + def __str__(self): + return str(ze_mutable_command_list_exp_version_v(self.value)) + + +############################################################################### +## @brief Mutable command flags +class ze_mutable_command_exp_flags_v(IntEnum): + KERNEL_ARGUMENTS = ZE_BIT(0) ## kernel arguments + GROUP_COUNT = ZE_BIT(1) ## kernel group count + GROUP_SIZE = ZE_BIT(2) ## kernel group size + GLOBAL_OFFSET = ZE_BIT(3) ## kernel global offset + SIGNAL_EVENT = ZE_BIT(4) ## command signal event + WAIT_EVENTS = ZE_BIT(5) ## command wait events + KERNEL_INSTRUCTION = ZE_BIT(6) ## command kernel + GRAPH_ARGUMENTS = ZE_BIT(7) ## graph arguments + +class ze_mutable_command_exp_flags_t(c_int): + def __str__(self): + return hex(self.value) + + +############################################################################### +## @brief Mutable command identifier descriptor +class ze_mutable_command_id_exp_desc_t(Structure): + _fields_ = [ + ("stype", ze_structure_type_t), ## [in] type of this structure + ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific + ## structure (i.e. contains stype and pNext). + ("flags", ze_mutable_command_exp_flags_t) ## [in] mutable command flags. + ## - must be 0 (default, equivalent to setting all flags bar kernel + ## instruction), or a valid combination of ::ze_mutable_command_exp_flag_t + ## - in order to include kernel instruction mutation, + ## ::ZE_MUTABLE_COMMAND_EXP_FLAG_KERNEL_INSTRUCTION must be explictly included + ] + +############################################################################### +## @brief Mutable command list flags +class ze_mutable_command_list_exp_flags_v(IntEnum): + RESERVED = ZE_BIT(0) ## reserved + +class ze_mutable_command_list_exp_flags_t(c_int): + def __str__(self): + return hex(self.value) + + +############################################################################### +## @brief Mutable command list properties +class ze_mutable_command_list_exp_properties_t(Structure): + _fields_ = [ + ("stype", ze_structure_type_t), ## [in] type of this structure + ("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific + ## structure (i.e. contains stype and pNext). + ("mutableCommandListFlags", ze_mutable_command_list_exp_flags_t), ## [out] mutable command list flags + ("mutableCommandFlags", ze_mutable_command_exp_flags_t) ## [out] mutable command flags + ] + +############################################################################### +## @brief Mutable command list descriptor +class ze_mutable_command_list_exp_desc_t(Structure): + _fields_ = [ + ("stype", ze_structure_type_t), ## [in] type of this structure + ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific + ## structure (i.e. contains stype and pNext). + ("flags", ze_mutable_command_list_exp_flags_t) ## [in] mutable command list flags. + ## - must be 0 (default) or a valid combination of ::ze_mutable_command_list_exp_flag_t + ] + +############################################################################### +## @brief Mutable commands descriptor +class ze_mutable_commands_exp_desc_t(Structure): + _fields_ = [ + ("stype", ze_structure_type_t), ## [in] type of this structure + ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific + ## structure (i.e. contains stype and pNext). + ("flags", c_ulong) ## [in] must be 0, this field is reserved for future use + ] + +############################################################################### +## @brief Mutable kernel argument descriptor +class ze_mutable_kernel_argument_exp_desc_t(Structure): + _fields_ = [ + ("stype", ze_structure_type_t), ## [in] type of this structure + ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific + ## structure (i.e. contains stype and pNext). + ("commandId", c_ulonglong), ## [in] command identifier + ("argIndex", c_ulong), ## [in] kernel argument index + ("argSize", c_size_t), ## [in] kernel argument size + ("pArgValue", c_void_p) ## [in] pointer to kernel argument value + ] + +############################################################################### +## @brief Mutable kernel group count descriptor +class ze_mutable_group_count_exp_desc_t(Structure): + _fields_ = [ + ("stype", ze_structure_type_t), ## [in] type of this structure + ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific + ## structure (i.e. contains stype and pNext). + ("commandId", c_ulonglong), ## [in] command identifier + ("pGroupCount", POINTER(ze_group_count_t)) ## [in] pointer to group count + ] + +############################################################################### +## @brief Mutable kernel group size descriptor +class ze_mutable_group_size_exp_desc_t(Structure): + _fields_ = [ + ("stype", ze_structure_type_t), ## [in] type of this structure + ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific + ## structure (i.e. contains stype and pNext). + ("commandId", c_ulonglong), ## [in] command identifier + ("groupSizeX", c_ulong), ## [in] group size for X dimension to use for the kernel + ("groupSizeY", c_ulong), ## [in] group size for Y dimension to use for the kernel + ("groupSizeZ", c_ulong) ## [in] group size for Z dimension to use for the kernel + ] + +############################################################################### +## @brief Mutable kernel global offset descriptor +class ze_mutable_global_offset_exp_desc_t(Structure): + _fields_ = [ + ("stype", ze_structure_type_t), ## [in] type of this structure + ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific + ## structure (i.e. contains stype and pNext). + ("commandId", c_ulonglong), ## [in] command identifier + ("offsetX", c_ulong), ## [in] global offset for X dimension to use for this kernel + ("offsetY", c_ulong), ## [in] global offset for Y dimension to use for this kernel + ("offsetZ", c_ulong) ## [in] global offset for Z dimension to use for this kernel + ] + +############################################################################### +## @brief Mutable graph argument descriptor +class ze_mutable_graph_argument_exp_desc_t(Structure): + _fields_ = [ + ("stype", ze_structure_type_t), ## [in] type of this structure + ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific + ## structure (i.e. contains stype and pNext). + ("commandId", c_ulonglong), ## [in] command identifier + ("argIndex", c_ulong), ## [in] graph argument index + ("pArgValue", c_void_p) ## [in] pointer to graph argument value + ] + ############################################################################### ## @brief Relaxed Allocation Limits Extension Name ZE_RELAXED_ALLOCATION_LIMITS_EXP_NAME = "ZE_experimental_relaxed_allocation_limits" @@ -2062,6 +2261,10 @@ class ze_relaxed_allocation_limits_exp_desc_t(Structure): ## must be 0 (default) or a valid combination of ::ze_relaxed_allocation_limits_exp_flag_t; ] +############################################################################### +## @brief Get Kernel Binary Extension Name +ZE_GET_KERNEL_BINARY_EXP_NAME = "ZE_extension_kernel_binary_exp" + ############################################################################### ## @brief Cache_Reservation Extension Name ZE_CACHE_RESERVATION_EXT_NAME = "ZE_extension_cache_reservation" @@ -3810,140 +4013,6 @@ def __str__(self): return str(ze_immediate_command_list_append_exp_version_v(self.value)) -############################################################################### -## @brief Mutable Command List Extension Name -ZE_MUTABLE_COMMAND_LIST_EXP_NAME = "ZE_experimental_mutable_command_list" - -############################################################################### -## @brief Mutable Command List Extension Version(s) -class ze_mutable_command_list_exp_version_v(IntEnum): - _1_0 = ZE_MAKE_VERSION( 1, 0 ) ## version 1.0 - CURRENT = ZE_MAKE_VERSION( 1, 0 ) ## latest known version - -class ze_mutable_command_list_exp_version_t(c_int): - def __str__(self): - return str(ze_mutable_command_list_exp_version_v(self.value)) - - -############################################################################### -## @brief Mutable command flags -class ze_mutable_command_exp_flags_v(IntEnum): - KERNEL_ARGUMENTS = ZE_BIT(0) ## kernel arguments - GROUP_COUNT = ZE_BIT(1) ## kernel group count - GROUP_SIZE = ZE_BIT(2) ## kernel group size - GLOBAL_OFFSET = ZE_BIT(3) ## kernel global offset - SIGNAL_EVENT = ZE_BIT(4) ## command signal event - WAIT_EVENTS = ZE_BIT(5) ## command wait events - -class ze_mutable_command_exp_flags_t(c_int): - def __str__(self): - return hex(self.value) - - -############################################################################### -## @brief Mutable command identifier descriptor -class ze_mutable_command_id_exp_desc_t(Structure): - _fields_ = [ - ("stype", ze_structure_type_t), ## [in] type of this structure - ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific - ## structure (i.e. contains stype and pNext). - ("flags", ze_mutable_command_exp_flags_t) ## [in] mutable command flags. - ## - must be 0 (default, equivalent to setting all flags), or a valid - ## combination of ::ze_mutable_command_exp_flag_t - ] - -############################################################################### -## @brief Mutable command list flags -class ze_mutable_command_list_exp_flags_v(IntEnum): - RESERVED = ZE_BIT(0) ## reserved - -class ze_mutable_command_list_exp_flags_t(c_int): - def __str__(self): - return hex(self.value) - - -############################################################################### -## @brief Mutable command list properties -class ze_mutable_command_list_exp_properties_t(Structure): - _fields_ = [ - ("stype", ze_structure_type_t), ## [in] type of this structure - ("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific - ## structure (i.e. contains stype and pNext). - ("mutableCommandListFlags", ze_mutable_command_list_exp_flags_t), ## [out] mutable command list flags - ("mutableCommandFlags", ze_mutable_command_exp_flags_t) ## [out] mutable command flags - ] - -############################################################################### -## @brief Mutable command list descriptor -class ze_mutable_command_list_exp_desc_t(Structure): - _fields_ = [ - ("stype", ze_structure_type_t), ## [in] type of this structure - ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific - ## structure (i.e. contains stype and pNext). - ("flags", ze_mutable_command_list_exp_flags_t) ## [in] mutable command list flags. - ## - must be 0 (default) or a valid combination of ::ze_mutable_command_list_exp_flag_t - ] - -############################################################################### -## @brief Mutable commands descriptor -class ze_mutable_commands_exp_desc_t(Structure): - _fields_ = [ - ("stype", ze_structure_type_t), ## [in] type of this structure - ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific - ## structure (i.e. contains stype and pNext). - ("flags", c_ulong) ## [in] must be 0, this field is reserved for future use - ] - -############################################################################### -## @brief Mutable kernel argument descriptor -class ze_mutable_kernel_argument_exp_desc_t(Structure): - _fields_ = [ - ("stype", ze_structure_type_t), ## [in] type of this structure - ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific - ## structure (i.e. contains stype and pNext). - ("commandId", c_ulonglong), ## [in] command identifier - ("argIndex", c_ulong), ## [in] kernel argument index - ("argSize", c_size_t), ## [in] kernel argument size - ("pArgValue", c_void_p) ## [in] pointer to kernel argument value - ] - -############################################################################### -## @brief Mutable kernel group count descriptor -class ze_mutable_group_count_exp_desc_t(Structure): - _fields_ = [ - ("stype", ze_structure_type_t), ## [in] type of this structure - ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific - ## structure (i.e. contains stype and pNext). - ("commandId", c_ulonglong), ## [in] command identifier - ("pGroupCount", POINTER(ze_group_count_t)) ## [in] pointer to group count - ] - -############################################################################### -## @brief Mutable kernel group size descriptor -class ze_mutable_group_size_exp_desc_t(Structure): - _fields_ = [ - ("stype", ze_structure_type_t), ## [in] type of this structure - ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific - ## structure (i.e. contains stype and pNext). - ("commandId", c_ulonglong), ## [in] command identifier - ("groupSizeX", c_ulong), ## [in] group size for X dimension to use for the kernel - ("groupSizeY", c_ulong), ## [in] group size for Y dimension to use for the kernel - ("groupSizeZ", c_ulong) ## [in] group size for Z dimension to use for the kernel - ] - -############################################################################### -## @brief Mutable kernel global offset descriptor -class ze_mutable_global_offset_exp_desc_t(Structure): - _fields_ = [ - ("stype", ze_structure_type_t), ## [in] type of this structure - ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific - ## structure (i.e. contains stype and pNext). - ("commandId", c_ulonglong), ## [in] command identifier - ("offsetX", c_ulong), ## [in] global offset for X dimension to use for this kernel - ("offsetY", c_ulong), ## [in] global offset for Y dimension to use for this kernel - ("offsetZ", c_ulong) ## [in] global offset for Z dimension to use for this kernel - ] - ############################################################################### __use_win_types = "Windows" == platform.uname()[0] @@ -4032,12 +4101,20 @@ class _ze_rtas_parallel_operation_exp_dditable_t(Structure): else: _zeInit_t = CFUNCTYPE( ze_result_t, ze_init_flags_t ) +############################################################################### +## @brief Function-pointer for zeInitDrivers +if __use_win_types: + _zeInitDrivers_t = WINFUNCTYPE( ze_result_t, POINTER(c_ulong), POINTER(ze_driver_handle_t), POINTER(ze_init_driver_type_desc_t) ) +else: + _zeInitDrivers_t = CFUNCTYPE( ze_result_t, POINTER(c_ulong), POINTER(ze_driver_handle_t), POINTER(ze_init_driver_type_desc_t) ) + ############################################################################### ## @brief Table of Global functions pointers class _ze_global_dditable_t(Structure): _fields_ = [ - ("pfnInit", c_void_p) ## _zeInit_t + ("pfnInit", c_void_p), ## _zeInit_t + ("pfnInitDrivers", c_void_p) ## _zeInitDrivers_t ] ############################################################################### @@ -4706,39 +4783,46 @@ class _ze_command_list_dditable_t(Structure): ] ############################################################################### -## @brief Function-pointer for zeCommandListCreateCloneExp +## @brief Function-pointer for zeCommandListGetNextCommandIdWithKernelsExp if __use_win_types: - _zeCommandListCreateCloneExp_t = WINFUNCTYPE( ze_result_t, ze_command_list_handle_t, POINTER(ze_command_list_handle_t) ) + _zeCommandListGetNextCommandIdWithKernelsExp_t = WINFUNCTYPE( ze_result_t, ze_command_list_handle_t, POINTER(ze_mutable_command_id_exp_desc_t), c_ulong, POINTER(ze_kernel_handle_t), POINTER(c_ulonglong) ) else: - _zeCommandListCreateCloneExp_t = CFUNCTYPE( ze_result_t, ze_command_list_handle_t, POINTER(ze_command_list_handle_t) ) + _zeCommandListGetNextCommandIdWithKernelsExp_t = CFUNCTYPE( ze_result_t, ze_command_list_handle_t, POINTER(ze_mutable_command_id_exp_desc_t), c_ulong, POINTER(ze_kernel_handle_t), POINTER(c_ulonglong) ) ############################################################################### -## @brief Function-pointer for zeCommandListImmediateAppendCommandListsExp +## @brief Function-pointer for zeCommandListUpdateMutableCommandsExp if __use_win_types: - _zeCommandListImmediateAppendCommandListsExp_t = WINFUNCTYPE( ze_result_t, ze_command_list_handle_t, c_ulong, POINTER(ze_command_list_handle_t), ze_event_handle_t, c_ulong, POINTER(ze_event_handle_t) ) + _zeCommandListUpdateMutableCommandsExp_t = WINFUNCTYPE( ze_result_t, ze_command_list_handle_t, POINTER(ze_mutable_commands_exp_desc_t) ) else: - _zeCommandListImmediateAppendCommandListsExp_t = CFUNCTYPE( ze_result_t, ze_command_list_handle_t, c_ulong, POINTER(ze_command_list_handle_t), ze_event_handle_t, c_ulong, POINTER(ze_event_handle_t) ) + _zeCommandListUpdateMutableCommandsExp_t = CFUNCTYPE( ze_result_t, ze_command_list_handle_t, POINTER(ze_mutable_commands_exp_desc_t) ) ############################################################################### -## @brief Function-pointer for zeCommandListGetNextCommandIdExp +## @brief Function-pointer for zeCommandListUpdateMutableCommandSignalEventExp if __use_win_types: - _zeCommandListGetNextCommandIdExp_t = WINFUNCTYPE( ze_result_t, ze_command_list_handle_t, POINTER(ze_mutable_command_id_exp_desc_t), POINTER(c_ulonglong) ) + _zeCommandListUpdateMutableCommandSignalEventExp_t = WINFUNCTYPE( ze_result_t, ze_command_list_handle_t, c_ulonglong, ze_event_handle_t ) else: - _zeCommandListGetNextCommandIdExp_t = CFUNCTYPE( ze_result_t, ze_command_list_handle_t, POINTER(ze_mutable_command_id_exp_desc_t), POINTER(c_ulonglong) ) + _zeCommandListUpdateMutableCommandSignalEventExp_t = CFUNCTYPE( ze_result_t, ze_command_list_handle_t, c_ulonglong, ze_event_handle_t ) ############################################################################### -## @brief Function-pointer for zeCommandListUpdateMutableCommandsExp +## @brief Function-pointer for zeCommandListUpdateMutableCommandKernelsExp if __use_win_types: - _zeCommandListUpdateMutableCommandsExp_t = WINFUNCTYPE( ze_result_t, ze_command_list_handle_t, POINTER(ze_mutable_commands_exp_desc_t) ) + _zeCommandListUpdateMutableCommandKernelsExp_t = WINFUNCTYPE( ze_result_t, ze_command_list_handle_t, c_ulong, POINTER(c_ulonglong), POINTER(ze_kernel_handle_t) ) else: - _zeCommandListUpdateMutableCommandsExp_t = CFUNCTYPE( ze_result_t, ze_command_list_handle_t, POINTER(ze_mutable_commands_exp_desc_t) ) + _zeCommandListUpdateMutableCommandKernelsExp_t = CFUNCTYPE( ze_result_t, ze_command_list_handle_t, c_ulong, POINTER(c_ulonglong), POINTER(ze_kernel_handle_t) ) ############################################################################### -## @brief Function-pointer for zeCommandListUpdateMutableCommandSignalEventExp +## @brief Function-pointer for zeCommandListCreateCloneExp if __use_win_types: - _zeCommandListUpdateMutableCommandSignalEventExp_t = WINFUNCTYPE( ze_result_t, ze_command_list_handle_t, c_ulonglong, ze_event_handle_t ) + _zeCommandListCreateCloneExp_t = WINFUNCTYPE( ze_result_t, ze_command_list_handle_t, POINTER(ze_command_list_handle_t) ) else: - _zeCommandListUpdateMutableCommandSignalEventExp_t = CFUNCTYPE( ze_result_t, ze_command_list_handle_t, c_ulonglong, ze_event_handle_t ) + _zeCommandListCreateCloneExp_t = CFUNCTYPE( ze_result_t, ze_command_list_handle_t, POINTER(ze_command_list_handle_t) ) + +############################################################################### +## @brief Function-pointer for zeCommandListGetNextCommandIdExp +if __use_win_types: + _zeCommandListGetNextCommandIdExp_t = WINFUNCTYPE( ze_result_t, ze_command_list_handle_t, POINTER(ze_mutable_command_id_exp_desc_t), POINTER(c_ulonglong) ) +else: + _zeCommandListGetNextCommandIdExp_t = CFUNCTYPE( ze_result_t, ze_command_list_handle_t, POINTER(ze_mutable_command_id_exp_desc_t), POINTER(c_ulonglong) ) ############################################################################### ## @brief Function-pointer for zeCommandListUpdateMutableCommandWaitEventsExp @@ -4747,17 +4831,26 @@ class _ze_command_list_dditable_t(Structure): else: _zeCommandListUpdateMutableCommandWaitEventsExp_t = CFUNCTYPE( ze_result_t, ze_command_list_handle_t, c_ulonglong, c_ulong, POINTER(ze_event_handle_t) ) +############################################################################### +## @brief Function-pointer for zeCommandListImmediateAppendCommandListsExp +if __use_win_types: + _zeCommandListImmediateAppendCommandListsExp_t = WINFUNCTYPE( ze_result_t, ze_command_list_handle_t, c_ulong, POINTER(ze_command_list_handle_t), ze_event_handle_t, c_ulong, POINTER(ze_event_handle_t) ) +else: + _zeCommandListImmediateAppendCommandListsExp_t = CFUNCTYPE( ze_result_t, ze_command_list_handle_t, c_ulong, POINTER(ze_command_list_handle_t), ze_event_handle_t, c_ulong, POINTER(ze_event_handle_t) ) + ############################################################################### ## @brief Table of CommandListExp functions pointers class _ze_command_list_exp_dditable_t(Structure): _fields_ = [ - ("pfnCreateCloneExp", c_void_p), ## _zeCommandListCreateCloneExp_t - ("pfnImmediateAppendCommandListsExp", c_void_p), ## _zeCommandListImmediateAppendCommandListsExp_t - ("pfnGetNextCommandIdExp", c_void_p), ## _zeCommandListGetNextCommandIdExp_t + ("pfnGetNextCommandIdWithKernelsExp", c_void_p), ## _zeCommandListGetNextCommandIdWithKernelsExp_t ("pfnUpdateMutableCommandsExp", c_void_p), ## _zeCommandListUpdateMutableCommandsExp_t ("pfnUpdateMutableCommandSignalEventExp", c_void_p), ## _zeCommandListUpdateMutableCommandSignalEventExp_t - ("pfnUpdateMutableCommandWaitEventsExp", c_void_p) ## _zeCommandListUpdateMutableCommandWaitEventsExp_t + ("pfnUpdateMutableCommandKernelsExp", c_void_p), ## _zeCommandListUpdateMutableCommandKernelsExp_t + ("pfnCreateCloneExp", c_void_p), ## _zeCommandListCreateCloneExp_t + ("pfnGetNextCommandIdExp", c_void_p), ## _zeCommandListGetNextCommandIdExp_t + ("pfnUpdateMutableCommandWaitEventsExp", c_void_p), ## _zeCommandListUpdateMutableCommandWaitEventsExp_t + ("pfnImmediateAppendCommandListsExp", c_void_p) ## _zeCommandListImmediateAppendCommandListsExp_t ] ############################################################################### @@ -5696,6 +5789,7 @@ def __init__(self, version : ze_api_version_t): # attach function interface to function address self.zeInit = _zeInit_t(self.__dditable.Global.pfnInit) + self.zeInitDrivers = _zeInitDrivers_t(self.__dditable.Global.pfnInitDrivers) # call driver to get function pointers _Driver = _ze_driver_dditable_t() @@ -5845,12 +5939,14 @@ def __init__(self, version : ze_api_version_t): self.__dditable.CommandListExp = _CommandListExp # attach function interface to function address - self.zeCommandListCreateCloneExp = _zeCommandListCreateCloneExp_t(self.__dditable.CommandListExp.pfnCreateCloneExp) - self.zeCommandListImmediateAppendCommandListsExp = _zeCommandListImmediateAppendCommandListsExp_t(self.__dditable.CommandListExp.pfnImmediateAppendCommandListsExp) - self.zeCommandListGetNextCommandIdExp = _zeCommandListGetNextCommandIdExp_t(self.__dditable.CommandListExp.pfnGetNextCommandIdExp) + self.zeCommandListGetNextCommandIdWithKernelsExp = _zeCommandListGetNextCommandIdWithKernelsExp_t(self.__dditable.CommandListExp.pfnGetNextCommandIdWithKernelsExp) self.zeCommandListUpdateMutableCommandsExp = _zeCommandListUpdateMutableCommandsExp_t(self.__dditable.CommandListExp.pfnUpdateMutableCommandsExp) self.zeCommandListUpdateMutableCommandSignalEventExp = _zeCommandListUpdateMutableCommandSignalEventExp_t(self.__dditable.CommandListExp.pfnUpdateMutableCommandSignalEventExp) + self.zeCommandListUpdateMutableCommandKernelsExp = _zeCommandListUpdateMutableCommandKernelsExp_t(self.__dditable.CommandListExp.pfnUpdateMutableCommandKernelsExp) + self.zeCommandListCreateCloneExp = _zeCommandListCreateCloneExp_t(self.__dditable.CommandListExp.pfnCreateCloneExp) + self.zeCommandListGetNextCommandIdExp = _zeCommandListGetNextCommandIdExp_t(self.__dditable.CommandListExp.pfnGetNextCommandIdExp) self.zeCommandListUpdateMutableCommandWaitEventsExp = _zeCommandListUpdateMutableCommandWaitEventsExp_t(self.__dditable.CommandListExp.pfnUpdateMutableCommandWaitEventsExp) + self.zeCommandListImmediateAppendCommandListsExp = _zeCommandListImmediateAppendCommandListsExp_t(self.__dditable.CommandListExp.pfnImmediateAppendCommandListsExp) # call driver to get function pointers _Image = _ze_image_dditable_t() diff --git a/include/ze_api.h b/include/ze_api.h index 2f59f4bb..fd7ca53a 100644 --- a/include/ze_api.h +++ b/include/ze_api.h @@ -5,7 +5,7 @@ * SPDX-License-Identifier: MIT * * @file ze_api.h - * @version v1.9-r1.9.3 + * @version v1.11-r1.11.0 * */ #ifndef _ZE_API_H @@ -248,6 +248,7 @@ typedef enum _ze_result_t ZE_RESULT_ERROR_OVERLAPPING_REGIONS = 0x7800001a, ///< [Validation] copy operations do not support overlapping regions of ///< memory ZE_RESULT_WARNING_ACTION_REQUIRED = 0x7800001b, ///< [Sysman] an action is required to complete the desired operation + ZE_RESULT_ERROR_INVALID_KERNEL_HANDLE = 0x7800001c, ///< [Core, Validation] kernel handle is invalid for the operation ZE_RESULT_ERROR_UNKNOWN = 0x7ffffffe, ///< [Core] unknown or internal error ZE_RESULT_FORCE_UINT32 = 0x7fffffff @@ -342,6 +343,8 @@ typedef enum _ze_structure_type_t ZE_STRUCTURE_TYPE_PITCHED_ALLOC_DEVICE_EXP_PROPERTIES = 0x0002001D, ///< ::ze_device_pitched_alloc_exp_properties_t ZE_STRUCTURE_TYPE_BINDLESS_IMAGE_EXP_DESC = 0x0002001E, ///< ::ze_image_bindless_exp_desc_t ZE_STRUCTURE_TYPE_PITCHED_IMAGE_EXP_DESC = 0x0002001F, ///< ::ze_image_pitched_exp_desc_t + ZE_STRUCTURE_TYPE_MUTABLE_GRAPH_ARGUMENT_EXP_DESC = 0x00020020, ///< ::ze_mutable_graph_argument_exp_desc_t + ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC = 0x00020021, ///< ::ze_init_driver_type_desc_t ZE_STRUCTURE_TYPE_FORCE_UINT32 = 0x7fffffff } ze_structure_type_t; @@ -470,6 +473,10 @@ typedef struct _ze_base_properties_t ze_base_properties_t; /// @brief Forward-declare ze_base_desc_t typedef struct _ze_base_desc_t ze_base_desc_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare ze_init_driver_type_desc_t +typedef struct _ze_init_driver_type_desc_t ze_init_driver_type_desc_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Forward-declare ze_driver_uuid_t typedef struct _ze_driver_uuid_t ze_driver_uuid_t; @@ -678,6 +685,42 @@ typedef struct _ze_physical_mem_desc_t ze_physical_mem_desc_t; /// @brief Forward-declare ze_float_atomic_ext_properties_t typedef struct _ze_float_atomic_ext_properties_t ze_float_atomic_ext_properties_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare ze_mutable_command_id_exp_desc_t +typedef struct _ze_mutable_command_id_exp_desc_t ze_mutable_command_id_exp_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare ze_mutable_command_list_exp_properties_t +typedef struct _ze_mutable_command_list_exp_properties_t ze_mutable_command_list_exp_properties_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare ze_mutable_command_list_exp_desc_t +typedef struct _ze_mutable_command_list_exp_desc_t ze_mutable_command_list_exp_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare ze_mutable_commands_exp_desc_t +typedef struct _ze_mutable_commands_exp_desc_t ze_mutable_commands_exp_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare ze_mutable_kernel_argument_exp_desc_t +typedef struct _ze_mutable_kernel_argument_exp_desc_t ze_mutable_kernel_argument_exp_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare ze_mutable_group_count_exp_desc_t +typedef struct _ze_mutable_group_count_exp_desc_t ze_mutable_group_count_exp_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare ze_mutable_group_size_exp_desc_t +typedef struct _ze_mutable_group_size_exp_desc_t ze_mutable_group_size_exp_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare ze_mutable_global_offset_exp_desc_t +typedef struct _ze_mutable_global_offset_exp_desc_t ze_mutable_global_offset_exp_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare ze_mutable_graph_argument_exp_desc_t +typedef struct _ze_mutable_graph_argument_exp_desc_t ze_mutable_graph_argument_exp_desc_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Forward-declare ze_relaxed_allocation_limits_exp_desc_t typedef struct _ze_relaxed_allocation_limits_exp_desc_t ze_relaxed_allocation_limits_exp_desc_t; @@ -902,38 +945,6 @@ typedef struct _ze_image_pitched_exp_desc_t ze_image_pitched_exp_desc_t; /// @brief Forward-declare ze_device_pitched_alloc_exp_properties_t typedef struct _ze_device_pitched_alloc_exp_properties_t ze_device_pitched_alloc_exp_properties_t; -/////////////////////////////////////////////////////////////////////////////// -/// @brief Forward-declare ze_mutable_command_id_exp_desc_t -typedef struct _ze_mutable_command_id_exp_desc_t ze_mutable_command_id_exp_desc_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Forward-declare ze_mutable_command_list_exp_properties_t -typedef struct _ze_mutable_command_list_exp_properties_t ze_mutable_command_list_exp_properties_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Forward-declare ze_mutable_command_list_exp_desc_t -typedef struct _ze_mutable_command_list_exp_desc_t ze_mutable_command_list_exp_desc_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Forward-declare ze_mutable_commands_exp_desc_t -typedef struct _ze_mutable_commands_exp_desc_t ze_mutable_commands_exp_desc_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Forward-declare ze_mutable_kernel_argument_exp_desc_t -typedef struct _ze_mutable_kernel_argument_exp_desc_t ze_mutable_kernel_argument_exp_desc_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Forward-declare ze_mutable_group_count_exp_desc_t -typedef struct _ze_mutable_group_count_exp_desc_t ze_mutable_group_count_exp_desc_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Forward-declare ze_mutable_group_size_exp_desc_t -typedef struct _ze_mutable_group_size_exp_desc_t ze_mutable_group_size_exp_desc_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Forward-declare ze_mutable_global_offset_exp_desc_t -typedef struct _ze_mutable_global_offset_exp_desc_t ze_mutable_global_offset_exp_desc_t; - #if !defined(__GNUC__) #pragma endregion @@ -1020,6 +1031,105 @@ zeDriverGet( ///< shall only retrieve that number of drivers. ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Supported driver initialization type flags +/// +/// @details +/// - Bit Field which details the driver types to be initialized and +/// returned to the user. +/// - Value Definition: +/// - 0, do not init or retrieve any drivers. +/// - ZE_INIT_DRIVER_TYPE_FLAG_GPU, GPU Drivers are Init and driver handles +/// retrieved. +/// - ZE_INIT_DRIVER_TYPE_FLAG_NPU, NPU Drivers are Init and driver handles +/// retrieved. +/// - ZE_INIT_DRIVER_TYPE_FLAG_GPU | ZE_INIT_DRIVER_TYPE_FLAG_NPU, NPU & GPU +/// Drivers are Init and driver handles retrieved. +/// - UINT32_MAX All Drivers of any type are Init and driver handles +/// retrieved. +typedef uint32_t ze_init_driver_type_flags_t; +typedef enum _ze_init_driver_type_flag_t +{ + ZE_INIT_DRIVER_TYPE_FLAG_GPU = ZE_BIT(0), ///< initialize and retrieve GPU drivers + ZE_INIT_DRIVER_TYPE_FLAG_NPU = ZE_BIT(1), ///< initialize and retrieve NPU drivers + ZE_INIT_DRIVER_TYPE_FLAG_FORCE_UINT32 = 0x7fffffff + +} ze_init_driver_type_flag_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Init Driver Type descriptor +typedef struct _ze_init_driver_type_desc_t +{ + ze_structure_type_t stype; ///< [in] type of this structure + const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific + ///< structure (i.e. contains stype and pNext). + ze_init_driver_type_flags_t flags; ///< [in] driver type init flags. + ///< must be a valid combination of ::ze_init_driver_type_flag_t or UINT32_MAX; + ///< driver types are init and retrieved based on these init flags in zeInitDrivers(). + +} ze_init_driver_type_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Initialize the 'oneAPI' driver(s) based on the driver types requested +/// and retrieve the driver handles. +/// +/// @details +/// - The application must call this function or zeInit before calling any +/// other function. +/// - The application can call InitDrivers or zeInit to init the drivers on +/// the system. +/// - Calls to zeInit or InitDrivers will not alter the drivers retrieved +/// thru either api. +/// - Drivers init thru zeInit or InitDrivers will not be reInitialized once +/// init in an application. The Loader will determine if the already init +/// driver needs to be delivered to the user thru the init type flags. +/// - Already init Drivers will not be uninitialized if the call to +/// InitDrivers does not include that driver's type. Those init drivers +/// which don't match the init flags will not have their driver handles +/// returned to the user in that InitDrivers call. +/// - If this function or zeInit is not called, then all other functions +/// will return ::ZE_RESULT_ERROR_UNINITIALIZED. +/// - Only one instance of each driver will be initialized per process. +/// - A driver represents a collection of physical devices. +/// - Multiple calls to this function will return identical driver handles, +/// in the same order. +/// - The drivers returned to the caller will be based on the init types +/// which state the drivers to be included. +/// - The application may pass nullptr for pDrivers when only querying the +/// number of drivers. +/// - The application may call this function multiple times with different +/// flags or environment variables enabled. +/// - The application must call this function after forking new processes. +/// Each forked process must call this function. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe for scenarios +/// where multiple libraries may initialize the driver(s) simultaneously. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCount` +/// + `nullptr == desc` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x0 == desc->flags` +ZE_APIEXPORT ze_result_t ZE_APICALL +zeInitDrivers( + uint32_t* pCount, ///< [in,out] pointer to the number of driver instances. + ///< if count is zero, then the loader shall update the value with the + ///< total number of drivers available. + ///< if count is greater than the number of drivers available, then the + ///< loader shall update the value with the correct number of drivers available. + ze_driver_handle_t* phDrivers, ///< [in,out][optional][range(0, *pCount)] array of driver instance handles. + ///< if count is less than the number of drivers available, then the loader + ///< shall only retrieve that number of drivers. + ze_init_driver_type_desc_t* desc ///< [in] descriptor containing the driver type initialization details + ///< including ::ze_init_driver_type_flag_t combinations. + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Supported API versions /// @@ -1038,11 +1148,19 @@ typedef enum _ze_api_version_t ZE_API_VERSION_1_7 = ZE_MAKE_VERSION( 1, 7 ), ///< version 1.7 ZE_API_VERSION_1_8 = ZE_MAKE_VERSION( 1, 8 ), ///< version 1.8 ZE_API_VERSION_1_9 = ZE_MAKE_VERSION( 1, 9 ), ///< version 1.9 - ZE_API_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 9 ), ///< latest known version + ZE_API_VERSION_1_10 = ZE_MAKE_VERSION( 1, 10 ), ///< version 1.10 + ZE_API_VERSION_1_11 = ZE_MAKE_VERSION( 1, 11 ), ///< version 1.11 + ZE_API_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 11 ), ///< latest known version ZE_API_VERSION_FORCE_UINT32 = 0x7fffffff } ze_api_version_t; +/////////////////////////////////////////////////////////////////////////////// +#ifndef ZE_API_VERSION_CURRENT_M +/// @brief Current API version as a macro +#define ZE_API_VERSION_CURRENT_M ZE_MAKE_VERSION( 1, 11 ) +#endif // ZE_API_VERSION_CURRENT_M + /////////////////////////////////////////////////////////////////////////////// /// @brief Returns the API version supported by the specified driver /// @@ -2159,13 +2277,15 @@ zeDeviceGetStatus( /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER /// + `nullptr == hostTimestamp` /// + `nullptr == deviceTimestamp` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + The feature is not supported by the underlying platform. ZE_APIEXPORT ze_result_t ZE_APICALL zeDeviceGetGlobalTimestamps( ze_device_handle_t hDevice, ///< [in] handle of the device uint64_t* hostTimestamp, ///< [out] value of the Host's global timestamp that correlates with the - ///< Device's global timestamp value + ///< Device's global timestamp value. uint64_t* deviceTimestamp ///< [out] value of the Device's global timestamp that correlates with the - ///< Host's global timestamp value + ///< Host's global timestamp value. ); #if !defined(__GNUC__) @@ -7134,7 +7254,8 @@ zeVirtualMemQueryPageSize( typedef uint32_t ze_physical_mem_flags_t; typedef enum _ze_physical_mem_flag_t { - ZE_PHYSICAL_MEM_FLAG_TBD = ZE_BIT(0), ///< reserved for future use. + ZE_PHYSICAL_MEM_FLAG_ALLOCATE_ON_DEVICE = ZE_BIT(0), ///< [default] allocate physical device memory. + ZE_PHYSICAL_MEM_FLAG_ALLOCATE_ON_HOST = ZE_BIT(1), ///< Allocate physical host memory instead. ZE_PHYSICAL_MEM_FLAG_FORCE_UINT32 = 0x7fffffff } ze_physical_mem_flag_t; @@ -7147,7 +7268,8 @@ typedef struct _ze_physical_mem_desc_t const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific ///< structure (i.e. contains stype and pNext). ze_physical_mem_flags_t flags; ///< [in] creation flags. - ///< must be 0 (default) or a valid combination of ::ze_physical_mem_flag_t. + ///< must be 0 (default) or a valid combination of + ///< ::ze_physical_mem_flag_t; default is to create physical device memory. size_t size; ///< [in] size in bytes to reserve; must be page aligned. } ze_physical_mem_desc_t; @@ -7158,7 +7280,9 @@ typedef struct _ze_physical_mem_desc_t /// @details /// - The application must only use the physical memory object on the /// context for which it was created. -/// - The size must be page aligned. See ::zeVirtualMemQueryPageSize. +/// - The size must be page aligned. For host memory, the operating system +/// page size should be used. For device memory, see +/// ::zeVirtualMemQueryPageSize. /// - The application may call this function from simultaneous threads. /// - The implementation of this function must be thread-safe. /// @@ -7175,14 +7299,15 @@ typedef struct _ze_physical_mem_desc_t /// + `nullptr == desc` /// + `nullptr == phPhysicalMemory` /// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION -/// + `0x1 < desc->flags` +/// + `0x3 < desc->flags` /// - ::ZE_RESULT_ERROR_UNSUPPORTED_SIZE /// + `0 == desc->size` /// - ::ZE_RESULT_ERROR_UNSUPPORTED_ALIGNMENT ZE_APIEXPORT ze_result_t ZE_APICALL zePhysicalMemCreate( ze_context_handle_t hContext, ///< [in] handle of the context object - ze_device_handle_t hDevice, ///< [in] handle of the device object + ze_device_handle_t hDevice, ///< [in] handle of the device object, can be `nullptr` if creating + ///< physical host memory. ze_physical_mem_desc_t* desc, ///< [in] pointer to physical memory descriptor. ze_physical_mem_handle_t* phPhysicalMemory ///< [out] pointer to handle of physical memory object created ); @@ -7471,125 +7596,515 @@ zeKernelSetGlobalOffsetExp( #if !defined(__GNUC__) #pragma endregion #endif -// Intel 'oneAPI' Level-Zero Extension for supporting relaxed allocation limits. +// Intel 'oneAPI' Level-Zero Extension for supporting compute graphs with dynamic properties. #if !defined(__GNUC__) -#pragma region relaxedAllocLimits +#pragma region mutableCommandList #endif /////////////////////////////////////////////////////////////////////////////// -#ifndef ZE_RELAXED_ALLOCATION_LIMITS_EXP_NAME -/// @brief Relaxed Allocation Limits Extension Name -#define ZE_RELAXED_ALLOCATION_LIMITS_EXP_NAME "ZE_experimental_relaxed_allocation_limits" -#endif // ZE_RELAXED_ALLOCATION_LIMITS_EXP_NAME +#ifndef ZE_MUTABLE_COMMAND_LIST_EXP_NAME +/// @brief Mutable Command List Extension Name +#define ZE_MUTABLE_COMMAND_LIST_EXP_NAME "ZE_experimental_mutable_command_list" +#endif // ZE_MUTABLE_COMMAND_LIST_EXP_NAME /////////////////////////////////////////////////////////////////////////////// -/// @brief Relaxed Allocation Limits Extension Version(s) -typedef enum _ze_relaxed_allocation_limits_exp_version_t +/// @brief Mutable Command List Extension Version(s) +typedef enum _ze_mutable_command_list_exp_version_t { - ZE_RELAXED_ALLOCATION_LIMITS_EXP_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 - ZE_RELAXED_ALLOCATION_LIMITS_EXP_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 0 ), ///< latest known version - ZE_RELAXED_ALLOCATION_LIMITS_EXP_VERSION_FORCE_UINT32 = 0x7fffffff + ZE_MUTABLE_COMMAND_LIST_EXP_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 + ZE_MUTABLE_COMMAND_LIST_EXP_VERSION_1_1 = ZE_MAKE_VERSION( 1, 1 ), ///< version 1.1 + ZE_MUTABLE_COMMAND_LIST_EXP_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 1 ), ///< latest known version + ZE_MUTABLE_COMMAND_LIST_EXP_VERSION_FORCE_UINT32 = 0x7fffffff -} ze_relaxed_allocation_limits_exp_version_t; +} ze_mutable_command_list_exp_version_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Supported relaxed memory allocation flags -typedef uint32_t ze_relaxed_allocation_limits_exp_flags_t; -typedef enum _ze_relaxed_allocation_limits_exp_flag_t +/// @brief Mutable command flags +typedef uint32_t ze_mutable_command_exp_flags_t; +typedef enum _ze_mutable_command_exp_flag_t { - ZE_RELAXED_ALLOCATION_LIMITS_EXP_FLAG_MAX_SIZE = ZE_BIT(0), ///< Allocation size may exceed the `maxMemAllocSize` member of - ///< ::ze_device_properties_t. - ZE_RELAXED_ALLOCATION_LIMITS_EXP_FLAG_FORCE_UINT32 = 0x7fffffff + ZE_MUTABLE_COMMAND_EXP_FLAG_KERNEL_ARGUMENTS = ZE_BIT(0), ///< kernel arguments + ZE_MUTABLE_COMMAND_EXP_FLAG_GROUP_COUNT = ZE_BIT(1), ///< kernel group count + ZE_MUTABLE_COMMAND_EXP_FLAG_GROUP_SIZE = ZE_BIT(2), ///< kernel group size + ZE_MUTABLE_COMMAND_EXP_FLAG_GLOBAL_OFFSET = ZE_BIT(3), ///< kernel global offset + ZE_MUTABLE_COMMAND_EXP_FLAG_SIGNAL_EVENT = ZE_BIT(4), ///< command signal event + ZE_MUTABLE_COMMAND_EXP_FLAG_WAIT_EVENTS = ZE_BIT(5), ///< command wait events + ZE_MUTABLE_COMMAND_EXP_FLAG_KERNEL_INSTRUCTION = ZE_BIT(6), ///< command kernel + ZE_MUTABLE_COMMAND_EXP_FLAG_GRAPH_ARGUMENTS = ZE_BIT(7), ///< graph arguments + ZE_MUTABLE_COMMAND_EXP_FLAG_FORCE_UINT32 = 0x7fffffff -} ze_relaxed_allocation_limits_exp_flag_t; +} ze_mutable_command_exp_flag_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Relaxed limits memory allocation descriptor -/// -/// @details -/// - This structure may be passed to ::zeMemAllocShared or -/// ::zeMemAllocDevice, via the `pNext` member of -/// ::ze_device_mem_alloc_desc_t. -/// - This structure may also be passed to ::zeMemAllocHost, via the `pNext` -/// member of ::ze_host_mem_alloc_desc_t. -typedef struct _ze_relaxed_allocation_limits_exp_desc_t +/// @brief Mutable command identifier descriptor +typedef struct _ze_mutable_command_id_exp_desc_t { ze_structure_type_t stype; ///< [in] type of this structure const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific ///< structure (i.e. contains stype and pNext). - ze_relaxed_allocation_limits_exp_flags_t flags; ///< [in] flags specifying allocation limits to relax. - ///< must be 0 (default) or a valid combination of ::ze_relaxed_allocation_limits_exp_flag_t; + ze_mutable_command_exp_flags_t flags; ///< [in] mutable command flags. + ///< - must be 0 (default, equivalent to setting all flags bar kernel + ///< instruction), or a valid combination of ::ze_mutable_command_exp_flag_t + ///< - in order to include kernel instruction mutation, + ///< ::ZE_MUTABLE_COMMAND_EXP_FLAG_KERNEL_INSTRUCTION must be explictly included -} ze_relaxed_allocation_limits_exp_desc_t; +} ze_mutable_command_id_exp_desc_t; -#if !defined(__GNUC__) -#pragma endregion -#endif -// Intel 'oneAPI' Level-Zero Extension APIs for Cache Reservation -#if !defined(__GNUC__) -#pragma region cacheReservation -#endif /////////////////////////////////////////////////////////////////////////////// -#ifndef ZE_CACHE_RESERVATION_EXT_NAME -/// @brief Cache_Reservation Extension Name -#define ZE_CACHE_RESERVATION_EXT_NAME "ZE_extension_cache_reservation" -#endif // ZE_CACHE_RESERVATION_EXT_NAME +/// @brief Mutable command list flags +typedef uint32_t ze_mutable_command_list_exp_flags_t; +typedef enum _ze_mutable_command_list_exp_flag_t +{ + ZE_MUTABLE_COMMAND_LIST_EXP_FLAG_RESERVED = ZE_BIT(0), ///< reserved + ZE_MUTABLE_COMMAND_LIST_EXP_FLAG_FORCE_UINT32 = 0x7fffffff + +} ze_mutable_command_list_exp_flag_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Cache_Reservation Extension Version(s) -typedef enum _ze_cache_reservation_ext_version_t +/// @brief Mutable command list properties +typedef struct _ze_mutable_command_list_exp_properties_t { - ZE_CACHE_RESERVATION_EXT_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 - ZE_CACHE_RESERVATION_EXT_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 0 ), ///< latest known version - ZE_CACHE_RESERVATION_EXT_VERSION_FORCE_UINT32 = 0x7fffffff + ze_structure_type_t stype; ///< [in] type of this structure + void* pNext; ///< [in,out][optional] must be null or a pointer to an extension-specific + ///< structure (i.e. contains stype and pNext). + ze_mutable_command_list_exp_flags_t mutableCommandListFlags; ///< [out] mutable command list flags + ze_mutable_command_exp_flags_t mutableCommandFlags; ///< [out] mutable command flags -} ze_cache_reservation_ext_version_t; +} ze_mutable_command_list_exp_properties_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Cache Reservation Region -typedef enum _ze_cache_ext_region_t +/// @brief Mutable command list descriptor +typedef struct _ze_mutable_command_list_exp_desc_t { - ZE_CACHE_EXT_REGION_ZE_CACHE_REGION_DEFAULT = 0, ///< [DEPRECATED] utilize driver default scheme. Use - ///< ::ZE_CACHE_EXT_REGION_DEFAULT. - ZE_CACHE_EXT_REGION_ZE_CACHE_RESERVE_REGION = 1, ///< [DEPRECATED] utilize reserved region. Use - ///< ::ZE_CACHE_EXT_REGION_RESERVED. - ZE_CACHE_EXT_REGION_ZE_CACHE_NON_RESERVED_REGION = 2, ///< [DEPRECATED] utilize non-reserverd region. Use - ///< ::ZE_CACHE_EXT_REGION_NON_RESERVED. - ZE_CACHE_EXT_REGION_DEFAULT = 0, ///< utilize driver default scheme - ZE_CACHE_EXT_REGION_RESERVED = 1, ///< utilize reserved region - ZE_CACHE_EXT_REGION_NON_RESERVED = 2, ///< utilize non-reserverd region - ZE_CACHE_EXT_REGION_FORCE_UINT32 = 0x7fffffff + ze_structure_type_t stype; ///< [in] type of this structure + const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific + ///< structure (i.e. contains stype and pNext). + ze_mutable_command_list_exp_flags_t flags; ///< [in] mutable command list flags. + ///< - must be 0 (default) or a valid combination of ::ze_mutable_command_list_exp_flag_t -} ze_cache_ext_region_t; +} ze_mutable_command_list_exp_desc_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief CacheReservation structure -/// -/// @details -/// - This structure must be passed to ::zeDeviceGetCacheProperties via the -/// `pNext` member of ::ze_device_cache_properties_t -/// - Used for determining the max cache reservation allowed on device. Size -/// of zero means no reservation available. -typedef struct _ze_cache_reservation_ext_desc_t +/// @brief Mutable commands descriptor +typedef struct _ze_mutable_commands_exp_desc_t { ze_structure_type_t stype; ///< [in] type of this structure const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific ///< structure (i.e. contains stype and pNext). - size_t maxCacheReservationSize; ///< [out] max cache reservation size + uint32_t flags; ///< [in] must be 0, this field is reserved for future use -} ze_cache_reservation_ext_desc_t; +} ze_mutable_commands_exp_desc_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Reserve Cache on Device -/// -/// @details -/// - The application may call this function but may not be successful as -/// some other application may have reserve prior -/// -/// @remarks -/// _Analogues_ -/// - None -/// -/// @returns +/// @brief Mutable kernel argument descriptor +typedef struct _ze_mutable_kernel_argument_exp_desc_t +{ + ze_structure_type_t stype; ///< [in] type of this structure + const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific + ///< structure (i.e. contains stype and pNext). + uint64_t commandId; ///< [in] command identifier + uint32_t argIndex; ///< [in] kernel argument index + size_t argSize; ///< [in] kernel argument size + const void* pArgValue; ///< [in] pointer to kernel argument value + +} ze_mutable_kernel_argument_exp_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Mutable kernel group count descriptor +typedef struct _ze_mutable_group_count_exp_desc_t +{ + ze_structure_type_t stype; ///< [in] type of this structure + const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific + ///< structure (i.e. contains stype and pNext). + uint64_t commandId; ///< [in] command identifier + const ze_group_count_t* pGroupCount; ///< [in] pointer to group count + +} ze_mutable_group_count_exp_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Mutable kernel group size descriptor +typedef struct _ze_mutable_group_size_exp_desc_t +{ + ze_structure_type_t stype; ///< [in] type of this structure + const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific + ///< structure (i.e. contains stype and pNext). + uint64_t commandId; ///< [in] command identifier + uint32_t groupSizeX; ///< [in] group size for X dimension to use for the kernel + uint32_t groupSizeY; ///< [in] group size for Y dimension to use for the kernel + uint32_t groupSizeZ; ///< [in] group size for Z dimension to use for the kernel + +} ze_mutable_group_size_exp_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Mutable kernel global offset descriptor +typedef struct _ze_mutable_global_offset_exp_desc_t +{ + ze_structure_type_t stype; ///< [in] type of this structure + const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific + ///< structure (i.e. contains stype and pNext). + uint64_t commandId; ///< [in] command identifier + uint32_t offsetX; ///< [in] global offset for X dimension to use for this kernel + uint32_t offsetY; ///< [in] global offset for Y dimension to use for this kernel + uint32_t offsetZ; ///< [in] global offset for Z dimension to use for this kernel + +} ze_mutable_global_offset_exp_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Mutable graph argument descriptor +typedef struct _ze_mutable_graph_argument_exp_desc_t +{ + ze_structure_type_t stype; ///< [in] type of this structure + const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific + ///< structure (i.e. contains stype and pNext). + uint64_t commandId; ///< [in] command identifier + uint32_t argIndex; ///< [in] graph argument index + const void* pArgValue; ///< [in] pointer to graph argument value + +} ze_mutable_graph_argument_exp_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Returns a unique command identifier for the next command to be +/// appended to a command list. +/// +/// @details +/// - This function may only be called for a mutable command list. +/// - This function may not be called on a closed command list. +/// - This function may be called from simultaneous threads with the same +/// command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == desc` +/// + `nullptr == pCommandId` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0xff < desc->flags` +ZE_APIEXPORT ze_result_t ZE_APICALL +zeCommandListGetNextCommandIdExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_command_id_exp_desc_t* desc, ///< [in] pointer to mutable command identifier descriptor + uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Returns a unique command identifier for the next command to be +/// appended to a command list. Provides possible kernel handles for +/// kernel mutation when ::ZE_MUTABLE_COMMAND_EXP_FLAG_KERNEL_INSTRUCTION +/// flag is present. +/// +/// @details +/// - This function may only be called for a mutable command list. +/// - This function may not be called on a closed command list. +/// - This function may be called from simultaneous threads with the same +/// command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == desc` +/// + `nullptr == pCommandId` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0xff < desc->flags` +ZE_APIEXPORT ze_result_t ZE_APICALL +zeCommandListGetNextCommandIdWithKernelsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_command_id_exp_desc_t* desc, ///< [in][out] pointer to mutable command identifier descriptor + uint32_t numKernels, ///< [in][optional] number of entries on phKernels list + ze_kernel_handle_t* phKernels, ///< [in][optional][range(0, numKernels)] list of kernels that user can + ///< switch between using ::zeCommandListUpdateMutableCommandKernelsExp + ///< call + uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Updates mutable commands. +/// +/// @details +/// - This function may only be called for a mutable command list. +/// - The application must synchronize mutable command list execution before +/// calling this function. +/// - The application must close a mutable command list after completing all +/// updates. +/// - This function must not be called from simultaneous threads with the +/// same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == desc` +/// - ::ZE_RESULT_ERROR_INVALID_ARGUMENT +/// + Invalid kernel argument or not matching update descriptor provided +ZE_APIEXPORT ze_result_t ZE_APICALL +zeCommandListUpdateMutableCommandsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_commands_exp_desc_t* desc ///< [in] pointer to mutable commands descriptor; multiple descriptors may + ///< be chained via `pNext` member + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Updates the signal event for a mutable command in a mutable command +/// list. +/// +/// @details +/// - This function may only be called for a mutable command list. +/// - The type, scope and flags of the signal event must match those of the +/// source command. +/// - The application must synchronize mutable command list execution before +/// calling this function. +/// - The application must close a mutable command list after completing all +/// updates. +/// - This function must not be called from simultaneous threads with the +/// same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hCommandList` +ZE_APIEXPORT ze_result_t ZE_APICALL +zeCommandListUpdateMutableCommandSignalEventExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint64_t commandId, ///< [in] command identifier + ze_event_handle_t hSignalEvent ///< [in][optional] handle of the event to signal on completion + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Updates the wait events for a mutable command in a mutable command +/// list. +/// +/// @details +/// - This function may only be called for a mutable command list. +/// - The number of wait events must match that of the source command. +/// - The type, scope and flags of the wait events must match those of the +/// source command. +/// - Passing `nullptr` as the wait events will update the command to not +/// wait on any events prior to dispatch. +/// - Passing `nullptr` as an event on event wait list will remove event +/// dependency from this wait list slot. +/// - The application must synchronize mutable command list execution before +/// calling this function. +/// - The application must close a mutable command list after completing all +/// updates. +/// - This function must not be called from simultaneous threads with the +/// same command list handle. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + The `numWaitEvents` parameter does not match that of the original command. +ZE_APIEXPORT ze_result_t ZE_APICALL +zeCommandListUpdateMutableCommandWaitEventsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint64_t commandId, ///< [in] command identifier + uint32_t numWaitEvents, ///< [in][optional] the number of wait events + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Updates the kernel for a mutable command in a mutable command list. +/// +/// @details +/// - This function may only be called for a mutable command list. +/// - The kernel handle must be from the provided list for given command id. +/// - The application must synchronize mutable command list execution before +/// calling this function. +/// - The application must close a mutable command list after completing all +/// updates. +/// - This function must not be called from simultaneous threads with the +/// same command list handle. +/// - This function must be called before updating kernel arguments and +/// dispatch parameters, when kernel is mutated. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCommandId` +/// + `nullptr == phKernels` +/// - ::ZE_RESULT_ERROR_INVALID_KERNEL_HANDLE +/// + Invalid kernel handle provided for the mutation kernel instruction operation. +ZE_APIEXPORT ze_result_t ZE_APICALL +zeCommandListUpdateMutableCommandKernelsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint32_t numKernels, ///< [in] the number of kernels to update + uint64_t* pCommandId, ///< [in][range(0, numKernels)] command identifier + ze_kernel_handle_t* phKernels ///< [in][range(0, numKernels)] handle of the kernel for a command + ///< identifier to switch to + ); + +#if !defined(__GNUC__) +#pragma endregion +#endif +// Intel 'oneAPI' Level-Zero Extension for supporting relaxed allocation limits. +#if !defined(__GNUC__) +#pragma region relaxedAllocLimits +#endif +/////////////////////////////////////////////////////////////////////////////// +#ifndef ZE_RELAXED_ALLOCATION_LIMITS_EXP_NAME +/// @brief Relaxed Allocation Limits Extension Name +#define ZE_RELAXED_ALLOCATION_LIMITS_EXP_NAME "ZE_experimental_relaxed_allocation_limits" +#endif // ZE_RELAXED_ALLOCATION_LIMITS_EXP_NAME + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Relaxed Allocation Limits Extension Version(s) +typedef enum _ze_relaxed_allocation_limits_exp_version_t +{ + ZE_RELAXED_ALLOCATION_LIMITS_EXP_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 + ZE_RELAXED_ALLOCATION_LIMITS_EXP_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 0 ), ///< latest known version + ZE_RELAXED_ALLOCATION_LIMITS_EXP_VERSION_FORCE_UINT32 = 0x7fffffff + +} ze_relaxed_allocation_limits_exp_version_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Supported relaxed memory allocation flags +typedef uint32_t ze_relaxed_allocation_limits_exp_flags_t; +typedef enum _ze_relaxed_allocation_limits_exp_flag_t +{ + ZE_RELAXED_ALLOCATION_LIMITS_EXP_FLAG_MAX_SIZE = ZE_BIT(0), ///< Allocation size may exceed the `maxMemAllocSize` member of + ///< ::ze_device_properties_t. + ZE_RELAXED_ALLOCATION_LIMITS_EXP_FLAG_FORCE_UINT32 = 0x7fffffff + +} ze_relaxed_allocation_limits_exp_flag_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Relaxed limits memory allocation descriptor +/// +/// @details +/// - This structure may be passed to ::zeMemAllocShared or +/// ::zeMemAllocDevice, via the `pNext` member of +/// ::ze_device_mem_alloc_desc_t. +/// - This structure may also be passed to ::zeMemAllocHost, via the `pNext` +/// member of ::ze_host_mem_alloc_desc_t. +typedef struct _ze_relaxed_allocation_limits_exp_desc_t +{ + ze_structure_type_t stype; ///< [in] type of this structure + const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific + ///< structure (i.e. contains stype and pNext). + ze_relaxed_allocation_limits_exp_flags_t flags; ///< [in] flags specifying allocation limits to relax. + ///< must be 0 (default) or a valid combination of ::ze_relaxed_allocation_limits_exp_flag_t; + +} ze_relaxed_allocation_limits_exp_desc_t; + +#if !defined(__GNUC__) +#pragma endregion +#endif +// Intel 'oneAPI' Level-Zero Extension for retrieving kernel binary program data. +#if !defined(__GNUC__) +#pragma region kernelBinary +#endif +/////////////////////////////////////////////////////////////////////////////// +#ifndef ZE_GET_KERNEL_BINARY_EXP_NAME +/// @brief Get Kernel Binary Extension Name +#define ZE_GET_KERNEL_BINARY_EXP_NAME "ZE_extension_kernel_binary_exp" +#endif // ZE_GET_KERNEL_BINARY_EXP_NAME + +#if !defined(__GNUC__) +#pragma endregion +#endif +// Intel 'oneAPI' Level-Zero Extension APIs for Cache Reservation +#if !defined(__GNUC__) +#pragma region cacheReservation +#endif +/////////////////////////////////////////////////////////////////////////////// +#ifndef ZE_CACHE_RESERVATION_EXT_NAME +/// @brief Cache_Reservation Extension Name +#define ZE_CACHE_RESERVATION_EXT_NAME "ZE_extension_cache_reservation" +#endif // ZE_CACHE_RESERVATION_EXT_NAME + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Cache_Reservation Extension Version(s) +typedef enum _ze_cache_reservation_ext_version_t +{ + ZE_CACHE_RESERVATION_EXT_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 + ZE_CACHE_RESERVATION_EXT_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 0 ), ///< latest known version + ZE_CACHE_RESERVATION_EXT_VERSION_FORCE_UINT32 = 0x7fffffff + +} ze_cache_reservation_ext_version_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Cache Reservation Region +typedef enum _ze_cache_ext_region_t +{ + ZE_CACHE_EXT_REGION_ZE_CACHE_REGION_DEFAULT = 0, ///< [DEPRECATED] utilize driver default scheme. Use + ///< ::ZE_CACHE_EXT_REGION_DEFAULT. + ZE_CACHE_EXT_REGION_ZE_CACHE_RESERVE_REGION = 1, ///< [DEPRECATED] utilize reserved region. Use + ///< ::ZE_CACHE_EXT_REGION_RESERVED. + ZE_CACHE_EXT_REGION_ZE_CACHE_NON_RESERVED_REGION = 2, ///< [DEPRECATED] utilize non-reserverd region. Use + ///< ::ZE_CACHE_EXT_REGION_NON_RESERVED. + ZE_CACHE_EXT_REGION_DEFAULT = 0, ///< utilize driver default scheme + ZE_CACHE_EXT_REGION_RESERVED = 1, ///< utilize reserved region + ZE_CACHE_EXT_REGION_NON_RESERVED = 2, ///< utilize non-reserverd region + ZE_CACHE_EXT_REGION_FORCE_UINT32 = 0x7fffffff + +} ze_cache_ext_region_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief CacheReservation structure +/// +/// @details +/// - This structure must be passed to ::zeDeviceGetCacheProperties via the +/// `pNext` member of ::ze_device_cache_properties_t +/// - Used for determining the max cache reservation allowed on device. Size +/// of zero means no reservation available. +typedef struct _ze_cache_reservation_ext_desc_t +{ + ze_structure_type_t stype; ///< [in] type of this structure + const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific + ///< structure (i.e. contains stype and pNext). + size_t maxCacheReservationSize; ///< [out] max cache reservation size + +} ze_cache_reservation_ext_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Reserve Cache on Device +/// +/// @details +/// - The application may call this function but may not be successful as +/// some other application may have reserve prior +/// +/// @remarks +/// _Analogues_ +/// - None +/// +/// @returns /// - ::ZE_RESULT_SUCCESS /// - ::ZE_RESULT_ERROR_UNINITIALIZED /// - ::ZE_RESULT_ERROR_DEVICE_LOST @@ -10372,249 +10887,11 @@ zeRTASBuilderDestroyExp( /// @brief Creates a ray tracing acceleration structure builder parallel /// operation object /// -/// @details -/// - The application may call this function from simultaneous threads. -/// - The implementation of this function must be thread-safe. -/// - The implementation must support ::ZE_experimental_rtas_builder -/// extension. -/// -/// @returns -/// - ::ZE_RESULT_SUCCESS -/// - ::ZE_RESULT_ERROR_UNINITIALIZED -/// - ::ZE_RESULT_ERROR_DEVICE_LOST -/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY -/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY -/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `nullptr == hDriver` -/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER -/// + `nullptr == phParallelOperation` -ZE_APIEXPORT ze_result_t ZE_APICALL -zeRTASParallelOperationCreateExp( - ze_driver_handle_t hDriver, ///< [in] handle of driver object - ze_rtas_parallel_operation_exp_handle_t* phParallelOperation ///< [out] handle of parallel operation object - ); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Retrieves ray tracing acceleration structure builder parallel -/// operation properties -/// -/// @details -/// - The application must first bind the parallel operation object to a -/// build operation before it may query the parallel operation properties. -/// In other words, the application must first call -/// ::zeRTASBuilderBuildExp with **hParallelOperation** before calling -/// this function. -/// - The application may call this function from simultaneous threads. -/// - The implementation of this function must be thread-safe. -/// -/// @returns -/// - ::ZE_RESULT_SUCCESS -/// - ::ZE_RESULT_ERROR_UNINITIALIZED -/// - ::ZE_RESULT_ERROR_DEVICE_LOST -/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY -/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY -/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `nullptr == hParallelOperation` -/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER -/// + `nullptr == pProperties` -ZE_APIEXPORT ze_result_t ZE_APICALL -zeRTASParallelOperationGetPropertiesExp( - ze_rtas_parallel_operation_exp_handle_t hParallelOperation, ///< [in] handle of parallel operation object - ze_rtas_parallel_operation_exp_properties_t* pProperties ///< [in,out] query result for parallel operation properties - ); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Joins a parallel build operation -/// -/// @details -/// - All worker threads return the same error code for the parallel build -/// operation upon build completion -/// -/// @returns -/// - ::ZE_RESULT_SUCCESS -/// - ::ZE_RESULT_ERROR_UNINITIALIZED -/// - ::ZE_RESULT_ERROR_DEVICE_LOST -/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY -/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY -/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `nullptr == hParallelOperation` -ZE_APIEXPORT ze_result_t ZE_APICALL -zeRTASParallelOperationJoinExp( - ze_rtas_parallel_operation_exp_handle_t hParallelOperation ///< [in] handle of parallel operation object - ); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Destroys a ray tracing acceleration structure builder parallel -/// operation object -/// -/// @details -/// - The implementation of this function may immediately release any -/// internal Host and Device resources associated with this parallel -/// operation. -/// - The application must **not** call this function from simultaneous -/// threads with the same parallel operation handle. -/// - The implementation of this function must be thread-safe. -/// -/// @returns -/// - ::ZE_RESULT_SUCCESS -/// - ::ZE_RESULT_ERROR_UNINITIALIZED -/// - ::ZE_RESULT_ERROR_DEVICE_LOST -/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY -/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY -/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `nullptr == hParallelOperation` -ZE_APIEXPORT ze_result_t ZE_APICALL -zeRTASParallelOperationDestroyExp( - ze_rtas_parallel_operation_exp_handle_t hParallelOperation ///< [in][release] handle of parallel operation object to destroy - ); - -#if !defined(__GNUC__) -#pragma endregion -#endif -// Intel 'oneAPI' Level-Zero Extension APIs for Counter-based Event Pools -#if !defined(__GNUC__) -#pragma region counterbasedeventpool -#endif -/////////////////////////////////////////////////////////////////////////////// -#ifndef ZE_EVENT_POOL_COUNTER_BASED_EXP_NAME -/// @brief Counter-based Event Pools Extension Name -#define ZE_EVENT_POOL_COUNTER_BASED_EXP_NAME "ZE_experimental_event_pool_counter_based" -#endif // ZE_EVENT_POOL_COUNTER_BASED_EXP_NAME - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Counter-based Event Pools Extension Version(s) -typedef enum _ze_event_pool_counter_based_exp_version_t -{ - ZE_EVENT_POOL_COUNTER_BASED_EXP_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 - ZE_EVENT_POOL_COUNTER_BASED_EXP_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 0 ), ///< latest known version - ZE_EVENT_POOL_COUNTER_BASED_EXP_VERSION_FORCE_UINT32 = 0x7fffffff - -} ze_event_pool_counter_based_exp_version_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Supported event flags for defining counter-based event pools. -typedef uint32_t ze_event_pool_counter_based_exp_flags_t; -typedef enum _ze_event_pool_counter_based_exp_flag_t -{ - ZE_EVENT_POOL_COUNTER_BASED_EXP_FLAG_IMMEDIATE = ZE_BIT(0), ///< Counter-based event pool is used for immediate command lists (default) - ZE_EVENT_POOL_COUNTER_BASED_EXP_FLAG_NON_IMMEDIATE = ZE_BIT(1), ///< Counter-based event pool is for non-immediate command lists - ZE_EVENT_POOL_COUNTER_BASED_EXP_FLAG_FORCE_UINT32 = 0x7fffffff - -} ze_event_pool_counter_based_exp_flag_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Event pool descriptor for counter-based events. This structure may be -/// passed to ::zeEventPoolCreate as pNext member of -/// ::ze_event_pool_desc_t. -typedef struct _ze_event_pool_counter_based_exp_desc_t -{ - ze_structure_type_t stype; ///< [in] type of this structure - const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific - ///< structure (i.e. contains stype and pNext). - ze_event_pool_counter_based_exp_flags_t flags; ///< [in] mode flags. - ///< must be 0 (default) or a valid value of ::ze_event_pool_counter_based_exp_flag_t - ///< default behavior is counter-based event pool is only used for - ///< immediate command lists. - -} ze_event_pool_counter_based_exp_desc_t; - -#if !defined(__GNUC__) -#pragma endregion -#endif -// Intel 'oneAPI' Level-Zero Extension for supporting bindless images. -#if !defined(__GNUC__) -#pragma region bindlessimages -#endif -/////////////////////////////////////////////////////////////////////////////// -#ifndef ZE_BINDLESS_IMAGE_EXP_NAME -/// @brief Image Memory Properties Extension Name -#define ZE_BINDLESS_IMAGE_EXP_NAME "ZE_experimental_bindless_image" -#endif // ZE_BINDLESS_IMAGE_EXP_NAME - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Bindless Image Extension Version(s) -typedef enum _ze_bindless_image_exp_version_t -{ - ZE_BINDLESS_IMAGE_EXP_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 - ZE_BINDLESS_IMAGE_EXP_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 0 ), ///< latest known version - ZE_BINDLESS_IMAGE_EXP_VERSION_FORCE_UINT32 = 0x7fffffff - -} ze_bindless_image_exp_version_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Image flags for Bindless images -typedef uint32_t ze_image_bindless_exp_flags_t; -typedef enum _ze_image_bindless_exp_flag_t -{ - ZE_IMAGE_BINDLESS_EXP_FLAG_BINDLESS = ZE_BIT(0), ///< Bindless images are created with ::zeImageCreate. The image handle - ///< created with this flag is valid on both host and device. - ZE_IMAGE_BINDLESS_EXP_FLAG_SAMPLED_IMAGE = ZE_BIT(1), ///< Bindless sampled images are created with ::zeImageCreate by combining - ///< BINDLESS and SAMPLED_IMAGE. - ///< Create sampled image view from bindless unsampled image using SAMPLED_IMAGE. - ZE_IMAGE_BINDLESS_EXP_FLAG_FORCE_UINT32 = 0x7fffffff - -} ze_image_bindless_exp_flag_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Image descriptor for bindless images. This structure may be passed to -/// ::zeImageCreate via pNext member of ::ze_image_desc_t. -typedef struct _ze_image_bindless_exp_desc_t -{ - ze_structure_type_t stype; ///< [in] type of this structure - const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific - ///< structure (i.e. contains stype and pNext). - ze_image_bindless_exp_flags_t flags; ///< [in] image flags. - ///< must be 0 (default) or a valid value of ::ze_image_bindless_exp_flag_t - ///< default behavior is bindless images are not used when creating handles - ///< via ::zeImageCreate. - ///< When the flag is passed to ::zeImageCreate, then only the memory for - ///< the image is allocated. - ///< Additional image handles can be created with ::zeImageViewCreateExt. - ///< When ::ZE_IMAGE_BINDLESS_EXP_FLAG_SAMPLED_IMAGE flag is passed, - ///< ::ze_sampler_desc_t must be attached via pNext member of ::ze_image_bindless_exp_desc_t. - -} ze_image_bindless_exp_desc_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Image descriptor for bindless images created from pitched allocations. -/// This structure may be passed to ::zeImageCreate via pNext member of -/// ::ze_image_desc_t. -typedef struct _ze_image_pitched_exp_desc_t -{ - ze_structure_type_t stype; ///< [in] type of this structure - const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific - ///< structure (i.e. contains stype and pNext). - void* ptr; ///< [in] pointer to pitched device allocation allocated using ::zeMemAllocDevice - -} ze_image_pitched_exp_desc_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Device specific properties for pitched allocations -/// -/// @details -/// - This structure may be passed to ::zeDeviceGetImageProperties via the -/// pNext member of ::ze_device_image_properties_t. -typedef struct _ze_device_pitched_alloc_exp_properties_t -{ - ze_structure_type_t stype; ///< [in] type of this structure - void* pNext; ///< [in,out][optional] must be null or a pointer to an extension-specific - ///< structure (i.e. contains stype and pNext). - size_t maxImageLinearWidth; ///< [out] Maximum image linear width. - size_t maxImageLinearHeight; ///< [out] Maximum image linear height. - -} ze_device_pitched_alloc_exp_properties_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Allocate pitched USM memory for images -/// -/// @details -/// - Retrieves pitch for 2D image given the width, height and size in bytes -/// - The memory is then allocated using ::zeMemAllocDevice by providing -/// input size calculated as the returned pitch value multiplied by image height -/// - The application may call this function from simultaneous threads +/// @details +/// - The application may call this function from simultaneous threads. /// - The implementation of this function must be thread-safe. -/// - The implementation of this function should be lock-free. -/// - The implementation must support ::ZE_experimental_bindless_image extension. +/// - The implementation must support ::ZE_experimental_rtas_builder +/// extension. /// /// @returns /// - ::ZE_RESULT_SUCCESS @@ -10623,27 +10900,27 @@ typedef struct _ze_device_pitched_alloc_exp_properties_t /// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY /// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `nullptr == hContext` -/// + `nullptr == hDevice` +/// + `nullptr == hDriver` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == phParallelOperation` ZE_APIEXPORT ze_result_t ZE_APICALL -zeMemGetPitchFor2dImage( - ze_context_handle_t hContext, ///< [in] handle of the context object - ze_device_handle_t hDevice, ///< [in] handle of the device - size_t imageWidth, ///< [in] imageWidth - size_t imageHeight, ///< [in] imageHeight - unsigned int elementSizeInBytes, ///< [in] Element size in bytes - size_t * rowPitch ///< [out] rowPitch +zeRTASParallelOperationCreateExp( + ze_driver_handle_t hDriver, ///< [in] handle of driver object + ze_rtas_parallel_operation_exp_handle_t* phParallelOperation ///< [out] handle of parallel operation object ); /////////////////////////////////////////////////////////////////////////////// -/// @brief Get bindless device offset for image +/// @brief Retrieves ray tracing acceleration structure builder parallel +/// operation properties /// /// @details -/// - The application may call this function from simultaneous threads +/// - The application must first bind the parallel operation object to a +/// build operation before it may query the parallel operation properties. +/// In other words, the application must first call +/// ::zeRTASBuilderBuildExp with **hParallelOperation** before calling +/// this function. +/// - The application may call this function from simultaneous threads. /// - The implementation of this function must be thread-safe. -/// - The implementation of this function should be lock-free. -/// - The implementation must support ::ZE_experimental_bindless_image -/// extension. /// /// @returns /// - ::ZE_RESULT_SUCCESS @@ -10652,55 +10929,21 @@ zeMemGetPitchFor2dImage( /// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY /// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `nullptr == hImage` +/// + `nullptr == hParallelOperation` /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER -/// + `nullptr == pDeviceOffset` +/// + `nullptr == pProperties` ZE_APIEXPORT ze_result_t ZE_APICALL -zeImageGetDeviceOffsetExp( - ze_image_handle_t hImage, ///< [in] handle of the image - uint64_t* pDeviceOffset ///< [out] bindless device offset for image +zeRTASParallelOperationGetPropertiesExp( + ze_rtas_parallel_operation_exp_handle_t hParallelOperation, ///< [in] handle of parallel operation object + ze_rtas_parallel_operation_exp_properties_t* pProperties ///< [in,out] query result for parallel operation properties ); -#if !defined(__GNUC__) -#pragma endregion -#endif -// Intel 'oneAPI' Level-Zero Extension for supporting compute graphs. -#if !defined(__GNUC__) -#pragma region commandListClone -#endif -/////////////////////////////////////////////////////////////////////////////// -#ifndef ZE_COMMAND_LIST_CLONE_EXP_NAME -/// @brief Command List Clone Extension Name -#define ZE_COMMAND_LIST_CLONE_EXP_NAME "ZE_experimental_command_list_clone" -#endif // ZE_COMMAND_LIST_CLONE_EXP_NAME - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Command List Clone Extension Version(s) -typedef enum _ze_command_list_clone_exp_version_t -{ - ZE_COMMAND_LIST_CLONE_EXP_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 - ZE_COMMAND_LIST_CLONE_EXP_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 0 ), ///< latest known version - ZE_COMMAND_LIST_CLONE_EXP_VERSION_FORCE_UINT32 = 0x7fffffff - -} ze_command_list_clone_exp_version_t; - /////////////////////////////////////////////////////////////////////////////// -/// @brief Creates a command list as the clone of another command list. +/// @brief Joins a parallel build operation /// /// @details -/// - The source command list must be created with the -/// ::ZE_COMMAND_LIST_FLAG_EXP_CLONEABLE flag. -/// - The source command list must be closed prior to cloning. -/// - The source command list may be cloned while it is running on the -/// device. -/// - The cloned command list inherits all properties of the source command -/// list. -/// - The cloned command list must be destroyed prior to the source command -/// list. -/// - The application must only use the command list for the device, or its -/// sub-devices, which was provided during creation. -/// - The application may call this function from simultaneous threads. -/// - The implementation of this function must be thread-safe. +/// - All worker threads return the same error code for the parallel build +/// operation upon build completion /// /// @returns /// - ::ZE_RESULT_SUCCESS @@ -10709,49 +10952,23 @@ typedef enum _ze_command_list_clone_exp_version_t /// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY /// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `nullptr == hCommandList` -/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER -/// + `nullptr == phClonedCommandList` +/// + `nullptr == hParallelOperation` ZE_APIEXPORT ze_result_t ZE_APICALL -zeCommandListCreateCloneExp( - ze_command_list_handle_t hCommandList, ///< [in] handle to source command list (the command list to clone) - ze_command_list_handle_t* phClonedCommandList ///< [out] pointer to handle of the cloned command list +zeRTASParallelOperationJoinExp( + ze_rtas_parallel_operation_exp_handle_t hParallelOperation ///< [in] handle of parallel operation object ); -#if !defined(__GNUC__) -#pragma endregion -#endif -// Intel 'oneAPI' Level-Zero Extension for supporting compute graphs. -#if !defined(__GNUC__) -#pragma region immediateCommandListAppend -#endif -/////////////////////////////////////////////////////////////////////////////// -#ifndef ZE_IMMEDIATE_COMMAND_LIST_APPEND_EXP_NAME -/// @brief Immediate Command List Append Extension Name -#define ZE_IMMEDIATE_COMMAND_LIST_APPEND_EXP_NAME "ZE_experimental_immediate_command_list_append" -#endif // ZE_IMMEDIATE_COMMAND_LIST_APPEND_EXP_NAME - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Immediate Command List Append Extension Version(s) -typedef enum _ze_immediate_command_list_append_exp_version_t -{ - ZE_IMMEDIATE_COMMAND_LIST_APPEND_EXP_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 - ZE_IMMEDIATE_COMMAND_LIST_APPEND_EXP_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 0 ), ///< latest known version - ZE_IMMEDIATE_COMMAND_LIST_APPEND_EXP_VERSION_FORCE_UINT32 = 0x7fffffff - -} ze_immediate_command_list_append_exp_version_t; - /////////////////////////////////////////////////////////////////////////////// -/// @brief Appends command lists to dispatch from an immediate command list. +/// @brief Destroys a ray tracing acceleration structure builder parallel +/// operation object /// /// @details -/// - The application must call this function only with command lists -/// created with ::zeCommandListCreateImmediate. -/// - The command lists passed to this function in the `phCommandLists` -/// argument must be regular command lists (i.e. not immediate command -/// lists). -/// - The application may call this function from simultaneous threads. -/// - The implementation of this function should be lock-free. +/// - The implementation of this function may immediately release any +/// internal Host and Device resources associated with this parallel +/// operation. +/// - The application must **not** call this function from simultaneous +/// threads with the same parallel operation handle. +/// - The implementation of this function must be thread-safe. /// /// @returns /// - ::ZE_RESULT_SUCCESS @@ -10760,185 +10977,159 @@ typedef enum _ze_immediate_command_list_append_exp_version_t /// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY /// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `nullptr == hCommandListImmediate` -/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER -/// + `nullptr == phCommandLists` +/// + `nullptr == hParallelOperation` ZE_APIEXPORT ze_result_t ZE_APICALL -zeCommandListImmediateAppendCommandListsExp( - ze_command_list_handle_t hCommandListImmediate, ///< [in] handle of the immediate command list - uint32_t numCommandLists, ///< [in] number of command lists - ze_command_list_handle_t* phCommandLists, ///< [in][range(0, numCommandLists)] handles of command lists - ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion - ///< - if not null, this event is signaled after the completion of all - ///< appended command lists - uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before executing appended - ///< command lists; must be 0 if nullptr == phWaitEvents - ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait - ///< on before executing appended command lists. - ///< - if not null, all wait events must be satisfied prior to the start - ///< of any appended command list(s) +zeRTASParallelOperationDestroyExp( + ze_rtas_parallel_operation_exp_handle_t hParallelOperation ///< [in][release] handle of parallel operation object to destroy ); #if !defined(__GNUC__) #pragma endregion #endif -// Intel 'oneAPI' Level-Zero Extension for supporting compute graphs with dynamic properties. +// Intel 'oneAPI' Level-Zero Extension APIs for Counter-based Event Pools #if !defined(__GNUC__) -#pragma region mutableCommandList +#pragma region counterbasedeventpool #endif /////////////////////////////////////////////////////////////////////////////// -#ifndef ZE_MUTABLE_COMMAND_LIST_EXP_NAME -/// @brief Mutable Command List Extension Name -#define ZE_MUTABLE_COMMAND_LIST_EXP_NAME "ZE_experimental_mutable_command_list" -#endif // ZE_MUTABLE_COMMAND_LIST_EXP_NAME +#ifndef ZE_EVENT_POOL_COUNTER_BASED_EXP_NAME +/// @brief Counter-based Event Pools Extension Name +#define ZE_EVENT_POOL_COUNTER_BASED_EXP_NAME "ZE_experimental_event_pool_counter_based" +#endif // ZE_EVENT_POOL_COUNTER_BASED_EXP_NAME /////////////////////////////////////////////////////////////////////////////// -/// @brief Mutable Command List Extension Version(s) -typedef enum _ze_mutable_command_list_exp_version_t +/// @brief Counter-based Event Pools Extension Version(s) +typedef enum _ze_event_pool_counter_based_exp_version_t { - ZE_MUTABLE_COMMAND_LIST_EXP_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 - ZE_MUTABLE_COMMAND_LIST_EXP_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 0 ), ///< latest known version - ZE_MUTABLE_COMMAND_LIST_EXP_VERSION_FORCE_UINT32 = 0x7fffffff + ZE_EVENT_POOL_COUNTER_BASED_EXP_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 + ZE_EVENT_POOL_COUNTER_BASED_EXP_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 0 ), ///< latest known version + ZE_EVENT_POOL_COUNTER_BASED_EXP_VERSION_FORCE_UINT32 = 0x7fffffff -} ze_mutable_command_list_exp_version_t; +} ze_event_pool_counter_based_exp_version_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Mutable command flags -typedef uint32_t ze_mutable_command_exp_flags_t; -typedef enum _ze_mutable_command_exp_flag_t +/// @brief Supported event flags for defining counter-based event pools. +typedef uint32_t ze_event_pool_counter_based_exp_flags_t; +typedef enum _ze_event_pool_counter_based_exp_flag_t { - ZE_MUTABLE_COMMAND_EXP_FLAG_KERNEL_ARGUMENTS = ZE_BIT(0), ///< kernel arguments - ZE_MUTABLE_COMMAND_EXP_FLAG_GROUP_COUNT = ZE_BIT(1), ///< kernel group count - ZE_MUTABLE_COMMAND_EXP_FLAG_GROUP_SIZE = ZE_BIT(2), ///< kernel group size - ZE_MUTABLE_COMMAND_EXP_FLAG_GLOBAL_OFFSET = ZE_BIT(3), ///< kernel global offset - ZE_MUTABLE_COMMAND_EXP_FLAG_SIGNAL_EVENT = ZE_BIT(4), ///< command signal event - ZE_MUTABLE_COMMAND_EXP_FLAG_WAIT_EVENTS = ZE_BIT(5), ///< command wait events - ZE_MUTABLE_COMMAND_EXP_FLAG_FORCE_UINT32 = 0x7fffffff + ZE_EVENT_POOL_COUNTER_BASED_EXP_FLAG_IMMEDIATE = ZE_BIT(0), ///< Counter-based event pool is used for immediate command lists (default) + ZE_EVENT_POOL_COUNTER_BASED_EXP_FLAG_NON_IMMEDIATE = ZE_BIT(1), ///< Counter-based event pool is for non-immediate command lists + ZE_EVENT_POOL_COUNTER_BASED_EXP_FLAG_FORCE_UINT32 = 0x7fffffff -} ze_mutable_command_exp_flag_t; +} ze_event_pool_counter_based_exp_flag_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Mutable command identifier descriptor -typedef struct _ze_mutable_command_id_exp_desc_t +/// @brief Event pool descriptor for counter-based events. This structure may be +/// passed to ::zeEventPoolCreate as pNext member of +/// ::ze_event_pool_desc_t. +typedef struct _ze_event_pool_counter_based_exp_desc_t { ze_structure_type_t stype; ///< [in] type of this structure const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific ///< structure (i.e. contains stype and pNext). - ze_mutable_command_exp_flags_t flags; ///< [in] mutable command flags. - ///< - must be 0 (default, equivalent to setting all flags), or a valid - ///< combination of ::ze_mutable_command_exp_flag_t - -} ze_mutable_command_id_exp_desc_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Mutable command list flags -typedef uint32_t ze_mutable_command_list_exp_flags_t; -typedef enum _ze_mutable_command_list_exp_flag_t -{ - ZE_MUTABLE_COMMAND_LIST_EXP_FLAG_RESERVED = ZE_BIT(0), ///< reserved - ZE_MUTABLE_COMMAND_LIST_EXP_FLAG_FORCE_UINT32 = 0x7fffffff - -} ze_mutable_command_list_exp_flag_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Mutable command list properties -typedef struct _ze_mutable_command_list_exp_properties_t -{ - ze_structure_type_t stype; ///< [in] type of this structure - void* pNext; ///< [in,out][optional] must be null or a pointer to an extension-specific - ///< structure (i.e. contains stype and pNext). - ze_mutable_command_list_exp_flags_t mutableCommandListFlags; ///< [out] mutable command list flags - ze_mutable_command_exp_flags_t mutableCommandFlags; ///< [out] mutable command flags + ze_event_pool_counter_based_exp_flags_t flags; ///< [in] mode flags. + ///< must be 0 (default) or a valid value of ::ze_event_pool_counter_based_exp_flag_t + ///< default behavior is counter-based event pool is only used for + ///< immediate command lists. -} ze_mutable_command_list_exp_properties_t; +} ze_event_pool_counter_based_exp_desc_t; +#if !defined(__GNUC__) +#pragma endregion +#endif +// Intel 'oneAPI' Level-Zero Extension for supporting bindless images. +#if !defined(__GNUC__) +#pragma region bindlessimages +#endif /////////////////////////////////////////////////////////////////////////////// -/// @brief Mutable command list descriptor -typedef struct _ze_mutable_command_list_exp_desc_t -{ - ze_structure_type_t stype; ///< [in] type of this structure - const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific - ///< structure (i.e. contains stype and pNext). - ze_mutable_command_list_exp_flags_t flags; ///< [in] mutable command list flags. - ///< - must be 0 (default) or a valid combination of ::ze_mutable_command_list_exp_flag_t - -} ze_mutable_command_list_exp_desc_t; +#ifndef ZE_BINDLESS_IMAGE_EXP_NAME +/// @brief Image Memory Properties Extension Name +#define ZE_BINDLESS_IMAGE_EXP_NAME "ZE_experimental_bindless_image" +#endif // ZE_BINDLESS_IMAGE_EXP_NAME /////////////////////////////////////////////////////////////////////////////// -/// @brief Mutable commands descriptor -typedef struct _ze_mutable_commands_exp_desc_t +/// @brief Bindless Image Extension Version(s) +typedef enum _ze_bindless_image_exp_version_t { - ze_structure_type_t stype; ///< [in] type of this structure - const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific - ///< structure (i.e. contains stype and pNext). - uint32_t flags; ///< [in] must be 0, this field is reserved for future use + ZE_BINDLESS_IMAGE_EXP_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 + ZE_BINDLESS_IMAGE_EXP_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 0 ), ///< latest known version + ZE_BINDLESS_IMAGE_EXP_VERSION_FORCE_UINT32 = 0x7fffffff -} ze_mutable_commands_exp_desc_t; +} ze_bindless_image_exp_version_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Mutable kernel argument descriptor -typedef struct _ze_mutable_kernel_argument_exp_desc_t +/// @brief Image flags for Bindless images +typedef uint32_t ze_image_bindless_exp_flags_t; +typedef enum _ze_image_bindless_exp_flag_t { - ze_structure_type_t stype; ///< [in] type of this structure - const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific - ///< structure (i.e. contains stype and pNext). - uint64_t commandId; ///< [in] command identifier - uint32_t argIndex; ///< [in] kernel argument index - size_t argSize; ///< [in] kernel argument size - const void* pArgValue; ///< [in] pointer to kernel argument value + ZE_IMAGE_BINDLESS_EXP_FLAG_BINDLESS = ZE_BIT(0), ///< Bindless images are created with ::zeImageCreate. The image handle + ///< created with this flag is valid on both host and device. + ZE_IMAGE_BINDLESS_EXP_FLAG_SAMPLED_IMAGE = ZE_BIT(1), ///< Bindless sampled images are created with ::zeImageCreate by combining + ///< BINDLESS and SAMPLED_IMAGE. + ///< Create sampled image view from bindless unsampled image using SAMPLED_IMAGE. + ZE_IMAGE_BINDLESS_EXP_FLAG_FORCE_UINT32 = 0x7fffffff -} ze_mutable_kernel_argument_exp_desc_t; +} ze_image_bindless_exp_flag_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Mutable kernel group count descriptor -typedef struct _ze_mutable_group_count_exp_desc_t +/// @brief Image descriptor for bindless images. This structure may be passed to +/// ::zeImageCreate via pNext member of ::ze_image_desc_t. +typedef struct _ze_image_bindless_exp_desc_t { ze_structure_type_t stype; ///< [in] type of this structure const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific ///< structure (i.e. contains stype and pNext). - uint64_t commandId; ///< [in] command identifier - const ze_group_count_t* pGroupCount; ///< [in] pointer to group count + ze_image_bindless_exp_flags_t flags; ///< [in] image flags. + ///< must be 0 (default) or a valid value of ::ze_image_bindless_exp_flag_t + ///< default behavior is bindless images are not used when creating handles + ///< via ::zeImageCreate. + ///< When the flag is passed to ::zeImageCreate, then only the memory for + ///< the image is allocated. + ///< Additional image handles can be created with ::zeImageViewCreateExt. + ///< When ::ZE_IMAGE_BINDLESS_EXP_FLAG_SAMPLED_IMAGE flag is passed, + ///< ::ze_sampler_desc_t must be attached via pNext member of ::ze_image_bindless_exp_desc_t. -} ze_mutable_group_count_exp_desc_t; +} ze_image_bindless_exp_desc_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Mutable kernel group size descriptor -typedef struct _ze_mutable_group_size_exp_desc_t +/// @brief Image descriptor for bindless images created from pitched allocations. +/// This structure may be passed to ::zeImageCreate via pNext member of +/// ::ze_image_desc_t. +typedef struct _ze_image_pitched_exp_desc_t { ze_structure_type_t stype; ///< [in] type of this structure const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific ///< structure (i.e. contains stype and pNext). - uint64_t commandId; ///< [in] command identifier - uint32_t groupSizeX; ///< [in] group size for X dimension to use for the kernel - uint32_t groupSizeY; ///< [in] group size for Y dimension to use for the kernel - uint32_t groupSizeZ; ///< [in] group size for Z dimension to use for the kernel + void* ptr; ///< [in] pointer to pitched device allocation allocated using ::zeMemAllocDevice -} ze_mutable_group_size_exp_desc_t; +} ze_image_pitched_exp_desc_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Mutable kernel global offset descriptor -typedef struct _ze_mutable_global_offset_exp_desc_t +/// @brief Device specific properties for pitched allocations +/// +/// @details +/// - This structure may be passed to ::zeDeviceGetImageProperties via the +/// pNext member of ::ze_device_image_properties_t. +typedef struct _ze_device_pitched_alloc_exp_properties_t { ze_structure_type_t stype; ///< [in] type of this structure - const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific + void* pNext; ///< [in,out][optional] must be null or a pointer to an extension-specific ///< structure (i.e. contains stype and pNext). - uint64_t commandId; ///< [in] command identifier - uint32_t offsetX; ///< [in] global offset for X dimension to use for this kernel - uint32_t offsetY; ///< [in] global offset for Y dimension to use for this kernel - uint32_t offsetZ; ///< [in] global offset for Z dimension to use for this kernel + size_t maxImageLinearWidth; ///< [out] Maximum image linear width. + size_t maxImageLinearHeight; ///< [out] Maximum image linear height. -} ze_mutable_global_offset_exp_desc_t; +} ze_device_pitched_alloc_exp_properties_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Returns a unique command identifier for the next command to be -/// appended to a command list. +/// @brief Allocate pitched USM memory for images /// /// @details -/// - This function may only be called for a mutable command list. -/// - This function may not be called on a closed command list. -/// - This function may be called from simultaneous threads with the same -/// command list handle. +/// - Retrieves pitch for 2D image given the width, height and size in bytes +/// - The memory is then allocated using ::zeMemAllocDevice by providing +/// input size calculated as the returned pitch value multiplied by image height +/// - The application may call this function from simultaneous threads +/// - The implementation of this function must be thread-safe. /// - The implementation of this function should be lock-free. +/// - The implementation must support ::ZE_experimental_bindless_image extension. /// /// @returns /// - ::ZE_RESULT_SUCCESS @@ -10947,31 +11138,27 @@ typedef struct _ze_mutable_global_offset_exp_desc_t /// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY /// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `nullptr == hCommandList` -/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER -/// + `nullptr == desc` -/// + `nullptr == pCommandId` -/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION -/// + `0x3f < desc->flags` +/// + `nullptr == hContext` +/// + `nullptr == hDevice` ZE_APIEXPORT ze_result_t ZE_APICALL -zeCommandListGetNextCommandIdExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - const ze_mutable_command_id_exp_desc_t* desc, ///< [in] pointer to mutable command identifier descriptor - uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written +zeMemGetPitchFor2dImage( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_device_handle_t hDevice, ///< [in] handle of the device + size_t imageWidth, ///< [in] imageWidth + size_t imageHeight, ///< [in] imageHeight + unsigned int elementSizeInBytes, ///< [in] Element size in bytes + size_t * rowPitch ///< [out] rowPitch ); /////////////////////////////////////////////////////////////////////////////// -/// @brief Updates mutable commands. +/// @brief Get bindless device offset for image /// /// @details -/// - This function may only be called for a mutable command list. -/// - The application must synchronize mutable command list execution before -/// calling this function. -/// - The application must close a mutable command list after completing all -/// updates. -/// - This function must not be called from simultaneous threads with the -/// same command list handle. +/// - The application may call this function from simultaneous threads +/// - The implementation of this function must be thread-safe. /// - The implementation of this function should be lock-free. +/// - The implementation must support ::ZE_experimental_bindless_image +/// extension. /// /// @returns /// - ::ZE_RESULT_SUCCESS @@ -10980,33 +11167,55 @@ zeCommandListGetNextCommandIdExp( /// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY /// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `nullptr == hCommandList` +/// + `nullptr == hImage` /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER -/// + `nullptr == desc` +/// + `nullptr == pDeviceOffset` ZE_APIEXPORT ze_result_t ZE_APICALL -zeCommandListUpdateMutableCommandsExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - const ze_mutable_commands_exp_desc_t* desc ///< [in] pointer to mutable commands descriptor; multiple descriptors may - ///< be chained via `pNext` member +zeImageGetDeviceOffsetExp( + ze_image_handle_t hImage, ///< [in] handle of the image + uint64_t* pDeviceOffset ///< [out] bindless device offset for image ); +#if !defined(__GNUC__) +#pragma endregion +#endif +// Intel 'oneAPI' Level-Zero Extension for supporting compute graphs. +#if !defined(__GNUC__) +#pragma region commandListClone +#endif +/////////////////////////////////////////////////////////////////////////////// +#ifndef ZE_COMMAND_LIST_CLONE_EXP_NAME +/// @brief Command List Clone Extension Name +#define ZE_COMMAND_LIST_CLONE_EXP_NAME "ZE_experimental_command_list_clone" +#endif // ZE_COMMAND_LIST_CLONE_EXP_NAME + /////////////////////////////////////////////////////////////////////////////// -/// @brief Updates the signal event for a mutable command in a mutable command -/// list. +/// @brief Command List Clone Extension Version(s) +typedef enum _ze_command_list_clone_exp_version_t +{ + ZE_COMMAND_LIST_CLONE_EXP_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 + ZE_COMMAND_LIST_CLONE_EXP_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 0 ), ///< latest known version + ZE_COMMAND_LIST_CLONE_EXP_VERSION_FORCE_UINT32 = 0x7fffffff + +} ze_command_list_clone_exp_version_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Creates a command list as the clone of another command list. /// /// @details -/// - This function may only be called for a mutable command list. -/// - The type, scope and flags of the signal event must match those of the -/// source command. -/// - Passing a null pointer as the signal event will update the command to -/// not issue a signal. -/// - The application must synchronize mutable command list execution before -/// calling this function. -/// - The application must close a mutable command list after completing all -/// updates. -/// - This function must not be called from simultaneous threads with the -/// same command list handle. -/// - The implementation of this function should be lock-free. +/// - The source command list must be created with the +/// ::ZE_COMMAND_LIST_FLAG_EXP_CLONEABLE flag. +/// - The source command list must be closed prior to cloning. +/// - The source command list may be cloned while it is running on the +/// device. +/// - The cloned command list inherits all properties of the source command +/// list. +/// - The cloned command list must be destroyed prior to the source command +/// list. +/// - The application must only use the command list for the device, or its +/// sub-devices, which was provided during creation. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. /// /// @returns /// - ::ZE_RESULT_SUCCESS @@ -11016,32 +11225,47 @@ zeCommandListUpdateMutableCommandsExp( /// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY /// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE /// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == phClonedCommandList` ZE_APIEXPORT ze_result_t ZE_APICALL -zeCommandListUpdateMutableCommandSignalEventExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - uint64_t commandId, ///< [in] command identifier - ze_event_handle_t hSignalEvent ///< [in][optional] handle of the event to signal on completion +zeCommandListCreateCloneExp( + ze_command_list_handle_t hCommandList, ///< [in] handle to source command list (the command list to clone) + ze_command_list_handle_t* phClonedCommandList ///< [out] pointer to handle of the cloned command list ); +#if !defined(__GNUC__) +#pragma endregion +#endif +// Intel 'oneAPI' Level-Zero Extension for supporting compute graphs. +#if !defined(__GNUC__) +#pragma region immediateCommandListAppend +#endif +/////////////////////////////////////////////////////////////////////////////// +#ifndef ZE_IMMEDIATE_COMMAND_LIST_APPEND_EXP_NAME +/// @brief Immediate Command List Append Extension Name +#define ZE_IMMEDIATE_COMMAND_LIST_APPEND_EXP_NAME "ZE_experimental_immediate_command_list_append" +#endif // ZE_IMMEDIATE_COMMAND_LIST_APPEND_EXP_NAME + /////////////////////////////////////////////////////////////////////////////// -/// @brief Updates the wait events for a mutable command in a mutable command -/// list. +/// @brief Immediate Command List Append Extension Version(s) +typedef enum _ze_immediate_command_list_append_exp_version_t +{ + ZE_IMMEDIATE_COMMAND_LIST_APPEND_EXP_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 + ZE_IMMEDIATE_COMMAND_LIST_APPEND_EXP_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 0 ), ///< latest known version + ZE_IMMEDIATE_COMMAND_LIST_APPEND_EXP_VERSION_FORCE_UINT32 = 0x7fffffff + +} ze_immediate_command_list_append_exp_version_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Appends command lists to dispatch from an immediate command list. /// /// @details -/// - This function may only be called for a mutable command list. -/// - The number of wait events must match that of the source command. -/// - The type, scope and flags of the wait events must match those of the -/// source command. -/// - Passing `nullptr` as the wait events will update the command to not -/// wait on any events prior to dispatch. -/// - Passing `nullptr` as an event on event wait list will remove event -/// dependency from this wait list slot. -/// - The application must synchronize mutable command list execution before -/// calling this function. -/// - The application must close a mutable command list after completing all -/// updates. -/// - This function must not be called from simultaneous threads with the -/// same command list handle. +/// - The application must call this function only with command lists +/// created with ::zeCommandListCreateImmediate. +/// - The command lists passed to this function in the `phCommandLists` +/// argument must be regular command lists (i.e. not immediate command +/// lists). +/// - The application may call this function from simultaneous threads. /// - The implementation of this function should be lock-free. /// /// @returns @@ -11051,16 +11275,23 @@ zeCommandListUpdateMutableCommandSignalEventExp( /// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY /// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `nullptr == hCommandList` -/// - ::ZE_RESULT_ERROR_INVALID_SIZE -/// + The `numWaitEvents` parameter does not match that of the original command. +/// + `nullptr == hCommandListImmediate` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == phCommandLists` ZE_APIEXPORT ze_result_t ZE_APICALL -zeCommandListUpdateMutableCommandWaitEventsExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - uint64_t commandId, ///< [in] command identifier - uint32_t numWaitEvents, ///< [in][optional] the number of wait events +zeCommandListImmediateAppendCommandListsExp( + ze_command_list_handle_t hCommandListImmediate, ///< [in] handle of the immediate command list + uint32_t numCommandLists, ///< [in] number of command lists + ze_command_list_handle_t* phCommandLists, ///< [in][range(0, numCommandLists)] handles of command lists + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + ///< - if not null, this event is signaled after the completion of all + ///< appended command lists + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before executing appended + ///< command lists; must be 0 if nullptr == phWaitEvents ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait - ///< on before launching + ///< on before executing appended command lists. + ///< - if not null, all wait events must be satisfied prior to the start + ///< of any appended command list(s) ); #if !defined(__GNUC__) diff --git a/include/ze_ddi.h b/include/ze_ddi.h index 952cdb03..f24ac326 100644 --- a/include/ze_ddi.h +++ b/include/ze_ddi.h @@ -5,7 +5,7 @@ * SPDX-License-Identifier: MIT * * @file ze_ddi.h - * @version v1.9-r1.9.3 + * @version v1.11-r1.11.0 * */ #ifndef _ZE_DDI_H @@ -152,11 +152,20 @@ typedef ze_result_t (ZE_APICALL *ze_pfnInit_t)( ze_init_flags_t ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zeInitDrivers +typedef ze_result_t (ZE_APICALL *ze_pfnInitDrivers_t)( + uint32_t*, + ze_driver_handle_t*, + ze_init_driver_type_desc_t* + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Table of Global functions pointers typedef struct _ze_global_dditable_t { ze_pfnInit_t pfnInit; + ze_pfnInitDrivers_t pfnInitDrivers; } ze_global_dditable_t; /////////////////////////////////////////////////////////////////////////////// @@ -1119,28 +1128,12 @@ typedef ze_result_t (ZE_APICALL *ze_pfnGetCommandListProcAddrTable_t)( ); /////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for zeCommandListCreateCloneExp -typedef ze_result_t (ZE_APICALL *ze_pfnCommandListCreateCloneExp_t)( - ze_command_list_handle_t, - ze_command_list_handle_t* - ); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for zeCommandListImmediateAppendCommandListsExp -typedef ze_result_t (ZE_APICALL *ze_pfnCommandListImmediateAppendCommandListsExp_t)( - ze_command_list_handle_t, - uint32_t, - ze_command_list_handle_t*, - ze_event_handle_t, - uint32_t, - ze_event_handle_t* - ); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for zeCommandListGetNextCommandIdExp -typedef ze_result_t (ZE_APICALL *ze_pfnCommandListGetNextCommandIdExp_t)( +/// @brief Function-pointer for zeCommandListGetNextCommandIdWithKernelsExp +typedef ze_result_t (ZE_APICALL *ze_pfnCommandListGetNextCommandIdWithKernelsExp_t)( ze_command_list_handle_t, const ze_mutable_command_id_exp_desc_t*, + uint32_t, + ze_kernel_handle_t*, uint64_t* ); @@ -1159,6 +1152,30 @@ typedef ze_result_t (ZE_APICALL *ze_pfnCommandListUpdateMutableCommandSignalEven ze_event_handle_t ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zeCommandListUpdateMutableCommandKernelsExp +typedef ze_result_t (ZE_APICALL *ze_pfnCommandListUpdateMutableCommandKernelsExp_t)( + ze_command_list_handle_t, + uint32_t, + uint64_t*, + ze_kernel_handle_t* + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zeCommandListCreateCloneExp +typedef ze_result_t (ZE_APICALL *ze_pfnCommandListCreateCloneExp_t)( + ze_command_list_handle_t, + ze_command_list_handle_t* + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zeCommandListGetNextCommandIdExp +typedef ze_result_t (ZE_APICALL *ze_pfnCommandListGetNextCommandIdExp_t)( + ze_command_list_handle_t, + const ze_mutable_command_id_exp_desc_t*, + uint64_t* + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for zeCommandListUpdateMutableCommandWaitEventsExp typedef ze_result_t (ZE_APICALL *ze_pfnCommandListUpdateMutableCommandWaitEventsExp_t)( @@ -1168,16 +1185,29 @@ typedef ze_result_t (ZE_APICALL *ze_pfnCommandListUpdateMutableCommandWaitEvents ze_event_handle_t* ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zeCommandListImmediateAppendCommandListsExp +typedef ze_result_t (ZE_APICALL *ze_pfnCommandListImmediateAppendCommandListsExp_t)( + ze_command_list_handle_t, + uint32_t, + ze_command_list_handle_t*, + ze_event_handle_t, + uint32_t, + ze_event_handle_t* + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Table of CommandListExp functions pointers typedef struct _ze_command_list_exp_dditable_t { - ze_pfnCommandListCreateCloneExp_t pfnCreateCloneExp; - ze_pfnCommandListImmediateAppendCommandListsExp_t pfnImmediateAppendCommandListsExp; - ze_pfnCommandListGetNextCommandIdExp_t pfnGetNextCommandIdExp; + ze_pfnCommandListGetNextCommandIdWithKernelsExp_t pfnGetNextCommandIdWithKernelsExp; ze_pfnCommandListUpdateMutableCommandsExp_t pfnUpdateMutableCommandsExp; ze_pfnCommandListUpdateMutableCommandSignalEventExp_t pfnUpdateMutableCommandSignalEventExp; + ze_pfnCommandListUpdateMutableCommandKernelsExp_t pfnUpdateMutableCommandKernelsExp; + ze_pfnCommandListCreateCloneExp_t pfnCreateCloneExp; + ze_pfnCommandListGetNextCommandIdExp_t pfnGetNextCommandIdExp; ze_pfnCommandListUpdateMutableCommandWaitEventsExp_t pfnUpdateMutableCommandWaitEventsExp; + ze_pfnCommandListImmediateAppendCommandListsExp_t pfnImmediateAppendCommandListsExp; } ze_command_list_exp_dditable_t; /////////////////////////////////////////////////////////////////////////////// diff --git a/include/zes.py b/include/zes.py index de70c2da..58b06516 100644 --- a/include/zes.py +++ b/include/zes.py @@ -4,7 +4,7 @@ SPDX-License-Identifier: MIT @file zes.py - @version v1.9-r1.9.3 + @version v1.11-r1.11.0 """ import platform @@ -165,6 +165,9 @@ class zes_structure_type_v(IntEnum): VF_EXP_PROPERTIES = 0x00020005 ## ::zes_vf_exp_properties_t VF_UTIL_MEM_EXP = 0x00020006 ## ::zes_vf_util_mem_exp_t VF_UTIL_ENGINE_EXP = 0x00020007 ## ::zes_vf_util_engine_exp_t + VF_EXP_CAPABILITIES = 0x00020008 ## ::zes_vf_exp_capabilities_t + VF_UTIL_MEM_EXP2 = 0x00020009 ## ::zes_vf_util_mem_exp2_t + VF_UTIL_ENGINE_EXP2 = 0x00020010 ## ::zes_vf_util_engine_exp2_t class zes_structure_type_t(c_int): def __str__(self): @@ -2086,6 +2089,7 @@ class zes_temp_sensors_v(IntEnum): MEMORY_MIN = 5 ## The minimum temperature across all sensors in the local device memory GPU_BOARD = 6 ## The maximum temperature across all sensors in the GPU Board GPU_BOARD_MIN = 7 ## The minimum temperature across all sensors in the GPU Board + VOLTAGE_REGULATOR = 8 ## The maximum temperature across all sensors in the Voltage Regulator class zes_temp_sensors_t(c_int): def __str__(self): @@ -2430,8 +2434,10 @@ class zes_subdevice_exp_properties_t(Structure): ############################################################################### ## @brief Virtual Function Management Extension Version(s) class zes_vf_management_exp_version_v(IntEnum): - _1_0 = ZE_MAKE_VERSION( 1, 0 ) ## version 1.0 - CURRENT = ZE_MAKE_VERSION( 1, 0 ) ## latest known version + _1_0 = ZE_MAKE_VERSION( 1, 0 ) ## version 1.0 (deprecated) + _1_1 = ZE_MAKE_VERSION( 1, 1 ) ## version 1.1 (deprecated) + _1_2 = ZE_MAKE_VERSION( 1, 2 ) ## version 1.2 + CURRENT = ZE_MAKE_VERSION( 1, 2 ) ## latest known version class zes_vf_management_exp_version_t(c_int): def __str__(self): @@ -2439,7 +2445,7 @@ def __str__(self): ############################################################################### -## @brief Virtual function memory types +## @brief Virtual function memory types (deprecated) class zes_vf_info_mem_type_exp_flags_v(IntEnum): MEM_TYPE_SYSTEM = ZE_BIT(0) ## System memory MEM_TYPE_DEVICE = ZE_BIT(1) ## Device local memory @@ -2450,7 +2456,7 @@ def __str__(self): ############################################################################### -## @brief Virtual function utilization flag bit fields +## @brief Virtual function utilization flag bit fields (deprecated) class zes_vf_info_util_exp_flags_v(IntEnum): INFO_NONE = ZE_BIT(0) ## No info associated with virtual function INFO_MEM_CPU = ZE_BIT(1) ## System memory utilization associated with virtual function @@ -2463,7 +2469,7 @@ def __str__(self): ############################################################################### -## @brief Virtual function management properties +## @brief Virtual function management properties (deprecated) class zes_vf_exp_properties_t(Structure): _fields_ = [ ("stype", zes_structure_type_t), ## [in] type of this structure @@ -2476,7 +2482,7 @@ class zes_vf_exp_properties_t(Structure): ] ############################################################################### -## @brief Provides memory utilization values for a virtual function +## @brief Provides memory utilization values for a virtual function (deprecated) class zes_vf_util_mem_exp_t(Structure): _fields_ = [ ("stype", zes_structure_type_t), ## [in] type of this structure @@ -2489,7 +2495,7 @@ class zes_vf_util_mem_exp_t(Structure): ] ############################################################################### -## @brief Provides engine utilization values for a virtual function +## @brief Provides engine utilization values for a virtual function (deprecated) class zes_vf_util_engine_exp_t(Structure): _fields_ = [ ("stype", zes_structure_type_t), ## [in] type of this structure @@ -2501,6 +2507,48 @@ class zes_vf_util_engine_exp_t(Structure): ("timestamp", c_ulonglong) ## [out] Wall clock time when the activeCounterValue was sampled. ] +############################################################################### +## @brief Virtual function management capabilities +class zes_vf_exp_capabilities_t(Structure): + _fields_ = [ + ("stype", zes_structure_type_t), ## [in] type of this structure + ("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific + ## structure (i.e. contains stype and pNext). + ("address", zes_pci_address_t), ## [out] Virtual function BDF address + ("vfDeviceMemSize", c_ulong), ## [out] Virtual function memory size in bytes + ("vfID", c_ulong) ## [out] Virtual Function ID + ] + +############################################################################### +## @brief Provides memory utilization values for a virtual function +class zes_vf_util_mem_exp2_t(Structure): + _fields_ = [ + ("stype", zes_structure_type_t), ## [in] type of this structure + ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific + ## structure (i.e. contains stype and pNext). + ("vfMemLocation", zes_mem_loc_t), ## [out] Location of this memory (system, device) + ("vfMemUtilized", c_ulonglong) ## [out] Free memory size in bytes. + ] + +############################################################################### +## @brief Provides engine utilization values for a virtual function +## +## @details +## - Percent utilization is calculated by taking two snapshots (s1, s2) and +## using the equation: %util = (s2.activeCounterValue - +## s1.activeCounterValue) / (s2.samplingCounterValue - +## s1.samplingCounterValue) +class zes_vf_util_engine_exp2_t(Structure): + _fields_ = [ + ("stype", zes_structure_type_t), ## [in] type of this structure + ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific + ## structure (i.e. contains stype and pNext). + ("vfEngineType", zes_engine_group_t), ## [out] The engine group. + ("activeCounterValue", c_ulonglong), ## [out] Represents active counter. + ("samplingCounterValue", c_ulonglong) ## [out] Represents counter value when activeCounterValue was sampled. + ## Refer to the formulae above for calculating the utilization percent + ] + ############################################################################### __use_win_types = "Windows" == platform.uname()[0] @@ -2822,6 +2870,13 @@ class _zes_device_dditable_t(Structure): ("pfnResetExt", c_void_p) ## _zesDeviceResetExt_t ] +############################################################################### +## @brief Function-pointer for zesDeviceEnumEnabledVFExp +if __use_win_types: + _zesDeviceEnumEnabledVFExp_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_vf_handle_t) ) +else: + _zesDeviceEnumEnabledVFExp_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_vf_handle_t) ) + ############################################################################### ## @brief Function-pointer for zesDeviceGetSubDevicePropertiesExp if __use_win_types: @@ -2841,6 +2896,7 @@ class _zes_device_dditable_t(Structure): ## @brief Table of DeviceExp functions pointers class _zes_device_exp_dditable_t(Structure): _fields_ = [ + ("pfnEnumEnabledVFExp", c_void_p), ## _zesDeviceEnumEnabledVFExp_t ("pfnGetSubDevicePropertiesExp", c_void_p), ## _zesDeviceGetSubDevicePropertiesExp_t ("pfnEnumActiveVFExp", c_void_p) ## _zesDeviceEnumActiveVFExp_t ] @@ -3777,6 +3833,36 @@ class _zes_diagnostics_dditable_t(Structure): ("pfnRunTests", c_void_p) ## _zesDiagnosticsRunTests_t ] +############################################################################### +## @brief Function-pointer for zesVFManagementGetVFMemoryUtilizationExp2 +if __use_win_types: + _zesVFManagementGetVFMemoryUtilizationExp2_t = WINFUNCTYPE( ze_result_t, zes_vf_handle_t, POINTER(c_ulong), POINTER(zes_vf_util_mem_exp2_t) ) +else: + _zesVFManagementGetVFMemoryUtilizationExp2_t = CFUNCTYPE( ze_result_t, zes_vf_handle_t, POINTER(c_ulong), POINTER(zes_vf_util_mem_exp2_t) ) + +############################################################################### +## @brief Function-pointer for zesVFManagementGetVFEngineUtilizationExp2 +if __use_win_types: + _zesVFManagementGetVFEngineUtilizationExp2_t = WINFUNCTYPE( ze_result_t, zes_vf_handle_t, POINTER(c_ulong), POINTER(zes_vf_util_engine_exp2_t) ) +else: + _zesVFManagementGetVFEngineUtilizationExp2_t = CFUNCTYPE( ze_result_t, zes_vf_handle_t, POINTER(c_ulong), POINTER(zes_vf_util_engine_exp2_t) ) + + +############################################################################### +## @brief Table of VFManagement functions pointers +class _zes_vf_management_dditable_t(Structure): + _fields_ = [ + ("pfnGetVFMemoryUtilizationExp2", c_void_p), ## _zesVFManagementGetVFMemoryUtilizationExp2_t + ("pfnGetVFEngineUtilizationExp2", c_void_p) ## _zesVFManagementGetVFEngineUtilizationExp2_t + ] + +############################################################################### +## @brief Function-pointer for zesVFManagementGetVFCapabilitiesExp +if __use_win_types: + _zesVFManagementGetVFCapabilitiesExp_t = WINFUNCTYPE( ze_result_t, zes_vf_handle_t, POINTER(zes_vf_exp_capabilities_t) ) +else: + _zesVFManagementGetVFCapabilitiesExp_t = CFUNCTYPE( ze_result_t, zes_vf_handle_t, POINTER(zes_vf_exp_capabilities_t) ) + ############################################################################### ## @brief Function-pointer for zesVFManagementGetVFPropertiesExp if __use_win_types: @@ -3817,6 +3903,7 @@ class _zes_diagnostics_dditable_t(Structure): ## @brief Table of VFManagementExp functions pointers class _zes_vf_management_exp_dditable_t(Structure): _fields_ = [ + ("pfnGetVFCapabilitiesExp", c_void_p), ## _zesVFManagementGetVFCapabilitiesExp_t ("pfnGetVFPropertiesExp", c_void_p), ## _zesVFManagementGetVFPropertiesExp_t ("pfnGetVFMemoryUtilizationExp", c_void_p), ## _zesVFManagementGetVFMemoryUtilizationExp_t ("pfnGetVFEngineUtilizationExp", c_void_p), ## _zesVFManagementGetVFEngineUtilizationExp_t @@ -3850,6 +3937,7 @@ class _zes_dditable_t(Structure): ("Ras", _zes_ras_dditable_t), ("RasExp", _zes_ras_exp_dditable_t), ("Diagnostics", _zes_diagnostics_dditable_t), + ("VFManagement", _zes_vf_management_dditable_t), ("VFManagementExp", _zes_vf_management_exp_dditable_t) ] @@ -3930,6 +4018,7 @@ def __init__(self, version : ze_api_version_t): self.__dditable.DeviceExp = _DeviceExp # attach function interface to function address + self.zesDeviceEnumEnabledVFExp = _zesDeviceEnumEnabledVFExp_t(self.__dditable.DeviceExp.pfnEnumEnabledVFExp) self.zesDeviceGetSubDevicePropertiesExp = _zesDeviceGetSubDevicePropertiesExp_t(self.__dditable.DeviceExp.pfnGetSubDevicePropertiesExp) self.zesDeviceEnumActiveVFExp = _zesDeviceEnumActiveVFExp_t(self.__dditable.DeviceExp.pfnEnumActiveVFExp) @@ -4212,6 +4301,17 @@ def __init__(self, version : ze_api_version_t): self.zesDiagnosticsGetTests = _zesDiagnosticsGetTests_t(self.__dditable.Diagnostics.pfnGetTests) self.zesDiagnosticsRunTests = _zesDiagnosticsRunTests_t(self.__dditable.Diagnostics.pfnRunTests) + # call driver to get function pointers + _VFManagement = _zes_vf_management_dditable_t() + r = ze_result_v(self.__dll.zesGetVFManagementProcAddrTable(version, byref(_VFManagement))) + if r != ze_result_v.SUCCESS: + raise Exception(r) + self.__dditable.VFManagement = _VFManagement + + # attach function interface to function address + self.zesVFManagementGetVFMemoryUtilizationExp2 = _zesVFManagementGetVFMemoryUtilizationExp2_t(self.__dditable.VFManagement.pfnGetVFMemoryUtilizationExp2) + self.zesVFManagementGetVFEngineUtilizationExp2 = _zesVFManagementGetVFEngineUtilizationExp2_t(self.__dditable.VFManagement.pfnGetVFEngineUtilizationExp2) + # call driver to get function pointers _VFManagementExp = _zes_vf_management_exp_dditable_t() r = ze_result_v(self.__dll.zesGetVFManagementExpProcAddrTable(version, byref(_VFManagementExp))) @@ -4220,6 +4320,7 @@ def __init__(self, version : ze_api_version_t): self.__dditable.VFManagementExp = _VFManagementExp # attach function interface to function address + self.zesVFManagementGetVFCapabilitiesExp = _zesVFManagementGetVFCapabilitiesExp_t(self.__dditable.VFManagementExp.pfnGetVFCapabilitiesExp) self.zesVFManagementGetVFPropertiesExp = _zesVFManagementGetVFPropertiesExp_t(self.__dditable.VFManagementExp.pfnGetVFPropertiesExp) self.zesVFManagementGetVFMemoryUtilizationExp = _zesVFManagementGetVFMemoryUtilizationExp_t(self.__dditable.VFManagementExp.pfnGetVFMemoryUtilizationExp) self.zesVFManagementGetVFEngineUtilizationExp = _zesVFManagementGetVFEngineUtilizationExp_t(self.__dditable.VFManagementExp.pfnGetVFEngineUtilizationExp) diff --git a/include/zes_api.h b/include/zes_api.h index 2c7c5986..40a54d22 100644 --- a/include/zes_api.h +++ b/include/zes_api.h @@ -5,7 +5,7 @@ * SPDX-License-Identifier: MIT * * @file zes_api.h - * @version v1.9-r1.9.3 + * @version v1.11-r1.11.0 * */ #ifndef _ZES_API_H @@ -158,6 +158,9 @@ typedef enum _zes_structure_type_t ZES_STRUCTURE_TYPE_VF_EXP_PROPERTIES = 0x00020005, ///< ::zes_vf_exp_properties_t ZES_STRUCTURE_TYPE_VF_UTIL_MEM_EXP = 0x00020006, ///< ::zes_vf_util_mem_exp_t ZES_STRUCTURE_TYPE_VF_UTIL_ENGINE_EXP = 0x00020007, ///< ::zes_vf_util_engine_exp_t + ZES_STRUCTURE_TYPE_VF_EXP_CAPABILITIES = 0x00020008, ///< ::zes_vf_exp_capabilities_t + ZES_STRUCTURE_TYPE_VF_UTIL_MEM_EXP2 = 0x00020009, ///< ::zes_vf_util_mem_exp2_t + ZES_STRUCTURE_TYPE_VF_UTIL_ENGINE_EXP2 = 0x00020010, ///< ::zes_vf_util_engine_exp2_t ZES_STRUCTURE_TYPE_FORCE_UINT32 = 0x7fffffff } zes_structure_type_t; @@ -548,6 +551,18 @@ typedef struct _zes_vf_util_mem_exp_t zes_vf_util_mem_exp_t; /// @brief Forward-declare zes_vf_util_engine_exp_t typedef struct _zes_vf_util_engine_exp_t zes_vf_util_engine_exp_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare zes_vf_exp_capabilities_t +typedef struct _zes_vf_exp_capabilities_t zes_vf_exp_capabilities_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare zes_vf_util_mem_exp2_t +typedef struct _zes_vf_util_mem_exp2_t zes_vf_util_mem_exp2_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare zes_vf_util_engine_exp2_t +typedef struct _zes_vf_util_engine_exp2_t zes_vf_util_engine_exp2_t; + #if !defined(__GNUC__) #pragma endregion @@ -6192,6 +6207,7 @@ typedef enum _zes_temp_sensors_t ZES_TEMP_SENSORS_MEMORY_MIN = 5, ///< The minimum temperature across all sensors in the local device memory ZES_TEMP_SENSORS_GPU_BOARD = 6, ///< The maximum temperature across all sensors in the GPU Board ZES_TEMP_SENSORS_GPU_BOARD_MIN = 7, ///< The minimum temperature across all sensors in the GPU Board + ZES_TEMP_SENSORS_VOLTAGE_REGULATOR = 8, ///< The maximum temperature across all sensors in the Voltage Regulator ZES_TEMP_SENSORS_FORCE_UINT32 = 0x7fffffff } zes_temp_sensors_t; @@ -7052,14 +7068,16 @@ zesDriverGetDeviceByUuidExp( /// @brief Virtual Function Management Extension Version(s) typedef enum _zes_vf_management_exp_version_t { - ZES_VF_MANAGEMENT_EXP_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 - ZES_VF_MANAGEMENT_EXP_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 0 ), ///< latest known version + ZES_VF_MANAGEMENT_EXP_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 (deprecated) + ZES_VF_MANAGEMENT_EXP_VERSION_1_1 = ZE_MAKE_VERSION( 1, 1 ), ///< version 1.1 (deprecated) + ZES_VF_MANAGEMENT_EXP_VERSION_1_2 = ZE_MAKE_VERSION( 1, 2 ), ///< version 1.2 + ZES_VF_MANAGEMENT_EXP_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 2 ), ///< latest known version ZES_VF_MANAGEMENT_EXP_VERSION_FORCE_UINT32 = 0x7fffffff } zes_vf_management_exp_version_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Virtual function memory types +/// @brief Virtual function memory types (deprecated) typedef uint32_t zes_vf_info_mem_type_exp_flags_t; typedef enum _zes_vf_info_mem_type_exp_flag_t { @@ -7070,7 +7088,7 @@ typedef enum _zes_vf_info_mem_type_exp_flag_t } zes_vf_info_mem_type_exp_flag_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Virtual function utilization flag bit fields +/// @brief Virtual function utilization flag bit fields (deprecated) typedef uint32_t zes_vf_info_util_exp_flags_t; typedef enum _zes_vf_info_util_exp_flag_t { @@ -7083,7 +7101,7 @@ typedef enum _zes_vf_info_util_exp_flag_t } zes_vf_info_util_exp_flag_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Virtual function management properties +/// @brief Virtual function management properties (deprecated) typedef struct _zes_vf_exp_properties_t { zes_structure_type_t stype; ///< [in] type of this structure @@ -7097,7 +7115,7 @@ typedef struct _zes_vf_exp_properties_t } zes_vf_exp_properties_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Provides memory utilization values for a virtual function +/// @brief Provides memory utilization values for a virtual function (deprecated) typedef struct _zes_vf_util_mem_exp_t { zes_structure_type_t stype; ///< [in] type of this structure @@ -7111,7 +7129,7 @@ typedef struct _zes_vf_util_mem_exp_t } zes_vf_util_mem_exp_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Provides engine utilization values for a virtual function +/// @brief Provides engine utilization values for a virtual function (deprecated) typedef struct _zes_vf_util_engine_exp_t { zes_structure_type_t stype; ///< [in] type of this structure @@ -7124,10 +7142,56 @@ typedef struct _zes_vf_util_engine_exp_t } zes_vf_util_engine_exp_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Virtual function management capabilities +typedef struct _zes_vf_exp_capabilities_t +{ + zes_structure_type_t stype; ///< [in] type of this structure + void* pNext; ///< [in,out][optional] must be null or a pointer to an extension-specific + ///< structure (i.e. contains stype and pNext). + zes_pci_address_t address; ///< [out] Virtual function BDF address + uint32_t vfDeviceMemSize; ///< [out] Virtual function memory size in bytes + uint32_t vfID; ///< [out] Virtual Function ID + +} zes_vf_exp_capabilities_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Provides memory utilization values for a virtual function +typedef struct _zes_vf_util_mem_exp2_t +{ + zes_structure_type_t stype; ///< [in] type of this structure + const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific + ///< structure (i.e. contains stype and pNext). + zes_mem_loc_t vfMemLocation; ///< [out] Location of this memory (system, device) + uint64_t vfMemUtilized; ///< [out] Free memory size in bytes. + +} zes_vf_util_mem_exp2_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Provides engine utilization values for a virtual function +/// +/// @details +/// - Percent utilization is calculated by taking two snapshots (s1, s2) and +/// using the equation: %util = (s2.activeCounterValue - +/// s1.activeCounterValue) / (s2.samplingCounterValue - +/// s1.samplingCounterValue) +typedef struct _zes_vf_util_engine_exp2_t +{ + zes_structure_type_t stype; ///< [in] type of this structure + const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific + ///< structure (i.e. contains stype and pNext). + zes_engine_group_t vfEngineType; ///< [out] The engine group. + uint64_t activeCounterValue; ///< [out] Represents active counter. + uint64_t samplingCounterValue; ///< [out] Represents counter value when activeCounterValue was sampled. + ///< Refer to the formulae above for calculating the utilization percent + +} zes_vf_util_engine_exp2_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Get handle of virtual function modules /// /// @details +/// - [DEPRECATED] No longer supported. Use ::zesDeviceEnumEnabledVFExp. /// - The application may call this function from simultaneous threads. /// - The implementation of this function should be lock-free. /// @@ -7161,6 +7225,8 @@ zesDeviceEnumActiveVFExp( /// @brief Get virtual function management properties /// /// @details +/// - [DEPRECATED] No longer supported. Use +/// ::zesVFManagementGetVFCapabilitiesExp. /// - The application may call this function from simultaneous threads. /// - The implementation of this function should be lock-free. /// @@ -7185,6 +7251,8 @@ zesVFManagementGetVFPropertiesExp( /// with Virtual Function (VF) /// /// @details +/// - [DEPRECATED] No longer supported. Use +/// ::zesVFManagementGetVFMemoryUtilizationExp2. /// - The application may call this function from simultaneous threads. /// - The implementation of this function should be lock-free. /// @@ -7221,6 +7289,8 @@ zesVFManagementGetVFMemoryUtilizationExp( /// with Virtual Function (VF) /// /// @details +/// - [DEPRECATED] No longer supported. Use +/// ::zesVFManagementGetVFEngineUtilizationExp2. /// - The application may call this function from simultaneous threads. /// - The implementation of this function should be lock-free. /// @@ -7257,6 +7327,7 @@ zesVFManagementGetVFEngineUtilizationExp( /// Virtual Function (VF) /// /// @details +/// - [DEPRECATED] No longer supported. /// - The application may call this function from simultaneous threads. /// - The implementation of this function should be lock-free. /// @@ -7283,6 +7354,7 @@ zesVFManagementSetVFTelemetryModeExp( /// telemetry associated with Virtual Function (VF) /// /// @details +/// - [DEPRECATED] No longer supported. /// - The application may call this function from simultaneous threads. /// - The implementation of this function should be lock-free. /// @@ -7304,6 +7376,132 @@ zesVFManagementSetVFTelemetrySamplingIntervalExp( uint64_t samplingInterval ///< [in] Sampling interval value. ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get handle of virtual function modules +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCount` +ZE_APIEXPORT ze_result_t ZE_APICALL +zesDeviceEnumEnabledVFExp( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_vf_handle_t* phVFhandle ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get virtual function management capabilities +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hVFhandle` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCapability` +ZE_APIEXPORT ze_result_t ZE_APICALL +zesVFManagementGetVFCapabilitiesExp( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. + zes_vf_exp_capabilities_t* pCapability ///< [in,out] Will contain VF capability. + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get memory activity stats for each available memory types associated +/// with Virtual Function (VF) +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// - If VF is disable/pause/not active, utilization will give zero value. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hVFhandle` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCount` +ZE_APIEXPORT ze_result_t ZE_APICALL +zesVFManagementGetVFMemoryUtilizationExp2( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF memory stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of memory stats available. + ///< - if count is greater than the total number of memory stats + ///< available, the driver shall update the value with the correct number + ///< of memory stats available. + zes_vf_util_mem_exp2_t* pMemUtil ///< [in,out][optional][range(0, *pCount)] array of memory group activity counters. + ///< - if count is less than the total number of memory stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector pCount-1 number of VF + ///< memory stats. + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get engine activity stats for each available engine group associated +/// with Virtual Function (VF) +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// - If VF is disable/pause/not active, utilization will give zero value. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hVFhandle` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCount` +ZE_APIEXPORT ze_result_t ZE_APICALL +zesVFManagementGetVFEngineUtilizationExp2( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF engine stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of engine stats available. + ///< - if count is greater than the total number of engine stats + ///< available, the driver shall update the value with the correct number + ///< of engine stats available. + zes_vf_util_engine_exp2_t* pEngineUtil ///< [in,out][optional][range(0, *pCount)] array of engine group activity counters. + ///< - if count is less than the total number of engine stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector pCount-1 number of VF + ///< engine stats. + ); + #if !defined(__GNUC__) #pragma endregion #endif diff --git a/include/zes_ddi.h b/include/zes_ddi.h index a33e838f..66471683 100644 --- a/include/zes_ddi.h +++ b/include/zes_ddi.h @@ -5,7 +5,7 @@ * SPDX-License-Identifier: MIT * * @file zes_ddi.h - * @version v1.9-r1.9.3 + * @version v1.11-r1.11.0 * */ #ifndef _ZES_DDI_H @@ -402,6 +402,14 @@ typedef ze_result_t (ZE_APICALL *zes_pfnGetDeviceProcAddrTable_t)( zes_device_dditable_t* ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zesDeviceEnumEnabledVFExp +typedef ze_result_t (ZE_APICALL *zes_pfnDeviceEnumEnabledVFExp_t)( + zes_device_handle_t, + uint32_t*, + zes_vf_handle_t* + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for zesDeviceGetSubDevicePropertiesExp typedef ze_result_t (ZE_APICALL *zes_pfnDeviceGetSubDevicePropertiesExp_t)( @@ -422,6 +430,7 @@ typedef ze_result_t (ZE_APICALL *zes_pfnDeviceEnumActiveVFExp_t)( /// @brief Table of DeviceExp functions pointers typedef struct _zes_device_exp_dditable_t { + zes_pfnDeviceEnumEnabledVFExp_t pfnEnumEnabledVFExp; zes_pfnDeviceGetSubDevicePropertiesExp_t pfnGetSubDevicePropertiesExp; zes_pfnDeviceEnumActiveVFExp_t pfnEnumActiveVFExp; } zes_device_exp_dditable_t; @@ -1847,6 +1856,59 @@ typedef ze_result_t (ZE_APICALL *zes_pfnGetDiagnosticsProcAddrTable_t)( zes_diagnostics_dditable_t* ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zesVFManagementGetVFMemoryUtilizationExp2 +typedef ze_result_t (ZE_APICALL *zes_pfnVFManagementGetVFMemoryUtilizationExp2_t)( + zes_vf_handle_t, + uint32_t*, + zes_vf_util_mem_exp2_t* + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zesVFManagementGetVFEngineUtilizationExp2 +typedef ze_result_t (ZE_APICALL *zes_pfnVFManagementGetVFEngineUtilizationExp2_t)( + zes_vf_handle_t, + uint32_t*, + zes_vf_util_engine_exp2_t* + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Table of VFManagement functions pointers +typedef struct _zes_vf_management_dditable_t +{ + zes_pfnVFManagementGetVFMemoryUtilizationExp2_t pfnGetVFMemoryUtilizationExp2; + zes_pfnVFManagementGetVFEngineUtilizationExp2_t pfnGetVFEngineUtilizationExp2; +} zes_vf_management_dditable_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's VFManagement table +/// with current process' addresses +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION +ZE_DLLEXPORT ze_result_t ZE_APICALL +zesGetVFManagementProcAddrTable( + ze_api_version_t version, ///< [in] API version requested + zes_vf_management_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zesGetVFManagementProcAddrTable +typedef ze_result_t (ZE_APICALL *zes_pfnGetVFManagementProcAddrTable_t)( + ze_api_version_t, + zes_vf_management_dditable_t* + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zesVFManagementGetVFCapabilitiesExp +typedef ze_result_t (ZE_APICALL *zes_pfnVFManagementGetVFCapabilitiesExp_t)( + zes_vf_handle_t, + zes_vf_exp_capabilities_t* + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for zesVFManagementGetVFPropertiesExp typedef ze_result_t (ZE_APICALL *zes_pfnVFManagementGetVFPropertiesExp_t)( @@ -1890,6 +1952,7 @@ typedef ze_result_t (ZE_APICALL *zes_pfnVFManagementSetVFTelemetrySamplingInterv /// @brief Table of VFManagementExp functions pointers typedef struct _zes_vf_management_exp_dditable_t { + zes_pfnVFManagementGetVFCapabilitiesExp_t pfnGetVFCapabilitiesExp; zes_pfnVFManagementGetVFPropertiesExp_t pfnGetVFPropertiesExp; zes_pfnVFManagementGetVFMemoryUtilizationExp_t pfnGetVFMemoryUtilizationExp; zes_pfnVFManagementGetVFEngineUtilizationExp_t pfnGetVFEngineUtilizationExp; @@ -1946,6 +2009,7 @@ typedef struct _zes_dditable_t zes_ras_dditable_t Ras; zes_ras_exp_dditable_t RasExp; zes_diagnostics_dditable_t Diagnostics; + zes_vf_management_dditable_t VFManagement; zes_vf_management_exp_dditable_t VFManagementExp; } zes_dditable_t; diff --git a/include/zet.py b/include/zet.py index ea50200f..4bb902c7 100644 --- a/include/zet.py +++ b/include/zet.py @@ -4,7 +4,7 @@ SPDX-License-Identifier: MIT @file zet.py - @version v1.9-r1.9.3 + @version v1.11-r1.11.0 """ import platform @@ -100,6 +100,9 @@ class zet_structure_type_v(IntEnum): METRIC_PROGRAMMABLE_EXP_PROPERTIES = 0x00010003 ## ::zet_metric_programmable_exp_properties_t METRIC_PROGRAMMABLE_PARAM_INFO_EXP = 0x00010004 ## ::zet_metric_programmable_param_info_exp_t METRIC_PROGRAMMABLE_PARAM_VALUE_INFO_EXP = 0x00010005 ## ::zet_metric_programmable_param_value_info_exp_t + METRIC_GROUP_TYPE_EXP = 0x00010006 ## ::zet_metric_group_type_exp_t + EXPORT_DMA_EXP_PROPERTIES = 0x00010007 ## ::zet_export_dma_buf_exp_properties_t + METRIC_TRACER_EXP_DESC = 0x00010008 ## ::zet_metric_tracer_exp_desc_t class zet_structure_type_t(c_int): def __str__(self): @@ -321,6 +324,7 @@ class zet_debug_event_t(Structure): class zet_debug_memory_space_type_v(IntEnum): DEFAULT = 0 ## default memory space (attribute may be omitted) SLM = 1 ## shared local memory space (GPU-only) + ELF = 2 ## ELF file memory space class zet_debug_memory_space_type_t(c_int): def __str__(self): @@ -379,6 +383,7 @@ class zet_debug_regset_properties_t(Structure): class zet_metric_group_sampling_type_flags_v(IntEnum): EVENT_BASED = ZE_BIT(0) ## Event based sampling TIME_BASED = ZE_BIT(1) ## Time based sampling + EXP_TRACER_BASED = ZE_BIT(2) ## Experimental Tracer based sampling class zet_metric_group_sampling_type_flags_t(c_int): def __str__(self): @@ -412,9 +417,16 @@ class zet_metric_type_v(IntEnum): FLAG = 5 ## Metric type: flag RATIO = 6 ## Metric type: ratio RAW = 7 ## Metric type: raw - IP_EXP = 0x7ffffffe ## Metric type: instruction pointer. Deprecated, use + IP_EXP = 8 ## Metric type: instruction pointer. Deprecated, use ## ::ZET_METRIC_TYPE_IP. - IP = 0x7ffffffe ## Metric type: instruction pointer + IP = 9 ## Metric type: instruction pointer + EVENT_EXP_TIMESTAMP = 10 ## Metric type: event with only timestamp and value has no meaning + EVENT_EXP_START = 11 ## Metric type: the first event of a start/end event pair + EVENT_EXP_END = 12 ## Metric type: the second event of a start/end event pair + EXPORT_DMA_BUF = 0x7ffffffd ## Metric which exports linux dma_buf, which could be imported/mapped to + ## the host process + EVENT_EXP_MONOTONIC_WRAPS_VALUE = 0x7ffffffe ## Metric type: value of the event is a monotonically increasing value + ## that can wrap around class zet_metric_type_t(c_int): def __str__(self): @@ -588,6 +600,113 @@ class zet_tracer_exp_desc_t(Structure): ("pUserData", c_void_p) ## [in] pointer passed to every tracer's callbacks ] +############################################################################### +## @brief Concurrent Metric Groups Experimental Extension Name +ZET_CONCURRENT_METRIC_GROUPS_EXP_NAME = "ZET_experimental_concurrent_metric_groups" + +############################################################################### +## @brief Concurrent Metric Groups Experimental Extension Version(s) +class zet_concurrent_metric_groups_exp_version_v(IntEnum): + _1_0 = ZE_MAKE_VERSION( 1, 0 ) ## version 1.0 + CURRENT = ZE_MAKE_VERSION( 1, 0 ) ## latest known version + +class zet_concurrent_metric_groups_exp_version_t(c_int): + def __str__(self): + return str(zet_concurrent_metric_groups_exp_version_v(self.value)) + + +############################################################################### +## @brief Metric Tracer Experimental Extension Name +ZET_METRICS_TRACER_EXP_NAME = "ZET_experimental_metric_tracer" + +############################################################################### +## @brief Metric Tracer Experimental Extension Version(s) +class zet_metric_tracer_exp_version_v(IntEnum): + _1_0 = ZE_MAKE_VERSION( 1, 0 ) ## version 1.0 + CURRENT = ZE_MAKE_VERSION( 1, 0 ) ## latest known version + +class zet_metric_tracer_exp_version_t(c_int): + def __str__(self): + return str(zet_metric_tracer_exp_version_v(self.value)) + + +############################################################################### +## @brief Handle of metric tracer's object +class zet_metric_tracer_exp_handle_t(c_void_p): + pass + +############################################################################### +## @brief Handle of metric decoder's object +class zet_metric_decoder_exp_handle_t(c_void_p): + pass + +############################################################################### +## @brief Metric tracer descriptor +class zet_metric_tracer_exp_desc_t(Structure): + _fields_ = [ + ("stype", zet_structure_type_t), ## [in] type of this structure + ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific + ## structure (i.e. contains stype and pNext). + ("notifyEveryNBytes", c_ulong) ## [in,out] number of collected bytes after which notification event will + ## be signaled. If the requested value is not supported exactly, then the + ## driver may use a value that is the closest supported approximation and + ## shall update this member during ::zetMetricTracerCreateExp. + ] + +############################################################################### +## @brief Decoded metric entry +class zet_metric_entry_exp_t(Structure): + _fields_ = [ + ("value", zet_value_t), ## [out] value of the decodable metric entry or event. Number is + ## meaningful based on the metric type. + ("timeStamp", c_ulonglong), ## [out] timestamp at which the event happened. + ("metricIndex", c_ulong), ## [out] index to the decodable metric handle in the input array + ## (phMetric) in ::zetMetricTracerDecodeExp(). + ("onSubdevice", ze_bool_t), ## [out] True if the event occurred on a sub-device; false means the + ## device on which the metric tracer was opened does not have + ## sub-devices. + ("subdeviceId", c_ulong) ## [out] If onSubdevice is true, this gives the ID of the sub-device. + ] + +############################################################################### +## @brief Metric group type +class zet_metric_group_type_exp_flags_v(IntEnum): + EXPORT_DMA_BUF = ZE_BIT(0) ## Metric group and metrics exports memory using linux dma-buf, which + ## could be imported/mapped to the host process. Properties of the + ## dma_buf could be queried using ::zet_export_dma_buf_exp_properties_t. + USER_CREATED = ZE_BIT(1) ## Metric group created using ::zetMetricGroupCreateExp + OTHER = ZE_BIT(2) ## Metric group which has a collection of metrics + +class zet_metric_group_type_exp_flags_t(c_int): + def __str__(self): + return hex(self.value) + + +############################################################################### +## @brief Query the metric group type using `pNext` of +## ::zet_metric_group_properties_t +class zet_metric_group_type_exp_t(Structure): + _fields_ = [ + ("stype", zet_structure_type_t), ## [in] type of this structure + ("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific + ## structure (i.e. contains stype and pNext). + ("type", zet_metric_group_type_exp_flags_t) ## [out] metric group type. + ## returns a combination of ::zet_metric_group_type_exp_flags_t. + ] + +############################################################################### +## @brief Exported dma_buf properties queried using `pNext` of +## ::zet_metric_group_properties_t or ::zet_metric_properties_t +class zet_export_dma_buf_exp_properties_t(Structure): + _fields_ = [ + ("stype", zet_structure_type_t), ## [in] type of this structure + ("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific + ## structure (i.e. contains stype and pNext). + ("fd", c_int), ## [out] the file descriptor handle that could be used to import the + ## memory by the host process. + ("size", c_size_t) ## [out] size in bytes of the dma_buf + ] + ############################################################################### ## @brief Calculating Multiple Metrics Experimental Extension Name ZET_MULTI_METRICS_EXP_NAME = "ZET_experimental_calculate_multiple_metrics" @@ -675,8 +794,8 @@ class zet_metric_calculate_exp_desc_t(Structure): ############################################################################### ## @brief Programmable Metrics Experimental Extension Version(s) class zet_metric_programmable_exp_version_v(IntEnum): - _1_0 = ZE_MAKE_VERSION( 1, 0 ) ## version 1.0 - CURRENT = ZE_MAKE_VERSION( 1, 0 ) ## latest known version + _1_1 = ZE_MAKE_VERSION( 1, 1 ) ## version 1.1 + CURRENT = ZE_MAKE_VERSION( 1, 1 ) ## latest known version class zet_metric_programmable_exp_version_t(c_int): def __str__(self): @@ -708,8 +827,12 @@ def __str__(self): ZET_MAX_METRIC_PROGRAMMABLE_PARAMETER_NAME_EXP = 128 ############################################################################### -## @brief Maximum value information string size -ZET_MAX_VALUE_INFO_CSTRING_EXP = 128 +## @brief Maximum value for programmable value description +ZET_MAX_METRIC_PROGRAMMABLE_VALUE_DESCRIPTION_EXP = 128 + +############################################################################### +## @brief Maximum value metric group name prefix +ZE_MAX_METRIC_GROUP_NAME_PREFIX = 64 ############################################################################### ## @brief Handle of metric programmable's object @@ -745,6 +868,7 @@ class zet_metric_programmable_param_type_exp_v(IntEnum): ## instance_count. NORMALIZATION_AVERAGE = 3 ## Produces normalization using raw_metric / HW instance_count. NORMALIZATION_RATE = 4 ## Produces normalization average using raw_metric / timestamp. + NORMALIZATION_BYTES = 5 ## Produces normalization average using raw_metric * n bytes. class zet_metric_programmable_param_type_exp_t(c_int): def __str__(self): @@ -759,10 +883,10 @@ class zet_value_info_type_exp_v(IntEnum): FLOAT32 = 2 ## 32-bit floating-point FLOAT64 = 3 ## 64-bit floating-point BOOL8 = 4 ## 8-bit boolean - CSTRING = 5 ## C string - UINT8 = 6 ## 8-bit unsigned-integer - UINT16 = 7 ## 16-bit unsigned-integer - UINT64_RANGE = 8 ## 64-bit unsigned-integer range (minimum and maximum) + UINT8 = 5 ## 8-bit unsigned-integer + UINT16 = 6 ## 16-bit unsigned-integer + UINT64_RANGE = 7 ## 64-bit unsigned-integer range (minimum and maximum) + FLOAT64_RANGE = 8 ## 64-bit floating point range (minimum and maximum) class zet_value_info_type_exp_t(c_int): def __str__(self): @@ -774,7 +898,15 @@ def __str__(self): class zet_value_uint64_range_exp_t(Structure): _fields_ = [ ("ui64Min", c_ulonglong), ## [out] minimum value of the range - ("ui64Max", c_ulonglong) ## [out] max value of the range + ("ui64Max", c_ulonglong) ## [out] maximum value of the range + ] + +############################################################################### +## @brief Value info of type float64 range +class zet_value_fp64_range_exp_t(Structure): + _fields_ = [ + ("fp64Min", c_double), ## [out] minimum value of the range + ("fp64Max", c_double) ## [out] maximum value of the range ] ############################################################################### @@ -788,8 +920,8 @@ class zet_value_info_exp_t(Structure): ("b8", ze_bool_t), ## [out] 8-bit boolean ("ui8", c_ubyte), ## [out] 8-bit unsigned integer ("ui16", c_ushort), ## [out] 16-bit unsigned integer - ("cString", c_char * ZET_MAX_VALUE_INFO_CSTRING_EXP), ## [out] cString - ("ui64Range", zet_value_uint64_range_exp_t) ## [out] minimum and maximum value of the range + ("ui64Range", zet_value_uint64_range_exp_t), ## [out] minimum and maximum value of the range + ("fp64Range", zet_value_fp64_range_exp_t) ## [out] minimum and maximum value of the range ] ############################################################################### @@ -797,7 +929,7 @@ class zet_value_info_exp_t(Structure): class zet_metric_programmable_param_info_exp_t(Structure): _fields_ = [ ("stype", zet_structure_type_t), ## [in] type of this structure - ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific + ("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific ## structure (i.e. contains stype and pNext). ("type", zet_metric_programmable_param_type_exp_t), ## [out] programmable parameter type ("name", c_char * ZET_MAX_METRIC_PROGRAMMABLE_PARAMETER_NAME_EXP), ## [out] metric programmable parameter name @@ -811,9 +943,10 @@ class zet_metric_programmable_param_info_exp_t(Structure): class zet_metric_programmable_param_value_info_exp_t(Structure): _fields_ = [ ("stype", zet_structure_type_t), ## [in] type of this structure - ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific + ("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific ## structure (i.e. contains stype and pNext). - ("valueInfo", zet_value_info_exp_t) ## [out] information about the parameter value + ("valueInfo", zet_value_info_exp_t), ## [out] information about the parameter value + ("description", c_char * ZET_MAX_METRIC_PROGRAMMABLE_VALUE_DESCRIPTION_EXP) ## [out] description about the value ] ############################################################################### @@ -865,6 +998,92 @@ class _zet_metric_programmable_exp_dditable_t(Structure): ("pfnGetParamValueInfoExp", c_void_p) ## _zetMetricProgrammableGetParamValueInfoExp_t ] +############################################################################### +## @brief Function-pointer for zetMetricTracerCreateExp +if __use_win_types: + _zetMetricTracerCreateExp_t = WINFUNCTYPE( ze_result_t, zet_context_handle_t, zet_device_handle_t, c_ulong, POINTER(zet_metric_group_handle_t), POINTER(zet_metric_tracer_exp_desc_t), ze_event_handle_t, POINTER(zet_metric_tracer_exp_handle_t) ) +else: + _zetMetricTracerCreateExp_t = CFUNCTYPE( ze_result_t, zet_context_handle_t, zet_device_handle_t, c_ulong, POINTER(zet_metric_group_handle_t), POINTER(zet_metric_tracer_exp_desc_t), ze_event_handle_t, POINTER(zet_metric_tracer_exp_handle_t) ) + +############################################################################### +## @brief Function-pointer for zetMetricTracerDestroyExp +if __use_win_types: + _zetMetricTracerDestroyExp_t = WINFUNCTYPE( ze_result_t, zet_metric_tracer_exp_handle_t ) +else: + _zetMetricTracerDestroyExp_t = CFUNCTYPE( ze_result_t, zet_metric_tracer_exp_handle_t ) + +############################################################################### +## @brief Function-pointer for zetMetricTracerEnableExp +if __use_win_types: + _zetMetricTracerEnableExp_t = WINFUNCTYPE( ze_result_t, zet_metric_tracer_exp_handle_t, ze_bool_t ) +else: + _zetMetricTracerEnableExp_t = CFUNCTYPE( ze_result_t, zet_metric_tracer_exp_handle_t, ze_bool_t ) + +############################################################################### +## @brief Function-pointer for zetMetricTracerDisableExp +if __use_win_types: + _zetMetricTracerDisableExp_t = WINFUNCTYPE( ze_result_t, zet_metric_tracer_exp_handle_t, ze_bool_t ) +else: + _zetMetricTracerDisableExp_t = CFUNCTYPE( ze_result_t, zet_metric_tracer_exp_handle_t, ze_bool_t ) + +############################################################################### +## @brief Function-pointer for zetMetricTracerReadDataExp +if __use_win_types: + _zetMetricTracerReadDataExp_t = WINFUNCTYPE( ze_result_t, zet_metric_tracer_exp_handle_t, POINTER(c_size_t), POINTER(c_ubyte) ) +else: + _zetMetricTracerReadDataExp_t = CFUNCTYPE( ze_result_t, zet_metric_tracer_exp_handle_t, POINTER(c_size_t), POINTER(c_ubyte) ) + +############################################################################### +## @brief Function-pointer for zetMetricTracerDecodeExp +if __use_win_types: + _zetMetricTracerDecodeExp_t = WINFUNCTYPE( ze_result_t, zet_metric_decoder_exp_handle_t, POINTER(c_size_t), POINTER(c_ubyte), c_ulong, POINTER(zet_metric_handle_t), POINTER(c_ulong), POINTER(c_ulong), POINTER(c_ulong), POINTER(zet_metric_entry_exp_t) ) +else: + _zetMetricTracerDecodeExp_t = CFUNCTYPE( ze_result_t, zet_metric_decoder_exp_handle_t, POINTER(c_size_t), POINTER(c_ubyte), c_ulong, POINTER(zet_metric_handle_t), POINTER(c_ulong), POINTER(c_ulong), POINTER(c_ulong), POINTER(zet_metric_entry_exp_t) ) + + +############################################################################### +## @brief Table of MetricTracerExp functions pointers +class _zet_metric_tracer_exp_dditable_t(Structure): + _fields_ = [ + ("pfnCreateExp", c_void_p), ## _zetMetricTracerCreateExp_t + ("pfnDestroyExp", c_void_p), ## _zetMetricTracerDestroyExp_t + ("pfnEnableExp", c_void_p), ## _zetMetricTracerEnableExp_t + ("pfnDisableExp", c_void_p), ## _zetMetricTracerDisableExp_t + ("pfnReadDataExp", c_void_p), ## _zetMetricTracerReadDataExp_t + ("pfnDecodeExp", c_void_p) ## _zetMetricTracerDecodeExp_t + ] + +############################################################################### +## @brief Function-pointer for zetMetricDecoderCreateExp +if __use_win_types: + _zetMetricDecoderCreateExp_t = WINFUNCTYPE( ze_result_t, zet_metric_tracer_exp_handle_t, POINTER(zet_metric_decoder_exp_handle_t) ) +else: + _zetMetricDecoderCreateExp_t = CFUNCTYPE( ze_result_t, zet_metric_tracer_exp_handle_t, POINTER(zet_metric_decoder_exp_handle_t) ) + +############################################################################### +## @brief Function-pointer for zetMetricDecoderDestroyExp +if __use_win_types: + _zetMetricDecoderDestroyExp_t = WINFUNCTYPE( ze_result_t, zet_metric_decoder_exp_handle_t ) +else: + _zetMetricDecoderDestroyExp_t = CFUNCTYPE( ze_result_t, zet_metric_decoder_exp_handle_t ) + +############################################################################### +## @brief Function-pointer for zetMetricDecoderGetDecodableMetricsExp +if __use_win_types: + _zetMetricDecoderGetDecodableMetricsExp_t = WINFUNCTYPE( ze_result_t, zet_metric_decoder_exp_handle_t, POINTER(c_ulong), POINTER(zet_metric_handle_t) ) +else: + _zetMetricDecoderGetDecodableMetricsExp_t = CFUNCTYPE( ze_result_t, zet_metric_decoder_exp_handle_t, POINTER(c_ulong), POINTER(zet_metric_handle_t) ) + + +############################################################################### +## @brief Table of MetricDecoderExp functions pointers +class _zet_metric_decoder_exp_dditable_t(Structure): + _fields_ = [ + ("pfnCreateExp", c_void_p), ## _zetMetricDecoderCreateExp_t + ("pfnDestroyExp", c_void_p), ## _zetMetricDecoderDestroyExp_t + ("pfnGetDecodableMetricsExp", c_void_p) ## _zetMetricDecoderGetDecodableMetricsExp_t + ] + ############################################################################### ## @brief Function-pointer for zetDeviceGetDebugProperties if __use_win_types: @@ -880,6 +1099,29 @@ class _zet_device_dditable_t(Structure): ("pfnGetDebugProperties", c_void_p) ## _zetDeviceGetDebugProperties_t ] +############################################################################### +## @brief Function-pointer for zetDeviceGetConcurrentMetricGroupsExp +if __use_win_types: + _zetDeviceGetConcurrentMetricGroupsExp_t = WINFUNCTYPE( ze_result_t, zet_device_handle_t, c_ulong, *, *, * ) +else: + _zetDeviceGetConcurrentMetricGroupsExp_t = CFUNCTYPE( ze_result_t, zet_device_handle_t, c_ulong, *, *, * ) + +############################################################################### +## @brief Function-pointer for zetDeviceCreateMetricGroupsFromMetricsExp +if __use_win_types: + _zetDeviceCreateMetricGroupsFromMetricsExp_t = WINFUNCTYPE( ze_result_t, zet_device_handle_t, c_ulong, *, *, *, *, POINTER(zet_metric_group_handle_t) ) +else: + _zetDeviceCreateMetricGroupsFromMetricsExp_t = CFUNCTYPE( ze_result_t, zet_device_handle_t, c_ulong, *, *, *, *, POINTER(zet_metric_group_handle_t) ) + + +############################################################################### +## @brief Table of DeviceExp functions pointers +class _zet_device_exp_dditable_t(Structure): + _fields_ = [ + ("pfnGetConcurrentMetricGroupsExp", c_void_p), ## _zetDeviceGetConcurrentMetricGroupsExp_t + ("pfnCreateMetricGroupsFromMetricsExp", c_void_p) ## _zetDeviceCreateMetricGroupsFromMetricsExp_t + ] + ############################################################################### ## @brief Function-pointer for zetContextActivateMetricGroups if __use_win_types: @@ -978,13 +1220,21 @@ class _zet_kernel_dditable_t(Structure): else: _zetMetricGetProperties_t = CFUNCTYPE( ze_result_t, zet_metric_handle_t, POINTER(zet_metric_properties_t) ) +############################################################################### +## @brief Function-pointer for zetMetricCreateFromProgrammableExp2 +if __use_win_types: + _zetMetricCreateFromProgrammableExp2_t = WINFUNCTYPE( ze_result_t, zet_metric_programmable_exp_handle_t, c_ulong, POINTER(zet_metric_programmable_param_value_exp_t), c_char_p, c_char_p, POINTER(c_ulong), POINTER(zet_metric_handle_t) ) +else: + _zetMetricCreateFromProgrammableExp2_t = CFUNCTYPE( ze_result_t, zet_metric_programmable_exp_handle_t, c_ulong, POINTER(zet_metric_programmable_param_value_exp_t), c_char_p, c_char_p, POINTER(c_ulong), POINTER(zet_metric_handle_t) ) + ############################################################################### ## @brief Table of Metric functions pointers class _zet_metric_dditable_t(Structure): _fields_ = [ ("pfnGet", c_void_p), ## _zetMetricGet_t - ("pfnGetProperties", c_void_p) ## _zetMetricGetProperties_t + ("pfnGetProperties", c_void_p), ## _zetMetricGetProperties_t + ("pfnCreateFromProgrammableExp2", c_void_p) ## _zetMetricCreateFromProgrammableExp2_t ] ############################################################################### @@ -1041,6 +1291,13 @@ class _zet_metric_group_dditable_t(Structure): ("pfnCalculateMetricValues", c_void_p) ## _zetMetricGroupCalculateMetricValues_t ] +############################################################################### +## @brief Function-pointer for zetMetricGroupCreateExp +if __use_win_types: + _zetMetricGroupCreateExp_t = WINFUNCTYPE( ze_result_t, zet_device_handle_t, c_char_p, c_char_p, zet_metric_group_sampling_type_flags_t, POINTER(zet_metric_group_handle_t) ) +else: + _zetMetricGroupCreateExp_t = CFUNCTYPE( ze_result_t, zet_device_handle_t, c_char_p, c_char_p, zet_metric_group_sampling_type_flags_t, POINTER(zet_metric_group_handle_t) ) + ############################################################################### ## @brief Function-pointer for zetMetricGroupCalculateMultipleMetricValuesExp if __use_win_types: @@ -1069,13 +1326,6 @@ class _zet_metric_group_dditable_t(Structure): else: _zetMetricGroupCalculateMetricExportDataExp_t = CFUNCTYPE( ze_result_t, ze_driver_handle_t, zet_metric_group_calculation_type_t, c_size_t, POINTER(c_ubyte), POINTER(zet_metric_calculate_exp_desc_t), POINTER(c_ulong), POINTER(c_ulong), POINTER(c_ulong), POINTER(zet_typed_value_t) ) -############################################################################### -## @brief Function-pointer for zetMetricGroupCreateExp -if __use_win_types: - _zetMetricGroupCreateExp_t = WINFUNCTYPE( ze_result_t, zet_device_handle_t, c_char_p, c_char_p, zet_metric_group_sampling_type_flags_t, POINTER(zet_metric_group_handle_t) ) -else: - _zetMetricGroupCreateExp_t = CFUNCTYPE( ze_result_t, zet_device_handle_t, c_char_p, c_char_p, zet_metric_group_sampling_type_flags_t, POINTER(zet_metric_group_handle_t) ) - ############################################################################### ## @brief Function-pointer for zetMetricGroupAddMetricExp if __use_win_types: @@ -1109,11 +1359,11 @@ class _zet_metric_group_dditable_t(Structure): ## @brief Table of MetricGroupExp functions pointers class _zet_metric_group_exp_dditable_t(Structure): _fields_ = [ + ("pfnCreateExp", c_void_p), ## _zetMetricGroupCreateExp_t ("pfnCalculateMultipleMetricValuesExp", c_void_p), ## _zetMetricGroupCalculateMultipleMetricValuesExp_t ("pfnGetGlobalTimestampsExp", c_void_p), ## _zetMetricGroupGetGlobalTimestampsExp_t ("pfnGetExportDataExp", c_void_p), ## _zetMetricGroupGetExportDataExp_t ("pfnCalculateMetricExportDataExp", c_void_p), ## _zetMetricGroupCalculateMetricExportDataExp_t - ("pfnCreateExp", c_void_p), ## _zetMetricGroupCreateExp_t ("pfnAddMetricExp", c_void_p), ## _zetMetricGroupAddMetricExp_t ("pfnRemoveMetricExp", c_void_p), ## _zetMetricGroupRemoveMetricExp_t ("pfnCloseExp", c_void_p), ## _zetMetricGroupCloseExp_t @@ -1367,7 +1617,10 @@ class _zet_debug_dditable_t(Structure): class _zet_dditable_t(Structure): _fields_ = [ ("MetricProgrammableExp", _zet_metric_programmable_exp_dditable_t), + ("MetricTracerExp", _zet_metric_tracer_exp_dditable_t), + ("MetricDecoderExp", _zet_metric_decoder_exp_dditable_t), ("Device", _zet_device_dditable_t), + ("DeviceExp", _zet_device_exp_dditable_t), ("Context", _zet_context_dditable_t), ("CommandList", _zet_command_list_dditable_t), ("Module", _zet_module_dditable_t), @@ -1409,6 +1662,33 @@ def __init__(self, version : ze_api_version_t): self.zetMetricProgrammableGetParamInfoExp = _zetMetricProgrammableGetParamInfoExp_t(self.__dditable.MetricProgrammableExp.pfnGetParamInfoExp) self.zetMetricProgrammableGetParamValueInfoExp = _zetMetricProgrammableGetParamValueInfoExp_t(self.__dditable.MetricProgrammableExp.pfnGetParamValueInfoExp) + # call driver to get function pointers + _MetricTracerExp = _zet_metric_tracer_exp_dditable_t() + r = ze_result_v(self.__dll.zetGetMetricTracerExpProcAddrTable(version, byref(_MetricTracerExp))) + if r != ze_result_v.SUCCESS: + raise Exception(r) + self.__dditable.MetricTracerExp = _MetricTracerExp + + # attach function interface to function address + self.zetMetricTracerCreateExp = _zetMetricTracerCreateExp_t(self.__dditable.MetricTracerExp.pfnCreateExp) + self.zetMetricTracerDestroyExp = _zetMetricTracerDestroyExp_t(self.__dditable.MetricTracerExp.pfnDestroyExp) + self.zetMetricTracerEnableExp = _zetMetricTracerEnableExp_t(self.__dditable.MetricTracerExp.pfnEnableExp) + self.zetMetricTracerDisableExp = _zetMetricTracerDisableExp_t(self.__dditable.MetricTracerExp.pfnDisableExp) + self.zetMetricTracerReadDataExp = _zetMetricTracerReadDataExp_t(self.__dditable.MetricTracerExp.pfnReadDataExp) + self.zetMetricTracerDecodeExp = _zetMetricTracerDecodeExp_t(self.__dditable.MetricTracerExp.pfnDecodeExp) + + # call driver to get function pointers + _MetricDecoderExp = _zet_metric_decoder_exp_dditable_t() + r = ze_result_v(self.__dll.zetGetMetricDecoderExpProcAddrTable(version, byref(_MetricDecoderExp))) + if r != ze_result_v.SUCCESS: + raise Exception(r) + self.__dditable.MetricDecoderExp = _MetricDecoderExp + + # attach function interface to function address + self.zetMetricDecoderCreateExp = _zetMetricDecoderCreateExp_t(self.__dditable.MetricDecoderExp.pfnCreateExp) + self.zetMetricDecoderDestroyExp = _zetMetricDecoderDestroyExp_t(self.__dditable.MetricDecoderExp.pfnDestroyExp) + self.zetMetricDecoderGetDecodableMetricsExp = _zetMetricDecoderGetDecodableMetricsExp_t(self.__dditable.MetricDecoderExp.pfnGetDecodableMetricsExp) + # call driver to get function pointers _Device = _zet_device_dditable_t() r = ze_result_v(self.__dll.zetGetDeviceProcAddrTable(version, byref(_Device))) @@ -1419,6 +1699,17 @@ def __init__(self, version : ze_api_version_t): # attach function interface to function address self.zetDeviceGetDebugProperties = _zetDeviceGetDebugProperties_t(self.__dditable.Device.pfnGetDebugProperties) + # call driver to get function pointers + _DeviceExp = _zet_device_exp_dditable_t() + r = ze_result_v(self.__dll.zetGetDeviceExpProcAddrTable(version, byref(_DeviceExp))) + if r != ze_result_v.SUCCESS: + raise Exception(r) + self.__dditable.DeviceExp = _DeviceExp + + # attach function interface to function address + self.zetDeviceGetConcurrentMetricGroupsExp = _zetDeviceGetConcurrentMetricGroupsExp_t(self.__dditable.DeviceExp.pfnGetConcurrentMetricGroupsExp) + self.zetDeviceCreateMetricGroupsFromMetricsExp = _zetDeviceCreateMetricGroupsFromMetricsExp_t(self.__dditable.DeviceExp.pfnCreateMetricGroupsFromMetricsExp) + # call driver to get function pointers _Context = _zet_context_dditable_t() r = ze_result_v(self.__dll.zetGetContextProcAddrTable(version, byref(_Context))) @@ -1472,6 +1763,7 @@ def __init__(self, version : ze_api_version_t): # attach function interface to function address self.zetMetricGet = _zetMetricGet_t(self.__dditable.Metric.pfnGet) self.zetMetricGetProperties = _zetMetricGetProperties_t(self.__dditable.Metric.pfnGetProperties) + self.zetMetricCreateFromProgrammableExp2 = _zetMetricCreateFromProgrammableExp2_t(self.__dditable.Metric.pfnCreateFromProgrammableExp2) # call driver to get function pointers _MetricExp = _zet_metric_exp_dditable_t() @@ -1504,11 +1796,11 @@ def __init__(self, version : ze_api_version_t): self.__dditable.MetricGroupExp = _MetricGroupExp # attach function interface to function address + self.zetMetricGroupCreateExp = _zetMetricGroupCreateExp_t(self.__dditable.MetricGroupExp.pfnCreateExp) self.zetMetricGroupCalculateMultipleMetricValuesExp = _zetMetricGroupCalculateMultipleMetricValuesExp_t(self.__dditable.MetricGroupExp.pfnCalculateMultipleMetricValuesExp) self.zetMetricGroupGetGlobalTimestampsExp = _zetMetricGroupGetGlobalTimestampsExp_t(self.__dditable.MetricGroupExp.pfnGetGlobalTimestampsExp) self.zetMetricGroupGetExportDataExp = _zetMetricGroupGetExportDataExp_t(self.__dditable.MetricGroupExp.pfnGetExportDataExp) self.zetMetricGroupCalculateMetricExportDataExp = _zetMetricGroupCalculateMetricExportDataExp_t(self.__dditable.MetricGroupExp.pfnCalculateMetricExportDataExp) - self.zetMetricGroupCreateExp = _zetMetricGroupCreateExp_t(self.__dditable.MetricGroupExp.pfnCreateExp) self.zetMetricGroupAddMetricExp = _zetMetricGroupAddMetricExp_t(self.__dditable.MetricGroupExp.pfnAddMetricExp) self.zetMetricGroupRemoveMetricExp = _zetMetricGroupRemoveMetricExp_t(self.__dditable.MetricGroupExp.pfnRemoveMetricExp) self.zetMetricGroupCloseExp = _zetMetricGroupCloseExp_t(self.__dditable.MetricGroupExp.pfnCloseExp) diff --git a/include/zet_api.h b/include/zet_api.h index a202fde6..64e6e82f 100644 --- a/include/zet_api.h +++ b/include/zet_api.h @@ -5,7 +5,7 @@ * SPDX-License-Identifier: MIT * * @file zet_api.h - * @version v1.9-r1.9.3 + * @version v1.11-r1.11.0 * */ #ifndef _ZET_API_H @@ -99,6 +99,9 @@ typedef enum _zet_structure_type_t ZET_STRUCTURE_TYPE_METRIC_PROGRAMMABLE_EXP_PROPERTIES = 0x00010003, ///< ::zet_metric_programmable_exp_properties_t ZET_STRUCTURE_TYPE_METRIC_PROGRAMMABLE_PARAM_INFO_EXP = 0x00010004, ///< ::zet_metric_programmable_param_info_exp_t ZET_STRUCTURE_TYPE_METRIC_PROGRAMMABLE_PARAM_VALUE_INFO_EXP = 0x00010005, ///< ::zet_metric_programmable_param_value_info_exp_t + ZET_STRUCTURE_TYPE_METRIC_GROUP_TYPE_EXP = 0x00010006, ///< ::zet_metric_group_type_exp_t + ZET_STRUCTURE_TYPE_EXPORT_DMA_EXP_PROPERTIES = 0x00010007, ///< ::zet_export_dma_buf_exp_properties_t + ZET_STRUCTURE_TYPE_METRIC_TRACER_EXP_DESC = 0x00010008, ///< ::zet_metric_tracer_exp_desc_t ZET_STRUCTURE_TYPE_FORCE_UINT32 = 0x7fffffff } zet_structure_type_t; @@ -250,6 +253,22 @@ typedef struct _zet_profile_register_sequence_t zet_profile_register_sequence_t; /// @brief Forward-declare zet_tracer_exp_desc_t typedef struct _zet_tracer_exp_desc_t zet_tracer_exp_desc_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare zet_metric_tracer_exp_desc_t +typedef struct _zet_metric_tracer_exp_desc_t zet_metric_tracer_exp_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare zet_metric_entry_exp_t +typedef struct _zet_metric_entry_exp_t zet_metric_entry_exp_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare zet_metric_group_type_exp_t +typedef struct _zet_metric_group_type_exp_t zet_metric_group_type_exp_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare zet_export_dma_buf_exp_properties_t +typedef struct _zet_export_dma_buf_exp_properties_t zet_export_dma_buf_exp_properties_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Forward-declare zet_metric_global_timestamps_resolution_exp_t typedef struct _zet_metric_global_timestamps_resolution_exp_t zet_metric_global_timestamps_resolution_exp_t; @@ -266,6 +285,10 @@ typedef struct _zet_metric_programmable_exp_properties_t zet_metric_programmable /// @brief Forward-declare zet_value_uint64_range_exp_t typedef struct _zet_value_uint64_range_exp_t zet_value_uint64_range_exp_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare zet_value_fp64_range_exp_t +typedef struct _zet_value_fp64_range_exp_t zet_value_fp64_range_exp_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Forward-declare zet_metric_programmable_param_info_exp_t typedef struct _zet_metric_programmable_param_info_exp_t zet_metric_programmable_param_info_exp_t; @@ -652,6 +675,7 @@ typedef enum _zet_debug_memory_space_type_t { ZET_DEBUG_MEMORY_SPACE_TYPE_DEFAULT = 0, ///< default memory space (attribute may be omitted) ZET_DEBUG_MEMORY_SPACE_TYPE_SLM = 1, ///< shared local memory space (GPU-only) + ZET_DEBUG_MEMORY_SPACE_TYPE_ELF = 2, ///< ELF file memory space ZET_DEBUG_MEMORY_SPACE_TYPE_FORCE_UINT32 = 0x7fffffff } zet_debug_memory_space_type_t; @@ -687,7 +711,7 @@ typedef struct _zet_debug_memory_space_desc_t /// + `nullptr == desc` /// + `nullptr == buffer` /// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION -/// + `::ZET_DEBUG_MEMORY_SPACE_TYPE_SLM < desc->type` +/// + `::ZET_DEBUG_MEMORY_SPACE_TYPE_ELF < desc->type` /// - ::ZE_RESULT_ERROR_NOT_AVAILABLE /// + the thread is running or unavailable /// + the memory cannot be accessed from the supplied thread @@ -719,7 +743,7 @@ zetDebugReadMemory( /// + `nullptr == desc` /// + `nullptr == buffer` /// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION -/// + `::ZET_DEBUG_MEMORY_SPACE_TYPE_SLM < desc->type` +/// + `::ZET_DEBUG_MEMORY_SPACE_TYPE_ELF < desc->type` /// - ::ZE_RESULT_ERROR_NOT_AVAILABLE /// + the thread is running or unavailable /// + the memory cannot be accessed from the supplied thread @@ -932,6 +956,7 @@ typedef enum _zet_metric_group_sampling_type_flag_t { ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_EVENT_BASED = ZE_BIT(0), ///< Event based sampling ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_TIME_BASED = ZE_BIT(1), ///< Time based sampling + ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_EXP_TRACER_BASED = ZE_BIT(2), ///< Experimental Tracer based sampling ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_FORCE_UINT32 = 0x7fffffff } zet_metric_group_sampling_type_flag_t; @@ -987,9 +1012,16 @@ typedef enum _zet_metric_type_t ZET_METRIC_TYPE_FLAG = 5, ///< Metric type: flag ZET_METRIC_TYPE_RATIO = 6, ///< Metric type: ratio ZET_METRIC_TYPE_RAW = 7, ///< Metric type: raw - ZET_METRIC_TYPE_IP_EXP = 0x7ffffffe, ///< Metric type: instruction pointer. Deprecated, use + ZET_METRIC_TYPE_IP_EXP = 8, ///< Metric type: instruction pointer. Deprecated, use ///< ::ZET_METRIC_TYPE_IP. - ZET_METRIC_TYPE_IP = 0x7ffffffe, ///< Metric type: instruction pointer + ZET_METRIC_TYPE_IP = 9, ///< Metric type: instruction pointer + ZET_METRIC_TYPE_EVENT_EXP_TIMESTAMP = 10, ///< Metric type: event with only timestamp and value has no meaning + ZET_METRIC_TYPE_EVENT_EXP_START = 11, ///< Metric type: the first event of a start/end event pair + ZET_METRIC_TYPE_EVENT_EXP_END = 12, ///< Metric type: the second event of a start/end event pair + ZET_METRIC_TYPE_EXPORT_DMA_BUF = 0x7ffffffd, ///< Metric which exports linux dma_buf, which could be imported/mapped to + ///< the host process + ZET_METRIC_TYPE_EVENT_EXP_MONOTONIC_WRAPS_VALUE = 0x7ffffffe, ///< Metric type: value of the event is a monotonically increasing value + ///< that can wrap around ZET_METRIC_TYPE_FORCE_UINT32 = 0x7fffffff } zet_metric_type_t; @@ -1839,6 +1871,459 @@ zetTracerExpSetEnabled( ze_bool_t enable ///< [in] enable the tracer if true; disable if false ); +#if !defined(__GNUC__) +#pragma endregion +#endif +// Intel 'oneAPI' Level-Zero Tool Experimental Extension to get Concurrent Metric Groups +#if !defined(__GNUC__) +#pragma region concurrentMetricGroup +#endif +/////////////////////////////////////////////////////////////////////////////// +#ifndef ZET_CONCURRENT_METRIC_GROUPS_EXP_NAME +/// @brief Concurrent Metric Groups Experimental Extension Name +#define ZET_CONCURRENT_METRIC_GROUPS_EXP_NAME "ZET_experimental_concurrent_metric_groups" +#endif // ZET_CONCURRENT_METRIC_GROUPS_EXP_NAME + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Concurrent Metric Groups Experimental Extension Version(s) +typedef enum _zet_concurrent_metric_groups_exp_version_t +{ + ZET_CONCURRENT_METRIC_GROUPS_EXP_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 + ZET_CONCURRENT_METRIC_GROUPS_EXP_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 0 ), ///< latest known version + ZET_CONCURRENT_METRIC_GROUPS_EXP_VERSION_FORCE_UINT32 = 0x7fffffff + +} zet_concurrent_metric_groups_exp_version_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get sets of metric groups which could be collected concurrently. +/// +/// @details +/// - Re-arrange the input metric groups to provide sets of concurrent +/// metric groups. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hDevice` +/// + `nullptr == phMetricGroups` +ZE_APIEXPORT ze_result_t ZE_APICALL +zetDeviceGetConcurrentMetricGroupsExp( + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t metricGroupCount, ///< [in] metric group count + zet_metric_group_handle_t * phMetricGroups, ///< [in,out] metrics groups to be re-arranged to be sets of concurrent + ///< groups + uint32_t * pMetricGroupsCountPerConcurrentGroup, ///< [in,out][optional][*pConcurrentGroupCount] count of metric groups per + ///< concurrent group. + uint32_t * pConcurrentGroupCount ///< [out] number of concurrent groups. + ///< The value of this parameter could be used to determine the number of + ///< replays necessary. + ); + +#if !defined(__GNUC__) +#pragma endregion +#endif +// Intel 'oneAPI' Level-Zero Tool Experimental Extension for Metrics Tracer +#if !defined(__GNUC__) +#pragma region metricTracer +#endif +/////////////////////////////////////////////////////////////////////////////// +#ifndef ZET_METRICS_TRACER_EXP_NAME +/// @brief Metric Tracer Experimental Extension Name +#define ZET_METRICS_TRACER_EXP_NAME "ZET_experimental_metric_tracer" +#endif // ZET_METRICS_TRACER_EXP_NAME + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Metric Tracer Experimental Extension Version(s) +typedef enum _zet_metric_tracer_exp_version_t +{ + ZET_METRIC_TRACER_EXP_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 + ZET_METRIC_TRACER_EXP_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 0 ), ///< latest known version + ZET_METRIC_TRACER_EXP_VERSION_FORCE_UINT32 = 0x7fffffff + +} zet_metric_tracer_exp_version_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Handle of metric tracer's object +typedef struct _zet_metric_tracer_exp_handle_t *zet_metric_tracer_exp_handle_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Handle of metric decoder's object +typedef struct _zet_metric_decoder_exp_handle_t *zet_metric_decoder_exp_handle_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Metric tracer descriptor +typedef struct _zet_metric_tracer_exp_desc_t +{ + zet_structure_type_t stype; ///< [in] type of this structure + const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific + ///< structure (i.e. contains stype and pNext). + uint32_t notifyEveryNBytes; ///< [in,out] number of collected bytes after which notification event will + ///< be signaled. If the requested value is not supported exactly, then the + ///< driver may use a value that is the closest supported approximation and + ///< shall update this member during ::zetMetricTracerCreateExp. + +} zet_metric_tracer_exp_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Decoded metric entry +typedef struct _zet_metric_entry_exp_t +{ + zet_value_t value; ///< [out] value of the decodable metric entry or event. Number is + ///< meaningful based on the metric type. + uint64_t timeStamp; ///< [out] timestamp at which the event happened. + uint32_t metricIndex; ///< [out] index to the decodable metric handle in the input array + ///< (phMetric) in ::zetMetricTracerDecodeExp(). + ze_bool_t onSubdevice; ///< [out] True if the event occurred on a sub-device; false means the + ///< device on which the metric tracer was opened does not have + ///< sub-devices. + uint32_t subdeviceId; ///< [out] If onSubdevice is true, this gives the ID of the sub-device. + +} zet_metric_entry_exp_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Create a metric tracer for a device. +/// +/// @details +/// - The notification event must have been created from an event pool that +/// was created using ::ZE_EVENT_POOL_FLAG_HOST_VISIBLE flag. +/// - The duration of the signal event created from an event pool that was +/// created using ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP flag is undefined. +/// However, for consistency and orthogonality the event will report +/// correctly as signaled when used by other event API functionality. +/// - The application must **not** call this function from simultaneous +/// threads with the same device handle. +/// - The metric tracer is created in disabled state +/// - Metric groups must support sampling type +/// ZET_METRIC_SAMPLING_TYPE_EXP_FLAG_TRACER_BASED +/// - All metric groups must be first activated +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == phMetricGroups` +/// + `nullptr == desc` +/// + `nullptr == phMetricTracer` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +ZE_APIEXPORT ze_result_t ZE_APICALL +zetMetricTracerCreateExp( + zet_context_handle_t hContext, ///< [in] handle of the context object + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t metricGroupCount, ///< [in] metric group count + zet_metric_group_handle_t* phMetricGroups, ///< [in][range(0, metricGroupCount )] handles of the metric groups to + ///< trace + zet_metric_tracer_exp_desc_t* desc, ///< [in,out] metric tracer descriptor + ze_event_handle_t hNotificationEvent, ///< [in][optional] event used for report availability notification. Note: + ///< If buffer is not drained when the event it flagged, there is a risk of + ///< HW event buffer being overrun + zet_metric_tracer_exp_handle_t* phMetricTracer ///< [out] handle of the metric tracer + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Destroy a metric tracer. +/// +/// @details +/// - The application must **not** call this function from simultaneous +/// threads with the same metric tracer handle. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hMetricTracer` +ZE_APIEXPORT ze_result_t ZE_APICALL +zetMetricTracerDestroyExp( + zet_metric_tracer_exp_handle_t hMetricTracer ///< [in] handle of the metric tracer + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Start events collection +/// +/// @details +/// - Driver implementations must make this API call have as minimal +/// overhead as possible, to allow applications start/stop event +/// collection at any point during execution +/// - The application must **not** call this function from simultaneous +/// threads with the same metric tracer handle. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hMetricTracer` +ZE_APIEXPORT ze_result_t ZE_APICALL +zetMetricTracerEnableExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + ze_bool_t synchronous ///< [in] request synchronous behavior. Confirmation of successful + ///< asynchronous operation is done by calling ::zetMetricTracerReadDataExp() + ///< and checking the return status: ::ZE_RESULT_NOT_READY will be returned + ///< when the tracer is inactive. ::ZE_RESULT_SUCCESS will be returned + ///< when the tracer is active. + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Stop events collection +/// +/// @details +/// - Driver implementations must make this API call have as minimal +/// overhead as possible, to allow applications start/stop event +/// collection at any point during execution +/// - The application must **not** call this function from simultaneous +/// threads with the same metric tracer handle. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hMetricTracer` +ZE_APIEXPORT ze_result_t ZE_APICALL +zetMetricTracerDisableExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + ze_bool_t synchronous ///< [in] request synchronous behavior. Confirmation of successful + ///< asynchronous operation is done by calling ::zetMetricTracerReadDataExp() + ///< and checking the return status: ::ZE_RESULT_SUCCESS will be returned + ///< when the tracer is active or when it is inactive but still has data. + ///< ::ZE_RESULT_NOT_READY will be returned when the tracer is inactive and + ///< has no more data to be retrieved. + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Read data from the metric tracer +/// +/// @details +/// - The application must **not** call this function from simultaneous +/// threads with the same metric tracer handle. +/// - Data can be retrieved after tracer is disabled. When buffers are +/// drained ::ZE_RESULT_NOT_READY will be returned +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hMetricTracer` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pRawDataSize` +/// - ::ZE_RESULT_WARNING_DROPPED_DATA +/// + Metric tracer data may have been dropped. +/// - ::ZE_RESULT_NOT_READY +/// + Metric tracer is disabled and no data is available to read. +ZE_APIEXPORT ze_result_t ZE_APICALL +zetMetricTracerReadDataExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + size_t* pRawDataSize, ///< [in,out] pointer to size in bytes of raw data requested to read. + ///< if size is zero, then the driver will update the value with the total + ///< size in bytes needed for all data available. + ///< if size is non-zero, then driver will only retrieve that amount of + ///< data. + ///< if size is larger than size needed for all data, then driver will + ///< update the value with the actual size needed. + uint8_t* pRawData ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing tracer + ///< data in raw format + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Create a metric decoder for a given metric tracer. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hMetricTracer` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == phMetricDecoder` +ZE_APIEXPORT ze_result_t ZE_APICALL +zetMetricDecoderCreateExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + zet_metric_decoder_exp_handle_t* phMetricDecoder ///< [out] handle of the metric decoder object + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Destroy a metric decoder. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == phMetricDecoder` +ZE_APIEXPORT ze_result_t ZE_APICALL +zetMetricDecoderDestroyExp( + zet_metric_decoder_exp_handle_t phMetricDecoder ///< [in] handle of the metric decoder object + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Return the list of the decodable metrics from the decoder. +/// +/// @details +/// - The decodable metrics handles returned by this API are defined by the +/// metric groups in the tracer on which the decoder was created. +/// - The decodable metrics handles returned by this API are only valid to +/// decode metrics raw data with ::zetMetricTracerDecodeExp(). Decodable +/// metric handles are not valid to compare with metrics handles included +/// in metric groups. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hMetricDecoder` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCount` +/// + `nullptr == phMetrics` +ZE_APIEXPORT ze_result_t ZE_APICALL +zetMetricDecoderGetDecodableMetricsExp( + zet_metric_decoder_exp_handle_t hMetricDecoder, ///< [in] handle of the metric decoder object + uint32_t* pCount, ///< [in,out] pointer to number of decodable metric in the hMetricDecoder + ///< handle. If count is zero, then the driver shall + ///< update the value with the total number of decodable metrics available + ///< in the decoder. if count is greater than zero + ///< but less than the total number of decodable metrics available in the + ///< decoder, then only that number will be returned. + ///< if count is greater than the number of decodable metrics available in + ///< the decoder, then the driver shall update the + ///< value with the actual number of decodable metrics available. + zet_metric_handle_t* phMetrics ///< [in,out] [range(0, *pCount)] array of handles of decodable metrics in + ///< the hMetricDecoder handle provided. + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Decode raw events collected from a tracer. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == phMetricDecoder` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pRawDataSize` +/// + `nullptr == phMetrics` +/// + `nullptr == pSetCount` +/// + `nullptr == pMetricEntriesCount` +ZE_APIEXPORT ze_result_t ZE_APICALL +zetMetricTracerDecodeExp( + zet_metric_decoder_exp_handle_t phMetricDecoder, ///< [in] handle of the metric decoder object + size_t* pRawDataSize, ///< [in,out] size in bytes of raw data buffer. If pMetricEntriesCount is + ///< greater than zero but less than total number of + ///< decodable metrics available in the raw data buffer, then driver shall + ///< update this value with actual number of raw + ///< data bytes processed. + uint8_t* pRawData, ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing tracer + ///< data in raw format + uint32_t metricsCount, ///< [in] number of decodable metrics in the tracer for which the + ///< hMetricDecoder handle was provided. See + ///< ::zetMetricDecoderGetDecodableMetricsExp(). If metricCount is greater + ///< than zero but less than the number decodable + ///< metrics available in the raw data buffer, then driver shall only + ///< decode those. + zet_metric_handle_t* phMetrics, ///< [in] [range(0, metricsCount)] array of handles of decodable metrics in + ///< the decoder for which the hMetricDecoder handle was + ///< provided. Metrics handles are expected to be for decodable metrics, + ///< see ::zetMetricDecoderGetDecodableMetrics() + uint32_t* pSetCount, ///< [in,out] pointer to number of metric sets. If count is zero, then the + ///< driver shall update the value with the total + ///< number of metric sets to be decoded. If count is greater than the + ///< number available in the raw data buffer, then the + ///< driver shall update the value with the actual number of metric sets to + ///< be decoded. There is a 1:1 relation between + ///< the number of sets and sub-devices returned in the decoded entries. + uint32_t* pMetricEntriesCountPerSet, ///< [in,out][optional][range(0, *pSetCount)] buffer of metric entries + ///< counts per metric set, one value per set. + uint32_t* pMetricEntriesCount, ///< [in,out] pointer to the total number of metric entries decoded, for + ///< all metric sets. If count is zero, then the + ///< driver shall update the value with the total number of metric entries + ///< to be decoded. If count is greater than zero + ///< but less than the total number of metric entries available in the raw + ///< data, then user provided number will be decoded. + ///< If count is greater than the number available in the raw data buffer, + ///< then the driver shall update the value with + ///< the actual number of decodable metric entries decoded. If set to null, + ///< then driver will only update the value of + ///< pSetCount. + zet_metric_entry_exp_t* pMetricEntries ///< [in,out][optional][range(0, *pMetricEntriesCount)] buffer containing + ///< decoded metric entries + ); + +#if !defined(__GNUC__) +#pragma endregion +#endif +// Intel 'oneAPI' Level-Zero Tool Experimental Extension for Metrics/Metric Groups which export Memory +#if !defined(__GNUC__) +#pragma region metricExportMemory +#endif +/////////////////////////////////////////////////////////////////////////////// +/// @brief Metric group type +typedef uint32_t zet_metric_group_type_exp_flags_t; +typedef enum _zet_metric_group_type_exp_flag_t +{ + ZET_METRIC_GROUP_TYPE_EXP_FLAG_EXPORT_DMA_BUF = ZE_BIT(0), ///< Metric group and metrics exports memory using linux dma-buf, which + ///< could be imported/mapped to the host process. Properties of the + ///< dma_buf could be queried using ::zet_export_dma_buf_exp_properties_t. + ZET_METRIC_GROUP_TYPE_EXP_FLAG_USER_CREATED = ZE_BIT(1), ///< Metric group created using ::zetMetricGroupCreateExp + ZET_METRIC_GROUP_TYPE_EXP_FLAG_OTHER = ZE_BIT(2), ///< Metric group which has a collection of metrics + ZET_METRIC_GROUP_TYPE_EXP_FLAG_FORCE_UINT32 = 0x7fffffff + +} zet_metric_group_type_exp_flag_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Query the metric group type using `pNext` of +/// ::zet_metric_group_properties_t +typedef struct _zet_metric_group_type_exp_t +{ + zet_structure_type_t stype; ///< [in] type of this structure + void* pNext; ///< [in,out][optional] must be null or a pointer to an extension-specific + ///< structure (i.e. contains stype and pNext). + zet_metric_group_type_exp_flags_t type; ///< [out] metric group type. + ///< returns a combination of ::zet_metric_group_type_exp_flags_t. + +} zet_metric_group_type_exp_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported dma_buf properties queried using `pNext` of +/// ::zet_metric_group_properties_t or ::zet_metric_properties_t +typedef struct _zet_export_dma_buf_exp_properties_t +{ + zet_structure_type_t stype; ///< [in] type of this structure + void* pNext; ///< [in,out][optional] must be null or a pointer to an extension-specific + ///< structure (i.e. contains stype and pNext). + int fd; ///< [out] the file descriptor handle that could be used to import the + ///< memory by the host process. + size_t size; ///< [out] size in bytes of the dma_buf + +} zet_export_dma_buf_exp_properties_t; + #if !defined(__GNUC__) #pragma endregion #endif @@ -2141,8 +2626,8 @@ zetMetricGroupCalculateMetricExportDataExp( /// @brief Programmable Metrics Experimental Extension Version(s) typedef enum _zet_metric_programmable_exp_version_t { - ZET_METRIC_PROGRAMMABLE_EXP_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 - ZET_METRIC_PROGRAMMABLE_EXP_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 0 ), ///< latest known version + ZET_METRIC_PROGRAMMABLE_EXP_VERSION_1_1 = ZE_MAKE_VERSION( 1, 1 ), ///< version 1.1 + ZET_METRIC_PROGRAMMABLE_EXP_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 1 ), ///< latest known version ZET_METRIC_PROGRAMMABLE_EXP_VERSION_FORCE_UINT32 = 0x7fffffff } zet_metric_programmable_exp_version_t; @@ -2184,10 +2669,16 @@ typedef enum _zet_metric_programmable_exp_version_t #endif // ZET_MAX_METRIC_PROGRAMMABLE_PARAMETER_NAME_EXP /////////////////////////////////////////////////////////////////////////////// -#ifndef ZET_MAX_VALUE_INFO_CSTRING_EXP -/// @brief Maximum value information string size -#define ZET_MAX_VALUE_INFO_CSTRING_EXP 128 -#endif // ZET_MAX_VALUE_INFO_CSTRING_EXP +#ifndef ZET_MAX_METRIC_PROGRAMMABLE_VALUE_DESCRIPTION_EXP +/// @brief Maximum value for programmable value description +#define ZET_MAX_METRIC_PROGRAMMABLE_VALUE_DESCRIPTION_EXP 128 +#endif // ZET_MAX_METRIC_PROGRAMMABLE_VALUE_DESCRIPTION_EXP + +/////////////////////////////////////////////////////////////////////////////// +#ifndef ZE_MAX_METRIC_GROUP_NAME_PREFIX +/// @brief Maximum value metric group name prefix +#define ZE_MAX_METRIC_GROUP_NAME_PREFIX 64 +#endif // ZE_MAX_METRIC_GROUP_NAME_PREFIX /////////////////////////////////////////////////////////////////////////////// /// @brief Handle of metric programmable's object @@ -2224,6 +2715,7 @@ typedef enum _zet_metric_programmable_param_type_exp_t ///< instance_count. ZET_METRIC_PROGRAMMABLE_PARAM_TYPE_EXP_NORMALIZATION_AVERAGE = 3, ///< Produces normalization using raw_metric / HW instance_count. ZET_METRIC_PROGRAMMABLE_PARAM_TYPE_EXP_NORMALIZATION_RATE = 4, ///< Produces normalization average using raw_metric / timestamp. + ZET_METRIC_PROGRAMMABLE_PARAM_TYPE_EXP_NORMALIZATION_BYTES = 5, ///< Produces normalization average using raw_metric * n bytes. ZET_METRIC_PROGRAMMABLE_PARAM_TYPE_EXP_FORCE_UINT32 = 0x7fffffff } zet_metric_programmable_param_type_exp_t; @@ -2237,10 +2729,10 @@ typedef enum _zet_value_info_type_exp_t ZET_VALUE_INFO_TYPE_EXP_FLOAT32 = 2, ///< 32-bit floating-point ZET_VALUE_INFO_TYPE_EXP_FLOAT64 = 3, ///< 64-bit floating-point ZET_VALUE_INFO_TYPE_EXP_BOOL8 = 4, ///< 8-bit boolean - ZET_VALUE_INFO_TYPE_EXP_CSTRING = 5, ///< C string - ZET_VALUE_INFO_TYPE_EXP_UINT8 = 6, ///< 8-bit unsigned-integer - ZET_VALUE_INFO_TYPE_EXP_UINT16 = 7, ///< 16-bit unsigned-integer - ZET_VALUE_INFO_TYPE_EXP_UINT64_RANGE = 8, ///< 64-bit unsigned-integer range (minimum and maximum) + ZET_VALUE_INFO_TYPE_EXP_UINT8 = 5, ///< 8-bit unsigned-integer + ZET_VALUE_INFO_TYPE_EXP_UINT16 = 6, ///< 16-bit unsigned-integer + ZET_VALUE_INFO_TYPE_EXP_UINT64_RANGE = 7, ///< 64-bit unsigned-integer range (minimum and maximum) + ZET_VALUE_INFO_TYPE_EXP_FLOAT64_RANGE = 8, ///< 64-bit floating point range (minimum and maximum) ZET_VALUE_INFO_TYPE_EXP_FORCE_UINT32 = 0x7fffffff } zet_value_info_type_exp_t; @@ -2250,10 +2742,19 @@ typedef enum _zet_value_info_type_exp_t typedef struct _zet_value_uint64_range_exp_t { uint64_t ui64Min; ///< [out] minimum value of the range - uint64_t ui64Max; ///< [out] max value of the range + uint64_t ui64Max; ///< [out] maximum value of the range } zet_value_uint64_range_exp_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Value info of type float64 range +typedef struct _zet_value_fp64_range_exp_t +{ + double fp64Min; ///< [out] minimum value of the range + double fp64Max; ///< [out] maximum value of the range + +} zet_value_fp64_range_exp_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Union of value information typedef union _zet_value_info_exp_t @@ -2265,8 +2766,8 @@ typedef union _zet_value_info_exp_t ze_bool_t b8; ///< [out] 8-bit boolean uint8_t ui8; ///< [out] 8-bit unsigned integer uint16_t ui16; ///< [out] 16-bit unsigned integer - char cString[ZET_MAX_VALUE_INFO_CSTRING_EXP]; ///< [out] cString zet_value_uint64_range_exp_t ui64Range; ///< [out] minimum and maximum value of the range + zet_value_fp64_range_exp_t fp64Range; ///< [out] minimum and maximum value of the range } zet_value_info_exp_t; @@ -2275,7 +2776,7 @@ typedef union _zet_value_info_exp_t typedef struct _zet_metric_programmable_param_info_exp_t { zet_structure_type_t stype; ///< [in] type of this structure - const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific + void* pNext; ///< [in,out][optional] must be null or a pointer to an extension-specific ///< structure (i.e. contains stype and pNext). zet_metric_programmable_param_type_exp_t type; ///< [out] programmable parameter type char name[ZET_MAX_METRIC_PROGRAMMABLE_PARAMETER_NAME_EXP]; ///< [out] metric programmable parameter name @@ -2290,9 +2791,10 @@ typedef struct _zet_metric_programmable_param_info_exp_t typedef struct _zet_metric_programmable_param_value_info_exp_t { zet_structure_type_t stype; ///< [in] type of this structure - const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific + void* pNext; ///< [in,out][optional] must be null or a pointer to an extension-specific ///< structure (i.e. contains stype and pNext). zet_value_info_exp_t valueInfo; ///< [out] information about the parameter value + char description[ZET_MAX_METRIC_PROGRAMMABLE_VALUE_DESCRIPTION_EXP]; ///< [out] description about the value } zet_metric_programmable_param_value_info_exp_t; @@ -2431,7 +2933,7 @@ zetMetricProgrammableGetParamValueInfoExp( /// - If parameterCount = 0, the default value of the metric programmable /// would be used for all parameters. /// - The implementation can post-fix a C string to the metric name and -/// description, based on the parmeter values chosen. +/// description, based on the parameter values chosen. /// - ::zetMetricProgrammableGetParamInfoExp() returns a list of parameters /// in a defined order. /// - Therefore, the list of values passed in to the API should respect the @@ -2451,6 +2953,48 @@ zetMetricProgrammableGetParamValueInfoExp( /// + `nullptr == pDescription` /// + `nullptr == pMetricHandleCount` ZE_APIEXPORT ze_result_t ZE_APICALL +zetMetricCreateFromProgrammableExp2( + zet_metric_programmable_exp_handle_t hMetricProgrammable, ///< [in] handle of the metric programmable + uint32_t parameterCount, ///< [in] Count of parameters to set. + zet_metric_programmable_param_value_exp_t* pParameterValues, ///< [in] list of parameter values to be set. + const char* pName, ///< [in] pointer to metric name to be used. Must point to a + ///< null-terminated character array no longer than ::ZET_MAX_METRIC_NAME. + const char* pDescription, ///< [in] pointer to metric description to be used. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_DESCRIPTION. + uint32_t* pMetricHandleCount, ///< [in,out] Pointer to the number of metric handles. + ///< if count is zero, then the driver shall update the value with the + ///< number of metric handles available for this programmable. + ///< if count is greater than the number of metric handles available, then + ///< the driver shall update the value with the correct number of metric + ///< handles available. + zet_metric_handle_t* phMetricHandles ///< [in,out][optional][range(0,*pMetricHandleCount)] array of handle of metrics. + ///< if count is less than the number of metrics available, then driver + ///< shall only retrieve that number of metric handles. + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Create metric handles by applying parameter values on the metric +/// programmable handle. +/// +/// @details +/// - This API is deprecated. Please use +/// ::zetMetricCreateFromProgrammableExp2() +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hMetricProgrammable` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pParameterValues` +/// + `nullptr == pName` +/// + `nullptr == pDescription` +/// + `nullptr == pMetricHandleCount` +ZE_APIEXPORT ze_result_t ZE_APICALL zetMetricCreateFromProgrammableExp( zet_metric_programmable_exp_handle_t hMetricProgrammable, ///< [in] handle of the metric programmable zet_metric_programmable_param_value_exp_t* pParameterValues, ///< [in] list of parameter values to be set. @@ -2471,12 +3015,59 @@ zetMetricCreateFromProgrammableExp( ///< shall only retrieve that number of metric handles. ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Create multiple metric group handles from metric handles. +/// +/// @details +/// - Creates multiple metric groups from metrics which were created using +/// ::zetMetricCreateFromProgrammableExp2(). +/// - Metrics whose Hardware resources do not overlap are added to same +/// metric group. +/// - The metric groups created using this API are managed by the +/// application and cannot be retrieved using ::zetMetricGroupGet(). +/// - The created metric groups are ready for activation and collection. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hDevice` +/// + `nullptr == phMetrics` +/// - ::ZE_RESULT_ERROR_INVALID_ARGUMENT +/// + metricGroupCount is lesser than the number of metric group handles that could be created. +ZE_APIEXPORT ze_result_t ZE_APICALL +zetDeviceCreateMetricGroupsFromMetricsExp( + zet_device_handle_t hDevice, ///< [in] handle of the device. + uint32_t metricCount, ///< [in] number of metric handles. + zet_metric_handle_t * phMetrics, ///< [in] metric handles to be added to the metric groups. + const char * pMetricGroupNamePrefix, ///< [in] prefix to the name created for the metric groups. Must point to a + ///< null-terminated character array no longer than + ///< ZEX_MAX_METRIC_GROUP_NAME_PREFIX. + const char * pDescription, ///< [in] pointer to description of the metric groups. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_GROUP_DESCRIPTION. + uint32_t * pMetricGroupCount, ///< [in,out] pointer to the number of metric group handles to be created. + ///< if pMetricGroupCount is zero, then the driver shall update the value + ///< with the maximum possible number of metric group handles that could be created. + ///< if pMetricGroupCount is greater than the number of metric group + ///< handles that could be created, then the driver shall update the value + ///< with the correct number of metric group handles generated. + ///< if pMetricGroupCount is lesser than the number of metric group handles + ///< that could be created, then ::ZE_RESULT_ERROR_INVALID_ARGUMENT is returned. + zet_metric_group_handle_t* phMetricGroup ///< [in,out][optional][range(0, *pMetricGroupCount)] array of handle of + ///< metric group handles. + ///< Created Metric group handles. + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Create metric group handle. /// /// @details -/// - Metrics from ::zetMetricCreateFromProgrammableExp() could be added to -/// the created metric group. +/// - This API is deprecated. Please use +/// ::zetCreateMetricGroupsFromMetricsExp() /// /// @returns /// - ::ZE_RESULT_SUCCESS @@ -2491,7 +3082,7 @@ zetMetricCreateFromProgrammableExp( /// + `nullptr == pDescription` /// + `nullptr == phMetricGroup` /// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION -/// + `0x3 < samplingType` +/// + `0x7 < samplingType` ZE_APIEXPORT ze_result_t ZE_APICALL zetMetricGroupCreateExp( zet_device_handle_t hDevice, ///< [in] handle of the device @@ -2611,11 +3202,11 @@ zetMetricGroupCloseExp( /// @brief Destroy a metric group created using ::zetMetricGroupCreateExp. /// /// @details -/// - Metric handles created using ::zetMetricCreateFromProgrammableExp and +/// - Metric handles created using ::zetMetricCreateFromProgrammableExp2 and /// are part of the metricGroup are not destroyed. /// - It is necessary to call ::zetMetricDestroyExp for each of the metric -/// handles (created from ::zetMetricCreateFromProgrammableExp) to destroy -/// them. +/// handles (created from ::zetMetricCreateFromProgrammableExp2) to +/// destroy them. /// /// @returns /// - ::ZE_RESULT_SUCCESS @@ -2635,7 +3226,7 @@ zetMetricGroupDestroyExp( ); /////////////////////////////////////////////////////////////////////////////// -/// @brief Destroy a metric created using ::zetMetricCreateFromProgrammableExp. +/// @brief Destroy a metric created using ::zetMetricCreateFromProgrammableExp2. /// /// @details /// - If a metric is added to a metric group, the metric has to be removed diff --git a/include/zet_ddi.h b/include/zet_ddi.h index 876df64a..9cbf1700 100644 --- a/include/zet_ddi.h +++ b/include/zet_ddi.h @@ -5,7 +5,7 @@ * SPDX-License-Identifier: MIT * * @file zet_ddi.h - * @version v1.9-r1.9.3 + * @version v1.11-r1.11.0 * */ #ifndef _ZET_DDI_H @@ -83,6 +83,146 @@ typedef ze_result_t (ZE_APICALL *zet_pfnGetMetricProgrammableExpProcAddrTable_t) zet_metric_programmable_exp_dditable_t* ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zetMetricTracerCreateExp +typedef ze_result_t (ZE_APICALL *zet_pfnMetricTracerCreateExp_t)( + zet_context_handle_t, + zet_device_handle_t, + uint32_t, + zet_metric_group_handle_t*, + zet_metric_tracer_exp_desc_t*, + ze_event_handle_t, + zet_metric_tracer_exp_handle_t* + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zetMetricTracerDestroyExp +typedef ze_result_t (ZE_APICALL *zet_pfnMetricTracerDestroyExp_t)( + zet_metric_tracer_exp_handle_t + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zetMetricTracerEnableExp +typedef ze_result_t (ZE_APICALL *zet_pfnMetricTracerEnableExp_t)( + zet_metric_tracer_exp_handle_t, + ze_bool_t + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zetMetricTracerDisableExp +typedef ze_result_t (ZE_APICALL *zet_pfnMetricTracerDisableExp_t)( + zet_metric_tracer_exp_handle_t, + ze_bool_t + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zetMetricTracerReadDataExp +typedef ze_result_t (ZE_APICALL *zet_pfnMetricTracerReadDataExp_t)( + zet_metric_tracer_exp_handle_t, + size_t*, + uint8_t* + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zetMetricTracerDecodeExp +typedef ze_result_t (ZE_APICALL *zet_pfnMetricTracerDecodeExp_t)( + zet_metric_decoder_exp_handle_t, + size_t*, + uint8_t*, + uint32_t, + zet_metric_handle_t*, + uint32_t*, + uint32_t*, + uint32_t*, + zet_metric_entry_exp_t* + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Table of MetricTracerExp functions pointers +typedef struct _zet_metric_tracer_exp_dditable_t +{ + zet_pfnMetricTracerCreateExp_t pfnCreateExp; + zet_pfnMetricTracerDestroyExp_t pfnDestroyExp; + zet_pfnMetricTracerEnableExp_t pfnEnableExp; + zet_pfnMetricTracerDisableExp_t pfnDisableExp; + zet_pfnMetricTracerReadDataExp_t pfnReadDataExp; + zet_pfnMetricTracerDecodeExp_t pfnDecodeExp; +} zet_metric_tracer_exp_dditable_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's MetricTracerExp table +/// with current process' addresses +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION +ZE_DLLEXPORT ze_result_t ZE_APICALL +zetGetMetricTracerExpProcAddrTable( + ze_api_version_t version, ///< [in] API version requested + zet_metric_tracer_exp_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zetGetMetricTracerExpProcAddrTable +typedef ze_result_t (ZE_APICALL *zet_pfnGetMetricTracerExpProcAddrTable_t)( + ze_api_version_t, + zet_metric_tracer_exp_dditable_t* + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zetMetricDecoderCreateExp +typedef ze_result_t (ZE_APICALL *zet_pfnMetricDecoderCreateExp_t)( + zet_metric_tracer_exp_handle_t, + zet_metric_decoder_exp_handle_t* + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zetMetricDecoderDestroyExp +typedef ze_result_t (ZE_APICALL *zet_pfnMetricDecoderDestroyExp_t)( + zet_metric_decoder_exp_handle_t + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zetMetricDecoderGetDecodableMetricsExp +typedef ze_result_t (ZE_APICALL *zet_pfnMetricDecoderGetDecodableMetricsExp_t)( + zet_metric_decoder_exp_handle_t, + uint32_t*, + zet_metric_handle_t* + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Table of MetricDecoderExp functions pointers +typedef struct _zet_metric_decoder_exp_dditable_t +{ + zet_pfnMetricDecoderCreateExp_t pfnCreateExp; + zet_pfnMetricDecoderDestroyExp_t pfnDestroyExp; + zet_pfnMetricDecoderGetDecodableMetricsExp_t pfnGetDecodableMetricsExp; +} zet_metric_decoder_exp_dditable_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's MetricDecoderExp table +/// with current process' addresses +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION +ZE_DLLEXPORT ze_result_t ZE_APICALL +zetGetMetricDecoderExpProcAddrTable( + ze_api_version_t version, ///< [in] API version requested + zet_metric_decoder_exp_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zetGetMetricDecoderExpProcAddrTable +typedef ze_result_t (ZE_APICALL *zet_pfnGetMetricDecoderExpProcAddrTable_t)( + ze_api_version_t, + zet_metric_decoder_exp_dditable_t* + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for zetDeviceGetDebugProperties typedef ze_result_t (ZE_APICALL *zet_pfnDeviceGetDebugProperties_t)( @@ -119,6 +259,58 @@ typedef ze_result_t (ZE_APICALL *zet_pfnGetDeviceProcAddrTable_t)( zet_device_dditable_t* ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zetDeviceGetConcurrentMetricGroupsExp +typedef ze_result_t (ZE_APICALL *zet_pfnDeviceGetConcurrentMetricGroupsExp_t)( + zet_device_handle_t, + uint32_t, + zet_metric_group_handle_t *, + uint32_t *, + uint32_t * + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zetDeviceCreateMetricGroupsFromMetricsExp +typedef ze_result_t (ZE_APICALL *zet_pfnDeviceCreateMetricGroupsFromMetricsExp_t)( + zet_device_handle_t, + uint32_t, + zet_metric_handle_t *, + const char *, + const char *, + uint32_t *, + zet_metric_group_handle_t* + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Table of DeviceExp functions pointers +typedef struct _zet_device_exp_dditable_t +{ + zet_pfnDeviceGetConcurrentMetricGroupsExp_t pfnGetConcurrentMetricGroupsExp; + zet_pfnDeviceCreateMetricGroupsFromMetricsExp_t pfnCreateMetricGroupsFromMetricsExp; +} zet_device_exp_dditable_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's DeviceExp table +/// with current process' addresses +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION +ZE_DLLEXPORT ze_result_t ZE_APICALL +zetGetDeviceExpProcAddrTable( + ze_api_version_t version, ///< [in] API version requested + zet_device_exp_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zetGetDeviceExpProcAddrTable +typedef ze_result_t (ZE_APICALL *zet_pfnGetDeviceExpProcAddrTable_t)( + ze_api_version_t, + zet_device_exp_dditable_t* + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for zetContextActivateMetricGroups typedef ze_result_t (ZE_APICALL *zet_pfnContextActivateMetricGroups_t)( @@ -309,12 +501,25 @@ typedef ze_result_t (ZE_APICALL *zet_pfnMetricGetProperties_t)( zet_metric_properties_t* ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zetMetricCreateFromProgrammableExp2 +typedef ze_result_t (ZE_APICALL *zet_pfnMetricCreateFromProgrammableExp2_t)( + zet_metric_programmable_exp_handle_t, + uint32_t, + zet_metric_programmable_param_value_exp_t*, + const char*, + const char*, + uint32_t*, + zet_metric_handle_t* + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Table of Metric functions pointers typedef struct _zet_metric_dditable_t { zet_pfnMetricGet_t pfnGet; zet_pfnMetricGetProperties_t pfnGetProperties; + zet_pfnMetricCreateFromProgrammableExp2_t pfnCreateFromProgrammableExp2; } zet_metric_dditable_t; /////////////////////////////////////////////////////////////////////////////// @@ -444,6 +649,16 @@ typedef ze_result_t (ZE_APICALL *zet_pfnGetMetricGroupProcAddrTable_t)( zet_metric_group_dditable_t* ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zetMetricGroupCreateExp +typedef ze_result_t (ZE_APICALL *zet_pfnMetricGroupCreateExp_t)( + zet_device_handle_t, + const char*, + const char*, + zet_metric_group_sampling_type_flags_t, + zet_metric_group_handle_t* + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for zetMetricGroupCalculateMultipleMetricValuesExp typedef ze_result_t (ZE_APICALL *zet_pfnMetricGroupCalculateMultipleMetricValuesExp_t)( @@ -490,16 +705,6 @@ typedef ze_result_t (ZE_APICALL *zet_pfnMetricGroupCalculateMetricExportDataExp_ zet_typed_value_t* ); -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for zetMetricGroupCreateExp -typedef ze_result_t (ZE_APICALL *zet_pfnMetricGroupCreateExp_t)( - zet_device_handle_t, - const char*, - const char*, - zet_metric_group_sampling_type_flags_t, - zet_metric_group_handle_t* - ); - /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for zetMetricGroupAddMetricExp typedef ze_result_t (ZE_APICALL *zet_pfnMetricGroupAddMetricExp_t)( @@ -532,11 +737,11 @@ typedef ze_result_t (ZE_APICALL *zet_pfnMetricGroupDestroyExp_t)( /// @brief Table of MetricGroupExp functions pointers typedef struct _zet_metric_group_exp_dditable_t { + zet_pfnMetricGroupCreateExp_t pfnCreateExp; zet_pfnMetricGroupCalculateMultipleMetricValuesExp_t pfnCalculateMultipleMetricValuesExp; zet_pfnMetricGroupGetGlobalTimestampsExp_t pfnGetGlobalTimestampsExp; zet_pfnMetricGroupGetExportDataExp_t pfnGetExportDataExp; zet_pfnMetricGroupCalculateMetricExportDataExp_t pfnCalculateMetricExportDataExp; - zet_pfnMetricGroupCreateExp_t pfnCreateExp; zet_pfnMetricGroupAddMetricExp_t pfnAddMetricExp; zet_pfnMetricGroupRemoveMetricExp_t pfnRemoveMetricExp; zet_pfnMetricGroupCloseExp_t pfnCloseExp; @@ -943,7 +1148,10 @@ typedef ze_result_t (ZE_APICALL *zet_pfnGetDebugProcAddrTable_t)( typedef struct _zet_dditable_t { zet_metric_programmable_exp_dditable_t MetricProgrammableExp; + zet_metric_tracer_exp_dditable_t MetricTracerExp; + zet_metric_decoder_exp_dditable_t MetricDecoderExp; zet_device_dditable_t Device; + zet_device_exp_dditable_t DeviceExp; zet_context_dditable_t Context; zet_command_list_dditable_t CommandList; zet_module_dditable_t Module; diff --git a/scripts/templates/ldrddi.cpp.mako b/scripts/templates/ldrddi.cpp.mako index 8410f5c6..f4f14d10 100644 --- a/scripts/templates/ldrddi.cpp.mako +++ b/scripts/templates/ldrddi.cpp.mako @@ -38,7 +38,7 @@ namespace loader arrays_to_delete = [] %> - %if re.match(r"Init", obj['name']): + %if re.match(r"Init", obj['name']) and not re.match(r"\w+InitDrivers$", th.make_func_name(n, tags, obj)): bool atLeastOneDriverValid = false; %if namespace != "zes": for( auto& drv : loader::context->zeDrivers ) @@ -56,7 +56,7 @@ namespace loader if(!atLeastOneDriverValid) result=ZE_RESULT_ERROR_UNINITIALIZED; - %elif re.match(r"\w+DriverGet$", th.make_func_name(n, tags, obj)): + %elif re.match(r"\w+DriverGet$", th.make_func_name(n, tags, obj)) or re.match(r"\w+InitDrivers$", th.make_func_name(n, tags, obj)): uint32_t total_driver_handle_count = 0; %if namespace != "zes": @@ -65,15 +65,26 @@ namespace loader for( auto& drv : *loader::context->sysmanInstanceDrivers ) %endif { + %if not re.match(r"\w+InitDrivers$", th.make_func_name(n, tags, obj)): if(drv.initStatus != ZE_RESULT_SUCCESS) continue; + %else: + if (!drv.dditable.${n}.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}) { + drv.initStatus = ${X}_RESULT_ERROR_UNINITIALIZED; + continue; + } + %endif if( ( 0 < *${obj['params'][0]['name']} ) && ( *${obj['params'][0]['name']} == total_driver_handle_count)) break; uint32_t library_driver_handle_count = 0; + %if re.match(r"\w+InitDrivers$", th.make_func_name(n, tags, obj)): + result = drv.dditable.${n}.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}( &library_driver_handle_count, nullptr, desc ); + %else: result = drv.dditable.${n}.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}( &library_driver_handle_count, nullptr ); + %endif if( ${X}_RESULT_SUCCESS != result ) { // If Get Drivers fails with Uninitialized, then update the driver init status to prevent reporting this driver in the next get call. if (${X}_RESULT_ERROR_UNINITIALIZED == result) { @@ -87,9 +98,15 @@ namespace loader if( total_driver_handle_count + library_driver_handle_count > *${obj['params'][0]['name']}) { library_driver_handle_count = *${obj['params'][0]['name']} - total_driver_handle_count; } + %if re.match(r"\w+InitDrivers$", th.make_func_name(n, tags, obj)): + result = drv.dditable.${n}.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}( &library_driver_handle_count, &${obj['params'][1]['name']}[ total_driver_handle_count ], desc ); + %else: result = drv.dditable.${n}.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}( &library_driver_handle_count, &${obj['params'][1]['name']}[ total_driver_handle_count ] ); + %endif if( ${X}_RESULT_SUCCESS != result ) break; + drv.driverInuse = true; + try { for( uint32_t i = 0; i < library_driver_handle_count; ++i ) { @@ -347,6 +364,13 @@ ${tbl['export']['name']}( atLeastOneDriverValid = true; else drv.initStatus = getTableResult; + %if namespace != "zes": + %if tbl['name'] == "Global": + if (drv.dditable.ze.Global.pfnInitDrivers) { + loader::context->initDriversSupport = true; + } + %endif + %endif %else: result = getTable( version, &drv.dditable.${n}.${tbl['name']}); %endif diff --git a/scripts/templates/libapi.cpp.mako b/scripts/templates/libapi.cpp.mako index f61ae4a0..db511935 100644 --- a/scripts/templates/libapi.cpp.mako +++ b/scripts/templates/libapi.cpp.mako @@ -58,7 +58,7 @@ ${th.make_func_name(n, tags, obj)}( static ${x}_result_t result = ${X}_RESULT_SUCCESS; %if re.match("zes", n): std::call_once(${x}_lib::context->initOnceSysMan, [flags]() { - result = ${x}_lib::context->Init(flags, true); + result = ${x}_lib::context->Init(flags, true, nullptr); }); @@ -79,9 +79,41 @@ ${th.make_func_name(n, tags, obj)}( return ${th.make_pfn_name(n, tags, obj)}( ${", ".join(th.make_param_lines(n, tags, obj, format=["name"]))} ); } +%else: +%if re.match("InitDrivers", obj['name']): + std::call_once(${x}_lib::context->initOnceDrivers, []() { + ze_init_flags_t all_enabled = UINT32_MAX; + ze_init_driver_type_desc_t all_enabled_desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; + all_enabled_desc.pNext = nullptr; + all_enabled_desc.flags = UINT32_MAX; + result = ${x}_lib::context->Init(all_enabled, false, &all_enabled_desc); + return result; + }); + + if(ze_lib::context->inTeardown) { + return ${X}_RESULT_ERROR_UNINITIALIZED; + } + + auto ${th.make_pfn_name(n, tags, obj)} = ${x}_lib::context->${n}DdiTable.load()->${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)}; + if( nullptr == ${th.make_pfn_name(n, tags, obj)} ) { + if(!ze_lib::context->isInitialized) + return ${X}_RESULT_ERROR_UNINITIALIZED; + else + return ${X}_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + result = ${th.make_pfn_name(n, tags, obj)}( ${", ".join(th.make_param_lines(n, tags, obj, format=["name"]))} ); + + if (result == ${X}_RESULT_SUCCESS) { + if (phDrivers) { + ze_lib::context->${n}Inuse = true; + } + } + + return result; %else: std::call_once(${x}_lib::context->initOnce, [flags]() { - result = ${x}_lib::context->Init(flags, false); + result = ${x}_lib::context->Init(flags, false, nullptr); if( ${X}_RESULT_SUCCESS != result ) return result; @@ -107,6 +139,7 @@ ${th.make_func_name(n, tags, obj)}( } return result; +%endif } %endif %else: diff --git a/scripts/templates/nullddi.cpp.mako b/scripts/templates/nullddi.cpp.mako index 8b32a46b..5a7dc9af 100644 --- a/scripts/templates/nullddi.cpp.mako +++ b/scripts/templates/nullddi.cpp.mako @@ -17,6 +17,7 @@ from templates import helper as th * */ #include "${x}_null.h" +#include namespace driver { @@ -46,6 +47,37 @@ namespace driver else { // generic implementation + %if re.match("Init", obj['name']): + %if re.match("InitDrivers", obj['name']): + auto driver_type = getenv_string( "ZEL_TEST_NULL_DRIVER_TYPE" ); + if (std::strcmp(driver_type.c_str(), "GPU") == 0) { + if (!(desc->flags & ZE_INIT_DRIVER_TYPE_FLAG_GPU)) { + return ${X}_RESULT_ERROR_UNINITIALIZED; + } + } + if (std::strcmp(driver_type.c_str(), "NPU") == 0) { + if (!(desc->flags & ZE_INIT_DRIVER_TYPE_FLAG_NPU)) { + return ${X}_RESULT_ERROR_UNINITIALIZED; + } + } + + if (phDrivers == nullptr) { + *pCount = 1; + } + %else: + auto driver_type = getenv_string( "ZEL_TEST_NULL_DRIVER_TYPE" ); + if (std::strcmp(driver_type.c_str(), "GPU") == 0) { + if (!(flags & ZE_INIT_FLAG_GPU_ONLY)) { + return ${X}_RESULT_ERROR_UNINITIALIZED; + } + } + if (std::strcmp(driver_type.c_str(), "NPU") == 0) { + if (!(flags & ZE_INIT_FLAG_VPU_ONLY)) { + return ${X}_RESULT_ERROR_UNINITIALIZED; + } + } + %endif + %endif %for item in th.get_loader_epilogue(n, tags, obj, meta): %if 'range' in item: for( size_t i = ${item['range'][0]}; ( nullptr != ${item['name']} ) && ( i < ${item['range'][1]} ); ++i ) diff --git a/scripts/templates/validation/param.cpp.mako b/scripts/templates/validation/param.cpp.mako index 37db632a..be438c34 100644 --- a/scripts/templates/validation/param.cpp.mako +++ b/scripts/templates/validation/param.cpp.mako @@ -35,7 +35,7 @@ namespace validation_layer parameterChecker.zeValidation = zeChecker; parameterChecker.zetValidation = zetChecker; parameterChecker.zesValidation = zesChecker; - validation_layer::context.validationHandlers.push_back(¶meterChecker); + validation_layer::context.getInstance().validationHandlers.push_back(¶meterChecker); } } diff --git a/source/drivers/null/ze_nullddi.cpp b/source/drivers/null/ze_nullddi.cpp index 1c8befc0..8541b077 100644 --- a/source/drivers/null/ze_nullddi.cpp +++ b/source/drivers/null/ze_nullddi.cpp @@ -8,6 +8,7 @@ * */ #include "ze_null.h" +#include namespace driver { @@ -30,6 +31,17 @@ namespace driver else { // generic implementation + auto driver_type = getenv_string( "ZEL_TEST_NULL_DRIVER_TYPE" ); + if (std::strcmp(driver_type.c_str(), "GPU") == 0) { + if (!(flags & ZE_INIT_FLAG_GPU_ONLY)) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + } + if (std::strcmp(driver_type.c_str(), "NPU") == 0) { + if (!(flags & ZE_INIT_FLAG_VPU_ONLY)) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + } } return result; @@ -68,6 +80,56 @@ namespace driver return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeInitDrivers + __zedlllocal ze_result_t ZE_APICALL + zeInitDrivers( + uint32_t* pCount, ///< [in,out] pointer to the number of driver instances. + ///< if count is zero, then the loader shall update the value with the + ///< total number of drivers available. + ///< if count is greater than the number of drivers available, then the + ///< loader shall update the value with the correct number of drivers available. + ze_driver_handle_t* phDrivers, ///< [in,out][optional][range(0, *pCount)] array of driver instance handles. + ///< if count is less than the number of drivers available, then the loader + ///< shall only retrieve that number of drivers. + ze_init_driver_type_desc_t* desc ///< [in] descriptor containing the driver type initialization details + ///< including ::ze_init_driver_type_flag_t combinations. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnInitDrivers = context.zeDdiTable.Global.pfnInitDrivers; + if( nullptr != pfnInitDrivers ) + { + result = pfnInitDrivers( pCount, phDrivers, desc ); + } + else + { + // generic implementation + auto driver_type = getenv_string( "ZEL_TEST_NULL_DRIVER_TYPE" ); + if (std::strcmp(driver_type.c_str(), "GPU") == 0) { + if (!(desc->flags & ZE_INIT_DRIVER_TYPE_FLAG_GPU)) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + } + if (std::strcmp(driver_type.c_str(), "NPU") == 0) { + if (!(desc->flags & ZE_INIT_DRIVER_TYPE_FLAG_NPU)) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + } + + if (phDrivers == nullptr) { + *pCount = 1; + } + for( size_t i = 0; ( nullptr != phDrivers ) && ( i < *pCount ); ++i ) + phDrivers[ i ] = reinterpret_cast( context.get() ); + + } + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeDriverGetApiVersion __zedlllocal ze_result_t ZE_APICALL @@ -639,9 +701,9 @@ namespace driver zeDeviceGetGlobalTimestamps( ze_device_handle_t hDevice, ///< [in] handle of the device uint64_t* hostTimestamp, ///< [out] value of the Host's global timestamp that correlates with the - ///< Device's global timestamp value + ///< Device's global timestamp value. uint64_t* deviceTimestamp ///< [out] value of the Device's global timestamp that correlates with the - ///< Host's global timestamp value + ///< Host's global timestamp value. ) { ze_result_t result = ZE_RESULT_SUCCESS; @@ -3721,7 +3783,8 @@ namespace driver __zedlllocal ze_result_t ZE_APICALL zePhysicalMemCreate( ze_context_handle_t hContext, ///< [in] handle of the context object - ze_device_handle_t hDevice, ///< [in] handle of the device object + ze_device_handle_t hDevice, ///< [in] handle of the device object, can be `nullptr` if creating + ///< physical host memory. ze_physical_mem_desc_t* desc, ///< [in] pointer to physical memory descriptor. ze_physical_mem_handle_t* phPhysicalMemory ///< [out] pointer to handle of physical memory object created ) @@ -3906,6 +3969,164 @@ namespace driver return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListGetNextCommandIdExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListGetNextCommandIdExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_command_id_exp_desc_t* desc, ///< [in] pointer to mutable command identifier descriptor + uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnGetNextCommandIdExp = context.zeDdiTable.CommandListExp.pfnGetNextCommandIdExp; + if( nullptr != pfnGetNextCommandIdExp ) + { + result = pfnGetNextCommandIdExp( hCommandList, desc, pCommandId ); + } + else + { + // generic implementation + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListGetNextCommandIdWithKernelsExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListGetNextCommandIdWithKernelsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_command_id_exp_desc_t* desc, ///< [in][out] pointer to mutable command identifier descriptor + uint32_t numKernels, ///< [in][optional] number of entries on phKernels list + ze_kernel_handle_t* phKernels, ///< [in][optional][range(0, numKernels)] list of kernels that user can + ///< switch between using ::zeCommandListUpdateMutableCommandKernelsExp + ///< call + uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnGetNextCommandIdWithKernelsExp = context.zeDdiTable.CommandListExp.pfnGetNextCommandIdWithKernelsExp; + if( nullptr != pfnGetNextCommandIdWithKernelsExp ) + { + result = pfnGetNextCommandIdWithKernelsExp( hCommandList, desc, numKernels, phKernels, pCommandId ); + } + else + { + // generic implementation + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListUpdateMutableCommandsExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_commands_exp_desc_t* desc ///< [in] pointer to mutable commands descriptor; multiple descriptors may + ///< be chained via `pNext` member + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnUpdateMutableCommandsExp = context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandsExp; + if( nullptr != pfnUpdateMutableCommandsExp ) + { + result = pfnUpdateMutableCommandsExp( hCommandList, desc ); + } + else + { + // generic implementation + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListUpdateMutableCommandSignalEventExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandSignalEventExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint64_t commandId, ///< [in] command identifier + ze_event_handle_t hSignalEvent ///< [in][optional] handle of the event to signal on completion + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnUpdateMutableCommandSignalEventExp = context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandSignalEventExp; + if( nullptr != pfnUpdateMutableCommandSignalEventExp ) + { + result = pfnUpdateMutableCommandSignalEventExp( hCommandList, commandId, hSignalEvent ); + } + else + { + // generic implementation + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListUpdateMutableCommandWaitEventsExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandWaitEventsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint64_t commandId, ///< [in] command identifier + uint32_t numWaitEvents, ///< [in][optional] the number of wait events + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnUpdateMutableCommandWaitEventsExp = context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandWaitEventsExp; + if( nullptr != pfnUpdateMutableCommandWaitEventsExp ) + { + result = pfnUpdateMutableCommandWaitEventsExp( hCommandList, commandId, numWaitEvents, phWaitEvents ); + } + else + { + // generic implementation + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListUpdateMutableCommandKernelsExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandKernelsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint32_t numKernels, ///< [in] the number of kernels to update + uint64_t* pCommandId, ///< [in][range(0, numKernels)] command identifier + ze_kernel_handle_t* phKernels ///< [in][range(0, numKernels)] handle of the kernel for a command + ///< identifier to switch to + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnUpdateMutableCommandKernelsExp = context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandKernelsExp; + if( nullptr != pfnUpdateMutableCommandKernelsExp ) + { + result = pfnUpdateMutableCommandKernelsExp( hCommandList, numKernels, pCommandId, phKernels ); + } + else + { + // generic implementation + } + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeDeviceReserveCacheExt __zedlllocal ze_result_t ZE_APICALL @@ -4891,108 +5112,6 @@ namespace driver return result; } - /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zeCommandListGetNextCommandIdExp - __zedlllocal ze_result_t ZE_APICALL - zeCommandListGetNextCommandIdExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - const ze_mutable_command_id_exp_desc_t* desc, ///< [in] pointer to mutable command identifier descriptor - uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written - ) - { - ze_result_t result = ZE_RESULT_SUCCESS; - - // if the driver has created a custom function, then call it instead of using the generic path - auto pfnGetNextCommandIdExp = context.zeDdiTable.CommandListExp.pfnGetNextCommandIdExp; - if( nullptr != pfnGetNextCommandIdExp ) - { - result = pfnGetNextCommandIdExp( hCommandList, desc, pCommandId ); - } - else - { - // generic implementation - } - - return result; - } - - /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zeCommandListUpdateMutableCommandsExp - __zedlllocal ze_result_t ZE_APICALL - zeCommandListUpdateMutableCommandsExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - const ze_mutable_commands_exp_desc_t* desc ///< [in] pointer to mutable commands descriptor; multiple descriptors may - ///< be chained via `pNext` member - ) - { - ze_result_t result = ZE_RESULT_SUCCESS; - - // if the driver has created a custom function, then call it instead of using the generic path - auto pfnUpdateMutableCommandsExp = context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandsExp; - if( nullptr != pfnUpdateMutableCommandsExp ) - { - result = pfnUpdateMutableCommandsExp( hCommandList, desc ); - } - else - { - // generic implementation - } - - return result; - } - - /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zeCommandListUpdateMutableCommandSignalEventExp - __zedlllocal ze_result_t ZE_APICALL - zeCommandListUpdateMutableCommandSignalEventExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - uint64_t commandId, ///< [in] command identifier - ze_event_handle_t hSignalEvent ///< [in][optional] handle of the event to signal on completion - ) - { - ze_result_t result = ZE_RESULT_SUCCESS; - - // if the driver has created a custom function, then call it instead of using the generic path - auto pfnUpdateMutableCommandSignalEventExp = context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandSignalEventExp; - if( nullptr != pfnUpdateMutableCommandSignalEventExp ) - { - result = pfnUpdateMutableCommandSignalEventExp( hCommandList, commandId, hSignalEvent ); - } - else - { - // generic implementation - } - - return result; - } - - /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zeCommandListUpdateMutableCommandWaitEventsExp - __zedlllocal ze_result_t ZE_APICALL - zeCommandListUpdateMutableCommandWaitEventsExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - uint64_t commandId, ///< [in] command identifier - uint32_t numWaitEvents, ///< [in][optional] the number of wait events - ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait - ///< on before launching - ) - { - ze_result_t result = ZE_RESULT_SUCCESS; - - // if the driver has created a custom function, then call it instead of using the generic path - auto pfnUpdateMutableCommandWaitEventsExp = context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandWaitEventsExp; - if( nullptr != pfnUpdateMutableCommandWaitEventsExp ) - { - result = pfnUpdateMutableCommandWaitEventsExp( hCommandList, commandId, numWaitEvents, phWaitEvents ); - } - else - { - // generic implementation - } - - return result; - } - } // namespace driver #if defined(__cplusplus) @@ -5023,6 +5142,8 @@ zeGetGlobalProcAddrTable( pDdiTable->pfnInit = driver::zeInit; + pDdiTable->pfnInitDrivers = driver::zeInitDrivers; + return result; } @@ -5443,18 +5564,22 @@ zeGetCommandListExpProcAddrTable( ze_result_t result = ZE_RESULT_SUCCESS; - pDdiTable->pfnCreateCloneExp = driver::zeCommandListCreateCloneExp; - - pDdiTable->pfnImmediateAppendCommandListsExp = driver::zeCommandListImmediateAppendCommandListsExp; - - pDdiTable->pfnGetNextCommandIdExp = driver::zeCommandListGetNextCommandIdExp; + pDdiTable->pfnGetNextCommandIdWithKernelsExp = driver::zeCommandListGetNextCommandIdWithKernelsExp; pDdiTable->pfnUpdateMutableCommandsExp = driver::zeCommandListUpdateMutableCommandsExp; pDdiTable->pfnUpdateMutableCommandSignalEventExp = driver::zeCommandListUpdateMutableCommandSignalEventExp; + pDdiTable->pfnUpdateMutableCommandKernelsExp = driver::zeCommandListUpdateMutableCommandKernelsExp; + + pDdiTable->pfnCreateCloneExp = driver::zeCommandListCreateCloneExp; + + pDdiTable->pfnGetNextCommandIdExp = driver::zeCommandListGetNextCommandIdExp; + pDdiTable->pfnUpdateMutableCommandWaitEventsExp = driver::zeCommandListUpdateMutableCommandWaitEventsExp; + pDdiTable->pfnImmediateAppendCommandListsExp = driver::zeCommandListImmediateAppendCommandListsExp; + return result; } diff --git a/source/drivers/null/zes_nullddi.cpp b/source/drivers/null/zes_nullddi.cpp index bcfbec4f..d1a27db1 100644 --- a/source/drivers/null/zes_nullddi.cpp +++ b/source/drivers/null/zes_nullddi.cpp @@ -8,6 +8,7 @@ * */ #include "ze_null.h" +#include namespace driver { @@ -30,6 +31,17 @@ namespace driver else { // generic implementation + auto driver_type = getenv_string( "ZEL_TEST_NULL_DRIVER_TYPE" ); + if (std::strcmp(driver_type.c_str(), "GPU") == 0) { + if (!(flags & ZE_INIT_FLAG_GPU_ONLY)) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + } + if (std::strcmp(driver_type.c_str(), "NPU") == 0) { + if (!(flags & ZE_INIT_FLAG_VPU_ONLY)) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + } } return result; @@ -3951,6 +3963,135 @@ namespace driver return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEnumEnabledVFExp + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumEnabledVFExp( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_vf_handle_t* phVFhandle ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnEnumEnabledVFExp = context.zesDdiTable.DeviceExp.pfnEnumEnabledVFExp; + if( nullptr != pfnEnumEnabledVFExp ) + { + result = pfnEnumEnabledVFExp( hDevice, pCount, phVFhandle ); + } + else + { + // generic implementation + for( size_t i = 0; ( nullptr != phVFhandle ) && ( i < *pCount ); ++i ) + phVFhandle[ i ] = reinterpret_cast( context.get() ); + + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesVFManagementGetVFCapabilitiesExp + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFCapabilitiesExp( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. + zes_vf_exp_capabilities_t* pCapability ///< [in,out] Will contain VF capability. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnGetVFCapabilitiesExp = context.zesDdiTable.VFManagementExp.pfnGetVFCapabilitiesExp; + if( nullptr != pfnGetVFCapabilitiesExp ) + { + result = pfnGetVFCapabilitiesExp( hVFhandle, pCapability ); + } + else + { + // generic implementation + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesVFManagementGetVFMemoryUtilizationExp2 + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFMemoryUtilizationExp2( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF memory stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of memory stats available. + ///< - if count is greater than the total number of memory stats + ///< available, the driver shall update the value with the correct number + ///< of memory stats available. + zes_vf_util_mem_exp2_t* pMemUtil ///< [in,out][optional][range(0, *pCount)] array of memory group activity counters. + ///< - if count is less than the total number of memory stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector pCount-1 number of VF + ///< memory stats. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnGetVFMemoryUtilizationExp2 = context.zesDdiTable.VFManagement.pfnGetVFMemoryUtilizationExp2; + if( nullptr != pfnGetVFMemoryUtilizationExp2 ) + { + result = pfnGetVFMemoryUtilizationExp2( hVFhandle, pCount, pMemUtil ); + } + else + { + // generic implementation + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesVFManagementGetVFEngineUtilizationExp2 + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFEngineUtilizationExp2( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF engine stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of engine stats available. + ///< - if count is greater than the total number of engine stats + ///< available, the driver shall update the value with the correct number + ///< of engine stats available. + zes_vf_util_engine_exp2_t* pEngineUtil ///< [in,out][optional][range(0, *pCount)] array of engine group activity counters. + ///< - if count is less than the total number of engine stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector pCount-1 number of VF + ///< engine stats. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnGetVFEngineUtilizationExp2 = context.zesDdiTable.VFManagement.pfnGetVFEngineUtilizationExp2; + if( nullptr != pfnGetVFEngineUtilizationExp2 ) + { + result = pfnGetVFEngineUtilizationExp2( hVFhandle, pCount, pEngineUtil ); + } + else + { + // generic implementation + } + + return result; + } + } // namespace driver #if defined(__cplusplus) @@ -4105,6 +4246,8 @@ zesGetDeviceExpProcAddrTable( ze_result_t result = ZE_RESULT_SUCCESS; + pDdiTable->pfnEnumEnabledVFExp = driver::zesDeviceEnumEnabledVFExp; + pDdiTable->pfnGetSubDevicePropertiesExp = driver::zesDeviceGetSubDevicePropertiesExp; pDdiTable->pfnEnumActiveVFExp = driver::zesDeviceEnumActiveVFExp; @@ -4810,6 +4953,35 @@ zesGetTemperatureProcAddrTable( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's VFManagement table +/// with current process' addresses +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION +ZE_DLLEXPORT ze_result_t ZE_APICALL +zesGetVFManagementProcAddrTable( + ze_api_version_t version, ///< [in] API version requested + zes_vf_management_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers + ) +{ + if( nullptr == pDdiTable ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( driver::context.version < version ) + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + + ze_result_t result = ZE_RESULT_SUCCESS; + + pDdiTable->pfnGetVFMemoryUtilizationExp2 = driver::zesVFManagementGetVFMemoryUtilizationExp2; + + pDdiTable->pfnGetVFEngineUtilizationExp2 = driver::zesVFManagementGetVFEngineUtilizationExp2; + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's VFManagementExp table /// with current process' addresses @@ -4832,6 +5004,8 @@ zesGetVFManagementExpProcAddrTable( ze_result_t result = ZE_RESULT_SUCCESS; + pDdiTable->pfnGetVFCapabilitiesExp = driver::zesVFManagementGetVFCapabilitiesExp; + pDdiTable->pfnGetVFPropertiesExp = driver::zesVFManagementGetVFPropertiesExp; pDdiTable->pfnGetVFMemoryUtilizationExp = driver::zesVFManagementGetVFMemoryUtilizationExp; diff --git a/source/drivers/null/zet_nullddi.cpp b/source/drivers/null/zet_nullddi.cpp index 27526197..f0769b41 100644 --- a/source/drivers/null/zet_nullddi.cpp +++ b/source/drivers/null/zet_nullddi.cpp @@ -8,6 +8,7 @@ * */ #include "ze_null.h" +#include namespace driver { @@ -1075,6 +1076,331 @@ namespace driver return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDeviceGetConcurrentMetricGroupsExp + __zedlllocal ze_result_t ZE_APICALL + zetDeviceGetConcurrentMetricGroupsExp( + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t metricGroupCount, ///< [in] metric group count + zet_metric_group_handle_t * phMetricGroups, ///< [in,out] metrics groups to be re-arranged to be sets of concurrent + ///< groups + uint32_t * pMetricGroupsCountPerConcurrentGroup,///< [in,out][optional][*pConcurrentGroupCount] count of metric groups per + ///< concurrent group. + uint32_t * pConcurrentGroupCount ///< [out] number of concurrent groups. + ///< The value of this parameter could be used to determine the number of + ///< replays necessary. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnGetConcurrentMetricGroupsExp = context.zetDdiTable.DeviceExp.pfnGetConcurrentMetricGroupsExp; + if( nullptr != pfnGetConcurrentMetricGroupsExp ) + { + result = pfnGetConcurrentMetricGroupsExp( hDevice, metricGroupCount, phMetricGroups, pMetricGroupsCountPerConcurrentGroup, pConcurrentGroupCount ); + } + else + { + // generic implementation + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerCreateExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerCreateExp( + zet_context_handle_t hContext, ///< [in] handle of the context object + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t metricGroupCount, ///< [in] metric group count + zet_metric_group_handle_t* phMetricGroups, ///< [in][range(0, metricGroupCount )] handles of the metric groups to + ///< trace + zet_metric_tracer_exp_desc_t* desc, ///< [in,out] metric tracer descriptor + ze_event_handle_t hNotificationEvent, ///< [in][optional] event used for report availability notification. Note: + ///< If buffer is not drained when the event it flagged, there is a risk of + ///< HW event buffer being overrun + zet_metric_tracer_exp_handle_t* phMetricTracer ///< [out] handle of the metric tracer + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnCreateExp = context.zetDdiTable.MetricTracerExp.pfnCreateExp; + if( nullptr != pfnCreateExp ) + { + result = pfnCreateExp( hContext, hDevice, metricGroupCount, phMetricGroups, desc, hNotificationEvent, phMetricTracer ); + } + else + { + // generic implementation + *phMetricTracer = reinterpret_cast( context.get() ); + + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerDestroyExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerDestroyExp( + zet_metric_tracer_exp_handle_t hMetricTracer ///< [in] handle of the metric tracer + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnDestroyExp = context.zetDdiTable.MetricTracerExp.pfnDestroyExp; + if( nullptr != pfnDestroyExp ) + { + result = pfnDestroyExp( hMetricTracer ); + } + else + { + // generic implementation + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerEnableExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerEnableExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + ze_bool_t synchronous ///< [in] request synchronous behavior. Confirmation of successful + ///< asynchronous operation is done by calling ::zetMetricTracerReadDataExp() + ///< and checking the return status: ::ZE_RESULT_NOT_READY will be returned + ///< when the tracer is inactive. ::ZE_RESULT_SUCCESS will be returned + ///< when the tracer is active. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnEnableExp = context.zetDdiTable.MetricTracerExp.pfnEnableExp; + if( nullptr != pfnEnableExp ) + { + result = pfnEnableExp( hMetricTracer, synchronous ); + } + else + { + // generic implementation + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerDisableExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerDisableExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + ze_bool_t synchronous ///< [in] request synchronous behavior. Confirmation of successful + ///< asynchronous operation is done by calling ::zetMetricTracerReadDataExp() + ///< and checking the return status: ::ZE_RESULT_SUCCESS will be returned + ///< when the tracer is active or when it is inactive but still has data. + ///< ::ZE_RESULT_NOT_READY will be returned when the tracer is inactive and + ///< has no more data to be retrieved. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnDisableExp = context.zetDdiTable.MetricTracerExp.pfnDisableExp; + if( nullptr != pfnDisableExp ) + { + result = pfnDisableExp( hMetricTracer, synchronous ); + } + else + { + // generic implementation + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerReadDataExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerReadDataExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + size_t* pRawDataSize, ///< [in,out] pointer to size in bytes of raw data requested to read. + ///< if size is zero, then the driver will update the value with the total + ///< size in bytes needed for all data available. + ///< if size is non-zero, then driver will only retrieve that amount of + ///< data. + ///< if size is larger than size needed for all data, then driver will + ///< update the value with the actual size needed. + uint8_t* pRawData ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing tracer + ///< data in raw format + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnReadDataExp = context.zetDdiTable.MetricTracerExp.pfnReadDataExp; + if( nullptr != pfnReadDataExp ) + { + result = pfnReadDataExp( hMetricTracer, pRawDataSize, pRawData ); + } + else + { + // generic implementation + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricDecoderCreateExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricDecoderCreateExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + zet_metric_decoder_exp_handle_t* phMetricDecoder///< [out] handle of the metric decoder object + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnCreateExp = context.zetDdiTable.MetricDecoderExp.pfnCreateExp; + if( nullptr != pfnCreateExp ) + { + result = pfnCreateExp( hMetricTracer, phMetricDecoder ); + } + else + { + // generic implementation + *phMetricDecoder = reinterpret_cast( context.get() ); + + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricDecoderDestroyExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricDecoderDestroyExp( + zet_metric_decoder_exp_handle_t phMetricDecoder ///< [in] handle of the metric decoder object + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnDestroyExp = context.zetDdiTable.MetricDecoderExp.pfnDestroyExp; + if( nullptr != pfnDestroyExp ) + { + result = pfnDestroyExp( phMetricDecoder ); + } + else + { + // generic implementation + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricDecoderGetDecodableMetricsExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricDecoderGetDecodableMetricsExp( + zet_metric_decoder_exp_handle_t hMetricDecoder, ///< [in] handle of the metric decoder object + uint32_t* pCount, ///< [in,out] pointer to number of decodable metric in the hMetricDecoder + ///< handle. If count is zero, then the driver shall + ///< update the value with the total number of decodable metrics available + ///< in the decoder. if count is greater than zero + ///< but less than the total number of decodable metrics available in the + ///< decoder, then only that number will be returned. + ///< if count is greater than the number of decodable metrics available in + ///< the decoder, then the driver shall update the + ///< value with the actual number of decodable metrics available. + zet_metric_handle_t* phMetrics ///< [in,out] [range(0, *pCount)] array of handles of decodable metrics in + ///< the hMetricDecoder handle provided. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnGetDecodableMetricsExp = context.zetDdiTable.MetricDecoderExp.pfnGetDecodableMetricsExp; + if( nullptr != pfnGetDecodableMetricsExp ) + { + result = pfnGetDecodableMetricsExp( hMetricDecoder, pCount, phMetrics ); + } + else + { + // generic implementation + for( size_t i = 0; ( nullptr != phMetrics ) && ( i < *pCount ); ++i ) + phMetrics[ i ] = reinterpret_cast( context.get() ); + + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerDecodeExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerDecodeExp( + zet_metric_decoder_exp_handle_t phMetricDecoder,///< [in] handle of the metric decoder object + size_t* pRawDataSize, ///< [in,out] size in bytes of raw data buffer. If pMetricEntriesCount is + ///< greater than zero but less than total number of + ///< decodable metrics available in the raw data buffer, then driver shall + ///< update this value with actual number of raw + ///< data bytes processed. + uint8_t* pRawData, ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing tracer + ///< data in raw format + uint32_t metricsCount, ///< [in] number of decodable metrics in the tracer for which the + ///< hMetricDecoder handle was provided. See + ///< ::zetMetricDecoderGetDecodableMetricsExp(). If metricCount is greater + ///< than zero but less than the number decodable + ///< metrics available in the raw data buffer, then driver shall only + ///< decode those. + zet_metric_handle_t* phMetrics, ///< [in] [range(0, metricsCount)] array of handles of decodable metrics in + ///< the decoder for which the hMetricDecoder handle was + ///< provided. Metrics handles are expected to be for decodable metrics, + ///< see ::zetMetricDecoderGetDecodableMetrics() + uint32_t* pSetCount, ///< [in,out] pointer to number of metric sets. If count is zero, then the + ///< driver shall update the value with the total + ///< number of metric sets to be decoded. If count is greater than the + ///< number available in the raw data buffer, then the + ///< driver shall update the value with the actual number of metric sets to + ///< be decoded. There is a 1:1 relation between + ///< the number of sets and sub-devices returned in the decoded entries. + uint32_t* pMetricEntriesCountPerSet, ///< [in,out][optional][range(0, *pSetCount)] buffer of metric entries + ///< counts per metric set, one value per set. + uint32_t* pMetricEntriesCount, ///< [in,out] pointer to the total number of metric entries decoded, for + ///< all metric sets. If count is zero, then the + ///< driver shall update the value with the total number of metric entries + ///< to be decoded. If count is greater than zero + ///< but less than the total number of metric entries available in the raw + ///< data, then user provided number will be decoded. + ///< If count is greater than the number available in the raw data buffer, + ///< then the driver shall update the value with + ///< the actual number of decodable metric entries decoded. If set to null, + ///< then driver will only update the value of + ///< pSetCount. + zet_metric_entry_exp_t* pMetricEntries ///< [in,out][optional][range(0, *pMetricEntriesCount)] buffer containing + ///< decoded metric entries + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnDecodeExp = context.zetDdiTable.MetricTracerExp.pfnDecodeExp; + if( nullptr != pfnDecodeExp ) + { + result = pfnDecodeExp( phMetricDecoder, pRawDataSize, pRawData, metricsCount, phMetrics, pSetCount, pMetricEntriesCountPerSet, pMetricEntriesCount, pMetricEntries ); + } + else + { + // generic implementation + } + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zetMetricGroupCalculateMultipleMetricValuesExp __zedlllocal ze_result_t ZE_APICALL @@ -1345,6 +1671,48 @@ namespace driver return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricCreateFromProgrammableExp2 + __zedlllocal ze_result_t ZE_APICALL + zetMetricCreateFromProgrammableExp2( + zet_metric_programmable_exp_handle_t hMetricProgrammable, ///< [in] handle of the metric programmable + uint32_t parameterCount, ///< [in] Count of parameters to set. + zet_metric_programmable_param_value_exp_t* pParameterValues,///< [in] list of parameter values to be set. + const char* pName, ///< [in] pointer to metric name to be used. Must point to a + ///< null-terminated character array no longer than ::ZET_MAX_METRIC_NAME. + const char* pDescription, ///< [in] pointer to metric description to be used. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_DESCRIPTION. + uint32_t* pMetricHandleCount, ///< [in,out] Pointer to the number of metric handles. + ///< if count is zero, then the driver shall update the value with the + ///< number of metric handles available for this programmable. + ///< if count is greater than the number of metric handles available, then + ///< the driver shall update the value with the correct number of metric + ///< handles available. + zet_metric_handle_t* phMetricHandles ///< [in,out][optional][range(0,*pMetricHandleCount)] array of handle of metrics. + ///< if count is less than the number of metrics available, then driver + ///< shall only retrieve that number of metric handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnCreateFromProgrammableExp2 = context.zetDdiTable.Metric.pfnCreateFromProgrammableExp2; + if( nullptr != pfnCreateFromProgrammableExp2 ) + { + result = pfnCreateFromProgrammableExp2( hMetricProgrammable, parameterCount, pParameterValues, pName, pDescription, pMetricHandleCount, phMetricHandles ); + } + else + { + // generic implementation + for( size_t i = 0; ( nullptr != phMetricHandles ) && ( i < *pMetricHandleCount ); ++i ) + phMetricHandles[ i ] = reinterpret_cast( context.get() ); + + } + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zetMetricCreateFromProgrammableExp __zedlllocal ze_result_t ZE_APICALL @@ -1387,6 +1755,51 @@ namespace driver return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDeviceCreateMetricGroupsFromMetricsExp + __zedlllocal ze_result_t ZE_APICALL + zetDeviceCreateMetricGroupsFromMetricsExp( + zet_device_handle_t hDevice, ///< [in] handle of the device. + uint32_t metricCount, ///< [in] number of metric handles. + zet_metric_handle_t * phMetrics, ///< [in] metric handles to be added to the metric groups. + const char * pMetricGroupNamePrefix, ///< [in] prefix to the name created for the metric groups. Must point to a + ///< null-terminated character array no longer than + ///< ZEX_MAX_METRIC_GROUP_NAME_PREFIX. + const char * pDescription, ///< [in] pointer to description of the metric groups. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_GROUP_DESCRIPTION. + uint32_t * pMetricGroupCount, ///< [in,out] pointer to the number of metric group handles to be created. + ///< if pMetricGroupCount is zero, then the driver shall update the value + ///< with the maximum possible number of metric group handles that could be created. + ///< if pMetricGroupCount is greater than the number of metric group + ///< handles that could be created, then the driver shall update the value + ///< with the correct number of metric group handles generated. + ///< if pMetricGroupCount is lesser than the number of metric group handles + ///< that could be created, then ::ZE_RESULT_ERROR_INVALID_ARGUMENT is returned. + zet_metric_group_handle_t* phMetricGroup ///< [in,out][optional][range(0, *pMetricGroupCount)] array of handle of + ///< metric group handles. + ///< Created Metric group handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // if the driver has created a custom function, then call it instead of using the generic path + auto pfnCreateMetricGroupsFromMetricsExp = context.zetDdiTable.DeviceExp.pfnCreateMetricGroupsFromMetricsExp; + if( nullptr != pfnCreateMetricGroupsFromMetricsExp ) + { + result = pfnCreateMetricGroupsFromMetricsExp( hDevice, metricCount, phMetrics, pMetricGroupNamePrefix, pDescription, pMetricGroupCount, phMetricGroup ); + } + else + { + // generic implementation + for( size_t i = 0; ( nullptr != phMetricGroup ) && ( i < *pMetricGroupCount ); ++i ) + phMetricGroup[ i ] = reinterpret_cast( context.get() ); + + } + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zetMetricGroupCreateExp __zedlllocal ze_result_t ZE_APICALL @@ -1549,6 +1962,37 @@ namespace driver extern "C" { #endif +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's MetricDecoderExp table +/// with current process' addresses +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION +ZE_DLLEXPORT ze_result_t ZE_APICALL +zetGetMetricDecoderExpProcAddrTable( + ze_api_version_t version, ///< [in] API version requested + zet_metric_decoder_exp_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers + ) +{ + if( nullptr == pDdiTable ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( driver::context.version < version ) + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + + ze_result_t result = ZE_RESULT_SUCCESS; + + pDdiTable->pfnCreateExp = driver::zetMetricDecoderCreateExp; + + pDdiTable->pfnDestroyExp = driver::zetMetricDecoderDestroyExp; + + pDdiTable->pfnGetDecodableMetricsExp = driver::zetMetricDecoderGetDecodableMetricsExp; + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's MetricProgrammableExp table /// with current process' addresses @@ -1582,6 +2026,43 @@ zetGetMetricProgrammableExpProcAddrTable( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's MetricTracerExp table +/// with current process' addresses +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION +ZE_DLLEXPORT ze_result_t ZE_APICALL +zetGetMetricTracerExpProcAddrTable( + ze_api_version_t version, ///< [in] API version requested + zet_metric_tracer_exp_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers + ) +{ + if( nullptr == pDdiTable ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( driver::context.version < version ) + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + + ze_result_t result = ZE_RESULT_SUCCESS; + + pDdiTable->pfnCreateExp = driver::zetMetricTracerCreateExp; + + pDdiTable->pfnDestroyExp = driver::zetMetricTracerDestroyExp; + + pDdiTable->pfnEnableExp = driver::zetMetricTracerEnableExp; + + pDdiTable->pfnDisableExp = driver::zetMetricTracerDisableExp; + + pDdiTable->pfnReadDataExp = driver::zetMetricTracerReadDataExp; + + pDdiTable->pfnDecodeExp = driver::zetMetricTracerDecodeExp; + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's Device table /// with current process' addresses @@ -1609,6 +2090,35 @@ zetGetDeviceProcAddrTable( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's DeviceExp table +/// with current process' addresses +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION +ZE_DLLEXPORT ze_result_t ZE_APICALL +zetGetDeviceExpProcAddrTable( + ze_api_version_t version, ///< [in] API version requested + zet_device_exp_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers + ) +{ + if( nullptr == pDdiTable ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( driver::context.version < version ) + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + + ze_result_t result = ZE_RESULT_SUCCESS; + + pDdiTable->pfnGetConcurrentMetricGroupsExp = driver::zetDeviceGetConcurrentMetricGroupsExp; + + pDdiTable->pfnCreateMetricGroupsFromMetricsExp = driver::zetDeviceCreateMetricGroupsFromMetricsExp; + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's Context table /// with current process' addresses @@ -1798,6 +2308,8 @@ zetGetMetricProcAddrTable( pDdiTable->pfnGetProperties = driver::zetMetricGetProperties; + pDdiTable->pfnCreateFromProgrammableExp2 = driver::zetMetricCreateFromProgrammableExp2; + return result; } @@ -1883,6 +2395,8 @@ zetGetMetricGroupExpProcAddrTable( ze_result_t result = ZE_RESULT_SUCCESS; + pDdiTable->pfnCreateExp = driver::zetMetricGroupCreateExp; + pDdiTable->pfnCalculateMultipleMetricValuesExp = driver::zetMetricGroupCalculateMultipleMetricValuesExp; pDdiTable->pfnGetGlobalTimestampsExp = driver::zetMetricGroupGetGlobalTimestampsExp; @@ -1891,8 +2405,6 @@ zetGetMetricGroupExpProcAddrTable( pDdiTable->pfnCalculateMetricExportDataExp = driver::zetMetricGroupCalculateMetricExportDataExp; - pDdiTable->pfnCreateExp = driver::zetMetricGroupCreateExp; - pDdiTable->pfnAddMetricExp = driver::zetMetricGroupAddMetricExp; pDdiTable->pfnRemoveMetricExp = driver::zetMetricGroupRemoveMetricExp; diff --git a/source/layers/tracing/ze_tracing_cb_structs.h b/source/layers/tracing/ze_tracing_cb_structs.h index 84a3b1f9..8eac2548 100644 --- a/source/layers/tracing/ze_tracing_cb_structs.h +++ b/source/layers/tracing/ze_tracing_cb_structs.h @@ -23,6 +23,7 @@ typedef struct _zel_global_callbacks_t { ze_pfnInitCb_t pfnInitCb; + ze_pfnInitDriversCb_t pfnInitDriversCb; } zel_global_callbacks_t; /////////////////////////////////////////////////////////////////////////////// @@ -142,6 +143,10 @@ typedef struct _zel_command_list_callbacks_t ze_pfnCommandListAppendLaunchCooperativeKernelCb_t pfnAppendLaunchCooperativeKernelCb; ze_pfnCommandListAppendLaunchKernelIndirectCb_t pfnAppendLaunchKernelIndirectCb; ze_pfnCommandListAppendLaunchMultipleKernelsIndirectCb_t pfnAppendLaunchMultipleKernelsIndirectCb; + ze_pfnCommandListGetNextCommandIdWithKernelsExpCb_t pfnGetNextCommandIdWithKernelsExpCb; + ze_pfnCommandListUpdateMutableCommandsExpCb_t pfnUpdateMutableCommandsExpCb; + ze_pfnCommandListUpdateMutableCommandSignalEventExpCb_t pfnUpdateMutableCommandSignalEventExpCb; + ze_pfnCommandListUpdateMutableCommandKernelsExpCb_t pfnUpdateMutableCommandKernelsExpCb; ze_pfnCommandListAppendImageCopyToMemoryExtCb_t pfnAppendImageCopyToMemoryExtCb; ze_pfnCommandListAppendImageCopyFromMemoryExtCb_t pfnAppendImageCopyFromMemoryExtCb; ze_pfnCommandListHostSynchronizeCb_t pfnHostSynchronizeCb; @@ -151,11 +156,9 @@ typedef struct _zel_command_list_callbacks_t ze_pfnCommandListGetOrdinalCb_t pfnGetOrdinalCb; ze_pfnCommandListImmediateGetIndexCb_t pfnImmediateGetIndexCb; ze_pfnCommandListIsImmediateCb_t pfnIsImmediateCb; - ze_pfnCommandListImmediateAppendCommandListsExpCb_t pfnImmediateAppendCommandListsExpCb; ze_pfnCommandListGetNextCommandIdExpCb_t pfnGetNextCommandIdExpCb; - ze_pfnCommandListUpdateMutableCommandsExpCb_t pfnUpdateMutableCommandsExpCb; - ze_pfnCommandListUpdateMutableCommandSignalEventExpCb_t pfnUpdateMutableCommandSignalEventExpCb; ze_pfnCommandListUpdateMutableCommandWaitEventsExpCb_t pfnUpdateMutableCommandWaitEventsExpCb; + ze_pfnCommandListImmediateAppendCommandListsExpCb_t pfnImmediateAppendCommandListsExpCb; } zel_command_list_callbacks_t; /////////////////////////////////////////////////////////////////////////////// diff --git a/source/layers/tracing/ze_tracing_register_cb.cpp b/source/layers/tracing/ze_tracing_register_cb.cpp index 13da0682..fe6e308f 100644 --- a/source/layers/tracing/ze_tracing_register_cb.cpp +++ b/source/layers/tracing/ze_tracing_register_cb.cpp @@ -51,6 +51,22 @@ zelTracerDriverGetRegisterCallback( } +ZE_DLLEXPORT ze_result_t ZE_APICALL +zelTracerInitDriversRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnInitDriversCb_t pfnInitDriversCb + ) { + + ze_result_t result; + auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result); + if (result == ZE_RESULT_SUCCESS) + cbs.Global.pfnInitDriversCb = pfnInitDriversCb; + + return result; +} + + ZE_DLLEXPORT ze_result_t ZE_APICALL zelTracerDriverGetApiVersionRegisterCallback( zel_tracer_handle_t hTracer, @@ -2339,6 +2355,102 @@ zelTracerKernelSetGlobalOffsetExpRegisterCallback( } +ZE_DLLEXPORT ze_result_t ZE_APICALL +zelTracerCommandListGetNextCommandIdExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListGetNextCommandIdExpCb_t pfnGetNextCommandIdExpCb + ) { + + ze_result_t result; + auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result); + if (result == ZE_RESULT_SUCCESS) + cbs.CommandList.pfnGetNextCommandIdExpCb = pfnGetNextCommandIdExpCb; + + return result; +} + + +ZE_DLLEXPORT ze_result_t ZE_APICALL +zelTracerCommandListGetNextCommandIdWithKernelsExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListGetNextCommandIdWithKernelsExpCb_t pfnGetNextCommandIdWithKernelsExpCb + ) { + + ze_result_t result; + auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result); + if (result == ZE_RESULT_SUCCESS) + cbs.CommandList.pfnGetNextCommandIdWithKernelsExpCb = pfnGetNextCommandIdWithKernelsExpCb; + + return result; +} + + +ZE_DLLEXPORT ze_result_t ZE_APICALL +zelTracerCommandListUpdateMutableCommandsExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListUpdateMutableCommandsExpCb_t pfnUpdateMutableCommandsExpCb + ) { + + ze_result_t result; + auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result); + if (result == ZE_RESULT_SUCCESS) + cbs.CommandList.pfnUpdateMutableCommandsExpCb = pfnUpdateMutableCommandsExpCb; + + return result; +} + + +ZE_DLLEXPORT ze_result_t ZE_APICALL +zelTracerCommandListUpdateMutableCommandSignalEventExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListUpdateMutableCommandSignalEventExpCb_t pfnUpdateMutableCommandSignalEventExpCb + ) { + + ze_result_t result; + auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result); + if (result == ZE_RESULT_SUCCESS) + cbs.CommandList.pfnUpdateMutableCommandSignalEventExpCb = pfnUpdateMutableCommandSignalEventExpCb; + + return result; +} + + +ZE_DLLEXPORT ze_result_t ZE_APICALL +zelTracerCommandListUpdateMutableCommandWaitEventsExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListUpdateMutableCommandWaitEventsExpCb_t pfnUpdateMutableCommandWaitEventsExpCb + ) { + + ze_result_t result; + auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result); + if (result == ZE_RESULT_SUCCESS) + cbs.CommandList.pfnUpdateMutableCommandWaitEventsExpCb = pfnUpdateMutableCommandWaitEventsExpCb; + + return result; +} + + +ZE_DLLEXPORT ze_result_t ZE_APICALL +zelTracerCommandListUpdateMutableCommandKernelsExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListUpdateMutableCommandKernelsExpCb_t pfnUpdateMutableCommandKernelsExpCb + ) { + + ze_result_t result; + auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result); + if (result == ZE_RESULT_SUCCESS) + cbs.CommandList.pfnUpdateMutableCommandKernelsExpCb = pfnUpdateMutableCommandKernelsExpCb; + + return result; +} + + ZE_DLLEXPORT ze_result_t ZE_APICALL zelTracerDeviceReserveCacheExtRegisterCallback( zel_tracer_handle_t hTracer, @@ -2899,69 +3011,5 @@ zelTracerCommandListImmediateAppendCommandListsExpRegisterCallback( } -ZE_DLLEXPORT ze_result_t ZE_APICALL -zelTracerCommandListGetNextCommandIdExpRegisterCallback( - zel_tracer_handle_t hTracer, - zel_tracer_reg_t callback_type, - ze_pfnCommandListGetNextCommandIdExpCb_t pfnGetNextCommandIdExpCb - ) { - - ze_result_t result; - auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result); - if (result == ZE_RESULT_SUCCESS) - cbs.CommandList.pfnGetNextCommandIdExpCb = pfnGetNextCommandIdExpCb; - - return result; -} - - -ZE_DLLEXPORT ze_result_t ZE_APICALL -zelTracerCommandListUpdateMutableCommandsExpRegisterCallback( - zel_tracer_handle_t hTracer, - zel_tracer_reg_t callback_type, - ze_pfnCommandListUpdateMutableCommandsExpCb_t pfnUpdateMutableCommandsExpCb - ) { - - ze_result_t result; - auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result); - if (result == ZE_RESULT_SUCCESS) - cbs.CommandList.pfnUpdateMutableCommandsExpCb = pfnUpdateMutableCommandsExpCb; - - return result; -} - - -ZE_DLLEXPORT ze_result_t ZE_APICALL -zelTracerCommandListUpdateMutableCommandSignalEventExpRegisterCallback( - zel_tracer_handle_t hTracer, - zel_tracer_reg_t callback_type, - ze_pfnCommandListUpdateMutableCommandSignalEventExpCb_t pfnUpdateMutableCommandSignalEventExpCb - ) { - - ze_result_t result; - auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result); - if (result == ZE_RESULT_SUCCESS) - cbs.CommandList.pfnUpdateMutableCommandSignalEventExpCb = pfnUpdateMutableCommandSignalEventExpCb; - - return result; -} - - -ZE_DLLEXPORT ze_result_t ZE_APICALL -zelTracerCommandListUpdateMutableCommandWaitEventsExpRegisterCallback( - zel_tracer_handle_t hTracer, - zel_tracer_reg_t callback_type, - ze_pfnCommandListUpdateMutableCommandWaitEventsExpCb_t pfnUpdateMutableCommandWaitEventsExpCb - ) { - - ze_result_t result; - auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result); - if (result == ZE_RESULT_SUCCESS) - cbs.CommandList.pfnUpdateMutableCommandWaitEventsExpCb = pfnUpdateMutableCommandWaitEventsExpCb; - - return result; -} - - } //extern C \ No newline at end of file diff --git a/source/layers/tracing/ze_trcddi.cpp b/source/layers/tracing/ze_trcddi.cpp index 36266686..d721d32e 100644 --- a/source/layers/tracing/ze_trcddi.cpp +++ b/source/layers/tracing/ze_trcddi.cpp @@ -87,6 +87,51 @@ namespace tracing_layer *tracerParams.pphDrivers); } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeInitDrivers + __zedlllocal ze_result_t ZE_APICALL + zeInitDrivers( + uint32_t* pCount, ///< [in,out] pointer to the number of driver instances. + ///< if count is zero, then the loader shall update the value with the + ///< total number of drivers available. + ///< if count is greater than the number of drivers available, then the + ///< loader shall update the value with the correct number of drivers available. + ze_driver_handle_t* phDrivers, ///< [in,out][optional][range(0, *pCount)] array of driver instance handles. + ///< if count is less than the number of drivers available, then the loader + ///< shall only retrieve that number of drivers. + ze_init_driver_type_desc_t* desc ///< [in] descriptor containing the driver type initialization details + ///< including ::ze_init_driver_type_flag_t combinations. + ) + { + auto pfnInitDrivers = context.zeDdiTable.Global.pfnInitDrivers; + + if( nullptr == pfnInitDrivers) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.Global.pfnInitDrivers, pCount, phDrivers, desc); + + // capture parameters + ze_init_drivers_params_t tracerParams = { + &pCount, + &phDrivers, + &desc + }; + + tracing_layer::APITracerCallbackDataImp apiCallbackData; + + ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnInitDriversCb_t, Global, pfnInitDriversCb); + + + return tracing_layer::APITracerWrapperImp(context.zeDdiTable.Global.pfnInitDrivers, + &tracerParams, + apiCallbackData.apiOrdinal, + apiCallbackData.prologCallbacks, + apiCallbackData.epilogCallbacks, + *tracerParams.ppCount, + *tracerParams.pphDrivers, + *tracerParams.pdesc); + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeDriverGetApiVersion __zedlllocal ze_result_t ZE_APICALL @@ -897,9 +942,9 @@ namespace tracing_layer zeDeviceGetGlobalTimestamps( ze_device_handle_t hDevice, ///< [in] handle of the device uint64_t* hostTimestamp, ///< [out] value of the Host's global timestamp that correlates with the - ///< Device's global timestamp value + ///< Device's global timestamp value. uint64_t* deviceTimestamp ///< [out] value of the Device's global timestamp that correlates with the - ///< Host's global timestamp value + ///< Host's global timestamp value. ) { auto pfnGetGlobalTimestamps = context.zeDdiTable.Device.pfnGetGlobalTimestamps; @@ -5494,7 +5539,8 @@ namespace tracing_layer __zedlllocal ze_result_t ZE_APICALL zePhysicalMemCreate( ze_context_handle_t hContext, ///< [in] handle of the context object - ze_device_handle_t hDevice, ///< [in] handle of the device object + ze_device_handle_t hDevice, ///< [in] handle of the device object, can be `nullptr` if creating + ///< physical host memory. ze_physical_mem_desc_t* desc, ///< [in] pointer to physical memory descriptor. ze_physical_mem_handle_t* phPhysicalMemory ///< [out] pointer to handle of physical memory object created ) @@ -5781,6 +5827,248 @@ namespace tracing_layer *tracerParams.poffsetZ); } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListGetNextCommandIdExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListGetNextCommandIdExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_command_id_exp_desc_t* desc, ///< [in] pointer to mutable command identifier descriptor + uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written + ) + { + auto pfnGetNextCommandIdExp = context.zeDdiTable.CommandListExp.pfnGetNextCommandIdExp; + + if( nullptr == pfnGetNextCommandIdExp) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.CommandListExp.pfnGetNextCommandIdExp, hCommandList, desc, pCommandId); + + // capture parameters + ze_command_list_get_next_command_id_exp_params_t tracerParams = { + &hCommandList, + &desc, + &pCommandId + }; + + tracing_layer::APITracerCallbackDataImp apiCallbackData; + + ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnCommandListGetNextCommandIdExpCb_t, CommandList, pfnGetNextCommandIdExpCb); + + + return tracing_layer::APITracerWrapperImp(context.zeDdiTable.CommandListExp.pfnGetNextCommandIdExp, + &tracerParams, + apiCallbackData.apiOrdinal, + apiCallbackData.prologCallbacks, + apiCallbackData.epilogCallbacks, + *tracerParams.phCommandList, + *tracerParams.pdesc, + *tracerParams.ppCommandId); + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListGetNextCommandIdWithKernelsExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListGetNextCommandIdWithKernelsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_command_id_exp_desc_t* desc, ///< [in][out] pointer to mutable command identifier descriptor + uint32_t numKernels, ///< [in][optional] number of entries on phKernels list + ze_kernel_handle_t* phKernels, ///< [in][optional][range(0, numKernels)] list of kernels that user can + ///< switch between using ::zeCommandListUpdateMutableCommandKernelsExp + ///< call + uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written + ) + { + auto pfnGetNextCommandIdWithKernelsExp = context.zeDdiTable.CommandListExp.pfnGetNextCommandIdWithKernelsExp; + + if( nullptr == pfnGetNextCommandIdWithKernelsExp) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.CommandListExp.pfnGetNextCommandIdWithKernelsExp, hCommandList, desc, numKernels, phKernels, pCommandId); + + // capture parameters + ze_command_list_get_next_command_id_with_kernels_exp_params_t tracerParams = { + &hCommandList, + &desc, + &numKernels, + &phKernels, + &pCommandId + }; + + tracing_layer::APITracerCallbackDataImp apiCallbackData; + + ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnCommandListGetNextCommandIdWithKernelsExpCb_t, CommandList, pfnGetNextCommandIdWithKernelsExpCb); + + + return tracing_layer::APITracerWrapperImp(context.zeDdiTable.CommandListExp.pfnGetNextCommandIdWithKernelsExp, + &tracerParams, + apiCallbackData.apiOrdinal, + apiCallbackData.prologCallbacks, + apiCallbackData.epilogCallbacks, + *tracerParams.phCommandList, + *tracerParams.pdesc, + *tracerParams.pnumKernels, + *tracerParams.pphKernels, + *tracerParams.ppCommandId); + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListUpdateMutableCommandsExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_commands_exp_desc_t* desc ///< [in] pointer to mutable commands descriptor; multiple descriptors may + ///< be chained via `pNext` member + ) + { + auto pfnUpdateMutableCommandsExp = context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandsExp; + + if( nullptr == pfnUpdateMutableCommandsExp) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandsExp, hCommandList, desc); + + // capture parameters + ze_command_list_update_mutable_commands_exp_params_t tracerParams = { + &hCommandList, + &desc + }; + + tracing_layer::APITracerCallbackDataImp apiCallbackData; + + ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnCommandListUpdateMutableCommandsExpCb_t, CommandList, pfnUpdateMutableCommandsExpCb); + + + return tracing_layer::APITracerWrapperImp(context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandsExp, + &tracerParams, + apiCallbackData.apiOrdinal, + apiCallbackData.prologCallbacks, + apiCallbackData.epilogCallbacks, + *tracerParams.phCommandList, + *tracerParams.pdesc); + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListUpdateMutableCommandSignalEventExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandSignalEventExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint64_t commandId, ///< [in] command identifier + ze_event_handle_t hSignalEvent ///< [in][optional] handle of the event to signal on completion + ) + { + auto pfnUpdateMutableCommandSignalEventExp = context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandSignalEventExp; + + if( nullptr == pfnUpdateMutableCommandSignalEventExp) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandSignalEventExp, hCommandList, commandId, hSignalEvent); + + // capture parameters + ze_command_list_update_mutable_command_signal_event_exp_params_t tracerParams = { + &hCommandList, + &commandId, + &hSignalEvent + }; + + tracing_layer::APITracerCallbackDataImp apiCallbackData; + + ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnCommandListUpdateMutableCommandSignalEventExpCb_t, CommandList, pfnUpdateMutableCommandSignalEventExpCb); + + + return tracing_layer::APITracerWrapperImp(context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandSignalEventExp, + &tracerParams, + apiCallbackData.apiOrdinal, + apiCallbackData.prologCallbacks, + apiCallbackData.epilogCallbacks, + *tracerParams.phCommandList, + *tracerParams.pcommandId, + *tracerParams.phSignalEvent); + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListUpdateMutableCommandWaitEventsExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandWaitEventsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint64_t commandId, ///< [in] command identifier + uint32_t numWaitEvents, ///< [in][optional] the number of wait events + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + auto pfnUpdateMutableCommandWaitEventsExp = context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandWaitEventsExp; + + if( nullptr == pfnUpdateMutableCommandWaitEventsExp) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandWaitEventsExp, hCommandList, commandId, numWaitEvents, phWaitEvents); + + // capture parameters + ze_command_list_update_mutable_command_wait_events_exp_params_t tracerParams = { + &hCommandList, + &commandId, + &numWaitEvents, + &phWaitEvents + }; + + tracing_layer::APITracerCallbackDataImp apiCallbackData; + + ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnCommandListUpdateMutableCommandWaitEventsExpCb_t, CommandList, pfnUpdateMutableCommandWaitEventsExpCb); + + + return tracing_layer::APITracerWrapperImp(context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandWaitEventsExp, + &tracerParams, + apiCallbackData.apiOrdinal, + apiCallbackData.prologCallbacks, + apiCallbackData.epilogCallbacks, + *tracerParams.phCommandList, + *tracerParams.pcommandId, + *tracerParams.pnumWaitEvents, + *tracerParams.pphWaitEvents); + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListUpdateMutableCommandKernelsExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandKernelsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint32_t numKernels, ///< [in] the number of kernels to update + uint64_t* pCommandId, ///< [in][range(0, numKernels)] command identifier + ze_kernel_handle_t* phKernels ///< [in][range(0, numKernels)] handle of the kernel for a command + ///< identifier to switch to + ) + { + auto pfnUpdateMutableCommandKernelsExp = context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandKernelsExp; + + if( nullptr == pfnUpdateMutableCommandKernelsExp) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandKernelsExp, hCommandList, numKernels, pCommandId, phKernels); + + // capture parameters + ze_command_list_update_mutable_command_kernels_exp_params_t tracerParams = { + &hCommandList, + &numKernels, + &pCommandId, + &phKernels + }; + + tracing_layer::APITracerCallbackDataImp apiCallbackData; + + ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnCommandListUpdateMutableCommandKernelsExpCb_t, CommandList, pfnUpdateMutableCommandKernelsExpCb); + + + return tracing_layer::APITracerWrapperImp(context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandKernelsExp, + &tracerParams, + apiCallbackData.apiOrdinal, + apiCallbackData.prologCallbacks, + apiCallbackData.epilogCallbacks, + *tracerParams.phCommandList, + *tracerParams.pnumKernels, + *tracerParams.ppCommandId, + *tracerParams.pphKernels); + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeDeviceReserveCacheExt __zedlllocal ze_result_t ZE_APICALL @@ -7224,160 +7512,6 @@ namespace tracing_layer *tracerParams.pphWaitEvents); } - /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zeCommandListGetNextCommandIdExp - __zedlllocal ze_result_t ZE_APICALL - zeCommandListGetNextCommandIdExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - const ze_mutable_command_id_exp_desc_t* desc, ///< [in] pointer to mutable command identifier descriptor - uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written - ) - { - auto pfnGetNextCommandIdExp = context.zeDdiTable.CommandListExp.pfnGetNextCommandIdExp; - - if( nullptr == pfnGetNextCommandIdExp) - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; - - ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.CommandListExp.pfnGetNextCommandIdExp, hCommandList, desc, pCommandId); - - // capture parameters - ze_command_list_get_next_command_id_exp_params_t tracerParams = { - &hCommandList, - &desc, - &pCommandId - }; - - tracing_layer::APITracerCallbackDataImp apiCallbackData; - - ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnCommandListGetNextCommandIdExpCb_t, CommandList, pfnGetNextCommandIdExpCb); - - - return tracing_layer::APITracerWrapperImp(context.zeDdiTable.CommandListExp.pfnGetNextCommandIdExp, - &tracerParams, - apiCallbackData.apiOrdinal, - apiCallbackData.prologCallbacks, - apiCallbackData.epilogCallbacks, - *tracerParams.phCommandList, - *tracerParams.pdesc, - *tracerParams.ppCommandId); - } - - /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zeCommandListUpdateMutableCommandsExp - __zedlllocal ze_result_t ZE_APICALL - zeCommandListUpdateMutableCommandsExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - const ze_mutable_commands_exp_desc_t* desc ///< [in] pointer to mutable commands descriptor; multiple descriptors may - ///< be chained via `pNext` member - ) - { - auto pfnUpdateMutableCommandsExp = context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandsExp; - - if( nullptr == pfnUpdateMutableCommandsExp) - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; - - ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandsExp, hCommandList, desc); - - // capture parameters - ze_command_list_update_mutable_commands_exp_params_t tracerParams = { - &hCommandList, - &desc - }; - - tracing_layer::APITracerCallbackDataImp apiCallbackData; - - ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnCommandListUpdateMutableCommandsExpCb_t, CommandList, pfnUpdateMutableCommandsExpCb); - - - return tracing_layer::APITracerWrapperImp(context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandsExp, - &tracerParams, - apiCallbackData.apiOrdinal, - apiCallbackData.prologCallbacks, - apiCallbackData.epilogCallbacks, - *tracerParams.phCommandList, - *tracerParams.pdesc); - } - - /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zeCommandListUpdateMutableCommandSignalEventExp - __zedlllocal ze_result_t ZE_APICALL - zeCommandListUpdateMutableCommandSignalEventExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - uint64_t commandId, ///< [in] command identifier - ze_event_handle_t hSignalEvent ///< [in][optional] handle of the event to signal on completion - ) - { - auto pfnUpdateMutableCommandSignalEventExp = context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandSignalEventExp; - - if( nullptr == pfnUpdateMutableCommandSignalEventExp) - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; - - ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandSignalEventExp, hCommandList, commandId, hSignalEvent); - - // capture parameters - ze_command_list_update_mutable_command_signal_event_exp_params_t tracerParams = { - &hCommandList, - &commandId, - &hSignalEvent - }; - - tracing_layer::APITracerCallbackDataImp apiCallbackData; - - ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnCommandListUpdateMutableCommandSignalEventExpCb_t, CommandList, pfnUpdateMutableCommandSignalEventExpCb); - - - return tracing_layer::APITracerWrapperImp(context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandSignalEventExp, - &tracerParams, - apiCallbackData.apiOrdinal, - apiCallbackData.prologCallbacks, - apiCallbackData.epilogCallbacks, - *tracerParams.phCommandList, - *tracerParams.pcommandId, - *tracerParams.phSignalEvent); - } - - /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zeCommandListUpdateMutableCommandWaitEventsExp - __zedlllocal ze_result_t ZE_APICALL - zeCommandListUpdateMutableCommandWaitEventsExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - uint64_t commandId, ///< [in] command identifier - uint32_t numWaitEvents, ///< [in][optional] the number of wait events - ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait - ///< on before launching - ) - { - auto pfnUpdateMutableCommandWaitEventsExp = context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandWaitEventsExp; - - if( nullptr == pfnUpdateMutableCommandWaitEventsExp) - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; - - ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandWaitEventsExp, hCommandList, commandId, numWaitEvents, phWaitEvents); - - // capture parameters - ze_command_list_update_mutable_command_wait_events_exp_params_t tracerParams = { - &hCommandList, - &commandId, - &numWaitEvents, - &phWaitEvents - }; - - tracing_layer::APITracerCallbackDataImp apiCallbackData; - - ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnCommandListUpdateMutableCommandWaitEventsExpCb_t, CommandList, pfnUpdateMutableCommandWaitEventsExpCb); - - - return tracing_layer::APITracerWrapperImp(context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandWaitEventsExp, - &tracerParams, - apiCallbackData.apiOrdinal, - apiCallbackData.prologCallbacks, - apiCallbackData.epilogCallbacks, - *tracerParams.phCommandList, - *tracerParams.pcommandId, - *tracerParams.pnumWaitEvents, - *tracerParams.pphWaitEvents); - } - } // namespace tracing_layer #if defined(__cplusplus) @@ -7412,6 +7546,9 @@ zeGetGlobalProcAddrTable( dditable.pfnInit = pDdiTable->pfnInit; pDdiTable->pfnInit = tracing_layer::zeInit; + dditable.pfnInitDrivers = pDdiTable->pfnInitDrivers; + pDdiTable->pfnInitDrivers = tracing_layer::zeInitDrivers; + return result; } @@ -7947,14 +8084,8 @@ zeGetCommandListExpProcAddrTable( ze_result_t result = ZE_RESULT_SUCCESS; - dditable.pfnCreateCloneExp = pDdiTable->pfnCreateCloneExp; - pDdiTable->pfnCreateCloneExp = tracing_layer::zeCommandListCreateCloneExp; - - dditable.pfnImmediateAppendCommandListsExp = pDdiTable->pfnImmediateAppendCommandListsExp; - pDdiTable->pfnImmediateAppendCommandListsExp = tracing_layer::zeCommandListImmediateAppendCommandListsExp; - - dditable.pfnGetNextCommandIdExp = pDdiTable->pfnGetNextCommandIdExp; - pDdiTable->pfnGetNextCommandIdExp = tracing_layer::zeCommandListGetNextCommandIdExp; + dditable.pfnGetNextCommandIdWithKernelsExp = pDdiTable->pfnGetNextCommandIdWithKernelsExp; + pDdiTable->pfnGetNextCommandIdWithKernelsExp = tracing_layer::zeCommandListGetNextCommandIdWithKernelsExp; dditable.pfnUpdateMutableCommandsExp = pDdiTable->pfnUpdateMutableCommandsExp; pDdiTable->pfnUpdateMutableCommandsExp = tracing_layer::zeCommandListUpdateMutableCommandsExp; @@ -7962,9 +8093,21 @@ zeGetCommandListExpProcAddrTable( dditable.pfnUpdateMutableCommandSignalEventExp = pDdiTable->pfnUpdateMutableCommandSignalEventExp; pDdiTable->pfnUpdateMutableCommandSignalEventExp = tracing_layer::zeCommandListUpdateMutableCommandSignalEventExp; + dditable.pfnUpdateMutableCommandKernelsExp = pDdiTable->pfnUpdateMutableCommandKernelsExp; + pDdiTable->pfnUpdateMutableCommandKernelsExp = tracing_layer::zeCommandListUpdateMutableCommandKernelsExp; + + dditable.pfnCreateCloneExp = pDdiTable->pfnCreateCloneExp; + pDdiTable->pfnCreateCloneExp = tracing_layer::zeCommandListCreateCloneExp; + + dditable.pfnGetNextCommandIdExp = pDdiTable->pfnGetNextCommandIdExp; + pDdiTable->pfnGetNextCommandIdExp = tracing_layer::zeCommandListGetNextCommandIdExp; + dditable.pfnUpdateMutableCommandWaitEventsExp = pDdiTable->pfnUpdateMutableCommandWaitEventsExp; pDdiTable->pfnUpdateMutableCommandWaitEventsExp = tracing_layer::zeCommandListUpdateMutableCommandWaitEventsExp; + dditable.pfnImmediateAppendCommandListsExp = pDdiTable->pfnImmediateAppendCommandListsExp; + pDdiTable->pfnImmediateAppendCommandListsExp = tracing_layer::zeCommandListImmediateAppendCommandListsExp; + return result; } diff --git a/source/layers/validation/checkers/parameter_validation/ze_parameter_validation.cpp b/source/layers/validation/checkers/parameter_validation/ze_parameter_validation.cpp index 1170f528..efd009a8 100644 --- a/source/layers/validation/checkers/parameter_validation/ze_parameter_validation.cpp +++ b/source/layers/validation/checkers/parameter_validation/ze_parameter_validation.cpp @@ -69,6 +69,33 @@ namespace validation_layer } + ze_result_t + ZEParameterValidation::zeInitDriversPrologue( + uint32_t* pCount, ///< [in,out] pointer to the number of driver instances. + ///< if count is zero, then the loader shall update the value with the + ///< total number of drivers available. + ///< if count is greater than the number of drivers available, then the + ///< loader shall update the value with the correct number of drivers available. + ze_driver_handle_t* phDrivers, ///< [in,out][optional][range(0, *pCount)] array of driver instance handles. + ///< if count is less than the number of drivers available, then the loader + ///< shall only retrieve that number of drivers. + ze_init_driver_type_desc_t* desc ///< [in] descriptor containing the driver type initialization details + ///< including ::ze_init_driver_type_flag_t combinations. + ) + { + if( nullptr == pCount ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( nullptr == desc ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( 0x0 == desc->flags ) + return ZE_RESULT_ERROR_INVALID_ENUMERATION; + + return ParameterValidation::validateExtensions(desc); + } + + ze_result_t ZEParameterValidation::zeDriverGetApiVersionPrologue( ze_driver_handle_t hDriver, ///< [in] handle of the driver instance @@ -468,9 +495,9 @@ namespace validation_layer ZEParameterValidation::zeDeviceGetGlobalTimestampsPrologue( ze_device_handle_t hDevice, ///< [in] handle of the device uint64_t* hostTimestamp, ///< [out] value of the Host's global timestamp that correlates with the - ///< Device's global timestamp value + ///< Device's global timestamp value. uint64_t* deviceTimestamp ///< [out] value of the Device's global timestamp that correlates with the - ///< Host's global timestamp value + ///< Host's global timestamp value. ) { if( nullptr == hDevice ) @@ -2852,7 +2879,8 @@ namespace validation_layer ze_result_t ZEParameterValidation::zePhysicalMemCreatePrologue( ze_context_handle_t hContext, ///< [in] handle of the context object - ze_device_handle_t hDevice, ///< [in] handle of the device object + ze_device_handle_t hDevice, ///< [in] handle of the device object, can be `nullptr` if creating + ///< physical host memory. ze_physical_mem_desc_t* desc, ///< [in] pointer to physical memory descriptor. ze_physical_mem_handle_t* phPhysicalMemory ///< [out] pointer to handle of physical memory object created ) @@ -2869,7 +2897,7 @@ namespace validation_layer if( nullptr == phPhysicalMemory ) return ZE_RESULT_ERROR_INVALID_NULL_POINTER; - if( 0x1 < desc->flags ) + if( 0x3 < desc->flags ) return ZE_RESULT_ERROR_INVALID_ENUMERATION; if( 0 == desc->size ) @@ -3016,6 +3044,125 @@ namespace validation_layer } + ze_result_t + ZEParameterValidation::zeCommandListGetNextCommandIdExpPrologue( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_command_id_exp_desc_t* desc, ///< [in] pointer to mutable command identifier descriptor + uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written + ) + { + if( nullptr == hCommandList ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == desc ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( nullptr == pCommandId ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( 0xff < desc->flags ) + return ZE_RESULT_ERROR_INVALID_ENUMERATION; + + return ParameterValidation::validateExtensions(desc); + } + + + ze_result_t + ZEParameterValidation::zeCommandListGetNextCommandIdWithKernelsExpPrologue( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_command_id_exp_desc_t* desc, ///< [in][out] pointer to mutable command identifier descriptor + uint32_t numKernels, ///< [in][optional] number of entries on phKernels list + ze_kernel_handle_t* phKernels, ///< [in][optional][range(0, numKernels)] list of kernels that user can + ///< switch between using ::zeCommandListUpdateMutableCommandKernelsExp + ///< call + uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written + ) + { + if( nullptr == hCommandList ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == desc ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( nullptr == pCommandId ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( 0xff < desc->flags ) + return ZE_RESULT_ERROR_INVALID_ENUMERATION; + + return ParameterValidation::validateExtensions(desc); + } + + + ze_result_t + ZEParameterValidation::zeCommandListUpdateMutableCommandsExpPrologue( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_commands_exp_desc_t* desc ///< [in] pointer to mutable commands descriptor; multiple descriptors may + ///< be chained via `pNext` member + ) + { + if( nullptr == hCommandList ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == desc ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + return ParameterValidation::validateExtensions(desc); + } + + + ze_result_t + ZEParameterValidation::zeCommandListUpdateMutableCommandSignalEventExpPrologue( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint64_t commandId, ///< [in] command identifier + ze_event_handle_t hSignalEvent ///< [in][optional] handle of the event to signal on completion + ) + { + if( nullptr == hCommandList ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + return ZE_RESULT_SUCCESS; + } + + + ze_result_t + ZEParameterValidation::zeCommandListUpdateMutableCommandWaitEventsExpPrologue( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint64_t commandId, ///< [in] command identifier + uint32_t numWaitEvents, ///< [in][optional] the number of wait events + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + if( nullptr == hCommandList ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + return ZE_RESULT_SUCCESS; + } + + + ze_result_t + ZEParameterValidation::zeCommandListUpdateMutableCommandKernelsExpPrologue( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint32_t numKernels, ///< [in] the number of kernels to update + uint64_t* pCommandId, ///< [in][range(0, numKernels)] command identifier + ze_kernel_handle_t* phKernels ///< [in][range(0, numKernels)] handle of the kernel for a command + ///< identifier to switch to + ) + { + if( nullptr == hCommandList ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == pCommandId ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( nullptr == phKernels ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + return ZE_RESULT_SUCCESS; + } + + ze_result_t ZEParameterValidation::zeDeviceReserveCacheExtPrologue( ze_device_handle_t hDevice, ///< [in] handle of the device object @@ -3793,74 +3940,4 @@ namespace validation_layer return ZE_RESULT_SUCCESS; } - - ze_result_t - ZEParameterValidation::zeCommandListGetNextCommandIdExpPrologue( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - const ze_mutable_command_id_exp_desc_t* desc, ///< [in] pointer to mutable command identifier descriptor - uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written - ) - { - if( nullptr == hCommandList ) - return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; - - if( nullptr == desc ) - return ZE_RESULT_ERROR_INVALID_NULL_POINTER; - - if( nullptr == pCommandId ) - return ZE_RESULT_ERROR_INVALID_NULL_POINTER; - - if( 0x3f < desc->flags ) - return ZE_RESULT_ERROR_INVALID_ENUMERATION; - - return ParameterValidation::validateExtensions(desc); - } - - - ze_result_t - ZEParameterValidation::zeCommandListUpdateMutableCommandsExpPrologue( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - const ze_mutable_commands_exp_desc_t* desc ///< [in] pointer to mutable commands descriptor; multiple descriptors may - ///< be chained via `pNext` member - ) - { - if( nullptr == hCommandList ) - return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; - - if( nullptr == desc ) - return ZE_RESULT_ERROR_INVALID_NULL_POINTER; - - return ParameterValidation::validateExtensions(desc); - } - - - ze_result_t - ZEParameterValidation::zeCommandListUpdateMutableCommandSignalEventExpPrologue( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - uint64_t commandId, ///< [in] command identifier - ze_event_handle_t hSignalEvent ///< [in][optional] handle of the event to signal on completion - ) - { - if( nullptr == hCommandList ) - return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; - - return ZE_RESULT_SUCCESS; - } - - - ze_result_t - ZEParameterValidation::zeCommandListUpdateMutableCommandWaitEventsExpPrologue( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - uint64_t commandId, ///< [in] command identifier - uint32_t numWaitEvents, ///< [in][optional] the number of wait events - ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait - ///< on before launching - ) - { - if( nullptr == hCommandList ) - return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; - - return ZE_RESULT_SUCCESS; - } - } \ No newline at end of file diff --git a/source/layers/validation/checkers/parameter_validation/ze_parameter_validation.h b/source/layers/validation/checkers/parameter_validation/ze_parameter_validation.h index 261a0312..355e11af 100644 --- a/source/layers/validation/checkers/parameter_validation/ze_parameter_validation.h +++ b/source/layers/validation/checkers/parameter_validation/ze_parameter_validation.h @@ -22,6 +22,7 @@ namespace validation_layer public: ze_result_t zeInitPrologue( ze_init_flags_t flags ) override; ze_result_t zeDriverGetPrologue( uint32_t* pCount, ze_driver_handle_t* phDrivers ) override; + ze_result_t zeInitDriversPrologue( uint32_t* pCount, ze_driver_handle_t* phDrivers, ze_init_driver_type_desc_t* desc ) override; ze_result_t zeDriverGetApiVersionPrologue( ze_driver_handle_t hDriver, ze_api_version_t* version ) override; ze_result_t zeDriverGetPropertiesPrologue( ze_driver_handle_t hDriver, ze_driver_properties_t* pDriverProperties ) override; ze_result_t zeDriverGetIpcPropertiesPrologue( ze_driver_handle_t hDriver, ze_driver_ipc_properties_t* pIpcProperties ) override; @@ -165,6 +166,12 @@ namespace validation_layer ze_result_t zeVirtualMemSetAccessAttributePrologue( ze_context_handle_t hContext, const void* ptr, size_t size, ze_memory_access_attribute_t access ) override; ze_result_t zeVirtualMemGetAccessAttributePrologue( ze_context_handle_t hContext, const void* ptr, size_t size, ze_memory_access_attribute_t* access, size_t* outSize ) override; ze_result_t zeKernelSetGlobalOffsetExpPrologue( ze_kernel_handle_t hKernel, uint32_t offsetX, uint32_t offsetY, uint32_t offsetZ ) override; + ze_result_t zeCommandListGetNextCommandIdExpPrologue( ze_command_list_handle_t hCommandList, const ze_mutable_command_id_exp_desc_t* desc, uint64_t* pCommandId ) override; + ze_result_t zeCommandListGetNextCommandIdWithKernelsExpPrologue( ze_command_list_handle_t hCommandList, const ze_mutable_command_id_exp_desc_t* desc, uint32_t numKernels, ze_kernel_handle_t* phKernels, uint64_t* pCommandId ) override; + ze_result_t zeCommandListUpdateMutableCommandsExpPrologue( ze_command_list_handle_t hCommandList, const ze_mutable_commands_exp_desc_t* desc ) override; + ze_result_t zeCommandListUpdateMutableCommandSignalEventExpPrologue( ze_command_list_handle_t hCommandList, uint64_t commandId, ze_event_handle_t hSignalEvent ) override; + ze_result_t zeCommandListUpdateMutableCommandWaitEventsExpPrologue( ze_command_list_handle_t hCommandList, uint64_t commandId, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) override; + ze_result_t zeCommandListUpdateMutableCommandKernelsExpPrologue( ze_command_list_handle_t hCommandList, uint32_t numKernels, uint64_t* pCommandId, ze_kernel_handle_t* phKernels ) override; ze_result_t zeDeviceReserveCacheExtPrologue( ze_device_handle_t hDevice, size_t cacheLevel, size_t cacheReservationSize ) override; ze_result_t zeDeviceSetCacheAdviceExtPrologue( ze_device_handle_t hDevice, void* ptr, size_t regionSize, ze_cache_ext_region_t cacheRegion ) override; ze_result_t zeEventQueryTimestampsExpPrologue( ze_event_handle_t hEvent, ze_device_handle_t hDevice, uint32_t* pCount, ze_kernel_timestamp_result_t* pTimestamps ) override; @@ -200,9 +207,5 @@ namespace validation_layer ze_result_t zeImageGetDeviceOffsetExpPrologue( ze_image_handle_t hImage, uint64_t* pDeviceOffset ) override; ze_result_t zeCommandListCreateCloneExpPrologue( ze_command_list_handle_t hCommandList, ze_command_list_handle_t* phClonedCommandList ) override; ze_result_t zeCommandListImmediateAppendCommandListsExpPrologue( ze_command_list_handle_t hCommandListImmediate, uint32_t numCommandLists, ze_command_list_handle_t* phCommandLists, ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) override; - ze_result_t zeCommandListGetNextCommandIdExpPrologue( ze_command_list_handle_t hCommandList, const ze_mutable_command_id_exp_desc_t* desc, uint64_t* pCommandId ) override; - ze_result_t zeCommandListUpdateMutableCommandsExpPrologue( ze_command_list_handle_t hCommandList, const ze_mutable_commands_exp_desc_t* desc ) override; - ze_result_t zeCommandListUpdateMutableCommandSignalEventExpPrologue( ze_command_list_handle_t hCommandList, uint64_t commandId, ze_event_handle_t hSignalEvent ) override; - ze_result_t zeCommandListUpdateMutableCommandWaitEventsExpPrologue( ze_command_list_handle_t hCommandList, uint64_t commandId, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) override; }; } \ No newline at end of file diff --git a/source/layers/validation/checkers/parameter_validation/zes_parameter_validation.cpp b/source/layers/validation/checkers/parameter_validation/zes_parameter_validation.cpp index efab458f..4f90e12c 100644 --- a/source/layers/validation/checkers/parameter_validation/zes_parameter_validation.cpp +++ b/source/layers/validation/checkers/parameter_validation/zes_parameter_validation.cpp @@ -2779,4 +2779,98 @@ namespace validation_layer return ZE_RESULT_SUCCESS; } + + ze_result_t + ZESParameterValidation::zesDeviceEnumEnabledVFExpPrologue( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_vf_handle_t* phVFhandle ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + if( nullptr == hDevice ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == pCount ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + return ZE_RESULT_SUCCESS; + } + + + ze_result_t + ZESParameterValidation::zesVFManagementGetVFCapabilitiesExpPrologue( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. + zes_vf_exp_capabilities_t* pCapability ///< [in,out] Will contain VF capability. + ) + { + if( nullptr == hVFhandle ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == pCapability ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + return ParameterValidation::validateExtensions(pCapability); + } + + + ze_result_t + ZESParameterValidation::zesVFManagementGetVFMemoryUtilizationExp2Prologue( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF memory stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of memory stats available. + ///< - if count is greater than the total number of memory stats + ///< available, the driver shall update the value with the correct number + ///< of memory stats available. + zes_vf_util_mem_exp2_t* pMemUtil ///< [in,out][optional][range(0, *pCount)] array of memory group activity counters. + ///< - if count is less than the total number of memory stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector pCount-1 number of VF + ///< memory stats. + ) + { + if( nullptr == hVFhandle ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == pCount ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + return ZE_RESULT_SUCCESS; + } + + + ze_result_t + ZESParameterValidation::zesVFManagementGetVFEngineUtilizationExp2Prologue( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF engine stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of engine stats available. + ///< - if count is greater than the total number of engine stats + ///< available, the driver shall update the value with the correct number + ///< of engine stats available. + zes_vf_util_engine_exp2_t* pEngineUtil ///< [in,out][optional][range(0, *pCount)] array of engine group activity counters. + ///< - if count is less than the total number of engine stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector pCount-1 number of VF + ///< engine stats. + ) + { + if( nullptr == hVFhandle ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == pCount ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + return ZE_RESULT_SUCCESS; + } + } \ No newline at end of file diff --git a/source/layers/validation/checkers/parameter_validation/zes_parameter_validation.h b/source/layers/validation/checkers/parameter_validation/zes_parameter_validation.h index f9344d6d..88f72bbe 100644 --- a/source/layers/validation/checkers/parameter_validation/zes_parameter_validation.h +++ b/source/layers/validation/checkers/parameter_validation/zes_parameter_validation.h @@ -164,5 +164,9 @@ namespace validation_layer ze_result_t zesVFManagementGetVFEngineUtilizationExpPrologue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_engine_exp_t* pEngineUtil ) override; ze_result_t zesVFManagementSetVFTelemetryModeExpPrologue( zes_vf_handle_t hVFhandle, zes_vf_info_util_exp_flags_t flags, ze_bool_t enable ) override; ze_result_t zesVFManagementSetVFTelemetrySamplingIntervalExpPrologue( zes_vf_handle_t hVFhandle, zes_vf_info_util_exp_flags_t flag, uint64_t samplingInterval ) override; + ze_result_t zesDeviceEnumEnabledVFExpPrologue( zes_device_handle_t hDevice, uint32_t* pCount, zes_vf_handle_t* phVFhandle ) override; + ze_result_t zesVFManagementGetVFCapabilitiesExpPrologue( zes_vf_handle_t hVFhandle, zes_vf_exp_capabilities_t* pCapability ) override; + ze_result_t zesVFManagementGetVFMemoryUtilizationExp2Prologue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_mem_exp2_t* pMemUtil ) override; + ze_result_t zesVFManagementGetVFEngineUtilizationExp2Prologue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_engine_exp2_t* pEngineUtil ) override; }; } \ No newline at end of file diff --git a/source/layers/validation/checkers/parameter_validation/zet_parameter_validation.cpp b/source/layers/validation/checkers/parameter_validation/zet_parameter_validation.cpp index df25e648..eb0d0fa1 100644 --- a/source/layers/validation/checkers/parameter_validation/zet_parameter_validation.cpp +++ b/source/layers/validation/checkers/parameter_validation/zet_parameter_validation.cpp @@ -167,7 +167,7 @@ namespace validation_layer if( nullptr == buffer ) return ZE_RESULT_ERROR_INVALID_NULL_POINTER; - if( ZET_DEBUG_MEMORY_SPACE_TYPE_SLM < desc->type ) + if( ZET_DEBUG_MEMORY_SPACE_TYPE_ELF < desc->type ) return ZE_RESULT_ERROR_INVALID_ENUMERATION; return ParameterValidation::validateExtensions(desc); @@ -192,7 +192,7 @@ namespace validation_layer if( nullptr == buffer ) return ZE_RESULT_ERROR_INVALID_NULL_POINTER; - if( ZET_DEBUG_MEMORY_SPACE_TYPE_SLM < desc->type ) + if( ZET_DEBUG_MEMORY_SPACE_TYPE_ELF < desc->type ) return ZE_RESULT_ERROR_INVALID_ENUMERATION; return ParameterValidation::validateExtensions(desc); @@ -767,6 +767,253 @@ namespace validation_layer } + ze_result_t + ZETParameterValidation::zetDeviceGetConcurrentMetricGroupsExpPrologue( + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t metricGroupCount, ///< [in] metric group count + zet_metric_group_handle_t * phMetricGroups, ///< [in,out] metrics groups to be re-arranged to be sets of concurrent + ///< groups + uint32_t * pMetricGroupsCountPerConcurrentGroup,///< [in,out][optional][*pConcurrentGroupCount] count of metric groups per + ///< concurrent group. + uint32_t * pConcurrentGroupCount ///< [out] number of concurrent groups. + ///< The value of this parameter could be used to determine the number of + ///< replays necessary. + ) + { + if( nullptr == hDevice ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == phMetricGroups ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + return ZE_RESULT_SUCCESS; + } + + + ze_result_t + ZETParameterValidation::zetMetricTracerCreateExpPrologue( + zet_context_handle_t hContext, ///< [in] handle of the context object + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t metricGroupCount, ///< [in] metric group count + zet_metric_group_handle_t* phMetricGroups, ///< [in][range(0, metricGroupCount )] handles of the metric groups to + ///< trace + zet_metric_tracer_exp_desc_t* desc, ///< [in,out] metric tracer descriptor + ze_event_handle_t hNotificationEvent, ///< [in][optional] event used for report availability notification. Note: + ///< If buffer is not drained when the event it flagged, there is a risk of + ///< HW event buffer being overrun + zet_metric_tracer_exp_handle_t* phMetricTracer ///< [out] handle of the metric tracer + ) + { + if( nullptr == hContext ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == hDevice ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == phMetricGroups ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( nullptr == desc ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( nullptr == phMetricTracer ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + return ParameterValidation::validateExtensions(desc); + } + + + ze_result_t + ZETParameterValidation::zetMetricTracerDestroyExpPrologue( + zet_metric_tracer_exp_handle_t hMetricTracer ///< [in] handle of the metric tracer + ) + { + if( nullptr == hMetricTracer ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + return ZE_RESULT_SUCCESS; + } + + + ze_result_t + ZETParameterValidation::zetMetricTracerEnableExpPrologue( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + ze_bool_t synchronous ///< [in] request synchronous behavior. Confirmation of successful + ///< asynchronous operation is done by calling ::zetMetricTracerReadDataExp() + ///< and checking the return status: ::ZE_RESULT_NOT_READY will be returned + ///< when the tracer is inactive. ::ZE_RESULT_SUCCESS will be returned + ///< when the tracer is active. + ) + { + if( nullptr == hMetricTracer ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + return ZE_RESULT_SUCCESS; + } + + + ze_result_t + ZETParameterValidation::zetMetricTracerDisableExpPrologue( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + ze_bool_t synchronous ///< [in] request synchronous behavior. Confirmation of successful + ///< asynchronous operation is done by calling ::zetMetricTracerReadDataExp() + ///< and checking the return status: ::ZE_RESULT_SUCCESS will be returned + ///< when the tracer is active or when it is inactive but still has data. + ///< ::ZE_RESULT_NOT_READY will be returned when the tracer is inactive and + ///< has no more data to be retrieved. + ) + { + if( nullptr == hMetricTracer ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + return ZE_RESULT_SUCCESS; + } + + + ze_result_t + ZETParameterValidation::zetMetricTracerReadDataExpPrologue( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + size_t* pRawDataSize, ///< [in,out] pointer to size in bytes of raw data requested to read. + ///< if size is zero, then the driver will update the value with the total + ///< size in bytes needed for all data available. + ///< if size is non-zero, then driver will only retrieve that amount of + ///< data. + ///< if size is larger than size needed for all data, then driver will + ///< update the value with the actual size needed. + uint8_t* pRawData ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing tracer + ///< data in raw format + ) + { + if( nullptr == hMetricTracer ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == pRawDataSize ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + return ZE_RESULT_SUCCESS; + } + + + ze_result_t + ZETParameterValidation::zetMetricDecoderCreateExpPrologue( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + zet_metric_decoder_exp_handle_t* phMetricDecoder///< [out] handle of the metric decoder object + ) + { + if( nullptr == hMetricTracer ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == phMetricDecoder ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + return ZE_RESULT_SUCCESS; + } + + + ze_result_t + ZETParameterValidation::zetMetricDecoderDestroyExpPrologue( + zet_metric_decoder_exp_handle_t phMetricDecoder ///< [in] handle of the metric decoder object + ) + { + if( nullptr == phMetricDecoder ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + return ZE_RESULT_SUCCESS; + } + + + ze_result_t + ZETParameterValidation::zetMetricDecoderGetDecodableMetricsExpPrologue( + zet_metric_decoder_exp_handle_t hMetricDecoder, ///< [in] handle of the metric decoder object + uint32_t* pCount, ///< [in,out] pointer to number of decodable metric in the hMetricDecoder + ///< handle. If count is zero, then the driver shall + ///< update the value with the total number of decodable metrics available + ///< in the decoder. if count is greater than zero + ///< but less than the total number of decodable metrics available in the + ///< decoder, then only that number will be returned. + ///< if count is greater than the number of decodable metrics available in + ///< the decoder, then the driver shall update the + ///< value with the actual number of decodable metrics available. + zet_metric_handle_t* phMetrics ///< [in,out] [range(0, *pCount)] array of handles of decodable metrics in + ///< the hMetricDecoder handle provided. + ) + { + if( nullptr == hMetricDecoder ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == pCount ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( nullptr == phMetrics ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + return ZE_RESULT_SUCCESS; + } + + + ze_result_t + ZETParameterValidation::zetMetricTracerDecodeExpPrologue( + zet_metric_decoder_exp_handle_t phMetricDecoder,///< [in] handle of the metric decoder object + size_t* pRawDataSize, ///< [in,out] size in bytes of raw data buffer. If pMetricEntriesCount is + ///< greater than zero but less than total number of + ///< decodable metrics available in the raw data buffer, then driver shall + ///< update this value with actual number of raw + ///< data bytes processed. + uint8_t* pRawData, ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing tracer + ///< data in raw format + uint32_t metricsCount, ///< [in] number of decodable metrics in the tracer for which the + ///< hMetricDecoder handle was provided. See + ///< ::zetMetricDecoderGetDecodableMetricsExp(). If metricCount is greater + ///< than zero but less than the number decodable + ///< metrics available in the raw data buffer, then driver shall only + ///< decode those. + zet_metric_handle_t* phMetrics, ///< [in] [range(0, metricsCount)] array of handles of decodable metrics in + ///< the decoder for which the hMetricDecoder handle was + ///< provided. Metrics handles are expected to be for decodable metrics, + ///< see ::zetMetricDecoderGetDecodableMetrics() + uint32_t* pSetCount, ///< [in,out] pointer to number of metric sets. If count is zero, then the + ///< driver shall update the value with the total + ///< number of metric sets to be decoded. If count is greater than the + ///< number available in the raw data buffer, then the + ///< driver shall update the value with the actual number of metric sets to + ///< be decoded. There is a 1:1 relation between + ///< the number of sets and sub-devices returned in the decoded entries. + uint32_t* pMetricEntriesCountPerSet, ///< [in,out][optional][range(0, *pSetCount)] buffer of metric entries + ///< counts per metric set, one value per set. + uint32_t* pMetricEntriesCount, ///< [in,out] pointer to the total number of metric entries decoded, for + ///< all metric sets. If count is zero, then the + ///< driver shall update the value with the total number of metric entries + ///< to be decoded. If count is greater than zero + ///< but less than the total number of metric entries available in the raw + ///< data, then user provided number will be decoded. + ///< If count is greater than the number available in the raw data buffer, + ///< then the driver shall update the value with + ///< the actual number of decodable metric entries decoded. If set to null, + ///< then driver will only update the value of + ///< pSetCount. + zet_metric_entry_exp_t* pMetricEntries ///< [in,out][optional][range(0, *pMetricEntriesCount)] buffer containing + ///< decoded metric entries + ) + { + if( nullptr == phMetricDecoder ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == pRawDataSize ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( nullptr == phMetrics ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( nullptr == pSetCount ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( nullptr == pMetricEntriesCount ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + return ZE_RESULT_SUCCESS; + } + + ze_result_t ZETParameterValidation::zetMetricGroupCalculateMultipleMetricValuesExpPrologue( zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group @@ -1003,6 +1250,46 @@ namespace validation_layer } + ze_result_t + ZETParameterValidation::zetMetricCreateFromProgrammableExp2Prologue( + zet_metric_programmable_exp_handle_t hMetricProgrammable, ///< [in] handle of the metric programmable + uint32_t parameterCount, ///< [in] Count of parameters to set. + zet_metric_programmable_param_value_exp_t* pParameterValues,///< [in] list of parameter values to be set. + const char* pName, ///< [in] pointer to metric name to be used. Must point to a + ///< null-terminated character array no longer than ::ZET_MAX_METRIC_NAME. + const char* pDescription, ///< [in] pointer to metric description to be used. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_DESCRIPTION. + uint32_t* pMetricHandleCount, ///< [in,out] Pointer to the number of metric handles. + ///< if count is zero, then the driver shall update the value with the + ///< number of metric handles available for this programmable. + ///< if count is greater than the number of metric handles available, then + ///< the driver shall update the value with the correct number of metric + ///< handles available. + zet_metric_handle_t* phMetricHandles ///< [in,out][optional][range(0,*pMetricHandleCount)] array of handle of metrics. + ///< if count is less than the number of metrics available, then driver + ///< shall only retrieve that number of metric handles. + ) + { + if( nullptr == hMetricProgrammable ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == pParameterValues ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( nullptr == pName ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( nullptr == pDescription ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( nullptr == pMetricHandleCount ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + return ZE_RESULT_SUCCESS; + } + + ze_result_t ZETParameterValidation::zetMetricCreateFromProgrammableExpPrologue( zet_metric_programmable_exp_handle_t hMetricProgrammable, ///< [in] handle of the metric programmable @@ -1043,6 +1330,40 @@ namespace validation_layer } + ze_result_t + ZETParameterValidation::zetDeviceCreateMetricGroupsFromMetricsExpPrologue( + zet_device_handle_t hDevice, ///< [in] handle of the device. + uint32_t metricCount, ///< [in] number of metric handles. + zet_metric_handle_t * phMetrics, ///< [in] metric handles to be added to the metric groups. + const char * pMetricGroupNamePrefix, ///< [in] prefix to the name created for the metric groups. Must point to a + ///< null-terminated character array no longer than + ///< ZEX_MAX_METRIC_GROUP_NAME_PREFIX. + const char * pDescription, ///< [in] pointer to description of the metric groups. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_GROUP_DESCRIPTION. + uint32_t * pMetricGroupCount, ///< [in,out] pointer to the number of metric group handles to be created. + ///< if pMetricGroupCount is zero, then the driver shall update the value + ///< with the maximum possible number of metric group handles that could be created. + ///< if pMetricGroupCount is greater than the number of metric group + ///< handles that could be created, then the driver shall update the value + ///< with the correct number of metric group handles generated. + ///< if pMetricGroupCount is lesser than the number of metric group handles + ///< that could be created, then ::ZE_RESULT_ERROR_INVALID_ARGUMENT is returned. + zet_metric_group_handle_t* phMetricGroup ///< [in,out][optional][range(0, *pMetricGroupCount)] array of handle of + ///< metric group handles. + ///< Created Metric group handles. + ) + { + if( nullptr == hDevice ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == phMetrics ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + return ZE_RESULT_SUCCESS; + } + + ze_result_t ZETParameterValidation::zetMetricGroupCreateExpPrologue( zet_device_handle_t hDevice, ///< [in] handle of the device @@ -1067,7 +1388,7 @@ namespace validation_layer if( nullptr == phMetricGroup ) return ZE_RESULT_ERROR_INVALID_NULL_POINTER; - if( 0x3 < samplingType ) + if( 0x7 < samplingType ) return ZE_RESULT_ERROR_INVALID_ENUMERATION; return ZE_RESULT_SUCCESS; diff --git a/source/layers/validation/checkers/parameter_validation/zet_parameter_validation.h b/source/layers/validation/checkers/parameter_validation/zet_parameter_validation.h index 3b6c68b5..4a2d24bc 100644 --- a/source/layers/validation/checkers/parameter_validation/zet_parameter_validation.h +++ b/source/layers/validation/checkers/parameter_validation/zet_parameter_validation.h @@ -59,6 +59,16 @@ namespace validation_layer ze_result_t zetTracerExpSetProloguesPrologue( zet_tracer_exp_handle_t hTracer, zet_core_callbacks_t* pCoreCbs ) override; ze_result_t zetTracerExpSetEpiloguesPrologue( zet_tracer_exp_handle_t hTracer, zet_core_callbacks_t* pCoreCbs ) override; ze_result_t zetTracerExpSetEnabledPrologue( zet_tracer_exp_handle_t hTracer, ze_bool_t enable ) override; + ze_result_t zetDeviceGetConcurrentMetricGroupsExpPrologue( zet_device_handle_t hDevice, uint32_t metricGroupCount, zet_metric_group_handle_t * phMetricGroups, uint32_t * pMetricGroupsCountPerConcurrentGroup, uint32_t * pConcurrentGroupCount ) override; + ze_result_t zetMetricTracerCreateExpPrologue( zet_context_handle_t hContext, zet_device_handle_t hDevice, uint32_t metricGroupCount, zet_metric_group_handle_t* phMetricGroups, zet_metric_tracer_exp_desc_t* desc, ze_event_handle_t hNotificationEvent, zet_metric_tracer_exp_handle_t* phMetricTracer ) override; + ze_result_t zetMetricTracerDestroyExpPrologue( zet_metric_tracer_exp_handle_t hMetricTracer ) override; + ze_result_t zetMetricTracerEnableExpPrologue( zet_metric_tracer_exp_handle_t hMetricTracer, ze_bool_t synchronous ) override; + ze_result_t zetMetricTracerDisableExpPrologue( zet_metric_tracer_exp_handle_t hMetricTracer, ze_bool_t synchronous ) override; + ze_result_t zetMetricTracerReadDataExpPrologue( zet_metric_tracer_exp_handle_t hMetricTracer, size_t* pRawDataSize, uint8_t* pRawData ) override; + ze_result_t zetMetricDecoderCreateExpPrologue( zet_metric_tracer_exp_handle_t hMetricTracer, zet_metric_decoder_exp_handle_t* phMetricDecoder ) override; + ze_result_t zetMetricDecoderDestroyExpPrologue( zet_metric_decoder_exp_handle_t phMetricDecoder ) override; + ze_result_t zetMetricDecoderGetDecodableMetricsExpPrologue( zet_metric_decoder_exp_handle_t hMetricDecoder, uint32_t* pCount, zet_metric_handle_t* phMetrics ) override; + ze_result_t zetMetricTracerDecodeExpPrologue( zet_metric_decoder_exp_handle_t phMetricDecoder, size_t* pRawDataSize, uint8_t* pRawData, uint32_t metricsCount, zet_metric_handle_t* phMetrics, uint32_t* pSetCount, uint32_t* pMetricEntriesCountPerSet, uint32_t* pMetricEntriesCount, zet_metric_entry_exp_t* pMetricEntries ) override; ze_result_t zetMetricGroupCalculateMultipleMetricValuesExpPrologue( zet_metric_group_handle_t hMetricGroup, zet_metric_group_calculation_type_t type, size_t rawDataSize, const uint8_t* pRawData, uint32_t* pSetCount, uint32_t* pTotalMetricValueCount, uint32_t* pMetricCounts, zet_typed_value_t* pMetricValues ) override; ze_result_t zetMetricGroupGetGlobalTimestampsExpPrologue( zet_metric_group_handle_t hMetricGroup, ze_bool_t synchronizedWithHost, uint64_t* globalTimestamp, uint64_t* metricTimestamp ) override; ze_result_t zetMetricGroupGetExportDataExpPrologue( zet_metric_group_handle_t hMetricGroup, const uint8_t* pRawData, size_t rawDataSize, size_t* pExportDataSize, uint8_t * pExportData ) override; @@ -67,7 +77,9 @@ namespace validation_layer ze_result_t zetMetricProgrammableGetPropertiesExpPrologue( zet_metric_programmable_exp_handle_t hMetricProgrammable, zet_metric_programmable_exp_properties_t* pProperties ) override; ze_result_t zetMetricProgrammableGetParamInfoExpPrologue( zet_metric_programmable_exp_handle_t hMetricProgrammable, uint32_t* pParameterCount, zet_metric_programmable_param_info_exp_t* pParameterInfo ) override; ze_result_t zetMetricProgrammableGetParamValueInfoExpPrologue( zet_metric_programmable_exp_handle_t hMetricProgrammable, uint32_t parameterOrdinal, uint32_t* pValueInfoCount, zet_metric_programmable_param_value_info_exp_t* pValueInfo ) override; + ze_result_t zetMetricCreateFromProgrammableExp2Prologue( zet_metric_programmable_exp_handle_t hMetricProgrammable, uint32_t parameterCount, zet_metric_programmable_param_value_exp_t* pParameterValues, const char* pName, const char* pDescription, uint32_t* pMetricHandleCount, zet_metric_handle_t* phMetricHandles ) override; ze_result_t zetMetricCreateFromProgrammableExpPrologue( zet_metric_programmable_exp_handle_t hMetricProgrammable, zet_metric_programmable_param_value_exp_t* pParameterValues, uint32_t parameterCount, const char* pName, const char* pDescription, uint32_t* pMetricHandleCount, zet_metric_handle_t* phMetricHandles ) override; + ze_result_t zetDeviceCreateMetricGroupsFromMetricsExpPrologue( zet_device_handle_t hDevice, uint32_t metricCount, zet_metric_handle_t * phMetrics, const char * pMetricGroupNamePrefix, const char * pDescription, uint32_t * pMetricGroupCount, zet_metric_group_handle_t* phMetricGroup ) override; ze_result_t zetMetricGroupCreateExpPrologue( zet_device_handle_t hDevice, const char* pName, const char* pDescription, zet_metric_group_sampling_type_flags_t samplingType, zet_metric_group_handle_t* phMetricGroup ) override; ze_result_t zetMetricGroupAddMetricExpPrologue( zet_metric_group_handle_t hMetricGroup, zet_metric_handle_t hMetric, size_t * pErrorStringSize, char* pErrorString ) override; ze_result_t zetMetricGroupRemoveMetricExpPrologue( zet_metric_group_handle_t hMetricGroup, zet_metric_handle_t hMetric ) override; diff --git a/source/layers/validation/common/ze_entry_points.h b/source/layers/validation/common/ze_entry_points.h index 9ac9bc04..104e941d 100644 --- a/source/layers/validation/common/ze_entry_points.h +++ b/source/layers/validation/common/ze_entry_points.h @@ -21,6 +21,8 @@ class ZEValidationEntryPoints { virtual ze_result_t zeInitEpilogue( ze_init_flags_t flags ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeDriverGetPrologue( uint32_t* pCount, ze_driver_handle_t* phDrivers ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeDriverGetEpilogue( uint32_t* pCount, ze_driver_handle_t* phDrivers ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeInitDriversPrologue( uint32_t* pCount, ze_driver_handle_t* phDrivers, ze_init_driver_type_desc_t* desc ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeInitDriversEpilogue( uint32_t* pCount, ze_driver_handle_t* phDrivers, ze_init_driver_type_desc_t* desc ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeDriverGetApiVersionPrologue( ze_driver_handle_t hDriver, ze_api_version_t* version ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeDriverGetApiVersionEpilogue( ze_driver_handle_t hDriver, ze_api_version_t* version ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeDriverGetPropertiesPrologue( ze_driver_handle_t hDriver, ze_driver_properties_t* pDriverProperties ) {return ZE_RESULT_SUCCESS;} @@ -307,6 +309,18 @@ class ZEValidationEntryPoints { virtual ze_result_t zeVirtualMemGetAccessAttributeEpilogue( ze_context_handle_t hContext, const void* ptr, size_t size, ze_memory_access_attribute_t* access, size_t* outSize ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeKernelSetGlobalOffsetExpPrologue( ze_kernel_handle_t hKernel, uint32_t offsetX, uint32_t offsetY, uint32_t offsetZ ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeKernelSetGlobalOffsetExpEpilogue( ze_kernel_handle_t hKernel, uint32_t offsetX, uint32_t offsetY, uint32_t offsetZ ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeCommandListGetNextCommandIdExpPrologue( ze_command_list_handle_t hCommandList, const ze_mutable_command_id_exp_desc_t* desc, uint64_t* pCommandId ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeCommandListGetNextCommandIdExpEpilogue( ze_command_list_handle_t hCommandList, const ze_mutable_command_id_exp_desc_t* desc, uint64_t* pCommandId ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeCommandListGetNextCommandIdWithKernelsExpPrologue( ze_command_list_handle_t hCommandList, const ze_mutable_command_id_exp_desc_t* desc, uint32_t numKernels, ze_kernel_handle_t* phKernels, uint64_t* pCommandId ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeCommandListGetNextCommandIdWithKernelsExpEpilogue( ze_command_list_handle_t hCommandList, const ze_mutable_command_id_exp_desc_t* desc, uint32_t numKernels, ze_kernel_handle_t* phKernels, uint64_t* pCommandId ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeCommandListUpdateMutableCommandsExpPrologue( ze_command_list_handle_t hCommandList, const ze_mutable_commands_exp_desc_t* desc ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeCommandListUpdateMutableCommandsExpEpilogue( ze_command_list_handle_t hCommandList, const ze_mutable_commands_exp_desc_t* desc ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeCommandListUpdateMutableCommandSignalEventExpPrologue( ze_command_list_handle_t hCommandList, uint64_t commandId, ze_event_handle_t hSignalEvent ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeCommandListUpdateMutableCommandSignalEventExpEpilogue( ze_command_list_handle_t hCommandList, uint64_t commandId, ze_event_handle_t hSignalEvent ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeCommandListUpdateMutableCommandWaitEventsExpPrologue( ze_command_list_handle_t hCommandList, uint64_t commandId, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeCommandListUpdateMutableCommandWaitEventsExpEpilogue( ze_command_list_handle_t hCommandList, uint64_t commandId, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeCommandListUpdateMutableCommandKernelsExpPrologue( ze_command_list_handle_t hCommandList, uint32_t numKernels, uint64_t* pCommandId, ze_kernel_handle_t* phKernels ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeCommandListUpdateMutableCommandKernelsExpEpilogue( ze_command_list_handle_t hCommandList, uint32_t numKernels, uint64_t* pCommandId, ze_kernel_handle_t* phKernels ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeDeviceReserveCacheExtPrologue( ze_device_handle_t hDevice, size_t cacheLevel, size_t cacheReservationSize ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeDeviceReserveCacheExtEpilogue( ze_device_handle_t hDevice, size_t cacheLevel, size_t cacheReservationSize ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeDeviceSetCacheAdviceExtPrologue( ze_device_handle_t hDevice, void* ptr, size_t regionSize, ze_cache_ext_region_t cacheRegion ) {return ZE_RESULT_SUCCESS;} @@ -377,14 +391,6 @@ class ZEValidationEntryPoints { virtual ze_result_t zeCommandListCreateCloneExpEpilogue( ze_command_list_handle_t hCommandList, ze_command_list_handle_t* phClonedCommandList ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeCommandListImmediateAppendCommandListsExpPrologue( ze_command_list_handle_t hCommandListImmediate, uint32_t numCommandLists, ze_command_list_handle_t* phCommandLists, ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeCommandListImmediateAppendCommandListsExpEpilogue( ze_command_list_handle_t hCommandListImmediate, uint32_t numCommandLists, ze_command_list_handle_t* phCommandLists, ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) {return ZE_RESULT_SUCCESS;} - virtual ze_result_t zeCommandListGetNextCommandIdExpPrologue( ze_command_list_handle_t hCommandList, const ze_mutable_command_id_exp_desc_t* desc, uint64_t* pCommandId ) {return ZE_RESULT_SUCCESS;} - virtual ze_result_t zeCommandListGetNextCommandIdExpEpilogue( ze_command_list_handle_t hCommandList, const ze_mutable_command_id_exp_desc_t* desc, uint64_t* pCommandId ) {return ZE_RESULT_SUCCESS;} - virtual ze_result_t zeCommandListUpdateMutableCommandsExpPrologue( ze_command_list_handle_t hCommandList, const ze_mutable_commands_exp_desc_t* desc ) {return ZE_RESULT_SUCCESS;} - virtual ze_result_t zeCommandListUpdateMutableCommandsExpEpilogue( ze_command_list_handle_t hCommandList, const ze_mutable_commands_exp_desc_t* desc ) {return ZE_RESULT_SUCCESS;} - virtual ze_result_t zeCommandListUpdateMutableCommandSignalEventExpPrologue( ze_command_list_handle_t hCommandList, uint64_t commandId, ze_event_handle_t hSignalEvent ) {return ZE_RESULT_SUCCESS;} - virtual ze_result_t zeCommandListUpdateMutableCommandSignalEventExpEpilogue( ze_command_list_handle_t hCommandList, uint64_t commandId, ze_event_handle_t hSignalEvent ) {return ZE_RESULT_SUCCESS;} - virtual ze_result_t zeCommandListUpdateMutableCommandWaitEventsExpPrologue( ze_command_list_handle_t hCommandList, uint64_t commandId, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) {return ZE_RESULT_SUCCESS;} - virtual ze_result_t zeCommandListUpdateMutableCommandWaitEventsExpEpilogue( ze_command_list_handle_t hCommandList, uint64_t commandId, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) {return ZE_RESULT_SUCCESS;} virtual ~ZEValidationEntryPoints() {} }; } \ No newline at end of file diff --git a/source/layers/validation/common/zes_entry_points.h b/source/layers/validation/common/zes_entry_points.h index 3d8f38d9..44815635 100644 --- a/source/layers/validation/common/zes_entry_points.h +++ b/source/layers/validation/common/zes_entry_points.h @@ -305,6 +305,14 @@ class ZESValidationEntryPoints { virtual ze_result_t zesVFManagementSetVFTelemetryModeExpEpilogue( zes_vf_handle_t hVFhandle, zes_vf_info_util_exp_flags_t flags, ze_bool_t enable ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zesVFManagementSetVFTelemetrySamplingIntervalExpPrologue( zes_vf_handle_t hVFhandle, zes_vf_info_util_exp_flags_t flag, uint64_t samplingInterval ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zesVFManagementSetVFTelemetrySamplingIntervalExpEpilogue( zes_vf_handle_t hVFhandle, zes_vf_info_util_exp_flags_t flag, uint64_t samplingInterval ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zesDeviceEnumEnabledVFExpPrologue( zes_device_handle_t hDevice, uint32_t* pCount, zes_vf_handle_t* phVFhandle ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zesDeviceEnumEnabledVFExpEpilogue( zes_device_handle_t hDevice, uint32_t* pCount, zes_vf_handle_t* phVFhandle ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zesVFManagementGetVFCapabilitiesExpPrologue( zes_vf_handle_t hVFhandle, zes_vf_exp_capabilities_t* pCapability ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zesVFManagementGetVFCapabilitiesExpEpilogue( zes_vf_handle_t hVFhandle, zes_vf_exp_capabilities_t* pCapability ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zesVFManagementGetVFMemoryUtilizationExp2Prologue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_mem_exp2_t* pMemUtil ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zesVFManagementGetVFMemoryUtilizationExp2Epilogue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_mem_exp2_t* pMemUtil ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zesVFManagementGetVFEngineUtilizationExp2Prologue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_engine_exp2_t* pEngineUtil ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zesVFManagementGetVFEngineUtilizationExp2Epilogue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_engine_exp2_t* pEngineUtil ) {return ZE_RESULT_SUCCESS;} virtual ~ZESValidationEntryPoints() {} }; } \ No newline at end of file diff --git a/source/layers/validation/common/zet_entry_points.h b/source/layers/validation/common/zet_entry_points.h index 129c5515..ec5d5a40 100644 --- a/source/layers/validation/common/zet_entry_points.h +++ b/source/layers/validation/common/zet_entry_points.h @@ -95,6 +95,26 @@ class ZETValidationEntryPoints { virtual ze_result_t zetTracerExpSetEpiloguesEpilogue( zet_tracer_exp_handle_t hTracer, zet_core_callbacks_t* pCoreCbs ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zetTracerExpSetEnabledPrologue( zet_tracer_exp_handle_t hTracer, ze_bool_t enable ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zetTracerExpSetEnabledEpilogue( zet_tracer_exp_handle_t hTracer, ze_bool_t enable ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetDeviceGetConcurrentMetricGroupsExpPrologue( zet_device_handle_t hDevice, uint32_t metricGroupCount, zet_metric_group_handle_t * phMetricGroups, uint32_t * pMetricGroupsCountPerConcurrentGroup, uint32_t * pConcurrentGroupCount ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetDeviceGetConcurrentMetricGroupsExpEpilogue( zet_device_handle_t hDevice, uint32_t metricGroupCount, zet_metric_group_handle_t * phMetricGroups, uint32_t * pMetricGroupsCountPerConcurrentGroup, uint32_t * pConcurrentGroupCount ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetMetricTracerCreateExpPrologue( zet_context_handle_t hContext, zet_device_handle_t hDevice, uint32_t metricGroupCount, zet_metric_group_handle_t* phMetricGroups, zet_metric_tracer_exp_desc_t* desc, ze_event_handle_t hNotificationEvent, zet_metric_tracer_exp_handle_t* phMetricTracer ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetMetricTracerCreateExpEpilogue( zet_context_handle_t hContext, zet_device_handle_t hDevice, uint32_t metricGroupCount, zet_metric_group_handle_t* phMetricGroups, zet_metric_tracer_exp_desc_t* desc, ze_event_handle_t hNotificationEvent, zet_metric_tracer_exp_handle_t* phMetricTracer ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetMetricTracerDestroyExpPrologue( zet_metric_tracer_exp_handle_t hMetricTracer ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetMetricTracerDestroyExpEpilogue( zet_metric_tracer_exp_handle_t hMetricTracer ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetMetricTracerEnableExpPrologue( zet_metric_tracer_exp_handle_t hMetricTracer, ze_bool_t synchronous ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetMetricTracerEnableExpEpilogue( zet_metric_tracer_exp_handle_t hMetricTracer, ze_bool_t synchronous ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetMetricTracerDisableExpPrologue( zet_metric_tracer_exp_handle_t hMetricTracer, ze_bool_t synchronous ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetMetricTracerDisableExpEpilogue( zet_metric_tracer_exp_handle_t hMetricTracer, ze_bool_t synchronous ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetMetricTracerReadDataExpPrologue( zet_metric_tracer_exp_handle_t hMetricTracer, size_t* pRawDataSize, uint8_t* pRawData ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetMetricTracerReadDataExpEpilogue( zet_metric_tracer_exp_handle_t hMetricTracer, size_t* pRawDataSize, uint8_t* pRawData ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetMetricDecoderCreateExpPrologue( zet_metric_tracer_exp_handle_t hMetricTracer, zet_metric_decoder_exp_handle_t* phMetricDecoder ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetMetricDecoderCreateExpEpilogue( zet_metric_tracer_exp_handle_t hMetricTracer, zet_metric_decoder_exp_handle_t* phMetricDecoder ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetMetricDecoderDestroyExpPrologue( zet_metric_decoder_exp_handle_t phMetricDecoder ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetMetricDecoderDestroyExpEpilogue( zet_metric_decoder_exp_handle_t phMetricDecoder ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetMetricDecoderGetDecodableMetricsExpPrologue( zet_metric_decoder_exp_handle_t hMetricDecoder, uint32_t* pCount, zet_metric_handle_t* phMetrics ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetMetricDecoderGetDecodableMetricsExpEpilogue( zet_metric_decoder_exp_handle_t hMetricDecoder, uint32_t* pCount, zet_metric_handle_t* phMetrics ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetMetricTracerDecodeExpPrologue( zet_metric_decoder_exp_handle_t phMetricDecoder, size_t* pRawDataSize, uint8_t* pRawData, uint32_t metricsCount, zet_metric_handle_t* phMetrics, uint32_t* pSetCount, uint32_t* pMetricEntriesCountPerSet, uint32_t* pMetricEntriesCount, zet_metric_entry_exp_t* pMetricEntries ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetMetricTracerDecodeExpEpilogue( zet_metric_decoder_exp_handle_t phMetricDecoder, size_t* pRawDataSize, uint8_t* pRawData, uint32_t metricsCount, zet_metric_handle_t* phMetrics, uint32_t* pSetCount, uint32_t* pMetricEntriesCountPerSet, uint32_t* pMetricEntriesCount, zet_metric_entry_exp_t* pMetricEntries ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zetMetricGroupCalculateMultipleMetricValuesExpPrologue( zet_metric_group_handle_t hMetricGroup, zet_metric_group_calculation_type_t type, size_t rawDataSize, const uint8_t* pRawData, uint32_t* pSetCount, uint32_t* pTotalMetricValueCount, uint32_t* pMetricCounts, zet_typed_value_t* pMetricValues ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zetMetricGroupCalculateMultipleMetricValuesExpEpilogue( zet_metric_group_handle_t hMetricGroup, zet_metric_group_calculation_type_t type, size_t rawDataSize, const uint8_t* pRawData, uint32_t* pSetCount, uint32_t* pTotalMetricValueCount, uint32_t* pMetricCounts, zet_typed_value_t* pMetricValues ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zetMetricGroupGetGlobalTimestampsExpPrologue( zet_metric_group_handle_t hMetricGroup, ze_bool_t synchronizedWithHost, uint64_t* globalTimestamp, uint64_t* metricTimestamp ) {return ZE_RESULT_SUCCESS;} @@ -111,8 +131,12 @@ class ZETValidationEntryPoints { virtual ze_result_t zetMetricProgrammableGetParamInfoExpEpilogue( zet_metric_programmable_exp_handle_t hMetricProgrammable, uint32_t* pParameterCount, zet_metric_programmable_param_info_exp_t* pParameterInfo ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zetMetricProgrammableGetParamValueInfoExpPrologue( zet_metric_programmable_exp_handle_t hMetricProgrammable, uint32_t parameterOrdinal, uint32_t* pValueInfoCount, zet_metric_programmable_param_value_info_exp_t* pValueInfo ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zetMetricProgrammableGetParamValueInfoExpEpilogue( zet_metric_programmable_exp_handle_t hMetricProgrammable, uint32_t parameterOrdinal, uint32_t* pValueInfoCount, zet_metric_programmable_param_value_info_exp_t* pValueInfo ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetMetricCreateFromProgrammableExp2Prologue( zet_metric_programmable_exp_handle_t hMetricProgrammable, uint32_t parameterCount, zet_metric_programmable_param_value_exp_t* pParameterValues, const char* pName, const char* pDescription, uint32_t* pMetricHandleCount, zet_metric_handle_t* phMetricHandles ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetMetricCreateFromProgrammableExp2Epilogue( zet_metric_programmable_exp_handle_t hMetricProgrammable, uint32_t parameterCount, zet_metric_programmable_param_value_exp_t* pParameterValues, const char* pName, const char* pDescription, uint32_t* pMetricHandleCount, zet_metric_handle_t* phMetricHandles ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zetMetricCreateFromProgrammableExpPrologue( zet_metric_programmable_exp_handle_t hMetricProgrammable, zet_metric_programmable_param_value_exp_t* pParameterValues, uint32_t parameterCount, const char* pName, const char* pDescription, uint32_t* pMetricHandleCount, zet_metric_handle_t* phMetricHandles ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zetMetricCreateFromProgrammableExpEpilogue( zet_metric_programmable_exp_handle_t hMetricProgrammable, zet_metric_programmable_param_value_exp_t* pParameterValues, uint32_t parameterCount, const char* pName, const char* pDescription, uint32_t* pMetricHandleCount, zet_metric_handle_t* phMetricHandles ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetDeviceCreateMetricGroupsFromMetricsExpPrologue( zet_device_handle_t hDevice, uint32_t metricCount, zet_metric_handle_t * phMetrics, const char * pMetricGroupNamePrefix, const char * pDescription, uint32_t * pMetricGroupCount, zet_metric_group_handle_t* phMetricGroup ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetDeviceCreateMetricGroupsFromMetricsExpEpilogue( zet_device_handle_t hDevice, uint32_t metricCount, zet_metric_handle_t * phMetrics, const char * pMetricGroupNamePrefix, const char * pDescription, uint32_t * pMetricGroupCount, zet_metric_group_handle_t* phMetricGroup ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zetMetricGroupCreateExpPrologue( zet_device_handle_t hDevice, const char* pName, const char* pDescription, zet_metric_group_sampling_type_flags_t samplingType, zet_metric_group_handle_t* phMetricGroup ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zetMetricGroupCreateExpEpilogue( zet_device_handle_t hDevice, const char* pName, const char* pDescription, zet_metric_group_sampling_type_flags_t samplingType, zet_metric_group_handle_t* phMetricGroup ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zetMetricGroupAddMetricExpPrologue( zet_metric_group_handle_t hMetricGroup, zet_metric_handle_t hMetric, size_t * pErrorStringSize, char* pErrorString ) {return ZE_RESULT_SUCCESS;} diff --git a/source/layers/validation/handle_lifetime_tracking/ze_handle_lifetime.cpp b/source/layers/validation/handle_lifetime_tracking/ze_handle_lifetime.cpp index 0f122fc3..5e2bd8e6 100644 --- a/source/layers/validation/handle_lifetime_tracking/ze_handle_lifetime.cpp +++ b/source/layers/validation/handle_lifetime_tracking/ze_handle_lifetime.cpp @@ -329,9 +329,9 @@ namespace validation_layer ZEHandleLifetimeValidation::zeDeviceGetGlobalTimestampsPrologue( ze_device_handle_t hDevice, ///< [in] handle of the device uint64_t* hostTimestamp, ///< [out] value of the Host's global timestamp that correlates with the - ///< Device's global timestamp value + ///< Device's global timestamp value. uint64_t* deviceTimestamp ///< [out] value of the Device's global timestamp that correlates with the - ///< Host's global timestamp value + ///< Host's global timestamp value. ) { @@ -2374,7 +2374,8 @@ namespace validation_layer ze_result_t ZEHandleLifetimeValidation::zePhysicalMemCreatePrologue( ze_context_handle_t hContext, ///< [in] handle of the context object - ze_device_handle_t hDevice, ///< [in] handle of the device object + ze_device_handle_t hDevice, ///< [in] handle of the device object, can be `nullptr` if creating + ///< physical host memory. ze_physical_mem_desc_t* desc, ///< [in] pointer to physical memory descriptor. ze_physical_mem_handle_t* phPhysicalMemory ///< [out] pointer to handle of physical memory object created ) @@ -2496,6 +2497,110 @@ namespace validation_layer return ZE_RESULT_SUCCESS; } ze_result_t + ZEHandleLifetimeValidation::zeCommandListGetNextCommandIdExpPrologue( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_command_id_exp_desc_t* desc, ///< [in] pointer to mutable command identifier descriptor + uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written + ) + { + + if ( !context.handleLifetime->isHandleValid( hCommandList )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + return ZE_RESULT_SUCCESS; + } + ze_result_t + ZEHandleLifetimeValidation::zeCommandListGetNextCommandIdWithKernelsExpPrologue( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_command_id_exp_desc_t* desc, ///< [in][out] pointer to mutable command identifier descriptor + uint32_t numKernels, ///< [in][optional] number of entries on phKernels list + ze_kernel_handle_t* phKernels, ///< [in][optional][range(0, numKernels)] list of kernels that user can + ///< switch between using ::zeCommandListUpdateMutableCommandKernelsExp + ///< call + uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written + ) + { + + if ( !context.handleLifetime->isHandleValid( hCommandList )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + for (size_t i = 0; ( nullptr != phKernels) && (i < numKernels); ++i){ + if (!context.handleLifetime->isHandleValid( phKernels[i] )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + } + return ZE_RESULT_SUCCESS; + } + ze_result_t + ZEHandleLifetimeValidation::zeCommandListUpdateMutableCommandsExpPrologue( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_commands_exp_desc_t* desc ///< [in] pointer to mutable commands descriptor; multiple descriptors may + ///< be chained via `pNext` member + ) + { + + if ( !context.handleLifetime->isHandleValid( hCommandList )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + return ZE_RESULT_SUCCESS; + } + ze_result_t + ZEHandleLifetimeValidation::zeCommandListUpdateMutableCommandSignalEventExpPrologue( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint64_t commandId, ///< [in] command identifier + ze_event_handle_t hSignalEvent ///< [in][optional] handle of the event to signal on completion + ) + { + + if ( !context.handleLifetime->isHandleValid( hCommandList )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (hSignalEvent && !context.handleLifetime->isHandleValid( hSignalEvent )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + return ZE_RESULT_SUCCESS; + } + ze_result_t + ZEHandleLifetimeValidation::zeCommandListUpdateMutableCommandWaitEventsExpPrologue( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint64_t commandId, ///< [in] command identifier + uint32_t numWaitEvents, ///< [in][optional] the number of wait events + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + + if ( !context.handleLifetime->isHandleValid( hCommandList )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + for (size_t i = 0; ( nullptr != phWaitEvents) && (i < numWaitEvents); ++i){ + if (!context.handleLifetime->isHandleValid( phWaitEvents[i] )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + } + return ZE_RESULT_SUCCESS; + } + ze_result_t + ZEHandleLifetimeValidation::zeCommandListUpdateMutableCommandKernelsExpPrologue( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint32_t numKernels, ///< [in] the number of kernels to update + uint64_t* pCommandId, ///< [in][range(0, numKernels)] command identifier + ze_kernel_handle_t* phKernels ///< [in][range(0, numKernels)] handle of the kernel for a command + ///< identifier to switch to + ) + { + + if ( !context.handleLifetime->isHandleValid( hCommandList )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + for (size_t i = 0; ( nullptr != phKernels) && (i < numKernels); ++i){ + if (!context.handleLifetime->isHandleValid( phKernels[i] )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + } + return ZE_RESULT_SUCCESS; + } + ze_result_t ZEHandleLifetimeValidation::zeDeviceReserveCacheExtPrologue( ze_device_handle_t hDevice, ///< [in] handle of the device object size_t cacheLevel, ///< [in] cache level where application want to reserve. If zero, then the @@ -3102,66 +3207,4 @@ namespace validation_layer } return ZE_RESULT_SUCCESS; } - ze_result_t - ZEHandleLifetimeValidation::zeCommandListGetNextCommandIdExpPrologue( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - const ze_mutable_command_id_exp_desc_t* desc, ///< [in] pointer to mutable command identifier descriptor - uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written - ) - { - - if ( !context.handleLifetime->isHandleValid( hCommandList )){ - return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; - } - return ZE_RESULT_SUCCESS; - } - ze_result_t - ZEHandleLifetimeValidation::zeCommandListUpdateMutableCommandsExpPrologue( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - const ze_mutable_commands_exp_desc_t* desc ///< [in] pointer to mutable commands descriptor; multiple descriptors may - ///< be chained via `pNext` member - ) - { - - if ( !context.handleLifetime->isHandleValid( hCommandList )){ - return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; - } - return ZE_RESULT_SUCCESS; - } - ze_result_t - ZEHandleLifetimeValidation::zeCommandListUpdateMutableCommandSignalEventExpPrologue( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - uint64_t commandId, ///< [in] command identifier - ze_event_handle_t hSignalEvent ///< [in][optional] handle of the event to signal on completion - ) - { - - if ( !context.handleLifetime->isHandleValid( hCommandList )){ - return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; - } - if (hSignalEvent && !context.handleLifetime->isHandleValid( hSignalEvent )){ - return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; - } - return ZE_RESULT_SUCCESS; - } - ze_result_t - ZEHandleLifetimeValidation::zeCommandListUpdateMutableCommandWaitEventsExpPrologue( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - uint64_t commandId, ///< [in] command identifier - uint32_t numWaitEvents, ///< [in][optional] the number of wait events - ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait - ///< on before launching - ) - { - - if ( !context.handleLifetime->isHandleValid( hCommandList )){ - return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; - } - for (size_t i = 0; ( nullptr != phWaitEvents) && (i < numWaitEvents); ++i){ - if (!context.handleLifetime->isHandleValid( phWaitEvents[i] )){ - return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; - } - } - return ZE_RESULT_SUCCESS; - } } \ No newline at end of file diff --git a/source/layers/validation/handle_lifetime_tracking/ze_handle_lifetime.h b/source/layers/validation/handle_lifetime_tracking/ze_handle_lifetime.h index 92e85be7..43f41ad1 100644 --- a/source/layers/validation/handle_lifetime_tracking/ze_handle_lifetime.h +++ b/source/layers/validation/handle_lifetime_tracking/ze_handle_lifetime.h @@ -19,7 +19,7 @@ namespace validation_layer class ZEHandleLifetimeValidation : public ZEValidationEntryPoints { public: - ze_result_t zeDriverGetApiVersionPrologue( ze_driver_handle_t hDriver, ze_api_version_t* version ) override; + ze_result_t zeDriverGetApiVersionPrologue( ze_driver_handle_t hDriver, ze_api_version_t* version ) override; ze_result_t zeDriverGetPropertiesPrologue( ze_driver_handle_t hDriver, ze_driver_properties_t* pDriverProperties ) override; ze_result_t zeDriverGetIpcPropertiesPrologue( ze_driver_handle_t hDriver, ze_driver_ipc_properties_t* pIpcProperties ) override; ze_result_t zeDriverGetExtensionPropertiesPrologue( ze_driver_handle_t hDriver, uint32_t* pCount, ze_driver_extension_properties_t* pExtensionProperties ) override; @@ -162,6 +162,12 @@ namespace validation_layer ze_result_t zeVirtualMemSetAccessAttributePrologue( ze_context_handle_t hContext, const void* ptr, size_t size, ze_memory_access_attribute_t access ) override; ze_result_t zeVirtualMemGetAccessAttributePrologue( ze_context_handle_t hContext, const void* ptr, size_t size, ze_memory_access_attribute_t* access, size_t* outSize ) override; ze_result_t zeKernelSetGlobalOffsetExpPrologue( ze_kernel_handle_t hKernel, uint32_t offsetX, uint32_t offsetY, uint32_t offsetZ ) override; + ze_result_t zeCommandListGetNextCommandIdExpPrologue( ze_command_list_handle_t hCommandList, const ze_mutable_command_id_exp_desc_t* desc, uint64_t* pCommandId ) override; + ze_result_t zeCommandListGetNextCommandIdWithKernelsExpPrologue( ze_command_list_handle_t hCommandList, const ze_mutable_command_id_exp_desc_t* desc, uint32_t numKernels, ze_kernel_handle_t* phKernels, uint64_t* pCommandId ) override; + ze_result_t zeCommandListUpdateMutableCommandsExpPrologue( ze_command_list_handle_t hCommandList, const ze_mutable_commands_exp_desc_t* desc ) override; + ze_result_t zeCommandListUpdateMutableCommandSignalEventExpPrologue( ze_command_list_handle_t hCommandList, uint64_t commandId, ze_event_handle_t hSignalEvent ) override; + ze_result_t zeCommandListUpdateMutableCommandWaitEventsExpPrologue( ze_command_list_handle_t hCommandList, uint64_t commandId, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) override; + ze_result_t zeCommandListUpdateMutableCommandKernelsExpPrologue( ze_command_list_handle_t hCommandList, uint32_t numKernels, uint64_t* pCommandId, ze_kernel_handle_t* phKernels ) override; ze_result_t zeDeviceReserveCacheExtPrologue( ze_device_handle_t hDevice, size_t cacheLevel, size_t cacheReservationSize ) override; ze_result_t zeDeviceSetCacheAdviceExtPrologue( ze_device_handle_t hDevice, void* ptr, size_t regionSize, ze_cache_ext_region_t cacheRegion ) override; ze_result_t zeEventQueryTimestampsExpPrologue( ze_event_handle_t hEvent, ze_device_handle_t hDevice, uint32_t* pCount, ze_kernel_timestamp_result_t* pTimestamps ) override; @@ -197,10 +203,6 @@ namespace validation_layer ze_result_t zeImageGetDeviceOffsetExpPrologue( ze_image_handle_t hImage, uint64_t* pDeviceOffset ) override; ze_result_t zeCommandListCreateCloneExpPrologue( ze_command_list_handle_t hCommandList, ze_command_list_handle_t* phClonedCommandList ) override; ze_result_t zeCommandListImmediateAppendCommandListsExpPrologue( ze_command_list_handle_t hCommandListImmediate, uint32_t numCommandLists, ze_command_list_handle_t* phCommandLists, ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) override; - ze_result_t zeCommandListGetNextCommandIdExpPrologue( ze_command_list_handle_t hCommandList, const ze_mutable_command_id_exp_desc_t* desc, uint64_t* pCommandId ) override; - ze_result_t zeCommandListUpdateMutableCommandsExpPrologue( ze_command_list_handle_t hCommandList, const ze_mutable_commands_exp_desc_t* desc ) override; - ze_result_t zeCommandListUpdateMutableCommandSignalEventExpPrologue( ze_command_list_handle_t hCommandList, uint64_t commandId, ze_event_handle_t hSignalEvent ) override; - ze_result_t zeCommandListUpdateMutableCommandWaitEventsExpPrologue( ze_command_list_handle_t hCommandList, uint64_t commandId, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) override; }; } diff --git a/source/layers/validation/handle_lifetime_tracking/zes_handle_lifetime.cpp b/source/layers/validation/handle_lifetime_tracking/zes_handle_lifetime.cpp index 51eebedd..f3aab2d2 100644 --- a/source/layers/validation/handle_lifetime_tracking/zes_handle_lifetime.cpp +++ b/source/layers/validation/handle_lifetime_tracking/zes_handle_lifetime.cpp @@ -2144,6 +2144,84 @@ namespace validation_layer ) { + if ( !context.handleLifetime->isHandleValid( hVFhandle )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + return ZE_RESULT_SUCCESS; + } + ze_result_t + ZESHandleLifetimeValidation::zesDeviceEnumEnabledVFExpPrologue( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_vf_handle_t* phVFhandle ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + + if ( !context.handleLifetime->isHandleValid( hDevice )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + return ZE_RESULT_SUCCESS; + } + ze_result_t + ZESHandleLifetimeValidation::zesVFManagementGetVFCapabilitiesExpPrologue( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. + zes_vf_exp_capabilities_t* pCapability ///< [in,out] Will contain VF capability. + ) + { + + if ( !context.handleLifetime->isHandleValid( hVFhandle )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + return ZE_RESULT_SUCCESS; + } + ze_result_t + ZESHandleLifetimeValidation::zesVFManagementGetVFMemoryUtilizationExp2Prologue( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF memory stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of memory stats available. + ///< - if count is greater than the total number of memory stats + ///< available, the driver shall update the value with the correct number + ///< of memory stats available. + zes_vf_util_mem_exp2_t* pMemUtil ///< [in,out][optional][range(0, *pCount)] array of memory group activity counters. + ///< - if count is less than the total number of memory stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector pCount-1 number of VF + ///< memory stats. + ) + { + + if ( !context.handleLifetime->isHandleValid( hVFhandle )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + return ZE_RESULT_SUCCESS; + } + ze_result_t + ZESHandleLifetimeValidation::zesVFManagementGetVFEngineUtilizationExp2Prologue( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF engine stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of engine stats available. + ///< - if count is greater than the total number of engine stats + ///< available, the driver shall update the value with the correct number + ///< of engine stats available. + zes_vf_util_engine_exp2_t* pEngineUtil ///< [in,out][optional][range(0, *pCount)] array of engine group activity counters. + ///< - if count is less than the total number of engine stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector pCount-1 number of VF + ///< engine stats. + ) + { + if ( !context.handleLifetime->isHandleValid( hVFhandle )){ return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; } diff --git a/source/layers/validation/handle_lifetime_tracking/zes_handle_lifetime.h b/source/layers/validation/handle_lifetime_tracking/zes_handle_lifetime.h index 957d7068..2d27779c 100644 --- a/source/layers/validation/handle_lifetime_tracking/zes_handle_lifetime.h +++ b/source/layers/validation/handle_lifetime_tracking/zes_handle_lifetime.h @@ -161,6 +161,10 @@ namespace validation_layer ze_result_t zesVFManagementGetVFEngineUtilizationExpPrologue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_engine_exp_t* pEngineUtil ) override; ze_result_t zesVFManagementSetVFTelemetryModeExpPrologue( zes_vf_handle_t hVFhandle, zes_vf_info_util_exp_flags_t flags, ze_bool_t enable ) override; ze_result_t zesVFManagementSetVFTelemetrySamplingIntervalExpPrologue( zes_vf_handle_t hVFhandle, zes_vf_info_util_exp_flags_t flag, uint64_t samplingInterval ) override; + ze_result_t zesDeviceEnumEnabledVFExpPrologue( zes_device_handle_t hDevice, uint32_t* pCount, zes_vf_handle_t* phVFhandle ) override; + ze_result_t zesVFManagementGetVFCapabilitiesExpPrologue( zes_vf_handle_t hVFhandle, zes_vf_exp_capabilities_t* pCapability ) override; + ze_result_t zesVFManagementGetVFMemoryUtilizationExp2Prologue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_mem_exp2_t* pMemUtil ) override; + ze_result_t zesVFManagementGetVFEngineUtilizationExp2Prologue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_engine_exp2_t* pEngineUtil ) override; }; } diff --git a/source/layers/validation/handle_lifetime_tracking/zet_handle_lifetime.cpp b/source/layers/validation/handle_lifetime_tracking/zet_handle_lifetime.cpp index 430085e9..82e5f877 100644 --- a/source/layers/validation/handle_lifetime_tracking/zet_handle_lifetime.cpp +++ b/source/layers/validation/handle_lifetime_tracking/zet_handle_lifetime.cpp @@ -655,6 +655,220 @@ namespace validation_layer return ZE_RESULT_SUCCESS; } ze_result_t + ZETHandleLifetimeValidation::zetDeviceGetConcurrentMetricGroupsExpPrologue( + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t metricGroupCount, ///< [in] metric group count + zet_metric_group_handle_t * phMetricGroups, ///< [in,out] metrics groups to be re-arranged to be sets of concurrent + ///< groups + uint32_t * pMetricGroupsCountPerConcurrentGroup,///< [in,out][optional][*pConcurrentGroupCount] count of metric groups per + ///< concurrent group. + uint32_t * pConcurrentGroupCount ///< [out] number of concurrent groups. + ///< The value of this parameter could be used to determine the number of + ///< replays necessary. + ) + { + + if ( !context.handleLifetime->isHandleValid( hDevice )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + return ZE_RESULT_SUCCESS; + } + ze_result_t + ZETHandleLifetimeValidation::zetMetricTracerCreateExpPrologue( + zet_context_handle_t hContext, ///< [in] handle of the context object + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t metricGroupCount, ///< [in] metric group count + zet_metric_group_handle_t* phMetricGroups, ///< [in][range(0, metricGroupCount )] handles of the metric groups to + ///< trace + zet_metric_tracer_exp_desc_t* desc, ///< [in,out] metric tracer descriptor + ze_event_handle_t hNotificationEvent, ///< [in][optional] event used for report availability notification. Note: + ///< If buffer is not drained when the event it flagged, there is a risk of + ///< HW event buffer being overrun + zet_metric_tracer_exp_handle_t* phMetricTracer ///< [out] handle of the metric tracer + ) + { + + if ( !context.handleLifetime->isHandleValid( hContext )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if ( !context.handleLifetime->isHandleValid( hDevice )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + for (size_t i = 0; ( nullptr != phMetricGroups) && (i < metricGroupCount ); ++i){ + if (!context.handleLifetime->isHandleValid( phMetricGroups[i] )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + } + if (hNotificationEvent && !context.handleLifetime->isHandleValid( hNotificationEvent )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + return ZE_RESULT_SUCCESS; + } + ze_result_t + ZETHandleLifetimeValidation::zetMetricTracerDestroyExpPrologue( + zet_metric_tracer_exp_handle_t hMetricTracer ///< [in] handle of the metric tracer + ) + { + + if ( !context.handleLifetime->isHandleValid( hMetricTracer )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + return ZE_RESULT_SUCCESS; + } + ze_result_t + ZETHandleLifetimeValidation::zetMetricTracerEnableExpPrologue( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + ze_bool_t synchronous ///< [in] request synchronous behavior. Confirmation of successful + ///< asynchronous operation is done by calling ::zetMetricTracerReadDataExp() + ///< and checking the return status: ::ZE_RESULT_NOT_READY will be returned + ///< when the tracer is inactive. ::ZE_RESULT_SUCCESS will be returned + ///< when the tracer is active. + ) + { + + if ( !context.handleLifetime->isHandleValid( hMetricTracer )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + return ZE_RESULT_SUCCESS; + } + ze_result_t + ZETHandleLifetimeValidation::zetMetricTracerDisableExpPrologue( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + ze_bool_t synchronous ///< [in] request synchronous behavior. Confirmation of successful + ///< asynchronous operation is done by calling ::zetMetricTracerReadDataExp() + ///< and checking the return status: ::ZE_RESULT_SUCCESS will be returned + ///< when the tracer is active or when it is inactive but still has data. + ///< ::ZE_RESULT_NOT_READY will be returned when the tracer is inactive and + ///< has no more data to be retrieved. + ) + { + + if ( !context.handleLifetime->isHandleValid( hMetricTracer )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + return ZE_RESULT_SUCCESS; + } + ze_result_t + ZETHandleLifetimeValidation::zetMetricTracerReadDataExpPrologue( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + size_t* pRawDataSize, ///< [in,out] pointer to size in bytes of raw data requested to read. + ///< if size is zero, then the driver will update the value with the total + ///< size in bytes needed for all data available. + ///< if size is non-zero, then driver will only retrieve that amount of + ///< data. + ///< if size is larger than size needed for all data, then driver will + ///< update the value with the actual size needed. + uint8_t* pRawData ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing tracer + ///< data in raw format + ) + { + + if ( !context.handleLifetime->isHandleValid( hMetricTracer )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + return ZE_RESULT_SUCCESS; + } + ze_result_t + ZETHandleLifetimeValidation::zetMetricDecoderCreateExpPrologue( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + zet_metric_decoder_exp_handle_t* phMetricDecoder///< [out] handle of the metric decoder object + ) + { + + if ( !context.handleLifetime->isHandleValid( hMetricTracer )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + return ZE_RESULT_SUCCESS; + } + ze_result_t + ZETHandleLifetimeValidation::zetMetricDecoderDestroyExpPrologue( + zet_metric_decoder_exp_handle_t phMetricDecoder ///< [in] handle of the metric decoder object + ) + { + + if ( !context.handleLifetime->isHandleValid( phMetricDecoder )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + return ZE_RESULT_SUCCESS; + } + ze_result_t + ZETHandleLifetimeValidation::zetMetricDecoderGetDecodableMetricsExpPrologue( + zet_metric_decoder_exp_handle_t hMetricDecoder, ///< [in] handle of the metric decoder object + uint32_t* pCount, ///< [in,out] pointer to number of decodable metric in the hMetricDecoder + ///< handle. If count is zero, then the driver shall + ///< update the value with the total number of decodable metrics available + ///< in the decoder. if count is greater than zero + ///< but less than the total number of decodable metrics available in the + ///< decoder, then only that number will be returned. + ///< if count is greater than the number of decodable metrics available in + ///< the decoder, then the driver shall update the + ///< value with the actual number of decodable metrics available. + zet_metric_handle_t* phMetrics ///< [in,out] [range(0, *pCount)] array of handles of decodable metrics in + ///< the hMetricDecoder handle provided. + ) + { + + if ( !context.handleLifetime->isHandleValid( hMetricDecoder )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + return ZE_RESULT_SUCCESS; + } + ze_result_t + ZETHandleLifetimeValidation::zetMetricTracerDecodeExpPrologue( + zet_metric_decoder_exp_handle_t phMetricDecoder,///< [in] handle of the metric decoder object + size_t* pRawDataSize, ///< [in,out] size in bytes of raw data buffer. If pMetricEntriesCount is + ///< greater than zero but less than total number of + ///< decodable metrics available in the raw data buffer, then driver shall + ///< update this value with actual number of raw + ///< data bytes processed. + uint8_t* pRawData, ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing tracer + ///< data in raw format + uint32_t metricsCount, ///< [in] number of decodable metrics in the tracer for which the + ///< hMetricDecoder handle was provided. See + ///< ::zetMetricDecoderGetDecodableMetricsExp(). If metricCount is greater + ///< than zero but less than the number decodable + ///< metrics available in the raw data buffer, then driver shall only + ///< decode those. + zet_metric_handle_t* phMetrics, ///< [in] [range(0, metricsCount)] array of handles of decodable metrics in + ///< the decoder for which the hMetricDecoder handle was + ///< provided. Metrics handles are expected to be for decodable metrics, + ///< see ::zetMetricDecoderGetDecodableMetrics() + uint32_t* pSetCount, ///< [in,out] pointer to number of metric sets. If count is zero, then the + ///< driver shall update the value with the total + ///< number of metric sets to be decoded. If count is greater than the + ///< number available in the raw data buffer, then the + ///< driver shall update the value with the actual number of metric sets to + ///< be decoded. There is a 1:1 relation between + ///< the number of sets and sub-devices returned in the decoded entries. + uint32_t* pMetricEntriesCountPerSet, ///< [in,out][optional][range(0, *pSetCount)] buffer of metric entries + ///< counts per metric set, one value per set. + uint32_t* pMetricEntriesCount, ///< [in,out] pointer to the total number of metric entries decoded, for + ///< all metric sets. If count is zero, then the + ///< driver shall update the value with the total number of metric entries + ///< to be decoded. If count is greater than zero + ///< but less than the total number of metric entries available in the raw + ///< data, then user provided number will be decoded. + ///< If count is greater than the number available in the raw data buffer, + ///< then the driver shall update the value with + ///< the actual number of decodable metric entries decoded. If set to null, + ///< then driver will only update the value of + ///< pSetCount. + zet_metric_entry_exp_t* pMetricEntries ///< [in,out][optional][range(0, *pMetricEntriesCount)] buffer containing + ///< decoded metric entries + ) + { + + if ( !context.handleLifetime->isHandleValid( phMetricDecoder )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + for (size_t i = 0; ( nullptr != phMetrics) && (i < metricsCount); ++i){ + if (!context.handleLifetime->isHandleValid( phMetrics[i] )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + } + return ZE_RESULT_SUCCESS; + } + ze_result_t ZETHandleLifetimeValidation::zetMetricGroupCalculateMultipleMetricValuesExpPrologue( zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group zet_metric_group_calculation_type_t type, ///< [in] calculation type to be applied on raw data @@ -826,6 +1040,33 @@ namespace validation_layer return ZE_RESULT_SUCCESS; } ze_result_t + ZETHandleLifetimeValidation::zetMetricCreateFromProgrammableExp2Prologue( + zet_metric_programmable_exp_handle_t hMetricProgrammable, ///< [in] handle of the metric programmable + uint32_t parameterCount, ///< [in] Count of parameters to set. + zet_metric_programmable_param_value_exp_t* pParameterValues,///< [in] list of parameter values to be set. + const char* pName, ///< [in] pointer to metric name to be used. Must point to a + ///< null-terminated character array no longer than ::ZET_MAX_METRIC_NAME. + const char* pDescription, ///< [in] pointer to metric description to be used. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_DESCRIPTION. + uint32_t* pMetricHandleCount, ///< [in,out] Pointer to the number of metric handles. + ///< if count is zero, then the driver shall update the value with the + ///< number of metric handles available for this programmable. + ///< if count is greater than the number of metric handles available, then + ///< the driver shall update the value with the correct number of metric + ///< handles available. + zet_metric_handle_t* phMetricHandles ///< [in,out][optional][range(0,*pMetricHandleCount)] array of handle of metrics. + ///< if count is less than the number of metrics available, then driver + ///< shall only retrieve that number of metric handles. + ) + { + + if ( !context.handleLifetime->isHandleValid( hMetricProgrammable )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + return ZE_RESULT_SUCCESS; + } + ze_result_t ZETHandleLifetimeValidation::zetMetricCreateFromProgrammableExpPrologue( zet_metric_programmable_exp_handle_t hMetricProgrammable, ///< [in] handle of the metric programmable zet_metric_programmable_param_value_exp_t* pParameterValues,///< [in] list of parameter values to be set. @@ -853,6 +1094,36 @@ namespace validation_layer return ZE_RESULT_SUCCESS; } ze_result_t + ZETHandleLifetimeValidation::zetDeviceCreateMetricGroupsFromMetricsExpPrologue( + zet_device_handle_t hDevice, ///< [in] handle of the device. + uint32_t metricCount, ///< [in] number of metric handles. + zet_metric_handle_t * phMetrics, ///< [in] metric handles to be added to the metric groups. + const char * pMetricGroupNamePrefix, ///< [in] prefix to the name created for the metric groups. Must point to a + ///< null-terminated character array no longer than + ///< ZEX_MAX_METRIC_GROUP_NAME_PREFIX. + const char * pDescription, ///< [in] pointer to description of the metric groups. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_GROUP_DESCRIPTION. + uint32_t * pMetricGroupCount, ///< [in,out] pointer to the number of metric group handles to be created. + ///< if pMetricGroupCount is zero, then the driver shall update the value + ///< with the maximum possible number of metric group handles that could be created. + ///< if pMetricGroupCount is greater than the number of metric group + ///< handles that could be created, then the driver shall update the value + ///< with the correct number of metric group handles generated. + ///< if pMetricGroupCount is lesser than the number of metric group handles + ///< that could be created, then ::ZE_RESULT_ERROR_INVALID_ARGUMENT is returned. + zet_metric_group_handle_t* phMetricGroup ///< [in,out][optional][range(0, *pMetricGroupCount)] array of handle of + ///< metric group handles. + ///< Created Metric group handles. + ) + { + + if ( !context.handleLifetime->isHandleValid( hDevice )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + return ZE_RESULT_SUCCESS; + } + ze_result_t ZETHandleLifetimeValidation::zetMetricGroupCreateExpPrologue( zet_device_handle_t hDevice, ///< [in] handle of the device const char* pName, ///< [in] pointer to metric group name. Must point to a null-terminated diff --git a/source/layers/validation/handle_lifetime_tracking/zet_handle_lifetime.h b/source/layers/validation/handle_lifetime_tracking/zet_handle_lifetime.h index 455ec426..bb3b6ea3 100644 --- a/source/layers/validation/handle_lifetime_tracking/zet_handle_lifetime.h +++ b/source/layers/validation/handle_lifetime_tracking/zet_handle_lifetime.h @@ -58,6 +58,16 @@ namespace validation_layer ze_result_t zetTracerExpSetProloguesPrologue( zet_tracer_exp_handle_t hTracer, zet_core_callbacks_t* pCoreCbs ) override; ze_result_t zetTracerExpSetEpiloguesPrologue( zet_tracer_exp_handle_t hTracer, zet_core_callbacks_t* pCoreCbs ) override; ze_result_t zetTracerExpSetEnabledPrologue( zet_tracer_exp_handle_t hTracer, ze_bool_t enable ) override; + ze_result_t zetDeviceGetConcurrentMetricGroupsExpPrologue( zet_device_handle_t hDevice, uint32_t metricGroupCount, zet_metric_group_handle_t * phMetricGroups, uint32_t * pMetricGroupsCountPerConcurrentGroup, uint32_t * pConcurrentGroupCount ) override; + ze_result_t zetMetricTracerCreateExpPrologue( zet_context_handle_t hContext, zet_device_handle_t hDevice, uint32_t metricGroupCount, zet_metric_group_handle_t* phMetricGroups, zet_metric_tracer_exp_desc_t* desc, ze_event_handle_t hNotificationEvent, zet_metric_tracer_exp_handle_t* phMetricTracer ) override; + ze_result_t zetMetricTracerDestroyExpPrologue( zet_metric_tracer_exp_handle_t hMetricTracer ) override; + ze_result_t zetMetricTracerEnableExpPrologue( zet_metric_tracer_exp_handle_t hMetricTracer, ze_bool_t synchronous ) override; + ze_result_t zetMetricTracerDisableExpPrologue( zet_metric_tracer_exp_handle_t hMetricTracer, ze_bool_t synchronous ) override; + ze_result_t zetMetricTracerReadDataExpPrologue( zet_metric_tracer_exp_handle_t hMetricTracer, size_t* pRawDataSize, uint8_t* pRawData ) override; + ze_result_t zetMetricDecoderCreateExpPrologue( zet_metric_tracer_exp_handle_t hMetricTracer, zet_metric_decoder_exp_handle_t* phMetricDecoder ) override; + ze_result_t zetMetricDecoderDestroyExpPrologue( zet_metric_decoder_exp_handle_t phMetricDecoder ) override; + ze_result_t zetMetricDecoderGetDecodableMetricsExpPrologue( zet_metric_decoder_exp_handle_t hMetricDecoder, uint32_t* pCount, zet_metric_handle_t* phMetrics ) override; + ze_result_t zetMetricTracerDecodeExpPrologue( zet_metric_decoder_exp_handle_t phMetricDecoder, size_t* pRawDataSize, uint8_t* pRawData, uint32_t metricsCount, zet_metric_handle_t* phMetrics, uint32_t* pSetCount, uint32_t* pMetricEntriesCountPerSet, uint32_t* pMetricEntriesCount, zet_metric_entry_exp_t* pMetricEntries ) override; ze_result_t zetMetricGroupCalculateMultipleMetricValuesExpPrologue( zet_metric_group_handle_t hMetricGroup, zet_metric_group_calculation_type_t type, size_t rawDataSize, const uint8_t* pRawData, uint32_t* pSetCount, uint32_t* pTotalMetricValueCount, uint32_t* pMetricCounts, zet_typed_value_t* pMetricValues ) override; ze_result_t zetMetricGroupGetGlobalTimestampsExpPrologue( zet_metric_group_handle_t hMetricGroup, ze_bool_t synchronizedWithHost, uint64_t* globalTimestamp, uint64_t* metricTimestamp ) override; ze_result_t zetMetricGroupGetExportDataExpPrologue( zet_metric_group_handle_t hMetricGroup, const uint8_t* pRawData, size_t rawDataSize, size_t* pExportDataSize, uint8_t * pExportData ) override; @@ -66,7 +76,9 @@ namespace validation_layer ze_result_t zetMetricProgrammableGetPropertiesExpPrologue( zet_metric_programmable_exp_handle_t hMetricProgrammable, zet_metric_programmable_exp_properties_t* pProperties ) override; ze_result_t zetMetricProgrammableGetParamInfoExpPrologue( zet_metric_programmable_exp_handle_t hMetricProgrammable, uint32_t* pParameterCount, zet_metric_programmable_param_info_exp_t* pParameterInfo ) override; ze_result_t zetMetricProgrammableGetParamValueInfoExpPrologue( zet_metric_programmable_exp_handle_t hMetricProgrammable, uint32_t parameterOrdinal, uint32_t* pValueInfoCount, zet_metric_programmable_param_value_info_exp_t* pValueInfo ) override; + ze_result_t zetMetricCreateFromProgrammableExp2Prologue( zet_metric_programmable_exp_handle_t hMetricProgrammable, uint32_t parameterCount, zet_metric_programmable_param_value_exp_t* pParameterValues, const char* pName, const char* pDescription, uint32_t* pMetricHandleCount, zet_metric_handle_t* phMetricHandles ) override; ze_result_t zetMetricCreateFromProgrammableExpPrologue( zet_metric_programmable_exp_handle_t hMetricProgrammable, zet_metric_programmable_param_value_exp_t* pParameterValues, uint32_t parameterCount, const char* pName, const char* pDescription, uint32_t* pMetricHandleCount, zet_metric_handle_t* phMetricHandles ) override; + ze_result_t zetDeviceCreateMetricGroupsFromMetricsExpPrologue( zet_device_handle_t hDevice, uint32_t metricCount, zet_metric_handle_t * phMetrics, const char * pMetricGroupNamePrefix, const char * pDescription, uint32_t * pMetricGroupCount, zet_metric_group_handle_t* phMetricGroup ) override; ze_result_t zetMetricGroupCreateExpPrologue( zet_device_handle_t hDevice, const char* pName, const char* pDescription, zet_metric_group_sampling_type_flags_t samplingType, zet_metric_group_handle_t* phMetricGroup ) override; ze_result_t zetMetricGroupAddMetricExpPrologue( zet_metric_group_handle_t hMetricGroup, zet_metric_handle_t hMetric, size_t * pErrorStringSize, char* pErrorString ) override; ze_result_t zetMetricGroupRemoveMetricExpPrologue( zet_metric_group_handle_t hMetricGroup, zet_metric_handle_t hMetric ) override; diff --git a/source/layers/validation/ze_valddi.cpp b/source/layers/validation/ze_valddi.cpp index 57a7904a..0505abae 100644 --- a/source/layers/validation/ze_valddi.cpp +++ b/source/layers/validation/ze_valddi.cpp @@ -109,6 +109,54 @@ namespace validation_layer return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeInitDrivers + __zedlllocal ze_result_t ZE_APICALL + zeInitDrivers( + uint32_t* pCount, ///< [in,out] pointer to the number of driver instances. + ///< if count is zero, then the loader shall update the value with the + ///< total number of drivers available. + ///< if count is greater than the number of drivers available, then the + ///< loader shall update the value with the correct number of drivers available. + ze_driver_handle_t* phDrivers, ///< [in,out][optional][range(0, *pCount)] array of driver instance handles. + ///< if count is less than the number of drivers available, then the loader + ///< shall only retrieve that number of drivers. + ze_init_driver_type_desc_t* desc ///< [in] descriptor containing the driver type initialization details + ///< including ::ze_init_driver_type_flag_t combinations. + ) + { + auto pfnInitDrivers = context.zeDdiTable.Global.pfnInitDrivers; + + if( nullptr == pfnInitDrivers ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zeValidation->zeInitDriversPrologue( pCount, phDrivers, desc ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zeHandleLifetime.zeInitDriversPrologue( pCount, phDrivers, desc ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnInitDrivers( pCount, phDrivers, desc ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zeValidation->zeInitDriversEpilogue( pCount, phDrivers, desc ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeDriverGetApiVersion __zedlllocal ze_result_t ZE_APICALL @@ -1028,9 +1076,9 @@ namespace validation_layer zeDeviceGetGlobalTimestamps( ze_device_handle_t hDevice, ///< [in] handle of the device uint64_t* hostTimestamp, ///< [out] value of the Host's global timestamp that correlates with the - ///< Device's global timestamp value + ///< Device's global timestamp value. uint64_t* deviceTimestamp ///< [out] value of the Device's global timestamp that correlates with the - ///< Host's global timestamp value + ///< Host's global timestamp value. ) { auto pfnGetGlobalTimestamps = context.zeDdiTable.Device.pfnGetGlobalTimestamps; @@ -6029,7 +6077,8 @@ namespace validation_layer __zedlllocal ze_result_t ZE_APICALL zePhysicalMemCreate( ze_context_handle_t hContext, ///< [in] handle of the context object - ze_device_handle_t hDevice, ///< [in] handle of the device object + ze_device_handle_t hDevice, ///< [in] handle of the device object, can be `nullptr` if creating + ///< physical host memory. ze_physical_mem_desc_t* desc, ///< [in] pointer to physical memory descriptor. ze_physical_mem_handle_t* phPhysicalMemory ///< [out] pointer to handle of physical memory object created ) @@ -6332,6 +6381,268 @@ namespace validation_layer return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListGetNextCommandIdExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListGetNextCommandIdExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_command_id_exp_desc_t* desc, ///< [in] pointer to mutable command identifier descriptor + uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written + ) + { + auto pfnGetNextCommandIdExp = context.zeDdiTable.CommandListExp.pfnGetNextCommandIdExp; + + if( nullptr == pfnGetNextCommandIdExp ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zeValidation->zeCommandListGetNextCommandIdExpPrologue( hCommandList, desc, pCommandId ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zeHandleLifetime.zeCommandListGetNextCommandIdExpPrologue( hCommandList, desc, pCommandId ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnGetNextCommandIdExp( hCommandList, desc, pCommandId ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zeValidation->zeCommandListGetNextCommandIdExpEpilogue( hCommandList, desc, pCommandId ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( result == ZE_RESULT_SUCCESS && context.enableHandleLifetime ){ + + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListGetNextCommandIdWithKernelsExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListGetNextCommandIdWithKernelsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_command_id_exp_desc_t* desc, ///< [in][out] pointer to mutable command identifier descriptor + uint32_t numKernels, ///< [in][optional] number of entries on phKernels list + ze_kernel_handle_t* phKernels, ///< [in][optional][range(0, numKernels)] list of kernels that user can + ///< switch between using ::zeCommandListUpdateMutableCommandKernelsExp + ///< call + uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written + ) + { + auto pfnGetNextCommandIdWithKernelsExp = context.zeDdiTable.CommandListExp.pfnGetNextCommandIdWithKernelsExp; + + if( nullptr == pfnGetNextCommandIdWithKernelsExp ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zeValidation->zeCommandListGetNextCommandIdWithKernelsExpPrologue( hCommandList, desc, numKernels, phKernels, pCommandId ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zeHandleLifetime.zeCommandListGetNextCommandIdWithKernelsExpPrologue( hCommandList, desc, numKernels, phKernels, pCommandId ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnGetNextCommandIdWithKernelsExp( hCommandList, desc, numKernels, phKernels, pCommandId ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zeValidation->zeCommandListGetNextCommandIdWithKernelsExpEpilogue( hCommandList, desc, numKernels, phKernels, pCommandId ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( result == ZE_RESULT_SUCCESS && context.enableHandleLifetime ){ + + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListUpdateMutableCommandsExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_commands_exp_desc_t* desc ///< [in] pointer to mutable commands descriptor; multiple descriptors may + ///< be chained via `pNext` member + ) + { + auto pfnUpdateMutableCommandsExp = context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandsExp; + + if( nullptr == pfnUpdateMutableCommandsExp ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zeValidation->zeCommandListUpdateMutableCommandsExpPrologue( hCommandList, desc ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zeHandleLifetime.zeCommandListUpdateMutableCommandsExpPrologue( hCommandList, desc ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnUpdateMutableCommandsExp( hCommandList, desc ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zeValidation->zeCommandListUpdateMutableCommandsExpEpilogue( hCommandList, desc ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListUpdateMutableCommandSignalEventExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandSignalEventExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint64_t commandId, ///< [in] command identifier + ze_event_handle_t hSignalEvent ///< [in][optional] handle of the event to signal on completion + ) + { + auto pfnUpdateMutableCommandSignalEventExp = context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandSignalEventExp; + + if( nullptr == pfnUpdateMutableCommandSignalEventExp ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zeValidation->zeCommandListUpdateMutableCommandSignalEventExpPrologue( hCommandList, commandId, hSignalEvent ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zeHandleLifetime.zeCommandListUpdateMutableCommandSignalEventExpPrologue( hCommandList, commandId, hSignalEvent ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnUpdateMutableCommandSignalEventExp( hCommandList, commandId, hSignalEvent ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zeValidation->zeCommandListUpdateMutableCommandSignalEventExpEpilogue( hCommandList, commandId, hSignalEvent ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListUpdateMutableCommandWaitEventsExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandWaitEventsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint64_t commandId, ///< [in] command identifier + uint32_t numWaitEvents, ///< [in][optional] the number of wait events + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + auto pfnUpdateMutableCommandWaitEventsExp = context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandWaitEventsExp; + + if( nullptr == pfnUpdateMutableCommandWaitEventsExp ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zeValidation->zeCommandListUpdateMutableCommandWaitEventsExpPrologue( hCommandList, commandId, numWaitEvents, phWaitEvents ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zeHandleLifetime.zeCommandListUpdateMutableCommandWaitEventsExpPrologue( hCommandList, commandId, numWaitEvents, phWaitEvents ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnUpdateMutableCommandWaitEventsExp( hCommandList, commandId, numWaitEvents, phWaitEvents ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zeValidation->zeCommandListUpdateMutableCommandWaitEventsExpEpilogue( hCommandList, commandId, numWaitEvents, phWaitEvents ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListUpdateMutableCommandKernelsExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandKernelsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint32_t numKernels, ///< [in] the number of kernels to update + uint64_t* pCommandId, ///< [in][range(0, numKernels)] command identifier + ze_kernel_handle_t* phKernels ///< [in][range(0, numKernels)] handle of the kernel for a command + ///< identifier to switch to + ) + { + auto pfnUpdateMutableCommandKernelsExp = context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandKernelsExp; + + if( nullptr == pfnUpdateMutableCommandKernelsExp ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zeValidation->zeCommandListUpdateMutableCommandKernelsExpPrologue( hCommandList, numKernels, pCommandId, phKernels ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zeHandleLifetime.zeCommandListUpdateMutableCommandKernelsExpPrologue( hCommandList, numKernels, pCommandId, phKernels ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnUpdateMutableCommandKernelsExp( hCommandList, numKernels, pCommandId, phKernels ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zeValidation->zeCommandListUpdateMutableCommandKernelsExpEpilogue( hCommandList, numKernels, pCommandId, phKernels ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeDeviceReserveCacheExt __zedlllocal ze_result_t ZE_APICALL @@ -7977,176 +8288,6 @@ namespace validation_layer return result; } - /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zeCommandListGetNextCommandIdExp - __zedlllocal ze_result_t ZE_APICALL - zeCommandListGetNextCommandIdExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - const ze_mutable_command_id_exp_desc_t* desc, ///< [in] pointer to mutable command identifier descriptor - uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written - ) - { - auto pfnGetNextCommandIdExp = context.zeDdiTable.CommandListExp.pfnGetNextCommandIdExp; - - if( nullptr == pfnGetNextCommandIdExp ) - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; - - auto numValHandlers = context.validationHandlers.size(); - for (size_t i = 0; i < numValHandlers; i++) { - auto result = context.validationHandlers[i]->zeValidation->zeCommandListGetNextCommandIdExpPrologue( hCommandList, desc, pCommandId ); - if(result!=ZE_RESULT_SUCCESS) return result; - } - - - if( context.enableThreadingValidation ){ - //Unimplemented - } - - - if(context.enableHandleLifetime ){ - auto result = context.handleLifetime->zeHandleLifetime.zeCommandListGetNextCommandIdExpPrologue( hCommandList, desc, pCommandId ); - if(result!=ZE_RESULT_SUCCESS) return result; - } - - auto result = pfnGetNextCommandIdExp( hCommandList, desc, pCommandId ); - - for (size_t i = 0; i < numValHandlers; i++) { - auto result = context.validationHandlers[i]->zeValidation->zeCommandListGetNextCommandIdExpEpilogue( hCommandList, desc, pCommandId ); - if(result!=ZE_RESULT_SUCCESS) return result; - } - - - if( result == ZE_RESULT_SUCCESS && context.enableHandleLifetime ){ - - } - return result; - } - - /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zeCommandListUpdateMutableCommandsExp - __zedlllocal ze_result_t ZE_APICALL - zeCommandListUpdateMutableCommandsExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - const ze_mutable_commands_exp_desc_t* desc ///< [in] pointer to mutable commands descriptor; multiple descriptors may - ///< be chained via `pNext` member - ) - { - auto pfnUpdateMutableCommandsExp = context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandsExp; - - if( nullptr == pfnUpdateMutableCommandsExp ) - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; - - auto numValHandlers = context.validationHandlers.size(); - for (size_t i = 0; i < numValHandlers; i++) { - auto result = context.validationHandlers[i]->zeValidation->zeCommandListUpdateMutableCommandsExpPrologue( hCommandList, desc ); - if(result!=ZE_RESULT_SUCCESS) return result; - } - - - if( context.enableThreadingValidation ){ - //Unimplemented - } - - - if(context.enableHandleLifetime ){ - auto result = context.handleLifetime->zeHandleLifetime.zeCommandListUpdateMutableCommandsExpPrologue( hCommandList, desc ); - if(result!=ZE_RESULT_SUCCESS) return result; - } - - auto result = pfnUpdateMutableCommandsExp( hCommandList, desc ); - - for (size_t i = 0; i < numValHandlers; i++) { - auto result = context.validationHandlers[i]->zeValidation->zeCommandListUpdateMutableCommandsExpEpilogue( hCommandList, desc ); - if(result!=ZE_RESULT_SUCCESS) return result; - } - - return result; - } - - /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zeCommandListUpdateMutableCommandSignalEventExp - __zedlllocal ze_result_t ZE_APICALL - zeCommandListUpdateMutableCommandSignalEventExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - uint64_t commandId, ///< [in] command identifier - ze_event_handle_t hSignalEvent ///< [in][optional] handle of the event to signal on completion - ) - { - auto pfnUpdateMutableCommandSignalEventExp = context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandSignalEventExp; - - if( nullptr == pfnUpdateMutableCommandSignalEventExp ) - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; - - auto numValHandlers = context.validationHandlers.size(); - for (size_t i = 0; i < numValHandlers; i++) { - auto result = context.validationHandlers[i]->zeValidation->zeCommandListUpdateMutableCommandSignalEventExpPrologue( hCommandList, commandId, hSignalEvent ); - if(result!=ZE_RESULT_SUCCESS) return result; - } - - - if( context.enableThreadingValidation ){ - //Unimplemented - } - - - if(context.enableHandleLifetime ){ - auto result = context.handleLifetime->zeHandleLifetime.zeCommandListUpdateMutableCommandSignalEventExpPrologue( hCommandList, commandId, hSignalEvent ); - if(result!=ZE_RESULT_SUCCESS) return result; - } - - auto result = pfnUpdateMutableCommandSignalEventExp( hCommandList, commandId, hSignalEvent ); - - for (size_t i = 0; i < numValHandlers; i++) { - auto result = context.validationHandlers[i]->zeValidation->zeCommandListUpdateMutableCommandSignalEventExpEpilogue( hCommandList, commandId, hSignalEvent ); - if(result!=ZE_RESULT_SUCCESS) return result; - } - - return result; - } - - /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zeCommandListUpdateMutableCommandWaitEventsExp - __zedlllocal ze_result_t ZE_APICALL - zeCommandListUpdateMutableCommandWaitEventsExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - uint64_t commandId, ///< [in] command identifier - uint32_t numWaitEvents, ///< [in][optional] the number of wait events - ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait - ///< on before launching - ) - { - auto pfnUpdateMutableCommandWaitEventsExp = context.zeDdiTable.CommandListExp.pfnUpdateMutableCommandWaitEventsExp; - - if( nullptr == pfnUpdateMutableCommandWaitEventsExp ) - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; - - auto numValHandlers = context.validationHandlers.size(); - for (size_t i = 0; i < numValHandlers; i++) { - auto result = context.validationHandlers[i]->zeValidation->zeCommandListUpdateMutableCommandWaitEventsExpPrologue( hCommandList, commandId, numWaitEvents, phWaitEvents ); - if(result!=ZE_RESULT_SUCCESS) return result; - } - - - if( context.enableThreadingValidation ){ - //Unimplemented - } - - - if(context.enableHandleLifetime ){ - auto result = context.handleLifetime->zeHandleLifetime.zeCommandListUpdateMutableCommandWaitEventsExpPrologue( hCommandList, commandId, numWaitEvents, phWaitEvents ); - if(result!=ZE_RESULT_SUCCESS) return result; - } - - auto result = pfnUpdateMutableCommandWaitEventsExp( hCommandList, commandId, numWaitEvents, phWaitEvents ); - - for (size_t i = 0; i < numValHandlers; i++) { - auto result = context.validationHandlers[i]->zeValidation->zeCommandListUpdateMutableCommandWaitEventsExpEpilogue( hCommandList, commandId, numWaitEvents, phWaitEvents ); - if(result!=ZE_RESULT_SUCCESS) return result; - } - - return result; - } - } // namespace validation_layer #if defined(__cplusplus) @@ -8181,6 +8322,9 @@ zeGetGlobalProcAddrTable( dditable.pfnInit = pDdiTable->pfnInit; pDdiTable->pfnInit = validation_layer::zeInit; + dditable.pfnInitDrivers = pDdiTable->pfnInitDrivers; + pDdiTable->pfnInitDrivers = validation_layer::zeInitDrivers; + return result; } @@ -8716,14 +8860,8 @@ zeGetCommandListExpProcAddrTable( ze_result_t result = ZE_RESULT_SUCCESS; - dditable.pfnCreateCloneExp = pDdiTable->pfnCreateCloneExp; - pDdiTable->pfnCreateCloneExp = validation_layer::zeCommandListCreateCloneExp; - - dditable.pfnImmediateAppendCommandListsExp = pDdiTable->pfnImmediateAppendCommandListsExp; - pDdiTable->pfnImmediateAppendCommandListsExp = validation_layer::zeCommandListImmediateAppendCommandListsExp; - - dditable.pfnGetNextCommandIdExp = pDdiTable->pfnGetNextCommandIdExp; - pDdiTable->pfnGetNextCommandIdExp = validation_layer::zeCommandListGetNextCommandIdExp; + dditable.pfnGetNextCommandIdWithKernelsExp = pDdiTable->pfnGetNextCommandIdWithKernelsExp; + pDdiTable->pfnGetNextCommandIdWithKernelsExp = validation_layer::zeCommandListGetNextCommandIdWithKernelsExp; dditable.pfnUpdateMutableCommandsExp = pDdiTable->pfnUpdateMutableCommandsExp; pDdiTable->pfnUpdateMutableCommandsExp = validation_layer::zeCommandListUpdateMutableCommandsExp; @@ -8731,9 +8869,21 @@ zeGetCommandListExpProcAddrTable( dditable.pfnUpdateMutableCommandSignalEventExp = pDdiTable->pfnUpdateMutableCommandSignalEventExp; pDdiTable->pfnUpdateMutableCommandSignalEventExp = validation_layer::zeCommandListUpdateMutableCommandSignalEventExp; + dditable.pfnUpdateMutableCommandKernelsExp = pDdiTable->pfnUpdateMutableCommandKernelsExp; + pDdiTable->pfnUpdateMutableCommandKernelsExp = validation_layer::zeCommandListUpdateMutableCommandKernelsExp; + + dditable.pfnCreateCloneExp = pDdiTable->pfnCreateCloneExp; + pDdiTable->pfnCreateCloneExp = validation_layer::zeCommandListCreateCloneExp; + + dditable.pfnGetNextCommandIdExp = pDdiTable->pfnGetNextCommandIdExp; + pDdiTable->pfnGetNextCommandIdExp = validation_layer::zeCommandListGetNextCommandIdExp; + dditable.pfnUpdateMutableCommandWaitEventsExp = pDdiTable->pfnUpdateMutableCommandWaitEventsExp; pDdiTable->pfnUpdateMutableCommandWaitEventsExp = validation_layer::zeCommandListUpdateMutableCommandWaitEventsExp; + dditable.pfnImmediateAppendCommandListsExp = pDdiTable->pfnImmediateAppendCommandListsExp; + pDdiTable->pfnImmediateAppendCommandListsExp = validation_layer::zeCommandListImmediateAppendCommandListsExp; + return result; } diff --git a/source/layers/validation/zes_valddi.cpp b/source/layers/validation/zes_valddi.cpp index cea33303..3a4efb87 100644 --- a/source/layers/validation/zes_valddi.cpp +++ b/source/layers/validation/zes_valddi.cpp @@ -6249,6 +6249,200 @@ namespace validation_layer return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEnumEnabledVFExp + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumEnabledVFExp( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_vf_handle_t* phVFhandle ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + auto pfnEnumEnabledVFExp = context.zesDdiTable.DeviceExp.pfnEnumEnabledVFExp; + + if( nullptr == pfnEnumEnabledVFExp ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zesValidation->zesDeviceEnumEnabledVFExpPrologue( hDevice, pCount, phVFhandle ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zesHandleLifetime.zesDeviceEnumEnabledVFExpPrologue( hDevice, pCount, phVFhandle ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnEnumEnabledVFExp( hDevice, pCount, phVFhandle ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zesValidation->zesDeviceEnumEnabledVFExpEpilogue( hDevice, pCount, phVFhandle ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesVFManagementGetVFCapabilitiesExp + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFCapabilitiesExp( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. + zes_vf_exp_capabilities_t* pCapability ///< [in,out] Will contain VF capability. + ) + { + auto pfnGetVFCapabilitiesExp = context.zesDdiTable.VFManagementExp.pfnGetVFCapabilitiesExp; + + if( nullptr == pfnGetVFCapabilitiesExp ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zesValidation->zesVFManagementGetVFCapabilitiesExpPrologue( hVFhandle, pCapability ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zesHandleLifetime.zesVFManagementGetVFCapabilitiesExpPrologue( hVFhandle, pCapability ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnGetVFCapabilitiesExp( hVFhandle, pCapability ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zesValidation->zesVFManagementGetVFCapabilitiesExpEpilogue( hVFhandle, pCapability ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( result == ZE_RESULT_SUCCESS && context.enableHandleLifetime ){ + + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesVFManagementGetVFMemoryUtilizationExp2 + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFMemoryUtilizationExp2( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF memory stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of memory stats available. + ///< - if count is greater than the total number of memory stats + ///< available, the driver shall update the value with the correct number + ///< of memory stats available. + zes_vf_util_mem_exp2_t* pMemUtil ///< [in,out][optional][range(0, *pCount)] array of memory group activity counters. + ///< - if count is less than the total number of memory stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector pCount-1 number of VF + ///< memory stats. + ) + { + auto pfnGetVFMemoryUtilizationExp2 = context.zesDdiTable.VFManagement.pfnGetVFMemoryUtilizationExp2; + + if( nullptr == pfnGetVFMemoryUtilizationExp2 ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zesValidation->zesVFManagementGetVFMemoryUtilizationExp2Prologue( hVFhandle, pCount, pMemUtil ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zesHandleLifetime.zesVFManagementGetVFMemoryUtilizationExp2Prologue( hVFhandle, pCount, pMemUtil ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnGetVFMemoryUtilizationExp2( hVFhandle, pCount, pMemUtil ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zesValidation->zesVFManagementGetVFMemoryUtilizationExp2Epilogue( hVFhandle, pCount, pMemUtil ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesVFManagementGetVFEngineUtilizationExp2 + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFEngineUtilizationExp2( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF engine stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of engine stats available. + ///< - if count is greater than the total number of engine stats + ///< available, the driver shall update the value with the correct number + ///< of engine stats available. + zes_vf_util_engine_exp2_t* pEngineUtil ///< [in,out][optional][range(0, *pCount)] array of engine group activity counters. + ///< - if count is less than the total number of engine stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector pCount-1 number of VF + ///< engine stats. + ) + { + auto pfnGetVFEngineUtilizationExp2 = context.zesDdiTable.VFManagement.pfnGetVFEngineUtilizationExp2; + + if( nullptr == pfnGetVFEngineUtilizationExp2 ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zesValidation->zesVFManagementGetVFEngineUtilizationExp2Prologue( hVFhandle, pCount, pEngineUtil ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zesHandleLifetime.zesVFManagementGetVFEngineUtilizationExp2Prologue( hVFhandle, pCount, pEngineUtil ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnGetVFEngineUtilizationExp2( hVFhandle, pCount, pEngineUtil ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zesValidation->zesVFManagementGetVFEngineUtilizationExp2Epilogue( hVFhandle, pCount, pEngineUtil ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + return result; + } + } // namespace validation_layer #if defined(__cplusplus) @@ -6450,6 +6644,9 @@ zesGetDeviceExpProcAddrTable( ze_result_t result = ZE_RESULT_SUCCESS; + dditable.pfnEnumEnabledVFExp = pDdiTable->pfnEnumEnabledVFExp; + pDdiTable->pfnEnumEnabledVFExp = validation_layer::zesDeviceEnumEnabledVFExp; + dditable.pfnGetSubDevicePropertiesExp = pDdiTable->pfnGetSubDevicePropertiesExp; pDdiTable->pfnGetSubDevicePropertiesExp = validation_layer::zesDeviceGetSubDevicePropertiesExp; @@ -7316,6 +7513,40 @@ zesGetTemperatureProcAddrTable( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's VFManagement table +/// with current process' addresses +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION +ZE_DLLEXPORT ze_result_t ZE_APICALL +zesGetVFManagementProcAddrTable( + ze_api_version_t version, ///< [in] API version requested + zes_vf_management_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers + ) +{ + auto& dditable = validation_layer::context.zesDdiTable.VFManagement; + + if( nullptr == pDdiTable ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if (ZE_MAJOR_VERSION(validation_layer::context.version) != ZE_MAJOR_VERSION(version) || + ZE_MINOR_VERSION(validation_layer::context.version) > ZE_MINOR_VERSION(version)) + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + + ze_result_t result = ZE_RESULT_SUCCESS; + + dditable.pfnGetVFMemoryUtilizationExp2 = pDdiTable->pfnGetVFMemoryUtilizationExp2; + pDdiTable->pfnGetVFMemoryUtilizationExp2 = validation_layer::zesVFManagementGetVFMemoryUtilizationExp2; + + dditable.pfnGetVFEngineUtilizationExp2 = pDdiTable->pfnGetVFEngineUtilizationExp2; + pDdiTable->pfnGetVFEngineUtilizationExp2 = validation_layer::zesVFManagementGetVFEngineUtilizationExp2; + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's VFManagementExp table /// with current process' addresses @@ -7341,6 +7572,9 @@ zesGetVFManagementExpProcAddrTable( ze_result_t result = ZE_RESULT_SUCCESS; + dditable.pfnGetVFCapabilitiesExp = pDdiTable->pfnGetVFCapabilitiesExp; + pDdiTable->pfnGetVFCapabilitiesExp = validation_layer::zesVFManagementGetVFCapabilitiesExp; + dditable.pfnGetVFPropertiesExp = pDdiTable->pfnGetVFPropertiesExp; pDdiTable->pfnGetVFPropertiesExp = validation_layer::zesVFManagementGetVFPropertiesExp; diff --git a/source/layers/validation/zet_valddi.cpp b/source/layers/validation/zet_valddi.cpp index 6488c425..eb729c58 100644 --- a/source/layers/validation/zet_valddi.cpp +++ b/source/layers/validation/zet_valddi.cpp @@ -1727,6 +1727,516 @@ namespace validation_layer return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDeviceGetConcurrentMetricGroupsExp + __zedlllocal ze_result_t ZE_APICALL + zetDeviceGetConcurrentMetricGroupsExp( + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t metricGroupCount, ///< [in] metric group count + zet_metric_group_handle_t * phMetricGroups, ///< [in,out] metrics groups to be re-arranged to be sets of concurrent + ///< groups + uint32_t * pMetricGroupsCountPerConcurrentGroup,///< [in,out][optional][*pConcurrentGroupCount] count of metric groups per + ///< concurrent group. + uint32_t * pConcurrentGroupCount ///< [out] number of concurrent groups. + ///< The value of this parameter could be used to determine the number of + ///< replays necessary. + ) + { + auto pfnGetConcurrentMetricGroupsExp = context.zetDdiTable.DeviceExp.pfnGetConcurrentMetricGroupsExp; + + if( nullptr == pfnGetConcurrentMetricGroupsExp ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetDeviceGetConcurrentMetricGroupsExpPrologue( hDevice, metricGroupCount, phMetricGroups, pMetricGroupsCountPerConcurrentGroup, pConcurrentGroupCount ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zetHandleLifetime.zetDeviceGetConcurrentMetricGroupsExpPrologue( hDevice, metricGroupCount, phMetricGroups, pMetricGroupsCountPerConcurrentGroup, pConcurrentGroupCount ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnGetConcurrentMetricGroupsExp( hDevice, metricGroupCount, phMetricGroups, pMetricGroupsCountPerConcurrentGroup, pConcurrentGroupCount ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetDeviceGetConcurrentMetricGroupsExpEpilogue( hDevice, metricGroupCount, phMetricGroups, pMetricGroupsCountPerConcurrentGroup, pConcurrentGroupCount ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( result == ZE_RESULT_SUCCESS && context.enableHandleLifetime ){ + + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerCreateExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerCreateExp( + zet_context_handle_t hContext, ///< [in] handle of the context object + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t metricGroupCount, ///< [in] metric group count + zet_metric_group_handle_t* phMetricGroups, ///< [in][range(0, metricGroupCount )] handles of the metric groups to + ///< trace + zet_metric_tracer_exp_desc_t* desc, ///< [in,out] metric tracer descriptor + ze_event_handle_t hNotificationEvent, ///< [in][optional] event used for report availability notification. Note: + ///< If buffer is not drained when the event it flagged, there is a risk of + ///< HW event buffer being overrun + zet_metric_tracer_exp_handle_t* phMetricTracer ///< [out] handle of the metric tracer + ) + { + auto pfnCreateExp = context.zetDdiTable.MetricTracerExp.pfnCreateExp; + + if( nullptr == pfnCreateExp ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetMetricTracerCreateExpPrologue( hContext, hDevice, metricGroupCount, phMetricGroups, desc, hNotificationEvent, phMetricTracer ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zetHandleLifetime.zetMetricTracerCreateExpPrologue( hContext, hDevice, metricGroupCount, phMetricGroups, desc, hNotificationEvent, phMetricTracer ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnCreateExp( hContext, hDevice, metricGroupCount, phMetricGroups, desc, hNotificationEvent, phMetricTracer ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetMetricTracerCreateExpEpilogue( hContext, hDevice, metricGroupCount, phMetricGroups, desc, hNotificationEvent, phMetricTracer ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( result == ZE_RESULT_SUCCESS && context.enableHandleLifetime ){ + + if (phMetricTracer){ + context.handleLifetime->addHandle( *phMetricTracer ); + context.handleLifetime->addDependent( hContext, *phMetricTracer ); + + } + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerDestroyExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerDestroyExp( + zet_metric_tracer_exp_handle_t hMetricTracer ///< [in] handle of the metric tracer + ) + { + auto pfnDestroyExp = context.zetDdiTable.MetricTracerExp.pfnDestroyExp; + + if( nullptr == pfnDestroyExp ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetMetricTracerDestroyExpPrologue( hMetricTracer ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zetHandleLifetime.zetMetricTracerDestroyExpPrologue( hMetricTracer ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnDestroyExp( hMetricTracer ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetMetricTracerDestroyExpEpilogue( hMetricTracer ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerEnableExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerEnableExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + ze_bool_t synchronous ///< [in] request synchronous behavior. Confirmation of successful + ///< asynchronous operation is done by calling ::zetMetricTracerReadDataExp() + ///< and checking the return status: ::ZE_RESULT_NOT_READY will be returned + ///< when the tracer is inactive. ::ZE_RESULT_SUCCESS will be returned + ///< when the tracer is active. + ) + { + auto pfnEnableExp = context.zetDdiTable.MetricTracerExp.pfnEnableExp; + + if( nullptr == pfnEnableExp ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetMetricTracerEnableExpPrologue( hMetricTracer, synchronous ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zetHandleLifetime.zetMetricTracerEnableExpPrologue( hMetricTracer, synchronous ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnEnableExp( hMetricTracer, synchronous ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetMetricTracerEnableExpEpilogue( hMetricTracer, synchronous ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerDisableExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerDisableExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + ze_bool_t synchronous ///< [in] request synchronous behavior. Confirmation of successful + ///< asynchronous operation is done by calling ::zetMetricTracerReadDataExp() + ///< and checking the return status: ::ZE_RESULT_SUCCESS will be returned + ///< when the tracer is active or when it is inactive but still has data. + ///< ::ZE_RESULT_NOT_READY will be returned when the tracer is inactive and + ///< has no more data to be retrieved. + ) + { + auto pfnDisableExp = context.zetDdiTable.MetricTracerExp.pfnDisableExp; + + if( nullptr == pfnDisableExp ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetMetricTracerDisableExpPrologue( hMetricTracer, synchronous ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zetHandleLifetime.zetMetricTracerDisableExpPrologue( hMetricTracer, synchronous ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnDisableExp( hMetricTracer, synchronous ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetMetricTracerDisableExpEpilogue( hMetricTracer, synchronous ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerReadDataExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerReadDataExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + size_t* pRawDataSize, ///< [in,out] pointer to size in bytes of raw data requested to read. + ///< if size is zero, then the driver will update the value with the total + ///< size in bytes needed for all data available. + ///< if size is non-zero, then driver will only retrieve that amount of + ///< data. + ///< if size is larger than size needed for all data, then driver will + ///< update the value with the actual size needed. + uint8_t* pRawData ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing tracer + ///< data in raw format + ) + { + auto pfnReadDataExp = context.zetDdiTable.MetricTracerExp.pfnReadDataExp; + + if( nullptr == pfnReadDataExp ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetMetricTracerReadDataExpPrologue( hMetricTracer, pRawDataSize, pRawData ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zetHandleLifetime.zetMetricTracerReadDataExpPrologue( hMetricTracer, pRawDataSize, pRawData ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnReadDataExp( hMetricTracer, pRawDataSize, pRawData ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetMetricTracerReadDataExpEpilogue( hMetricTracer, pRawDataSize, pRawData ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricDecoderCreateExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricDecoderCreateExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + zet_metric_decoder_exp_handle_t* phMetricDecoder///< [out] handle of the metric decoder object + ) + { + auto pfnCreateExp = context.zetDdiTable.MetricDecoderExp.pfnCreateExp; + + if( nullptr == pfnCreateExp ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetMetricDecoderCreateExpPrologue( hMetricTracer, phMetricDecoder ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zetHandleLifetime.zetMetricDecoderCreateExpPrologue( hMetricTracer, phMetricDecoder ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnCreateExp( hMetricTracer, phMetricDecoder ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetMetricDecoderCreateExpEpilogue( hMetricTracer, phMetricDecoder ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( result == ZE_RESULT_SUCCESS && context.enableHandleLifetime ){ + + if (phMetricDecoder){ + context.handleLifetime->addHandle( *phMetricDecoder ); + context.handleLifetime->addDependent( hMetricTracer, *phMetricDecoder ); + + } + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricDecoderDestroyExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricDecoderDestroyExp( + zet_metric_decoder_exp_handle_t phMetricDecoder ///< [in] handle of the metric decoder object + ) + { + auto pfnDestroyExp = context.zetDdiTable.MetricDecoderExp.pfnDestroyExp; + + if( nullptr == pfnDestroyExp ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetMetricDecoderDestroyExpPrologue( phMetricDecoder ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zetHandleLifetime.zetMetricDecoderDestroyExpPrologue( phMetricDecoder ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnDestroyExp( phMetricDecoder ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetMetricDecoderDestroyExpEpilogue( phMetricDecoder ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricDecoderGetDecodableMetricsExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricDecoderGetDecodableMetricsExp( + zet_metric_decoder_exp_handle_t hMetricDecoder, ///< [in] handle of the metric decoder object + uint32_t* pCount, ///< [in,out] pointer to number of decodable metric in the hMetricDecoder + ///< handle. If count is zero, then the driver shall + ///< update the value with the total number of decodable metrics available + ///< in the decoder. if count is greater than zero + ///< but less than the total number of decodable metrics available in the + ///< decoder, then only that number will be returned. + ///< if count is greater than the number of decodable metrics available in + ///< the decoder, then the driver shall update the + ///< value with the actual number of decodable metrics available. + zet_metric_handle_t* phMetrics ///< [in,out] [range(0, *pCount)] array of handles of decodable metrics in + ///< the hMetricDecoder handle provided. + ) + { + auto pfnGetDecodableMetricsExp = context.zetDdiTable.MetricDecoderExp.pfnGetDecodableMetricsExp; + + if( nullptr == pfnGetDecodableMetricsExp ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetMetricDecoderGetDecodableMetricsExpPrologue( hMetricDecoder, pCount, phMetrics ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zetHandleLifetime.zetMetricDecoderGetDecodableMetricsExpPrologue( hMetricDecoder, pCount, phMetrics ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnGetDecodableMetricsExp( hMetricDecoder, pCount, phMetrics ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetMetricDecoderGetDecodableMetricsExpEpilogue( hMetricDecoder, pCount, phMetrics ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( result == ZE_RESULT_SUCCESS && context.enableHandleLifetime ){ + + for (size_t i = 0; ( nullptr != phMetrics) && (i < *pCount); ++i){ + if (phMetrics[i]){ + context.handleLifetime->addHandle( phMetrics[i] ); + context.handleLifetime->addDependent( hMetricDecoder, phMetrics[i] ); + } + } + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerDecodeExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerDecodeExp( + zet_metric_decoder_exp_handle_t phMetricDecoder,///< [in] handle of the metric decoder object + size_t* pRawDataSize, ///< [in,out] size in bytes of raw data buffer. If pMetricEntriesCount is + ///< greater than zero but less than total number of + ///< decodable metrics available in the raw data buffer, then driver shall + ///< update this value with actual number of raw + ///< data bytes processed. + uint8_t* pRawData, ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing tracer + ///< data in raw format + uint32_t metricsCount, ///< [in] number of decodable metrics in the tracer for which the + ///< hMetricDecoder handle was provided. See + ///< ::zetMetricDecoderGetDecodableMetricsExp(). If metricCount is greater + ///< than zero but less than the number decodable + ///< metrics available in the raw data buffer, then driver shall only + ///< decode those. + zet_metric_handle_t* phMetrics, ///< [in] [range(0, metricsCount)] array of handles of decodable metrics in + ///< the decoder for which the hMetricDecoder handle was + ///< provided. Metrics handles are expected to be for decodable metrics, + ///< see ::zetMetricDecoderGetDecodableMetrics() + uint32_t* pSetCount, ///< [in,out] pointer to number of metric sets. If count is zero, then the + ///< driver shall update the value with the total + ///< number of metric sets to be decoded. If count is greater than the + ///< number available in the raw data buffer, then the + ///< driver shall update the value with the actual number of metric sets to + ///< be decoded. There is a 1:1 relation between + ///< the number of sets and sub-devices returned in the decoded entries. + uint32_t* pMetricEntriesCountPerSet, ///< [in,out][optional][range(0, *pSetCount)] buffer of metric entries + ///< counts per metric set, one value per set. + uint32_t* pMetricEntriesCount, ///< [in,out] pointer to the total number of metric entries decoded, for + ///< all metric sets. If count is zero, then the + ///< driver shall update the value with the total number of metric entries + ///< to be decoded. If count is greater than zero + ///< but less than the total number of metric entries available in the raw + ///< data, then user provided number will be decoded. + ///< If count is greater than the number available in the raw data buffer, + ///< then the driver shall update the value with + ///< the actual number of decodable metric entries decoded. If set to null, + ///< then driver will only update the value of + ///< pSetCount. + zet_metric_entry_exp_t* pMetricEntries ///< [in,out][optional][range(0, *pMetricEntriesCount)] buffer containing + ///< decoded metric entries + ) + { + auto pfnDecodeExp = context.zetDdiTable.MetricTracerExp.pfnDecodeExp; + + if( nullptr == pfnDecodeExp ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetMetricTracerDecodeExpPrologue( phMetricDecoder, pRawDataSize, pRawData, metricsCount, phMetrics, pSetCount, pMetricEntriesCountPerSet, pMetricEntriesCount, pMetricEntries ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zetHandleLifetime.zetMetricTracerDecodeExpPrologue( phMetricDecoder, pRawDataSize, pRawData, metricsCount, phMetrics, pSetCount, pMetricEntriesCountPerSet, pMetricEntriesCount, pMetricEntries ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnDecodeExp( phMetricDecoder, pRawDataSize, pRawData, metricsCount, phMetrics, pSetCount, pMetricEntriesCountPerSet, pMetricEntriesCount, pMetricEntries ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetMetricTracerDecodeExpEpilogue( phMetricDecoder, pRawDataSize, pRawData, metricsCount, phMetrics, pSetCount, pMetricEntriesCountPerSet, pMetricEntriesCount, pMetricEntries ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zetMetricGroupCalculateMultipleMetricValuesExp __zedlllocal ze_result_t ZE_APICALL @@ -2152,6 +2662,71 @@ namespace validation_layer return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricCreateFromProgrammableExp2 + __zedlllocal ze_result_t ZE_APICALL + zetMetricCreateFromProgrammableExp2( + zet_metric_programmable_exp_handle_t hMetricProgrammable, ///< [in] handle of the metric programmable + uint32_t parameterCount, ///< [in] Count of parameters to set. + zet_metric_programmable_param_value_exp_t* pParameterValues,///< [in] list of parameter values to be set. + const char* pName, ///< [in] pointer to metric name to be used. Must point to a + ///< null-terminated character array no longer than ::ZET_MAX_METRIC_NAME. + const char* pDescription, ///< [in] pointer to metric description to be used. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_DESCRIPTION. + uint32_t* pMetricHandleCount, ///< [in,out] Pointer to the number of metric handles. + ///< if count is zero, then the driver shall update the value with the + ///< number of metric handles available for this programmable. + ///< if count is greater than the number of metric handles available, then + ///< the driver shall update the value with the correct number of metric + ///< handles available. + zet_metric_handle_t* phMetricHandles ///< [in,out][optional][range(0,*pMetricHandleCount)] array of handle of metrics. + ///< if count is less than the number of metrics available, then driver + ///< shall only retrieve that number of metric handles. + ) + { + auto pfnCreateFromProgrammableExp2 = context.zetDdiTable.Metric.pfnCreateFromProgrammableExp2; + + if( nullptr == pfnCreateFromProgrammableExp2 ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetMetricCreateFromProgrammableExp2Prologue( hMetricProgrammable, parameterCount, pParameterValues, pName, pDescription, pMetricHandleCount, phMetricHandles ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zetHandleLifetime.zetMetricCreateFromProgrammableExp2Prologue( hMetricProgrammable, parameterCount, pParameterValues, pName, pDescription, pMetricHandleCount, phMetricHandles ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnCreateFromProgrammableExp2( hMetricProgrammable, parameterCount, pParameterValues, pName, pDescription, pMetricHandleCount, phMetricHandles ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetMetricCreateFromProgrammableExp2Epilogue( hMetricProgrammable, parameterCount, pParameterValues, pName, pDescription, pMetricHandleCount, phMetricHandles ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( result == ZE_RESULT_SUCCESS && context.enableHandleLifetime ){ + + for (size_t i = 0; ( nullptr != phMetricHandles) && (i < *pMetricHandleCount); ++i){ + if (phMetricHandles[i]){ + context.handleLifetime->addHandle( phMetricHandles[i] ); + context.handleLifetime->addDependent( hMetricProgrammable, phMetricHandles[i] ); + } + } + } + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zetMetricCreateFromProgrammableExp __zedlllocal ze_result_t ZE_APICALL @@ -2217,6 +2792,74 @@ namespace validation_layer return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDeviceCreateMetricGroupsFromMetricsExp + __zedlllocal ze_result_t ZE_APICALL + zetDeviceCreateMetricGroupsFromMetricsExp( + zet_device_handle_t hDevice, ///< [in] handle of the device. + uint32_t metricCount, ///< [in] number of metric handles. + zet_metric_handle_t * phMetrics, ///< [in] metric handles to be added to the metric groups. + const char * pMetricGroupNamePrefix, ///< [in] prefix to the name created for the metric groups. Must point to a + ///< null-terminated character array no longer than + ///< ZEX_MAX_METRIC_GROUP_NAME_PREFIX. + const char * pDescription, ///< [in] pointer to description of the metric groups. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_GROUP_DESCRIPTION. + uint32_t * pMetricGroupCount, ///< [in,out] pointer to the number of metric group handles to be created. + ///< if pMetricGroupCount is zero, then the driver shall update the value + ///< with the maximum possible number of metric group handles that could be created. + ///< if pMetricGroupCount is greater than the number of metric group + ///< handles that could be created, then the driver shall update the value + ///< with the correct number of metric group handles generated. + ///< if pMetricGroupCount is lesser than the number of metric group handles + ///< that could be created, then ::ZE_RESULT_ERROR_INVALID_ARGUMENT is returned. + zet_metric_group_handle_t* phMetricGroup ///< [in,out][optional][range(0, *pMetricGroupCount)] array of handle of + ///< metric group handles. + ///< Created Metric group handles. + ) + { + auto pfnCreateMetricGroupsFromMetricsExp = context.zetDdiTable.DeviceExp.pfnCreateMetricGroupsFromMetricsExp; + + if( nullptr == pfnCreateMetricGroupsFromMetricsExp ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + auto numValHandlers = context.validationHandlers.size(); + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetDeviceCreateMetricGroupsFromMetricsExpPrologue( hDevice, metricCount, phMetrics, pMetricGroupNamePrefix, pDescription, pMetricGroupCount, phMetricGroup ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zetHandleLifetime.zetDeviceCreateMetricGroupsFromMetricsExpPrologue( hDevice, metricCount, phMetrics, pMetricGroupNamePrefix, pDescription, pMetricGroupCount, phMetricGroup ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto result = pfnCreateMetricGroupsFromMetricsExp( hDevice, metricCount, phMetrics, pMetricGroupNamePrefix, pDescription, pMetricGroupCount, phMetricGroup ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zetValidation->zetDeviceCreateMetricGroupsFromMetricsExpEpilogue( hDevice, metricCount, phMetrics, pMetricGroupNamePrefix, pDescription, pMetricGroupCount, phMetricGroup ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( result == ZE_RESULT_SUCCESS && context.enableHandleLifetime ){ + + for (size_t i = 0; ( nullptr != phMetricGroup) && (i < *pMetricGroupCount); ++i){ + if (phMetricGroup[i]){ + context.handleLifetime->addHandle( phMetricGroup[i] ); + context.handleLifetime->addDependent( hDevice, phMetricGroup[i] ); + } + } + } + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zetMetricGroupCreateExp __zedlllocal ze_result_t ZE_APICALL @@ -2482,6 +3125,43 @@ namespace validation_layer extern "C" { #endif +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's MetricDecoderExp table +/// with current process' addresses +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION +ZE_DLLEXPORT ze_result_t ZE_APICALL +zetGetMetricDecoderExpProcAddrTable( + ze_api_version_t version, ///< [in] API version requested + zet_metric_decoder_exp_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers + ) +{ + auto& dditable = validation_layer::context.zetDdiTable.MetricDecoderExp; + + if( nullptr == pDdiTable ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if (ZE_MAJOR_VERSION(validation_layer::context.version) != ZE_MAJOR_VERSION(version) || + ZE_MINOR_VERSION(validation_layer::context.version) > ZE_MINOR_VERSION(version)) + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + + ze_result_t result = ZE_RESULT_SUCCESS; + + dditable.pfnCreateExp = pDdiTable->pfnCreateExp; + pDdiTable->pfnCreateExp = validation_layer::zetMetricDecoderCreateExp; + + dditable.pfnDestroyExp = pDdiTable->pfnDestroyExp; + pDdiTable->pfnDestroyExp = validation_layer::zetMetricDecoderDestroyExp; + + dditable.pfnGetDecodableMetricsExp = pDdiTable->pfnGetDecodableMetricsExp; + pDdiTable->pfnGetDecodableMetricsExp = validation_layer::zetMetricDecoderGetDecodableMetricsExp; + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's MetricProgrammableExp table /// with current process' addresses @@ -2522,6 +3202,52 @@ zetGetMetricProgrammableExpProcAddrTable( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's MetricTracerExp table +/// with current process' addresses +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION +ZE_DLLEXPORT ze_result_t ZE_APICALL +zetGetMetricTracerExpProcAddrTable( + ze_api_version_t version, ///< [in] API version requested + zet_metric_tracer_exp_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers + ) +{ + auto& dditable = validation_layer::context.zetDdiTable.MetricTracerExp; + + if( nullptr == pDdiTable ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if (ZE_MAJOR_VERSION(validation_layer::context.version) != ZE_MAJOR_VERSION(version) || + ZE_MINOR_VERSION(validation_layer::context.version) > ZE_MINOR_VERSION(version)) + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + + ze_result_t result = ZE_RESULT_SUCCESS; + + dditable.pfnCreateExp = pDdiTable->pfnCreateExp; + pDdiTable->pfnCreateExp = validation_layer::zetMetricTracerCreateExp; + + dditable.pfnDestroyExp = pDdiTable->pfnDestroyExp; + pDdiTable->pfnDestroyExp = validation_layer::zetMetricTracerDestroyExp; + + dditable.pfnEnableExp = pDdiTable->pfnEnableExp; + pDdiTable->pfnEnableExp = validation_layer::zetMetricTracerEnableExp; + + dditable.pfnDisableExp = pDdiTable->pfnDisableExp; + pDdiTable->pfnDisableExp = validation_layer::zetMetricTracerDisableExp; + + dditable.pfnReadDataExp = pDdiTable->pfnReadDataExp; + pDdiTable->pfnReadDataExp = validation_layer::zetMetricTracerReadDataExp; + + dditable.pfnDecodeExp = pDdiTable->pfnDecodeExp; + pDdiTable->pfnDecodeExp = validation_layer::zetMetricTracerDecodeExp; + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's Device table /// with current process' addresses @@ -2553,6 +3279,40 @@ zetGetDeviceProcAddrTable( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's DeviceExp table +/// with current process' addresses +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION +ZE_DLLEXPORT ze_result_t ZE_APICALL +zetGetDeviceExpProcAddrTable( + ze_api_version_t version, ///< [in] API version requested + zet_device_exp_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers + ) +{ + auto& dditable = validation_layer::context.zetDdiTable.DeviceExp; + + if( nullptr == pDdiTable ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if (ZE_MAJOR_VERSION(validation_layer::context.version) != ZE_MAJOR_VERSION(version) || + ZE_MINOR_VERSION(validation_layer::context.version) > ZE_MINOR_VERSION(version)) + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + + ze_result_t result = ZE_RESULT_SUCCESS; + + dditable.pfnGetConcurrentMetricGroupsExp = pDdiTable->pfnGetConcurrentMetricGroupsExp; + pDdiTable->pfnGetConcurrentMetricGroupsExp = validation_layer::zetDeviceGetConcurrentMetricGroupsExp; + + dditable.pfnCreateMetricGroupsFromMetricsExp = pDdiTable->pfnCreateMetricGroupsFromMetricsExp; + pDdiTable->pfnCreateMetricGroupsFromMetricsExp = validation_layer::zetDeviceCreateMetricGroupsFromMetricsExp; + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's Context table /// with current process' addresses @@ -2781,6 +3541,9 @@ zetGetMetricProcAddrTable( dditable.pfnGetProperties = pDdiTable->pfnGetProperties; pDdiTable->pfnGetProperties = validation_layer::zetMetricGetProperties; + dditable.pfnCreateFromProgrammableExp2 = pDdiTable->pfnCreateFromProgrammableExp2; + pDdiTable->pfnCreateFromProgrammableExp2 = validation_layer::zetMetricCreateFromProgrammableExp2; + return result; } @@ -2880,6 +3643,9 @@ zetGetMetricGroupExpProcAddrTable( ze_result_t result = ZE_RESULT_SUCCESS; + dditable.pfnCreateExp = pDdiTable->pfnCreateExp; + pDdiTable->pfnCreateExp = validation_layer::zetMetricGroupCreateExp; + dditable.pfnCalculateMultipleMetricValuesExp = pDdiTable->pfnCalculateMultipleMetricValuesExp; pDdiTable->pfnCalculateMultipleMetricValuesExp = validation_layer::zetMetricGroupCalculateMultipleMetricValuesExp; @@ -2892,9 +3658,6 @@ zetGetMetricGroupExpProcAddrTable( dditable.pfnCalculateMetricExportDataExp = pDdiTable->pfnCalculateMetricExportDataExp; pDdiTable->pfnCalculateMetricExportDataExp = validation_layer::zetMetricGroupCalculateMetricExportDataExp; - dditable.pfnCreateExp = pDdiTable->pfnCreateExp; - pDdiTable->pfnCreateExp = validation_layer::zetMetricGroupCreateExp; - dditable.pfnAddMetricExp = pDdiTable->pfnAddMetricExp; pDdiTable->pfnAddMetricExp = validation_layer::zetMetricGroupAddMetricExp; diff --git a/source/lib/ze_lib.cpp b/source/lib/ze_lib.cpp index cfa3bb21..fc0e1880 100644 --- a/source/lib/ze_lib.cpp +++ b/source/lib/ze_lib.cpp @@ -35,7 +35,7 @@ namespace ze_lib }; ////////////////////////////////////////////////////////////////////////// - __zedlllocal ze_result_t context_t::Init(ze_init_flags_t flags, bool sysmanOnly) + __zedlllocal ze_result_t context_t::Init(ze_init_flags_t flags, bool sysmanOnly, ze_init_driver_type_desc_t* desc) { ze_result_t result; #ifdef DYNAMIC_LOAD_LOADER @@ -114,7 +114,7 @@ namespace ze_lib // Check which drivers support the ze_driver_flag_t specified // No need to check if only initializing sysman bool requireDdiReinit = false; - result = zelLoaderDriverCheck(flags, &ze_lib::context->initialzeDdiTable.Global, &ze_lib::context->initialzesDdiTable.Global, &requireDdiReinit, sysmanOnly); + result = zelLoaderDriverCheck(flags, desc, &ze_lib::context->initialzeDdiTable.Global, &ze_lib::context->initialzesDdiTable.Global, &requireDdiReinit, sysmanOnly); // If a driver was removed from the driver list, then the ddi tables need to be reinit to allow for passthru directly to the driver. if (requireDdiReinit) { // If a user has already called the core apis, then ddi table reinit is not possible due to handles already being read by the user. diff --git a/source/lib/ze_lib.h b/source/lib/ze_lib.h index 77f53c45..73589936 100644 --- a/source/lib/ze_lib.h +++ b/source/lib/ze_lib.h @@ -35,9 +35,10 @@ namespace ze_lib ~context_t(); std::once_flag initOnce; + std::once_flag initOnceDrivers; std::once_flag initOnceSysMan; - ze_result_t Init(ze_init_flags_t flags, bool sysmanOnly); + ze_result_t Init(ze_init_flags_t flags, bool sysmanOnly, ze_init_driver_type_desc_t* desc); ze_result_t zeDdiTableInit(); std::atomic zeDdiTable = {nullptr}; diff --git a/source/lib/ze_libapi.cpp b/source/lib/ze_libapi.cpp index fca47e35..ac7fed2b 100644 --- a/source/lib/ze_libapi.cpp +++ b/source/lib/ze_libapi.cpp @@ -46,7 +46,7 @@ zeInit( { static ze_result_t result = ZE_RESULT_SUCCESS; std::call_once(ze_lib::context->initOnce, [flags]() { - result = ze_lib::context->Init(flags, false); + result = ze_lib::context->Init(flags, false, nullptr); if( ZE_RESULT_SUCCESS != result ) return result; @@ -130,6 +130,100 @@ zeDriverGet( return pfnGet( pCount, phDrivers ); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Initialize the 'oneAPI' driver(s) based on the driver types requested +/// and retrieve the driver handles. +/// +/// @details +/// - The application must call this function or zeInit before calling any +/// other function. +/// - The application can call InitDrivers or zeInit to init the drivers on +/// the system. +/// - Calls to zeInit or InitDrivers will not alter the drivers retrieved +/// thru either api. +/// - Drivers init thru zeInit or InitDrivers will not be reInitialized once +/// init in an application. The Loader will determine if the already init +/// driver needs to be delivered to the user thru the init type flags. +/// - Already init Drivers will not be uninitialized if the call to +/// InitDrivers does not include that driver's type. Those init drivers +/// which don't match the init flags will not have their driver handles +/// returned to the user in that InitDrivers call. +/// - If this function or zeInit is not called, then all other functions +/// will return ::ZE_RESULT_ERROR_UNINITIALIZED. +/// - Only one instance of each driver will be initialized per process. +/// - A driver represents a collection of physical devices. +/// - Multiple calls to this function will return identical driver handles, +/// in the same order. +/// - The drivers returned to the caller will be based on the init types +/// which state the drivers to be included. +/// - The application may pass nullptr for pDrivers when only querying the +/// number of drivers. +/// - The application may call this function multiple times with different +/// flags or environment variables enabled. +/// - The application must call this function after forking new processes. +/// Each forked process must call this function. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe for scenarios +/// where multiple libraries may initialize the driver(s) simultaneously. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCount` +/// + `nullptr == desc` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x0 == desc->flags` +ze_result_t ZE_APICALL +zeInitDrivers( + uint32_t* pCount, ///< [in,out] pointer to the number of driver instances. + ///< if count is zero, then the loader shall update the value with the + ///< total number of drivers available. + ///< if count is greater than the number of drivers available, then the + ///< loader shall update the value with the correct number of drivers available. + ze_driver_handle_t* phDrivers, ///< [in,out][optional][range(0, *pCount)] array of driver instance handles. + ///< if count is less than the number of drivers available, then the loader + ///< shall only retrieve that number of drivers. + ze_init_driver_type_desc_t* desc ///< [in] descriptor containing the driver type initialization details + ///< including ::ze_init_driver_type_flag_t combinations. + ) +{ + static ze_result_t result = ZE_RESULT_SUCCESS; + std::call_once(ze_lib::context->initOnceDrivers, []() { + ze_init_flags_t all_enabled = UINT32_MAX; + ze_init_driver_type_desc_t all_enabled_desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; + all_enabled_desc.pNext = nullptr; + all_enabled_desc.flags = UINT32_MAX; + result = ze_lib::context->Init(all_enabled, false, &all_enabled_desc); + return result; + }); + + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnInitDrivers = ze_lib::context->zeDdiTable.load()->Global.pfnInitDrivers; + if( nullptr == pfnInitDrivers ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + result = pfnInitDrivers( pCount, phDrivers, desc ); + + if (result == ZE_RESULT_SUCCESS) { + if (phDrivers) { + ze_lib::context->zeInuse = true; + } + } + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Returns the API version supported by the specified driver /// @@ -1098,13 +1192,15 @@ zeDeviceGetStatus( /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER /// + `nullptr == hostTimestamp` /// + `nullptr == deviceTimestamp` +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_FEATURE +/// + The feature is not supported by the underlying platform. ze_result_t ZE_APICALL zeDeviceGetGlobalTimestamps( ze_device_handle_t hDevice, ///< [in] handle of the device uint64_t* hostTimestamp, ///< [out] value of the Host's global timestamp that correlates with the - ///< Device's global timestamp value + ///< Device's global timestamp value. uint64_t* deviceTimestamp ///< [out] value of the Device's global timestamp that correlates with the - ///< Host's global timestamp value + ///< Host's global timestamp value. ) { if(ze_lib::context->inTeardown) { @@ -6613,7 +6709,9 @@ zeVirtualMemQueryPageSize( /// @details /// - The application must only use the physical memory object on the /// context for which it was created. -/// - The size must be page aligned. See ::zeVirtualMemQueryPageSize. +/// - The size must be page aligned. For host memory, the operating system +/// page size should be used. For device memory, see +/// ::zeVirtualMemQueryPageSize. /// - The application may call this function from simultaneous threads. /// - The implementation of this function must be thread-safe. /// @@ -6630,14 +6728,15 @@ zeVirtualMemQueryPageSize( /// + `nullptr == desc` /// + `nullptr == phPhysicalMemory` /// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION -/// + `0x1 < desc->flags` +/// + `0x3 < desc->flags` /// - ::ZE_RESULT_ERROR_UNSUPPORTED_SIZE /// + `0 == desc->size` /// - ::ZE_RESULT_ERROR_UNSUPPORTED_ALIGNMENT ze_result_t ZE_APICALL zePhysicalMemCreate( ze_context_handle_t hContext, ///< [in] handle of the context object - ze_device_handle_t hDevice, ///< [in] handle of the device object + ze_device_handle_t hDevice, ///< [in] handle of the device object, can be `nullptr` if creating + ///< physical host memory. ze_physical_mem_desc_t* desc, ///< [in] pointer to physical memory descriptor. ze_physical_mem_handle_t* phPhysicalMemory ///< [out] pointer to handle of physical memory object created ) @@ -6948,15 +7047,15 @@ zeKernelSetGlobalOffsetExp( } /////////////////////////////////////////////////////////////////////////////// -/// @brief Reserve Cache on Device +/// @brief Returns a unique command identifier for the next command to be +/// appended to a command list. /// /// @details -/// - The application may call this function but may not be successful as -/// some other application may have reserve prior -/// -/// @remarks -/// _Analogues_ -/// - None +/// - This function may only be called for a mutable command list. +/// - This function may not be called on a closed command list. +/// - This function may be called from simultaneous threads with the same +/// command list handle. +/// - The implementation of this function should be lock-free. /// /// @returns /// - ::ZE_RESULT_SUCCESS @@ -6965,38 +7064,46 @@ zeKernelSetGlobalOffsetExp( /// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY /// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `nullptr == hDevice` +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == desc` +/// + `nullptr == pCommandId` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0xff < desc->flags` ze_result_t ZE_APICALL -zeDeviceReserveCacheExt( - ze_device_handle_t hDevice, ///< [in] handle of the device object - size_t cacheLevel, ///< [in] cache level where application want to reserve. If zero, then the - ///< driver shall default to last level of cache and attempt to reserve in - ///< that cache. - size_t cacheReservationSize ///< [in] value for reserving size, in bytes. If zero, then the driver - ///< shall remove prior reservation +zeCommandListGetNextCommandIdExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_command_id_exp_desc_t* desc, ///< [in] pointer to mutable command identifier descriptor + uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written ) { if(ze_lib::context->inTeardown) { return ZE_RESULT_ERROR_UNINITIALIZED; } - auto pfnReserveCacheExt = ze_lib::context->zeDdiTable.load()->Device.pfnReserveCacheExt; - if( nullptr == pfnReserveCacheExt ) { + auto pfnGetNextCommandIdExp = ze_lib::context->zeDdiTable.load()->CommandListExp.pfnGetNextCommandIdExp; + if( nullptr == pfnGetNextCommandIdExp ) { if(!ze_lib::context->isInitialized) return ZE_RESULT_ERROR_UNINITIALIZED; else return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; } - return pfnReserveCacheExt( hDevice, cacheLevel, cacheReservationSize ); + return pfnGetNextCommandIdExp( hCommandList, desc, pCommandId ); } /////////////////////////////////////////////////////////////////////////////// -/// @brief Assign VA section to use reserved section +/// @brief Returns a unique command identifier for the next command to be +/// appended to a command list. Provides possible kernel handles for +/// kernel mutation when ::ZE_MUTABLE_COMMAND_EXP_FLAG_KERNEL_INSTRUCTION +/// flag is present. /// /// @details -/// - The application may call this function to assign VA to particular -/// reservartion region +/// - This function may only be called for a mutable command list. +/// - This function may not be called on a closed command list. +/// - This function may be called from simultaneous threads with the same +/// command list handle. +/// - The implementation of this function should be lock-free. /// /// @returns /// - ::ZE_RESULT_SUCCESS @@ -7005,52 +7112,50 @@ zeDeviceReserveCacheExt( /// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY /// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `nullptr == hDevice` +/// + `nullptr == hCommandList` /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER -/// + `nullptr == ptr` +/// + `nullptr == desc` +/// + `nullptr == pCommandId` /// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION -/// + `::ZE_CACHE_EXT_REGION_NON_RESERVED < cacheRegion` +/// + `0xff < desc->flags` ze_result_t ZE_APICALL -zeDeviceSetCacheAdviceExt( - ze_device_handle_t hDevice, ///< [in] handle of the device object - void* ptr, ///< [in] memory pointer to query - size_t regionSize, ///< [in] region size, in pages - ze_cache_ext_region_t cacheRegion ///< [in] reservation region +zeCommandListGetNextCommandIdWithKernelsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_command_id_exp_desc_t* desc, ///< [in][out] pointer to mutable command identifier descriptor + uint32_t numKernels, ///< [in][optional] number of entries on phKernels list + ze_kernel_handle_t* phKernels, ///< [in][optional][range(0, numKernels)] list of kernels that user can + ///< switch between using ::zeCommandListUpdateMutableCommandKernelsExp + ///< call + uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written ) { if(ze_lib::context->inTeardown) { return ZE_RESULT_ERROR_UNINITIALIZED; } - auto pfnSetCacheAdviceExt = ze_lib::context->zeDdiTable.load()->Device.pfnSetCacheAdviceExt; - if( nullptr == pfnSetCacheAdviceExt ) { + auto pfnGetNextCommandIdWithKernelsExp = ze_lib::context->zeDdiTable.load()->CommandListExp.pfnGetNextCommandIdWithKernelsExp; + if( nullptr == pfnGetNextCommandIdWithKernelsExp ) { if(!ze_lib::context->isInitialized) return ZE_RESULT_ERROR_UNINITIALIZED; else return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; } - return pfnSetCacheAdviceExt( hDevice, ptr, regionSize, cacheRegion ); + return pfnGetNextCommandIdWithKernelsExp( hCommandList, desc, numKernels, phKernels, pCommandId ); } /////////////////////////////////////////////////////////////////////////////// -/// @brief Query event timestamps for a device or sub-device. +/// @brief Updates mutable commands. /// /// @details -/// - The application may call this function from simultaneous threads. -/// - The implementation of this function must be thread-safe. -/// - The implementation must support -/// ::ZE_experimental_event_query_timestamps. -/// - The implementation must return all timestamps for the specified event -/// and device pair. -/// - The implementation must return all timestamps for all sub-devices when -/// device handle is parent device. -/// - The implementation may return all timestamps for sub-devices when -/// device handle is sub-device or may return 0 for count. -/// -/// @remarks -/// _Analogues_ -/// - None +/// - This function may only be called for a mutable command list. +/// - The application must synchronize mutable command list execution before +/// calling this function. +/// - The application must close a mutable command list after completing all +/// updates. +/// - This function must not be called from simultaneous threads with the +/// same command list handle. +/// - The implementation of this function should be lock-free. /// /// @returns /// - ::ZE_RESULT_SUCCESS @@ -7059,51 +7164,48 @@ zeDeviceSetCacheAdviceExt( /// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY /// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `nullptr == hEvent` -/// + `nullptr == hDevice` +/// + `nullptr == hCommandList` /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER -/// + `nullptr == pCount` +/// + `nullptr == desc` +/// - ::ZE_RESULT_ERROR_INVALID_ARGUMENT +/// + Invalid kernel argument or not matching update descriptor provided ze_result_t ZE_APICALL -zeEventQueryTimestampsExp( - ze_event_handle_t hEvent, ///< [in] handle of the event - ze_device_handle_t hDevice, ///< [in] handle of the device to query - uint32_t* pCount, ///< [in,out] pointer to the number of timestamp results. - ///< if count is zero, then the driver shall update the value with the - ///< total number of timestamps available. - ///< if count is greater than the number of timestamps available, then the - ///< driver shall update the value with the correct number of timestamps available. - ze_kernel_timestamp_result_t* pTimestamps ///< [in,out][optional][range(0, *pCount)] array of timestamp results. - ///< if count is less than the number of timestamps available, then driver - ///< shall only retrieve that number of timestamps. +zeCommandListUpdateMutableCommandsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_commands_exp_desc_t* desc ///< [in] pointer to mutable commands descriptor; multiple descriptors may + ///< be chained via `pNext` member ) { if(ze_lib::context->inTeardown) { return ZE_RESULT_ERROR_UNINITIALIZED; } - auto pfnQueryTimestampsExp = ze_lib::context->zeDdiTable.load()->EventExp.pfnQueryTimestampsExp; - if( nullptr == pfnQueryTimestampsExp ) { + auto pfnUpdateMutableCommandsExp = ze_lib::context->zeDdiTable.load()->CommandListExp.pfnUpdateMutableCommandsExp; + if( nullptr == pfnUpdateMutableCommandsExp ) { if(!ze_lib::context->isInitialized) return ZE_RESULT_ERROR_UNINITIALIZED; else return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; } - return pfnQueryTimestampsExp( hEvent, hDevice, pCount, pTimestamps ); + return pfnUpdateMutableCommandsExp( hCommandList, desc ); } /////////////////////////////////////////////////////////////////////////////// -/// @brief Query image memory properties. +/// @brief Updates the signal event for a mutable command in a mutable command +/// list. /// /// @details -/// - The application may call this function from simultaneous threads. -/// - The implementation of this function must be thread-safe. -/// - The implementation must support -/// ::ZE_experimental_image_memory_properties extension. -/// -/// @remarks -/// _Analogues_ -/// - None +/// - This function may only be called for a mutable command list. +/// - The type, scope and flags of the signal event must match those of the +/// source command. +/// - The application must synchronize mutable command list execution before +/// calling this function. +/// - The application must close a mutable command list after completing all +/// updates. +/// - This function must not be called from simultaneous threads with the +/// same command list handle. +/// - The implementation of this function should be lock-free. /// /// @returns /// - ::ZE_RESULT_SUCCESS @@ -7112,49 +7214,49 @@ zeEventQueryTimestampsExp( /// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY /// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `nullptr == hImage` -/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER -/// + `nullptr == pMemoryProperties` +/// + `nullptr == hCommandList` ze_result_t ZE_APICALL -zeImageGetMemoryPropertiesExp( - ze_image_handle_t hImage, ///< [in] handle of image object - ze_image_memory_properties_exp_t* pMemoryProperties ///< [in,out] query result for image memory properties. +zeCommandListUpdateMutableCommandSignalEventExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint64_t commandId, ///< [in] command identifier + ze_event_handle_t hSignalEvent ///< [in][optional] handle of the event to signal on completion ) { if(ze_lib::context->inTeardown) { return ZE_RESULT_ERROR_UNINITIALIZED; } - auto pfnGetMemoryPropertiesExp = ze_lib::context->zeDdiTable.load()->ImageExp.pfnGetMemoryPropertiesExp; - if( nullptr == pfnGetMemoryPropertiesExp ) { + auto pfnUpdateMutableCommandSignalEventExp = ze_lib::context->zeDdiTable.load()->CommandListExp.pfnUpdateMutableCommandSignalEventExp; + if( nullptr == pfnUpdateMutableCommandSignalEventExp ) { if(!ze_lib::context->isInitialized) return ZE_RESULT_ERROR_UNINITIALIZED; else return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; } - return pfnGetMemoryPropertiesExp( hImage, pMemoryProperties ); + return pfnUpdateMutableCommandSignalEventExp( hCommandList, commandId, hSignalEvent ); } /////////////////////////////////////////////////////////////////////////////// -/// @brief Create image view on the context. +/// @brief Updates the wait events for a mutable command in a mutable command +/// list. /// /// @details -/// - The application must only use the image view for the device, or its -/// sub-devices, which was provided during creation. -/// - The application may call this function from simultaneous threads. -/// - The implementation of this function must be thread-safe. -/// - The implementation must support ::ZE_extension_image_view extension. -/// - Image views are treated as images from the API. -/// - Image views provide a mechanism to redescribe how an image is -/// interpreted (e.g. different format). -/// - Image views become disabled when their corresponding image resource is -/// destroyed. -/// - Use ::zeImageDestroy to destroy image view objects. -/// -/// @remarks -/// _Analogues_ -/// - None +/// - This function may only be called for a mutable command list. +/// - The number of wait events must match that of the source command. +/// - The type, scope and flags of the wait events must match those of the +/// source command. +/// - Passing `nullptr` as the wait events will update the command to not +/// wait on any events prior to dispatch. +/// - Passing `nullptr` as an event on event wait list will remove event +/// dependency from this wait list slot. +/// - The application must synchronize mutable command list execution before +/// calling this function. +/// - The application must close a mutable command list after completing all +/// updates. +/// - This function must not be called from simultaneous threads with the +/// same command list handle. +/// - The implementation of this function should be lock-free. /// /// @returns /// - ::ZE_RESULT_SUCCESS @@ -7163,15 +7265,311 @@ zeImageGetMemoryPropertiesExp( /// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY /// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY /// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `nullptr == hContext` -/// + `nullptr == hDevice` -/// + `nullptr == hImage` -/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER -/// + `nullptr == desc` -/// + `nullptr == phImageView` -/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION -/// + `0x3 < desc->flags` -/// + `::ZE_IMAGE_TYPE_BUFFER < desc->type` +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + The `numWaitEvents` parameter does not match that of the original command. +ze_result_t ZE_APICALL +zeCommandListUpdateMutableCommandWaitEventsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint64_t commandId, ///< [in] command identifier + uint32_t numWaitEvents, ///< [in][optional] the number of wait events + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnUpdateMutableCommandWaitEventsExp = ze_lib::context->zeDdiTable.load()->CommandListExp.pfnUpdateMutableCommandWaitEventsExp; + if( nullptr == pfnUpdateMutableCommandWaitEventsExp ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnUpdateMutableCommandWaitEventsExp( hCommandList, commandId, numWaitEvents, phWaitEvents ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Updates the kernel for a mutable command in a mutable command list. +/// +/// @details +/// - This function may only be called for a mutable command list. +/// - The kernel handle must be from the provided list for given command id. +/// - The application must synchronize mutable command list execution before +/// calling this function. +/// - The application must close a mutable command list after completing all +/// updates. +/// - This function must not be called from simultaneous threads with the +/// same command list handle. +/// - This function must be called before updating kernel arguments and +/// dispatch parameters, when kernel is mutated. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hCommandList` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCommandId` +/// + `nullptr == phKernels` +/// - ::ZE_RESULT_ERROR_INVALID_KERNEL_HANDLE +/// + Invalid kernel handle provided for the mutation kernel instruction operation. +ze_result_t ZE_APICALL +zeCommandListUpdateMutableCommandKernelsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint32_t numKernels, ///< [in] the number of kernels to update + uint64_t* pCommandId, ///< [in][range(0, numKernels)] command identifier + ze_kernel_handle_t* phKernels ///< [in][range(0, numKernels)] handle of the kernel for a command + ///< identifier to switch to + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnUpdateMutableCommandKernelsExp = ze_lib::context->zeDdiTable.load()->CommandListExp.pfnUpdateMutableCommandKernelsExp; + if( nullptr == pfnUpdateMutableCommandKernelsExp ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnUpdateMutableCommandKernelsExp( hCommandList, numKernels, pCommandId, phKernels ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Reserve Cache on Device +/// +/// @details +/// - The application may call this function but may not be successful as +/// some other application may have reserve prior +/// +/// @remarks +/// _Analogues_ +/// - None +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hDevice` +ze_result_t ZE_APICALL +zeDeviceReserveCacheExt( + ze_device_handle_t hDevice, ///< [in] handle of the device object + size_t cacheLevel, ///< [in] cache level where application want to reserve. If zero, then the + ///< driver shall default to last level of cache and attempt to reserve in + ///< that cache. + size_t cacheReservationSize ///< [in] value for reserving size, in bytes. If zero, then the driver + ///< shall remove prior reservation + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnReserveCacheExt = ze_lib::context->zeDdiTable.load()->Device.pfnReserveCacheExt; + if( nullptr == pfnReserveCacheExt ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnReserveCacheExt( hDevice, cacheLevel, cacheReservationSize ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Assign VA section to use reserved section +/// +/// @details +/// - The application may call this function to assign VA to particular +/// reservartion region +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == ptr` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `::ZE_CACHE_EXT_REGION_NON_RESERVED < cacheRegion` +ze_result_t ZE_APICALL +zeDeviceSetCacheAdviceExt( + ze_device_handle_t hDevice, ///< [in] handle of the device object + void* ptr, ///< [in] memory pointer to query + size_t regionSize, ///< [in] region size, in pages + ze_cache_ext_region_t cacheRegion ///< [in] reservation region + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnSetCacheAdviceExt = ze_lib::context->zeDdiTable.load()->Device.pfnSetCacheAdviceExt; + if( nullptr == pfnSetCacheAdviceExt ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnSetCacheAdviceExt( hDevice, ptr, regionSize, cacheRegion ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Query event timestamps for a device or sub-device. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// - The implementation must support +/// ::ZE_experimental_event_query_timestamps. +/// - The implementation must return all timestamps for the specified event +/// and device pair. +/// - The implementation must return all timestamps for all sub-devices when +/// device handle is parent device. +/// - The implementation may return all timestamps for sub-devices when +/// device handle is sub-device or may return 0 for count. +/// +/// @remarks +/// _Analogues_ +/// - None +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hEvent` +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCount` +ze_result_t ZE_APICALL +zeEventQueryTimestampsExp( + ze_event_handle_t hEvent, ///< [in] handle of the event + ze_device_handle_t hDevice, ///< [in] handle of the device to query + uint32_t* pCount, ///< [in,out] pointer to the number of timestamp results. + ///< if count is zero, then the driver shall update the value with the + ///< total number of timestamps available. + ///< if count is greater than the number of timestamps available, then the + ///< driver shall update the value with the correct number of timestamps available. + ze_kernel_timestamp_result_t* pTimestamps ///< [in,out][optional][range(0, *pCount)] array of timestamp results. + ///< if count is less than the number of timestamps available, then driver + ///< shall only retrieve that number of timestamps. + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnQueryTimestampsExp = ze_lib::context->zeDdiTable.load()->EventExp.pfnQueryTimestampsExp; + if( nullptr == pfnQueryTimestampsExp ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnQueryTimestampsExp( hEvent, hDevice, pCount, pTimestamps ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Query image memory properties. +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// - The implementation must support +/// ::ZE_experimental_image_memory_properties extension. +/// +/// @remarks +/// _Analogues_ +/// - None +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hImage` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pMemoryProperties` +ze_result_t ZE_APICALL +zeImageGetMemoryPropertiesExp( + ze_image_handle_t hImage, ///< [in] handle of image object + ze_image_memory_properties_exp_t* pMemoryProperties ///< [in,out] query result for image memory properties. + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnGetMemoryPropertiesExp = ze_lib::context->zeDdiTable.load()->ImageExp.pfnGetMemoryPropertiesExp; + if( nullptr == pfnGetMemoryPropertiesExp ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnGetMemoryPropertiesExp( hImage, pMemoryProperties ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Create image view on the context. +/// +/// @details +/// - The application must only use the image view for the device, or its +/// sub-devices, which was provided during creation. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// - The implementation must support ::ZE_extension_image_view extension. +/// - Image views are treated as images from the API. +/// - Image views provide a mechanism to redescribe how an image is +/// interpreted (e.g. different format). +/// - Image views become disabled when their corresponding image resource is +/// destroyed. +/// - Use ::zeImageDestroy to destroy image view objects. +/// +/// @remarks +/// _Analogues_ +/// - None +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hDevice` +/// + `nullptr == hImage` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == desc` +/// + `nullptr == phImageView` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x3 < desc->flags` +/// + `::ZE_IMAGE_TYPE_BUFFER < desc->type` /// - ::ZE_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT ze_result_t ZE_APICALL zeImageViewCreateExt( @@ -8684,198 +9082,4 @@ zeCommandListImmediateAppendCommandListsExp( return pfnImmediateAppendCommandListsExp( hCommandListImmediate, numCommandLists, phCommandLists, hSignalEvent, numWaitEvents, phWaitEvents ); } -/////////////////////////////////////////////////////////////////////////////// -/// @brief Returns a unique command identifier for the next command to be -/// appended to a command list. -/// -/// @details -/// - This function may only be called for a mutable command list. -/// - This function may not be called on a closed command list. -/// - This function may be called from simultaneous threads with the same -/// command list handle. -/// - The implementation of this function should be lock-free. -/// -/// @returns -/// - ::ZE_RESULT_SUCCESS -/// - ::ZE_RESULT_ERROR_UNINITIALIZED -/// - ::ZE_RESULT_ERROR_DEVICE_LOST -/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY -/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY -/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `nullptr == hCommandList` -/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER -/// + `nullptr == desc` -/// + `nullptr == pCommandId` -/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION -/// + `0x3f < desc->flags` -ze_result_t ZE_APICALL -zeCommandListGetNextCommandIdExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - const ze_mutable_command_id_exp_desc_t* desc, ///< [in] pointer to mutable command identifier descriptor - uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written - ) -{ - if(ze_lib::context->inTeardown) { - return ZE_RESULT_ERROR_UNINITIALIZED; - } - - auto pfnGetNextCommandIdExp = ze_lib::context->zeDdiTable.load()->CommandListExp.pfnGetNextCommandIdExp; - if( nullptr == pfnGetNextCommandIdExp ) { - if(!ze_lib::context->isInitialized) - return ZE_RESULT_ERROR_UNINITIALIZED; - else - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; - } - - return pfnGetNextCommandIdExp( hCommandList, desc, pCommandId ); -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Updates mutable commands. -/// -/// @details -/// - This function may only be called for a mutable command list. -/// - The application must synchronize mutable command list execution before -/// calling this function. -/// - The application must close a mutable command list after completing all -/// updates. -/// - This function must not be called from simultaneous threads with the -/// same command list handle. -/// - The implementation of this function should be lock-free. -/// -/// @returns -/// - ::ZE_RESULT_SUCCESS -/// - ::ZE_RESULT_ERROR_UNINITIALIZED -/// - ::ZE_RESULT_ERROR_DEVICE_LOST -/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY -/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY -/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `nullptr == hCommandList` -/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER -/// + `nullptr == desc` -ze_result_t ZE_APICALL -zeCommandListUpdateMutableCommandsExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - const ze_mutable_commands_exp_desc_t* desc ///< [in] pointer to mutable commands descriptor; multiple descriptors may - ///< be chained via `pNext` member - ) -{ - if(ze_lib::context->inTeardown) { - return ZE_RESULT_ERROR_UNINITIALIZED; - } - - auto pfnUpdateMutableCommandsExp = ze_lib::context->zeDdiTable.load()->CommandListExp.pfnUpdateMutableCommandsExp; - if( nullptr == pfnUpdateMutableCommandsExp ) { - if(!ze_lib::context->isInitialized) - return ZE_RESULT_ERROR_UNINITIALIZED; - else - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; - } - - return pfnUpdateMutableCommandsExp( hCommandList, desc ); -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Updates the signal event for a mutable command in a mutable command -/// list. -/// -/// @details -/// - This function may only be called for a mutable command list. -/// - The type, scope and flags of the signal event must match those of the -/// source command. -/// - Passing a null pointer as the signal event will update the command to -/// not issue a signal. -/// - The application must synchronize mutable command list execution before -/// calling this function. -/// - The application must close a mutable command list after completing all -/// updates. -/// - This function must not be called from simultaneous threads with the -/// same command list handle. -/// - The implementation of this function should be lock-free. -/// -/// @returns -/// - ::ZE_RESULT_SUCCESS -/// - ::ZE_RESULT_ERROR_UNINITIALIZED -/// - ::ZE_RESULT_ERROR_DEVICE_LOST -/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY -/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY -/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `nullptr == hCommandList` -ze_result_t ZE_APICALL -zeCommandListUpdateMutableCommandSignalEventExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - uint64_t commandId, ///< [in] command identifier - ze_event_handle_t hSignalEvent ///< [in][optional] handle of the event to signal on completion - ) -{ - if(ze_lib::context->inTeardown) { - return ZE_RESULT_ERROR_UNINITIALIZED; - } - - auto pfnUpdateMutableCommandSignalEventExp = ze_lib::context->zeDdiTable.load()->CommandListExp.pfnUpdateMutableCommandSignalEventExp; - if( nullptr == pfnUpdateMutableCommandSignalEventExp ) { - if(!ze_lib::context->isInitialized) - return ZE_RESULT_ERROR_UNINITIALIZED; - else - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; - } - - return pfnUpdateMutableCommandSignalEventExp( hCommandList, commandId, hSignalEvent ); -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Updates the wait events for a mutable command in a mutable command -/// list. -/// -/// @details -/// - This function may only be called for a mutable command list. -/// - The number of wait events must match that of the source command. -/// - The type, scope and flags of the wait events must match those of the -/// source command. -/// - Passing `nullptr` as the wait events will update the command to not -/// wait on any events prior to dispatch. -/// - Passing `nullptr` as an event on event wait list will remove event -/// dependency from this wait list slot. -/// - The application must synchronize mutable command list execution before -/// calling this function. -/// - The application must close a mutable command list after completing all -/// updates. -/// - This function must not be called from simultaneous threads with the -/// same command list handle. -/// - The implementation of this function should be lock-free. -/// -/// @returns -/// - ::ZE_RESULT_SUCCESS -/// - ::ZE_RESULT_ERROR_UNINITIALIZED -/// - ::ZE_RESULT_ERROR_DEVICE_LOST -/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY -/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY -/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `nullptr == hCommandList` -/// - ::ZE_RESULT_ERROR_INVALID_SIZE -/// + The `numWaitEvents` parameter does not match that of the original command. -ze_result_t ZE_APICALL -zeCommandListUpdateMutableCommandWaitEventsExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - uint64_t commandId, ///< [in] command identifier - uint32_t numWaitEvents, ///< [in][optional] the number of wait events - ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait - ///< on before launching - ) -{ - if(ze_lib::context->inTeardown) { - return ZE_RESULT_ERROR_UNINITIALIZED; - } - - auto pfnUpdateMutableCommandWaitEventsExp = ze_lib::context->zeDdiTable.load()->CommandListExp.pfnUpdateMutableCommandWaitEventsExp; - if( nullptr == pfnUpdateMutableCommandWaitEventsExp ) { - if(!ze_lib::context->isInitialized) - return ZE_RESULT_ERROR_UNINITIALIZED; - else - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; - } - - return pfnUpdateMutableCommandWaitEventsExp( hCommandList, commandId, numWaitEvents, phWaitEvents ); -} - } // extern "C" diff --git a/source/lib/ze_tracing_register_cb_libapi.cpp b/source/lib/ze_tracing_register_cb_libapi.cpp index e94c6fe4..8fafc55b 100644 --- a/source/lib/ze_tracing_register_cb_libapi.cpp +++ b/source/lib/ze_tracing_register_cb_libapi.cpp @@ -68,6 +68,31 @@ zelTracerDriverGetRegisterCallback( } +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerInitDriversRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnInitDriversCb_t pfnInitDriversCb + ) { + + if(!ze_lib::context->tracing_lib) + return ZE_RESULT_ERROR_UNINITIALIZED; + typedef ze_result_t (ZE_APICALL *ze_pfnSetCallback_t)( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnInitDriversCb_t pfnInitDriversCb + ); + + auto func = reinterpret_cast( + GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "zelTracerInitDriversRegisterCallback") ); + + if(func) + return func(hTracer, callback_type, pfnInitDriversCb); + + return ZE_RESULT_ERROR_UNINITIALIZED; +} + + ZE_APIEXPORT ze_result_t ZE_APICALL zelTracerDriverGetApiVersionRegisterCallback( zel_tracer_handle_t hTracer, @@ -3643,6 +3668,156 @@ zelTracerKernelSetGlobalOffsetExpRegisterCallback( } +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerCommandListGetNextCommandIdExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListGetNextCommandIdExpCb_t pfnGetNextCommandIdExpCb + ) { + + if(!ze_lib::context->tracing_lib) + return ZE_RESULT_ERROR_UNINITIALIZED; + typedef ze_result_t (ZE_APICALL *ze_pfnSetCallback_t)( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListGetNextCommandIdExpCb_t pfnGetNextCommandIdExpCb + ); + + auto func = reinterpret_cast( + GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "zelTracerCommandListGetNextCommandIdExpRegisterCallback") ); + + if(func) + return func(hTracer, callback_type, pfnGetNextCommandIdExpCb); + + return ZE_RESULT_ERROR_UNINITIALIZED; +} + + +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerCommandListGetNextCommandIdWithKernelsExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListGetNextCommandIdWithKernelsExpCb_t pfnGetNextCommandIdWithKernelsExpCb + ) { + + if(!ze_lib::context->tracing_lib) + return ZE_RESULT_ERROR_UNINITIALIZED; + typedef ze_result_t (ZE_APICALL *ze_pfnSetCallback_t)( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListGetNextCommandIdWithKernelsExpCb_t pfnGetNextCommandIdWithKernelsExpCb + ); + + auto func = reinterpret_cast( + GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "zelTracerCommandListGetNextCommandIdWithKernelsExpRegisterCallback") ); + + if(func) + return func(hTracer, callback_type, pfnGetNextCommandIdWithKernelsExpCb); + + return ZE_RESULT_ERROR_UNINITIALIZED; +} + + +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerCommandListUpdateMutableCommandsExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListUpdateMutableCommandsExpCb_t pfnUpdateMutableCommandsExpCb + ) { + + if(!ze_lib::context->tracing_lib) + return ZE_RESULT_ERROR_UNINITIALIZED; + typedef ze_result_t (ZE_APICALL *ze_pfnSetCallback_t)( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListUpdateMutableCommandsExpCb_t pfnUpdateMutableCommandsExpCb + ); + + auto func = reinterpret_cast( + GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "zelTracerCommandListUpdateMutableCommandsExpRegisterCallback") ); + + if(func) + return func(hTracer, callback_type, pfnUpdateMutableCommandsExpCb); + + return ZE_RESULT_ERROR_UNINITIALIZED; +} + + +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerCommandListUpdateMutableCommandSignalEventExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListUpdateMutableCommandSignalEventExpCb_t pfnUpdateMutableCommandSignalEventExpCb + ) { + + if(!ze_lib::context->tracing_lib) + return ZE_RESULT_ERROR_UNINITIALIZED; + typedef ze_result_t (ZE_APICALL *ze_pfnSetCallback_t)( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListUpdateMutableCommandSignalEventExpCb_t pfnUpdateMutableCommandSignalEventExpCb + ); + + auto func = reinterpret_cast( + GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "zelTracerCommandListUpdateMutableCommandSignalEventExpRegisterCallback") ); + + if(func) + return func(hTracer, callback_type, pfnUpdateMutableCommandSignalEventExpCb); + + return ZE_RESULT_ERROR_UNINITIALIZED; +} + + +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerCommandListUpdateMutableCommandWaitEventsExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListUpdateMutableCommandWaitEventsExpCb_t pfnUpdateMutableCommandWaitEventsExpCb + ) { + + if(!ze_lib::context->tracing_lib) + return ZE_RESULT_ERROR_UNINITIALIZED; + typedef ze_result_t (ZE_APICALL *ze_pfnSetCallback_t)( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListUpdateMutableCommandWaitEventsExpCb_t pfnUpdateMutableCommandWaitEventsExpCb + ); + + auto func = reinterpret_cast( + GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "zelTracerCommandListUpdateMutableCommandWaitEventsExpRegisterCallback") ); + + if(func) + return func(hTracer, callback_type, pfnUpdateMutableCommandWaitEventsExpCb); + + return ZE_RESULT_ERROR_UNINITIALIZED; +} + + +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerCommandListUpdateMutableCommandKernelsExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListUpdateMutableCommandKernelsExpCb_t pfnUpdateMutableCommandKernelsExpCb + ) { + + if(!ze_lib::context->tracing_lib) + return ZE_RESULT_ERROR_UNINITIALIZED; + typedef ze_result_t (ZE_APICALL *ze_pfnSetCallback_t)( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListUpdateMutableCommandKernelsExpCb_t pfnUpdateMutableCommandKernelsExpCb + ); + + auto func = reinterpret_cast( + GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "zelTracerCommandListUpdateMutableCommandKernelsExpRegisterCallback") ); + + if(func) + return func(hTracer, callback_type, pfnUpdateMutableCommandKernelsExpCb); + + return ZE_RESULT_ERROR_UNINITIALIZED; +} + + ZE_APIEXPORT ze_result_t ZE_APICALL zelTracerDeviceReserveCacheExtRegisterCallback( zel_tracer_handle_t hTracer, @@ -4518,104 +4693,4 @@ zelTracerCommandListImmediateAppendCommandListsExpRegisterCallback( } -ZE_APIEXPORT ze_result_t ZE_APICALL -zelTracerCommandListGetNextCommandIdExpRegisterCallback( - zel_tracer_handle_t hTracer, - zel_tracer_reg_t callback_type, - ze_pfnCommandListGetNextCommandIdExpCb_t pfnGetNextCommandIdExpCb - ) { - - if(!ze_lib::context->tracing_lib) - return ZE_RESULT_ERROR_UNINITIALIZED; - typedef ze_result_t (ZE_APICALL *ze_pfnSetCallback_t)( - zel_tracer_handle_t hTracer, - zel_tracer_reg_t callback_type, - ze_pfnCommandListGetNextCommandIdExpCb_t pfnGetNextCommandIdExpCb - ); - - auto func = reinterpret_cast( - GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "zelTracerCommandListGetNextCommandIdExpRegisterCallback") ); - - if(func) - return func(hTracer, callback_type, pfnGetNextCommandIdExpCb); - - return ZE_RESULT_ERROR_UNINITIALIZED; -} - - -ZE_APIEXPORT ze_result_t ZE_APICALL -zelTracerCommandListUpdateMutableCommandsExpRegisterCallback( - zel_tracer_handle_t hTracer, - zel_tracer_reg_t callback_type, - ze_pfnCommandListUpdateMutableCommandsExpCb_t pfnUpdateMutableCommandsExpCb - ) { - - if(!ze_lib::context->tracing_lib) - return ZE_RESULT_ERROR_UNINITIALIZED; - typedef ze_result_t (ZE_APICALL *ze_pfnSetCallback_t)( - zel_tracer_handle_t hTracer, - zel_tracer_reg_t callback_type, - ze_pfnCommandListUpdateMutableCommandsExpCb_t pfnUpdateMutableCommandsExpCb - ); - - auto func = reinterpret_cast( - GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "zelTracerCommandListUpdateMutableCommandsExpRegisterCallback") ); - - if(func) - return func(hTracer, callback_type, pfnUpdateMutableCommandsExpCb); - - return ZE_RESULT_ERROR_UNINITIALIZED; -} - - -ZE_APIEXPORT ze_result_t ZE_APICALL -zelTracerCommandListUpdateMutableCommandSignalEventExpRegisterCallback( - zel_tracer_handle_t hTracer, - zel_tracer_reg_t callback_type, - ze_pfnCommandListUpdateMutableCommandSignalEventExpCb_t pfnUpdateMutableCommandSignalEventExpCb - ) { - - if(!ze_lib::context->tracing_lib) - return ZE_RESULT_ERROR_UNINITIALIZED; - typedef ze_result_t (ZE_APICALL *ze_pfnSetCallback_t)( - zel_tracer_handle_t hTracer, - zel_tracer_reg_t callback_type, - ze_pfnCommandListUpdateMutableCommandSignalEventExpCb_t pfnUpdateMutableCommandSignalEventExpCb - ); - - auto func = reinterpret_cast( - GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "zelTracerCommandListUpdateMutableCommandSignalEventExpRegisterCallback") ); - - if(func) - return func(hTracer, callback_type, pfnUpdateMutableCommandSignalEventExpCb); - - return ZE_RESULT_ERROR_UNINITIALIZED; -} - - -ZE_APIEXPORT ze_result_t ZE_APICALL -zelTracerCommandListUpdateMutableCommandWaitEventsExpRegisterCallback( - zel_tracer_handle_t hTracer, - zel_tracer_reg_t callback_type, - ze_pfnCommandListUpdateMutableCommandWaitEventsExpCb_t pfnUpdateMutableCommandWaitEventsExpCb - ) { - - if(!ze_lib::context->tracing_lib) - return ZE_RESULT_ERROR_UNINITIALIZED; - typedef ze_result_t (ZE_APICALL *ze_pfnSetCallback_t)( - zel_tracer_handle_t hTracer, - zel_tracer_reg_t callback_type, - ze_pfnCommandListUpdateMutableCommandWaitEventsExpCb_t pfnUpdateMutableCommandWaitEventsExpCb - ); - - auto func = reinterpret_cast( - GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "zelTracerCommandListUpdateMutableCommandWaitEventsExpRegisterCallback") ); - - if(func) - return func(hTracer, callback_type, pfnUpdateMutableCommandWaitEventsExpCb); - - return ZE_RESULT_ERROR_UNINITIALIZED; -} - - } //Extern C \ No newline at end of file diff --git a/source/lib/zes_libapi.cpp b/source/lib/zes_libapi.cpp index f3151164..3f995507 100644 --- a/source/lib/zes_libapi.cpp +++ b/source/lib/zes_libapi.cpp @@ -50,7 +50,7 @@ zesInit( { static ze_result_t result = ZE_RESULT_SUCCESS; std::call_once(ze_lib::context->initOnceSysMan, [flags]() { - result = ze_lib::context->Init(flags, true); + result = ze_lib::context->Init(flags, true, nullptr); }); @@ -6117,6 +6117,7 @@ zesDriverGetDeviceByUuidExp( /// @brief Get handle of virtual function modules /// /// @details +/// - [DEPRECATED] No longer supported. Use ::zesDeviceEnumEnabledVFExp. /// - The application may call this function from simultaneous threads. /// - The implementation of this function should be lock-free. /// @@ -6165,6 +6166,8 @@ zesDeviceEnumActiveVFExp( /// @brief Get virtual function management properties /// /// @details +/// - [DEPRECATED] No longer supported. Use +/// ::zesVFManagementGetVFCapabilitiesExp. /// - The application may call this function from simultaneous threads. /// - The implementation of this function should be lock-free. /// @@ -6204,6 +6207,8 @@ zesVFManagementGetVFPropertiesExp( /// with Virtual Function (VF) /// /// @details +/// - [DEPRECATED] No longer supported. Use +/// ::zesVFManagementGetVFMemoryUtilizationExp2. /// - The application may call this function from simultaneous threads. /// - The implementation of this function should be lock-free. /// @@ -6255,6 +6260,8 @@ zesVFManagementGetVFMemoryUtilizationExp( /// with Virtual Function (VF) /// /// @details +/// - [DEPRECATED] No longer supported. Use +/// ::zesVFManagementGetVFEngineUtilizationExp2. /// - The application may call this function from simultaneous threads. /// - The implementation of this function should be lock-free. /// @@ -6306,6 +6313,7 @@ zesVFManagementGetVFEngineUtilizationExp( /// Virtual Function (VF) /// /// @details +/// - [DEPRECATED] No longer supported. /// - The application may call this function from simultaneous threads. /// - The implementation of this function should be lock-free. /// @@ -6347,6 +6355,7 @@ zesVFManagementSetVFTelemetryModeExp( /// telemetry associated with Virtual Function (VF) /// /// @details +/// - [DEPRECATED] No longer supported. /// - The application may call this function from simultaneous threads. /// - The implementation of this function should be lock-free. /// @@ -6383,4 +6392,190 @@ zesVFManagementSetVFTelemetrySamplingIntervalExp( return pfnSetVFTelemetrySamplingIntervalExp( hVFhandle, flag, samplingInterval ); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get handle of virtual function modules +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCount` +ze_result_t ZE_APICALL +zesDeviceEnumEnabledVFExp( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_vf_handle_t* phVFhandle ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnEnumEnabledVFExp = ze_lib::context->zesDdiTable.load()->DeviceExp.pfnEnumEnabledVFExp; + if( nullptr == pfnEnumEnabledVFExp ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnEnumEnabledVFExp( hDevice, pCount, phVFhandle ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get virtual function management capabilities +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hVFhandle` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCapability` +ze_result_t ZE_APICALL +zesVFManagementGetVFCapabilitiesExp( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. + zes_vf_exp_capabilities_t* pCapability ///< [in,out] Will contain VF capability. + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnGetVFCapabilitiesExp = ze_lib::context->zesDdiTable.load()->VFManagementExp.pfnGetVFCapabilitiesExp; + if( nullptr == pfnGetVFCapabilitiesExp ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnGetVFCapabilitiesExp( hVFhandle, pCapability ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get memory activity stats for each available memory types associated +/// with Virtual Function (VF) +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// - If VF is disable/pause/not active, utilization will give zero value. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hVFhandle` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCount` +ze_result_t ZE_APICALL +zesVFManagementGetVFMemoryUtilizationExp2( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF memory stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of memory stats available. + ///< - if count is greater than the total number of memory stats + ///< available, the driver shall update the value with the correct number + ///< of memory stats available. + zes_vf_util_mem_exp2_t* pMemUtil ///< [in,out][optional][range(0, *pCount)] array of memory group activity counters. + ///< - if count is less than the total number of memory stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector pCount-1 number of VF + ///< memory stats. + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnGetVFMemoryUtilizationExp2 = ze_lib::context->zesDdiTable.load()->VFManagement.pfnGetVFMemoryUtilizationExp2; + if( nullptr == pfnGetVFMemoryUtilizationExp2 ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnGetVFMemoryUtilizationExp2( hVFhandle, pCount, pMemUtil ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get engine activity stats for each available engine group associated +/// with Virtual Function (VF) +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// - If VF is disable/pause/not active, utilization will give zero value. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hVFhandle` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCount` +ze_result_t ZE_APICALL +zesVFManagementGetVFEngineUtilizationExp2( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF engine stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of engine stats available. + ///< - if count is greater than the total number of engine stats + ///< available, the driver shall update the value with the correct number + ///< of engine stats available. + zes_vf_util_engine_exp2_t* pEngineUtil ///< [in,out][optional][range(0, *pCount)] array of engine group activity counters. + ///< - if count is less than the total number of engine stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector pCount-1 number of VF + ///< engine stats. + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnGetVFEngineUtilizationExp2 = ze_lib::context->zesDdiTable.load()->VFManagement.pfnGetVFEngineUtilizationExp2; + if( nullptr == pfnGetVFEngineUtilizationExp2 ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnGetVFEngineUtilizationExp2( hVFhandle, pCount, pEngineUtil ); +} + } // extern "C" diff --git a/source/lib/zes_libddi.cpp b/source/lib/zes_libddi.cpp index 48bad20a..8e5b961a 100644 --- a/source/lib/zes_libddi.cpp +++ b/source/lib/zes_libddi.cpp @@ -182,6 +182,13 @@ namespace ze_lib result = getTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.Temperature ); } + if( ZE_RESULT_SUCCESS == result ) + { + auto getTable = reinterpret_cast( + GET_FUNCTION_PTR(loader, "zesGetVFManagementProcAddrTable") ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.VFManagement ); + } + if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( @@ -311,6 +318,11 @@ namespace ze_lib result = zesGetTemperatureProcAddrTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.Temperature ); } + if( ZE_RESULT_SUCCESS == result ) + { + result = zesGetVFManagementProcAddrTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.VFManagement ); + } + if( ZE_RESULT_SUCCESS == result ) { result = zesGetVFManagementExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.VFManagementExp ); diff --git a/source/lib/zet_libapi.cpp b/source/lib/zet_libapi.cpp index 75661344..501d0dfc 100644 --- a/source/lib/zet_libapi.cpp +++ b/source/lib/zet_libapi.cpp @@ -334,7 +334,7 @@ zetDebugResume( /// + `nullptr == desc` /// + `nullptr == buffer` /// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION -/// + `::ZET_DEBUG_MEMORY_SPACE_TYPE_SLM < desc->type` +/// + `::ZET_DEBUG_MEMORY_SPACE_TYPE_ELF < desc->type` /// - ::ZE_RESULT_ERROR_NOT_AVAILABLE /// + the thread is running or unavailable /// + the memory cannot be accessed from the supplied thread @@ -381,7 +381,7 @@ zetDebugReadMemory( /// + `nullptr == desc` /// + `nullptr == buffer` /// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION -/// + `::ZET_DEBUG_MEMORY_SPACE_TYPE_SLM < desc->type` +/// + `::ZET_DEBUG_MEMORY_SPACE_TYPE_ELF < desc->type` /// - ::ZE_RESULT_ERROR_NOT_AVAILABLE /// + the thread is running or unavailable /// + the memory cannot be accessed from the supplied thread @@ -1663,6 +1663,477 @@ zetTracerExpSetEnabled( return pfnSetEnabled( hTracer, enable ); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get sets of metric groups which could be collected concurrently. +/// +/// @details +/// - Re-arrange the input metric groups to provide sets of concurrent +/// metric groups. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hDevice` +/// + `nullptr == phMetricGroups` +ze_result_t ZE_APICALL +zetDeviceGetConcurrentMetricGroupsExp( + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t metricGroupCount, ///< [in] metric group count + zet_metric_group_handle_t * phMetricGroups, ///< [in,out] metrics groups to be re-arranged to be sets of concurrent + ///< groups + uint32_t * pMetricGroupsCountPerConcurrentGroup,///< [in,out][optional][*pConcurrentGroupCount] count of metric groups per + ///< concurrent group. + uint32_t * pConcurrentGroupCount ///< [out] number of concurrent groups. + ///< The value of this parameter could be used to determine the number of + ///< replays necessary. + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnGetConcurrentMetricGroupsExp = ze_lib::context->zetDdiTable.load()->DeviceExp.pfnGetConcurrentMetricGroupsExp; + if( nullptr == pfnGetConcurrentMetricGroupsExp ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnGetConcurrentMetricGroupsExp( hDevice, metricGroupCount, phMetricGroups, pMetricGroupsCountPerConcurrentGroup, pConcurrentGroupCount ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Create a metric tracer for a device. +/// +/// @details +/// - The notification event must have been created from an event pool that +/// was created using ::ZE_EVENT_POOL_FLAG_HOST_VISIBLE flag. +/// - The duration of the signal event created from an event pool that was +/// created using ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP flag is undefined. +/// However, for consistency and orthogonality the event will report +/// correctly as signaled when used by other event API functionality. +/// - The application must **not** call this function from simultaneous +/// threads with the same device handle. +/// - The metric tracer is created in disabled state +/// - Metric groups must support sampling type +/// ZET_METRIC_SAMPLING_TYPE_EXP_FLAG_TRACER_BASED +/// - All metric groups must be first activated +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hContext` +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == phMetricGroups` +/// + `nullptr == desc` +/// + `nullptr == phMetricTracer` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +ze_result_t ZE_APICALL +zetMetricTracerCreateExp( + zet_context_handle_t hContext, ///< [in] handle of the context object + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t metricGroupCount, ///< [in] metric group count + zet_metric_group_handle_t* phMetricGroups, ///< [in][range(0, metricGroupCount )] handles of the metric groups to + ///< trace + zet_metric_tracer_exp_desc_t* desc, ///< [in,out] metric tracer descriptor + ze_event_handle_t hNotificationEvent, ///< [in][optional] event used for report availability notification. Note: + ///< If buffer is not drained when the event it flagged, there is a risk of + ///< HW event buffer being overrun + zet_metric_tracer_exp_handle_t* phMetricTracer ///< [out] handle of the metric tracer + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnCreateExp = ze_lib::context->zetDdiTable.load()->MetricTracerExp.pfnCreateExp; + if( nullptr == pfnCreateExp ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnCreateExp( hContext, hDevice, metricGroupCount, phMetricGroups, desc, hNotificationEvent, phMetricTracer ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Destroy a metric tracer. +/// +/// @details +/// - The application must **not** call this function from simultaneous +/// threads with the same metric tracer handle. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hMetricTracer` +ze_result_t ZE_APICALL +zetMetricTracerDestroyExp( + zet_metric_tracer_exp_handle_t hMetricTracer ///< [in] handle of the metric tracer + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnDestroyExp = ze_lib::context->zetDdiTable.load()->MetricTracerExp.pfnDestroyExp; + if( nullptr == pfnDestroyExp ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnDestroyExp( hMetricTracer ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Start events collection +/// +/// @details +/// - Driver implementations must make this API call have as minimal +/// overhead as possible, to allow applications start/stop event +/// collection at any point during execution +/// - The application must **not** call this function from simultaneous +/// threads with the same metric tracer handle. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hMetricTracer` +ze_result_t ZE_APICALL +zetMetricTracerEnableExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + ze_bool_t synchronous ///< [in] request synchronous behavior. Confirmation of successful + ///< asynchronous operation is done by calling ::zetMetricTracerReadDataExp() + ///< and checking the return status: ::ZE_RESULT_NOT_READY will be returned + ///< when the tracer is inactive. ::ZE_RESULT_SUCCESS will be returned + ///< when the tracer is active. + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnEnableExp = ze_lib::context->zetDdiTable.load()->MetricTracerExp.pfnEnableExp; + if( nullptr == pfnEnableExp ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnEnableExp( hMetricTracer, synchronous ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Stop events collection +/// +/// @details +/// - Driver implementations must make this API call have as minimal +/// overhead as possible, to allow applications start/stop event +/// collection at any point during execution +/// - The application must **not** call this function from simultaneous +/// threads with the same metric tracer handle. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hMetricTracer` +ze_result_t ZE_APICALL +zetMetricTracerDisableExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + ze_bool_t synchronous ///< [in] request synchronous behavior. Confirmation of successful + ///< asynchronous operation is done by calling ::zetMetricTracerReadDataExp() + ///< and checking the return status: ::ZE_RESULT_SUCCESS will be returned + ///< when the tracer is active or when it is inactive but still has data. + ///< ::ZE_RESULT_NOT_READY will be returned when the tracer is inactive and + ///< has no more data to be retrieved. + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnDisableExp = ze_lib::context->zetDdiTable.load()->MetricTracerExp.pfnDisableExp; + if( nullptr == pfnDisableExp ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnDisableExp( hMetricTracer, synchronous ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Read data from the metric tracer +/// +/// @details +/// - The application must **not** call this function from simultaneous +/// threads with the same metric tracer handle. +/// - Data can be retrieved after tracer is disabled. When buffers are +/// drained ::ZE_RESULT_NOT_READY will be returned +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hMetricTracer` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pRawDataSize` +/// - ::ZE_RESULT_WARNING_DROPPED_DATA +/// + Metric tracer data may have been dropped. +/// - ::ZE_RESULT_NOT_READY +/// + Metric tracer is disabled and no data is available to read. +ze_result_t ZE_APICALL +zetMetricTracerReadDataExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + size_t* pRawDataSize, ///< [in,out] pointer to size in bytes of raw data requested to read. + ///< if size is zero, then the driver will update the value with the total + ///< size in bytes needed for all data available. + ///< if size is non-zero, then driver will only retrieve that amount of + ///< data. + ///< if size is larger than size needed for all data, then driver will + ///< update the value with the actual size needed. + uint8_t* pRawData ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing tracer + ///< data in raw format + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnReadDataExp = ze_lib::context->zetDdiTable.load()->MetricTracerExp.pfnReadDataExp; + if( nullptr == pfnReadDataExp ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnReadDataExp( hMetricTracer, pRawDataSize, pRawData ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Create a metric decoder for a given metric tracer. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hMetricTracer` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == phMetricDecoder` +ze_result_t ZE_APICALL +zetMetricDecoderCreateExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + zet_metric_decoder_exp_handle_t* phMetricDecoder///< [out] handle of the metric decoder object + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnCreateExp = ze_lib::context->zetDdiTable.load()->MetricDecoderExp.pfnCreateExp; + if( nullptr == pfnCreateExp ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnCreateExp( hMetricTracer, phMetricDecoder ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Destroy a metric decoder. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == phMetricDecoder` +ze_result_t ZE_APICALL +zetMetricDecoderDestroyExp( + zet_metric_decoder_exp_handle_t phMetricDecoder ///< [in] handle of the metric decoder object + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnDestroyExp = ze_lib::context->zetDdiTable.load()->MetricDecoderExp.pfnDestroyExp; + if( nullptr == pfnDestroyExp ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnDestroyExp( phMetricDecoder ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Return the list of the decodable metrics from the decoder. +/// +/// @details +/// - The decodable metrics handles returned by this API are defined by the +/// metric groups in the tracer on which the decoder was created. +/// - The decodable metrics handles returned by this API are only valid to +/// decode metrics raw data with ::zetMetricTracerDecodeExp(). Decodable +/// metric handles are not valid to compare with metrics handles included +/// in metric groups. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hMetricDecoder` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCount` +/// + `nullptr == phMetrics` +ze_result_t ZE_APICALL +zetMetricDecoderGetDecodableMetricsExp( + zet_metric_decoder_exp_handle_t hMetricDecoder, ///< [in] handle of the metric decoder object + uint32_t* pCount, ///< [in,out] pointer to number of decodable metric in the hMetricDecoder + ///< handle. If count is zero, then the driver shall + ///< update the value with the total number of decodable metrics available + ///< in the decoder. if count is greater than zero + ///< but less than the total number of decodable metrics available in the + ///< decoder, then only that number will be returned. + ///< if count is greater than the number of decodable metrics available in + ///< the decoder, then the driver shall update the + ///< value with the actual number of decodable metrics available. + zet_metric_handle_t* phMetrics ///< [in,out] [range(0, *pCount)] array of handles of decodable metrics in + ///< the hMetricDecoder handle provided. + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnGetDecodableMetricsExp = ze_lib::context->zetDdiTable.load()->MetricDecoderExp.pfnGetDecodableMetricsExp; + if( nullptr == pfnGetDecodableMetricsExp ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnGetDecodableMetricsExp( hMetricDecoder, pCount, phMetrics ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Decode raw events collected from a tracer. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == phMetricDecoder` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pRawDataSize` +/// + `nullptr == phMetrics` +/// + `nullptr == pSetCount` +/// + `nullptr == pMetricEntriesCount` +ze_result_t ZE_APICALL +zetMetricTracerDecodeExp( + zet_metric_decoder_exp_handle_t phMetricDecoder,///< [in] handle of the metric decoder object + size_t* pRawDataSize, ///< [in,out] size in bytes of raw data buffer. If pMetricEntriesCount is + ///< greater than zero but less than total number of + ///< decodable metrics available in the raw data buffer, then driver shall + ///< update this value with actual number of raw + ///< data bytes processed. + uint8_t* pRawData, ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing tracer + ///< data in raw format + uint32_t metricsCount, ///< [in] number of decodable metrics in the tracer for which the + ///< hMetricDecoder handle was provided. See + ///< ::zetMetricDecoderGetDecodableMetricsExp(). If metricCount is greater + ///< than zero but less than the number decodable + ///< metrics available in the raw data buffer, then driver shall only + ///< decode those. + zet_metric_handle_t* phMetrics, ///< [in] [range(0, metricsCount)] array of handles of decodable metrics in + ///< the decoder for which the hMetricDecoder handle was + ///< provided. Metrics handles are expected to be for decodable metrics, + ///< see ::zetMetricDecoderGetDecodableMetrics() + uint32_t* pSetCount, ///< [in,out] pointer to number of metric sets. If count is zero, then the + ///< driver shall update the value with the total + ///< number of metric sets to be decoded. If count is greater than the + ///< number available in the raw data buffer, then the + ///< driver shall update the value with the actual number of metric sets to + ///< be decoded. There is a 1:1 relation between + ///< the number of sets and sub-devices returned in the decoded entries. + uint32_t* pMetricEntriesCountPerSet, ///< [in,out][optional][range(0, *pSetCount)] buffer of metric entries + ///< counts per metric set, one value per set. + uint32_t* pMetricEntriesCount, ///< [in,out] pointer to the total number of metric entries decoded, for + ///< all metric sets. If count is zero, then the + ///< driver shall update the value with the total number of metric entries + ///< to be decoded. If count is greater than zero + ///< but less than the total number of metric entries available in the raw + ///< data, then user provided number will be decoded. + ///< If count is greater than the number available in the raw data buffer, + ///< then the driver shall update the value with + ///< the actual number of decodable metric entries decoded. If set to null, + ///< then driver will only update the value of + ///< pSetCount. + zet_metric_entry_exp_t* pMetricEntries ///< [in,out][optional][range(0, *pMetricEntriesCount)] buffer containing + ///< decoded metric entries + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnDecodeExp = ze_lib::context->zetDdiTable.load()->MetricTracerExp.pfnDecodeExp; + if( nullptr == pfnDecodeExp ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnDecodeExp( phMetricDecoder, pRawDataSize, pRawData, metricsCount, phMetrics, pSetCount, pMetricEntriesCountPerSet, pMetricEntriesCount, pMetricEntries ); +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Calculate one or more sets of metric values from raw data. /// @@ -2085,7 +2556,7 @@ zetMetricProgrammableGetParamValueInfoExp( /// - If parameterCount = 0, the default value of the metric programmable /// would be used for all parameters. /// - The implementation can post-fix a C string to the metric name and -/// description, based on the parmeter values chosen. +/// description, based on the parameter values chosen. /// - ::zetMetricProgrammableGetParamInfoExp() returns a list of parameters /// in a defined order. /// - Therefore, the list of values passed in to the API should respect the @@ -2105,6 +2576,63 @@ zetMetricProgrammableGetParamValueInfoExp( /// + `nullptr == pDescription` /// + `nullptr == pMetricHandleCount` ze_result_t ZE_APICALL +zetMetricCreateFromProgrammableExp2( + zet_metric_programmable_exp_handle_t hMetricProgrammable, ///< [in] handle of the metric programmable + uint32_t parameterCount, ///< [in] Count of parameters to set. + zet_metric_programmable_param_value_exp_t* pParameterValues,///< [in] list of parameter values to be set. + const char* pName, ///< [in] pointer to metric name to be used. Must point to a + ///< null-terminated character array no longer than ::ZET_MAX_METRIC_NAME. + const char* pDescription, ///< [in] pointer to metric description to be used. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_DESCRIPTION. + uint32_t* pMetricHandleCount, ///< [in,out] Pointer to the number of metric handles. + ///< if count is zero, then the driver shall update the value with the + ///< number of metric handles available for this programmable. + ///< if count is greater than the number of metric handles available, then + ///< the driver shall update the value with the correct number of metric + ///< handles available. + zet_metric_handle_t* phMetricHandles ///< [in,out][optional][range(0,*pMetricHandleCount)] array of handle of metrics. + ///< if count is less than the number of metrics available, then driver + ///< shall only retrieve that number of metric handles. + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnCreateFromProgrammableExp2 = ze_lib::context->zetDdiTable.load()->Metric.pfnCreateFromProgrammableExp2; + if( nullptr == pfnCreateFromProgrammableExp2 ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnCreateFromProgrammableExp2( hMetricProgrammable, parameterCount, pParameterValues, pName, pDescription, pMetricHandleCount, phMetricHandles ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Create metric handles by applying parameter values on the metric +/// programmable handle. +/// +/// @details +/// - This API is deprecated. Please use +/// ::zetMetricCreateFromProgrammableExp2() +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hMetricProgrammable` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pParameterValues` +/// + `nullptr == pName` +/// + `nullptr == pDescription` +/// + `nullptr == pMetricHandleCount` +ze_result_t ZE_APICALL zetMetricCreateFromProgrammableExp( zet_metric_programmable_exp_handle_t hMetricProgrammable, ///< [in] handle of the metric programmable zet_metric_programmable_param_value_exp_t* pParameterValues,///< [in] list of parameter values to be set. @@ -2140,12 +2668,74 @@ zetMetricCreateFromProgrammableExp( return pfnCreateFromProgrammableExp( hMetricProgrammable, pParameterValues, parameterCount, pName, pDescription, pMetricHandleCount, phMetricHandles ); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Create multiple metric group handles from metric handles. +/// +/// @details +/// - Creates multiple metric groups from metrics which were created using +/// ::zetMetricCreateFromProgrammableExp2(). +/// - Metrics whose Hardware resources do not overlap are added to same +/// metric group. +/// - The metric groups created using this API are managed by the +/// application and cannot be retrieved using ::zetMetricGroupGet(). +/// - The created metric groups are ready for activation and collection. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hDevice` +/// + `nullptr == phMetrics` +/// - ::ZE_RESULT_ERROR_INVALID_ARGUMENT +/// + metricGroupCount is lesser than the number of metric group handles that could be created. +ze_result_t ZE_APICALL +zetDeviceCreateMetricGroupsFromMetricsExp( + zet_device_handle_t hDevice, ///< [in] handle of the device. + uint32_t metricCount, ///< [in] number of metric handles. + zet_metric_handle_t * phMetrics, ///< [in] metric handles to be added to the metric groups. + const char * pMetricGroupNamePrefix, ///< [in] prefix to the name created for the metric groups. Must point to a + ///< null-terminated character array no longer than + ///< ZEX_MAX_METRIC_GROUP_NAME_PREFIX. + const char * pDescription, ///< [in] pointer to description of the metric groups. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_GROUP_DESCRIPTION. + uint32_t * pMetricGroupCount, ///< [in,out] pointer to the number of metric group handles to be created. + ///< if pMetricGroupCount is zero, then the driver shall update the value + ///< with the maximum possible number of metric group handles that could be created. + ///< if pMetricGroupCount is greater than the number of metric group + ///< handles that could be created, then the driver shall update the value + ///< with the correct number of metric group handles generated. + ///< if pMetricGroupCount is lesser than the number of metric group handles + ///< that could be created, then ::ZE_RESULT_ERROR_INVALID_ARGUMENT is returned. + zet_metric_group_handle_t* phMetricGroup ///< [in,out][optional][range(0, *pMetricGroupCount)] array of handle of + ///< metric group handles. + ///< Created Metric group handles. + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnCreateMetricGroupsFromMetricsExp = ze_lib::context->zetDdiTable.load()->DeviceExp.pfnCreateMetricGroupsFromMetricsExp; + if( nullptr == pfnCreateMetricGroupsFromMetricsExp ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnCreateMetricGroupsFromMetricsExp( hDevice, metricCount, phMetrics, pMetricGroupNamePrefix, pDescription, pMetricGroupCount, phMetricGroup ); +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Create metric group handle. /// /// @details -/// - Metrics from ::zetMetricCreateFromProgrammableExp() could be added to -/// the created metric group. +/// - This API is deprecated. Please use +/// ::zetCreateMetricGroupsFromMetricsExp() /// /// @returns /// - ::ZE_RESULT_SUCCESS @@ -2160,7 +2750,7 @@ zetMetricCreateFromProgrammableExp( /// + `nullptr == pDescription` /// + `nullptr == phMetricGroup` /// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION -/// + `0x3 < samplingType` +/// + `0x7 < samplingType` ze_result_t ZE_APICALL zetMetricGroupCreateExp( zet_device_handle_t hDevice, ///< [in] handle of the device @@ -2340,11 +2930,11 @@ zetMetricGroupCloseExp( /// @brief Destroy a metric group created using ::zetMetricGroupCreateExp. /// /// @details -/// - Metric handles created using ::zetMetricCreateFromProgrammableExp and +/// - Metric handles created using ::zetMetricCreateFromProgrammableExp2 and /// are part of the metricGroup are not destroyed. /// - It is necessary to call ::zetMetricDestroyExp for each of the metric -/// handles (created from ::zetMetricCreateFromProgrammableExp) to destroy -/// them. +/// handles (created from ::zetMetricCreateFromProgrammableExp2) to +/// destroy them. /// /// @returns /// - ::ZE_RESULT_SUCCESS @@ -2379,7 +2969,7 @@ zetMetricGroupDestroyExp( } /////////////////////////////////////////////////////////////////////////////// -/// @brief Destroy a metric created using ::zetMetricCreateFromProgrammableExp. +/// @brief Destroy a metric created using ::zetMetricCreateFromProgrammableExp2. /// /// @details /// - If a metric is added to a metric group, the metric has to be removed diff --git a/source/lib/zet_libddi.cpp b/source/lib/zet_libddi.cpp index e6c26331..dbd1f597 100644 --- a/source/lib/zet_libddi.cpp +++ b/source/lib/zet_libddi.cpp @@ -21,6 +21,13 @@ namespace ze_lib { ze_result_t result = ZE_RESULT_SUCCESS; + if( ZE_RESULT_SUCCESS == result ) + { + auto getTable = reinterpret_cast( + GET_FUNCTION_PTR(loader, "zetGetMetricDecoderExpProcAddrTable") ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricDecoderExp ); + } + if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( @@ -28,6 +35,13 @@ namespace ze_lib result = getTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricProgrammableExp ); } + if( ZE_RESULT_SUCCESS == result ) + { + auto getTable = reinterpret_cast( + GET_FUNCTION_PTR(loader, "zetGetMetricTracerExpProcAddrTable") ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricTracerExp ); + } + if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( @@ -35,6 +49,13 @@ namespace ze_lib result = getTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.Device ); } + if( ZE_RESULT_SUCCESS == result ) + { + auto getTable = reinterpret_cast( + GET_FUNCTION_PTR(loader, "zetGetDeviceExpProcAddrTable") ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.DeviceExp ); + } + if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( @@ -133,16 +154,31 @@ namespace ze_lib { ze_result_t result = ZE_RESULT_SUCCESS; + if( ZE_RESULT_SUCCESS == result ) + { + result = zetGetMetricDecoderExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricDecoderExp ); + } + if( ZE_RESULT_SUCCESS == result ) { result = zetGetMetricProgrammableExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricProgrammableExp ); } + if( ZE_RESULT_SUCCESS == result ) + { + result = zetGetMetricTracerExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricTracerExp ); + } + if( ZE_RESULT_SUCCESS == result ) { result = zetGetDeviceProcAddrTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.Device ); } + if( ZE_RESULT_SUCCESS == result ) + { + result = zetGetDeviceExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.DeviceExp ); + } + if( ZE_RESULT_SUCCESS == result ) { result = zetGetContextProcAddrTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.Context ); diff --git a/source/loader/ze_ldrddi.cpp b/source/loader/ze_ldrddi.cpp index 6576951f..e2e0b83d 100644 --- a/source/loader/ze_ldrddi.cpp +++ b/source/loader/ze_ldrddi.cpp @@ -82,6 +82,86 @@ namespace loader result = drv.dditable.ze.Driver.pfnGet( &library_driver_handle_count, &phDrivers[ total_driver_handle_count ] ); if( ZE_RESULT_SUCCESS != result ) break; + drv.driverInuse = true; + + try + { + for( uint32_t i = 0; i < library_driver_handle_count; ++i ) { + uint32_t driver_index = total_driver_handle_count + i; + phDrivers[ driver_index ] = reinterpret_cast( + context->ze_driver_factory.getInstance( phDrivers[ driver_index ], &drv.dditable ) ); + } + } + catch( std::bad_alloc& ) + { + result = ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + } + + total_driver_handle_count += library_driver_handle_count; + } + + // If the last driver get failed, but at least one driver succeeded, then return success with total count. + if( ZE_RESULT_SUCCESS == result || total_driver_handle_count > 0) + *pCount = total_driver_handle_count; + if (total_driver_handle_count > 0) { + result = ZE_RESULT_SUCCESS; + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeInitDrivers + __zedlllocal ze_result_t ZE_APICALL + zeInitDrivers( + uint32_t* pCount, ///< [in,out] pointer to the number of driver instances. + ///< if count is zero, then the loader shall update the value with the + ///< total number of drivers available. + ///< if count is greater than the number of drivers available, then the + ///< loader shall update the value with the correct number of drivers available. + ze_driver_handle_t* phDrivers, ///< [in,out][optional][range(0, *pCount)] array of driver instance handles. + ///< if count is less than the number of drivers available, then the loader + ///< shall only retrieve that number of drivers. + ze_init_driver_type_desc_t* desc ///< [in] descriptor containing the driver type initialization details + ///< including ::ze_init_driver_type_flag_t combinations. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + uint32_t total_driver_handle_count = 0; + + for( auto& drv : loader::context->zeDrivers ) + { + if (!drv.dditable.ze.Global.pfnInitDrivers) { + drv.initStatus = ZE_RESULT_ERROR_UNINITIALIZED; + continue; + } + + if( ( 0 < *pCount ) && ( *pCount == total_driver_handle_count)) + break; + + uint32_t library_driver_handle_count = 0; + + result = drv.dditable.ze.Global.pfnInitDrivers( &library_driver_handle_count, nullptr, desc ); + if( ZE_RESULT_SUCCESS != result ) { + // If Get Drivers fails with Uninitialized, then update the driver init status to prevent reporting this driver in the next get call. + if (ZE_RESULT_ERROR_UNINITIALIZED == result) { + drv.initStatus = result; + } + continue; + } + + if( nullptr != phDrivers && *pCount !=0) + { + if( total_driver_handle_count + library_driver_handle_count > *pCount) { + library_driver_handle_count = *pCount - total_driver_handle_count; + } + result = drv.dditable.ze.Global.pfnInitDrivers( &library_driver_handle_count, &phDrivers[ total_driver_handle_count ], desc ); + if( ZE_RESULT_SUCCESS != result ) break; + + drv.driverInuse = true; + try { for( uint32_t i = 0; i < library_driver_handle_count; ++i ) { @@ -743,9 +823,9 @@ namespace loader zeDeviceGetGlobalTimestamps( ze_device_handle_t hDevice, ///< [in] handle of the device uint64_t* hostTimestamp, ///< [out] value of the Host's global timestamp that correlates with the - ///< Device's global timestamp value + ///< Device's global timestamp value. uint64_t* deviceTimestamp ///< [out] value of the Device's global timestamp that correlates with the - ///< Host's global timestamp value + ///< Host's global timestamp value. ) { ze_result_t result = ZE_RESULT_SUCCESS; @@ -4560,7 +4640,8 @@ namespace loader __zedlllocal ze_result_t ZE_APICALL zePhysicalMemCreate( ze_context_handle_t hContext, ///< [in] handle of the context object - ze_device_handle_t hDevice, ///< [in] handle of the device object + ze_device_handle_t hDevice, ///< [in] handle of the device object, can be `nullptr` if creating + ///< physical host memory. ze_physical_mem_desc_t* desc, ///< [in] pointer to physical memory descriptor. ze_physical_mem_handle_t* phPhysicalMemory ///< [out] pointer to handle of physical memory object created ) @@ -4778,6 +4859,191 @@ namespace loader return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListGetNextCommandIdExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListGetNextCommandIdExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_command_id_exp_desc_t* desc, ///< [in] pointer to mutable command identifier descriptor + uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hCommandList )->dditable; + auto pfnGetNextCommandIdExp = dditable->ze.CommandListExp.pfnGetNextCommandIdExp; + if( nullptr == pfnGetNextCommandIdExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hCommandList = reinterpret_cast( hCommandList )->handle; + + // forward to device-driver + result = pfnGetNextCommandIdExp( hCommandList, desc, pCommandId ); + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListGetNextCommandIdWithKernelsExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListGetNextCommandIdWithKernelsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_command_id_exp_desc_t* desc, ///< [in][out] pointer to mutable command identifier descriptor + uint32_t numKernels, ///< [in][optional] number of entries on phKernels list + ze_kernel_handle_t* phKernels, ///< [in][optional][range(0, numKernels)] list of kernels that user can + ///< switch between using ::zeCommandListUpdateMutableCommandKernelsExp + ///< call + uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hCommandList )->dditable; + auto pfnGetNextCommandIdWithKernelsExp = dditable->ze.CommandListExp.pfnGetNextCommandIdWithKernelsExp; + if( nullptr == pfnGetNextCommandIdWithKernelsExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hCommandList = reinterpret_cast( hCommandList )->handle; + + // convert loader handles to driver handles + auto phKernelsLocal = new ze_kernel_handle_t [numKernels]; + for( size_t i = 0; ( nullptr != phKernels ) && ( i < numKernels ); ++i ) + phKernelsLocal[ i ] = reinterpret_cast( phKernels[ i ] )->handle; + + // forward to device-driver + result = pfnGetNextCommandIdWithKernelsExp( hCommandList, desc, numKernels, phKernelsLocal, pCommandId ); + delete []phKernelsLocal; + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListUpdateMutableCommandsExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + const ze_mutable_commands_exp_desc_t* desc ///< [in] pointer to mutable commands descriptor; multiple descriptors may + ///< be chained via `pNext` member + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hCommandList )->dditable; + auto pfnUpdateMutableCommandsExp = dditable->ze.CommandListExp.pfnUpdateMutableCommandsExp; + if( nullptr == pfnUpdateMutableCommandsExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hCommandList = reinterpret_cast( hCommandList )->handle; + + // forward to device-driver + result = pfnUpdateMutableCommandsExp( hCommandList, desc ); + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListUpdateMutableCommandSignalEventExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandSignalEventExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint64_t commandId, ///< [in] command identifier + ze_event_handle_t hSignalEvent ///< [in][optional] handle of the event to signal on completion + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hCommandList )->dditable; + auto pfnUpdateMutableCommandSignalEventExp = dditable->ze.CommandListExp.pfnUpdateMutableCommandSignalEventExp; + if( nullptr == pfnUpdateMutableCommandSignalEventExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hCommandList = reinterpret_cast( hCommandList )->handle; + + // convert loader handle to driver handle + hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; + + // forward to device-driver + result = pfnUpdateMutableCommandSignalEventExp( hCommandList, commandId, hSignalEvent ); + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListUpdateMutableCommandWaitEventsExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandWaitEventsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint64_t commandId, ///< [in] command identifier + uint32_t numWaitEvents, ///< [in][optional] the number of wait events + ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait + ///< on before launching + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hCommandList )->dditable; + auto pfnUpdateMutableCommandWaitEventsExp = dditable->ze.CommandListExp.pfnUpdateMutableCommandWaitEventsExp; + if( nullptr == pfnUpdateMutableCommandWaitEventsExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hCommandList = reinterpret_cast( hCommandList )->handle; + + // convert loader handles to driver handles + auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; + for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) + phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; + + // forward to device-driver + result = pfnUpdateMutableCommandWaitEventsExp( hCommandList, commandId, numWaitEvents, phWaitEventsLocal ); + delete []phWaitEventsLocal; + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListUpdateMutableCommandKernelsExp + __zedlllocal ze_result_t ZE_APICALL + zeCommandListUpdateMutableCommandKernelsExp( + ze_command_list_handle_t hCommandList, ///< [in] handle of the command list + uint32_t numKernels, ///< [in] the number of kernels to update + uint64_t* pCommandId, ///< [in][range(0, numKernels)] command identifier + ze_kernel_handle_t* phKernels ///< [in][range(0, numKernels)] handle of the kernel for a command + ///< identifier to switch to + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hCommandList )->dditable; + auto pfnUpdateMutableCommandKernelsExp = dditable->ze.CommandListExp.pfnUpdateMutableCommandKernelsExp; + if( nullptr == pfnUpdateMutableCommandKernelsExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hCommandList = reinterpret_cast( hCommandList )->handle; + + // convert loader handles to driver handles + auto phKernelsLocal = new ze_kernel_handle_t [numKernels]; + for( size_t i = 0; ( nullptr != phKernels ) && ( i < numKernels ); ++i ) + phKernelsLocal[ i ] = reinterpret_cast( phKernels[ i ] )->handle; + + // forward to device-driver + result = pfnUpdateMutableCommandKernelsExp( hCommandList, numKernels, pCommandId, phKernelsLocal ); + delete []phKernelsLocal; + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeDeviceReserveCacheExt __zedlllocal ze_result_t ZE_APICALL @@ -6039,121 +6305,6 @@ namespace loader return result; } - /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zeCommandListGetNextCommandIdExp - __zedlllocal ze_result_t ZE_APICALL - zeCommandListGetNextCommandIdExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - const ze_mutable_command_id_exp_desc_t* desc, ///< [in] pointer to mutable command identifier descriptor - uint64_t* pCommandId ///< [out] pointer to mutable command identifier to be written - ) - { - ze_result_t result = ZE_RESULT_SUCCESS; - - // extract driver's function pointer table - auto dditable = reinterpret_cast( hCommandList )->dditable; - auto pfnGetNextCommandIdExp = dditable->ze.CommandListExp.pfnGetNextCommandIdExp; - if( nullptr == pfnGetNextCommandIdExp ) - return ZE_RESULT_ERROR_UNINITIALIZED; - - // convert loader handle to driver handle - hCommandList = reinterpret_cast( hCommandList )->handle; - - // forward to device-driver - result = pfnGetNextCommandIdExp( hCommandList, desc, pCommandId ); - - return result; - } - - /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zeCommandListUpdateMutableCommandsExp - __zedlllocal ze_result_t ZE_APICALL - zeCommandListUpdateMutableCommandsExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - const ze_mutable_commands_exp_desc_t* desc ///< [in] pointer to mutable commands descriptor; multiple descriptors may - ///< be chained via `pNext` member - ) - { - ze_result_t result = ZE_RESULT_SUCCESS; - - // extract driver's function pointer table - auto dditable = reinterpret_cast( hCommandList )->dditable; - auto pfnUpdateMutableCommandsExp = dditable->ze.CommandListExp.pfnUpdateMutableCommandsExp; - if( nullptr == pfnUpdateMutableCommandsExp ) - return ZE_RESULT_ERROR_UNINITIALIZED; - - // convert loader handle to driver handle - hCommandList = reinterpret_cast( hCommandList )->handle; - - // forward to device-driver - result = pfnUpdateMutableCommandsExp( hCommandList, desc ); - - return result; - } - - /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zeCommandListUpdateMutableCommandSignalEventExp - __zedlllocal ze_result_t ZE_APICALL - zeCommandListUpdateMutableCommandSignalEventExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - uint64_t commandId, ///< [in] command identifier - ze_event_handle_t hSignalEvent ///< [in][optional] handle of the event to signal on completion - ) - { - ze_result_t result = ZE_RESULT_SUCCESS; - - // extract driver's function pointer table - auto dditable = reinterpret_cast( hCommandList )->dditable; - auto pfnUpdateMutableCommandSignalEventExp = dditable->ze.CommandListExp.pfnUpdateMutableCommandSignalEventExp; - if( nullptr == pfnUpdateMutableCommandSignalEventExp ) - return ZE_RESULT_ERROR_UNINITIALIZED; - - // convert loader handle to driver handle - hCommandList = reinterpret_cast( hCommandList )->handle; - - // convert loader handle to driver handle - hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; - - // forward to device-driver - result = pfnUpdateMutableCommandSignalEventExp( hCommandList, commandId, hSignalEvent ); - - return result; - } - - /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zeCommandListUpdateMutableCommandWaitEventsExp - __zedlllocal ze_result_t ZE_APICALL - zeCommandListUpdateMutableCommandWaitEventsExp( - ze_command_list_handle_t hCommandList, ///< [in] handle of the command list - uint64_t commandId, ///< [in] command identifier - uint32_t numWaitEvents, ///< [in][optional] the number of wait events - ze_event_handle_t* phWaitEvents ///< [in][optional][range(0, numWaitEvents)] handle of the events to wait - ///< on before launching - ) - { - ze_result_t result = ZE_RESULT_SUCCESS; - - // extract driver's function pointer table - auto dditable = reinterpret_cast( hCommandList )->dditable; - auto pfnUpdateMutableCommandWaitEventsExp = dditable->ze.CommandListExp.pfnUpdateMutableCommandWaitEventsExp; - if( nullptr == pfnUpdateMutableCommandWaitEventsExp ) - return ZE_RESULT_ERROR_UNINITIALIZED; - - // convert loader handle to driver handle - hCommandList = reinterpret_cast( hCommandList )->handle; - - // convert loader handles to driver handles - auto phWaitEventsLocal = new ze_event_handle_t [numWaitEvents]; - for( size_t i = 0; ( nullptr != phWaitEvents ) && ( i < numWaitEvents ); ++i ) - phWaitEventsLocal[ i ] = reinterpret_cast( phWaitEvents[ i ] )->handle; - - // forward to device-driver - result = pfnUpdateMutableCommandWaitEventsExp( hCommandList, commandId, numWaitEvents, phWaitEventsLocal ); - delete []phWaitEventsLocal; - - return result; - } - } // namespace loader #if defined(__cplusplus) @@ -6202,6 +6353,9 @@ zeGetGlobalProcAddrTable( atLeastOneDriverValid = true; else drv.initStatus = getTableResult; + if (drv.dditable.ze.Global.pfnInitDrivers) { + loader::context->initDriversSupport = true; + } } if(!atLeastOneDriverValid) @@ -6215,6 +6369,7 @@ zeGetGlobalProcAddrTable( { // return pointers to loader's DDIs pDdiTable->pfnInit = loader::zeInit; + pDdiTable->pfnInitDrivers = loader::zeInitDrivers; } else { @@ -7165,12 +7320,14 @@ zeGetCommandListExpProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs - pDdiTable->pfnCreateCloneExp = loader::zeCommandListCreateCloneExp; - pDdiTable->pfnImmediateAppendCommandListsExp = loader::zeCommandListImmediateAppendCommandListsExp; - pDdiTable->pfnGetNextCommandIdExp = loader::zeCommandListGetNextCommandIdExp; + pDdiTable->pfnGetNextCommandIdWithKernelsExp = loader::zeCommandListGetNextCommandIdWithKernelsExp; pDdiTable->pfnUpdateMutableCommandsExp = loader::zeCommandListUpdateMutableCommandsExp; pDdiTable->pfnUpdateMutableCommandSignalEventExp = loader::zeCommandListUpdateMutableCommandSignalEventExp; + pDdiTable->pfnUpdateMutableCommandKernelsExp = loader::zeCommandListUpdateMutableCommandKernelsExp; + pDdiTable->pfnCreateCloneExp = loader::zeCommandListCreateCloneExp; + pDdiTable->pfnGetNextCommandIdExp = loader::zeCommandListGetNextCommandIdExp; pDdiTable->pfnUpdateMutableCommandWaitEventsExp = loader::zeCommandListUpdateMutableCommandWaitEventsExp; + pDdiTable->pfnImmediateAppendCommandListsExp = loader::zeCommandListImmediateAppendCommandListsExp; } else { diff --git a/source/loader/ze_loader.cpp b/source/loader/ze_loader.cpp index 1d52642d..62d28a30 100644 --- a/source/loader/ze_loader.cpp +++ b/source/loader/ze_loader.cpp @@ -124,14 +124,34 @@ namespace loader } } - ze_result_t context_t::check_drivers(ze_init_flags_t flags, ze_global_dditable_t *globalInitStored, zes_global_dditable_t *sysmanGlobalInitStored, bool *requireDdiReinit, bool sysmanOnly) { + std::string to_string(const ze_init_driver_type_desc_t *desc) { + std::string flags_value; + if (desc->flags & ZE_INIT_DRIVER_TYPE_FLAG_GPU) { + flags_value+= "|ZE_INIT_DRIVER_TYPE_FLAG_GPU|"; + } + if (desc->flags & ZE_INIT_DRIVER_TYPE_FLAG_NPU) { + flags_value+= "|ZE_INIT_DRIVER_TYPE_FLAG_NPU|"; + } + return flags_value; + } + + ze_result_t context_t::check_drivers(ze_init_flags_t flags, ze_init_driver_type_desc_t* desc, ze_global_dditable_t *globalInitStored, zes_global_dditable_t *sysmanGlobalInitStored, bool *requireDdiReinit, bool sysmanOnly) { if (debugTraceEnabled) { - std::string message = "check_drivers(" + std::string("flags=") + loader::to_string(flags) + ")"; - debug_trace_message(message, ""); + if (desc) { + std::string message = "check_drivers(" + std::string("desc->flags=") + loader::to_string(desc) + ")"; + debug_trace_message(message, ""); + } else { + std::string message = "check_drivers(" + std::string("flags=") + loader::to_string(flags) + ")"; + debug_trace_message(message, ""); + } } bool return_first_driver_result=false; std::string initName = "zeInit"; driver_vector_t *drivers = &zeDrivers; + // If desc is set, then this is zeInitDrivers. + if (desc) { + initName = "zeInitDrivers"; + } // If this is sysmanOnly check_drivers, then zesInit is being called and we need to use zesDrivers. if (sysmanOnly) { drivers = &zesDrivers; @@ -144,22 +164,29 @@ namespace loader for(auto it = drivers->begin(); it != drivers->end(); ) { std::string freeLibraryErrorValue; - ze_result_t result = init_driver(*it, flags, globalInitStored, sysmanGlobalInitStored, sysmanOnly); + ze_result_t result = init_driver(*it, flags, desc, globalInitStored, sysmanGlobalInitStored, sysmanOnly); if(result != ZE_RESULT_SUCCESS) { - if (debugTraceEnabled) { - std::string errorMessage = "Check Drivers Failed on " + it->name + " , driver will be removed. " + initName + " failed with "; - debug_trace_message(errorMessage, loader::to_string(result)); - } - it = drivers->erase(it); - // If the number of drivers is now ==1, then we need to reinit the ddi tables to pass through. - // If ZE_ENABLE_LOADER_INTERCEPT is set to 1, then even if drivers were removed, don't reinit the ddi tables. - if (drivers->size() == 1 && !loader::context->forceIntercept) { - *requireDdiReinit = true; + // If the driver has already been init and handles are to be read, then this driver cannot be removed from the list. + // Also, if any driver supports zeInitDrivers, then no driver can be removed to allow for different sets of drivers. + if (!it->driverInuse && !loader::context->initDriversSupport) { + if (debugTraceEnabled) { + std::string errorMessage = "Check Drivers Failed on " + it->name + " , driver will be removed. " + initName + " failed with "; + debug_trace_message(errorMessage, loader::to_string(result)); + } + it = drivers->erase(it); + // If the number of drivers is now ==1, then we need to reinit the ddi tables to pass through. + // If ZE_ENABLE_LOADER_INTERCEPT is set to 1, then even if drivers were removed, don't reinit the ddi tables. + if (drivers->size() == 1 && !loader::context->forceIntercept) { + *requireDdiReinit = true; + } + } else { + it++; } if(return_first_driver_result) return result; - } - else { + } else { + // If this is a single driver system, then the first success for this driver needs to be set. + it->driverInuse = true; it++; } } @@ -170,7 +197,7 @@ namespace loader return ZE_RESULT_SUCCESS; } - ze_result_t context_t::init_driver(driver_t &driver, ze_init_flags_t flags, ze_global_dditable_t *globalInitStored, zes_global_dditable_t *sysmanGlobalInitStored, bool sysmanOnly) { + ze_result_t context_t::init_driver(driver_t &driver, ze_init_flags_t flags, ze_init_driver_type_desc_t* desc, ze_global_dditable_t *globalInitStored, zes_global_dditable_t *sysmanGlobalInitStored, bool sysmanOnly) { if (sysmanOnly) { auto getTable = reinterpret_cast( @@ -233,34 +260,66 @@ namespace loader return ZE_RESULT_ERROR_UNINITIALIZED; } - if(nullptr == global.pfnInit) { - if (debugTraceEnabled) { - std::string errorMessage = "init driver " + driver.name + " failed, zeInit function pointer null. Returning "; - debug_trace_message(errorMessage, loader::to_string(ZE_RESULT_ERROR_UNINITIALIZED)); + if (!desc) { + if(nullptr == global.pfnInit) { + if (debugTraceEnabled) { + std::string errorMessage = "init driver " + driver.name + " failed, zeInit function pointer null. Returning "; + debug_trace_message(errorMessage, loader::to_string(ZE_RESULT_ERROR_UNINITIALIZED)); + } + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnInit = global.pfnInit; + if(nullptr == pfnInit || globalInitStored->pfnInit == nullptr) { + if (debugTraceEnabled) { + std::string errorMessage = "init driver " + driver.name + " failed, zeInit function pointer null. Returning "; + debug_trace_message(errorMessage, loader::to_string(ZE_RESULT_ERROR_UNINITIALIZED)); + } + return ZE_RESULT_ERROR_UNINITIALIZED; } - return ZE_RESULT_ERROR_UNINITIALIZED; - } - auto pfnInit = global.pfnInit; - if(nullptr == pfnInit || globalInitStored->pfnInit == nullptr) { + // Use the previously init ddi table pointer to zeInit to allow for intercept of the zeInit calls + ze_result_t res = globalInitStored->pfnInit(flags); + // Verify that this driver successfully init in the call above. + if (driver.initStatus != ZE_RESULT_SUCCESS) { + res = driver.initStatus; + } if (debugTraceEnabled) { - std::string errorMessage = "init driver " + driver.name + " failed, zeInit function pointer null. Returning "; - debug_trace_message(errorMessage, loader::to_string(ZE_RESULT_ERROR_UNINITIALIZED)); + std::string message = "init driver " + driver.name + " zeInit(" + loader::to_string(flags) + ") returning "; + debug_trace_message(message, loader::to_string(res)); + } + return res; + } else { + if(nullptr == global.pfnInitDrivers) { + if (debugTraceEnabled) { + std::string errorMessage = "init driver " + driver.name + " failed, zeInitDrivers function pointer null. Returning "; + debug_trace_message(errorMessage, loader::to_string(ZE_RESULT_ERROR_UNINITIALIZED)); + } + return ZE_RESULT_ERROR_UNINITIALIZED; } - return ZE_RESULT_ERROR_UNINITIALIZED; - } - // Use the previously init ddi table pointer to zeInit to allow for intercept of the zeInit calls - ze_result_t res = globalInitStored->pfnInit(flags); - // Verify that this driver successfully init in the call above. - if (driver.initStatus != ZE_RESULT_SUCCESS) { - res = driver.initStatus; - } - if (debugTraceEnabled) { - std::string message = "init driver " + driver.name + " zeInit(" + loader::to_string(flags) + ") returning "; - debug_trace_message(message, loader::to_string(res)); + auto pfnInitDrivers = global.pfnInitDrivers; + if(nullptr == pfnInitDrivers || globalInitStored->pfnInitDrivers == nullptr) { + if (debugTraceEnabled) { + std::string errorMessage = "init driver " + driver.name + " failed, pfnInitDrivers function pointer null. Returning "; + debug_trace_message(errorMessage, loader::to_string(ZE_RESULT_ERROR_UNINITIALIZED)); + } + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + // Use the previously init ddi table pointer to zeInit to allow for intercept of the zeInit calls + uint32_t pCount = 0; + ze_result_t res = globalInitStored->pfnInitDrivers(&pCount, nullptr, desc); + // Verify that this driver successfully init in the call above. + if (driver.initDriversStatus != ZE_RESULT_SUCCESS) { + res = driver.initDriversStatus; + } + if (debugTraceEnabled) { + std::string message = "init driver " + driver.name + " zeInitDrivers(" + loader::to_string(desc) + ") returning "; + debug_trace_message(message, loader::to_string(res)); + } + return res; } - return res; } } diff --git a/source/loader/ze_loader_api.cpp b/source/loader/ze_loader_api.cpp index d86d92ca..a94daa9c 100644 --- a/source/loader/ze_loader_api.cpp +++ b/source/loader/ze_loader_api.cpp @@ -33,9 +33,9 @@ zeLoaderInit() /// - ::ZE_RESULT_SUCCESS /// - ::ZE_RESULT_ERROR_UNINITIALIZED ZE_DLLEXPORT ze_result_t ZE_APICALL -zelLoaderDriverCheck(ze_init_flags_t flags, ze_global_dditable_t *globalInitStored, zes_global_dditable_t *sysmanGlobalInitStored, bool *requireDdiReinit, bool sysmanOnly) +zelLoaderDriverCheck(ze_init_flags_t flags, ze_init_driver_type_desc_t* desc, ze_global_dditable_t *globalInitStored, zes_global_dditable_t *sysmanGlobalInitStored, bool *requireDdiReinit, bool sysmanOnly) { - return loader::context->check_drivers(flags, globalInitStored, sysmanGlobalInitStored, requireDdiReinit, sysmanOnly); + return loader::context->check_drivers(flags, desc, globalInitStored, sysmanGlobalInitStored, requireDdiReinit, sysmanOnly); } /////////////////////////////////////////////////////////////////////////////// diff --git a/source/loader/ze_loader_api.h b/source/loader/ze_loader_api.h index 590f1432..4459602f 100644 --- a/source/loader/ze_loader_api.h +++ b/source/loader/ze_loader_api.h @@ -33,7 +33,7 @@ zeLoaderInit(); /// - ::ZE_RESULT_SUCCESS /// - ::ZE_RESULT_ERROR_UNINITIALIZED ZE_DLLEXPORT ze_result_t ZE_APICALL -zelLoaderDriverCheck(ze_init_flags_t flags, ze_global_dditable_t *globalInitStored, zes_global_dditable_t *sysmanGlobalInitStored, bool *requireDdiReinit, bool sysmanOnly); +zelLoaderDriverCheck(ze_init_flags_t flags, ze_init_driver_type_desc_t* desc, ze_global_dditable_t *globalInitStored, zes_global_dditable_t *sysmanGlobalInitStored, bool *requireDdiReinit, bool sysmanOnly); /////////////////////////////////////////////////////////////////////////////// diff --git a/source/loader/ze_loader_internal.h b/source/loader/ze_loader_internal.h index b5b0679d..087adef9 100644 --- a/source/loader/ze_loader_internal.h +++ b/source/loader/ze_loader_internal.h @@ -31,8 +31,10 @@ namespace loader { HMODULE handle = NULL; ze_result_t initStatus = ZE_RESULT_SUCCESS; + ze_result_t initDriversStatus = ZE_RESULT_SUCCESS; dditable_t dditable = {}; std::string name; + bool driverInuse = false; }; using driver_vector_t = std::vector< driver_t >; @@ -95,6 +97,8 @@ namespace loader zet_tracer_exp_factory_t zet_tracer_exp_factory; zet_debug_session_factory_t zet_debug_session_factory; zet_metric_programmable_exp_factory_t zet_metric_programmable_exp_factory; + zet_metric_tracer_exp_factory_t zet_metric_tracer_exp_factory; + zet_metric_decoder_exp_factory_t zet_metric_decoder_exp_factory; /////////////////////////////////////////////////////////////////////////////// std::mutex image_handle_map_lock; std::mutex sampler_handle_map_lock; @@ -112,13 +116,14 @@ namespace loader bool driverEnvironmentQueried = false; bool forceIntercept = false; + bool initDriversSupport = false; std::vector compVersions; const char *LOADER_COMP_NAME = "loader"; - ze_result_t check_drivers(ze_init_flags_t flags, ze_global_dditable_t *globalInitStored, zes_global_dditable_t *sysmanGlobalInitStored, bool *requireDdiReinit, bool sysmanOnly); + ze_result_t check_drivers(ze_init_flags_t flags, ze_init_driver_type_desc_t* desc, ze_global_dditable_t *globalInitStored, zes_global_dditable_t *sysmanGlobalInitStored, bool *requireDdiReinit, bool sysmanOnly); void debug_trace_message(std::string errorMessage, std::string errorValue); ze_result_t init(); - ze_result_t init_driver(driver_t &driver, ze_init_flags_t flags, ze_global_dditable_t *globalInitStored, zes_global_dditable_t *sysmanGlobalInitStored, bool sysmanOnly); + ze_result_t init_driver(driver_t &driver, ze_init_flags_t flags, ze_init_driver_type_desc_t* desc, ze_global_dditable_t *globalInitStored, zes_global_dditable_t *sysmanGlobalInitStored, bool sysmanOnly); void add_loader_version(); ~context_t(); bool intercept_enabled = false; diff --git a/source/loader/zes_ldrddi.cpp b/source/loader/zes_ldrddi.cpp index 0a9d1cda..4ae26bef 100644 --- a/source/loader/zes_ldrddi.cpp +++ b/source/loader/zes_ldrddi.cpp @@ -83,6 +83,8 @@ namespace loader result = drv.dditable.zes.Driver.pfnGet( &library_driver_handle_count, &phDrivers[ total_driver_handle_count ] ); if( ZE_RESULT_SUCCESS != result ) break; + drv.driverInuse = true; + try { for( uint32_t i = 0; i < library_driver_handle_count; ++i ) { @@ -4392,6 +4394,151 @@ namespace loader return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesDeviceEnumEnabledVFExp + __zedlllocal ze_result_t ZE_APICALL + zesDeviceEnumEnabledVFExp( + zes_device_handle_t hDevice, ///< [in] Sysman handle of the device. + uint32_t* pCount, ///< [in,out] pointer to the number of components of this type. + ///< if count is zero, then the driver shall update the value with the + ///< total number of components of this type that are available. + ///< if count is greater than the number of components of this type that + ///< are available, then the driver shall update the value with the correct + ///< number of components. + zes_vf_handle_t* phVFhandle ///< [in,out][optional][range(0, *pCount)] array of handle of components of + ///< this type. + ///< if count is less than the number of components of this type that are + ///< available, then the driver shall only retrieve that number of + ///< component handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hDevice )->dditable; + auto pfnEnumEnabledVFExp = dditable->zes.DeviceExp.pfnEnumEnabledVFExp; + if( nullptr == pfnEnumEnabledVFExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hDevice = reinterpret_cast( hDevice )->handle; + + // forward to device-driver + result = pfnEnumEnabledVFExp( hDevice, pCount, phVFhandle ); + + if( ZE_RESULT_SUCCESS != result ) + return result; + + try + { + // convert driver handles to loader handles + for( size_t i = 0; ( nullptr != phVFhandle ) && ( i < *pCount ); ++i ) + phVFhandle[ i ] = reinterpret_cast( + context->zes_vf_factory.getInstance( phVFhandle[ i ], dditable ) ); + } + catch( std::bad_alloc& ) + { + result = ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesVFManagementGetVFCapabilitiesExp + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFCapabilitiesExp( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. + zes_vf_exp_capabilities_t* pCapability ///< [in,out] Will contain VF capability. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hVFhandle )->dditable; + auto pfnGetVFCapabilitiesExp = dditable->zes.VFManagementExp.pfnGetVFCapabilitiesExp; + if( nullptr == pfnGetVFCapabilitiesExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hVFhandle = reinterpret_cast( hVFhandle )->handle; + + // forward to device-driver + result = pfnGetVFCapabilitiesExp( hVFhandle, pCapability ); + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesVFManagementGetVFMemoryUtilizationExp2 + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFMemoryUtilizationExp2( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF memory stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of memory stats available. + ///< - if count is greater than the total number of memory stats + ///< available, the driver shall update the value with the correct number + ///< of memory stats available. + zes_vf_util_mem_exp2_t* pMemUtil ///< [in,out][optional][range(0, *pCount)] array of memory group activity counters. + ///< - if count is less than the total number of memory stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector pCount-1 number of VF + ///< memory stats. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hVFhandle )->dditable; + auto pfnGetVFMemoryUtilizationExp2 = dditable->zes.VFManagement.pfnGetVFMemoryUtilizationExp2; + if( nullptr == pfnGetVFMemoryUtilizationExp2 ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hVFhandle = reinterpret_cast( hVFhandle )->handle; + + // forward to device-driver + result = pfnGetVFMemoryUtilizationExp2( hVFhandle, pCount, pMemUtil ); + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesVFManagementGetVFEngineUtilizationExp2 + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFEngineUtilizationExp2( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. + uint32_t* pCount, ///< [in,out] Pointer to the number of VF engine stats descriptors. + ///< - if count is zero, the driver shall update the value with the total + ///< number of engine stats available. + ///< - if count is greater than the total number of engine stats + ///< available, the driver shall update the value with the correct number + ///< of engine stats available. + zes_vf_util_engine_exp2_t* pEngineUtil ///< [in,out][optional][range(0, *pCount)] array of engine group activity counters. + ///< - if count is less than the total number of engine stats available, + ///< then driver shall only retrieve that number of stats. + ///< - the implementation shall populate the vector pCount-1 number of VF + ///< engine stats. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hVFhandle )->dditable; + auto pfnGetVFEngineUtilizationExp2 = dditable->zes.VFManagement.pfnGetVFEngineUtilizationExp2; + if( nullptr == pfnGetVFEngineUtilizationExp2 ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hVFhandle = reinterpret_cast( hVFhandle )->handle; + + // forward to device-driver + result = pfnGetVFEngineUtilizationExp2( hVFhandle, pCount, pEngineUtil ); + + return result; + } + } // namespace loader #if defined(__cplusplus) @@ -4635,6 +4782,7 @@ zesGetDeviceExpProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + pDdiTable->pfnEnumEnabledVFExp = loader::zesDeviceEnumEnabledVFExp; pDdiTable->pfnGetSubDevicePropertiesExp = loader::zesDeviceGetSubDevicePropertiesExp; pDdiTable->pfnEnumActiveVFExp = loader::zesDeviceEnumActiveVFExp; } @@ -6234,6 +6382,83 @@ zesGetTemperatureProcAddrTable( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's VFManagement table +/// with current process' addresses +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION +ZE_DLLEXPORT ze_result_t ZE_APICALL +zesGetVFManagementProcAddrTable( + ze_api_version_t version, ///< [in] API version requested + zes_vf_management_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers + ) +{ + if( loader::context->sysmanInstanceDrivers->size() < 1 ) + + return ZE_RESULT_ERROR_UNINITIALIZED; + + if( nullptr == pDdiTable ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( loader::context->version < version ) + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + + ze_result_t result = ZE_RESULT_SUCCESS; + + bool atLeastOneDriverValid = false; + // Load the device-driver DDI tables + for( auto& drv : *loader::context->sysmanInstanceDrivers ) + { + if(drv.initStatus != ZE_RESULT_SUCCESS) + continue; + auto getTable = reinterpret_cast( + GET_FUNCTION_PTR( drv.handle, "zesGetVFManagementProcAddrTable") ); + if(!getTable) + continue; + auto getTableResult = getTable( version, &drv.dditable.zes.VFManagement); + if(getTableResult == ZE_RESULT_SUCCESS) + atLeastOneDriverValid = true; + else + drv.initStatus = getTableResult; + } + + if(!atLeastOneDriverValid) + result = ZE_RESULT_ERROR_UNINITIALIZED; + else + result = ZE_RESULT_SUCCESS; + + if( ZE_RESULT_SUCCESS == result ) + { + if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) + { + // return pointers to loader's DDIs + pDdiTable->pfnGetVFMemoryUtilizationExp2 = loader::zesVFManagementGetVFMemoryUtilizationExp2; + pDdiTable->pfnGetVFEngineUtilizationExp2 = loader::zesVFManagementGetVFEngineUtilizationExp2; + } + else + { + // return pointers directly to driver's DDIs + *pDdiTable = loader::context->sysmanInstanceDrivers->front().dditable.zes.VFManagement; + } + } + + // If the validation layer is enabled, then intercept the loader's DDIs + if(( ZE_RESULT_SUCCESS == result ) && ( nullptr != loader::context->validationLayer )) + { + auto getTable = reinterpret_cast( + GET_FUNCTION_PTR(loader::context->validationLayer, "zesGetVFManagementProcAddrTable") ); + if(!getTable) + return ZE_RESULT_ERROR_UNINITIALIZED; + result = getTable( version, pDdiTable ); + } + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's VFManagementExp table /// with current process' addresses @@ -6279,6 +6504,7 @@ zesGetVFManagementExpProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + pDdiTable->pfnGetVFCapabilitiesExp = loader::zesVFManagementGetVFCapabilitiesExp; pDdiTable->pfnGetVFPropertiesExp = loader::zesVFManagementGetVFPropertiesExp; pDdiTable->pfnGetVFMemoryUtilizationExp = loader::zesVFManagementGetVFMemoryUtilizationExp; pDdiTable->pfnGetVFEngineUtilizationExp = loader::zesVFManagementGetVFEngineUtilizationExp; diff --git a/source/loader/zet_ldrddi.cpp b/source/loader/zet_ldrddi.cpp index b506d45d..8f3973a5 100644 --- a/source/loader/zet_ldrddi.cpp +++ b/source/loader/zet_ldrddi.cpp @@ -1265,6 +1265,395 @@ namespace loader return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDeviceGetConcurrentMetricGroupsExp + __zedlllocal ze_result_t ZE_APICALL + zetDeviceGetConcurrentMetricGroupsExp( + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t metricGroupCount, ///< [in] metric group count + zet_metric_group_handle_t * phMetricGroups, ///< [in,out] metrics groups to be re-arranged to be sets of concurrent + ///< groups + uint32_t * pMetricGroupsCountPerConcurrentGroup,///< [in,out][optional][*pConcurrentGroupCount] count of metric groups per + ///< concurrent group. + uint32_t * pConcurrentGroupCount ///< [out] number of concurrent groups. + ///< The value of this parameter could be used to determine the number of + ///< replays necessary. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hDevice )->dditable; + auto pfnGetConcurrentMetricGroupsExp = dditable->zet.DeviceExp.pfnGetConcurrentMetricGroupsExp; + if( nullptr == pfnGetConcurrentMetricGroupsExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hDevice = reinterpret_cast( hDevice )->handle; + + // forward to device-driver + result = pfnGetConcurrentMetricGroupsExp( hDevice, metricGroupCount, phMetricGroups, pMetricGroupsCountPerConcurrentGroup, pConcurrentGroupCount ); + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerCreateExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerCreateExp( + zet_context_handle_t hContext, ///< [in] handle of the context object + zet_device_handle_t hDevice, ///< [in] handle of the device + uint32_t metricGroupCount, ///< [in] metric group count + zet_metric_group_handle_t* phMetricGroups, ///< [in][range(0, metricGroupCount )] handles of the metric groups to + ///< trace + zet_metric_tracer_exp_desc_t* desc, ///< [in,out] metric tracer descriptor + ze_event_handle_t hNotificationEvent, ///< [in][optional] event used for report availability notification. Note: + ///< If buffer is not drained when the event it flagged, there is a risk of + ///< HW event buffer being overrun + zet_metric_tracer_exp_handle_t* phMetricTracer ///< [out] handle of the metric tracer + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hContext )->dditable; + auto pfnCreateExp = dditable->zet.MetricTracerExp.pfnCreateExp; + if( nullptr == pfnCreateExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hContext = reinterpret_cast( hContext )->handle; + + // convert loader handle to driver handle + hDevice = reinterpret_cast( hDevice )->handle; + + // convert loader handles to driver handles + auto phMetricGroupsLocal = new zet_metric_group_handle_t [metricGroupCount ]; + for( size_t i = 0; ( nullptr != phMetricGroups ) && ( i < metricGroupCount ); ++i ) + phMetricGroupsLocal[ i ] = reinterpret_cast( phMetricGroups[ i ] )->handle; + + // convert loader handle to driver handle + hNotificationEvent = ( hNotificationEvent ) ? reinterpret_cast( hNotificationEvent )->handle : nullptr; + + // forward to device-driver + result = pfnCreateExp( hContext, hDevice, metricGroupCount, phMetricGroupsLocal, desc, hNotificationEvent, phMetricTracer ); + delete []phMetricGroupsLocal; + + if( ZE_RESULT_SUCCESS != result ) + return result; + + try + { + // convert driver handle to loader handle + *phMetricTracer = reinterpret_cast( + context->zet_metric_tracer_exp_factory.getInstance( *phMetricTracer, dditable ) ); + } + catch( std::bad_alloc& ) + { + result = ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerDestroyExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerDestroyExp( + zet_metric_tracer_exp_handle_t hMetricTracer ///< [in] handle of the metric tracer + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hMetricTracer )->dditable; + auto pfnDestroyExp = dditable->zet.MetricTracerExp.pfnDestroyExp; + if( nullptr == pfnDestroyExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hMetricTracer = reinterpret_cast( hMetricTracer )->handle; + + // forward to device-driver + result = pfnDestroyExp( hMetricTracer ); + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerEnableExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerEnableExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + ze_bool_t synchronous ///< [in] request synchronous behavior. Confirmation of successful + ///< asynchronous operation is done by calling ::zetMetricTracerReadDataExp() + ///< and checking the return status: ::ZE_RESULT_NOT_READY will be returned + ///< when the tracer is inactive. ::ZE_RESULT_SUCCESS will be returned + ///< when the tracer is active. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hMetricTracer )->dditable; + auto pfnEnableExp = dditable->zet.MetricTracerExp.pfnEnableExp; + if( nullptr == pfnEnableExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hMetricTracer = reinterpret_cast( hMetricTracer )->handle; + + // forward to device-driver + result = pfnEnableExp( hMetricTracer, synchronous ); + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerDisableExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerDisableExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + ze_bool_t synchronous ///< [in] request synchronous behavior. Confirmation of successful + ///< asynchronous operation is done by calling ::zetMetricTracerReadDataExp() + ///< and checking the return status: ::ZE_RESULT_SUCCESS will be returned + ///< when the tracer is active or when it is inactive but still has data. + ///< ::ZE_RESULT_NOT_READY will be returned when the tracer is inactive and + ///< has no more data to be retrieved. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hMetricTracer )->dditable; + auto pfnDisableExp = dditable->zet.MetricTracerExp.pfnDisableExp; + if( nullptr == pfnDisableExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hMetricTracer = reinterpret_cast( hMetricTracer )->handle; + + // forward to device-driver + result = pfnDisableExp( hMetricTracer, synchronous ); + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerReadDataExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerReadDataExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + size_t* pRawDataSize, ///< [in,out] pointer to size in bytes of raw data requested to read. + ///< if size is zero, then the driver will update the value with the total + ///< size in bytes needed for all data available. + ///< if size is non-zero, then driver will only retrieve that amount of + ///< data. + ///< if size is larger than size needed for all data, then driver will + ///< update the value with the actual size needed. + uint8_t* pRawData ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing tracer + ///< data in raw format + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hMetricTracer )->dditable; + auto pfnReadDataExp = dditable->zet.MetricTracerExp.pfnReadDataExp; + if( nullptr == pfnReadDataExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hMetricTracer = reinterpret_cast( hMetricTracer )->handle; + + // forward to device-driver + result = pfnReadDataExp( hMetricTracer, pRawDataSize, pRawData ); + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricDecoderCreateExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricDecoderCreateExp( + zet_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer + zet_metric_decoder_exp_handle_t* phMetricDecoder///< [out] handle of the metric decoder object + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hMetricTracer )->dditable; + auto pfnCreateExp = dditable->zet.MetricDecoderExp.pfnCreateExp; + if( nullptr == pfnCreateExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hMetricTracer = reinterpret_cast( hMetricTracer )->handle; + + // forward to device-driver + result = pfnCreateExp( hMetricTracer, phMetricDecoder ); + + if( ZE_RESULT_SUCCESS != result ) + return result; + + try + { + // convert driver handle to loader handle + *phMetricDecoder = reinterpret_cast( + context->zet_metric_decoder_exp_factory.getInstance( *phMetricDecoder, dditable ) ); + } + catch( std::bad_alloc& ) + { + result = ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricDecoderDestroyExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricDecoderDestroyExp( + zet_metric_decoder_exp_handle_t phMetricDecoder ///< [in] handle of the metric decoder object + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( phMetricDecoder )->dditable; + auto pfnDestroyExp = dditable->zet.MetricDecoderExp.pfnDestroyExp; + if( nullptr == pfnDestroyExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + phMetricDecoder = reinterpret_cast( phMetricDecoder )->handle; + + // forward to device-driver + result = pfnDestroyExp( phMetricDecoder ); + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricDecoderGetDecodableMetricsExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricDecoderGetDecodableMetricsExp( + zet_metric_decoder_exp_handle_t hMetricDecoder, ///< [in] handle of the metric decoder object + uint32_t* pCount, ///< [in,out] pointer to number of decodable metric in the hMetricDecoder + ///< handle. If count is zero, then the driver shall + ///< update the value with the total number of decodable metrics available + ///< in the decoder. if count is greater than zero + ///< but less than the total number of decodable metrics available in the + ///< decoder, then only that number will be returned. + ///< if count is greater than the number of decodable metrics available in + ///< the decoder, then the driver shall update the + ///< value with the actual number of decodable metrics available. + zet_metric_handle_t* phMetrics ///< [in,out] [range(0, *pCount)] array of handles of decodable metrics in + ///< the hMetricDecoder handle provided. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hMetricDecoder )->dditable; + auto pfnGetDecodableMetricsExp = dditable->zet.MetricDecoderExp.pfnGetDecodableMetricsExp; + if( nullptr == pfnGetDecodableMetricsExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hMetricDecoder = reinterpret_cast( hMetricDecoder )->handle; + + // forward to device-driver + result = pfnGetDecodableMetricsExp( hMetricDecoder, pCount, phMetrics ); + + if( ZE_RESULT_SUCCESS != result ) + return result; + + try + { + // convert driver handles to loader handles + for( size_t i = 0; ( nullptr != phMetrics ) && ( i < *pCount ); ++i ) + phMetrics[ i ] = reinterpret_cast( + context->zet_metric_factory.getInstance( phMetrics[ i ], dditable ) ); + } + catch( std::bad_alloc& ) + { + result = ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricTracerDecodeExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricTracerDecodeExp( + zet_metric_decoder_exp_handle_t phMetricDecoder,///< [in] handle of the metric decoder object + size_t* pRawDataSize, ///< [in,out] size in bytes of raw data buffer. If pMetricEntriesCount is + ///< greater than zero but less than total number of + ///< decodable metrics available in the raw data buffer, then driver shall + ///< update this value with actual number of raw + ///< data bytes processed. + uint8_t* pRawData, ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing tracer + ///< data in raw format + uint32_t metricsCount, ///< [in] number of decodable metrics in the tracer for which the + ///< hMetricDecoder handle was provided. See + ///< ::zetMetricDecoderGetDecodableMetricsExp(). If metricCount is greater + ///< than zero but less than the number decodable + ///< metrics available in the raw data buffer, then driver shall only + ///< decode those. + zet_metric_handle_t* phMetrics, ///< [in] [range(0, metricsCount)] array of handles of decodable metrics in + ///< the decoder for which the hMetricDecoder handle was + ///< provided. Metrics handles are expected to be for decodable metrics, + ///< see ::zetMetricDecoderGetDecodableMetrics() + uint32_t* pSetCount, ///< [in,out] pointer to number of metric sets. If count is zero, then the + ///< driver shall update the value with the total + ///< number of metric sets to be decoded. If count is greater than the + ///< number available in the raw data buffer, then the + ///< driver shall update the value with the actual number of metric sets to + ///< be decoded. There is a 1:1 relation between + ///< the number of sets and sub-devices returned in the decoded entries. + uint32_t* pMetricEntriesCountPerSet, ///< [in,out][optional][range(0, *pSetCount)] buffer of metric entries + ///< counts per metric set, one value per set. + uint32_t* pMetricEntriesCount, ///< [in,out] pointer to the total number of metric entries decoded, for + ///< all metric sets. If count is zero, then the + ///< driver shall update the value with the total number of metric entries + ///< to be decoded. If count is greater than zero + ///< but less than the total number of metric entries available in the raw + ///< data, then user provided number will be decoded. + ///< If count is greater than the number available in the raw data buffer, + ///< then the driver shall update the value with + ///< the actual number of decodable metric entries decoded. If set to null, + ///< then driver will only update the value of + ///< pSetCount. + zet_metric_entry_exp_t* pMetricEntries ///< [in,out][optional][range(0, *pMetricEntriesCount)] buffer containing + ///< decoded metric entries + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( phMetricDecoder )->dditable; + auto pfnDecodeExp = dditable->zet.MetricTracerExp.pfnDecodeExp; + if( nullptr == pfnDecodeExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + phMetricDecoder = reinterpret_cast( phMetricDecoder )->handle; + + // convert loader handles to driver handles + auto phMetricsLocal = new zet_metric_handle_t [metricsCount]; + for( size_t i = 0; ( nullptr != phMetrics ) && ( i < metricsCount ); ++i ) + phMetricsLocal[ i ] = reinterpret_cast( phMetrics[ i ] )->handle; + + // forward to device-driver + result = pfnDecodeExp( phMetricDecoder, pRawDataSize, pRawData, metricsCount, phMetricsLocal, pSetCount, pMetricEntriesCountPerSet, pMetricEntriesCount, pMetricEntries ); + delete []phMetricsLocal; + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zetMetricGroupCalculateMultipleMetricValuesExp __zedlllocal ze_result_t ZE_APICALL @@ -1555,6 +1944,61 @@ namespace loader return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricCreateFromProgrammableExp2 + __zedlllocal ze_result_t ZE_APICALL + zetMetricCreateFromProgrammableExp2( + zet_metric_programmable_exp_handle_t hMetricProgrammable, ///< [in] handle of the metric programmable + uint32_t parameterCount, ///< [in] Count of parameters to set. + zet_metric_programmable_param_value_exp_t* pParameterValues,///< [in] list of parameter values to be set. + const char* pName, ///< [in] pointer to metric name to be used. Must point to a + ///< null-terminated character array no longer than ::ZET_MAX_METRIC_NAME. + const char* pDescription, ///< [in] pointer to metric description to be used. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_DESCRIPTION. + uint32_t* pMetricHandleCount, ///< [in,out] Pointer to the number of metric handles. + ///< if count is zero, then the driver shall update the value with the + ///< number of metric handles available for this programmable. + ///< if count is greater than the number of metric handles available, then + ///< the driver shall update the value with the correct number of metric + ///< handles available. + zet_metric_handle_t* phMetricHandles ///< [in,out][optional][range(0,*pMetricHandleCount)] array of handle of metrics. + ///< if count is less than the number of metrics available, then driver + ///< shall only retrieve that number of metric handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hMetricProgrammable )->dditable; + auto pfnCreateFromProgrammableExp2 = dditable->zet.Metric.pfnCreateFromProgrammableExp2; + if( nullptr == pfnCreateFromProgrammableExp2 ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hMetricProgrammable = reinterpret_cast( hMetricProgrammable )->handle; + + // forward to device-driver + result = pfnCreateFromProgrammableExp2( hMetricProgrammable, parameterCount, pParameterValues, pName, pDescription, pMetricHandleCount, phMetricHandles ); + + if( ZE_RESULT_SUCCESS != result ) + return result; + + try + { + // convert driver handles to loader handles + for( size_t i = 0; ( nullptr != phMetricHandles ) && ( i < *pMetricHandleCount ); ++i ) + phMetricHandles[ i ] = reinterpret_cast( + context->zet_metric_factory.getInstance( phMetricHandles[ i ], dditable ) ); + } + catch( std::bad_alloc& ) + { + result = ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zetMetricCreateFromProgrammableExp __zedlllocal ze_result_t ZE_APICALL @@ -1610,6 +2054,64 @@ namespace loader return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetDeviceCreateMetricGroupsFromMetricsExp + __zedlllocal ze_result_t ZE_APICALL + zetDeviceCreateMetricGroupsFromMetricsExp( + zet_device_handle_t hDevice, ///< [in] handle of the device. + uint32_t metricCount, ///< [in] number of metric handles. + zet_metric_handle_t * phMetrics, ///< [in] metric handles to be added to the metric groups. + const char * pMetricGroupNamePrefix, ///< [in] prefix to the name created for the metric groups. Must point to a + ///< null-terminated character array no longer than + ///< ZEX_MAX_METRIC_GROUP_NAME_PREFIX. + const char * pDescription, ///< [in] pointer to description of the metric groups. Must point to a + ///< null-terminated character array no longer than + ///< ::ZET_MAX_METRIC_GROUP_DESCRIPTION. + uint32_t * pMetricGroupCount, ///< [in,out] pointer to the number of metric group handles to be created. + ///< if pMetricGroupCount is zero, then the driver shall update the value + ///< with the maximum possible number of metric group handles that could be created. + ///< if pMetricGroupCount is greater than the number of metric group + ///< handles that could be created, then the driver shall update the value + ///< with the correct number of metric group handles generated. + ///< if pMetricGroupCount is lesser than the number of metric group handles + ///< that could be created, then ::ZE_RESULT_ERROR_INVALID_ARGUMENT is returned. + zet_metric_group_handle_t* phMetricGroup ///< [in,out][optional][range(0, *pMetricGroupCount)] array of handle of + ///< metric group handles. + ///< Created Metric group handles. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hDevice )->dditable; + auto pfnCreateMetricGroupsFromMetricsExp = dditable->zet.DeviceExp.pfnCreateMetricGroupsFromMetricsExp; + if( nullptr == pfnCreateMetricGroupsFromMetricsExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hDevice = reinterpret_cast( hDevice )->handle; + + // forward to device-driver + result = pfnCreateMetricGroupsFromMetricsExp( hDevice, metricCount, phMetrics, pMetricGroupNamePrefix, pDescription, pMetricGroupCount, phMetricGroup ); + + if( ZE_RESULT_SUCCESS != result ) + return result; + + try + { + // convert driver handles to loader handles + for( size_t i = 0; ( nullptr != phMetricGroup ) && ( i < *pMetricGroupCount ); ++i ) + phMetricGroup[ i ] = reinterpret_cast( + context->zet_metric_group_factory.getInstance( phMetricGroup[ i ], dditable ) ); + } + catch( std::bad_alloc& ) + { + result = ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zetMetricGroupCreateExp __zedlllocal ze_result_t ZE_APICALL @@ -1796,6 +2298,75 @@ namespace loader extern "C" { #endif +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's MetricDecoderExp table +/// with current process' addresses +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION +ZE_DLLEXPORT ze_result_t ZE_APICALL +zetGetMetricDecoderExpProcAddrTable( + ze_api_version_t version, ///< [in] API version requested + zet_metric_decoder_exp_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers + ) +{ + if( loader::context->zeDrivers.size() < 1 ) + + return ZE_RESULT_ERROR_UNINITIALIZED; + + if( nullptr == pDdiTable ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( loader::context->version < version ) + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + + ze_result_t result = ZE_RESULT_SUCCESS; + + // Load the device-driver DDI tables + for( auto& drv : loader::context->zeDrivers ) + { + if(drv.initStatus != ZE_RESULT_SUCCESS) + continue; + auto getTable = reinterpret_cast( + GET_FUNCTION_PTR( drv.handle, "zetGetMetricDecoderExpProcAddrTable") ); + if(!getTable) + continue; + result = getTable( version, &drv.dditable.zet.MetricDecoderExp); + } + + + if( ZE_RESULT_SUCCESS == result ) + { + if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) + { + // return pointers to loader's DDIs + pDdiTable->pfnCreateExp = loader::zetMetricDecoderCreateExp; + pDdiTable->pfnDestroyExp = loader::zetMetricDecoderDestroyExp; + pDdiTable->pfnGetDecodableMetricsExp = loader::zetMetricDecoderGetDecodableMetricsExp; + } + else + { + // return pointers directly to driver's DDIs + *pDdiTable = loader::context->zeDrivers.front().dditable.zet.MetricDecoderExp; + } + } + + // If the validation layer is enabled, then intercept the loader's DDIs + if(( ZE_RESULT_SUCCESS == result ) && ( nullptr != loader::context->validationLayer )) + { + auto getTable = reinterpret_cast( + GET_FUNCTION_PTR(loader::context->validationLayer, "zetGetMetricDecoderExpProcAddrTable") ); + if(!getTable) + return ZE_RESULT_ERROR_UNINITIALIZED; + result = getTable( version, pDdiTable ); + } + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's MetricProgrammableExp table /// with current process' addresses @@ -1866,6 +2437,78 @@ zetGetMetricProgrammableExpProcAddrTable( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's MetricTracerExp table +/// with current process' addresses +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION +ZE_DLLEXPORT ze_result_t ZE_APICALL +zetGetMetricTracerExpProcAddrTable( + ze_api_version_t version, ///< [in] API version requested + zet_metric_tracer_exp_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers + ) +{ + if( loader::context->zeDrivers.size() < 1 ) + + return ZE_RESULT_ERROR_UNINITIALIZED; + + if( nullptr == pDdiTable ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( loader::context->version < version ) + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + + ze_result_t result = ZE_RESULT_SUCCESS; + + // Load the device-driver DDI tables + for( auto& drv : loader::context->zeDrivers ) + { + if(drv.initStatus != ZE_RESULT_SUCCESS) + continue; + auto getTable = reinterpret_cast( + GET_FUNCTION_PTR( drv.handle, "zetGetMetricTracerExpProcAddrTable") ); + if(!getTable) + continue; + result = getTable( version, &drv.dditable.zet.MetricTracerExp); + } + + + if( ZE_RESULT_SUCCESS == result ) + { + if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) + { + // return pointers to loader's DDIs + pDdiTable->pfnCreateExp = loader::zetMetricTracerCreateExp; + pDdiTable->pfnDestroyExp = loader::zetMetricTracerDestroyExp; + pDdiTable->pfnEnableExp = loader::zetMetricTracerEnableExp; + pDdiTable->pfnDisableExp = loader::zetMetricTracerDisableExp; + pDdiTable->pfnReadDataExp = loader::zetMetricTracerReadDataExp; + pDdiTable->pfnDecodeExp = loader::zetMetricTracerDecodeExp; + } + else + { + // return pointers directly to driver's DDIs + *pDdiTable = loader::context->zeDrivers.front().dditable.zet.MetricTracerExp; + } + } + + // If the validation layer is enabled, then intercept the loader's DDIs + if(( ZE_RESULT_SUCCESS == result ) && ( nullptr != loader::context->validationLayer )) + { + auto getTable = reinterpret_cast( + GET_FUNCTION_PTR(loader::context->validationLayer, "zetGetMetricTracerExpProcAddrTable") ); + if(!getTable) + return ZE_RESULT_ERROR_UNINITIALIZED; + result = getTable( version, pDdiTable ); + } + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's Device table /// with current process' addresses @@ -1942,6 +2585,74 @@ zetGetDeviceProcAddrTable( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's DeviceExp table +/// with current process' addresses +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION +ZE_DLLEXPORT ze_result_t ZE_APICALL +zetGetDeviceExpProcAddrTable( + ze_api_version_t version, ///< [in] API version requested + zet_device_exp_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers + ) +{ + if( loader::context->zeDrivers.size() < 1 ) + + return ZE_RESULT_ERROR_UNINITIALIZED; + + if( nullptr == pDdiTable ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( loader::context->version < version ) + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + + ze_result_t result = ZE_RESULT_SUCCESS; + + // Load the device-driver DDI tables + for( auto& drv : loader::context->zeDrivers ) + { + if(drv.initStatus != ZE_RESULT_SUCCESS) + continue; + auto getTable = reinterpret_cast( + GET_FUNCTION_PTR( drv.handle, "zetGetDeviceExpProcAddrTable") ); + if(!getTable) + continue; + result = getTable( version, &drv.dditable.zet.DeviceExp); + } + + + if( ZE_RESULT_SUCCESS == result ) + { + if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) + { + // return pointers to loader's DDIs + pDdiTable->pfnGetConcurrentMetricGroupsExp = loader::zetDeviceGetConcurrentMetricGroupsExp; + pDdiTable->pfnCreateMetricGroupsFromMetricsExp = loader::zetDeviceCreateMetricGroupsFromMetricsExp; + } + else + { + // return pointers directly to driver's DDIs + *pDdiTable = loader::context->zeDrivers.front().dditable.zet.DeviceExp; + } + } + + // If the validation layer is enabled, then intercept the loader's DDIs + if(( ZE_RESULT_SUCCESS == result ) && ( nullptr != loader::context->validationLayer )) + { + auto getTable = reinterpret_cast( + GET_FUNCTION_PTR(loader::context->validationLayer, "zetGetDeviceExpProcAddrTable") ); + if(!getTable) + return ZE_RESULT_ERROR_UNINITIALIZED; + result = getTable( version, pDdiTable ); + } + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's Context table /// with current process' addresses @@ -2392,6 +3103,7 @@ zetGetMetricProcAddrTable( // return pointers to loader's DDIs pDdiTable->pfnGet = loader::zetMetricGet; pDdiTable->pfnGetProperties = loader::zetMetricGetProperties; + pDdiTable->pfnCreateFromProgrammableExp2 = loader::zetMetricCreateFromProgrammableExp2; } else { @@ -2604,11 +3316,11 @@ zetGetMetricGroupExpProcAddrTable( if( ( loader::context->zeDrivers.size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs + pDdiTable->pfnCreateExp = loader::zetMetricGroupCreateExp; pDdiTable->pfnCalculateMultipleMetricValuesExp = loader::zetMetricGroupCalculateMultipleMetricValuesExp; pDdiTable->pfnGetGlobalTimestampsExp = loader::zetMetricGroupGetGlobalTimestampsExp; pDdiTable->pfnGetExportDataExp = loader::zetMetricGroupGetExportDataExp; pDdiTable->pfnCalculateMetricExportDataExp = loader::zetMetricGroupCalculateMetricExportDataExp; - pDdiTable->pfnCreateExp = loader::zetMetricGroupCreateExp; pDdiTable->pfnAddMetricExp = loader::zetMetricGroupAddMetricExp; pDdiTable->pfnRemoveMetricExp = loader::zetMetricGroupRemoveMetricExp; pDdiTable->pfnCloseExp = loader::zetMetricGroupCloseExp; diff --git a/source/loader/zet_ldrddi.h b/source/loader/zet_ldrddi.h index b6e2dd46..548dfbc9 100644 --- a/source/loader/zet_ldrddi.h +++ b/source/loader/zet_ldrddi.h @@ -51,6 +51,12 @@ namespace loader using zet_debug_session_object_t = object_t < zet_debug_session_handle_t >; using zet_debug_session_factory_t = singleton_factory_t < zet_debug_session_object_t, zet_debug_session_handle_t >; + using zet_metric_tracer_exp_object_t = object_t < zet_metric_tracer_exp_handle_t >; + using zet_metric_tracer_exp_factory_t = singleton_factory_t < zet_metric_tracer_exp_object_t, zet_metric_tracer_exp_handle_t >; + + using zet_metric_decoder_exp_object_t = object_t < zet_metric_decoder_exp_handle_t >; + using zet_metric_decoder_exp_factory_t = singleton_factory_t < zet_metric_decoder_exp_object_t, zet_metric_decoder_exp_handle_t >; + using zet_metric_programmable_exp_object_t = object_t < zet_metric_programmable_exp_handle_t >; using zet_metric_programmable_exp_factory_t = singleton_factory_t < zet_metric_programmable_exp_object_t, zet_metric_programmable_exp_handle_t >; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5b1f0e27..6dca3648 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -18,5 +18,23 @@ if(MSVC) target_compile_options(tests PRIVATE "/MD$<$:d>") endif() -add_test(NAME tests COMMAND tests) -set_property(TEST tests PROPERTY ENVIRONMENT "ZE_ENABLE_NULL_DRIVER=1") \ No newline at end of file +add_test(NAME tests_api COMMAND tests --gtest_filter=-*LoaderInit*) +set_property(TEST tests_api PROPERTY ENVIRONMENT "ZE_ENABLE_NULL_DRIVER=1") +add_test(NAME tests_init_gpu_all COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWhenCallingZeInitDriversWithGPUTypeThenExpectPassWithGPUorAllOnly*) +set_property(TEST tests_init_gpu_all PROPERTY ENVIRONMENT "ZE_ENABLE_NULL_DRIVER=1") +add_test(NAME tests_init_npu_all COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWhenCallingZeInitDriversWithNPUTypeThenExpectPassWithNPUorAllOnly*) +set_property(TEST tests_init_npu_all PROPERTY ENVIRONMENT "ZE_ENABLE_NULL_DRIVER=1") +add_test(NAME tests_any COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWhenCallingZeInitDriversWithAnyTypeWithNullDriverAcceptingAllThenExpectatLeast1Driver*) +set_property(TEST tests_any PROPERTY ENVIRONMENT "ZE_ENABLE_NULL_DRIVER=1") +add_test(NAME tests_both_init_all COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWhenCallingZeInitDriversThenzeInitThenBothCallsSucceedWithAllTypes*) +set_property(TEST tests_both_init_all PROPERTY ENVIRONMENT "ZE_ENABLE_NULL_DRIVER=1") +add_test(NAME tests_both_init_gpu COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWhenCallingZeInitDriversThenzeInitThenBothCallsSucceedWithGPUTypes*) +set_property(TEST tests_both_init_gpu PROPERTY ENVIRONMENT "ZE_ENABLE_NULL_DRIVER=1") +add_test(NAME tests_both_init_npu COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWhenCallingZeInitDriversThenzeInitThenBothCallsSucceedWithNPUTypes*) +set_property(TEST tests_both_init_npu PROPERTY ENVIRONMENT "ZE_ENABLE_NULL_DRIVER=1") +add_test(NAME tests_both_succeed COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWhenCallingzeInitThenZeInitDriversThenBothCallsSucceedWithAllTypes*) +set_property(TEST tests_both_succeed PROPERTY ENVIRONMENT "ZE_ENABLE_NULL_DRIVER=1") +add_test(NAME tests_both_gpu COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWhenCallingzeInitThenZeInitDriversThenBothCallsSucceedWithGPUTypes*) +set_property(TEST tests_both_gpu PROPERTY ENVIRONMENT "ZE_ENABLE_NULL_DRIVER=1") +add_test(NAME tests_both_npu COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWhenCallingzeInitThenZeInitDriversThenBothCallsSucceedWithNPUTypes*) +set_property(TEST tests_both_npu PROPERTY ENVIRONMENT "ZE_ENABLE_NULL_DRIVER=1") \ No newline at end of file diff --git a/test/loader_api.cpp b/test/loader_api.cpp index 4fdf8e19..3a499097 100644 --- a/test/loader_api.cpp +++ b/test/loader_api.cpp @@ -11,6 +11,12 @@ #include "loader/ze_loader.h" #include "ze_api.h" +#if defined(_WIN32) + #define putenv_safe _putenv +#else + #define putenv_safe putenv +#endif + namespace { TEST( @@ -42,4 +48,148 @@ TEST( } } +TEST( + LoaderInit, + GivenLevelZeroLoaderPresentWhenCallingZeInitDriversWithGPUTypeThenExpectPassWithGPUorAllOnly) { + + uint32_t pCount = 0; + ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; + desc.flags = ZE_INIT_DRIVER_TYPE_FLAG_GPU; + desc.pNext = nullptr; + putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_TYPE=GPU" ) ); + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc)); + EXPECT_GT(pCount, 0); + desc.flags = UINT32_MAX; + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc)); + EXPECT_GT(pCount, 0); + desc.flags = ZE_INIT_DRIVER_TYPE_FLAG_GPU | ZE_INIT_DRIVER_TYPE_FLAG_NPU; + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc)); + EXPECT_GT(pCount, 0); +} + +TEST( + LoaderInit, + GivenLevelZeroLoaderPresentWhenCallingZeInitDriversWithNPUTypeThenExpectPassWithNPUorAllOnly) { + + uint32_t pCount = 0; + ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; + desc.flags = ZE_INIT_DRIVER_TYPE_FLAG_NPU; + desc.pNext = nullptr; + putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_TYPE=NPU" ) ); + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc)); + EXPECT_GT(pCount, 0); + desc.flags = UINT32_MAX; + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc)); + EXPECT_GT(pCount, 0); + desc.flags = ZE_INIT_DRIVER_TYPE_FLAG_GPU | ZE_INIT_DRIVER_TYPE_FLAG_NPU; + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc)); + EXPECT_GT(pCount, 0); +} + +TEST( + LoaderInit, + GivenLevelZeroLoaderPresentWhenCallingZeInitDriversWithAnyTypeWithNullDriverAcceptingAllThenExpectatLeast1Driver) { + + uint32_t pCount = 0; + ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; + desc.flags = ZE_INIT_DRIVER_TYPE_FLAG_NPU; + desc.pNext = nullptr; + putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_TYPE=ALL" ) ); + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc)); + EXPECT_GT(pCount, 0); + desc.flags = UINT32_MAX; + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc)); + EXPECT_GT(pCount, 0); + desc.flags = ZE_INIT_DRIVER_TYPE_FLAG_GPU; + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc)); + EXPECT_GT(pCount, 0); + desc.flags = ZE_INIT_DRIVER_TYPE_FLAG_GPU | ZE_INIT_DRIVER_TYPE_FLAG_NPU; + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc)); + EXPECT_GT(pCount, 0); +} + +TEST( + LoaderInit, + GivenLevelZeroLoaderPresentWhenCallingZeInitDriversThenzeInitThenBothCallsSucceedWithAllTypes) { + + uint32_t pCount = 0; + ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; + desc.flags = UINT32_MAX; + desc.pNext = nullptr; + putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_TYPE=ALL" ) ); + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc)); + EXPECT_GT(pCount, 0); + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInit(0)); +} + +TEST( + LoaderInit, + GivenLevelZeroLoaderPresentWhenCallingZeInitDriversThenzeInitThenBothCallsSucceedWithGPUTypes) { + + uint32_t pCount = 0; + ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; + desc.flags = UINT32_MAX; + desc.pNext = nullptr; + putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_TYPE=GPU" ) ); + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc)); + EXPECT_GT(pCount, 0); + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInit(ZE_INIT_FLAG_GPU_ONLY)); +} + +TEST( + LoaderInit, + GivenLevelZeroLoaderPresentWhenCallingZeInitDriversThenzeInitThenBothCallsSucceedWithNPUTypes) { + + uint32_t pCount = 0; + ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; + desc.flags = UINT32_MAX; + desc.pNext = nullptr; + putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_TYPE=NPU" ) ); + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc)); + EXPECT_GT(pCount, 0); + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInit(ZE_INIT_FLAG_VPU_ONLY)); +} + +TEST( + LoaderInit, + GivenLevelZeroLoaderPresentWhenCallingzeInitThenZeInitDriversThenBothCallsSucceedWithAllTypes) { + + uint32_t pCount = 0; + ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; + desc.flags = UINT32_MAX; + desc.pNext = nullptr; + putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_TYPE=ALL" ) ); + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInit(0)); + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc)); + EXPECT_GT(pCount, 0); +} + +TEST( + LoaderInit, + GivenLevelZeroLoaderPresentWhenCallingzeInitThenZeInitDriversThenBothCallsSucceedWithGPUTypes) { + + uint32_t pCount = 0; + ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; + desc.flags = UINT32_MAX; + desc.pNext = nullptr; + putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_TYPE=GPU" ) ); + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInit(ZE_INIT_FLAG_GPU_ONLY)); + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc)); + EXPECT_GT(pCount, 0); +} + +TEST( + LoaderInit, + GivenLevelZeroLoaderPresentWhenCallingzeInitThenZeInitDriversThenBothCallsSucceedWithNPUTypes) { + + uint32_t pCount = 0; + ze_init_driver_type_desc_t desc = {ZE_STRUCTURE_TYPE_INIT_DRIVER_TYPE_DESC}; + desc.flags = UINT32_MAX; + desc.pNext = nullptr; + putenv_safe( const_cast( "ZEL_TEST_NULL_DRIVER_TYPE=NPU" ) ); + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInit(ZE_INIT_FLAG_VPU_ONLY)); + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc)); + EXPECT_GT(pCount, 0); +} + } // namespace