From 9a78aea3c6ec6d135da161ae636aa04755651605 Mon Sep 17 00:00:00 2001 From: Lisanna Dettwyler Date: Mon, 2 Dec 2024 23:56:25 +0000 Subject: [PATCH] Update to spec 1.12 Signed-off-by: Lisanna Dettwyler --- CHANGELOG.md | 2 + CMakeLists.txt | 2 +- include/layers/zel_tracing_register_cb.h | 146 ++++++++ include/ze.py | 191 +++++++++- include/ze_api.h | 333 +++++++++++++++++- include/ze_ddi.h | 78 +++- include/zes.py | 32 +- include/zes_api.h | 51 ++- include/zes_ddi.h | 40 ++- include/zet.py | 2 +- include/zet_api.h | 2 +- include/zet_ddi.h | 26 +- source/drivers/null/ze_nullddi.cpp | 122 +++++++ source/drivers/null/zes_nullddi.cpp | 26 ++ source/layers/tracing/ze_tracing_cb_structs.h | 4 + .../layers/tracing/ze_tracing_register_cb.cpp | 64 ++++ source/layers/tracing/ze_trcddi.cpp | 188 ++++++++++ .../ze_parameter_validation.cpp | 107 ++++++ .../ze_parameter_validation.h | 4 + .../zes_parameter_validation.cpp | 16 + .../zes_parameter_validation.h | 1 + .../validation/common/ze_entry_points.h | 8 + .../validation/common/zes_entry_points.h | 2 + .../ze_handle_lifetime.cpp | 96 +++++ .../ze_handle_lifetime.h | 4 + .../zes_handle_lifetime.cpp | 12 + .../zes_handle_lifetime.h | 1 + source/layers/validation/ze_valddi.cpp | 188 ++++++++++ source/layers/validation/zes_valddi.cpp | 43 +++ source/lib/ze_libapi.cpp | 197 +++++++++++ source/lib/ze_libddi.cpp | 66 ++-- source/lib/ze_tracing_register_cb_libapi.cpp | 100 ++++++ source/lib/zes_libapi.cpp | 40 +++ source/lib/zes_libddi.cpp | 42 +-- source/lib/zet_libddi.cpp | 36 +- source/loader/ze_ldrddi.cpp | 164 +++++++++ source/loader/ze_ldrddi.h | 3 + source/loader/ze_loader_internal.h | 1 + source/loader/zes_ldrddi.cpp | 26 ++ 39 files changed, 2347 insertions(+), 119 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef8ce1ae..7103a6f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Level zero loader changelog +## v1.20.0 +* Update to spec 1.12 ## v1.19.2 * Remove static result in InitDrivers given first init fails ## v1.19.1 diff --git a/CMakeLists.txt b/CMakeLists.txt index ca0746fa..27dc1b24 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ message(FATAL_ERROR "Visual Studio Compiler Version >= 1900 Required to build.") endif() # This project follows semantic versioning (https://semver.org/) -project(level-zero VERSION 1.19.2) +project(level-zero VERSION 1.20.0) include(GNUInstallDirs) diff --git a/include/layers/zel_tracing_register_cb.h b/include/layers/zel_tracing_register_cb.h index 5341c090..a04d08ed 100644 --- a/include/layers/zel_tracing_register_cb.h +++ b/include/layers/zel_tracing_register_cb.h @@ -376,6 +376,58 @@ typedef void (ZE_APICALL *ze_pfnDeviceGetGlobalTimestampsCb_t)( void** ppTracerInstanceUserData ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function parameters for zeDeviceImportExternalSemaphoreExt +/// @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_device_import_external_semaphore_ext_params_t +{ + ze_device_handle_t* phDevice; + const ze_external_semaphore_ext_desc_t** pdesc; + ze_external_semaphore_ext_handle_t** pphSemaphore; +} ze_device_import_external_semaphore_ext_params_t; + + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function-pointer for zeDeviceImportExternalSemaphoreExt +/// @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_pfnDeviceImportExternalSemaphoreExtCb_t)( + ze_device_import_external_semaphore_ext_params_t* params, + ze_result_t result, + void* pTracerUserData, + void** ppTracerInstanceUserData + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function parameters for zeDeviceReleaseExternalSemaphoreExt +/// @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_device_release_external_semaphore_ext_params_t +{ + ze_external_semaphore_ext_handle_t* phSemaphore; +} ze_device_release_external_semaphore_ext_params_t; + + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function-pointer for zeDeviceReleaseExternalSemaphoreExt +/// @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_pfnDeviceReleaseExternalSemaphoreExtCb_t)( + ze_device_release_external_semaphore_ext_params_t* params, + ze_result_t result, + void* pTracerUserData, + void** ppTracerInstanceUserData + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Callback function parameters for zeDeviceReserveCacheExt /// @details Each entry is a pointer to the parameter passed to the function; @@ -647,6 +699,68 @@ typedef void (ZE_APICALL *ze_pfnCommandListUpdateMutableCommandKernelsExpCb_t)( void** ppTracerInstanceUserData ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function parameters for zeCommandListAppendSignalExternalSemaphoreExt +/// @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_append_signal_external_semaphore_ext_params_t +{ + ze_command_list_handle_t* phCommandList; + uint32_t* pnumSemaphores; + ze_external_semaphore_ext_handle_t** pphSemaphores; + ze_external_semaphore_signal_params_ext_t** psignalParams; + ze_event_handle_t* phSignalEvent; + uint32_t* pnumWaitEvents; + ze_event_handle_t** pphWaitEvents; +} ze_command_list_append_signal_external_semaphore_ext_params_t; + + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function-pointer for zeCommandListAppendSignalExternalSemaphoreExt +/// @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_pfnCommandListAppendSignalExternalSemaphoreExtCb_t)( + ze_command_list_append_signal_external_semaphore_ext_params_t* params, + ze_result_t result, + void* pTracerUserData, + void** ppTracerInstanceUserData + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function parameters for zeCommandListAppendWaitExternalSemaphoreExt +/// @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_append_wait_external_semaphore_ext_params_t +{ + ze_command_list_handle_t* phCommandList; + uint32_t* pnumSemaphores; + ze_external_semaphore_ext_handle_t** pphSemaphores; + ze_external_semaphore_wait_params_ext_t** pwaitParams; + ze_event_handle_t* phSignalEvent; + uint32_t* pnumWaitEvents; + ze_event_handle_t** pphWaitEvents; +} ze_command_list_append_wait_external_semaphore_ext_params_t; + + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function-pointer for zeCommandListAppendWaitExternalSemaphoreExt +/// @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_pfnCommandListAppendWaitExternalSemaphoreExtCb_t)( + ze_command_list_append_wait_external_semaphore_ext_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; @@ -3058,6 +3172,38 @@ zelTracerKernelGetBinaryExpRegisterCallback( ); +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerDeviceImportExternalSemaphoreExtRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnDeviceImportExternalSemaphoreExtCb_t pfnImportExternalSemaphoreExtCb + ); + + +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerDeviceReleaseExternalSemaphoreExtRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnDeviceReleaseExternalSemaphoreExtCb_t pfnReleaseExternalSemaphoreExtCb + ); + + +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerCommandListAppendSignalExternalSemaphoreExtRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListAppendSignalExternalSemaphoreExtCb_t pfnAppendSignalExternalSemaphoreExtCb + ); + + +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerCommandListAppendWaitExternalSemaphoreExtRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListAppendWaitExternalSemaphoreExtCb_t pfnAppendWaitExternalSemaphoreExtCb + ); + + ZE_APIEXPORT ze_result_t ZE_APICALL zelTracerDeviceReserveCacheExtRegisterCallback( zel_tracer_handle_t hTracer, diff --git a/include/ze.py b/include/ze.py index d17cf647..a43aad2c 100644 --- a/include/ze.py +++ b/include/ze.py @@ -4,7 +4,7 @@ SPDX-License-Identifier: MIT @file ze.py - @version v1.11-r1.11.8 + @version v1.12-r1.12.0 """ import platform @@ -316,6 +316,12 @@ class ze_structure_type_v(IntEnum): 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 + EXTERNAL_SEMAPHORE_EXT_DESC = 0x00020022 ## ::ze_external_semaphore_ext_desc_t + EXTERNAL_SEMAPHORE_WIN32_EXT_DESC = 0x00020023 ## ::ze_external_semaphore_win32_ext_desc_t + EXTERNAL_SEMAPHORE_FD_EXT_DESC = 0x00020024 ## ::ze_external_semaphore_fd_ext_desc_t + EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_EXT = 0x00020025 ## ::ze_external_semaphore_signal_params_ext_t + EXTERNAL_SEMAPHORE_WAIT_PARAMS_EXT = 0x00020026 ## ::ze_external_semaphore_wait_params_ext_t + DRIVER_DDI_HANDLES_EXT_PROPERTIES = 0x00020027 ## ::ze_driver_ddi_handles_ext_properties_t class ze_structure_type_t(c_int): def __str__(self): @@ -485,7 +491,8 @@ class ze_api_version_v(IntEnum): _1_9 = ZE_MAKE_VERSION( 1, 9 ) ## version 1.9 _1_10 = ZE_MAKE_VERSION( 1, 10 ) ## version 1.10 _1_11 = ZE_MAKE_VERSION( 1, 11 ) ## version 1.11 - CURRENT = ZE_MAKE_VERSION( 1, 11 ) ## latest known version + _1_12 = ZE_MAKE_VERSION( 1, 12 ) ## version 1.12 + CURRENT = ZE_MAKE_VERSION( 1, 12 ) ## latest known version class ze_api_version_t(c_int): def __str__(self): @@ -494,7 +501,7 @@ def __str__(self): ############################################################################### ## @brief Current API version as a macro -ZE_API_VERSION_CURRENT_M = ZE_MAKE_VERSION( 1, 11 ) +ZE_API_VERSION_CURRENT_M = ZE_MAKE_VERSION( 1, 12 ) ############################################################################### ## @brief Maximum driver universal unique id (UUID) size in bytes @@ -2114,6 +2121,144 @@ class ze_relaxed_allocation_limits_exp_desc_t(Structure): ## @brief Get Kernel Binary Extension Name ZE_GET_KERNEL_BINARY_EXP_NAME = "ZE_extension_kernel_binary_exp" +############################################################################### +## @brief Driver Direct Device Interface (DDI) Handles Extension Name +ZE_DRIVER_DDI_HANDLES_EXT_NAME = "ZE_extension_driver_ddi_handles" + +############################################################################### +## @brief Driver Direct Device Interface (DDI) Handles Extension Version(s) +class ze_driver_ddi_handles_ext_version_v(IntEnum): + _1_0 = ZE_MAKE_VERSION( 1, 0 ) ## version 1.0 + CURRENT = ZE_MAKE_VERSION( 1, 0 ) ## latest known version + +class ze_driver_ddi_handles_ext_version_t(c_int): + def __str__(self): + return str(ze_driver_ddi_handles_ext_version_v(self.value)) + + +############################################################################### +## @brief Driver Direct Device Interface (DDI) Handle Extension Flags +class ze_driver_ddi_handle_ext_flags_v(IntEnum): + DDI_HANDLE_EXT_SUPPORTED = ZE_BIT(0) ## Driver Supports DDI Handles Extension + +class ze_driver_ddi_handle_ext_flags_t(c_int): + def __str__(self): + return hex(self.value) + + +############################################################################### +## @brief Driver DDI Handles properties queried using ::zeDriverGetProperties +## +## @details +## - This structure may be returned from ::zeDriverGetProperties, via the +## `pNext` member of ::ze_driver_properties_t. +class ze_driver_ddi_handles_ext_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). + ("flags", ze_driver_ddi_handle_ext_flags_t) ## [out] 0 (none) or a valid combination of ::ze_driver_ddi_handle_ext_flags_t + ] + +############################################################################### +## @brief External Semaphores Extension Name +ZE_EXTERNAL_SEMAPHORES_EXTENSION_NAME = "ZE_extension_external_semaphores" + +############################################################################### +## @brief External Semaphores Extension Version +class ze_external_semaphore_ext_version_v(IntEnum): + _1_0 = ZE_MAKE_VERSION( 1, 0 ) ## version 1.0 + CURRENT = ZE_MAKE_VERSION( 1, 0 ) ## latest known version + +class ze_external_semaphore_ext_version_t(c_int): + def __str__(self): + return str(ze_external_semaphore_ext_version_v(self.value)) + + +############################################################################### +## @brief Handle of external semaphore object +class ze_external_semaphore_ext_handle_t(c_void_p): + pass + +############################################################################### +## @brief External Semaphores Type Flags +class ze_external_semaphore_ext_flags_v(IntEnum): + OPAQUE_FD = ZE_BIT(0) ## Semaphore is an Linux opaque file descriptor + OPAQUE_WIN32 = ZE_BIT(1) ## Semaphore is an opaque Win32 handle for monitored fence + OPAQUE_WIN32_KMT = ZE_BIT(2) ## Semaphore is an opaque Win32 KMT handle for monitored fence + D3D12_FENCE = ZE_BIT(3) ## Semaphore is a D3D12 fence + D3D11_FENCE = ZE_BIT(4) ## Semaphore is a D3D11 fence + KEYED_MUTEX = ZE_BIT(5) ## Semaphore is a keyed mutex for Win32 + KEYED_MUTEX_KMT = ZE_BIT(6) ## Semaphore is a keyed mutex for Win32 KMT + VK_TIMELINE_SEMAPHORE_FD = ZE_BIT(7) ## Semaphore is a Vulkan Timeline semaphore for Linux + VK_TIMELINE_SEMAPHORE_WIN32 = ZE_BIT(8) ## Semaphore is a Vulkan Timeline semaphore for Win32 + +class ze_external_semaphore_ext_flags_t(c_int): + def __str__(self): + return hex(self.value) + + +############################################################################### +## @brief External Semaphore Descriptor +class ze_external_semaphore_ext_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_external_semaphore_ext_flags_t) ## [in] The flags describing the type of the semaphore. + ## must be 0 (default) or a valid combination of ::ze_external_semaphore_ext_flag_t. + ## When importing a semaphore, pNext should be pointing to one of the + ## following structures: ::ze_external_semaphore_win32_ext_desc_t or ::ze_external_semaphore_fd_ext_desc_t. + ] + +############################################################################### +## @brief External Semaphore Win32 Descriptor +class ze_external_semaphore_win32_ext_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). + ("handle", c_void_p), ## [in] Win32 handle of the semaphore. + ## Must be a valid Win32 handle. + ("name", c_char_p) ## [in] Name of the semaphore. + ## Must be a valid null-terminated string. + ] + +############################################################################### +## @brief External Semaphore FD Descriptor +class ze_external_semaphore_fd_ext_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). + ("fd", c_int) ## [in] File descriptor of the semaphore. + ## Must be a valid file descriptor. + ] + +############################################################################### +## @brief External Semaphore Signal parameters +class ze_external_semaphore_signal_params_ext_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). + ("value", c_ulonglong) ## [in] [optional] Value to signal. + ## Specified by user as an expected value with some of semaphore types, + ## such as ::ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_D3D12_FENCE. + ] + +############################################################################### +## @brief External Semaphore Wait parameters +class ze_external_semaphore_wait_params_ext_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). + ("value", c_ulonglong) ## [in] [optional] Value to wait for. + ## Specified by user as an expected value with some of semaphore types, + ## such as ::ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_D3D12_FENCE. + ] + ############################################################################### ## @brief Cache_Reservation Extension Name ZE_CACHE_RESERVATION_EXT_NAME = "ZE_extension_cache_reservation" @@ -4328,6 +4473,20 @@ class _ze_driver_exp_dditable_t(Structure): else: _zeDeviceGetRootDevice_t = CFUNCTYPE( ze_result_t, ze_device_handle_t, POINTER(ze_device_handle_t) ) +############################################################################### +## @brief Function-pointer for zeDeviceImportExternalSemaphoreExt +if __use_win_types: + _zeDeviceImportExternalSemaphoreExt_t = WINFUNCTYPE( ze_result_t, ze_device_handle_t, POINTER(ze_external_semaphore_ext_desc_t), POINTER(ze_external_semaphore_ext_handle_t) ) +else: + _zeDeviceImportExternalSemaphoreExt_t = CFUNCTYPE( ze_result_t, ze_device_handle_t, POINTER(ze_external_semaphore_ext_desc_t), POINTER(ze_external_semaphore_ext_handle_t) ) + +############################################################################### +## @brief Function-pointer for zeDeviceReleaseExternalSemaphoreExt +if __use_win_types: + _zeDeviceReleaseExternalSemaphoreExt_t = WINFUNCTYPE( ze_result_t, ze_external_semaphore_ext_handle_t ) +else: + _zeDeviceReleaseExternalSemaphoreExt_t = CFUNCTYPE( ze_result_t, ze_external_semaphore_ext_handle_t ) + ############################################################################### ## @brief Table of Device functions pointers @@ -4351,7 +4510,9 @@ class _ze_device_dditable_t(Structure): ("pfnReserveCacheExt", c_void_p), ## _zeDeviceReserveCacheExt_t ("pfnSetCacheAdviceExt", c_void_p), ## _zeDeviceSetCacheAdviceExt_t ("pfnPciGetPropertiesExt", c_void_p), ## _zeDevicePciGetPropertiesExt_t - ("pfnGetRootDevice", c_void_p) ## _zeDeviceGetRootDevice_t + ("pfnGetRootDevice", c_void_p), ## _zeDeviceGetRootDevice_t + ("pfnImportExternalSemaphoreExt", c_void_p), ## _zeDeviceImportExternalSemaphoreExt_t + ("pfnReleaseExternalSemaphoreExt", c_void_p) ## _zeDeviceReleaseExternalSemaphoreExt_t ] ############################################################################### @@ -4741,6 +4902,20 @@ class _ze_command_queue_dditable_t(Structure): else: _zeCommandListIsImmediate_t = CFUNCTYPE( ze_result_t, ze_command_list_handle_t, POINTER(ze_bool_t) ) +############################################################################### +## @brief Function-pointer for zeCommandListAppendSignalExternalSemaphoreExt +if __use_win_types: + _zeCommandListAppendSignalExternalSemaphoreExt_t = WINFUNCTYPE( ze_result_t, ze_command_list_handle_t, c_ulong, POINTER(ze_external_semaphore_ext_handle_t), POINTER(ze_external_semaphore_signal_params_ext_t), ze_event_handle_t, c_ulong, POINTER(ze_event_handle_t) ) +else: + _zeCommandListAppendSignalExternalSemaphoreExt_t = CFUNCTYPE( ze_result_t, ze_command_list_handle_t, c_ulong, POINTER(ze_external_semaphore_ext_handle_t), POINTER(ze_external_semaphore_signal_params_ext_t), ze_event_handle_t, c_ulong, POINTER(ze_event_handle_t) ) + +############################################################################### +## @brief Function-pointer for zeCommandListAppendWaitExternalSemaphoreExt +if __use_win_types: + _zeCommandListAppendWaitExternalSemaphoreExt_t = WINFUNCTYPE( ze_result_t, ze_command_list_handle_t, c_ulong, POINTER(ze_external_semaphore_ext_handle_t), POINTER(ze_external_semaphore_wait_params_ext_t), ze_event_handle_t, c_ulong, POINTER(ze_event_handle_t) ) +else: + _zeCommandListAppendWaitExternalSemaphoreExt_t = CFUNCTYPE( ze_result_t, ze_command_list_handle_t, c_ulong, POINTER(ze_external_semaphore_ext_handle_t), POINTER(ze_external_semaphore_wait_params_ext_t), ze_event_handle_t, c_ulong, POINTER(ze_event_handle_t) ) + ############################################################################### ## @brief Table of CommandList functions pointers @@ -4779,7 +4954,9 @@ class _ze_command_list_dditable_t(Structure): ("pfnGetContextHandle", c_void_p), ## _zeCommandListGetContextHandle_t ("pfnGetOrdinal", c_void_p), ## _zeCommandListGetOrdinal_t ("pfnImmediateGetIndex", c_void_p), ## _zeCommandListImmediateGetIndex_t - ("pfnIsImmediate", c_void_p) ## _zeCommandListIsImmediate_t + ("pfnIsImmediate", c_void_p), ## _zeCommandListIsImmediate_t + ("pfnAppendSignalExternalSemaphoreExt", c_void_p), ## _zeCommandListAppendSignalExternalSemaphoreExt_t + ("pfnAppendWaitExternalSemaphoreExt", c_void_p) ## _zeCommandListAppendWaitExternalSemaphoreExt_t ] ############################################################################### @@ -5852,6 +6029,8 @@ def __init__(self, version : ze_api_version_t): self.zeDeviceSetCacheAdviceExt = _zeDeviceSetCacheAdviceExt_t(self.__dditable.Device.pfnSetCacheAdviceExt) self.zeDevicePciGetPropertiesExt = _zeDevicePciGetPropertiesExt_t(self.__dditable.Device.pfnPciGetPropertiesExt) self.zeDeviceGetRootDevice = _zeDeviceGetRootDevice_t(self.__dditable.Device.pfnGetRootDevice) + self.zeDeviceImportExternalSemaphoreExt = _zeDeviceImportExternalSemaphoreExt_t(self.__dditable.Device.pfnImportExternalSemaphoreExt) + self.zeDeviceReleaseExternalSemaphoreExt = _zeDeviceReleaseExternalSemaphoreExt_t(self.__dditable.Device.pfnReleaseExternalSemaphoreExt) # call driver to get function pointers _DeviceExp = _ze_device_exp_dditable_t() @@ -5938,6 +6117,8 @@ def __init__(self, version : ze_api_version_t): self.zeCommandListGetOrdinal = _zeCommandListGetOrdinal_t(self.__dditable.CommandList.pfnGetOrdinal) self.zeCommandListImmediateGetIndex = _zeCommandListImmediateGetIndex_t(self.__dditable.CommandList.pfnImmediateGetIndex) self.zeCommandListIsImmediate = _zeCommandListIsImmediate_t(self.__dditable.CommandList.pfnIsImmediate) + self.zeCommandListAppendSignalExternalSemaphoreExt = _zeCommandListAppendSignalExternalSemaphoreExt_t(self.__dditable.CommandList.pfnAppendSignalExternalSemaphoreExt) + self.zeCommandListAppendWaitExternalSemaphoreExt = _zeCommandListAppendWaitExternalSemaphoreExt_t(self.__dditable.CommandList.pfnAppendWaitExternalSemaphoreExt) # call driver to get function pointers _CommandListExp = _ze_command_list_exp_dditable_t() diff --git a/include/ze_api.h b/include/ze_api.h index dc57f4d4..76fcaded 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.11-r1.11.8 + * @version v1.12-r1.12.0 * */ #ifndef _ZE_API_H @@ -345,6 +345,12 @@ typedef enum _ze_structure_type_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_EXTERNAL_SEMAPHORE_EXT_DESC = 0x00020022, ///< ::ze_external_semaphore_ext_desc_t + ZE_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_WIN32_EXT_DESC = 0x00020023, ///< ::ze_external_semaphore_win32_ext_desc_t + ZE_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_FD_EXT_DESC = 0x00020024, ///< ::ze_external_semaphore_fd_ext_desc_t + ZE_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS_EXT = 0x00020025, ///< ::ze_external_semaphore_signal_params_ext_t + ZE_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_WAIT_PARAMS_EXT = 0x00020026, ///< ::ze_external_semaphore_wait_params_ext_t + ZE_STRUCTURE_TYPE_DRIVER_DDI_HANDLES_EXT_PROPERTIES = 0x00020027, ///< ::ze_driver_ddi_handles_ext_properties_t ZE_STRUCTURE_TYPE_FORCE_UINT32 = 0x7fffffff } ze_structure_type_t; @@ -689,6 +695,30 @@ typedef struct _ze_float_atomic_ext_properties_t ze_float_atomic_ext_properties_ /// @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; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare ze_driver_ddi_handles_ext_properties_t +typedef struct _ze_driver_ddi_handles_ext_properties_t ze_driver_ddi_handles_ext_properties_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare ze_external_semaphore_ext_desc_t +typedef struct _ze_external_semaphore_ext_desc_t ze_external_semaphore_ext_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare ze_external_semaphore_win32_ext_desc_t +typedef struct _ze_external_semaphore_win32_ext_desc_t ze_external_semaphore_win32_ext_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare ze_external_semaphore_fd_ext_desc_t +typedef struct _ze_external_semaphore_fd_ext_desc_t ze_external_semaphore_fd_ext_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare ze_external_semaphore_signal_params_ext_t +typedef struct _ze_external_semaphore_signal_params_ext_t ze_external_semaphore_signal_params_ext_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare ze_external_semaphore_wait_params_ext_t +typedef struct _ze_external_semaphore_wait_params_ext_t ze_external_semaphore_wait_params_ext_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Forward-declare ze_cache_reservation_ext_desc_t typedef struct _ze_cache_reservation_ext_desc_t ze_cache_reservation_ext_desc_t; @@ -1155,7 +1185,8 @@ typedef enum _ze_api_version_t ZE_API_VERSION_1_9 = ZE_MAKE_VERSION( 1, 9 ), ///< version 1.9 ZE_API_VERSION_1_10 = ZE_MAKE_VERSION( 1, 10 ), ///< version 1.10 ZE_API_VERSION_1_11 = ZE_MAKE_VERSION( 1, 11 ), ///< version 1.11 - ZE_API_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 11 ), ///< latest known version + ZE_API_VERSION_1_12 = ZE_MAKE_VERSION( 1, 12 ), ///< version 1.12 + ZE_API_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 12 ), ///< latest known version ZE_API_VERSION_FORCE_UINT32 = 0x7fffffff } ze_api_version_t; @@ -1163,7 +1194,7 @@ typedef enum _ze_api_version_t /////////////////////////////////////////////////////////////////////////////// #ifndef ZE_API_VERSION_CURRENT_M /// @brief Current API version as a macro -#define ZE_API_VERSION_CURRENT_M ZE_MAKE_VERSION( 1, 11 ) +#define ZE_API_VERSION_CURRENT_M ZE_MAKE_VERSION( 1, 12 ) #endif // ZE_API_VERSION_CURRENT_M /////////////////////////////////////////////////////////////////////////////// @@ -7692,6 +7723,302 @@ zeKernelGetBinaryExp( uint8_t* pKernelBinary ///< [in,out] pointer to storage area for GEN ISA binary function. ); +#if !defined(__GNUC__) +#pragma endregion +#endif +// Intel 'oneAPI' Level-Zero Extension for Driver Direct Device Interface (DDI) Handles +#if !defined(__GNUC__) +#pragma region driverDDIHandles +#endif +/////////////////////////////////////////////////////////////////////////////// +#ifndef ZE_DRIVER_DDI_HANDLES_EXT_NAME +/// @brief Driver Direct Device Interface (DDI) Handles Extension Name +#define ZE_DRIVER_DDI_HANDLES_EXT_NAME "ZE_extension_driver_ddi_handles" +#endif // ZE_DRIVER_DDI_HANDLES_EXT_NAME + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Driver Direct Device Interface (DDI) Handles Extension Version(s) +typedef enum _ze_driver_ddi_handles_ext_version_t +{ + ZE_DRIVER_DDI_HANDLES_EXT_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 + ZE_DRIVER_DDI_HANDLES_EXT_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 0 ), ///< latest known version + ZE_DRIVER_DDI_HANDLES_EXT_VERSION_FORCE_UINT32 = 0x7fffffff + +} ze_driver_ddi_handles_ext_version_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Driver Direct Device Interface (DDI) Handle Extension Flags +typedef uint32_t ze_driver_ddi_handle_ext_flags_t; +typedef enum _ze_driver_ddi_handle_ext_flag_t +{ + ZE_DRIVER_DDI_HANDLE_EXT_FLAG_DDI_HANDLE_EXT_SUPPORTED = ZE_BIT(0), ///< Driver Supports DDI Handles Extension + ZE_DRIVER_DDI_HANDLE_EXT_FLAG_FORCE_UINT32 = 0x7fffffff + +} ze_driver_ddi_handle_ext_flag_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Driver DDI Handles properties queried using ::zeDriverGetProperties +/// +/// @details +/// - This structure may be returned from ::zeDriverGetProperties, via the +/// `pNext` member of ::ze_driver_properties_t. +typedef struct _ze_driver_ddi_handles_ext_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_driver_ddi_handle_ext_flags_t flags; ///< [out] 0 (none) or a valid combination of ::ze_driver_ddi_handle_ext_flags_t + +} ze_driver_ddi_handles_ext_properties_t; + +#if !defined(__GNUC__) +#pragma endregion +#endif +// Intel 'oneAPI' Level-Zero Extension for external semaphores +#if !defined(__GNUC__) +#pragma region externalSemaphores +#endif +/////////////////////////////////////////////////////////////////////////////// +#ifndef ZE_EXTERNAL_SEMAPHORES_EXTENSION_NAME +/// @brief External Semaphores Extension Name +#define ZE_EXTERNAL_SEMAPHORES_EXTENSION_NAME "ZE_extension_external_semaphores" +#endif // ZE_EXTERNAL_SEMAPHORES_EXTENSION_NAME + +/////////////////////////////////////////////////////////////////////////////// +/// @brief External Semaphores Extension Version +typedef enum _ze_external_semaphore_ext_version_t +{ + ZE_EXTERNAL_SEMAPHORE_EXT_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 + ZE_EXTERNAL_SEMAPHORE_EXT_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 0 ), ///< latest known version + ZE_EXTERNAL_SEMAPHORE_EXT_VERSION_FORCE_UINT32 = 0x7fffffff + +} ze_external_semaphore_ext_version_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Handle of external semaphore object +typedef struct _ze_external_semaphore_ext_handle_t *ze_external_semaphore_ext_handle_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief External Semaphores Type Flags +typedef uint32_t ze_external_semaphore_ext_flags_t; +typedef enum _ze_external_semaphore_ext_flag_t +{ + ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_OPAQUE_FD = ZE_BIT(0), ///< Semaphore is an Linux opaque file descriptor + ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_OPAQUE_WIN32 = ZE_BIT(1), ///< Semaphore is an opaque Win32 handle for monitored fence + ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_OPAQUE_WIN32_KMT = ZE_BIT(2), ///< Semaphore is an opaque Win32 KMT handle for monitored fence + ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_D3D12_FENCE = ZE_BIT(3), ///< Semaphore is a D3D12 fence + ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_D3D11_FENCE = ZE_BIT(4), ///< Semaphore is a D3D11 fence + ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_KEYED_MUTEX = ZE_BIT(5), ///< Semaphore is a keyed mutex for Win32 + ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_KEYED_MUTEX_KMT = ZE_BIT(6), ///< Semaphore is a keyed mutex for Win32 KMT + ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_VK_TIMELINE_SEMAPHORE_FD = ZE_BIT(7), ///< Semaphore is a Vulkan Timeline semaphore for Linux + ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_VK_TIMELINE_SEMAPHORE_WIN32 = ZE_BIT(8), ///< Semaphore is a Vulkan Timeline semaphore for Win32 + ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_FORCE_UINT32 = 0x7fffffff + +} ze_external_semaphore_ext_flag_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief External Semaphore Descriptor +typedef struct _ze_external_semaphore_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). + ze_external_semaphore_ext_flags_t flags; ///< [in] The flags describing the type of the semaphore. + ///< must be 0 (default) or a valid combination of ::ze_external_semaphore_ext_flag_t. + ///< When importing a semaphore, pNext should be pointing to one of the + ///< following structures: ::ze_external_semaphore_win32_ext_desc_t or ::ze_external_semaphore_fd_ext_desc_t. + +} ze_external_semaphore_ext_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief External Semaphore Win32 Descriptor +typedef struct _ze_external_semaphore_win32_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). + void* handle; ///< [in] Win32 handle of the semaphore. + ///< Must be a valid Win32 handle. + const char* name; ///< [in] Name of the semaphore. + ///< Must be a valid null-terminated string. + +} ze_external_semaphore_win32_ext_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief External Semaphore FD Descriptor +typedef struct _ze_external_semaphore_fd_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). + int fd; ///< [in] File descriptor of the semaphore. + ///< Must be a valid file descriptor. + +} ze_external_semaphore_fd_ext_desc_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief External Semaphore Signal parameters +typedef struct _ze_external_semaphore_signal_params_ext_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 value; ///< [in] [optional] Value to signal. + ///< Specified by user as an expected value with some of semaphore types, + ///< such as ::ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_D3D12_FENCE. + +} ze_external_semaphore_signal_params_ext_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief External Semaphore Wait parameters +typedef struct _ze_external_semaphore_wait_params_ext_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 value; ///< [in] [optional] Value to wait for. + ///< Specified by user as an expected value with some of semaphore types, + ///< such as ::ZE_EXTERNAL_SEMAPHORE_EXT_FLAG_D3D12_FENCE. + +} ze_external_semaphore_wait_params_ext_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Import an external semaphore +/// +/// @details +/// - Imports an external semaphore. +/// - This function may be called from simultaneous threads with the same +/// device 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 == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == desc` +/// + `nullptr == phSemaphore` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x1ff < desc->flags` +ZE_APIEXPORT ze_result_t ZE_APICALL +zeDeviceImportExternalSemaphoreExt( + ze_device_handle_t hDevice, ///< [in] The device handle. + const ze_external_semaphore_ext_desc_t* desc, ///< [in] The pointer to external semaphore descriptor. + ze_external_semaphore_ext_handle_t* phSemaphore ///< [out] The handle of the external semaphore imported. + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Release an external semaphore +/// +/// @details +/// - The application must ensure the device is not currently referencing +/// the semaphore before it is released. +/// - The application must **not** call this function from simultaneous +/// threads with the same semaphore 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 == hSemaphore` +/// - ::ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE +ZE_APIEXPORT ze_result_t ZE_APICALL +zeDeviceReleaseExternalSemaphoreExt( + ze_external_semaphore_ext_handle_t hSemaphore ///< [in] The handle of the external semaphore. + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Signal an external semaphore +/// +/// @details +/// - Signals an external semaphore. +/// - This function must only be used with an immediate 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 == phSemaphores` +/// + `nullptr == signalParams` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +/// + `(nullptr == phSemaphores) && (0 < numSemaphores)` +/// + `(nullptr == signalParams) && (0 < numSemaphores)` +/// - ::ZE_RESULT_ERROR_INVALID_ARGUMENT +/// + Commandlist handle does not correspond to an immediate command list +ZE_APIEXPORT ze_result_t ZE_APICALL +zeCommandListAppendSignalExternalSemaphoreExt( + ze_command_list_handle_t hCommandList, ///< [in] The command list handle. + uint32_t numSemaphores, ///< [in] The number of external semaphores. + ze_external_semaphore_ext_handle_t* phSemaphores, ///< [in][range(0, numSemaphores)] The vector of external semaphore handles + ///< to be appended into command list. + ze_external_semaphore_signal_params_ext_t* signalParams, ///< [in] Signal parameters. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; 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 + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Wait on external semaphores +/// +/// @details +/// - Waits on external semaphores. +/// - This function must only be used with an immediate 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 == phSemaphores` +/// + `nullptr == waitParams` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +/// + `(nullptr == phSemaphores) && (0 < numSemaphores)` +/// + `(nullptr == waitParams) && (0 < numSemaphores)` +/// - ::ZE_RESULT_ERROR_INVALID_ARGUMENT +/// + Commandlist handle does not correspond to an immediate command list +ZE_APIEXPORT ze_result_t ZE_APICALL +zeCommandListAppendWaitExternalSemaphoreExt( + ze_command_list_handle_t hCommandList, ///< [in] The command list handle. + uint32_t numSemaphores, ///< [in] The number of external semaphores. + ze_external_semaphore_ext_handle_t* phSemaphores, ///< [in] [range(0,numSemaphores)] The vector of external semaphore handles + ///< to append into command list. + ze_external_semaphore_wait_params_ext_t* waitParams, ///< [in] Wait parameters. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; 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 + ); + #if !defined(__GNUC__) #pragma endregion #endif diff --git a/include/ze_ddi.h b/include/ze_ddi.h index e06ef343..a0a4027a 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.11-r1.11.8 + * @version v1.12-r1.12.0 * */ #ifndef _ZE_DDI_H @@ -456,6 +456,20 @@ typedef ze_result_t (ZE_APICALL *ze_pfnDeviceGetRootDevice_t)( ze_device_handle_t* ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zeDeviceImportExternalSemaphoreExt +typedef ze_result_t (ZE_APICALL *ze_pfnDeviceImportExternalSemaphoreExt_t)( + ze_device_handle_t, + const ze_external_semaphore_ext_desc_t*, + ze_external_semaphore_ext_handle_t* + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zeDeviceReleaseExternalSemaphoreExt +typedef ze_result_t (ZE_APICALL *ze_pfnDeviceReleaseExternalSemaphoreExt_t)( + ze_external_semaphore_ext_handle_t + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Table of Device functions pointers typedef struct _ze_device_dditable_t @@ -479,6 +493,8 @@ typedef struct _ze_device_dditable_t ze_pfnDeviceSetCacheAdviceExt_t pfnSetCacheAdviceExt; ze_pfnDevicePciGetPropertiesExt_t pfnPciGetPropertiesExt; ze_pfnDeviceGetRootDevice_t pfnGetRootDevice; + ze_pfnDeviceImportExternalSemaphoreExt_t pfnImportExternalSemaphoreExt; + ze_pfnDeviceReleaseExternalSemaphoreExt_t pfnReleaseExternalSemaphoreExt; } ze_device_dditable_t; /////////////////////////////////////////////////////////////////////////////// @@ -1065,6 +1081,30 @@ typedef ze_result_t (ZE_APICALL *ze_pfnCommandListIsImmediate_t)( ze_bool_t* ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zeCommandListAppendSignalExternalSemaphoreExt +typedef ze_result_t (ZE_APICALL *ze_pfnCommandListAppendSignalExternalSemaphoreExt_t)( + ze_command_list_handle_t, + uint32_t, + ze_external_semaphore_ext_handle_t*, + ze_external_semaphore_signal_params_ext_t*, + ze_event_handle_t, + uint32_t, + ze_event_handle_t* + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zeCommandListAppendWaitExternalSemaphoreExt +typedef ze_result_t (ZE_APICALL *ze_pfnCommandListAppendWaitExternalSemaphoreExt_t)( + ze_command_list_handle_t, + uint32_t, + ze_external_semaphore_ext_handle_t*, + ze_external_semaphore_wait_params_ext_t*, + ze_event_handle_t, + uint32_t, + ze_event_handle_t* + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Table of CommandList functions pointers typedef struct _ze_command_list_dditable_t @@ -1103,6 +1143,8 @@ typedef struct _ze_command_list_dditable_t ze_pfnCommandListGetOrdinal_t pfnGetOrdinal; ze_pfnCommandListImmediateGetIndex_t pfnImmediateGetIndex; ze_pfnCommandListIsImmediate_t pfnIsImmediate; + ze_pfnCommandListAppendSignalExternalSemaphoreExt_t pfnAppendSignalExternalSemaphoreExt; + ze_pfnCommandListAppendWaitExternalSemaphoreExt_t pfnAppendWaitExternalSemaphoreExt; } ze_command_list_dditable_t; /////////////////////////////////////////////////////////////////////////////// @@ -2575,6 +2617,40 @@ typedef struct _ze_dditable_t ze_fabric_vertex_exp_dditable_t FabricVertexExp; ze_fabric_edge_exp_dditable_t FabricEdgeExp; } ze_dditable_t; +/// @brief Container for all DDI tables with version and tables set by the Driver +typedef struct _ze_dditable_driver_t +{ + ze_api_version_t version; + uint8_t isValidFlag; + ze_rtas_builder_exp_dditable_t * RTASBuilderExp; + ze_rtas_parallel_operation_exp_dditable_t * RTASParallelOperationExp; + ze_global_dditable_t * Global; + ze_driver_dditable_t * Driver; + ze_driver_exp_dditable_t * DriverExp; + ze_device_dditable_t * Device; + ze_device_exp_dditable_t * DeviceExp; + ze_context_dditable_t * Context; + ze_command_queue_dditable_t * CommandQueue; + ze_command_list_dditable_t * CommandList; + ze_command_list_exp_dditable_t * CommandListExp; + ze_image_dditable_t * Image; + ze_image_exp_dditable_t * ImageExp; + ze_mem_dditable_t * Mem; + ze_mem_exp_dditable_t * MemExp; + ze_fence_dditable_t * Fence; + ze_event_pool_dditable_t * EventPool; + ze_event_dditable_t * Event; + ze_event_exp_dditable_t * EventExp; + ze_module_dditable_t * Module; + ze_module_build_log_dditable_t * ModuleBuildLog; + ze_kernel_dditable_t * Kernel; + ze_kernel_exp_dditable_t * KernelExp; + ze_sampler_dditable_t * Sampler; + ze_physical_mem_dditable_t * PhysicalMem; + ze_virtual_mem_dditable_t * VirtualMem; + ze_fabric_vertex_exp_dditable_t * FabricVertexExp; + ze_fabric_edge_exp_dditable_t * FabricEdgeExp; +} ze_dditable_driver_t; #if defined(__cplusplus) } // extern "C" diff --git a/include/zes.py b/include/zes.py index dc4af648..aaf1ec22 100644 --- a/include/zes.py +++ b/include/zes.py @@ -4,7 +4,7 @@ SPDX-License-Identifier: MIT @file zes.py - @version v1.11-r1.11.8 + @version v1.12-r1.12.0 """ import platform @@ -168,6 +168,7 @@ class zes_structure_type_v(IntEnum): VF_EXP_CAPABILITIES = 0x00020008 ## ::zes_vf_exp_capabilities_t VF_UTIL_MEM_EXP2 = 0x00020009 ## ::zes_vf_util_mem_exp2_t VF_UTIL_ENGINE_EXP2 = 0x00020010 ## ::zes_vf_util_engine_exp2_t + VF_EXP2_CAPABILITIES = 0x00020011 ## ::zes_vf_exp2_capabilities_t class zes_structure_type_t(c_int): def __str__(self): @@ -2508,14 +2509,26 @@ class zes_vf_util_engine_exp_t(Structure): ] ############################################################################### -## @brief Virtual function management capabilities +## @brief Virtual function management capabilities (deprecated) class zes_vf_exp_capabilities_t(Structure): _fields_ = [ ("stype", zes_structure_type_t), ## [in] type of this structure ("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific ## structure (i.e. contains stype and pNext). ("address", zes_pci_address_t), ## [out] Virtual function BDF address - ("vfDeviceMemSize", c_ulong), ## [out] Virtual function memory size in bytes + ("vfDeviceMemSize", c_ulong), ## [out] Virtual function memory size in kilo bytes + ("vfID", c_ulong) ## [out] Virtual Function ID + ] + +############################################################################### +## @brief Virtual function management capabilities +class zes_vf_exp2_capabilities_t(Structure): + _fields_ = [ + ("stype", zes_structure_type_t), ## [in] type of this structure + ("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific + ## structure (i.e. contains stype and pNext). + ("address", zes_pci_address_t), ## [out] Virtual function BDF address + ("vfDeviceMemSize", c_ulonglong), ## [out] Virtual function memory size in bytes ("vfID", c_ulong) ## [out] Virtual Function ID ] @@ -2527,7 +2540,7 @@ class zes_vf_util_mem_exp2_t(Structure): ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific ## structure (i.e. contains stype and pNext). ("vfMemLocation", zes_mem_loc_t), ## [out] Location of this memory (system, device) - ("vfMemUtilized", c_ulonglong) ## [out] Free memory size in bytes. + ("vfMemUtilized", c_ulonglong) ## [out] Utilized memory size in bytes. ] ############################################################################### @@ -3889,6 +3902,13 @@ class _zes_diagnostics_dditable_t(Structure): else: _zesVFManagementGetVFEngineUtilizationExp2_t = CFUNCTYPE( ze_result_t, zes_vf_handle_t, POINTER(c_ulong), POINTER(zes_vf_util_engine_exp2_t) ) +############################################################################### +## @brief Function-pointer for zesVFManagementGetVFCapabilitiesExp2 +if __use_win_types: + _zesVFManagementGetVFCapabilitiesExp2_t = WINFUNCTYPE( ze_result_t, zes_vf_handle_t, POINTER(zes_vf_exp2_capabilities_t) ) +else: + _zesVFManagementGetVFCapabilitiesExp2_t = CFUNCTYPE( ze_result_t, zes_vf_handle_t, POINTER(zes_vf_exp2_capabilities_t) ) + ############################################################################### ## @brief Table of VFManagementExp functions pointers @@ -3901,7 +3921,8 @@ class _zes_vf_management_exp_dditable_t(Structure): ("pfnSetVFTelemetrySamplingIntervalExp", c_void_p), ## _zesVFManagementSetVFTelemetrySamplingIntervalExp_t ("pfnGetVFCapabilitiesExp", c_void_p), ## _zesVFManagementGetVFCapabilitiesExp_t ("pfnGetVFMemoryUtilizationExp2", c_void_p), ## _zesVFManagementGetVFMemoryUtilizationExp2_t - ("pfnGetVFEngineUtilizationExp2", c_void_p) ## _zesVFManagementGetVFEngineUtilizationExp2_t + ("pfnGetVFEngineUtilizationExp2", c_void_p), ## _zesVFManagementGetVFEngineUtilizationExp2_t + ("pfnGetVFCapabilitiesExp2", c_void_p) ## _zesVFManagementGetVFCapabilitiesExp2_t ] ############################################################################### @@ -4309,5 +4330,6 @@ def __init__(self, version : ze_api_version_t): self.zesVFManagementGetVFCapabilitiesExp = _zesVFManagementGetVFCapabilitiesExp_t(self.__dditable.VFManagementExp.pfnGetVFCapabilitiesExp) self.zesVFManagementGetVFMemoryUtilizationExp2 = _zesVFManagementGetVFMemoryUtilizationExp2_t(self.__dditable.VFManagementExp.pfnGetVFMemoryUtilizationExp2) self.zesVFManagementGetVFEngineUtilizationExp2 = _zesVFManagementGetVFEngineUtilizationExp2_t(self.__dditable.VFManagementExp.pfnGetVFEngineUtilizationExp2) + self.zesVFManagementGetVFCapabilitiesExp2 = _zesVFManagementGetVFCapabilitiesExp2_t(self.__dditable.VFManagementExp.pfnGetVFCapabilitiesExp2) # success! diff --git a/include/zes_api.h b/include/zes_api.h index 874643ce..5ece4520 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.11-r1.11.8 + * @version v1.12-r1.12.0 * */ #ifndef _ZES_API_H @@ -161,6 +161,7 @@ typedef enum _zes_structure_type_t ZES_STRUCTURE_TYPE_VF_EXP_CAPABILITIES = 0x00020008, ///< ::zes_vf_exp_capabilities_t ZES_STRUCTURE_TYPE_VF_UTIL_MEM_EXP2 = 0x00020009, ///< ::zes_vf_util_mem_exp2_t ZES_STRUCTURE_TYPE_VF_UTIL_ENGINE_EXP2 = 0x00020010, ///< ::zes_vf_util_engine_exp2_t + ZES_STRUCTURE_TYPE_VF_EXP2_CAPABILITIES = 0x00020011, ///< ::zes_vf_exp2_capabilities_t ZES_STRUCTURE_TYPE_FORCE_UINT32 = 0x7fffffff } zes_structure_type_t; @@ -555,6 +556,10 @@ typedef struct _zes_vf_util_engine_exp_t zes_vf_util_engine_exp_t; /// @brief Forward-declare zes_vf_exp_capabilities_t typedef struct _zes_vf_exp_capabilities_t zes_vf_exp_capabilities_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare zes_vf_exp2_capabilities_t +typedef struct _zes_vf_exp2_capabilities_t zes_vf_exp2_capabilities_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Forward-declare zes_vf_util_mem_exp2_t typedef struct _zes_vf_util_mem_exp2_t zes_vf_util_mem_exp2_t; @@ -7143,18 +7148,31 @@ typedef struct _zes_vf_util_engine_exp_t } zes_vf_util_engine_exp_t; /////////////////////////////////////////////////////////////////////////////// -/// @brief Virtual function management capabilities +/// @brief Virtual function management capabilities (deprecated) typedef struct _zes_vf_exp_capabilities_t { zes_structure_type_t stype; ///< [in] type of this structure void* pNext; ///< [in,out][optional] must be null or a pointer to an extension-specific ///< structure (i.e. contains stype and pNext). zes_pci_address_t address; ///< [out] Virtual function BDF address - uint32_t vfDeviceMemSize; ///< [out] Virtual function memory size in bytes + uint32_t vfDeviceMemSize; ///< [out] Virtual function memory size in kilo bytes uint32_t vfID; ///< [out] Virtual Function ID } zes_vf_exp_capabilities_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Virtual function management capabilities +typedef struct _zes_vf_exp2_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 + uint64_t vfDeviceMemSize; ///< [out] Virtual function memory size in bytes + uint32_t vfID; ///< [out] Virtual Function ID + +} zes_vf_exp2_capabilities_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Provides memory utilization values for a virtual function typedef struct _zes_vf_util_mem_exp2_t @@ -7163,7 +7181,7 @@ typedef struct _zes_vf_util_mem_exp2_t const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific ///< structure (i.e. contains stype and pNext). zes_mem_loc_t vfMemLocation; ///< [out] Location of this memory (system, device) - uint64_t vfMemUtilized; ///< [out] Free memory size in bytes. + uint64_t vfMemUtilized; ///< [out] Utilized memory size in bytes. } zes_vf_util_mem_exp2_t; @@ -7413,6 +7431,8 @@ zesDeviceEnumEnabledVFExp( /// @brief Get virtual function management capabilities /// /// @details +/// - [DEPRECATED] No longer supported. Use +/// ::zesVFManagementGetVFCapabilitiesExp2. /// - The application may call this function from simultaneous threads. /// - The implementation of this function should be lock-free. /// @@ -7502,6 +7522,29 @@ zesVFManagementGetVFEngineUtilizationExp2( ///< engine stats. ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get virtual function management capabilities +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hVFhandle` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCapability` +ZE_APIEXPORT ze_result_t ZE_APICALL +zesVFManagementGetVFCapabilitiesExp2( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. + zes_vf_exp2_capabilities_t* pCapability ///< [in,out] Will contain VF capability. + ); + #if !defined(__GNUC__) #pragma endregion #endif diff --git a/include/zes_ddi.h b/include/zes_ddi.h index 27ef4403..84c1925e 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.11-r1.11.8 + * @version v1.12-r1.12.0 * */ #ifndef _ZES_DDI_H @@ -1918,6 +1918,13 @@ typedef ze_result_t (ZE_APICALL *zes_pfnVFManagementGetVFEngineUtilizationExp2_t zes_vf_util_engine_exp2_t* ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zesVFManagementGetVFCapabilitiesExp2 +typedef ze_result_t (ZE_APICALL *zes_pfnVFManagementGetVFCapabilitiesExp2_t)( + zes_vf_handle_t, + zes_vf_exp2_capabilities_t* + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Table of VFManagementExp functions pointers typedef struct _zes_vf_management_exp_dditable_t @@ -1930,6 +1937,7 @@ typedef struct _zes_vf_management_exp_dditable_t zes_pfnVFManagementGetVFCapabilitiesExp_t pfnGetVFCapabilitiesExp; zes_pfnVFManagementGetVFMemoryUtilizationExp2_t pfnGetVFMemoryUtilizationExp2; zes_pfnVFManagementGetVFEngineUtilizationExp2_t pfnGetVFEngineUtilizationExp2; + zes_pfnVFManagementGetVFCapabilitiesExp2_t pfnGetVFCapabilitiesExp2; } zes_vf_management_exp_dditable_t; /////////////////////////////////////////////////////////////////////////////// @@ -1983,6 +1991,36 @@ typedef struct _zes_dditable_t zes_diagnostics_dditable_t Diagnostics; zes_vf_management_exp_dditable_t VFManagementExp; } zes_dditable_t; +/// @brief Container for all DDI tables with version and tables set by the Driver +typedef struct _zes_dditable_driver_t +{ + ze_api_version_t version; + uint8_t isValidFlag; + zes_global_dditable_t * Global; + zes_device_dditable_t * Device; + zes_device_exp_dditable_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_t * VFManagementExp; +} zes_dditable_driver_t; #if defined(__cplusplus) } // extern "C" diff --git a/include/zet.py b/include/zet.py index 993e7383..0162b975 100644 --- a/include/zet.py +++ b/include/zet.py @@ -4,7 +4,7 @@ SPDX-License-Identifier: MIT @file zet.py - @version v1.11-r1.11.8 + @version v1.12-r1.12.0 """ import platform diff --git a/include/zet_api.h b/include/zet_api.h index 15c74eb5..d37cf6ae 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.11-r1.11.8 + * @version v1.12-r1.12.0 * */ #ifndef _ZET_API_H diff --git a/include/zet_ddi.h b/include/zet_ddi.h index 8d6d7c0d..43b1394b 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.11-r1.11.8 + * @version v1.12-r1.12.0 * */ #ifndef _ZET_DDI_H @@ -1166,6 +1166,30 @@ typedef struct _zet_dditable_t zet_tracer_exp_dditable_t TracerExp; zet_debug_dditable_t Debug; } zet_dditable_t; +/// @brief Container for all DDI tables with version and tables set by the Driver +typedef struct _zet_dditable_driver_t +{ + ze_api_version_t version; + uint8_t isValidFlag; + 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_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_driver_t; #if defined(__cplusplus) } // extern "C" diff --git a/source/drivers/null/ze_nullddi.cpp b/source/drivers/null/ze_nullddi.cpp index 4eb10ddb..fc19bac5 100644 --- a/source/drivers/null/ze_nullddi.cpp +++ b/source/drivers/null/ze_nullddi.cpp @@ -3994,6 +3994,120 @@ namespace driver return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceImportExternalSemaphoreExt + __zedlllocal ze_result_t ZE_APICALL + zeDeviceImportExternalSemaphoreExt( + ze_device_handle_t hDevice, ///< [in] The device handle. + const ze_external_semaphore_ext_desc_t* desc, ///< [in] The pointer to external semaphore descriptor. + ze_external_semaphore_ext_handle_t* phSemaphore ///< [out] The handle of the external semaphore imported. + ) + { + 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 pfnImportExternalSemaphoreExt = context.zeDdiTable.Device.pfnImportExternalSemaphoreExt; + if( nullptr != pfnImportExternalSemaphoreExt ) + { + result = pfnImportExternalSemaphoreExt( hDevice, desc, phSemaphore ); + } + else + { + // generic implementation + *phSemaphore = reinterpret_cast( context.get() ); + + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceReleaseExternalSemaphoreExt + __zedlllocal ze_result_t ZE_APICALL + zeDeviceReleaseExternalSemaphoreExt( + ze_external_semaphore_ext_handle_t hSemaphore ///< [in] The handle of the external semaphore. + ) + { + 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 pfnReleaseExternalSemaphoreExt = context.zeDdiTable.Device.pfnReleaseExternalSemaphoreExt; + if( nullptr != pfnReleaseExternalSemaphoreExt ) + { + result = pfnReleaseExternalSemaphoreExt( hSemaphore ); + } + else + { + // generic implementation + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendSignalExternalSemaphoreExt + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendSignalExternalSemaphoreExt( + ze_command_list_handle_t hCommandList, ///< [in] The command list handle. + uint32_t numSemaphores, ///< [in] The number of external semaphores. + ze_external_semaphore_ext_handle_t* phSemaphores, ///< [in][range(0, numSemaphores)] The vector of external semaphore handles + ///< to be appended into command list. + ze_external_semaphore_signal_params_ext_t* signalParams,///< [in] Signal parameters. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; 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 + ) + { + 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 pfnAppendSignalExternalSemaphoreExt = context.zeDdiTable.CommandList.pfnAppendSignalExternalSemaphoreExt; + if( nullptr != pfnAppendSignalExternalSemaphoreExt ) + { + result = pfnAppendSignalExternalSemaphoreExt( hCommandList, numSemaphores, phSemaphores, signalParams, hSignalEvent, numWaitEvents, phWaitEvents ); + } + else + { + // generic implementation + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendWaitExternalSemaphoreExt + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendWaitExternalSemaphoreExt( + ze_command_list_handle_t hCommandList, ///< [in] The command list handle. + uint32_t numSemaphores, ///< [in] The number of external semaphores. + ze_external_semaphore_ext_handle_t* phSemaphores, ///< [in] [range(0,numSemaphores)] The vector of external semaphore handles + ///< to append into command list. + ze_external_semaphore_wait_params_ext_t* waitParams,///< [in] Wait parameters. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; 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 + ) + { + 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 pfnAppendWaitExternalSemaphoreExt = context.zeDdiTable.CommandList.pfnAppendWaitExternalSemaphoreExt; + if( nullptr != pfnAppendWaitExternalSemaphoreExt ) + { + result = pfnAppendWaitExternalSemaphoreExt( hCommandList, numSemaphores, phSemaphores, waitParams, hSignalEvent, numWaitEvents, phWaitEvents ); + } + else + { + // generic implementation + } + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeDeviceReserveCacheExt __zedlllocal ze_result_t ZE_APICALL @@ -5360,6 +5474,10 @@ zeGetDeviceProcAddrTable( pDdiTable->pfnGetGlobalTimestamps = driver::zeDeviceGetGlobalTimestamps; + pDdiTable->pfnImportExternalSemaphoreExt = driver::zeDeviceImportExternalSemaphoreExt; + + pDdiTable->pfnReleaseExternalSemaphoreExt = driver::zeDeviceReleaseExternalSemaphoreExt; + pDdiTable->pfnReserveCacheExt = driver::zeDeviceReserveCacheExt; pDdiTable->pfnSetCacheAdviceExt = driver::zeDeviceSetCacheAdviceExt; @@ -5552,6 +5670,10 @@ zeGetCommandListProcAddrTable( pDdiTable->pfnAppendLaunchMultipleKernelsIndirect = driver::zeCommandListAppendLaunchMultipleKernelsIndirect; + pDdiTable->pfnAppendSignalExternalSemaphoreExt = driver::zeCommandListAppendSignalExternalSemaphoreExt; + + pDdiTable->pfnAppendWaitExternalSemaphoreExt = driver::zeCommandListAppendWaitExternalSemaphoreExt; + pDdiTable->pfnAppendImageCopyToMemoryExt = driver::zeCommandListAppendImageCopyToMemoryExt; pDdiTable->pfnAppendImageCopyFromMemoryExt = driver::zeCommandListAppendImageCopyFromMemoryExt; diff --git a/source/drivers/null/zes_nullddi.cpp b/source/drivers/null/zes_nullddi.cpp index 0692ab09..0e9e8b75 100644 --- a/source/drivers/null/zes_nullddi.cpp +++ b/source/drivers/null/zes_nullddi.cpp @@ -4092,6 +4092,30 @@ namespace driver return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesVFManagementGetVFCapabilitiesExp2 + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFCapabilitiesExp2( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. + zes_vf_exp2_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 pfnGetVFCapabilitiesExp2 = context.zesDdiTable.VFManagementExp.pfnGetVFCapabilitiesExp2; + if( nullptr != pfnGetVFCapabilitiesExp2 ) + { + result = pfnGetVFCapabilitiesExp2( hVFhandle, pCapability ); + } + else + { + // generic implementation + } + + return result; + } + } // namespace driver #if defined(__cplusplus) @@ -4981,6 +5005,8 @@ zesGetVFManagementExpProcAddrTable( pDdiTable->pfnGetVFEngineUtilizationExp2 = driver::zesVFManagementGetVFEngineUtilizationExp2; + pDdiTable->pfnGetVFCapabilitiesExp2 = driver::zesVFManagementGetVFCapabilitiesExp2; + pDdiTable->pfnGetVFPropertiesExp = driver::zesVFManagementGetVFPropertiesExp; pDdiTable->pfnGetVFMemoryUtilizationExp = driver::zesVFManagementGetVFMemoryUtilizationExp; diff --git a/source/layers/tracing/ze_tracing_cb_structs.h b/source/layers/tracing/ze_tracing_cb_structs.h index 601e66cf..5e6f6e74 100644 --- a/source/layers/tracing/ze_tracing_cb_structs.h +++ b/source/layers/tracing/ze_tracing_cb_structs.h @@ -79,6 +79,8 @@ typedef struct _zel_device_callbacks_t ze_pfnDeviceCanAccessPeerCb_t pfnCanAccessPeerCb; ze_pfnDeviceGetStatusCb_t pfnGetStatusCb; ze_pfnDeviceGetGlobalTimestampsCb_t pfnGetGlobalTimestampsCb; + ze_pfnDeviceImportExternalSemaphoreExtCb_t pfnImportExternalSemaphoreExtCb; + ze_pfnDeviceReleaseExternalSemaphoreExtCb_t pfnReleaseExternalSemaphoreExtCb; ze_pfnDeviceReserveCacheExtCb_t pfnReserveCacheExtCb; ze_pfnDeviceSetCacheAdviceExtCb_t pfnSetCacheAdviceExtCb; ze_pfnDevicePciGetPropertiesExtCb_t pfnPciGetPropertiesExtCb; @@ -145,6 +147,8 @@ typedef struct _zel_command_list_callbacks_t ze_pfnCommandListAppendLaunchMultipleKernelsIndirectCb_t pfnAppendLaunchMultipleKernelsIndirectCb; ze_pfnCommandListGetNextCommandIdWithKernelsExpCb_t pfnGetNextCommandIdWithKernelsExpCb; ze_pfnCommandListUpdateMutableCommandKernelsExpCb_t pfnUpdateMutableCommandKernelsExpCb; + ze_pfnCommandListAppendSignalExternalSemaphoreExtCb_t pfnAppendSignalExternalSemaphoreExtCb; + ze_pfnCommandListAppendWaitExternalSemaphoreExtCb_t pfnAppendWaitExternalSemaphoreExtCb; ze_pfnCommandListAppendImageCopyToMemoryExtCb_t pfnAppendImageCopyToMemoryExtCb; ze_pfnCommandListAppendImageCopyFromMemoryExtCb_t pfnAppendImageCopyFromMemoryExtCb; ze_pfnCommandListHostSynchronizeCb_t pfnHostSynchronizeCb; diff --git a/source/layers/tracing/ze_tracing_register_cb.cpp b/source/layers/tracing/ze_tracing_register_cb.cpp index 3ccdc516..bf2379a0 100644 --- a/source/layers/tracing/ze_tracing_register_cb.cpp +++ b/source/layers/tracing/ze_tracing_register_cb.cpp @@ -2371,6 +2371,70 @@ zelTracerKernelGetBinaryExpRegisterCallback( } +ZE_DLLEXPORT ze_result_t ZE_APICALL +zelTracerDeviceImportExternalSemaphoreExtRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnDeviceImportExternalSemaphoreExtCb_t pfnImportExternalSemaphoreExtCb + ) { + + ze_result_t result; + auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result); + if (result == ZE_RESULT_SUCCESS) + cbs.Device.pfnImportExternalSemaphoreExtCb = pfnImportExternalSemaphoreExtCb; + + return result; +} + + +ZE_DLLEXPORT ze_result_t ZE_APICALL +zelTracerDeviceReleaseExternalSemaphoreExtRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnDeviceReleaseExternalSemaphoreExtCb_t pfnReleaseExternalSemaphoreExtCb + ) { + + ze_result_t result; + auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result); + if (result == ZE_RESULT_SUCCESS) + cbs.Device.pfnReleaseExternalSemaphoreExtCb = pfnReleaseExternalSemaphoreExtCb; + + return result; +} + + +ZE_DLLEXPORT ze_result_t ZE_APICALL +zelTracerCommandListAppendSignalExternalSemaphoreExtRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListAppendSignalExternalSemaphoreExtCb_t pfnAppendSignalExternalSemaphoreExtCb + ) { + + ze_result_t result; + auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result); + if (result == ZE_RESULT_SUCCESS) + cbs.CommandList.pfnAppendSignalExternalSemaphoreExtCb = pfnAppendSignalExternalSemaphoreExtCb; + + return result; +} + + +ZE_DLLEXPORT ze_result_t ZE_APICALL +zelTracerCommandListAppendWaitExternalSemaphoreExtRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListAppendWaitExternalSemaphoreExtCb_t pfnAppendWaitExternalSemaphoreExtCb + ) { + + ze_result_t result; + auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result); + if (result == ZE_RESULT_SUCCESS) + cbs.CommandList.pfnAppendWaitExternalSemaphoreExtCb = pfnAppendWaitExternalSemaphoreExtCb; + + return result; +} + + ZE_DLLEXPORT ze_result_t ZE_APICALL zelTracerDeviceReserveCacheExtRegisterCallback( zel_tracer_handle_t hTracer, diff --git a/source/layers/tracing/ze_trcddi.cpp b/source/layers/tracing/ze_trcddi.cpp index 5342ffea..9df2671d 100644 --- a/source/layers/tracing/ze_trcddi.cpp +++ b/source/layers/tracing/ze_trcddi.cpp @@ -5865,6 +5865,182 @@ namespace tracing_layer *tracerParams.ppKernelBinary); } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceImportExternalSemaphoreExt + __zedlllocal ze_result_t ZE_APICALL + zeDeviceImportExternalSemaphoreExt( + ze_device_handle_t hDevice, ///< [in] The device handle. + const ze_external_semaphore_ext_desc_t* desc, ///< [in] The pointer to external semaphore descriptor. + ze_external_semaphore_ext_handle_t* phSemaphore ///< [out] The handle of the external semaphore imported. + ) + { + auto pfnImportExternalSemaphoreExt = context.zeDdiTable.Device.pfnImportExternalSemaphoreExt; + + if( nullptr == pfnImportExternalSemaphoreExt) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.Device.pfnImportExternalSemaphoreExt, hDevice, desc, phSemaphore); + + // capture parameters + ze_device_import_external_semaphore_ext_params_t tracerParams = { + &hDevice, + &desc, + &phSemaphore + }; + + tracing_layer::APITracerCallbackDataImp apiCallbackData; + + ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnDeviceImportExternalSemaphoreExtCb_t, Device, pfnImportExternalSemaphoreExtCb); + + + return tracing_layer::APITracerWrapperImp(context.zeDdiTable.Device.pfnImportExternalSemaphoreExt, + &tracerParams, + apiCallbackData.apiOrdinal, + apiCallbackData.prologCallbacks, + apiCallbackData.epilogCallbacks, + *tracerParams.phDevice, + *tracerParams.pdesc, + *tracerParams.pphSemaphore); + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceReleaseExternalSemaphoreExt + __zedlllocal ze_result_t ZE_APICALL + zeDeviceReleaseExternalSemaphoreExt( + ze_external_semaphore_ext_handle_t hSemaphore ///< [in] The handle of the external semaphore. + ) + { + auto pfnReleaseExternalSemaphoreExt = context.zeDdiTable.Device.pfnReleaseExternalSemaphoreExt; + + if( nullptr == pfnReleaseExternalSemaphoreExt) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.Device.pfnReleaseExternalSemaphoreExt, hSemaphore); + + // capture parameters + ze_device_release_external_semaphore_ext_params_t tracerParams = { + &hSemaphore + }; + + tracing_layer::APITracerCallbackDataImp apiCallbackData; + + ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnDeviceReleaseExternalSemaphoreExtCb_t, Device, pfnReleaseExternalSemaphoreExtCb); + + + return tracing_layer::APITracerWrapperImp(context.zeDdiTable.Device.pfnReleaseExternalSemaphoreExt, + &tracerParams, + apiCallbackData.apiOrdinal, + apiCallbackData.prologCallbacks, + apiCallbackData.epilogCallbacks, + *tracerParams.phSemaphore); + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendSignalExternalSemaphoreExt + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendSignalExternalSemaphoreExt( + ze_command_list_handle_t hCommandList, ///< [in] The command list handle. + uint32_t numSemaphores, ///< [in] The number of external semaphores. + ze_external_semaphore_ext_handle_t* phSemaphores, ///< [in][range(0, numSemaphores)] The vector of external semaphore handles + ///< to be appended into command list. + ze_external_semaphore_signal_params_ext_t* signalParams,///< [in] Signal parameters. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; 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 + ) + { + auto pfnAppendSignalExternalSemaphoreExt = context.zeDdiTable.CommandList.pfnAppendSignalExternalSemaphoreExt; + + if( nullptr == pfnAppendSignalExternalSemaphoreExt) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.CommandList.pfnAppendSignalExternalSemaphoreExt, hCommandList, numSemaphores, phSemaphores, signalParams, hSignalEvent, numWaitEvents, phWaitEvents); + + // capture parameters + ze_command_list_append_signal_external_semaphore_ext_params_t tracerParams = { + &hCommandList, + &numSemaphores, + &phSemaphores, + &signalParams, + &hSignalEvent, + &numWaitEvents, + &phWaitEvents + }; + + tracing_layer::APITracerCallbackDataImp apiCallbackData; + + ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnCommandListAppendSignalExternalSemaphoreExtCb_t, CommandList, pfnAppendSignalExternalSemaphoreExtCb); + + + return tracing_layer::APITracerWrapperImp(context.zeDdiTable.CommandList.pfnAppendSignalExternalSemaphoreExt, + &tracerParams, + apiCallbackData.apiOrdinal, + apiCallbackData.prologCallbacks, + apiCallbackData.epilogCallbacks, + *tracerParams.phCommandList, + *tracerParams.pnumSemaphores, + *tracerParams.pphSemaphores, + *tracerParams.psignalParams, + *tracerParams.phSignalEvent, + *tracerParams.pnumWaitEvents, + *tracerParams.pphWaitEvents); + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendWaitExternalSemaphoreExt + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendWaitExternalSemaphoreExt( + ze_command_list_handle_t hCommandList, ///< [in] The command list handle. + uint32_t numSemaphores, ///< [in] The number of external semaphores. + ze_external_semaphore_ext_handle_t* phSemaphores, ///< [in] [range(0,numSemaphores)] The vector of external semaphore handles + ///< to append into command list. + ze_external_semaphore_wait_params_ext_t* waitParams,///< [in] Wait parameters. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; 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 + ) + { + auto pfnAppendWaitExternalSemaphoreExt = context.zeDdiTable.CommandList.pfnAppendWaitExternalSemaphoreExt; + + if( nullptr == pfnAppendWaitExternalSemaphoreExt) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.CommandList.pfnAppendWaitExternalSemaphoreExt, hCommandList, numSemaphores, phSemaphores, waitParams, hSignalEvent, numWaitEvents, phWaitEvents); + + // capture parameters + ze_command_list_append_wait_external_semaphore_ext_params_t tracerParams = { + &hCommandList, + &numSemaphores, + &phSemaphores, + &waitParams, + &hSignalEvent, + &numWaitEvents, + &phWaitEvents + }; + + tracing_layer::APITracerCallbackDataImp apiCallbackData; + + ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnCommandListAppendWaitExternalSemaphoreExtCb_t, CommandList, pfnAppendWaitExternalSemaphoreExtCb); + + + return tracing_layer::APITracerWrapperImp(context.zeDdiTable.CommandList.pfnAppendWaitExternalSemaphoreExt, + &tracerParams, + apiCallbackData.apiOrdinal, + apiCallbackData.prologCallbacks, + apiCallbackData.epilogCallbacks, + *tracerParams.phCommandList, + *tracerParams.pnumSemaphores, + *tracerParams.pphSemaphores, + *tracerParams.pwaitParams, + *tracerParams.phSignalEvent, + *tracerParams.pnumWaitEvents, + *tracerParams.pphWaitEvents); + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeDeviceReserveCacheExt __zedlllocal ze_result_t ZE_APICALL @@ -7820,6 +7996,12 @@ zeGetDeviceProcAddrTable( dditable.pfnGetGlobalTimestamps = pDdiTable->pfnGetGlobalTimestamps; pDdiTable->pfnGetGlobalTimestamps = tracing_layer::zeDeviceGetGlobalTimestamps; + dditable.pfnImportExternalSemaphoreExt = pDdiTable->pfnImportExternalSemaphoreExt; + pDdiTable->pfnImportExternalSemaphoreExt = tracing_layer::zeDeviceImportExternalSemaphoreExt; + + dditable.pfnReleaseExternalSemaphoreExt = pDdiTable->pfnReleaseExternalSemaphoreExt; + pDdiTable->pfnReleaseExternalSemaphoreExt = tracing_layer::zeDeviceReleaseExternalSemaphoreExt; + dditable.pfnReserveCacheExt = pDdiTable->pfnReserveCacheExt; pDdiTable->pfnReserveCacheExt = tracing_layer::zeDeviceReserveCacheExt; @@ -8070,6 +8252,12 @@ zeGetCommandListProcAddrTable( dditable.pfnAppendLaunchMultipleKernelsIndirect = pDdiTable->pfnAppendLaunchMultipleKernelsIndirect; pDdiTable->pfnAppendLaunchMultipleKernelsIndirect = tracing_layer::zeCommandListAppendLaunchMultipleKernelsIndirect; + dditable.pfnAppendSignalExternalSemaphoreExt = pDdiTable->pfnAppendSignalExternalSemaphoreExt; + pDdiTable->pfnAppendSignalExternalSemaphoreExt = tracing_layer::zeCommandListAppendSignalExternalSemaphoreExt; + + dditable.pfnAppendWaitExternalSemaphoreExt = pDdiTable->pfnAppendWaitExternalSemaphoreExt; + pDdiTable->pfnAppendWaitExternalSemaphoreExt = tracing_layer::zeCommandListAppendWaitExternalSemaphoreExt; + dditable.pfnAppendImageCopyToMemoryExt = pDdiTable->pfnAppendImageCopyToMemoryExt; pDdiTable->pfnAppendImageCopyToMemoryExt = tracing_layer::zeCommandListAppendImageCopyToMemoryExt; 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 89fdccc1..d51c6b3f 100644 --- a/source/layers/validation/checkers/parameter_validation/ze_parameter_validation.cpp +++ b/source/layers/validation/checkers/parameter_validation/ze_parameter_validation.cpp @@ -3064,6 +3064,113 @@ namespace validation_layer } + ze_result_t + ZEParameterValidation::zeDeviceImportExternalSemaphoreExtPrologue( + ze_device_handle_t hDevice, ///< [in] The device handle. + const ze_external_semaphore_ext_desc_t* desc, ///< [in] The pointer to external semaphore descriptor. + ze_external_semaphore_ext_handle_t* phSemaphore ///< [out] The handle of the external semaphore imported. + ) + { + if( nullptr == hDevice ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == desc ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( nullptr == phSemaphore ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( 0x1ff < desc->flags ) + return ZE_RESULT_ERROR_INVALID_ENUMERATION; + + return ParameterValidation::validateExtensions(desc); + } + + + ze_result_t + ZEParameterValidation::zeDeviceReleaseExternalSemaphoreExtPrologue( + ze_external_semaphore_ext_handle_t hSemaphore ///< [in] The handle of the external semaphore. + ) + { + if( nullptr == hSemaphore ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + return ZE_RESULT_SUCCESS; + } + + + ze_result_t + ZEParameterValidation::zeCommandListAppendSignalExternalSemaphoreExtPrologue( + ze_command_list_handle_t hCommandList, ///< [in] The command list handle. + uint32_t numSemaphores, ///< [in] The number of external semaphores. + ze_external_semaphore_ext_handle_t* phSemaphores, ///< [in][range(0, numSemaphores)] The vector of external semaphore handles + ///< to be appended into command list. + ze_external_semaphore_signal_params_ext_t* signalParams,///< [in] Signal parameters. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; 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 + ) + { + if( nullptr == hCommandList ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == phSemaphores ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( nullptr == signalParams ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( (nullptr == phWaitEvents) && (0 < numWaitEvents) ) + return ZE_RESULT_ERROR_INVALID_SIZE; + + if( (nullptr == phSemaphores) && (0 < numSemaphores) ) + return ZE_RESULT_ERROR_INVALID_SIZE; + + if( (nullptr == signalParams) && (0 < numSemaphores) ) + return ZE_RESULT_ERROR_INVALID_SIZE; + + return ZE_RESULT_SUCCESS; + } + + + ze_result_t + ZEParameterValidation::zeCommandListAppendWaitExternalSemaphoreExtPrologue( + ze_command_list_handle_t hCommandList, ///< [in] The command list handle. + uint32_t numSemaphores, ///< [in] The number of external semaphores. + ze_external_semaphore_ext_handle_t* phSemaphores, ///< [in] [range(0,numSemaphores)] The vector of external semaphore handles + ///< to append into command list. + ze_external_semaphore_wait_params_ext_t* waitParams,///< [in] Wait parameters. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; 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 + ) + { + if( nullptr == hCommandList ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == phSemaphores ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( nullptr == waitParams ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( (nullptr == phWaitEvents) && (0 < numWaitEvents) ) + return ZE_RESULT_ERROR_INVALID_SIZE; + + if( (nullptr == phSemaphores) && (0 < numSemaphores) ) + return ZE_RESULT_ERROR_INVALID_SIZE; + + if( (nullptr == waitParams) && (0 < numSemaphores) ) + return ZE_RESULT_ERROR_INVALID_SIZE; + + return ZE_RESULT_SUCCESS; + } + + ze_result_t ZEParameterValidation::zeDeviceReserveCacheExtPrologue( ze_device_handle_t hDevice, ///< [in] handle of the device object 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 d193a1be..a22a25ff 100644 --- a/source/layers/validation/checkers/parameter_validation/ze_parameter_validation.h +++ b/source/layers/validation/checkers/parameter_validation/ze_parameter_validation.h @@ -167,6 +167,10 @@ namespace validation_layer 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 zeKernelGetBinaryExpPrologue( ze_kernel_handle_t hKernel, size_t* pSize, uint8_t* pKernelBinary ) override; + ze_result_t zeDeviceImportExternalSemaphoreExtPrologue( ze_device_handle_t hDevice, const ze_external_semaphore_ext_desc_t* desc, ze_external_semaphore_ext_handle_t* phSemaphore ) override; + ze_result_t zeDeviceReleaseExternalSemaphoreExtPrologue( ze_external_semaphore_ext_handle_t hSemaphore ) override; + ze_result_t zeCommandListAppendSignalExternalSemaphoreExtPrologue( ze_command_list_handle_t hCommandList, uint32_t numSemaphores, ze_external_semaphore_ext_handle_t* phSemaphores, ze_external_semaphore_signal_params_ext_t* signalParams, ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) override; + ze_result_t zeCommandListAppendWaitExternalSemaphoreExtPrologue( ze_command_list_handle_t hCommandList, uint32_t numSemaphores, ze_external_semaphore_ext_handle_t* phSemaphores, ze_external_semaphore_wait_params_ext_t* waitParams, ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) 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; 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 4f90e12c..8d14ac89 100644 --- a/source/layers/validation/checkers/parameter_validation/zes_parameter_validation.cpp +++ b/source/layers/validation/checkers/parameter_validation/zes_parameter_validation.cpp @@ -2873,4 +2873,20 @@ namespace validation_layer return ZE_RESULT_SUCCESS; } + + ze_result_t + ZESParameterValidation::zesVFManagementGetVFCapabilitiesExp2Prologue( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. + zes_vf_exp2_capabilities_t* pCapability ///< [in,out] Will contain VF capability. + ) + { + if( nullptr == hVFhandle ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == pCapability ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + return ParameterValidation::validateExtensions(pCapability); + } + } \ 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 88f72bbe..2ae67bd2 100644 --- a/source/layers/validation/checkers/parameter_validation/zes_parameter_validation.h +++ b/source/layers/validation/checkers/parameter_validation/zes_parameter_validation.h @@ -168,5 +168,6 @@ namespace validation_layer ze_result_t zesVFManagementGetVFCapabilitiesExpPrologue( zes_vf_handle_t hVFhandle, zes_vf_exp_capabilities_t* pCapability ) override; ze_result_t zesVFManagementGetVFMemoryUtilizationExp2Prologue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_mem_exp2_t* pMemUtil ) override; ze_result_t zesVFManagementGetVFEngineUtilizationExp2Prologue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_engine_exp2_t* pEngineUtil ) override; + ze_result_t zesVFManagementGetVFCapabilitiesExp2Prologue( zes_vf_handle_t hVFhandle, zes_vf_exp2_capabilities_t* pCapability ) override; }; } \ No newline at end of file diff --git a/source/layers/validation/common/ze_entry_points.h b/source/layers/validation/common/ze_entry_points.h index 96cdce58..c96c1ec5 100644 --- a/source/layers/validation/common/ze_entry_points.h +++ b/source/layers/validation/common/ze_entry_points.h @@ -311,6 +311,14 @@ class ZEValidationEntryPoints { virtual ze_result_t zeKernelSetGlobalOffsetExpEpilogue( ze_kernel_handle_t hKernel, uint32_t offsetX, uint32_t offsetY, uint32_t offsetZ , ze_result_t result) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeKernelGetBinaryExpPrologue( ze_kernel_handle_t hKernel, size_t* pSize, uint8_t* pKernelBinary ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeKernelGetBinaryExpEpilogue( ze_kernel_handle_t hKernel, size_t* pSize, uint8_t* pKernelBinary , ze_result_t result) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeDeviceImportExternalSemaphoreExtPrologue( ze_device_handle_t hDevice, const ze_external_semaphore_ext_desc_t* desc, ze_external_semaphore_ext_handle_t* phSemaphore ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeDeviceImportExternalSemaphoreExtEpilogue( ze_device_handle_t hDevice, const ze_external_semaphore_ext_desc_t* desc, ze_external_semaphore_ext_handle_t* phSemaphore , ze_result_t result) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeDeviceReleaseExternalSemaphoreExtPrologue( ze_external_semaphore_ext_handle_t hSemaphore ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeDeviceReleaseExternalSemaphoreExtEpilogue( ze_external_semaphore_ext_handle_t hSemaphore , ze_result_t result) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeCommandListAppendSignalExternalSemaphoreExtPrologue( ze_command_list_handle_t hCommandList, uint32_t numSemaphores, ze_external_semaphore_ext_handle_t* phSemaphores, ze_external_semaphore_signal_params_ext_t* signalParams, ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeCommandListAppendSignalExternalSemaphoreExtEpilogue( ze_command_list_handle_t hCommandList, uint32_t numSemaphores, ze_external_semaphore_ext_handle_t* phSemaphores, ze_external_semaphore_signal_params_ext_t* signalParams, ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents , ze_result_t result) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeCommandListAppendWaitExternalSemaphoreExtPrologue( ze_command_list_handle_t hCommandList, uint32_t numSemaphores, ze_external_semaphore_ext_handle_t* phSemaphores, ze_external_semaphore_wait_params_ext_t* waitParams, ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeCommandListAppendWaitExternalSemaphoreExtEpilogue( ze_command_list_handle_t hCommandList, uint32_t numSemaphores, ze_external_semaphore_ext_handle_t* phSemaphores, ze_external_semaphore_wait_params_ext_t* waitParams, ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents , ze_result_t result) {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 , ze_result_t result) {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;} diff --git a/source/layers/validation/common/zes_entry_points.h b/source/layers/validation/common/zes_entry_points.h index a9659c3d..fdfe053a 100644 --- a/source/layers/validation/common/zes_entry_points.h +++ b/source/layers/validation/common/zes_entry_points.h @@ -313,6 +313,8 @@ class ZESValidationEntryPoints { virtual ze_result_t zesVFManagementGetVFMemoryUtilizationExp2Epilogue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_mem_exp2_t* pMemUtil , ze_result_t result) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zesVFManagementGetVFEngineUtilizationExp2Prologue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_engine_exp2_t* pEngineUtil ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zesVFManagementGetVFEngineUtilizationExp2Epilogue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_engine_exp2_t* pEngineUtil , ze_result_t result) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zesVFManagementGetVFCapabilitiesExp2Prologue( zes_vf_handle_t hVFhandle, zes_vf_exp2_capabilities_t* pCapability ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zesVFManagementGetVFCapabilitiesExp2Epilogue( zes_vf_handle_t hVFhandle, zes_vf_exp2_capabilities_t* pCapability , ze_result_t result) {return ZE_RESULT_SUCCESS;} virtual ~ZESValidationEntryPoints() {} }; } \ No newline at end of file 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 7edec245..b892b6c0 100644 --- a/source/layers/validation/handle_lifetime_tracking/ze_handle_lifetime.cpp +++ b/source/layers/validation/handle_lifetime_tracking/ze_handle_lifetime.cpp @@ -2510,6 +2510,102 @@ namespace validation_layer return ZE_RESULT_SUCCESS; } ze_result_t + ZEHandleLifetimeValidation::zeDeviceImportExternalSemaphoreExtPrologue( + ze_device_handle_t hDevice, ///< [in] The device handle. + const ze_external_semaphore_ext_desc_t* desc, ///< [in] The pointer to external semaphore descriptor. + ze_external_semaphore_ext_handle_t* phSemaphore ///< [out] The handle of the external semaphore imported. + ) + { + + if ( !context.handleLifetime->isHandleValid( hDevice )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + return ZE_RESULT_SUCCESS; + } + ze_result_t + ZEHandleLifetimeValidation::zeDeviceReleaseExternalSemaphoreExtPrologue( + ze_external_semaphore_ext_handle_t hSemaphore ///< [in] The handle of the external semaphore. + ) + { + + if ( !context.handleLifetime->isHandleValid( hSemaphore )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + return ZE_RESULT_SUCCESS; + } + ze_result_t + ZEHandleLifetimeValidation::zeCommandListAppendSignalExternalSemaphoreExtPrologue( + ze_command_list_handle_t hCommandList, ///< [in] The command list handle. + uint32_t numSemaphores, ///< [in] The number of external semaphores. + ze_external_semaphore_ext_handle_t* phSemaphores, ///< [in][range(0, numSemaphores)] The vector of external semaphore handles + ///< to be appended into command list. + ze_external_semaphore_signal_params_ext_t* signalParams,///< [in] Signal parameters. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; 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 + ) + { + + if ( !context.handleLifetime->isHandleValid( hCommandList )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (!context.handleLifetime->isOpen( hCommandList )){ + return ZE_RESULT_ERROR_INVALID_ARGUMENT; + } + for (size_t i = 0; ( nullptr != phSemaphores) && (i < numSemaphores); ++i){ + if (!context.handleLifetime->isHandleValid( phSemaphores[i] )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + } + if (hSignalEvent && !context.handleLifetime->isHandleValid( hSignalEvent )){ + 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::zeCommandListAppendWaitExternalSemaphoreExtPrologue( + ze_command_list_handle_t hCommandList, ///< [in] The command list handle. + uint32_t numSemaphores, ///< [in] The number of external semaphores. + ze_external_semaphore_ext_handle_t* phSemaphores, ///< [in] [range(0,numSemaphores)] The vector of external semaphore handles + ///< to append into command list. + ze_external_semaphore_wait_params_ext_t* waitParams,///< [in] Wait parameters. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; 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 + ) + { + + if ( !context.handleLifetime->isHandleValid( hCommandList )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + if (!context.handleLifetime->isOpen( hCommandList )){ + return ZE_RESULT_ERROR_INVALID_ARGUMENT; + } + for (size_t i = 0; ( nullptr != phSemaphores) && (i < numSemaphores); ++i){ + if (!context.handleLifetime->isHandleValid( phSemaphores[i] )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + } + if (hSignalEvent && !context.handleLifetime->isHandleValid( hSignalEvent )){ + 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::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 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 d0d7635f..5b598b0d 100644 --- a/source/layers/validation/handle_lifetime_tracking/ze_handle_lifetime.h +++ b/source/layers/validation/handle_lifetime_tracking/ze_handle_lifetime.h @@ -163,6 +163,10 @@ namespace validation_layer 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 zeKernelGetBinaryExpPrologue( ze_kernel_handle_t hKernel, size_t* pSize, uint8_t* pKernelBinary ) override; + ze_result_t zeDeviceImportExternalSemaphoreExtPrologue( ze_device_handle_t hDevice, const ze_external_semaphore_ext_desc_t* desc, ze_external_semaphore_ext_handle_t* phSemaphore ) override; + ze_result_t zeDeviceReleaseExternalSemaphoreExtPrologue( ze_external_semaphore_ext_handle_t hSemaphore ) override; + ze_result_t zeCommandListAppendSignalExternalSemaphoreExtPrologue( ze_command_list_handle_t hCommandList, uint32_t numSemaphores, ze_external_semaphore_ext_handle_t* phSemaphores, ze_external_semaphore_signal_params_ext_t* signalParams, ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) override; + ze_result_t zeCommandListAppendWaitExternalSemaphoreExtPrologue( ze_command_list_handle_t hCommandList, uint32_t numSemaphores, ze_external_semaphore_ext_handle_t* phSemaphores, ze_external_semaphore_wait_params_ext_t* waitParams, ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) 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; 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 f3aab2d2..eb766616 100644 --- a/source/layers/validation/handle_lifetime_tracking/zes_handle_lifetime.cpp +++ b/source/layers/validation/handle_lifetime_tracking/zes_handle_lifetime.cpp @@ -2222,6 +2222,18 @@ namespace validation_layer ) { + if ( !context.handleLifetime->isHandleValid( hVFhandle )){ + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + } + return ZE_RESULT_SUCCESS; + } + ze_result_t + ZESHandleLifetimeValidation::zesVFManagementGetVFCapabilitiesExp2Prologue( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. + zes_vf_exp2_capabilities_t* pCapability ///< [in,out] Will contain VF capability. + ) + { + 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 2d27779c..35463b60 100644 --- a/source/layers/validation/handle_lifetime_tracking/zes_handle_lifetime.h +++ b/source/layers/validation/handle_lifetime_tracking/zes_handle_lifetime.h @@ -165,6 +165,7 @@ namespace validation_layer ze_result_t zesVFManagementGetVFCapabilitiesExpPrologue( zes_vf_handle_t hVFhandle, zes_vf_exp_capabilities_t* pCapability ) override; ze_result_t zesVFManagementGetVFMemoryUtilizationExp2Prologue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_mem_exp2_t* pMemUtil ) override; ze_result_t zesVFManagementGetVFEngineUtilizationExp2Prologue( zes_vf_handle_t hVFhandle, uint32_t* pCount, zes_vf_util_engine_exp2_t* pEngineUtil ) override; + ze_result_t zesVFManagementGetVFCapabilitiesExp2Prologue( zes_vf_handle_t hVFhandle, zes_vf_exp2_capabilities_t* pCapability ) override; }; } diff --git a/source/layers/validation/ze_valddi.cpp b/source/layers/validation/ze_valddi.cpp index ea7a838c..78385a3b 100644 --- a/source/layers/validation/ze_valddi.cpp +++ b/source/layers/validation/ze_valddi.cpp @@ -6426,6 +6426,182 @@ namespace validation_layer return driver_result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceImportExternalSemaphoreExt + __zedlllocal ze_result_t ZE_APICALL + zeDeviceImportExternalSemaphoreExt( + ze_device_handle_t hDevice, ///< [in] The device handle. + const ze_external_semaphore_ext_desc_t* desc, ///< [in] The pointer to external semaphore descriptor. + ze_external_semaphore_ext_handle_t* phSemaphore ///< [out] The handle of the external semaphore imported. + ) + { + auto pfnImportExternalSemaphoreExt = context.zeDdiTable.Device.pfnImportExternalSemaphoreExt; + + if( nullptr == pfnImportExternalSemaphoreExt ) + 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->zeDeviceImportExternalSemaphoreExtPrologue( hDevice, desc, phSemaphore ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zeHandleLifetime.zeDeviceImportExternalSemaphoreExtPrologue( hDevice, desc, phSemaphore ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto driver_result = pfnImportExternalSemaphoreExt( hDevice, desc, phSemaphore ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zeValidation->zeDeviceImportExternalSemaphoreExtEpilogue( hDevice, desc, phSemaphore ,driver_result); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + return driver_result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceReleaseExternalSemaphoreExt + __zedlllocal ze_result_t ZE_APICALL + zeDeviceReleaseExternalSemaphoreExt( + ze_external_semaphore_ext_handle_t hSemaphore ///< [in] The handle of the external semaphore. + ) + { + auto pfnReleaseExternalSemaphoreExt = context.zeDdiTable.Device.pfnReleaseExternalSemaphoreExt; + + if( nullptr == pfnReleaseExternalSemaphoreExt ) + 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->zeDeviceReleaseExternalSemaphoreExtPrologue( hSemaphore ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zeHandleLifetime.zeDeviceReleaseExternalSemaphoreExtPrologue( hSemaphore ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto driver_result = pfnReleaseExternalSemaphoreExt( hSemaphore ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zeValidation->zeDeviceReleaseExternalSemaphoreExtEpilogue( hSemaphore ,driver_result); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + return driver_result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendSignalExternalSemaphoreExt + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendSignalExternalSemaphoreExt( + ze_command_list_handle_t hCommandList, ///< [in] The command list handle. + uint32_t numSemaphores, ///< [in] The number of external semaphores. + ze_external_semaphore_ext_handle_t* phSemaphores, ///< [in][range(0, numSemaphores)] The vector of external semaphore handles + ///< to be appended into command list. + ze_external_semaphore_signal_params_ext_t* signalParams,///< [in] Signal parameters. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; 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 + ) + { + auto pfnAppendSignalExternalSemaphoreExt = context.zeDdiTable.CommandList.pfnAppendSignalExternalSemaphoreExt; + + if( nullptr == pfnAppendSignalExternalSemaphoreExt ) + 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->zeCommandListAppendSignalExternalSemaphoreExtPrologue( hCommandList, numSemaphores, phSemaphores, signalParams, hSignalEvent, numWaitEvents, phWaitEvents ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zeHandleLifetime.zeCommandListAppendSignalExternalSemaphoreExtPrologue( hCommandList, numSemaphores, phSemaphores, signalParams, hSignalEvent, numWaitEvents, phWaitEvents ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto driver_result = pfnAppendSignalExternalSemaphoreExt( hCommandList, numSemaphores, phSemaphores, signalParams, hSignalEvent, numWaitEvents, phWaitEvents ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zeValidation->zeCommandListAppendSignalExternalSemaphoreExtEpilogue( hCommandList, numSemaphores, phSemaphores, signalParams, hSignalEvent, numWaitEvents, phWaitEvents ,driver_result); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + return driver_result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendWaitExternalSemaphoreExt + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendWaitExternalSemaphoreExt( + ze_command_list_handle_t hCommandList, ///< [in] The command list handle. + uint32_t numSemaphores, ///< [in] The number of external semaphores. + ze_external_semaphore_ext_handle_t* phSemaphores, ///< [in] [range(0,numSemaphores)] The vector of external semaphore handles + ///< to append into command list. + ze_external_semaphore_wait_params_ext_t* waitParams,///< [in] Wait parameters. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; 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 + ) + { + auto pfnAppendWaitExternalSemaphoreExt = context.zeDdiTable.CommandList.pfnAppendWaitExternalSemaphoreExt; + + if( nullptr == pfnAppendWaitExternalSemaphoreExt ) + 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->zeCommandListAppendWaitExternalSemaphoreExtPrologue( hCommandList, numSemaphores, phSemaphores, waitParams, hSignalEvent, numWaitEvents, phWaitEvents ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zeHandleLifetime.zeCommandListAppendWaitExternalSemaphoreExtPrologue( hCommandList, numSemaphores, phSemaphores, waitParams, hSignalEvent, numWaitEvents, phWaitEvents ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto driver_result = pfnAppendWaitExternalSemaphoreExt( hCommandList, numSemaphores, phSemaphores, waitParams, hSignalEvent, numWaitEvents, phWaitEvents ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zeValidation->zeCommandListAppendWaitExternalSemaphoreExtEpilogue( hCommandList, numSemaphores, phSemaphores, waitParams, hSignalEvent, numWaitEvents, phWaitEvents ,driver_result); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + return driver_result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeDeviceReserveCacheExt __zedlllocal ze_result_t ZE_APICALL @@ -8603,6 +8779,12 @@ zeGetDeviceProcAddrTable( dditable.pfnGetGlobalTimestamps = pDdiTable->pfnGetGlobalTimestamps; pDdiTable->pfnGetGlobalTimestamps = validation_layer::zeDeviceGetGlobalTimestamps; + dditable.pfnImportExternalSemaphoreExt = pDdiTable->pfnImportExternalSemaphoreExt; + pDdiTable->pfnImportExternalSemaphoreExt = validation_layer::zeDeviceImportExternalSemaphoreExt; + + dditable.pfnReleaseExternalSemaphoreExt = pDdiTable->pfnReleaseExternalSemaphoreExt; + pDdiTable->pfnReleaseExternalSemaphoreExt = validation_layer::zeDeviceReleaseExternalSemaphoreExt; + dditable.pfnReserveCacheExt = pDdiTable->pfnReserveCacheExt; pDdiTable->pfnReserveCacheExt = validation_layer::zeDeviceReserveCacheExt; @@ -8853,6 +9035,12 @@ zeGetCommandListProcAddrTable( dditable.pfnAppendLaunchMultipleKernelsIndirect = pDdiTable->pfnAppendLaunchMultipleKernelsIndirect; pDdiTable->pfnAppendLaunchMultipleKernelsIndirect = validation_layer::zeCommandListAppendLaunchMultipleKernelsIndirect; + dditable.pfnAppendSignalExternalSemaphoreExt = pDdiTable->pfnAppendSignalExternalSemaphoreExt; + pDdiTable->pfnAppendSignalExternalSemaphoreExt = validation_layer::zeCommandListAppendSignalExternalSemaphoreExt; + + dditable.pfnAppendWaitExternalSemaphoreExt = pDdiTable->pfnAppendWaitExternalSemaphoreExt; + pDdiTable->pfnAppendWaitExternalSemaphoreExt = validation_layer::zeCommandListAppendWaitExternalSemaphoreExt; + dditable.pfnAppendImageCopyToMemoryExt = pDdiTable->pfnAppendImageCopyToMemoryExt; pDdiTable->pfnAppendImageCopyToMemoryExt = validation_layer::zeCommandListAppendImageCopyToMemoryExt; diff --git a/source/layers/validation/zes_valddi.cpp b/source/layers/validation/zes_valddi.cpp index 27107baf..bb9283d1 100644 --- a/source/layers/validation/zes_valddi.cpp +++ b/source/layers/validation/zes_valddi.cpp @@ -6443,6 +6443,46 @@ namespace validation_layer return driver_result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesVFManagementGetVFCapabilitiesExp2 + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFCapabilitiesExp2( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. + zes_vf_exp2_capabilities_t* pCapability ///< [in,out] Will contain VF capability. + ) + { + auto pfnGetVFCapabilitiesExp2 = context.zesDdiTable.VFManagementExp.pfnGetVFCapabilitiesExp2; + + if( nullptr == pfnGetVFCapabilitiesExp2 ) + 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->zesVFManagementGetVFCapabilitiesExp2Prologue( hVFhandle, pCapability ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + + if(context.enableHandleLifetime ){ + auto result = context.handleLifetime->zesHandleLifetime.zesVFManagementGetVFCapabilitiesExp2Prologue( hVFhandle, pCapability ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + auto driver_result = pfnGetVFCapabilitiesExp2( hVFhandle, pCapability ); + + for (size_t i = 0; i < numValHandlers; i++) { + auto result = context.validationHandlers[i]->zesValidation->zesVFManagementGetVFCapabilitiesExp2Epilogue( hVFhandle, pCapability ,driver_result); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + return driver_result; + } + } // namespace validation_layer #if defined(__cplusplus) @@ -7547,6 +7587,9 @@ zesGetVFManagementExpProcAddrTable( dditable.pfnGetVFEngineUtilizationExp2 = pDdiTable->pfnGetVFEngineUtilizationExp2; pDdiTable->pfnGetVFEngineUtilizationExp2 = validation_layer::zesVFManagementGetVFEngineUtilizationExp2; + dditable.pfnGetVFCapabilitiesExp2 = pDdiTable->pfnGetVFCapabilitiesExp2; + pDdiTable->pfnGetVFCapabilitiesExp2 = validation_layer::zesVFManagementGetVFCapabilitiesExp2; + dditable.pfnGetVFPropertiesExp = pDdiTable->pfnGetVFPropertiesExp; pDdiTable->pfnGetVFPropertiesExp = validation_layer::zesVFManagementGetVFPropertiesExp; diff --git a/source/lib/ze_libapi.cpp b/source/lib/ze_libapi.cpp index 4fafd1cd..189743d6 100644 --- a/source/lib/ze_libapi.cpp +++ b/source/lib/ze_libapi.cpp @@ -7094,6 +7094,203 @@ zeKernelGetBinaryExp( return pfnGetBinaryExp( hKernel, pSize, pKernelBinary ); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Import an external semaphore +/// +/// @details +/// - Imports an external semaphore. +/// - This function may be called from simultaneous threads with the same +/// device 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 == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == desc` +/// + `nullptr == phSemaphore` +/// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION +/// + `0x1ff < desc->flags` +ze_result_t ZE_APICALL +zeDeviceImportExternalSemaphoreExt( + ze_device_handle_t hDevice, ///< [in] The device handle. + const ze_external_semaphore_ext_desc_t* desc, ///< [in] The pointer to external semaphore descriptor. + ze_external_semaphore_ext_handle_t* phSemaphore ///< [out] The handle of the external semaphore imported. + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnImportExternalSemaphoreExt = ze_lib::context->zeDdiTable.load()->Device.pfnImportExternalSemaphoreExt; + if( nullptr == pfnImportExternalSemaphoreExt ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnImportExternalSemaphoreExt( hDevice, desc, phSemaphore ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Release an external semaphore +/// +/// @details +/// - The application must ensure the device is not currently referencing +/// the semaphore before it is released. +/// - The application must **not** call this function from simultaneous +/// threads with the same semaphore 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 == hSemaphore` +/// - ::ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE +ze_result_t ZE_APICALL +zeDeviceReleaseExternalSemaphoreExt( + ze_external_semaphore_ext_handle_t hSemaphore ///< [in] The handle of the external semaphore. + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnReleaseExternalSemaphoreExt = ze_lib::context->zeDdiTable.load()->Device.pfnReleaseExternalSemaphoreExt; + if( nullptr == pfnReleaseExternalSemaphoreExt ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnReleaseExternalSemaphoreExt( hSemaphore ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Signal an external semaphore +/// +/// @details +/// - Signals an external semaphore. +/// - This function must only be used with an immediate 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 == phSemaphores` +/// + `nullptr == signalParams` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +/// + `(nullptr == phSemaphores) && (0 < numSemaphores)` +/// + `(nullptr == signalParams) && (0 < numSemaphores)` +/// - ::ZE_RESULT_ERROR_INVALID_ARGUMENT +/// + Commandlist handle does not correspond to an immediate command list +ze_result_t ZE_APICALL +zeCommandListAppendSignalExternalSemaphoreExt( + ze_command_list_handle_t hCommandList, ///< [in] The command list handle. + uint32_t numSemaphores, ///< [in] The number of external semaphores. + ze_external_semaphore_ext_handle_t* phSemaphores, ///< [in][range(0, numSemaphores)] The vector of external semaphore handles + ///< to be appended into command list. + ze_external_semaphore_signal_params_ext_t* signalParams,///< [in] Signal parameters. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; 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 + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnAppendSignalExternalSemaphoreExt = ze_lib::context->zeDdiTable.load()->CommandList.pfnAppendSignalExternalSemaphoreExt; + if( nullptr == pfnAppendSignalExternalSemaphoreExt ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnAppendSignalExternalSemaphoreExt( hCommandList, numSemaphores, phSemaphores, signalParams, hSignalEvent, numWaitEvents, phWaitEvents ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Wait on external semaphores +/// +/// @details +/// - Waits on external semaphores. +/// - This function must only be used with an immediate 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 == phSemaphores` +/// + `nullptr == waitParams` +/// - ::ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT +/// - ::ZE_RESULT_ERROR_INVALID_SIZE +/// + `(nullptr == phWaitEvents) && (0 < numWaitEvents)` +/// + `(nullptr == phSemaphores) && (0 < numSemaphores)` +/// + `(nullptr == waitParams) && (0 < numSemaphores)` +/// - ::ZE_RESULT_ERROR_INVALID_ARGUMENT +/// + Commandlist handle does not correspond to an immediate command list +ze_result_t ZE_APICALL +zeCommandListAppendWaitExternalSemaphoreExt( + ze_command_list_handle_t hCommandList, ///< [in] The command list handle. + uint32_t numSemaphores, ///< [in] The number of external semaphores. + ze_external_semaphore_ext_handle_t* phSemaphores, ///< [in] [range(0,numSemaphores)] The vector of external semaphore handles + ///< to append into command list. + ze_external_semaphore_wait_params_ext_t* waitParams,///< [in] Wait parameters. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; 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 + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnAppendWaitExternalSemaphoreExt = ze_lib::context->zeDdiTable.load()->CommandList.pfnAppendWaitExternalSemaphoreExt; + if( nullptr == pfnAppendWaitExternalSemaphoreExt ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnAppendWaitExternalSemaphoreExt( hCommandList, numSemaphores, phSemaphores, waitParams, hSignalEvent, numWaitEvents, phWaitEvents ); +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Reserve Cache on Device /// diff --git a/source/lib/ze_libddi.cpp b/source/lib/ze_libddi.cpp index 42aa0dde..5a6c8a81 100644 --- a/source/lib/ze_libddi.cpp +++ b/source/lib/ze_libddi.cpp @@ -30,18 +30,16 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetRTASBuilderExpProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.RTASBuilderExp ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.RTASBuilderExp ); } if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetRTASParallelOperationExpProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.RTASParallelOperationExp ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.RTASParallelOperationExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -53,10 +51,9 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetDriverExpProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.DriverExp ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.DriverExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -68,10 +65,9 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetDeviceExpProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.DeviceExp ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.DeviceExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -97,10 +93,9 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetCommandListExpProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.CommandListExp ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.CommandListExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -112,10 +107,9 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetEventExpProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.EventExp ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.EventExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -141,10 +135,9 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetImageExpProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.ImageExp ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.ImageExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -156,10 +149,9 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetKernelExpProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.KernelExp ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.KernelExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -171,10 +163,9 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetMemExpProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.MemExp ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.MemExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -214,18 +205,16 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetFabricEdgeExpProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.FabricEdgeExp ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.FabricEdgeExp ); } if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetFabricVertexExpProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.FabricVertexExp ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.FabricVertexExp ); } return result; @@ -242,14 +231,12 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional - zeGetRTASBuilderExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.RTASBuilderExp ); + result = zeGetRTASBuilderExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.RTASBuilderExp ); } if( ZE_RESULT_SUCCESS == result ) { - // Optional - zeGetRTASParallelOperationExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.RTASParallelOperationExp ); + result = zeGetRTASParallelOperationExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.RTASParallelOperationExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -259,8 +246,7 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional - zeGetDriverExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.DriverExp ); + result = zeGetDriverExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.DriverExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -270,8 +256,7 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional - zeGetDeviceExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.DeviceExp ); + result = zeGetDeviceExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.DeviceExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -291,8 +276,7 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional - zeGetCommandListExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.CommandListExp ); + result = zeGetCommandListExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.CommandListExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -302,8 +286,7 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional - zeGetEventExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.EventExp ); + result = zeGetEventExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.EventExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -323,8 +306,7 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional - zeGetImageExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.ImageExp ); + result = zeGetImageExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.ImageExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -334,8 +316,7 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional - zeGetKernelExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.KernelExp ); + result = zeGetKernelExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.KernelExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -345,8 +326,7 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional - zeGetMemExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.MemExp ); + result = zeGetMemExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.MemExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -376,14 +356,12 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional - zeGetFabricEdgeExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.FabricEdgeExp ); + result = zeGetFabricEdgeExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.FabricEdgeExp ); } if( ZE_RESULT_SUCCESS == result ) { - // Optional - zeGetFabricVertexExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.FabricVertexExp ); + result = zeGetFabricVertexExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzeDdiTable.FabricVertexExp ); } return result; diff --git a/source/lib/ze_tracing_register_cb_libapi.cpp b/source/lib/ze_tracing_register_cb_libapi.cpp index 1f85cfdb..df0192d8 100644 --- a/source/lib/ze_tracing_register_cb_libapi.cpp +++ b/source/lib/ze_tracing_register_cb_libapi.cpp @@ -3693,6 +3693,106 @@ zelTracerKernelGetBinaryExpRegisterCallback( } +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerDeviceImportExternalSemaphoreExtRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnDeviceImportExternalSemaphoreExtCb_t pfnImportExternalSemaphoreExtCb + ) { + + 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_pfnDeviceImportExternalSemaphoreExtCb_t pfnImportExternalSemaphoreExtCb + ); + + auto func = reinterpret_cast( + GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "zelTracerDeviceImportExternalSemaphoreExtRegisterCallback") ); + + if(func) + return func(hTracer, callback_type, pfnImportExternalSemaphoreExtCb); + + return ZE_RESULT_ERROR_UNINITIALIZED; +} + + +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerDeviceReleaseExternalSemaphoreExtRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnDeviceReleaseExternalSemaphoreExtCb_t pfnReleaseExternalSemaphoreExtCb + ) { + + 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_pfnDeviceReleaseExternalSemaphoreExtCb_t pfnReleaseExternalSemaphoreExtCb + ); + + auto func = reinterpret_cast( + GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "zelTracerDeviceReleaseExternalSemaphoreExtRegisterCallback") ); + + if(func) + return func(hTracer, callback_type, pfnReleaseExternalSemaphoreExtCb); + + return ZE_RESULT_ERROR_UNINITIALIZED; +} + + +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerCommandListAppendSignalExternalSemaphoreExtRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListAppendSignalExternalSemaphoreExtCb_t pfnAppendSignalExternalSemaphoreExtCb + ) { + + 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_pfnCommandListAppendSignalExternalSemaphoreExtCb_t pfnAppendSignalExternalSemaphoreExtCb + ); + + auto func = reinterpret_cast( + GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "zelTracerCommandListAppendSignalExternalSemaphoreExtRegisterCallback") ); + + if(func) + return func(hTracer, callback_type, pfnAppendSignalExternalSemaphoreExtCb); + + return ZE_RESULT_ERROR_UNINITIALIZED; +} + + +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerCommandListAppendWaitExternalSemaphoreExtRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListAppendWaitExternalSemaphoreExtCb_t pfnAppendWaitExternalSemaphoreExtCb + ) { + + 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_pfnCommandListAppendWaitExternalSemaphoreExtCb_t pfnAppendWaitExternalSemaphoreExtCb + ); + + auto func = reinterpret_cast( + GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "zelTracerCommandListAppendWaitExternalSemaphoreExtRegisterCallback") ); + + if(func) + return func(hTracer, callback_type, pfnAppendWaitExternalSemaphoreExtCb); + + return ZE_RESULT_ERROR_UNINITIALIZED; +} + + ZE_APIEXPORT ze_result_t ZE_APICALL zelTracerDeviceReserveCacheExtRegisterCallback( zel_tracer_handle_t hTracer, diff --git a/source/lib/zes_libapi.cpp b/source/lib/zes_libapi.cpp index 5b5a69ae..2f356f9d 100644 --- a/source/lib/zes_libapi.cpp +++ b/source/lib/zes_libapi.cpp @@ -6444,6 +6444,8 @@ zesDeviceEnumEnabledVFExp( /// @brief Get virtual function management capabilities /// /// @details +/// - [DEPRECATED] No longer supported. Use +/// ::zesVFManagementGetVFCapabilitiesExp2. /// - The application may call this function from simultaneous threads. /// - The implementation of this function should be lock-free. /// @@ -6578,4 +6580,42 @@ zesVFManagementGetVFEngineUtilizationExp2( return pfnGetVFEngineUtilizationExp2( hVFhandle, pCount, pEngineUtil ); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Get virtual function management capabilities +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function should be lock-free. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hVFhandle` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCapability` +ze_result_t ZE_APICALL +zesVFManagementGetVFCapabilitiesExp2( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. + zes_vf_exp2_capabilities_t* pCapability ///< [in,out] Will contain VF capability. + ) +{ + if(ze_lib::context->inTeardown) { + return ZE_RESULT_ERROR_UNINITIALIZED; + } + + auto pfnGetVFCapabilitiesExp2 = ze_lib::context->zesDdiTable.load()->VFManagementExp.pfnGetVFCapabilitiesExp2; + if( nullptr == pfnGetVFCapabilitiesExp2 ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnGetVFCapabilitiesExp2( hVFhandle, pCapability ); +} + } // extern "C" diff --git a/source/lib/zes_libddi.cpp b/source/lib/zes_libddi.cpp index 4159a931..48bad20a 100644 --- a/source/lib/zes_libddi.cpp +++ b/source/lib/zes_libddi.cpp @@ -23,10 +23,9 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetGlobalProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.Global ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.Global ); } if( ZE_RESULT_SUCCESS == result ) @@ -38,10 +37,9 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetDeviceExpProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.DeviceExp ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.DeviceExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -53,10 +51,9 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetDriverExpProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.DriverExp ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.DriverExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -96,10 +93,9 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetFirmwareExpProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.FirmwareExp ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.FirmwareExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -125,10 +121,9 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetOverclockProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.Overclock ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.Overclock ); } if( ZE_RESULT_SUCCESS == result ) @@ -161,10 +156,9 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetRasExpProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.RasExp ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.RasExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -190,10 +184,9 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetVFManagementExpProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.VFManagementExp ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.VFManagementExp ); } return result; @@ -205,8 +198,7 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional - zesGetGlobalProcAddrTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.Global ); + result = zesGetGlobalProcAddrTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.Global ); } if( ZE_RESULT_SUCCESS == result ) @@ -216,8 +208,7 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional - zesGetDeviceExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.DeviceExp ); + result = zesGetDeviceExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.DeviceExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -227,8 +218,7 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional - zesGetDriverExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.DriverExp ); + result = zesGetDriverExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.DriverExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -258,8 +248,7 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional - zesGetFirmwareExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.FirmwareExp ); + result = zesGetFirmwareExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.FirmwareExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -279,8 +268,7 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional - zesGetOverclockProcAddrTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.Overclock ); + result = zesGetOverclockProcAddrTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.Overclock ); } if( ZE_RESULT_SUCCESS == result ) @@ -305,8 +293,7 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional - zesGetRasExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.RasExp ); + result = zesGetRasExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.RasExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -326,8 +313,7 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional - zesGetVFManagementExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.VFManagementExp ); + result = zesGetVFManagementExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzesDdiTable.VFManagementExp ); } return result; diff --git a/source/lib/zet_libddi.cpp b/source/lib/zet_libddi.cpp index 5a6595b6..dbd1f597 100644 --- a/source/lib/zet_libddi.cpp +++ b/source/lib/zet_libddi.cpp @@ -23,26 +23,23 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zetGetMetricDecoderExpProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricDecoderExp ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricDecoderExp ); } if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zetGetMetricProgrammableExpProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricProgrammableExp ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricProgrammableExp ); } if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zetGetMetricTracerExpProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricTracerExp ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricTracerExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -54,10 +51,9 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zetGetDeviceExpProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.DeviceExp ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.DeviceExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -104,10 +100,9 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zetGetMetricExpProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricExp ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -119,10 +114,9 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zetGetMetricGroupExpProcAddrTable") ); - getTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricGroupExp ); + result = getTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricGroupExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -162,20 +156,17 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional - zetGetMetricDecoderExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricDecoderExp ); + result = zetGetMetricDecoderExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricDecoderExp ); } if( ZE_RESULT_SUCCESS == result ) { - // Optional - zetGetMetricProgrammableExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricProgrammableExp ); + result = zetGetMetricProgrammableExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricProgrammableExp ); } if( ZE_RESULT_SUCCESS == result ) { - // Optional - zetGetMetricTracerExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricTracerExp ); + result = zetGetMetricTracerExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricTracerExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -185,8 +176,7 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional - zetGetDeviceExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.DeviceExp ); + result = zetGetDeviceExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.DeviceExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -221,8 +211,7 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional - zetGetMetricExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricExp ); + result = zetGetMetricExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricExp ); } if( ZE_RESULT_SUCCESS == result ) @@ -232,8 +221,7 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - // Optional - zetGetMetricGroupExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricGroupExp ); + result = zetGetMetricGroupExpProcAddrTable( ZE_API_VERSION_CURRENT, &initialzetDdiTable.MetricGroupExp ); } if( ZE_RESULT_SUCCESS == result ) diff --git a/source/loader/ze_ldrddi.cpp b/source/loader/ze_ldrddi.cpp index 3347c119..85139a91 100644 --- a/source/loader/ze_ldrddi.cpp +++ b/source/loader/ze_ldrddi.cpp @@ -4885,6 +4885,166 @@ namespace loader return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceImportExternalSemaphoreExt + __zedlllocal ze_result_t ZE_APICALL + zeDeviceImportExternalSemaphoreExt( + ze_device_handle_t hDevice, ///< [in] The device handle. + const ze_external_semaphore_ext_desc_t* desc, ///< [in] The pointer to external semaphore descriptor. + ze_external_semaphore_ext_handle_t* phSemaphore ///< [out] The handle of the external semaphore imported. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hDevice )->dditable; + auto pfnImportExternalSemaphoreExt = dditable->ze.Device.pfnImportExternalSemaphoreExt; + if( nullptr == pfnImportExternalSemaphoreExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hDevice = reinterpret_cast( hDevice )->handle; + + // forward to device-driver + result = pfnImportExternalSemaphoreExt( hDevice, desc, phSemaphore ); + + if( ZE_RESULT_SUCCESS != result ) + return result; + + try + { + // convert driver handle to loader handle + *phSemaphore = reinterpret_cast( + context->ze_external_semaphore_ext_factory.getInstance( *phSemaphore, dditable ) ); + } + catch( std::bad_alloc& ) + { + result = ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDeviceReleaseExternalSemaphoreExt + __zedlllocal ze_result_t ZE_APICALL + zeDeviceReleaseExternalSemaphoreExt( + ze_external_semaphore_ext_handle_t hSemaphore ///< [in] The handle of the external semaphore. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hSemaphore )->dditable; + auto pfnReleaseExternalSemaphoreExt = dditable->ze.Device.pfnReleaseExternalSemaphoreExt; + if( nullptr == pfnReleaseExternalSemaphoreExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hSemaphore = reinterpret_cast( hSemaphore )->handle; + + // forward to device-driver + result = pfnReleaseExternalSemaphoreExt( hSemaphore ); + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendSignalExternalSemaphoreExt + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendSignalExternalSemaphoreExt( + ze_command_list_handle_t hCommandList, ///< [in] The command list handle. + uint32_t numSemaphores, ///< [in] The number of external semaphores. + ze_external_semaphore_ext_handle_t* phSemaphores, ///< [in][range(0, numSemaphores)] The vector of external semaphore handles + ///< to be appended into command list. + ze_external_semaphore_signal_params_ext_t* signalParams,///< [in] Signal parameters. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; 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 + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hCommandList )->dditable; + auto pfnAppendSignalExternalSemaphoreExt = dditable->ze.CommandList.pfnAppendSignalExternalSemaphoreExt; + if( nullptr == pfnAppendSignalExternalSemaphoreExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hCommandList = reinterpret_cast( hCommandList )->handle; + + // convert loader handles to driver handles + auto phSemaphoresLocal = new ze_external_semaphore_ext_handle_t [numSemaphores]; + for( size_t i = 0; ( nullptr != phSemaphores ) && ( i < numSemaphores ); ++i ) + phSemaphoresLocal[ i ] = reinterpret_cast( phSemaphores[ i ] )->handle; + + // convert loader handle to driver handle + hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; + + // 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 = pfnAppendSignalExternalSemaphoreExt( hCommandList, numSemaphores, phSemaphoresLocal, signalParams, hSignalEvent, numWaitEvents, phWaitEventsLocal ); + delete []phSemaphoresLocal; + delete []phWaitEventsLocal; + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListAppendWaitExternalSemaphoreExt + __zedlllocal ze_result_t ZE_APICALL + zeCommandListAppendWaitExternalSemaphoreExt( + ze_command_list_handle_t hCommandList, ///< [in] The command list handle. + uint32_t numSemaphores, ///< [in] The number of external semaphores. + ze_external_semaphore_ext_handle_t* phSemaphores, ///< [in] [range(0,numSemaphores)] The vector of external semaphore handles + ///< to append into command list. + ze_external_semaphore_wait_params_ext_t* waitParams,///< [in] Wait parameters. + ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion + uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching; 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 + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hCommandList )->dditable; + auto pfnAppendWaitExternalSemaphoreExt = dditable->ze.CommandList.pfnAppendWaitExternalSemaphoreExt; + if( nullptr == pfnAppendWaitExternalSemaphoreExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hCommandList = reinterpret_cast( hCommandList )->handle; + + // convert loader handles to driver handles + auto phSemaphoresLocal = new ze_external_semaphore_ext_handle_t [numSemaphores]; + for( size_t i = 0; ( nullptr != phSemaphores ) && ( i < numSemaphores ); ++i ) + phSemaphoresLocal[ i ] = reinterpret_cast( phSemaphores[ i ] )->handle; + + // convert loader handle to driver handle + hSignalEvent = ( hSignalEvent ) ? reinterpret_cast( hSignalEvent )->handle : nullptr; + + // 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 = pfnAppendWaitExternalSemaphoreExt( hCommandList, numSemaphores, phSemaphoresLocal, waitParams, hSignalEvent, numWaitEvents, phWaitEventsLocal ); + delete []phSemaphoresLocal; + delete []phWaitEventsLocal; + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeDeviceReserveCacheExt __zedlllocal ze_result_t ZE_APICALL @@ -6855,6 +7015,8 @@ zeGetDeviceProcAddrTable( pDdiTable->pfnCanAccessPeer = loader::zeDeviceCanAccessPeer; pDdiTable->pfnGetStatus = loader::zeDeviceGetStatus; pDdiTable->pfnGetGlobalTimestamps = loader::zeDeviceGetGlobalTimestamps; + pDdiTable->pfnImportExternalSemaphoreExt = loader::zeDeviceImportExternalSemaphoreExt; + pDdiTable->pfnReleaseExternalSemaphoreExt = loader::zeDeviceReleaseExternalSemaphoreExt; pDdiTable->pfnReserveCacheExt = loader::zeDeviceReserveCacheExt; pDdiTable->pfnSetCacheAdviceExt = loader::zeDeviceSetCacheAdviceExt; pDdiTable->pfnPciGetPropertiesExt = loader::zeDevicePciGetPropertiesExt; @@ -7256,6 +7418,8 @@ zeGetCommandListProcAddrTable( pDdiTable->pfnAppendLaunchCooperativeKernel = loader::zeCommandListAppendLaunchCooperativeKernel; pDdiTable->pfnAppendLaunchKernelIndirect = loader::zeCommandListAppendLaunchKernelIndirect; pDdiTable->pfnAppendLaunchMultipleKernelsIndirect = loader::zeCommandListAppendLaunchMultipleKernelsIndirect; + pDdiTable->pfnAppendSignalExternalSemaphoreExt = loader::zeCommandListAppendSignalExternalSemaphoreExt; + pDdiTable->pfnAppendWaitExternalSemaphoreExt = loader::zeCommandListAppendWaitExternalSemaphoreExt; pDdiTable->pfnAppendImageCopyToMemoryExt = loader::zeCommandListAppendImageCopyToMemoryExt; pDdiTable->pfnAppendImageCopyFromMemoryExt = loader::zeCommandListAppendImageCopyFromMemoryExt; pDdiTable->pfnHostSynchronize = loader::zeCommandListHostSynchronize; diff --git a/source/loader/ze_ldrddi.h b/source/loader/ze_ldrddi.h index 3bae53a8..2643d540 100644 --- a/source/loader/ze_ldrddi.h +++ b/source/loader/ze_ldrddi.h @@ -60,6 +60,9 @@ namespace loader using ze_fabric_edge_object_t = object_t < ze_fabric_edge_handle_t >; using ze_fabric_edge_factory_t = singleton_factory_t < ze_fabric_edge_object_t, ze_fabric_edge_handle_t >; + using ze_external_semaphore_ext_object_t = object_t < ze_external_semaphore_ext_handle_t >; + using ze_external_semaphore_ext_factory_t = singleton_factory_t < ze_external_semaphore_ext_object_t, ze_external_semaphore_ext_handle_t >; + using ze_rtas_builder_exp_object_t = object_t < ze_rtas_builder_exp_handle_t >; using ze_rtas_builder_exp_factory_t = singleton_factory_t < ze_rtas_builder_exp_object_t, ze_rtas_builder_exp_handle_t >; diff --git a/source/loader/ze_loader_internal.h b/source/loader/ze_loader_internal.h index 087adef9..432187ab 100644 --- a/source/loader/ze_loader_internal.h +++ b/source/loader/ze_loader_internal.h @@ -60,6 +60,7 @@ namespace loader ze_physical_mem_factory_t ze_physical_mem_factory; ze_fabric_vertex_factory_t ze_fabric_vertex_factory; ze_fabric_edge_factory_t ze_fabric_edge_factory; + ze_external_semaphore_ext_factory_t ze_external_semaphore_ext_factory; ze_rtas_builder_exp_factory_t ze_rtas_builder_exp_factory; ze_rtas_parallel_operation_exp_factory_t ze_rtas_parallel_operation_exp_factory; /////////////////////////////////////////////////////////////////////////////// diff --git a/source/loader/zes_ldrddi.cpp b/source/loader/zes_ldrddi.cpp index e89e7913..4e8700c5 100644 --- a/source/loader/zes_ldrddi.cpp +++ b/source/loader/zes_ldrddi.cpp @@ -4539,6 +4539,31 @@ namespace loader return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zesVFManagementGetVFCapabilitiesExp2 + __zedlllocal ze_result_t ZE_APICALL + zesVFManagementGetVFCapabilitiesExp2( + zes_vf_handle_t hVFhandle, ///< [in] Sysman handle for the VF component. + zes_vf_exp2_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 pfnGetVFCapabilitiesExp2 = dditable->zes.VFManagementExp.pfnGetVFCapabilitiesExp2; + if( nullptr == pfnGetVFCapabilitiesExp2 ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hVFhandle = reinterpret_cast( hVFhandle )->handle; + + // forward to device-driver + result = pfnGetVFCapabilitiesExp2( hVFhandle, pCapability ); + + return result; + } + } // namespace loader #if defined(__cplusplus) @@ -6430,6 +6455,7 @@ zesGetVFManagementExpProcAddrTable( pDdiTable->pfnGetVFCapabilitiesExp = loader::zesVFManagementGetVFCapabilitiesExp; pDdiTable->pfnGetVFMemoryUtilizationExp2 = loader::zesVFManagementGetVFMemoryUtilizationExp2; pDdiTable->pfnGetVFEngineUtilizationExp2 = loader::zesVFManagementGetVFEngineUtilizationExp2; + pDdiTable->pfnGetVFCapabilitiesExp2 = loader::zesVFManagementGetVFCapabilitiesExp2; pDdiTable->pfnGetVFPropertiesExp = loader::zesVFManagementGetVFPropertiesExp; pDdiTable->pfnGetVFMemoryUtilizationExp = loader::zesVFManagementGetVFMemoryUtilizationExp; pDdiTable->pfnGetVFEngineUtilizationExp = loader::zesVFManagementGetVFEngineUtilizationExp;