From a56a1f07c7dadcfc5d478d8aa4cbb473bccab791 Mon Sep 17 00:00:00 2001 From: "Neil R. Spruit" Date: Tue, 10 Sep 2024 15:10:29 -0700 Subject: [PATCH 1/9] Update with v1.10.0 spec Signed-off-by: Neil R. Spruit --- include/layers/zel_tracing_register_cb.h | 314 ++-- include/ze.py | 404 +++-- include/ze_api.h | 1491 ++++++++++------- include/ze_ddi.h | 78 +- include/zes.py | 101 +- include/zes_api.h | 133 +- include/zes_ddi.h | 34 +- include/zet.py | 287 +++- include/zet_api.h | 530 +++++- include/zet_ddi.h | 210 ++- source/drivers/null/ze_nullddi.cpp | 311 ++-- source/drivers/null/zes_nullddi.cpp | 86 +- source/drivers/null/zet_nullddi.cpp | 465 ++++- source/layers/tracing/ze_tracing_cb_structs.h | 9 +- .../layers/tracing/ze_tracing_register_cb.cpp | 176 +- source/layers/tracing/ze_trcddi.cpp | 466 ++++-- .../ze_parameter_validation.cpp | 216 ++- .../ze_parameter_validation.h | 11 +- .../zes_parameter_validation.cpp | 50 +- .../zes_parameter_validation.h | 6 +- .../zet_parameter_validation.cpp | 292 +++- .../zet_parameter_validation.h | 14 +- .../validation/common/ze_entry_points.h | 22 +- .../validation/common/zes_entry_points.h | 12 +- .../validation/common/zet_entry_points.h | 28 +- .../ze_handle_lifetime.cpp | 166 +- .../ze_handle_lifetime.h | 12 +- .../zes_handle_lifetime.cpp | 38 +- .../zes_handle_lifetime.h | 6 +- .../zet_handle_lifetime.cpp | 242 ++- .../zet_handle_lifetime.h | 14 +- source/layers/validation/ze_valddi.cpp | 505 ++++-- source/layers/validation/zes_valddi.cpp | 136 +- source/layers/validation/zet_valddi.cpp | 689 +++++++- source/lib/ze_libapi.cpp | 800 +++++---- source/lib/ze_tracing_register_cb_libapi.cpp | 275 +-- source/lib/zes_libapi.cpp | 110 +- source/lib/zet_libapi.cpp | 533 +++++- source/lib/zet_libddi.cpp | 36 + source/loader/ze_ldrddi.cpp | 343 ++-- source/loader/zes_ldrddi.cpp | 86 +- source/loader/zet_ldrddi.cpp | 644 ++++++- source/loader/zet_ldrddi.h | 6 + 43 files changed, 7428 insertions(+), 2959 deletions(-) diff --git a/include/layers/zel_tracing_register_cb.h b/include/layers/zel_tracing_register_cb.h index f54dbed..2b73c3c 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 3804d98..ca50bf3 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.10-r1.10.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 ## @@ -450,6 +490,10 @@ 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, 10 ) + ############################################################################### ## @brief Maximum driver universal unique id (UUID) size in bytes ZE_MAX_DRIVER_UUID_SIZE = 16 @@ -2018,6 +2062,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" @@ -3810,140 +4005,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 +4093,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 +4775,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 +4823,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 +5781,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 +5931,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 2f59f4b..1b81dac 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.10-r1.10.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 /// @@ -1043,6 +1153,12 @@ typedef enum _ze_api_version_t } 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, 10 ) +#endif // ZE_API_VERSION_CURRENT_M + /////////////////////////////////////////////////////////////////////////////// /// @brief Returns the API version supported by the specified driver /// @@ -7471,130 +7587,507 @@ 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 -/// - ::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 +/// @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 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 +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY /// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE /// + `nullptr == hDevice` ZE_APIEXPORT ze_result_t ZE_APICALL @@ -10372,249 +10865,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 +10878,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 +10907,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 +10930,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 +10955,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 +11116,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 +11145,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 +11203,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 +11253,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 952cdb0..5656622 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.10-r1.10.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 de70c2d..cc44c84 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.10-r1.10.0 """ import platform @@ -162,7 +162,7 @@ class zes_structure_type_v(IntEnum): MEM_BANDWIDTH_COUNTER_BITS_EXP_PROPERTIES = 0x00020002 ## ::zes_mem_bandwidth_counter_bits_exp_properties_t MEMORY_PAGE_OFFLINE_STATE_EXP = 0x00020003 ## ::zes_mem_page_offline_state_exp_t SUBDEVICE_EXP_PROPERTIES = 0x00020004 ## ::zes_subdevice_exp_properties_t - VF_EXP_PROPERTIES = 0x00020005 ## ::zes_vf_exp_properties_t + VF_EXP_CAPABILITIES = 0x00020005 ## ::zes_vf_exp_capabilities_t VF_UTIL_MEM_EXP = 0x00020006 ## ::zes_vf_util_mem_exp_t VF_UTIL_ENGINE_EXP = 0x00020007 ## ::zes_vf_util_engine_exp_t @@ -2086,6 +2086,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 +2431,9 @@ 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 + CURRENT = ZE_MAKE_VERSION( 1, 1 ) ## latest known version class zes_vf_management_exp_version_t(c_int): def __str__(self): @@ -2439,40 +2441,15 @@ def __str__(self): ############################################################################### -## @brief Virtual function memory types -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 - -class zes_vf_info_mem_type_exp_flags_t(c_int): - def __str__(self): - return hex(self.value) - - -############################################################################### -## @brief Virtual function utilization flag bit fields -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 - INFO_MEM_GPU = ZE_BIT(2) ## Device memory utilization associated with virtual function - INFO_ENGINE = ZE_BIT(3) ## Engine utilization associated with virtual function - -class zes_vf_info_util_exp_flags_t(c_int): - def __str__(self): - return hex(self.value) - - -############################################################################### -## @brief Virtual function management properties -class zes_vf_exp_properties_t(Structure): +## @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 - ("uuid", zes_uuid_t), ## [out] universal unique identifier of the device - ("flags", zes_vf_info_util_exp_flags_t) ## [out] utilization flags available. May be 0 or a valid combination of - ## ::zes_vf_info_util_exp_flag_t. + ("vfDeviceMemSize", c_ulong), ## [out] Virtual function memory size in bytes + ("vfID", c_ulong) ## [out] Virtual Function ID ] ############################################################################### @@ -2482,23 +2459,27 @@ class zes_vf_util_mem_exp_t(Structure): ("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). - ("memTypeFlags", zes_vf_info_mem_type_exp_flags_t), ## [out] Memory type flags. - ("free", c_ulonglong), ## [out] Free memory size in bytes. - ("size", c_ulonglong), ## [out] Total allocatable memory in bytes. - ("timestamp", c_ulonglong) ## [out] Wall clock time from VF when value was sampled. + ("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_exp_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). - ("type", zes_engine_group_t), ## [out] The engine group. + ("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. - ("timestamp", c_ulonglong) ## [out] Wall clock time when the activeCounterValue was sampled. + ("samplingCounterValue", c_ulonglong) ## [out] Represents counter value when activeCounterValue was sampled. + ## Refer to the formulae above for calculating the utilization percent ] ############################################################################### @@ -2830,11 +2811,11 @@ class _zes_device_dditable_t(Structure): _zesDeviceGetSubDevicePropertiesExp_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_subdevice_exp_properties_t) ) ############################################################################### -## @brief Function-pointer for zesDeviceEnumActiveVFExp +## @brief Function-pointer for zesDeviceEnumEnabledVFExp if __use_win_types: - _zesDeviceEnumActiveVFExp_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_vf_handle_t) ) + _zesDeviceEnumEnabledVFExp_t = WINFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_vf_handle_t) ) else: - _zesDeviceEnumActiveVFExp_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_vf_handle_t) ) + _zesDeviceEnumEnabledVFExp_t = CFUNCTYPE( ze_result_t, zes_device_handle_t, POINTER(c_ulong), POINTER(zes_vf_handle_t) ) ############################################################################### @@ -2842,7 +2823,7 @@ class _zes_device_dditable_t(Structure): class _zes_device_exp_dditable_t(Structure): _fields_ = [ ("pfnGetSubDevicePropertiesExp", c_void_p), ## _zesDeviceGetSubDevicePropertiesExp_t - ("pfnEnumActiveVFExp", c_void_p) ## _zesDeviceEnumActiveVFExp_t + ("pfnEnumEnabledVFExp", c_void_p) ## _zesDeviceEnumEnabledVFExp_t ] ############################################################################### @@ -3778,11 +3759,11 @@ class _zes_diagnostics_dditable_t(Structure): ] ############################################################################### -## @brief Function-pointer for zesVFManagementGetVFPropertiesExp +## @brief Function-pointer for zesVFManagementGetVFCapabilitiesExp if __use_win_types: - _zesVFManagementGetVFPropertiesExp_t = WINFUNCTYPE( ze_result_t, zes_vf_handle_t, POINTER(zes_vf_exp_properties_t) ) + _zesVFManagementGetVFCapabilitiesExp_t = WINFUNCTYPE( ze_result_t, zes_vf_handle_t, POINTER(zes_vf_exp_capabilities_t) ) else: - _zesVFManagementGetVFPropertiesExp_t = CFUNCTYPE( ze_result_t, zes_vf_handle_t, POINTER(zes_vf_exp_properties_t) ) + _zesVFManagementGetVFCapabilitiesExp_t = CFUNCTYPE( ze_result_t, zes_vf_handle_t, POINTER(zes_vf_exp_capabilities_t) ) ############################################################################### ## @brief Function-pointer for zesVFManagementGetVFMemoryUtilizationExp @@ -3798,30 +3779,14 @@ class _zes_diagnostics_dditable_t(Structure): else: _zesVFManagementGetVFEngineUtilizationExp_t = CFUNCTYPE( ze_result_t, zes_vf_handle_t, POINTER(c_ulong), POINTER(zes_vf_util_engine_exp_t) ) -############################################################################### -## @brief Function-pointer for zesVFManagementSetVFTelemetryModeExp -if __use_win_types: - _zesVFManagementSetVFTelemetryModeExp_t = WINFUNCTYPE( ze_result_t, zes_vf_handle_t, zes_vf_info_util_exp_flags_t, ze_bool_t ) -else: - _zesVFManagementSetVFTelemetryModeExp_t = CFUNCTYPE( ze_result_t, zes_vf_handle_t, zes_vf_info_util_exp_flags_t, ze_bool_t ) - -############################################################################### -## @brief Function-pointer for zesVFManagementSetVFTelemetrySamplingIntervalExp -if __use_win_types: - _zesVFManagementSetVFTelemetrySamplingIntervalExp_t = WINFUNCTYPE( ze_result_t, zes_vf_handle_t, zes_vf_info_util_exp_flags_t, c_ulonglong ) -else: - _zesVFManagementSetVFTelemetrySamplingIntervalExp_t = CFUNCTYPE( ze_result_t, zes_vf_handle_t, zes_vf_info_util_exp_flags_t, c_ulonglong ) - ############################################################################### ## @brief Table of VFManagementExp functions pointers class _zes_vf_management_exp_dditable_t(Structure): _fields_ = [ - ("pfnGetVFPropertiesExp", c_void_p), ## _zesVFManagementGetVFPropertiesExp_t + ("pfnGetVFCapabilitiesExp", c_void_p), ## _zesVFManagementGetVFCapabilitiesExp_t ("pfnGetVFMemoryUtilizationExp", c_void_p), ## _zesVFManagementGetVFMemoryUtilizationExp_t - ("pfnGetVFEngineUtilizationExp", c_void_p), ## _zesVFManagementGetVFEngineUtilizationExp_t - ("pfnSetVFTelemetryModeExp", c_void_p), ## _zesVFManagementSetVFTelemetryModeExp_t - ("pfnSetVFTelemetrySamplingIntervalExp", c_void_p) ## _zesVFManagementSetVFTelemetrySamplingIntervalExp_t + ("pfnGetVFEngineUtilizationExp", c_void_p) ## _zesVFManagementGetVFEngineUtilizationExp_t ] ############################################################################### @@ -3931,7 +3896,7 @@ def __init__(self, version : ze_api_version_t): # attach function interface to function address self.zesDeviceGetSubDevicePropertiesExp = _zesDeviceGetSubDevicePropertiesExp_t(self.__dditable.DeviceExp.pfnGetSubDevicePropertiesExp) - self.zesDeviceEnumActiveVFExp = _zesDeviceEnumActiveVFExp_t(self.__dditable.DeviceExp.pfnEnumActiveVFExp) + self.zesDeviceEnumEnabledVFExp = _zesDeviceEnumEnabledVFExp_t(self.__dditable.DeviceExp.pfnEnumEnabledVFExp) # call driver to get function pointers _Driver = _zes_driver_dditable_t() @@ -4220,10 +4185,8 @@ def __init__(self, version : ze_api_version_t): self.__dditable.VFManagementExp = _VFManagementExp # attach function interface to function address - self.zesVFManagementGetVFPropertiesExp = _zesVFManagementGetVFPropertiesExp_t(self.__dditable.VFManagementExp.pfnGetVFPropertiesExp) + self.zesVFManagementGetVFCapabilitiesExp = _zesVFManagementGetVFCapabilitiesExp_t(self.__dditable.VFManagementExp.pfnGetVFCapabilitiesExp) self.zesVFManagementGetVFMemoryUtilizationExp = _zesVFManagementGetVFMemoryUtilizationExp_t(self.__dditable.VFManagementExp.pfnGetVFMemoryUtilizationExp) self.zesVFManagementGetVFEngineUtilizationExp = _zesVFManagementGetVFEngineUtilizationExp_t(self.__dditable.VFManagementExp.pfnGetVFEngineUtilizationExp) - self.zesVFManagementSetVFTelemetryModeExp = _zesVFManagementSetVFTelemetryModeExp_t(self.__dditable.VFManagementExp.pfnSetVFTelemetryModeExp) - self.zesVFManagementSetVFTelemetrySamplingIntervalExp = _zesVFManagementSetVFTelemetrySamplingIntervalExp_t(self.__dditable.VFManagementExp.pfnSetVFTelemetrySamplingIntervalExp) # success! diff --git a/include/zes_api.h b/include/zes_api.h index 2c7c598..2aa9908 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.10-r1.10.0 * */ #ifndef _ZES_API_H @@ -155,7 +155,7 @@ typedef enum _zes_structure_type_t ZES_STRUCTURE_TYPE_MEM_BANDWIDTH_COUNTER_BITS_EXP_PROPERTIES = 0x00020002, ///< ::zes_mem_bandwidth_counter_bits_exp_properties_t ZES_STRUCTURE_TYPE_MEMORY_PAGE_OFFLINE_STATE_EXP = 0x00020003, ///< ::zes_mem_page_offline_state_exp_t ZES_STRUCTURE_TYPE_SUBDEVICE_EXP_PROPERTIES = 0x00020004, ///< ::zes_subdevice_exp_properties_t - ZES_STRUCTURE_TYPE_VF_EXP_PROPERTIES = 0x00020005, ///< ::zes_vf_exp_properties_t + ZES_STRUCTURE_TYPE_VF_EXP_CAPABILITIES = 0x00020005, ///< ::zes_vf_exp_capabilities_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_FORCE_UINT32 = 0x7fffffff @@ -537,8 +537,8 @@ typedef struct _zes_power_domain_exp_properties_t zes_power_domain_exp_propertie typedef struct _zes_subdevice_exp_properties_t zes_subdevice_exp_properties_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Forward-declare zes_vf_exp_properties_t -typedef struct _zes_vf_exp_properties_t zes_vf_exp_properties_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_exp_t @@ -6192,6 +6192,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,49 +7053,25 @@ 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 + ZES_VF_MANAGEMENT_EXP_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 1 ), ///< latest known version ZES_VF_MANAGEMENT_EXP_VERSION_FORCE_UINT32 = 0x7fffffff } zes_vf_management_exp_version_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Virtual function memory types -typedef uint32_t zes_vf_info_mem_type_exp_flags_t; -typedef enum _zes_vf_info_mem_type_exp_flag_t -{ - ZES_VF_INFO_MEM_TYPE_EXP_FLAG_MEM_TYPE_SYSTEM = ZE_BIT(0), ///< System memory - ZES_VF_INFO_MEM_TYPE_EXP_FLAG_MEM_TYPE_DEVICE = ZE_BIT(1), ///< Device local memory - ZES_VF_INFO_MEM_TYPE_EXP_FLAG_FORCE_UINT32 = 0x7fffffff - -} zes_vf_info_mem_type_exp_flag_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Virtual function utilization flag bit fields -typedef uint32_t zes_vf_info_util_exp_flags_t; -typedef enum _zes_vf_info_util_exp_flag_t -{ - ZES_VF_INFO_UTIL_EXP_FLAG_INFO_NONE = ZE_BIT(0), ///< No info associated with virtual function - ZES_VF_INFO_UTIL_EXP_FLAG_INFO_MEM_CPU = ZE_BIT(1), ///< System memory utilization associated with virtual function - ZES_VF_INFO_UTIL_EXP_FLAG_INFO_MEM_GPU = ZE_BIT(2), ///< Device memory utilization associated with virtual function - ZES_VF_INFO_UTIL_EXP_FLAG_INFO_ENGINE = ZE_BIT(3), ///< Engine utilization associated with virtual function - ZES_VF_INFO_UTIL_EXP_FLAG_FORCE_UINT32 = 0x7fffffff - -} zes_vf_info_util_exp_flag_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Virtual function management properties -typedef struct _zes_vf_exp_properties_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 - zes_uuid_t uuid; ///< [out] universal unique identifier of the device - zes_vf_info_util_exp_flags_t flags; ///< [out] utilization flags available. May be 0 or a valid combination of - ///< ::zes_vf_info_util_exp_flag_t. + uint32_t vfDeviceMemSize; ///< [out] Virtual function memory size in bytes + uint32_t vfID; ///< [out] Virtual Function ID -} zes_vf_exp_properties_t; +} zes_vf_exp_capabilities_t; /////////////////////////////////////////////////////////////////////////////// /// @brief Provides memory utilization values for a virtual function @@ -7103,24 +7080,28 @@ typedef struct _zes_vf_util_mem_exp_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_vf_info_mem_type_exp_flags_t memTypeFlags; ///< [out] Memory type flags. - uint64_t free; ///< [out] Free memory size in bytes. - uint64_t size; ///< [out] Total allocatable memory in bytes. - uint64_t timestamp; ///< [out] Wall clock time from VF when value was sampled. + 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_exp_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_exp_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 type; ///< [out] The engine group. + 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. - uint64_t timestamp; ///< [out] Wall clock time when the activeCounterValue was sampled. + ///< Refer to the formulae above for calculating the utilization percent } zes_vf_util_engine_exp_t; @@ -7142,7 +7123,7 @@ typedef struct _zes_vf_util_engine_exp_t /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER /// + `nullptr == pCount` ZE_APIEXPORT ze_result_t ZE_APICALL -zesDeviceEnumActiveVFExp( +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 @@ -7158,7 +7139,7 @@ zesDeviceEnumActiveVFExp( ); /////////////////////////////////////////////////////////////////////////////// -/// @brief Get virtual function management properties +/// @brief Get virtual function management capabilities /// /// @details /// - The application may call this function from simultaneous threads. @@ -7173,11 +7154,11 @@ zesDeviceEnumActiveVFExp( /// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE /// + `nullptr == hVFhandle` /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER -/// + `nullptr == pProperties` +/// + `nullptr == pCapability` ZE_APIEXPORT ze_result_t ZE_APICALL -zesVFManagementGetVFPropertiesExp( +zesVFManagementGetVFCapabilitiesExp( zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. - zes_vf_exp_properties_t* pProperties ///< [in,out] Will contain VF properties. + zes_vf_exp_capabilities_t* pCapability ///< [in,out] Will contain VF capability. ); /////////////////////////////////////////////////////////////////////////////// @@ -7187,6 +7168,7 @@ zesVFManagementGetVFPropertiesExp( /// @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 @@ -7207,8 +7189,6 @@ zesVFManagementGetVFMemoryUtilizationExp( ///< - 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. - ///< - The count returned is the sum of number of VF instances currently - ///< available and the PF instance. zes_vf_util_mem_exp_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. @@ -7223,6 +7203,7 @@ zesVFManagementGetVFMemoryUtilizationExp( /// @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 @@ -7243,8 +7224,6 @@ zesVFManagementGetVFEngineUtilizationExp( ///< - 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. - ///< - The count returned is the sum of number of VF instances currently - ///< available and the PF instance. zes_vf_util_engine_exp_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. @@ -7252,58 +7231,6 @@ zesVFManagementGetVFEngineUtilizationExp( ///< engine stats. ); -/////////////////////////////////////////////////////////////////////////////// -/// @brief Configure utilization telemetry enabled or disabled associated with -/// Virtual Function (VF) -/// -/// @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_ENUMERATION -/// + `0xf < flags` -ZE_APIEXPORT ze_result_t ZE_APICALL -zesVFManagementSetVFTelemetryModeExp( - zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. - zes_vf_info_util_exp_flags_t flags, ///< [in] utilization flags to enable or disable. May be 0 or a valid - ///< combination of ::zes_vf_info_util_exp_flag_t. - ze_bool_t enable ///< [in] Enable utilization telemetry. - ); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Set sampling interval to monitor for a particular utilization -/// telemetry associated with Virtual Function (VF) -/// -/// @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_ENUMERATION -/// + `0xf < flag` -ZE_APIEXPORT ze_result_t ZE_APICALL -zesVFManagementSetVFTelemetrySamplingIntervalExp( - zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. - zes_vf_info_util_exp_flags_t flag, ///< [in] utilization flags to set sampling interval. May be 0 or a valid - ///< combination of ::zes_vf_info_util_exp_flag_t. - uint64_t samplingInterval ///< [in] Sampling interval value. - ); - #if !defined(__GNUC__) #pragma endregion #endif diff --git a/include/zes_ddi.h b/include/zes_ddi.h index a33e838..f01e192 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.10-r1.10.0 * */ #ifndef _ZES_DDI_H @@ -411,8 +411,8 @@ typedef ze_result_t (ZE_APICALL *zes_pfnDeviceGetSubDevicePropertiesExp_t)( ); /////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for zesDeviceEnumActiveVFExp -typedef ze_result_t (ZE_APICALL *zes_pfnDeviceEnumActiveVFExp_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* @@ -423,7 +423,7 @@ typedef ze_result_t (ZE_APICALL *zes_pfnDeviceEnumActiveVFExp_t)( typedef struct _zes_device_exp_dditable_t { zes_pfnDeviceGetSubDevicePropertiesExp_t pfnGetSubDevicePropertiesExp; - zes_pfnDeviceEnumActiveVFExp_t pfnEnumActiveVFExp; + zes_pfnDeviceEnumEnabledVFExp_t pfnEnumEnabledVFExp; } zes_device_exp_dditable_t; /////////////////////////////////////////////////////////////////////////////// @@ -1848,10 +1848,10 @@ typedef ze_result_t (ZE_APICALL *zes_pfnGetDiagnosticsProcAddrTable_t)( ); /////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for zesVFManagementGetVFPropertiesExp -typedef ze_result_t (ZE_APICALL *zes_pfnVFManagementGetVFPropertiesExp_t)( +/// @brief Function-pointer for zesVFManagementGetVFCapabilitiesExp +typedef ze_result_t (ZE_APICALL *zes_pfnVFManagementGetVFCapabilitiesExp_t)( zes_vf_handle_t, - zes_vf_exp_properties_t* + zes_vf_exp_capabilities_t* ); /////////////////////////////////////////////////////////////////////////////// @@ -1870,31 +1870,13 @@ typedef ze_result_t (ZE_APICALL *zes_pfnVFManagementGetVFEngineUtilizationExp_t) zes_vf_util_engine_exp_t* ); -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for zesVFManagementSetVFTelemetryModeExp -typedef ze_result_t (ZE_APICALL *zes_pfnVFManagementSetVFTelemetryModeExp_t)( - zes_vf_handle_t, - zes_vf_info_util_exp_flags_t, - ze_bool_t - ); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for zesVFManagementSetVFTelemetrySamplingIntervalExp -typedef ze_result_t (ZE_APICALL *zes_pfnVFManagementSetVFTelemetrySamplingIntervalExp_t)( - zes_vf_handle_t, - zes_vf_info_util_exp_flags_t, - uint64_t - ); - /////////////////////////////////////////////////////////////////////////////// /// @brief Table of VFManagementExp functions pointers typedef struct _zes_vf_management_exp_dditable_t { - zes_pfnVFManagementGetVFPropertiesExp_t pfnGetVFPropertiesExp; + zes_pfnVFManagementGetVFCapabilitiesExp_t pfnGetVFCapabilitiesExp; zes_pfnVFManagementGetVFMemoryUtilizationExp_t pfnGetVFMemoryUtilizationExp; zes_pfnVFManagementGetVFEngineUtilizationExp_t pfnGetVFEngineUtilizationExp; - zes_pfnVFManagementSetVFTelemetryModeExp_t pfnSetVFTelemetryModeExp; - zes_pfnVFManagementSetVFTelemetrySamplingIntervalExp_t pfnSetVFTelemetrySamplingIntervalExp; } zes_vf_management_exp_dditable_t; /////////////////////////////////////////////////////////////////////////////// diff --git a/include/zet.py b/include/zet.py index ea50200..cfca32d 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.10-r1.10.0 """ import platform @@ -100,6 +100,7 @@ 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_TRACER_EXP_DESC = 0x00010006 ## ::zet_metric_tracer_exp_desc_t class zet_structure_type_t(c_int): def __str__(self): @@ -321,6 +322,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 +381,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 +415,14 @@ 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 + 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 +596,74 @@ 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 Calculating Multiple Metrics Experimental Extension Name ZET_MULTI_METRICS_EXP_NAME = "ZET_experimental_calculate_multiple_metrics" @@ -675,8 +751,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 +784,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 +825,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 +840,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 +855,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 +877,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 +886,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 +900,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 +955,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 +1056,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: @@ -990,9 +1189,9 @@ class _zet_metric_dditable_t(Structure): ############################################################################### ## @brief Function-pointer for zetMetricCreateFromProgrammableExp if __use_win_types: - _zetMetricCreateFromProgrammableExp_t = WINFUNCTYPE( ze_result_t, zet_metric_programmable_exp_handle_t, POINTER(zet_metric_programmable_param_value_exp_t), c_ulong, c_char_p, c_char_p, POINTER(c_ulong), POINTER(zet_metric_handle_t) ) + _zetMetricCreateFromProgrammableExp_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: - _zetMetricCreateFromProgrammableExp_t = CFUNCTYPE( ze_result_t, zet_metric_programmable_exp_handle_t, POINTER(zet_metric_programmable_param_value_exp_t), c_ulong, c_char_p, c_char_p, POINTER(c_ulong), POINTER(zet_metric_handle_t) ) + _zetMetricCreateFromProgrammableExp_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 Function-pointer for zetMetricDestroyExp @@ -1069,13 +1268,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: @@ -1113,7 +1305,6 @@ class _zet_metric_group_exp_dditable_t(Structure): ("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 +1558,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 +1603,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 +1640,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))) @@ -1508,7 +1740,6 @@ def __init__(self, version : ze_api_version_t): 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 a202fde..9b2b3c9 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.10-r1.10.0 * */ #ifndef _ZET_API_H @@ -99,6 +99,7 @@ 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_TRACER_EXP_DESC = 0x00010006, ///< ::zet_metric_tracer_exp_desc_t ZET_STRUCTURE_TYPE_FORCE_UINT32 = 0x7fffffff } zet_structure_type_t; @@ -250,6 +251,14 @@ 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_global_timestamps_resolution_exp_t typedef struct _zet_metric_global_timestamps_resolution_exp_t zet_metric_global_timestamps_resolution_exp_t; @@ -266,6 +275,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 +665,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 +701,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 +733,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 +946,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 +1002,14 @@ 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_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 +1859,411 @@ 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 @@ -2141,8 +2566,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 +2609,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 +2655,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 +2669,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 +2682,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 +2706,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 +2716,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 +2731,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 +2873,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 @@ -2453,8 +2895,8 @@ zetMetricProgrammableGetParamValueInfoExp( 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. 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 @@ -2472,11 +2914,16 @@ zetMetricCreateFromProgrammableExp( ); /////////////////////////////////////////////////////////////////////////////// -/// @brief Create metric group handle. +/// @brief Create multiple metric group handles from metric handles. /// /// @details -/// - Metrics from ::zetMetricCreateFromProgrammableExp() could be added to -/// the created metric group. +/// - Creates multiple metric groups from metrics which were created using +/// ::zetMetricCreateFromProgrammableExp(). +/// - 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 @@ -2486,22 +2933,31 @@ zetMetricCreateFromProgrammableExp( /// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY /// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE /// + `nullptr == hDevice` -/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER -/// + `nullptr == pName` -/// + `nullptr == pDescription` -/// + `nullptr == phMetricGroup` -/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION -/// + `0x3 < samplingType` +/// + `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 -zetMetricGroupCreateExp( - 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 - ///< character array no longer than ::ZET_MAX_METRIC_GROUP_NAME. - const char* pDescription, ///< [in] pointer to metric group description. Must point to a +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. - zet_metric_group_sampling_type_flags_t samplingType, ///< [in] Sampling type for the metric group. - zet_metric_group_handle_t* phMetricGroup ///< [in,out] Created Metric group handle + 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. ); /////////////////////////////////////////////////////////////////////////////// diff --git a/include/zet_ddi.h b/include/zet_ddi.h index 876df64..a5a7869 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.10-r1.10.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)( @@ -343,8 +535,8 @@ typedef ze_result_t (ZE_APICALL *zet_pfnGetMetricProcAddrTable_t)( /// @brief Function-pointer for zetMetricCreateFromProgrammableExp typedef ze_result_t (ZE_APICALL *zet_pfnMetricCreateFromProgrammableExp_t)( zet_metric_programmable_exp_handle_t, - zet_metric_programmable_param_value_exp_t*, uint32_t, + zet_metric_programmable_param_value_exp_t*, const char*, const char*, uint32_t*, @@ -490,16 +682,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)( @@ -536,7 +718,6 @@ typedef struct _zet_metric_group_exp_dditable_t 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 +1124,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/source/drivers/null/ze_nullddi.cpp b/source/drivers/null/ze_nullddi.cpp index 1c8befc..130c745 100644 --- a/source/drivers/null/ze_nullddi.cpp +++ b/source/drivers/null/ze_nullddi.cpp @@ -68,6 +68,41 @@ 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 + 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 @@ -3906,6 +3941,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 +5084,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 +5114,8 @@ zeGetGlobalProcAddrTable( pDdiTable->pfnInit = driver::zeInit; + pDdiTable->pfnInitDrivers = driver::zeInitDrivers; + return result; } @@ -5443,18 +5536,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 bcfbec4..5e8337c 100644 --- a/source/drivers/null/zes_nullddi.cpp +++ b/source/drivers/null/zes_nullddi.cpp @@ -3767,9 +3767,9 @@ namespace driver } /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zesDeviceEnumActiveVFExp + /// @brief Intercept function for zesDeviceEnumEnabledVFExp __zedlllocal ze_result_t ZE_APICALL - zesDeviceEnumActiveVFExp( + 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 @@ -3787,10 +3787,10 @@ namespace driver 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 pfnEnumActiveVFExp = context.zesDdiTable.DeviceExp.pfnEnumActiveVFExp; - if( nullptr != pfnEnumActiveVFExp ) + auto pfnEnumEnabledVFExp = context.zesDdiTable.DeviceExp.pfnEnumEnabledVFExp; + if( nullptr != pfnEnumEnabledVFExp ) { - result = pfnEnumActiveVFExp( hDevice, pCount, phVFhandle ); + result = pfnEnumEnabledVFExp( hDevice, pCount, phVFhandle ); } else { @@ -3804,20 +3804,20 @@ namespace driver } /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zesVFManagementGetVFPropertiesExp + /// @brief Intercept function for zesVFManagementGetVFCapabilitiesExp __zedlllocal ze_result_t ZE_APICALL - zesVFManagementGetVFPropertiesExp( + zesVFManagementGetVFCapabilitiesExp( zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. - zes_vf_exp_properties_t* pProperties ///< [in,out] Will contain VF properties. + 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 pfnGetVFPropertiesExp = context.zesDdiTable.VFManagementExp.pfnGetVFPropertiesExp; - if( nullptr != pfnGetVFPropertiesExp ) + auto pfnGetVFCapabilitiesExp = context.zesDdiTable.VFManagementExp.pfnGetVFCapabilitiesExp; + if( nullptr != pfnGetVFCapabilitiesExp ) { - result = pfnGetVFPropertiesExp( hVFhandle, pProperties ); + result = pfnGetVFCapabilitiesExp( hVFhandle, pCapability ); } else { @@ -3838,8 +3838,6 @@ namespace driver ///< - 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. - ///< - The count returned is the sum of number of VF instances currently - ///< available and the PF instance. zes_vf_util_mem_exp_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. @@ -3874,8 +3872,6 @@ namespace driver ///< - 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. - ///< - The count returned is the sum of number of VF instances currently - ///< available and the PF instance. zes_vf_util_engine_exp_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. @@ -3899,58 +3895,6 @@ namespace driver return result; } - /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zesVFManagementSetVFTelemetryModeExp - __zedlllocal ze_result_t ZE_APICALL - zesVFManagementSetVFTelemetryModeExp( - zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. - zes_vf_info_util_exp_flags_t flags, ///< [in] utilization flags to enable or disable. May be 0 or a valid - ///< combination of ::zes_vf_info_util_exp_flag_t. - ze_bool_t enable ///< [in] Enable utilization telemetry. - ) - { - 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 pfnSetVFTelemetryModeExp = context.zesDdiTable.VFManagementExp.pfnSetVFTelemetryModeExp; - if( nullptr != pfnSetVFTelemetryModeExp ) - { - result = pfnSetVFTelemetryModeExp( hVFhandle, flags, enable ); - } - else - { - // generic implementation - } - - return result; - } - - /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zesVFManagementSetVFTelemetrySamplingIntervalExp - __zedlllocal ze_result_t ZE_APICALL - zesVFManagementSetVFTelemetrySamplingIntervalExp( - zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. - zes_vf_info_util_exp_flags_t flag, ///< [in] utilization flags to set sampling interval. May be 0 or a valid - ///< combination of ::zes_vf_info_util_exp_flag_t. - uint64_t samplingInterval ///< [in] Sampling interval value. - ) - { - 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 pfnSetVFTelemetrySamplingIntervalExp = context.zesDdiTable.VFManagementExp.pfnSetVFTelemetrySamplingIntervalExp; - if( nullptr != pfnSetVFTelemetrySamplingIntervalExp ) - { - result = pfnSetVFTelemetrySamplingIntervalExp( hVFhandle, flag, samplingInterval ); - } - else - { - // generic implementation - } - - return result; - } - } // namespace driver #if defined(__cplusplus) @@ -4107,7 +4051,7 @@ zesGetDeviceExpProcAddrTable( pDdiTable->pfnGetSubDevicePropertiesExp = driver::zesDeviceGetSubDevicePropertiesExp; - pDdiTable->pfnEnumActiveVFExp = driver::zesDeviceEnumActiveVFExp; + pDdiTable->pfnEnumEnabledVFExp = driver::zesDeviceEnumEnabledVFExp; return result; } @@ -4832,16 +4776,12 @@ zesGetVFManagementExpProcAddrTable( ze_result_t result = ZE_RESULT_SUCCESS; - pDdiTable->pfnGetVFPropertiesExp = driver::zesVFManagementGetVFPropertiesExp; + pDdiTable->pfnGetVFCapabilitiesExp = driver::zesVFManagementGetVFCapabilitiesExp; pDdiTable->pfnGetVFMemoryUtilizationExp = driver::zesVFManagementGetVFMemoryUtilizationExp; pDdiTable->pfnGetVFEngineUtilizationExp = driver::zesVFManagementGetVFEngineUtilizationExp; - pDdiTable->pfnSetVFTelemetryModeExp = driver::zesVFManagementSetVFTelemetryModeExp; - - pDdiTable->pfnSetVFTelemetrySamplingIntervalExp = driver::zesVFManagementSetVFTelemetrySamplingIntervalExp; - return result; } diff --git a/source/drivers/null/zet_nullddi.cpp b/source/drivers/null/zet_nullddi.cpp index 2752619..ef4757b 100644 --- a/source/drivers/null/zet_nullddi.cpp +++ b/source/drivers/null/zet_nullddi.cpp @@ -1075,6 +1075,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 @@ -1350,8 +1675,8 @@ namespace driver __zedlllocal 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. 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 @@ -1374,7 +1699,7 @@ namespace driver auto pfnCreateFromProgrammableExp = context.zetDdiTable.MetricExp.pfnCreateFromProgrammableExp; if( nullptr != pfnCreateFromProgrammableExp ) { - result = pfnCreateFromProgrammableExp( hMetricProgrammable, pParameterValues, parameterCount, pName, pDescription, pMetricHandleCount, phMetricHandles ); + result = pfnCreateFromProgrammableExp( hMetricProgrammable, parameterCount, pParameterValues, pName, pDescription, pMetricHandleCount, phMetricHandles ); } else { @@ -1388,31 +1713,44 @@ namespace driver } /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zetMetricGroupCreateExp + /// @brief Intercept function for zetDeviceCreateMetricGroupsFromMetricsExp __zedlllocal ze_result_t ZE_APICALL - zetMetricGroupCreateExp( - 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 - ///< character array no longer than ::ZET_MAX_METRIC_GROUP_NAME. - const char* pDescription, ///< [in] pointer to metric group description. Must point to a + 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. - zet_metric_group_sampling_type_flags_t samplingType,///< [in] Sampling type for the metric group. - zet_metric_group_handle_t* phMetricGroup ///< [in,out] Created Metric group handle + 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 pfnCreateExp = context.zetDdiTable.MetricGroupExp.pfnCreateExp; - if( nullptr != pfnCreateExp ) + auto pfnCreateMetricGroupsFromMetricsExp = context.zetDdiTable.DeviceExp.pfnCreateMetricGroupsFromMetricsExp; + if( nullptr != pfnCreateMetricGroupsFromMetricsExp ) { - result = pfnCreateExp( hDevice, pName, pDescription, samplingType, phMetricGroup ); + result = pfnCreateMetricGroupsFromMetricsExp( hDevice, metricCount, phMetrics, pMetricGroupNamePrefix, pDescription, pMetricGroupCount, phMetricGroup ); } else { // generic implementation - *phMetricGroup = reinterpret_cast( context.get() ); + for( size_t i = 0; ( nullptr != phMetricGroup ) && ( i < *pMetricGroupCount ); ++i ) + phMetricGroup[ i ] = reinterpret_cast( context.get() ); } @@ -1549,6 +1887,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 +1951,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 +2015,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 @@ -1891,8 +2326,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 84a3b1f..8eac254 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 13da068..fe6e308 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 3626668..f03b28f 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 @@ -5781,6 +5826,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 +7511,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 +7545,9 @@ zeGetGlobalProcAddrTable( dditable.pfnInit = pDdiTable->pfnInit; pDdiTable->pfnInit = tracing_layer::zeInit; + dditable.pfnInitDrivers = pDdiTable->pfnInitDrivers; + pDdiTable->pfnInitDrivers = tracing_layer::zeInitDrivers; + return result; } @@ -7947,14 +8083,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 +8092,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 c6b9ea4..14b1fb1 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 @@ -3016,6 +3043,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 +3939,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 261a031..355e11a 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 efab458..2a870ac 100644 --- a/source/layers/validation/checkers/parameter_validation/zes_parameter_validation.cpp +++ b/source/layers/validation/checkers/parameter_validation/zes_parameter_validation.cpp @@ -2647,7 +2647,7 @@ namespace validation_layer ze_result_t - ZESParameterValidation::zesDeviceEnumActiveVFExpPrologue( + 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 @@ -2673,18 +2673,18 @@ namespace validation_layer ze_result_t - ZESParameterValidation::zesVFManagementGetVFPropertiesExpPrologue( + ZESParameterValidation::zesVFManagementGetVFCapabilitiesExpPrologue( zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. - zes_vf_exp_properties_t* pProperties ///< [in,out] Will contain VF properties. + zes_vf_exp_capabilities_t* pCapability ///< [in,out] Will contain VF capability. ) { if( nullptr == hVFhandle ) return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; - if( nullptr == pProperties ) + if( nullptr == pCapability ) return ZE_RESULT_ERROR_INVALID_NULL_POINTER; - return ParameterValidation::validateExtensions(pProperties); + return ParameterValidation::validateExtensions(pCapability); } @@ -2697,8 +2697,6 @@ namespace validation_layer ///< - 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. - ///< - The count returned is the sum of number of VF instances currently - ///< available and the PF instance. zes_vf_util_mem_exp_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. @@ -2725,8 +2723,6 @@ namespace validation_layer ///< - 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. - ///< - The count returned is the sum of number of VF instances currently - ///< available and the PF instance. zes_vf_util_engine_exp_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. @@ -2743,40 +2739,4 @@ namespace validation_layer return ZE_RESULT_SUCCESS; } - - ze_result_t - ZESParameterValidation::zesVFManagementSetVFTelemetryModeExpPrologue( - zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. - zes_vf_info_util_exp_flags_t flags, ///< [in] utilization flags to enable or disable. May be 0 or a valid - ///< combination of ::zes_vf_info_util_exp_flag_t. - ze_bool_t enable ///< [in] Enable utilization telemetry. - ) - { - if( nullptr == hVFhandle ) - return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; - - if( 0xf < flags ) - return ZE_RESULT_ERROR_INVALID_ENUMERATION; - - return ZE_RESULT_SUCCESS; - } - - - ze_result_t - ZESParameterValidation::zesVFManagementSetVFTelemetrySamplingIntervalExpPrologue( - zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. - zes_vf_info_util_exp_flags_t flag, ///< [in] utilization flags to set sampling interval. May be 0 or a valid - ///< combination of ::zes_vf_info_util_exp_flag_t. - uint64_t samplingInterval ///< [in] Sampling interval value. - ) - { - if( nullptr == hVFhandle ) - return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; - - if( 0xf < flag ) - return ZE_RESULT_ERROR_INVALID_ENUMERATION; - - 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 f9344d6..8eb666f 100644 --- a/source/layers/validation/checkers/parameter_validation/zes_parameter_validation.h +++ b/source/layers/validation/checkers/parameter_validation/zes_parameter_validation.h @@ -158,11 +158,9 @@ namespace validation_layer ze_result_t zesFirmwareSetSecurityVersionExpPrologue( zes_firmware_handle_t hFirmware ) override; ze_result_t zesDeviceGetSubDevicePropertiesExpPrologue( zes_device_handle_t hDevice, uint32_t* pCount, zes_subdevice_exp_properties_t* pSubdeviceProps ) override; ze_result_t zesDriverGetDeviceByUuidExpPrologue( zes_driver_handle_t hDriver, zes_uuid_t uuid, zes_device_handle_t* phDevice, ze_bool_t* onSubdevice, uint32_t* subdeviceId ) override; - ze_result_t zesDeviceEnumActiveVFExpPrologue( zes_device_handle_t hDevice, uint32_t* pCount, zes_vf_handle_t* phVFhandle ) override; - ze_result_t zesVFManagementGetVFPropertiesExpPrologue( zes_vf_handle_t hVFhandle, zes_vf_exp_properties_t* pProperties ) 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 zesVFManagementGetVFMemoryUtilizationExpPrologue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_mem_exp_t* pMemUtil ) override; 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; }; } \ 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 df25e64..17ddfbc 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 @@ -1006,8 +1253,8 @@ namespace validation_layer ze_result_t ZETParameterValidation::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. 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 @@ -1044,31 +1291,34 @@ namespace validation_layer ze_result_t - ZETParameterValidation::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 - ///< character array no longer than ::ZET_MAX_METRIC_GROUP_NAME. - const char* pDescription, ///< [in] pointer to metric group description. Must point to a + 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. - zet_metric_group_sampling_type_flags_t samplingType,///< [in] Sampling type for the metric group. - zet_metric_group_handle_t* phMetricGroup ///< [in,out] Created Metric group handle + 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 == pName ) - return ZE_RESULT_ERROR_INVALID_NULL_POINTER; - - if( nullptr == pDescription ) - return ZE_RESULT_ERROR_INVALID_NULL_POINTER; - - if( nullptr == phMetricGroup ) - return ZE_RESULT_ERROR_INVALID_NULL_POINTER; - - if( 0x3 < samplingType ) - return ZE_RESULT_ERROR_INVALID_ENUMERATION; + if( nullptr == phMetrics ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; 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 3b6c68b..08cd0ea 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,8 +77,8 @@ 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 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 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 zetMetricCreateFromProgrammableExpPrologue( 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 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 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; ze_result_t zetMetricGroupCloseExpPrologue( zet_metric_group_handle_t hMetricGroup ) override; diff --git a/source/layers/validation/common/ze_entry_points.h b/source/layers/validation/common/ze_entry_points.h index 9ac9bc0..104e941 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 3d8f38d..e0a73b0 100644 --- a/source/layers/validation/common/zes_entry_points.h +++ b/source/layers/validation/common/zes_entry_points.h @@ -293,18 +293,14 @@ class ZESValidationEntryPoints { virtual ze_result_t zesDeviceGetSubDevicePropertiesExpEpilogue( zes_device_handle_t hDevice, uint32_t* pCount, zes_subdevice_exp_properties_t* pSubdeviceProps ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zesDriverGetDeviceByUuidExpPrologue( zes_driver_handle_t hDriver, zes_uuid_t uuid, zes_device_handle_t* phDevice, ze_bool_t* onSubdevice, uint32_t* subdeviceId ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zesDriverGetDeviceByUuidExpEpilogue( zes_driver_handle_t hDriver, zes_uuid_t uuid, zes_device_handle_t* phDevice, ze_bool_t* onSubdevice, uint32_t* subdeviceId ) {return ZE_RESULT_SUCCESS;} - virtual ze_result_t zesDeviceEnumActiveVFExpPrologue( zes_device_handle_t hDevice, uint32_t* pCount, zes_vf_handle_t* phVFhandle ) {return ZE_RESULT_SUCCESS;} - virtual ze_result_t zesDeviceEnumActiveVFExpEpilogue( zes_device_handle_t hDevice, uint32_t* pCount, zes_vf_handle_t* phVFhandle ) {return ZE_RESULT_SUCCESS;} - virtual ze_result_t zesVFManagementGetVFPropertiesExpPrologue( zes_vf_handle_t hVFhandle, zes_vf_exp_properties_t* pProperties ) {return ZE_RESULT_SUCCESS;} - virtual ze_result_t zesVFManagementGetVFPropertiesExpEpilogue( zes_vf_handle_t hVFhandle, zes_vf_exp_properties_t* pProperties ) {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 zesVFManagementGetVFMemoryUtilizationExpPrologue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_mem_exp_t* pMemUtil ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zesVFManagementGetVFMemoryUtilizationExpEpilogue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_mem_exp_t* pMemUtil ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zesVFManagementGetVFEngineUtilizationExpPrologue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_engine_exp_t* pEngineUtil ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zesVFManagementGetVFEngineUtilizationExpEpilogue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_engine_exp_t* pEngineUtil ) {return ZE_RESULT_SUCCESS;} - virtual ze_result_t zesVFManagementSetVFTelemetryModeExpPrologue( 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 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 ~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 129c551..30f51ee 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,10 +131,10 @@ 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 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 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 zetMetricCreateFromProgrammableExpPrologue( 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 zetMetricCreateFromProgrammableExpEpilogue( 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 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 zetMetricGroupAddMetricExpPrologue( zet_metric_group_handle_t hMetricGroup, zet_metric_handle_t hMetric, size_t * pErrorStringSize, char* pErrorString ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zetMetricGroupAddMetricExpEpilogue( zet_metric_group_handle_t hMetricGroup, zet_metric_handle_t hMetric, size_t * pErrorStringSize, char* pErrorString ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zetMetricGroupRemoveMetricExpPrologue( zet_metric_group_handle_t hMetricGroup, zet_metric_handle_t hMetric ) {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 0f122fc..0225733 100644 --- a/source/layers/validation/handle_lifetime_tracking/ze_handle_lifetime.cpp +++ b/source/layers/validation/handle_lifetime_tracking/ze_handle_lifetime.cpp @@ -2496,6 +2496,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 +3206,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 92e85be..43f41ad 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 51eebed..ffb1c30 100644 --- a/source/layers/validation/handle_lifetime_tracking/zes_handle_lifetime.cpp +++ b/source/layers/validation/handle_lifetime_tracking/zes_handle_lifetime.cpp @@ -2040,7 +2040,7 @@ namespace validation_layer return ZE_RESULT_SUCCESS; } ze_result_t - ZESHandleLifetimeValidation::zesDeviceEnumActiveVFExpPrologue( + 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 @@ -2062,9 +2062,9 @@ namespace validation_layer return ZE_RESULT_SUCCESS; } ze_result_t - ZESHandleLifetimeValidation::zesVFManagementGetVFPropertiesExpPrologue( + ZESHandleLifetimeValidation::zesVFManagementGetVFCapabilitiesExpPrologue( zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. - zes_vf_exp_properties_t* pProperties ///< [in,out] Will contain VF properties. + zes_vf_exp_capabilities_t* pCapability ///< [in,out] Will contain VF capability. ) { @@ -2082,8 +2082,6 @@ namespace validation_layer ///< - 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. - ///< - The count returned is the sum of number of VF instances currently - ///< available and the PF instance. zes_vf_util_mem_exp_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. @@ -2106,8 +2104,6 @@ namespace validation_layer ///< - 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. - ///< - The count returned is the sum of number of VF instances currently - ///< available and the PF instance. zes_vf_util_engine_exp_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. @@ -2116,34 +2112,6 @@ namespace validation_layer ) { - if ( !context.handleLifetime->isHandleValid( hVFhandle )){ - return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; - } - return ZE_RESULT_SUCCESS; - } - ze_result_t - ZESHandleLifetimeValidation::zesVFManagementSetVFTelemetryModeExpPrologue( - zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. - zes_vf_info_util_exp_flags_t flags, ///< [in] utilization flags to enable or disable. May be 0 or a valid - ///< combination of ::zes_vf_info_util_exp_flag_t. - ze_bool_t enable ///< [in] Enable utilization telemetry. - ) - { - - if ( !context.handleLifetime->isHandleValid( hVFhandle )){ - return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; - } - return ZE_RESULT_SUCCESS; - } - ze_result_t - ZESHandleLifetimeValidation::zesVFManagementSetVFTelemetrySamplingIntervalExpPrologue( - zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. - zes_vf_info_util_exp_flags_t flag, ///< [in] utilization flags to set sampling interval. May be 0 or a valid - ///< combination of ::zes_vf_info_util_exp_flag_t. - uint64_t samplingInterval ///< [in] Sampling interval value. - ) - { - 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 957d706..d638429 100644 --- a/source/layers/validation/handle_lifetime_tracking/zes_handle_lifetime.h +++ b/source/layers/validation/handle_lifetime_tracking/zes_handle_lifetime.h @@ -155,12 +155,10 @@ namespace validation_layer ze_result_t zesFirmwareSetSecurityVersionExpPrologue( zes_firmware_handle_t hFirmware ) override; ze_result_t zesDeviceGetSubDevicePropertiesExpPrologue( zes_device_handle_t hDevice, uint32_t* pCount, zes_subdevice_exp_properties_t* pSubdeviceProps ) override; ze_result_t zesDriverGetDeviceByUuidExpPrologue( zes_driver_handle_t hDriver, zes_uuid_t uuid, zes_device_handle_t* phDevice, ze_bool_t* onSubdevice, uint32_t* subdeviceId ) override; - ze_result_t zesDeviceEnumActiveVFExpPrologue( zes_device_handle_t hDevice, uint32_t* pCount, zes_vf_handle_t* phVFhandle ) override; - ze_result_t zesVFManagementGetVFPropertiesExpPrologue( zes_vf_handle_t hVFhandle, zes_vf_exp_properties_t* pProperties ) 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 zesVFManagementGetVFMemoryUtilizationExpPrologue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_mem_exp_t* pMemUtil ) override; 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; }; } 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 430085e..b16f68b 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 @@ -828,8 +1042,8 @@ namespace validation_layer 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. 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 @@ -853,15 +1067,27 @@ namespace validation_layer 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 - ///< character array no longer than ::ZET_MAX_METRIC_GROUP_NAME. - const char* pDescription, ///< [in] pointer to metric group description. Must point to a + 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. - zet_metric_group_sampling_type_flags_t samplingType,///< [in] Sampling type for the metric group. - zet_metric_group_handle_t* phMetricGroup ///< [in,out] Created Metric group handle + 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. ) { 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 455ec42..a549c03 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,8 +76,8 @@ 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 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 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 zetMetricCreateFromProgrammableExpPrologue( 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 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 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; ze_result_t zetMetricGroupCloseExpPrologue( zet_metric_group_handle_t hMetricGroup ) override; diff --git a/source/layers/validation/ze_valddi.cpp b/source/layers/validation/ze_valddi.cpp index 57a7904..3b840dd 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 @@ -6332,6 +6380,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 +8287,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 +8321,9 @@ zeGetGlobalProcAddrTable( dditable.pfnInit = pDdiTable->pfnInit; pDdiTable->pfnInit = validation_layer::zeInit; + dditable.pfnInitDrivers = pDdiTable->pfnInitDrivers; + pDdiTable->pfnInitDrivers = validation_layer::zeInitDrivers; + return result; } @@ -8716,14 +8859,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 +8868,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 cea3330..91bfcff 100644 --- a/source/layers/validation/zes_valddi.cpp +++ b/source/layers/validation/zes_valddi.cpp @@ -5960,9 +5960,9 @@ namespace validation_layer } /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zesDeviceEnumActiveVFExp + /// @brief Intercept function for zesDeviceEnumEnabledVFExp __zedlllocal ze_result_t ZE_APICALL - zesDeviceEnumActiveVFExp( + 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 @@ -5977,14 +5977,14 @@ namespace validation_layer ///< component handles. ) { - auto pfnEnumActiveVFExp = context.zesDdiTable.DeviceExp.pfnEnumActiveVFExp; + auto pfnEnumEnabledVFExp = context.zesDdiTable.DeviceExp.pfnEnumEnabledVFExp; - if( nullptr == pfnEnumActiveVFExp ) + 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->zesDeviceEnumActiveVFExpPrologue( hDevice, pCount, phVFhandle ); + auto result = context.validationHandlers[i]->zesValidation->zesDeviceEnumEnabledVFExpPrologue( hDevice, pCount, phVFhandle ); if(result!=ZE_RESULT_SUCCESS) return result; } @@ -5995,14 +5995,14 @@ namespace validation_layer if(context.enableHandleLifetime ){ - auto result = context.handleLifetime->zesHandleLifetime.zesDeviceEnumActiveVFExpPrologue( hDevice, pCount, phVFhandle ); + auto result = context.handleLifetime->zesHandleLifetime.zesDeviceEnumEnabledVFExpPrologue( hDevice, pCount, phVFhandle ); if(result!=ZE_RESULT_SUCCESS) return result; } - auto result = pfnEnumActiveVFExp( hDevice, pCount, phVFhandle ); + auto result = pfnEnumEnabledVFExp( hDevice, pCount, phVFhandle ); for (size_t i = 0; i < numValHandlers; i++) { - auto result = context.validationHandlers[i]->zesValidation->zesDeviceEnumActiveVFExpEpilogue( hDevice, pCount, phVFhandle ); + auto result = context.validationHandlers[i]->zesValidation->zesDeviceEnumEnabledVFExpEpilogue( hDevice, pCount, phVFhandle ); if(result!=ZE_RESULT_SUCCESS) return result; } @@ -6010,21 +6010,21 @@ namespace validation_layer } /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zesVFManagementGetVFPropertiesExp + /// @brief Intercept function for zesVFManagementGetVFCapabilitiesExp __zedlllocal ze_result_t ZE_APICALL - zesVFManagementGetVFPropertiesExp( + zesVFManagementGetVFCapabilitiesExp( zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. - zes_vf_exp_properties_t* pProperties ///< [in,out] Will contain VF properties. + zes_vf_exp_capabilities_t* pCapability ///< [in,out] Will contain VF capability. ) { - auto pfnGetVFPropertiesExp = context.zesDdiTable.VFManagementExp.pfnGetVFPropertiesExp; + auto pfnGetVFCapabilitiesExp = context.zesDdiTable.VFManagementExp.pfnGetVFCapabilitiesExp; - if( nullptr == pfnGetVFPropertiesExp ) + 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->zesVFManagementGetVFPropertiesExpPrologue( hVFhandle, pProperties ); + auto result = context.validationHandlers[i]->zesValidation->zesVFManagementGetVFCapabilitiesExpPrologue( hVFhandle, pCapability ); if(result!=ZE_RESULT_SUCCESS) return result; } @@ -6035,14 +6035,14 @@ namespace validation_layer if(context.enableHandleLifetime ){ - auto result = context.handleLifetime->zesHandleLifetime.zesVFManagementGetVFPropertiesExpPrologue( hVFhandle, pProperties ); + auto result = context.handleLifetime->zesHandleLifetime.zesVFManagementGetVFCapabilitiesExpPrologue( hVFhandle, pCapability ); if(result!=ZE_RESULT_SUCCESS) return result; } - auto result = pfnGetVFPropertiesExp( hVFhandle, pProperties ); + auto result = pfnGetVFCapabilitiesExp( hVFhandle, pCapability ); for (size_t i = 0; i < numValHandlers; i++) { - auto result = context.validationHandlers[i]->zesValidation->zesVFManagementGetVFPropertiesExpEpilogue( hVFhandle, pProperties ); + auto result = context.validationHandlers[i]->zesValidation->zesVFManagementGetVFCapabilitiesExpEpilogue( hVFhandle, pCapability ); if(result!=ZE_RESULT_SUCCESS) return result; } @@ -6064,8 +6064,6 @@ namespace validation_layer ///< - 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. - ///< - The count returned is the sum of number of VF instances currently - ///< available and the PF instance. zes_vf_util_mem_exp_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. @@ -6120,8 +6118,6 @@ namespace validation_layer ///< - 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. - ///< - The count returned is the sum of number of VF instances currently - ///< available and the PF instance. zes_vf_util_engine_exp_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. @@ -6165,90 +6161,6 @@ namespace validation_layer return result; } - /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zesVFManagementSetVFTelemetryModeExp - __zedlllocal ze_result_t ZE_APICALL - zesVFManagementSetVFTelemetryModeExp( - zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. - zes_vf_info_util_exp_flags_t flags, ///< [in] utilization flags to enable or disable. May be 0 or a valid - ///< combination of ::zes_vf_info_util_exp_flag_t. - ze_bool_t enable ///< [in] Enable utilization telemetry. - ) - { - auto pfnSetVFTelemetryModeExp = context.zesDdiTable.VFManagementExp.pfnSetVFTelemetryModeExp; - - if( nullptr == pfnSetVFTelemetryModeExp ) - 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->zesVFManagementSetVFTelemetryModeExpPrologue( hVFhandle, flags, enable ); - if(result!=ZE_RESULT_SUCCESS) return result; - } - - - if( context.enableThreadingValidation ){ - //Unimplemented - } - - - if(context.enableHandleLifetime ){ - auto result = context.handleLifetime->zesHandleLifetime.zesVFManagementSetVFTelemetryModeExpPrologue( hVFhandle, flags, enable ); - if(result!=ZE_RESULT_SUCCESS) return result; - } - - auto result = pfnSetVFTelemetryModeExp( hVFhandle, flags, enable ); - - for (size_t i = 0; i < numValHandlers; i++) { - auto result = context.validationHandlers[i]->zesValidation->zesVFManagementSetVFTelemetryModeExpEpilogue( hVFhandle, flags, enable ); - if(result!=ZE_RESULT_SUCCESS) return result; - } - - return result; - } - - /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zesVFManagementSetVFTelemetrySamplingIntervalExp - __zedlllocal ze_result_t ZE_APICALL - zesVFManagementSetVFTelemetrySamplingIntervalExp( - zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. - zes_vf_info_util_exp_flags_t flag, ///< [in] utilization flags to set sampling interval. May be 0 or a valid - ///< combination of ::zes_vf_info_util_exp_flag_t. - uint64_t samplingInterval ///< [in] Sampling interval value. - ) - { - auto pfnSetVFTelemetrySamplingIntervalExp = context.zesDdiTable.VFManagementExp.pfnSetVFTelemetrySamplingIntervalExp; - - if( nullptr == pfnSetVFTelemetrySamplingIntervalExp ) - 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->zesVFManagementSetVFTelemetrySamplingIntervalExpPrologue( hVFhandle, flag, samplingInterval ); - if(result!=ZE_RESULT_SUCCESS) return result; - } - - - if( context.enableThreadingValidation ){ - //Unimplemented - } - - - if(context.enableHandleLifetime ){ - auto result = context.handleLifetime->zesHandleLifetime.zesVFManagementSetVFTelemetrySamplingIntervalExpPrologue( hVFhandle, flag, samplingInterval ); - if(result!=ZE_RESULT_SUCCESS) return result; - } - - auto result = pfnSetVFTelemetrySamplingIntervalExp( hVFhandle, flag, samplingInterval ); - - for (size_t i = 0; i < numValHandlers; i++) { - auto result = context.validationHandlers[i]->zesValidation->zesVFManagementSetVFTelemetrySamplingIntervalExpEpilogue( hVFhandle, flag, samplingInterval ); - if(result!=ZE_RESULT_SUCCESS) return result; - } - - return result; - } - } // namespace validation_layer #if defined(__cplusplus) @@ -6453,8 +6365,8 @@ zesGetDeviceExpProcAddrTable( dditable.pfnGetSubDevicePropertiesExp = pDdiTable->pfnGetSubDevicePropertiesExp; pDdiTable->pfnGetSubDevicePropertiesExp = validation_layer::zesDeviceGetSubDevicePropertiesExp; - dditable.pfnEnumActiveVFExp = pDdiTable->pfnEnumActiveVFExp; - pDdiTable->pfnEnumActiveVFExp = validation_layer::zesDeviceEnumActiveVFExp; + dditable.pfnEnumEnabledVFExp = pDdiTable->pfnEnumEnabledVFExp; + pDdiTable->pfnEnumEnabledVFExp = validation_layer::zesDeviceEnumEnabledVFExp; return result; } @@ -7341,8 +7253,8 @@ zesGetVFManagementExpProcAddrTable( ze_result_t result = ZE_RESULT_SUCCESS; - dditable.pfnGetVFPropertiesExp = pDdiTable->pfnGetVFPropertiesExp; - pDdiTable->pfnGetVFPropertiesExp = validation_layer::zesVFManagementGetVFPropertiesExp; + dditable.pfnGetVFCapabilitiesExp = pDdiTable->pfnGetVFCapabilitiesExp; + pDdiTable->pfnGetVFCapabilitiesExp = validation_layer::zesVFManagementGetVFCapabilitiesExp; dditable.pfnGetVFMemoryUtilizationExp = pDdiTable->pfnGetVFMemoryUtilizationExp; pDdiTable->pfnGetVFMemoryUtilizationExp = validation_layer::zesVFManagementGetVFMemoryUtilizationExp; @@ -7350,12 +7262,6 @@ zesGetVFManagementExpProcAddrTable( dditable.pfnGetVFEngineUtilizationExp = pDdiTable->pfnGetVFEngineUtilizationExp; pDdiTable->pfnGetVFEngineUtilizationExp = validation_layer::zesVFManagementGetVFEngineUtilizationExp; - dditable.pfnSetVFTelemetryModeExp = pDdiTable->pfnSetVFTelemetryModeExp; - pDdiTable->pfnSetVFTelemetryModeExp = validation_layer::zesVFManagementSetVFTelemetryModeExp; - - dditable.pfnSetVFTelemetrySamplingIntervalExp = pDdiTable->pfnSetVFTelemetrySamplingIntervalExp; - pDdiTable->pfnSetVFTelemetrySamplingIntervalExp = validation_layer::zesVFManagementSetVFTelemetrySamplingIntervalExp; - return result; } diff --git a/source/layers/validation/zet_valddi.cpp b/source/layers/validation/zet_valddi.cpp index 6488c42..39de982 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 @@ -2157,8 +2667,8 @@ namespace validation_layer __zedlllocal 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. 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 @@ -2182,7 +2692,7 @@ namespace validation_layer auto numValHandlers = context.validationHandlers.size(); for (size_t i = 0; i < numValHandlers; i++) { - auto result = context.validationHandlers[i]->zetValidation->zetMetricCreateFromProgrammableExpPrologue( hMetricProgrammable, pParameterValues, parameterCount, pName, pDescription, pMetricHandleCount, phMetricHandles ); + auto result = context.validationHandlers[i]->zetValidation->zetMetricCreateFromProgrammableExpPrologue( hMetricProgrammable, parameterCount, pParameterValues, pName, pDescription, pMetricHandleCount, phMetricHandles ); if(result!=ZE_RESULT_SUCCESS) return result; } @@ -2193,14 +2703,14 @@ namespace validation_layer if(context.enableHandleLifetime ){ - auto result = context.handleLifetime->zetHandleLifetime.zetMetricCreateFromProgrammableExpPrologue( hMetricProgrammable, pParameterValues, parameterCount, pName, pDescription, pMetricHandleCount, phMetricHandles ); + auto result = context.handleLifetime->zetHandleLifetime.zetMetricCreateFromProgrammableExpPrologue( hMetricProgrammable, parameterCount, pParameterValues, pName, pDescription, pMetricHandleCount, phMetricHandles ); if(result!=ZE_RESULT_SUCCESS) return result; } - auto result = pfnCreateFromProgrammableExp( hMetricProgrammable, pParameterValues, parameterCount, pName, pDescription, pMetricHandleCount, phMetricHandles ); + auto result = pfnCreateFromProgrammableExp( hMetricProgrammable, parameterCount, pParameterValues, pName, pDescription, pMetricHandleCount, phMetricHandles ); for (size_t i = 0; i < numValHandlers; i++) { - auto result = context.validationHandlers[i]->zetValidation->zetMetricCreateFromProgrammableExpEpilogue( hMetricProgrammable, pParameterValues, parameterCount, pName, pDescription, pMetricHandleCount, phMetricHandles ); + auto result = context.validationHandlers[i]->zetValidation->zetMetricCreateFromProgrammableExpEpilogue( hMetricProgrammable, parameterCount, pParameterValues, pName, pDescription, pMetricHandleCount, phMetricHandles ); if(result!=ZE_RESULT_SUCCESS) return result; } @@ -2218,27 +2728,39 @@ namespace validation_layer } /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zetMetricGroupCreateExp + /// @brief Intercept function for zetDeviceCreateMetricGroupsFromMetricsExp __zedlllocal ze_result_t ZE_APICALL - zetMetricGroupCreateExp( - 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 - ///< character array no longer than ::ZET_MAX_METRIC_GROUP_NAME. - const char* pDescription, ///< [in] pointer to metric group description. Must point to a + 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. - zet_metric_group_sampling_type_flags_t samplingType,///< [in] Sampling type for the metric group. - zet_metric_group_handle_t* phMetricGroup ///< [in,out] Created Metric group handle + 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 pfnCreateExp = context.zetDdiTable.MetricGroupExp.pfnCreateExp; + auto pfnCreateMetricGroupsFromMetricsExp = context.zetDdiTable.DeviceExp.pfnCreateMetricGroupsFromMetricsExp; - if( nullptr == pfnCreateExp ) + 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->zetMetricGroupCreateExpPrologue( hDevice, pName, pDescription, samplingType, phMetricGroup ); + auto result = context.validationHandlers[i]->zetValidation->zetDeviceCreateMetricGroupsFromMetricsExpPrologue( hDevice, metricCount, phMetrics, pMetricGroupNamePrefix, pDescription, pMetricGroupCount, phMetricGroup ); if(result!=ZE_RESULT_SUCCESS) return result; } @@ -2249,24 +2771,25 @@ namespace validation_layer if(context.enableHandleLifetime ){ - auto result = context.handleLifetime->zetHandleLifetime.zetMetricGroupCreateExpPrologue( hDevice, pName, pDescription, samplingType, phMetricGroup ); + auto result = context.handleLifetime->zetHandleLifetime.zetDeviceCreateMetricGroupsFromMetricsExpPrologue( hDevice, metricCount, phMetrics, pMetricGroupNamePrefix, pDescription, pMetricGroupCount, phMetricGroup ); if(result!=ZE_RESULT_SUCCESS) return result; } - auto result = pfnCreateExp( hDevice, pName, pDescription, samplingType, phMetricGroup ); + auto result = pfnCreateMetricGroupsFromMetricsExp( hDevice, metricCount, phMetrics, pMetricGroupNamePrefix, pDescription, pMetricGroupCount, phMetricGroup ); for (size_t i = 0; i < numValHandlers; i++) { - auto result = context.validationHandlers[i]->zetValidation->zetMetricGroupCreateExpEpilogue( hDevice, pName, pDescription, samplingType, phMetricGroup ); + 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 ){ - if (phMetricGroup){ - context.handleLifetime->addHandle( *phMetricGroup ); - context.handleLifetime->addDependent( hDevice, *phMetricGroup ); - + 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; @@ -2482,6 +3005,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 +3082,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 +3159,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 @@ -2892,9 +3532,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_libapi.cpp b/source/lib/ze_libapi.cpp index fca47e3..a989820 100644 --- a/source/lib/ze_libapi.cpp +++ b/source/lib/ze_libapi.cpp @@ -130,6 +130,97 @@ 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->initOnce, [flags]() { + result = ze_lib::context->Init(flags, false); + + if( ZE_RESULT_SUCCESS != result ) + 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 ); + return result; + }); + + if(ze_lib::context->inTeardown) { + result = ZE_RESULT_ERROR_UNINITIALIZED; + } + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Returns the API version supported by the specified driver /// @@ -6948,15 +7039,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 +7056,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 +7104,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 +7156,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 +7206,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,16 +7257,312 @@ 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` -/// - ::ZE_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT +/// + `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( ze_context_handle_t hContext, ///< [in] handle of the context object @@ -8684,198 +9074,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 e94c6fe..8fafc55 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 f315116..c9e93e8 100644 --- a/source/lib/zes_libapi.cpp +++ b/source/lib/zes_libapi.cpp @@ -6131,7 +6131,7 @@ zesDriverGetDeviceByUuidExp( /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER /// + `nullptr == pCount` ze_result_t ZE_APICALL -zesDeviceEnumActiveVFExp( +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 @@ -6150,19 +6150,19 @@ zesDeviceEnumActiveVFExp( return ZE_RESULT_ERROR_UNINITIALIZED; } - auto pfnEnumActiveVFExp = ze_lib::context->zesDdiTable.load()->DeviceExp.pfnEnumActiveVFExp; - if( nullptr == pfnEnumActiveVFExp ) { + 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 pfnEnumActiveVFExp( hDevice, pCount, phVFhandle ); + return pfnEnumEnabledVFExp( hDevice, pCount, phVFhandle ); } /////////////////////////////////////////////////////////////////////////////// -/// @brief Get virtual function management properties +/// @brief Get virtual function management capabilities /// /// @details /// - The application may call this function from simultaneous threads. @@ -6177,26 +6177,26 @@ zesDeviceEnumActiveVFExp( /// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE /// + `nullptr == hVFhandle` /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER -/// + `nullptr == pProperties` +/// + `nullptr == pCapability` ze_result_t ZE_APICALL -zesVFManagementGetVFPropertiesExp( +zesVFManagementGetVFCapabilitiesExp( zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. - zes_vf_exp_properties_t* pProperties ///< [in,out] Will contain VF properties. + zes_vf_exp_capabilities_t* pCapability ///< [in,out] Will contain VF capability. ) { if(ze_lib::context->inTeardown) { return ZE_RESULT_ERROR_UNINITIALIZED; } - auto pfnGetVFPropertiesExp = ze_lib::context->zesDdiTable.load()->VFManagementExp.pfnGetVFPropertiesExp; - if( nullptr == pfnGetVFPropertiesExp ) { + 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 pfnGetVFPropertiesExp( hVFhandle, pProperties ); + return pfnGetVFCapabilitiesExp( hVFhandle, pCapability ); } /////////////////////////////////////////////////////////////////////////////// @@ -6206,6 +6206,7 @@ zesVFManagementGetVFPropertiesExp( /// @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 @@ -6226,8 +6227,6 @@ zesVFManagementGetVFMemoryUtilizationExp( ///< - 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. - ///< - The count returned is the sum of number of VF instances currently - ///< available and the PF instance. zes_vf_util_mem_exp_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. @@ -6257,6 +6256,7 @@ zesVFManagementGetVFMemoryUtilizationExp( /// @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 @@ -6277,8 +6277,6 @@ zesVFManagementGetVFEngineUtilizationExp( ///< - 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. - ///< - The count returned is the sum of number of VF instances currently - ///< available and the PF instance. zes_vf_util_engine_exp_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. @@ -6301,86 +6299,4 @@ zesVFManagementGetVFEngineUtilizationExp( return pfnGetVFEngineUtilizationExp( hVFhandle, pCount, pEngineUtil ); } -/////////////////////////////////////////////////////////////////////////////// -/// @brief Configure utilization telemetry enabled or disabled associated with -/// Virtual Function (VF) -/// -/// @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_ENUMERATION -/// + `0xf < flags` -ze_result_t ZE_APICALL -zesVFManagementSetVFTelemetryModeExp( - zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. - zes_vf_info_util_exp_flags_t flags, ///< [in] utilization flags to enable or disable. May be 0 or a valid - ///< combination of ::zes_vf_info_util_exp_flag_t. - ze_bool_t enable ///< [in] Enable utilization telemetry. - ) -{ - if(ze_lib::context->inTeardown) { - return ZE_RESULT_ERROR_UNINITIALIZED; - } - - auto pfnSetVFTelemetryModeExp = ze_lib::context->zesDdiTable.load()->VFManagementExp.pfnSetVFTelemetryModeExp; - if( nullptr == pfnSetVFTelemetryModeExp ) { - if(!ze_lib::context->isInitialized) - return ZE_RESULT_ERROR_UNINITIALIZED; - else - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; - } - - return pfnSetVFTelemetryModeExp( hVFhandle, flags, enable ); -} - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Set sampling interval to monitor for a particular utilization -/// telemetry associated with Virtual Function (VF) -/// -/// @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_ENUMERATION -/// + `0xf < flag` -ze_result_t ZE_APICALL -zesVFManagementSetVFTelemetrySamplingIntervalExp( - zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. - zes_vf_info_util_exp_flags_t flag, ///< [in] utilization flags to set sampling interval. May be 0 or a valid - ///< combination of ::zes_vf_info_util_exp_flag_t. - uint64_t samplingInterval ///< [in] Sampling interval value. - ) -{ - if(ze_lib::context->inTeardown) { - return ZE_RESULT_ERROR_UNINITIALIZED; - } - - auto pfnSetVFTelemetrySamplingIntervalExp = ze_lib::context->zesDdiTable.load()->VFManagementExp.pfnSetVFTelemetrySamplingIntervalExp; - if( nullptr == pfnSetVFTelemetrySamplingIntervalExp ) { - if(!ze_lib::context->isInitialized) - return ZE_RESULT_ERROR_UNINITIALIZED; - else - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; - } - - return pfnSetVFTelemetrySamplingIntervalExp( hVFhandle, flag, samplingInterval ); -} - } // extern "C" diff --git a/source/lib/zet_libapi.cpp b/source/lib/zet_libapi.cpp index 7566134..8a3308c 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 @@ -2107,8 +2578,8 @@ zetMetricProgrammableGetParamValueInfoExp( 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. 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 @@ -2137,15 +2608,20 @@ zetMetricCreateFromProgrammableExp( return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; } - return pfnCreateFromProgrammableExp( hMetricProgrammable, pParameterValues, parameterCount, pName, pDescription, pMetricHandleCount, phMetricHandles ); + return pfnCreateFromProgrammableExp( hMetricProgrammable, parameterCount, pParameterValues, pName, pDescription, pMetricHandleCount, phMetricHandles ); } /////////////////////////////////////////////////////////////////////////////// -/// @brief Create metric group handle. +/// @brief Create multiple metric group handles from metric handles. /// /// @details -/// - Metrics from ::zetMetricCreateFromProgrammableExp() could be added to -/// the created metric group. +/// - Creates multiple metric groups from metrics which were created using +/// ::zetMetricCreateFromProgrammableExp(). +/// - 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 @@ -2155,37 +2631,46 @@ zetMetricCreateFromProgrammableExp( /// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY /// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE /// + `nullptr == hDevice` -/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER -/// + `nullptr == pName` -/// + `nullptr == pDescription` -/// + `nullptr == phMetricGroup` -/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION -/// + `0x3 < samplingType` +/// + `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 -zetMetricGroupCreateExp( - 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 - ///< character array no longer than ::ZET_MAX_METRIC_GROUP_NAME. - const char* pDescription, ///< [in] pointer to metric group description. Must point to a +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. - zet_metric_group_sampling_type_flags_t samplingType,///< [in] Sampling type for the metric group. - zet_metric_group_handle_t* phMetricGroup ///< [in,out] Created Metric group handle + 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 pfnCreateExp = ze_lib::context->zetDdiTable.load()->MetricGroupExp.pfnCreateExp; - if( nullptr == pfnCreateExp ) { + 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 pfnCreateExp( hDevice, pName, pDescription, samplingType, phMetricGroup ); + return pfnCreateMetricGroupsFromMetricsExp( hDevice, metricCount, phMetrics, pMetricGroupNamePrefix, pDescription, pMetricGroupCount, phMetricGroup ); } /////////////////////////////////////////////////////////////////////////////// diff --git a/source/lib/zet_libddi.cpp b/source/lib/zet_libddi.cpp index e6c2633..dbd1f59 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 6576951..caa5ff5 100644 --- a/source/loader/ze_ldrddi.cpp +++ b/source/loader/ze_ldrddi.cpp @@ -109,6 +109,40 @@ namespace loader 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; + + bool atLeastOneDriverValid = false; + for( auto& drv : loader::context->zeDrivers ) + { + if(drv.initStatus != ZE_RESULT_SUCCESS) + continue; + drv.initStatus = drv.dditable.ze.Global.pfnInitDrivers( pCount, phDrivers, desc ); + if(drv.initStatus == ZE_RESULT_SUCCESS) + atLeastOneDriverValid = true; + } + + if(!atLeastOneDriverValid) + result=ZE_RESULT_ERROR_UNINITIALIZED; + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeDriverGetApiVersion __zedlllocal ze_result_t ZE_APICALL @@ -4778,6 +4812,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 +6258,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) @@ -6215,6 +6319,7 @@ zeGetGlobalProcAddrTable( { // return pointers to loader's DDIs pDdiTable->pfnInit = loader::zeInit; + pDdiTable->pfnInitDrivers = loader::zeInitDrivers; } else { @@ -7165,12 +7270,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/zes_ldrddi.cpp b/source/loader/zes_ldrddi.cpp index 0a9d1cd..d0b1ff8 100644 --- a/source/loader/zes_ldrddi.cpp +++ b/source/loader/zes_ldrddi.cpp @@ -4190,9 +4190,9 @@ namespace loader } /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zesDeviceEnumActiveVFExp + /// @brief Intercept function for zesDeviceEnumEnabledVFExp __zedlllocal ze_result_t ZE_APICALL - zesDeviceEnumActiveVFExp( + 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 @@ -4211,15 +4211,15 @@ namespace loader // extract driver's function pointer table auto dditable = reinterpret_cast( hDevice )->dditable; - auto pfnEnumActiveVFExp = dditable->zes.DeviceExp.pfnEnumActiveVFExp; - if( nullptr == pfnEnumActiveVFExp ) + 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 = pfnEnumActiveVFExp( hDevice, pCount, phVFhandle ); + result = pfnEnumEnabledVFExp( hDevice, pCount, phVFhandle ); if( ZE_RESULT_SUCCESS != result ) return result; @@ -4240,26 +4240,26 @@ namespace loader } /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zesVFManagementGetVFPropertiesExp + /// @brief Intercept function for zesVFManagementGetVFCapabilitiesExp __zedlllocal ze_result_t ZE_APICALL - zesVFManagementGetVFPropertiesExp( + zesVFManagementGetVFCapabilitiesExp( zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. - zes_vf_exp_properties_t* pProperties ///< [in,out] Will contain VF properties. + 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 pfnGetVFPropertiesExp = dditable->zes.VFManagementExp.pfnGetVFPropertiesExp; - if( nullptr == pfnGetVFPropertiesExp ) + 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 = pfnGetVFPropertiesExp( hVFhandle, pProperties ); + result = pfnGetVFCapabilitiesExp( hVFhandle, pCapability ); return result; } @@ -4275,8 +4275,6 @@ namespace loader ///< - 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. - ///< - The count returned is the sum of number of VF instances currently - ///< available and the PF instance. zes_vf_util_mem_exp_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. @@ -4312,8 +4310,6 @@ namespace loader ///< - 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. - ///< - The count returned is the sum of number of VF instances currently - ///< available and the PF instance. zes_vf_util_engine_exp_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. @@ -4338,60 +4334,6 @@ namespace loader return result; } - /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zesVFManagementSetVFTelemetryModeExp - __zedlllocal ze_result_t ZE_APICALL - zesVFManagementSetVFTelemetryModeExp( - zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. - zes_vf_info_util_exp_flags_t flags, ///< [in] utilization flags to enable or disable. May be 0 or a valid - ///< combination of ::zes_vf_info_util_exp_flag_t. - ze_bool_t enable ///< [in] Enable utilization telemetry. - ) - { - ze_result_t result = ZE_RESULT_SUCCESS; - - // extract driver's function pointer table - auto dditable = reinterpret_cast( hVFhandle )->dditable; - auto pfnSetVFTelemetryModeExp = dditable->zes.VFManagementExp.pfnSetVFTelemetryModeExp; - if( nullptr == pfnSetVFTelemetryModeExp ) - return ZE_RESULT_ERROR_UNINITIALIZED; - - // convert loader handle to driver handle - hVFhandle = reinterpret_cast( hVFhandle )->handle; - - // forward to device-driver - result = pfnSetVFTelemetryModeExp( hVFhandle, flags, enable ); - - return result; - } - - /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zesVFManagementSetVFTelemetrySamplingIntervalExp - __zedlllocal ze_result_t ZE_APICALL - zesVFManagementSetVFTelemetrySamplingIntervalExp( - zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the component. - zes_vf_info_util_exp_flags_t flag, ///< [in] utilization flags to set sampling interval. May be 0 or a valid - ///< combination of ::zes_vf_info_util_exp_flag_t. - uint64_t samplingInterval ///< [in] Sampling interval value. - ) - { - ze_result_t result = ZE_RESULT_SUCCESS; - - // extract driver's function pointer table - auto dditable = reinterpret_cast( hVFhandle )->dditable; - auto pfnSetVFTelemetrySamplingIntervalExp = dditable->zes.VFManagementExp.pfnSetVFTelemetrySamplingIntervalExp; - if( nullptr == pfnSetVFTelemetrySamplingIntervalExp ) - return ZE_RESULT_ERROR_UNINITIALIZED; - - // convert loader handle to driver handle - hVFhandle = reinterpret_cast( hVFhandle )->handle; - - // forward to device-driver - result = pfnSetVFTelemetrySamplingIntervalExp( hVFhandle, flag, samplingInterval ); - - return result; - } - } // namespace loader #if defined(__cplusplus) @@ -4636,7 +4578,7 @@ zesGetDeviceExpProcAddrTable( { // return pointers to loader's DDIs pDdiTable->pfnGetSubDevicePropertiesExp = loader::zesDeviceGetSubDevicePropertiesExp; - pDdiTable->pfnEnumActiveVFExp = loader::zesDeviceEnumActiveVFExp; + pDdiTable->pfnEnumEnabledVFExp = loader::zesDeviceEnumEnabledVFExp; } else { @@ -6279,11 +6221,9 @@ zesGetVFManagementExpProcAddrTable( if( ( loader::context->sysmanInstanceDrivers->size() > 1 ) || loader::context->forceIntercept ) { // return pointers to loader's DDIs - pDdiTable->pfnGetVFPropertiesExp = loader::zesVFManagementGetVFPropertiesExp; + pDdiTable->pfnGetVFCapabilitiesExp = loader::zesVFManagementGetVFCapabilitiesExp; pDdiTable->pfnGetVFMemoryUtilizationExp = loader::zesVFManagementGetVFMemoryUtilizationExp; pDdiTable->pfnGetVFEngineUtilizationExp = loader::zesVFManagementGetVFEngineUtilizationExp; - pDdiTable->pfnSetVFTelemetryModeExp = loader::zesVFManagementSetVFTelemetryModeExp; - pDdiTable->pfnSetVFTelemetrySamplingIntervalExp = loader::zesVFManagementSetVFTelemetrySamplingIntervalExp; } else { diff --git a/source/loader/zet_ldrddi.cpp b/source/loader/zet_ldrddi.cpp index b506d45..b97d8f5 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 @@ -1560,8 +1949,8 @@ namespace loader __zedlllocal 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. 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 @@ -1590,7 +1979,7 @@ namespace loader hMetricProgrammable = reinterpret_cast( hMetricProgrammable )->handle; // forward to device-driver - result = pfnCreateFromProgrammableExp( hMetricProgrammable, pParameterValues, parameterCount, pName, pDescription, pMetricHandleCount, phMetricHandles ); + result = pfnCreateFromProgrammableExp( hMetricProgrammable, parameterCount, pParameterValues, pName, pDescription, pMetricHandleCount, phMetricHandles ); if( ZE_RESULT_SUCCESS != result ) return result; @@ -1611,41 +2000,54 @@ namespace loader } /////////////////////////////////////////////////////////////////////////////// - /// @brief Intercept function for zetMetricGroupCreateExp + /// @brief Intercept function for zetDeviceCreateMetricGroupsFromMetricsExp __zedlllocal ze_result_t ZE_APICALL - zetMetricGroupCreateExp( - 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 - ///< character array no longer than ::ZET_MAX_METRIC_GROUP_NAME. - const char* pDescription, ///< [in] pointer to metric group description. Must point to a + 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. - zet_metric_group_sampling_type_flags_t samplingType,///< [in] Sampling type for the metric group. - zet_metric_group_handle_t* phMetricGroup ///< [in,out] Created Metric group handle + 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 pfnCreateExp = dditable->zet.MetricGroupExp.pfnCreateExp; - if( nullptr == pfnCreateExp ) + 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 = pfnCreateExp( hDevice, pName, pDescription, samplingType, phMetricGroup ); + result = pfnCreateMetricGroupsFromMetricsExp( hDevice, metricCount, phMetrics, pMetricGroupNamePrefix, pDescription, pMetricGroupCount, phMetricGroup ); if( ZE_RESULT_SUCCESS != result ) return result; try { - // convert driver handle to loader handle - *phMetricGroup = reinterpret_cast( - context->zet_metric_group_factory.getInstance( *phMetricGroup, dditable ) ); + // 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& ) { @@ -1796,6 +2198,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 +2337,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 +2485,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 @@ -2608,7 +3219,6 @@ zetGetMetricGroupExpProcAddrTable( 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 b6e2dd4..548dfbc 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 >; From c4e775f07c0e512221853e1e9495205932426fd0 Mon Sep 17 00:00:00 2001 From: "Neil R. Spruit" Date: Tue, 10 Sep 2024 15:12:52 -0700 Subject: [PATCH 2/9] Add factories for new metric handle types Signed-off-by: Neil R. Spruit --- source/loader/ze_loader_internal.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/loader/ze_loader_internal.h b/source/loader/ze_loader_internal.h index b5b0679..ee42636 100644 --- a/source/loader/ze_loader_internal.h +++ b/source/loader/ze_loader_internal.h @@ -95,6 +95,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; From 528faadd6eb3f1f5f6b00ef06b6e0c095d58d7e2 Mon Sep 17 00:00:00 2001 From: "Neil R. Spruit" Date: Tue, 10 Sep 2024 15:09:00 -0700 Subject: [PATCH 3/9] Add support for zeInitDrivers Signed-off-by: Neil R. Spruit --- scripts/templates/ldrddi.cpp.mako | 14 +++- scripts/templates/libapi.cpp.mako | 37 +++++++++- source/lib/ze_lib.cpp | 4 +- source/lib/ze_lib.h | 3 +- source/lib/ze_libapi.cpp | 43 ++++++------ source/lib/zes_libapi.cpp | 2 +- source/loader/ze_ldrddi.cpp | 52 ++++++++++++-- source/loader/ze_loader.cpp | 107 +++++++++++++++++++++-------- source/loader/ze_loader_api.cpp | 4 +- source/loader/ze_loader_api.h | 2 +- source/loader/ze_loader_internal.h | 4 +- 11 files changed, 205 insertions(+), 67 deletions(-) diff --git a/scripts/templates/ldrddi.cpp.mako b/scripts/templates/ldrddi.cpp.mako index 8410f5c..503bae8 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,21 @@ 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; + %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,7 +93,11 @@ 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; try diff --git a/scripts/templates/libapi.cpp.mako b/scripts/templates/libapi.cpp.mako index f61ae4a..db51193 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/source/lib/ze_lib.cpp b/source/lib/ze_lib.cpp index cfa3bb2..fc0e188 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 77f53c4..7358993 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 a989820..c49f031 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; @@ -192,30 +192,33 @@ zeInitDrivers( ) { static ze_result_t result = ZE_RESULT_SUCCESS; - std::call_once(ze_lib::context->initOnce, [flags]() { - result = ze_lib::context->Init(flags, false); + 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_RESULT_SUCCESS != result ) - return result; + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } - if(ze_lib::context->inTeardown) { + auto pfnInitDrivers = ze_lib::context->zeDdiTable.load()->Global.pfnInitDrivers; + if( nullptr == pfnInitDrivers ) { + if(!ze_lib::context->isInitialized) 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; - } + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } - result = pfnInitDrivers( pCount, phDrivers, desc ); - return result; - }); + result = pfnInitDrivers( pCount, phDrivers, desc ); - if(ze_lib::context->inTeardown) { - result = ZE_RESULT_ERROR_UNINITIALIZED; + if (result == ZE_RESULT_SUCCESS) { + if (phDrivers) { + ze_lib::context->zeInuse = true; + } } return result; diff --git a/source/lib/zes_libapi.cpp b/source/lib/zes_libapi.cpp index c9e93e8..79ebe66 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); }); diff --git a/source/loader/ze_ldrddi.cpp b/source/loader/ze_ldrddi.cpp index caa5ff5..27832f1 100644 --- a/source/loader/ze_ldrddi.cpp +++ b/source/loader/ze_ldrddi.cpp @@ -127,18 +127,56 @@ namespace loader { ze_result_t result = ZE_RESULT_SUCCESS; - bool atLeastOneDriverValid = false; + uint32_t total_driver_handle_count = 0; + for( auto& drv : loader::context->zeDrivers ) { - if(drv.initStatus != ZE_RESULT_SUCCESS) + + 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; - drv.initStatus = drv.dditable.ze.Global.pfnInitDrivers( pCount, phDrivers, desc ); - if(drv.initStatus == ZE_RESULT_SUCCESS) - atLeastOneDriverValid = true; + } + + 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; + + 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(!atLeastOneDriverValid) - result=ZE_RESULT_ERROR_UNINITIALIZED; + // 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; } diff --git a/source/loader/ze_loader.cpp b/source/loader/ze_loader.cpp index 3bbd47f..eafebe2 100644 --- a/source/loader/ze_loader.cpp +++ b/source/loader/ze_loader.cpp @@ -124,14 +124,35 @@ 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 = "Driver Type Flags="; + 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|"; + } + flags_value + "\n"; + 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,7 +165,7 @@ 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 "; @@ -170,7 +191,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 +254,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; } - return ZE_RESULT_ERROR_UNINITIALIZED; - } - auto pfnInit = global.pfnInit; - if(nullptr == pfnInit || globalInitStored->pfnInit == nullptr) { + 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; + } + + // 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.initStatus != ZE_RESULT_SUCCESS) { + res = driver.initStatus; + } + 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 d86d92c..a94daa9 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 590f143..4459602 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 ee42636..445c26a 100644 --- a/source/loader/ze_loader_internal.h +++ b/source/loader/ze_loader_internal.h @@ -117,10 +117,10 @@ namespace loader 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; From 77710c89197f4aa73088d77dd8cbcbfe0a514feb Mon Sep 17 00:00:00 2001 From: "Neil R. Spruit" Date: Thu, 12 Sep 2024 15:51:29 -0700 Subject: [PATCH 4/9] Add driver init check and init tests Signed-off-by: Neil R. Spruit --- scripts/templates/ldrddi.cpp.mako | 2 + scripts/templates/nullddi.cpp.mako | 28 +++++ source/drivers/null/ze_nullddi.cpp | 23 ++++ source/drivers/null/zes_nullddi.cpp | 12 ++ source/drivers/null/zet_nullddi.cpp | 1 + source/loader/ze_ldrddi.cpp | 4 + source/loader/ze_loader.cpp | 18 +-- source/loader/ze_loader_internal.h | 1 + source/loader/zes_ldrddi.cpp | 2 + test/loader_api.cpp | 178 ++++++++++++++++++++++++++++ 10 files changed, 262 insertions(+), 7 deletions(-) diff --git a/scripts/templates/ldrddi.cpp.mako b/scripts/templates/ldrddi.cpp.mako index 503bae8..8853a9f 100644 --- a/scripts/templates/ldrddi.cpp.mako +++ b/scripts/templates/ldrddi.cpp.mako @@ -100,6 +100,8 @@ namespace loader %endif if( ${X}_RESULT_SUCCESS != result ) break; + drv.driverInuse = true; + try { for( uint32_t i = 0; i < library_driver_handle_count; ++i ) { diff --git a/scripts/templates/nullddi.cpp.mako b/scripts/templates/nullddi.cpp.mako index 8b32a46..3ba679c 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,33 @@ 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; + } + } + %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/source/drivers/null/ze_nullddi.cpp b/source/drivers/null/ze_nullddi.cpp index 130c745..54ab0a7 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; @@ -95,6 +107,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 (!(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; + } + } for( size_t i = 0; ( nullptr != phDrivers ) && ( i < *pCount ); ++i ) phDrivers[ i ] = reinterpret_cast( context.get() ); diff --git a/source/drivers/null/zes_nullddi.cpp b/source/drivers/null/zes_nullddi.cpp index 5e8337c..3717dd7 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; diff --git a/source/drivers/null/zet_nullddi.cpp b/source/drivers/null/zet_nullddi.cpp index ef4757b..b85ecab 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 { diff --git a/source/loader/ze_ldrddi.cpp b/source/loader/ze_ldrddi.cpp index 27832f1..7d1d5e6 100644 --- a/source/loader/ze_ldrddi.cpp +++ b/source/loader/ze_ldrddi.cpp @@ -82,6 +82,8 @@ 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 ) { @@ -154,6 +156,8 @@ namespace loader 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 ) { diff --git a/source/loader/ze_loader.cpp b/source/loader/ze_loader.cpp index eafebe2..8b957cc 100644 --- a/source/loader/ze_loader.cpp +++ b/source/loader/ze_loader.cpp @@ -171,16 +171,20 @@ namespace loader 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. + if (!it->driverInuse) { + 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(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++; } } diff --git a/source/loader/ze_loader_internal.h b/source/loader/ze_loader_internal.h index 445c26a..4ecdd33 100644 --- a/source/loader/ze_loader_internal.h +++ b/source/loader/ze_loader_internal.h @@ -33,6 +33,7 @@ namespace loader ze_result_t initStatus = ZE_RESULT_SUCCESS; dditable_t dditable = {}; std::string name; + bool driverInuse = false; }; using driver_vector_t = std::vector< driver_t >; diff --git a/source/loader/zes_ldrddi.cpp b/source/loader/zes_ldrddi.cpp index d0b1ff8..bbc8862 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 ) { diff --git a/test/loader_api.cpp b/test/loader_api.cpp index 4fdf8e1..fc5db00 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,176 @@ TEST( } } +TEST( + LoaderAPI, + 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( + LoaderAPI, + 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( + LoaderAPI, + 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( + LoaderAPI, + 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( + LoaderAPI, + 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( + LoaderAPI, + 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( + LoaderAPI, + 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( + LoaderAPI, + 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( + LoaderAPI, + 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); +} + +TEST( + LoaderAPI, + GivenLevelZeroLoaderPresentWhenCallingzeInitThenZeInitDriversThenOnlyOneSucceedsforGPUTypes) { + + 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_ERROR_UNINITIALIZED, zeInit(ZE_INIT_FLAG_VPU_ONLY)); + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc)); + EXPECT_GT(pCount, 0); +} + +TEST( + LoaderAPI, + GivenLevelZeroLoaderPresentWhenCallingzeInitThenZeInitDriversThenOnlyOneSucceedsforNPUTypes) { + + 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_ERROR_UNINITIALIZED, zeInit(ZE_INIT_FLAG_GPU_ONLY)); + EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc)); + EXPECT_GT(pCount, 0); +} + } // namespace From 95bd4333858266f324f0e2ccc7316dd2e66b38e8 Mon Sep 17 00:00:00 2001 From: "Neil R. Spruit" Date: Fri, 13 Sep 2024 11:34:05 -0700 Subject: [PATCH 5/9] Fix null driver zeInitDrivers count and tests Signed-off-by: Neil R. Spruit --- scripts/templates/ldrddi.cpp.mako | 5 +++++ scripts/templates/nullddi.cpp.mako | 4 ++++ source/drivers/null/ze_nullddi.cpp | 4 ++++ source/loader/ze_ldrddi.cpp | 4 ++++ test/CMakeLists.txt | 26 ++++++++++++++++++++++++-- test/loader_api.cpp | 22 +++++++++++----------- 6 files changed, 52 insertions(+), 13 deletions(-) diff --git a/scripts/templates/ldrddi.cpp.mako b/scripts/templates/ldrddi.cpp.mako index 8853a9f..1950229 100644 --- a/scripts/templates/ldrddi.cpp.mako +++ b/scripts/templates/ldrddi.cpp.mako @@ -68,6 +68,11 @@ namespace loader %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)) diff --git a/scripts/templates/nullddi.cpp.mako b/scripts/templates/nullddi.cpp.mako index 3ba679c..5a7dc9a 100644 --- a/scripts/templates/nullddi.cpp.mako +++ b/scripts/templates/nullddi.cpp.mako @@ -60,6 +60,10 @@ namespace driver 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) { diff --git a/source/drivers/null/ze_nullddi.cpp b/source/drivers/null/ze_nullddi.cpp index 54ab0a7..6e21936 100644 --- a/source/drivers/null/ze_nullddi.cpp +++ b/source/drivers/null/ze_nullddi.cpp @@ -118,6 +118,10 @@ namespace driver 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() ); diff --git a/source/loader/ze_ldrddi.cpp b/source/loader/ze_ldrddi.cpp index 7d1d5e6..a2c296d 100644 --- a/source/loader/ze_ldrddi.cpp +++ b/source/loader/ze_ldrddi.cpp @@ -133,6 +133,10 @@ namespace loader 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; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5b1f0e2..334efea 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -18,5 +18,27 @@ 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") +add_test(NAME tests_only_one_gpu COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWhenCallingzeInitThenZeInitDriversThenOnlyOneSucceedsforGPUTypes*) +set_property(TEST tests_only_one_gpu PROPERTY ENVIRONMENT "ZE_ENABLE_NULL_DRIVER=1") +add_test(NAME tests_only_one_npu COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWhenCallingzeInitThenZeInitDriversThenOnlyOneSucceedsforNPUTypes*) +set_property(TEST tests_only_one_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 fc5db00..ca55798 100644 --- a/test/loader_api.cpp +++ b/test/loader_api.cpp @@ -49,7 +49,7 @@ TEST( } TEST( - LoaderAPI, + LoaderInit, GivenLevelZeroLoaderPresentWhenCallingZeInitDriversWithGPUTypeThenExpectPassWithGPUorAllOnly) { uint32_t pCount = 0; @@ -68,7 +68,7 @@ TEST( } TEST( - LoaderAPI, + LoaderInit, GivenLevelZeroLoaderPresentWhenCallingZeInitDriversWithNPUTypeThenExpectPassWithNPUorAllOnly) { uint32_t pCount = 0; @@ -87,7 +87,7 @@ TEST( } TEST( - LoaderAPI, + LoaderInit, GivenLevelZeroLoaderPresentWhenCallingZeInitDriversWithAnyTypeWithNullDriverAcceptingAllThenExpectatLeast1Driver) { uint32_t pCount = 0; @@ -109,7 +109,7 @@ TEST( } TEST( - LoaderAPI, + LoaderInit, GivenLevelZeroLoaderPresentWhenCallingZeInitDriversThenzeInitThenBothCallsSucceedWithAllTypes) { uint32_t pCount = 0; @@ -123,7 +123,7 @@ TEST( } TEST( - LoaderAPI, + LoaderInit, GivenLevelZeroLoaderPresentWhenCallingZeInitDriversThenzeInitThenBothCallsSucceedWithGPUTypes) { uint32_t pCount = 0; @@ -137,7 +137,7 @@ TEST( } TEST( - LoaderAPI, + LoaderInit, GivenLevelZeroLoaderPresentWhenCallingZeInitDriversThenzeInitThenBothCallsSucceedWithNPUTypes) { uint32_t pCount = 0; @@ -151,7 +151,7 @@ TEST( } TEST( - LoaderAPI, + LoaderInit, GivenLevelZeroLoaderPresentWhenCallingzeInitThenZeInitDriversThenBothCallsSucceedWithAllTypes) { uint32_t pCount = 0; @@ -165,7 +165,7 @@ TEST( } TEST( - LoaderAPI, + LoaderInit, GivenLevelZeroLoaderPresentWhenCallingzeInitThenZeInitDriversThenBothCallsSucceedWithGPUTypes) { uint32_t pCount = 0; @@ -179,7 +179,7 @@ TEST( } TEST( - LoaderAPI, + LoaderInit, GivenLevelZeroLoaderPresentWhenCallingzeInitThenZeInitDriversThenBothCallsSucceedWithNPUTypes) { uint32_t pCount = 0; @@ -193,7 +193,7 @@ TEST( } TEST( - LoaderAPI, + LoaderInit, GivenLevelZeroLoaderPresentWhenCallingzeInitThenZeInitDriversThenOnlyOneSucceedsforGPUTypes) { uint32_t pCount = 0; @@ -207,7 +207,7 @@ TEST( } TEST( - LoaderAPI, + LoaderInit, GivenLevelZeroLoaderPresentWhenCallingzeInitThenZeInitDriversThenOnlyOneSucceedsforNPUTypes) { uint32_t pCount = 0; From 418ce2907bacb73ac909759be4069489c9de3546 Mon Sep 17 00:00:00 2001 From: "Neil R. Spruit" Date: Fri, 13 Sep 2024 14:12:35 -0700 Subject: [PATCH 6/9] Prevent driver removal if initDrivers support exists Signed-off-by: Neil R. Spruit --- scripts/templates/ldrddi.cpp.mako | 7 +++++++ source/loader/ze_ldrddi.cpp | 3 +++ source/loader/ze_loader.cpp | 11 ++++++----- source/loader/ze_loader_internal.h | 1 + 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/scripts/templates/ldrddi.cpp.mako b/scripts/templates/ldrddi.cpp.mako index 1950229..f4f14d1 100644 --- a/scripts/templates/ldrddi.cpp.mako +++ b/scripts/templates/ldrddi.cpp.mako @@ -364,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/source/loader/ze_ldrddi.cpp b/source/loader/ze_ldrddi.cpp index a2c296d..ba93026 100644 --- a/source/loader/ze_ldrddi.cpp +++ b/source/loader/ze_ldrddi.cpp @@ -6352,6 +6352,9 @@ zeGetGlobalProcAddrTable( atLeastOneDriverValid = true; else drv.initStatus = getTableResult; + if (drv.dditable.ze.Global.pfnInitDrivers) { + loader::context->initDriversSupport = true; + } } if(!atLeastOneDriverValid) diff --git a/source/loader/ze_loader.cpp b/source/loader/ze_loader.cpp index 8b957cc..ae225e3 100644 --- a/source/loader/ze_loader.cpp +++ b/source/loader/ze_loader.cpp @@ -167,12 +167,13 @@ namespace loader std::string freeLibraryErrorValue; 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)); - } // If the driver has already been init and handles are to be read, then this driver cannot be removed from the list. - if (!it->driverInuse) { + // 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. diff --git a/source/loader/ze_loader_internal.h b/source/loader/ze_loader_internal.h index 4ecdd33..2b624a3 100644 --- a/source/loader/ze_loader_internal.h +++ b/source/loader/ze_loader_internal.h @@ -115,6 +115,7 @@ namespace loader bool driverEnvironmentQueried = false; bool forceIntercept = false; + bool initDriversSupport = false; std::vector compVersions; const char *LOADER_COMP_NAME = "loader"; From e8975fef23ae2a48528f2db31955133e866ae973 Mon Sep 17 00:00:00 2001 From: "Neil R. Spruit" Date: Fri, 13 Sep 2024 14:15:37 -0700 Subject: [PATCH 7/9] Fix ze_init_driver_type_desc_t to string function Signed-off-by: Neil R. Spruit --- source/loader/ze_loader.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/loader/ze_loader.cpp b/source/loader/ze_loader.cpp index ae225e3..da97ef8 100644 --- a/source/loader/ze_loader.cpp +++ b/source/loader/ze_loader.cpp @@ -125,14 +125,13 @@ namespace loader } std::string to_string(const ze_init_driver_type_desc_t *desc) { - std::string flags_value = "Driver Type Flags="; + std::string flags_value; if (desc->flags & ZE_INIT_DRIVER_TYPE_FLAG_GPU) { - flags_value + "|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|"; + flags_value+= "|ZE_INIT_DRIVER_TYPE_FLAG_NPU|"; } - flags_value + "\n"; return flags_value; } From b9b76604e7c569d0f1d838fd45ec77f48e5a6bd6 Mon Sep 17 00:00:00 2001 From: "Neil R. Spruit" Date: Fri, 13 Sep 2024 14:28:28 -0700 Subject: [PATCH 8/9] create compat header for 1.10 abi breakage Signed-off-by: Neil R. Spruit --- source/lib/CMakeLists.txt | 1 + source/lib/ze_lib.h | 9 +++++---- source/lib/zes_libddi.cpp | 4 ++-- source/lib/zet_libddi.cpp | 2 +- source/loader/ze_object.h | 5 +++-- source/loader/zes_ldrddi.cpp | 8 ++++---- source/loader/zet_ldrddi.cpp | 4 ++-- 7 files changed, 18 insertions(+), 15 deletions(-) diff --git a/source/lib/CMakeLists.txt b/source/lib/CMakeLists.txt index 7ba6d10..72cb379 100644 --- a/source/lib/CMakeLists.txt +++ b/source/lib/CMakeLists.txt @@ -13,6 +13,7 @@ target_sources(${TARGET_LOADER_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/ze_lib.h ${CMAKE_CURRENT_SOURCE_DIR}/ze_lib.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ze_tracing_register_cb_libapi.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ze_loader_compat.h ) diff --git a/source/lib/ze_lib.h b/source/lib/ze_lib.h index 7358993..fae11e1 100644 --- a/source/lib/ze_lib.h +++ b/source/lib/ze_lib.h @@ -20,6 +20,7 @@ #include #include #include +#include "ze_loader_compat.h" namespace ze_lib { @@ -44,17 +45,17 @@ namespace ze_lib std::atomic zeDdiTable = {nullptr}; ze_result_t zetDdiTableInit(); - std::atomic zetDdiTable = {nullptr}; + std::atomic zetDdiTable = {nullptr}; ze_result_t zesDdiTableInit(); - std::atomic zesDdiTable = {nullptr}; + std::atomic zesDdiTable = {nullptr}; ze_result_t zelTracingDdiTableInit(); zel_tracing_dditable_t zelTracingDdiTable = {}; std::atomic pTracingZeDdiTable = {nullptr}; ze_dditable_t initialzeDdiTable; - zet_dditable_t initialzetDdiTable; - zes_dditable_t initialzesDdiTable; + zet_dditable_compat_t initialzetDdiTable; + zes_dditable_compat_t initialzesDdiTable; std::atomic_uint32_t tracingLayerEnableCounter{0}; HMODULE tracing_lib = nullptr; diff --git a/source/lib/zes_libddi.cpp b/source/lib/zes_libddi.cpp index 48bad20..4db1564 100644 --- a/source/lib/zes_libddi.cpp +++ b/source/lib/zes_libddi.cpp @@ -208,7 +208,7 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - result = zesGetDeviceExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.DeviceExp ); + result = zesGetDeviceExpProcAddrTable( ZE_API_VERSION_CURRENT, reinterpret_cast(&initialzesDdiTable.DeviceExp) ); } if( ZE_RESULT_SUCCESS == result ) @@ -313,7 +313,7 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - result = zesGetVFManagementExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.VFManagementExp ); + result = zesGetVFManagementExpProcAddrTable( ZE_API_VERSION_CURRENT, reinterpret_cast(&initialzesDdiTable.VFManagementExp) ); } return result; diff --git a/source/lib/zet_libddi.cpp b/source/lib/zet_libddi.cpp index dbd1f59..0947f7b 100644 --- a/source/lib/zet_libddi.cpp +++ b/source/lib/zet_libddi.cpp @@ -221,7 +221,7 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - result = zetGetMetricGroupExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricGroupExp ); + result = zetGetMetricGroupExpProcAddrTable( ZE_API_VERSION_CURRENT, reinterpret_cast< zet_metric_group_exp_dditable_t *>(&initialzetDdiTable.MetricGroupExp) ); } if( ZE_RESULT_SUCCESS == result ) diff --git a/source/loader/ze_object.h b/source/loader/ze_object.h index 0420e73..860db1d 100644 --- a/source/loader/ze_object.h +++ b/source/loader/ze_object.h @@ -9,13 +9,14 @@ */ #pragma once #include "ze_singleton.h" +#include "../lib/ze_loader_compat.h" ////////////////////////////////////////////////////////////////////////// struct dditable_t { ze_dditable_t ze; - zet_dditable_t zet; - zes_dditable_t zes; + zet_dditable_compat_t zet; + zes_dditable_compat_t zes; }; ////////////////////////////////////////////////////////////////////////// diff --git a/source/loader/zes_ldrddi.cpp b/source/loader/zes_ldrddi.cpp index bbc8862..c25542a 100644 --- a/source/loader/zes_ldrddi.cpp +++ b/source/loader/zes_ldrddi.cpp @@ -4570,7 +4570,7 @@ zesGetDeviceExpProcAddrTable( GET_FUNCTION_PTR( drv.handle, "zesGetDeviceExpProcAddrTable") ); if(!getTable) continue; - result = getTable( version, &drv.dditable.zes.DeviceExp); + result = getTable( version, reinterpret_cast(&drv.dditable.zes.DeviceExp)); } @@ -4585,7 +4585,7 @@ zesGetDeviceExpProcAddrTable( else { // return pointers directly to driver's DDIs - *pDdiTable = loader::context->sysmanInstanceDrivers->front().dditable.zes.DeviceExp; + pDdiTable = reinterpret_cast(&loader::context->sysmanInstanceDrivers->front().dditable.zes.DeviceExp); } } @@ -6214,7 +6214,7 @@ zesGetVFManagementExpProcAddrTable( GET_FUNCTION_PTR( drv.handle, "zesGetVFManagementExpProcAddrTable") ); if(!getTable) continue; - result = getTable( version, &drv.dditable.zes.VFManagementExp); + result = getTable( version, reinterpret_cast(&drv.dditable.zes.VFManagementExp)); } @@ -6230,7 +6230,7 @@ zesGetVFManagementExpProcAddrTable( else { // return pointers directly to driver's DDIs - *pDdiTable = loader::context->sysmanInstanceDrivers->front().dditable.zes.VFManagementExp; + pDdiTable = reinterpret_cast(&loader::context->sysmanInstanceDrivers->front().dditable.zes.VFManagementExp); } } diff --git a/source/loader/zet_ldrddi.cpp b/source/loader/zet_ldrddi.cpp index b97d8f5..91e2ae3 100644 --- a/source/loader/zet_ldrddi.cpp +++ b/source/loader/zet_ldrddi.cpp @@ -3206,7 +3206,7 @@ zetGetMetricGroupExpProcAddrTable( GET_FUNCTION_PTR( drv.handle, "zetGetMetricGroupExpProcAddrTable") ); if(!getTable) continue; - result = getTable( version, &drv.dditable.zet.MetricGroupExp); + result = getTable( version, reinterpret_cast(&drv.dditable.zet.MetricGroupExp)); } @@ -3227,7 +3227,7 @@ zetGetMetricGroupExpProcAddrTable( else { // return pointers directly to driver's DDIs - *pDdiTable = loader::context->zeDrivers.front().dditable.zet.MetricGroupExp; + pDdiTable = reinterpret_cast(&loader::context->zeDrivers.front().dditable.zet.MetricGroupExp); } } From d25d48ccb8d2d354ced9c640c579cb4e1f59ee9c Mon Sep 17 00:00:00 2001 From: "Neil R. Spruit" Date: Fri, 13 Sep 2024 15:37:55 -0700 Subject: [PATCH 9/9] Fix init type coexistence and fix init recursion error Signed-off-by: Neil R. Spruit --- source/lib/ze_loader_compat.h | 162 +++++++++++++++++++++++++++++ source/loader/ze_ldrddi.cpp | 6 +- source/loader/ze_loader.cpp | 6 +- source/loader/ze_loader_internal.h | 1 + test/CMakeLists.txt | 6 +- test/loader_api.cpp | 28 ----- 6 files changed, 172 insertions(+), 37 deletions(-) create mode 100644 source/lib/ze_loader_compat.h diff --git a/source/lib/ze_loader_compat.h b/source/lib/ze_loader_compat.h new file mode 100644 index 0000000..56f17e8 --- /dev/null +++ b/source/lib/ze_loader_compat.h @@ -0,0 +1,162 @@ +/* + * + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ +#pragma once + +#include "ze_ddi.h" +#include "zet_ddi.h" +#include "zes_ddi.h" + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zesDeviceEnumActiveVFExp +typedef ze_result_t (ZE_APICALL *zes_pfnDeviceEnumActiveVFExp_t)( + zes_device_handle_t, + uint32_t*, + zes_vf_handle_t* + ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Table of DeviceExp functions pointers +typedef struct _zes_device_exp_dditable_compat_t +{ + zes_pfnDeviceGetSubDevicePropertiesExp_t pfnGetSubDevicePropertiesExp; + zes_pfnDeviceEnumActiveVFExp_t pfnEnumActiveVFExp; + zes_pfnDeviceEnumEnabledVFExp_t pfnEnumEnabledVFExp; +} zes_device_exp_dditable_compat_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Virtual function utilization flag bit fields +typedef uint32_t zes_vf_info_util_exp_flags_t; +typedef enum _zes_vf_info_util_exp_flag_t +{ + ZES_VF_INFO_UTIL_EXP_FLAG_INFO_NONE = ZE_BIT(0), ///< No info associated with virtual function + ZES_VF_INFO_UTIL_EXP_FLAG_INFO_MEM_CPU = ZE_BIT(1), ///< System memory utilization associated with virtual function + ZES_VF_INFO_UTIL_EXP_FLAG_INFO_MEM_GPU = ZE_BIT(2), ///< Device memory utilization associated with virtual function + ZES_VF_INFO_UTIL_EXP_FLAG_INFO_ENGINE = ZE_BIT(3), ///< Engine utilization associated with virtual function + ZES_VF_INFO_UTIL_EXP_FLAG_FORCE_UINT32 = 0x7fffffff + +} zes_vf_info_util_exp_flag_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Virtual function management properties +typedef struct _zes_vf_exp_properties_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 + zes_uuid_t uuid; ///< [out] universal unique identifier of the device + zes_vf_info_util_exp_flags_t flags; ///< [out] utilization flags available. May be 0 or a valid combination of + ///< ::zes_vf_info_util_exp_flag_t. + +} zes_vf_exp_properties_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zesVFManagementGetVFPropertiesExp +typedef ze_result_t (ZE_APICALL *zes_pfnVFManagementGetVFPropertiesExp_t)( + zes_vf_handle_t, + zes_vf_exp_properties_t* + ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zesVFManagementSetVFTelemetryModeExp +typedef ze_result_t (ZE_APICALL *zes_pfnVFManagementSetVFTelemetryModeExp_t)( + zes_vf_handle_t, + zes_vf_info_util_exp_flags_t, + ze_bool_t + ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zesVFManagementSetVFTelemetrySamplingIntervalExp +typedef ze_result_t (ZE_APICALL *zes_pfnVFManagementSetVFTelemetrySamplingIntervalExp_t)( + zes_vf_handle_t, + zes_vf_info_util_exp_flags_t, + uint64_t + ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Table of VFManagementExp functions pointers +typedef struct _zes_vf_management_exp_dditable_compat_t +{ + zes_pfnVFManagementGetVFCapabilitiesExp_t pfnGetVFCapabilitiesExp; + zes_pfnVFManagementGetVFPropertiesExp_t pfnGetVFPropertiesExp; + zes_pfnVFManagementGetVFMemoryUtilizationExp_t pfnGetVFMemoryUtilizationExp; + zes_pfnVFManagementGetVFEngineUtilizationExp_t pfnGetVFEngineUtilizationExp; + zes_pfnVFManagementSetVFTelemetryModeExp_t pfnSetVFTelemetryModeExp; + zes_pfnVFManagementSetVFTelemetrySamplingIntervalExp_t pfnSetVFTelemetrySamplingIntervalExp; +} zes_vf_management_exp_dditable_compat_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 Table of MetricGroupExp functions pointers +typedef struct _zet_metric_group_exp_dditable_compat_t +{ + 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; + zet_pfnMetricGroupDestroyExp_t pfnDestroyExp; +} zet_metric_group_exp_dditable_compat_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Container for all DDI tables +typedef struct _zes_dditable_compat_t +{ + zes_global_dditable_t Global; + zes_device_dditable_t Device; + zes_device_exp_dditable_compat_t DeviceExp; + zes_driver_dditable_t Driver; + zes_driver_exp_dditable_t DriverExp; + zes_overclock_dditable_t Overclock; + zes_scheduler_dditable_t Scheduler; + zes_performance_factor_dditable_t PerformanceFactor; + zes_power_dditable_t Power; + zes_frequency_dditable_t Frequency; + zes_engine_dditable_t Engine; + zes_standby_dditable_t Standby; + zes_firmware_dditable_t Firmware; + zes_firmware_exp_dditable_t FirmwareExp; + zes_memory_dditable_t Memory; + zes_fabric_port_dditable_t FabricPort; + zes_temperature_dditable_t Temperature; + zes_psu_dditable_t Psu; + zes_fan_dditable_t Fan; + zes_led_dditable_t Led; + zes_ras_dditable_t Ras; + zes_ras_exp_dditable_t RasExp; + zes_diagnostics_dditable_t Diagnostics; + zes_vf_management_exp_dditable_compat_t VFManagementExp; +} zes_dditable_compat_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Container for all DDI tables +typedef struct _zet_dditable_compat_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; + zet_kernel_dditable_t Kernel; + zet_metric_dditable_t Metric; + zet_metric_exp_dditable_t MetricExp; + zet_metric_group_dditable_t MetricGroup; + zet_metric_group_exp_dditable_compat_t MetricGroupExp; + zet_metric_streamer_dditable_t MetricStreamer; + zet_metric_query_pool_dditable_t MetricQueryPool; + zet_metric_query_dditable_t MetricQuery; + zet_tracer_exp_dditable_t TracerExp; + zet_debug_dditable_t Debug; +} zet_dditable_compat_t; \ No newline at end of file diff --git a/source/loader/ze_ldrddi.cpp b/source/loader/ze_ldrddi.cpp index ba93026..9ac3258 100644 --- a/source/loader/ze_ldrddi.cpp +++ b/source/loader/ze_ldrddi.cpp @@ -134,9 +134,11 @@ namespace loader for( auto& drv : loader::context->zeDrivers ) { if (!drv.dditable.ze.Global.pfnInitDrivers) { - drv.initStatus = ZE_RESULT_ERROR_UNINITIALIZED; + drv.initDriversStatus = ZE_RESULT_ERROR_UNINITIALIZED; continue; } + if(drv.initDriversStatus != ZE_RESULT_SUCCESS) + continue; if( ( 0 < *pCount ) && ( *pCount == total_driver_handle_count)) break; @@ -147,7 +149,7 @@ namespace loader 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; + drv.initDriversStatus = result; } continue; } diff --git a/source/loader/ze_loader.cpp b/source/loader/ze_loader.cpp index da97ef8..b7b6169 100644 --- a/source/loader/ze_loader.cpp +++ b/source/loader/ze_loader.cpp @@ -179,6 +179,8 @@ namespace loader if (drivers->size() == 1 && !loader::context->forceIntercept) { *requireDdiReinit = true; } + } else { + it++; } if(return_first_driver_result) return result; @@ -309,8 +311,8 @@ namespace loader 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.initStatus != ZE_RESULT_SUCCESS) { - res = driver.initStatus; + if (driver.initDriversStatus != ZE_RESULT_SUCCESS) { + res = driver.initDriversStatus; } if (debugTraceEnabled) { std::string message = "init driver " + driver.name + " zeInitDrivers(" + loader::to_string(desc) + ") returning "; diff --git a/source/loader/ze_loader_internal.h b/source/loader/ze_loader_internal.h index 2b624a3..087adef 100644 --- a/source/loader/ze_loader_internal.h +++ b/source/loader/ze_loader_internal.h @@ -31,6 +31,7 @@ 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; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 334efea..6dca364 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -37,8 +37,4 @@ set_property(TEST tests_both_succeed PROPERTY ENVIRONMENT "ZE_ENABLE_NULL_DRIVER 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") -add_test(NAME tests_only_one_gpu COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWhenCallingzeInitThenZeInitDriversThenOnlyOneSucceedsforGPUTypes*) -set_property(TEST tests_only_one_gpu PROPERTY ENVIRONMENT "ZE_ENABLE_NULL_DRIVER=1") -add_test(NAME tests_only_one_npu COMMAND tests --gtest_filter=*GivenLevelZeroLoaderPresentWhenCallingzeInitThenZeInitDriversThenOnlyOneSucceedsforNPUTypes*) -set_property(TEST tests_only_one_npu PROPERTY ENVIRONMENT "ZE_ENABLE_NULL_DRIVER=1") \ No newline at end of file +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 ca55798..3a49909 100644 --- a/test/loader_api.cpp +++ b/test/loader_api.cpp @@ -192,32 +192,4 @@ TEST( EXPECT_GT(pCount, 0); } -TEST( - LoaderInit, - GivenLevelZeroLoaderPresentWhenCallingzeInitThenZeInitDriversThenOnlyOneSucceedsforGPUTypes) { - - 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_ERROR_UNINITIALIZED, zeInit(ZE_INIT_FLAG_VPU_ONLY)); - EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc)); - EXPECT_GT(pCount, 0); -} - -TEST( - LoaderInit, - GivenLevelZeroLoaderPresentWhenCallingzeInitThenZeInitDriversThenOnlyOneSucceedsforNPUTypes) { - - 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_ERROR_UNINITIALIZED, zeInit(ZE_INIT_FLAG_GPU_ONLY)); - EXPECT_EQ(ZE_RESULT_SUCCESS, zeInitDrivers(&pCount, nullptr, &desc)); - EXPECT_GT(pCount, 0); -} - } // namespace