diff --git a/CHANGELOG.md b/CHANGELOG.md index 1febc6de..7dc4ddfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Level zero loader changelog +## v1.10.0 +* Update to spec 1.6 +* Added validation for stype and pnext + + ## v1.9.9 * Update to spec 1.5.17 * Fix for calling zeInit in zesInit path diff --git a/CMakeLists.txt b/CMakeLists.txt index badfb84a..2e1efcf1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ endif() # This project follows semantic versioning (https://semver.org/). Only set the # major and minor version here - patch version is determined dynamically. -project(level-zero VERSION 1.9) +project(level-zero VERSION 1.10) # Patch version corresponds to # of commits on master since last version # major/minor tag (e.g., v1.0). If not building in a git repository, then get diff --git a/include/layers/zel_tracing_register_cb.h b/include/layers/zel_tracing_register_cb.h index 3991dca0..4f0e7048 100644 --- a/include/layers/zel_tracing_register_cb.h +++ b/include/layers/zel_tracing_register_cb.h @@ -54,6 +54,32 @@ typedef void (ZE_APICALL *ze_pfnDriverGetExtensionFunctionAddressCb_t)( void** ppTracerInstanceUserData ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function parameters for zeDriverGetLastErrorDescription +/// @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_driver_get_last_error_description_params_t +{ + ze_driver_handle_t* phDriver; + const char*** pppString; +} ze_driver_get_last_error_description_params_t; + + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function-pointer for zeDriverGetLastErrorDescription +/// @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_pfnDriverGetLastErrorDescriptionCb_t)( + ze_driver_get_last_error_description_params_t* params, + ze_result_t result, + void* pTracerUserData, + void** ppTracerInstanceUserData + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Callback function parameters for zeDeviceGetGlobalTimestamps /// @details Each entry is a pointer to the parameter passed to the function; @@ -283,6 +309,32 @@ typedef void (ZE_APICALL *ze_pfnCommandListAppendImageCopyFromMemoryExtCb_t)( void** ppTracerInstanceUserData ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function parameters for zeCommandListHostSynchronize +/// @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_host_synchronize_params_t +{ + ze_command_list_handle_t* phCommandList; + uint64_t* ptimeout; +} ze_command_list_host_synchronize_params_t; + + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function-pointer for zeCommandListHostSynchronize +/// @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_pfnCommandListHostSynchronizeCb_t)( + ze_command_list_host_synchronize_params_t* params, + ze_result_t result, + void* pTracerUserData, + void** ppTracerInstanceUserData + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Callback function parameters for zeEventQueryTimestampsExp /// @details Each entry is a pointer to the parameter passed to the function; @@ -311,6 +363,60 @@ typedef void (ZE_APICALL *ze_pfnEventQueryTimestampsExpCb_t)( void** ppTracerInstanceUserData ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function parameters for zeEventQueryKernelTimestampsExt +/// @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_event_query_kernel_timestamps_ext_params_t +{ + ze_event_handle_t* phEvent; + ze_device_handle_t* phDevice; + uint32_t** ppCount; + ze_event_query_kernel_timestamps_results_ext_properties_t** ppResults; +} ze_event_query_kernel_timestamps_ext_params_t; + + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function-pointer for zeEventQueryKernelTimestampsExt +/// @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_pfnEventQueryKernelTimestampsExtCb_t)( + ze_event_query_kernel_timestamps_ext_params_t* params, + ze_result_t result, + void* pTracerUserData, + void** ppTracerInstanceUserData + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function parameters for zeEventPoolPutIpcHandle +/// @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_event_pool_put_ipc_handle_params_t +{ + ze_context_handle_t* phContext; + ze_ipc_event_pool_handle_t* phIpc; +} ze_event_pool_put_ipc_handle_params_t; + + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function-pointer for zeEventPoolPutIpcHandle +/// @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_pfnEventPoolPutIpcHandleCb_t)( + ze_event_pool_put_ipc_handle_params_t* params, + ze_result_t result, + void* pTracerUserData, + void** ppTracerInstanceUserData + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Callback function parameters for zeImageGetMemoryPropertiesExp /// @details Each entry is a pointer to the parameter passed to the function; @@ -503,6 +609,86 @@ typedef void (ZE_APICALL *ze_pfnMemFreeExtCb_t)( void** ppTracerInstanceUserData ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function parameters for zeMemGetIpcHandleFromFileDescriptorExp +/// @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_mem_get_ipc_handle_from_file_descriptor_exp_params_t +{ + ze_context_handle_t* phContext; + uint64_t* phandle; + ze_ipc_mem_handle_t** ppIpcHandle; +} ze_mem_get_ipc_handle_from_file_descriptor_exp_params_t; + + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function-pointer for zeMemGetIpcHandleFromFileDescriptorExp +/// @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_pfnMemGetIpcHandleFromFileDescriptorExpCb_t)( + ze_mem_get_ipc_handle_from_file_descriptor_exp_params_t* params, + ze_result_t result, + void* pTracerUserData, + void** ppTracerInstanceUserData + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function parameters for zeMemGetFileDescriptorFromIpcHandleExp +/// @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_mem_get_file_descriptor_from_ipc_handle_exp_params_t +{ + ze_context_handle_t* phContext; + ze_ipc_mem_handle_t* pipcHandle; + uint64_t** ppHandle; +} ze_mem_get_file_descriptor_from_ipc_handle_exp_params_t; + + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function-pointer for zeMemGetFileDescriptorFromIpcHandleExp +/// @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_pfnMemGetFileDescriptorFromIpcHandleExpCb_t)( + ze_mem_get_file_descriptor_from_ipc_handle_exp_params_t* params, + ze_result_t result, + void* pTracerUserData, + void** ppTracerInstanceUserData + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function parameters for zeMemPutIpcHandle +/// @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_mem_put_ipc_handle_params_t +{ + ze_context_handle_t* phContext; + ze_ipc_mem_handle_t* phandle; +} ze_mem_put_ipc_handle_params_t; + + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Callback function-pointer for zeMemPutIpcHandle +/// @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_pfnMemPutIpcHandleCb_t)( + ze_mem_put_ipc_handle_params_t* params, + ze_result_t result, + void* pTracerUserData, + void** ppTracerInstanceUserData + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Callback function parameters for zeModuleInspectLinkageExt /// @details Each entry is a pointer to the parameter passed to the function; @@ -783,6 +969,14 @@ zelTracerDriverGetExtensionFunctionAddressRegisterCallback( ); +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerDriverGetLastErrorDescriptionRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnDriverGetLastErrorDescriptionCb_t pfnGetLastErrorDescriptionCb + ); + + ZE_APIEXPORT ze_result_t ZE_APICALL zelTracerDeviceGetRegisterCallback( zel_tracer_handle_t hTracer, @@ -1015,6 +1209,14 @@ zelTracerCommandListAppendWriteGlobalTimestampRegisterCallback( ); +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerCommandListHostSynchronizeRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListHostSynchronizeCb_t pfnHostSynchronizeCb + ); + + ZE_APIEXPORT ze_result_t ZE_APICALL zelTracerCommandListAppendBarrierRegisterCallback( zel_tracer_handle_t hTracer, @@ -1159,6 +1361,14 @@ zelTracerEventPoolGetIpcHandleRegisterCallback( ); +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerEventPoolPutIpcHandleRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnEventPoolPutIpcHandleCb_t pfnPutIpcHandleCb + ); + + ZE_APIEXPORT ze_result_t ZE_APICALL zelTracerEventPoolOpenIpcHandleRegisterCallback( zel_tracer_handle_t hTracer, @@ -1367,6 +1577,30 @@ zelTracerMemGetIpcHandleRegisterCallback( ); +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerMemGetIpcHandleFromFileDescriptorExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnMemGetIpcHandleFromFileDescriptorExpCb_t pfnGetIpcHandleFromFileDescriptorExpCb + ); + + +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerMemGetFileDescriptorFromIpcHandleExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnMemGetFileDescriptorFromIpcHandleExpCb_t pfnGetFileDescriptorFromIpcHandleExpCb + ); + + +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerMemPutIpcHandleRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnMemPutIpcHandleCb_t pfnPutIpcHandleCb + ); + + ZE_APIEXPORT ze_result_t ZE_APICALL zelTracerMemOpenIpcHandleRegisterCallback( zel_tracer_handle_t hTracer, @@ -1887,6 +2121,14 @@ zelTracerFabricEdgeGetPropertiesExpRegisterCallback( ); +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerEventQueryKernelTimestampsExtRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnEventQueryKernelTimestampsExtCb_t pfnQueryKernelTimestampsExtCb + ); + + ZE_APIEXPORT ze_result_t ZE_APICALL zelTracerResetAllCallbacks(zel_tracer_handle_t hTracer); diff --git a/include/ze.py b/include/ze.py index abee040f..fa5cd5a8 100644 --- a/include/ze.py +++ b/include/ze.py @@ -4,7 +4,7 @@ SPDX-License-Identifier: MIT @file ze.py - @version v1.5-r1.5.17 + @version v1.6-r1.6.0 """ import platform @@ -273,6 +273,8 @@ class ze_structure_type_v(IntEnum): DEVICE_MEMORY_EXT_PROPERTIES = 0x1000e ## ::ze_device_memory_ext_properties_t DEVICE_IP_VERSION_EXT = 0x1000f ## ::ze_device_ip_version_ext_t IMAGE_VIEW_PLANAR_EXT_DESC = 0x10010 ## ::ze_image_view_planar_ext_desc_t + EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_PROPERTIES = 0x10011 ## ::ze_event_query_kernel_timestamps_ext_properties_t + EVENT_QUERY_KERNEL_TIMESTAMPS_RESULTS_EXT_PROPERTIES = 0x10012 ## ::ze_event_query_kernel_timestamps_results_ext_properties_t RELAXED_ALLOCATION_LIMITS_EXP_DESC = 0x00020001 ## ::ze_relaxed_allocation_limits_exp_desc_t MODULE_PROGRAM_EXP_DESC = 0x00020002 ## ::ze_module_program_exp_desc_t SCHEDULING_HINT_EXP_PROPERTIES = 0x00020003 ## ::ze_scheduling_hint_exp_properties_t @@ -399,7 +401,8 @@ class ze_api_version_v(IntEnum): _1_3 = ZE_MAKE_VERSION( 1, 3 ) ## version 1.3 _1_4 = ZE_MAKE_VERSION( 1, 4 ) ## version 1.4 _1_5 = ZE_MAKE_VERSION( 1, 5 ) ## version 1.5 - CURRENT = ZE_MAKE_VERSION( 1, 5 ) ## latest known version + _1_6 = ZE_MAKE_VERSION( 1, 6 ) ## version 1.6 + CURRENT = ZE_MAKE_VERSION( 1, 6 ) ## latest known version class ze_api_version_t(c_int): def __str__(self): @@ -998,6 +1001,9 @@ class ze_event_pool_flags_v(IntEnum): HOST_VISIBLE = ZE_BIT(0) ## signals and waits are also visible to host IPC = ZE_BIT(1) ## signals and waits may be shared across processes KERNEL_TIMESTAMP = ZE_BIT(2) ## Indicates all events in pool will contain kernel timestamps + KERNEL_MAPPED_TIMESTAMP = ZE_BIT(3) ## Indicates all events in pool will contain kernel timestamps + ## synchronized to host time domain; cannot be combined with + ## ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP class ze_event_pool_flags_t(c_int): def __str__(self): @@ -1210,9 +1216,9 @@ def __str__(self): ## @brief Image format class ze_image_format_t(Structure): _fields_ = [ - ("layout", ze_image_format_layout_t), ## [in] image format component layout - ("type", ze_image_format_type_t), ## [in] image format type. Media formats can't be used for - ## ::ZE_IMAGE_TYPE_BUFFER. + ("layout", ze_image_format_layout_t), ## [in] image format component layout (e.g. N-component layouts and media + ## formats) + ("type", ze_image_format_type_t), ## [in] image format type ("x", ze_image_format_swizzle_t), ## [in] image component swizzle into channel x ("y", ze_image_format_swizzle_t), ## [in] image component swizzle into channel y ("z", ze_image_format_swizzle_t), ## [in] image component swizzle into channel z @@ -1229,7 +1235,8 @@ class ze_image_desc_t(Structure): ("flags", ze_image_flags_t), ## [in] creation flags. ## must be 0 (default) or a valid combination of ::ze_image_flag_t; ## default is read-only, cached access. - ("type", ze_image_type_t), ## [in] image type + ("type", ze_image_type_t), ## [in] image type. Media format layouts are unsupported for + ## ::ZE_IMAGE_TYPE_BUFFER ("format", ze_image_format_t), ## [in] image format ("width", c_ulonglong), ## [in] width dimension. ## ::ZE_IMAGE_TYPE_BUFFER: size in bytes; see @@ -1508,7 +1515,8 @@ class ze_module_desc_t(Structure): ("format", ze_module_format_t), ## [in] Module format passed in with pInputModule ("inputSize", c_size_t), ## [in] size of input IL or ISA from pInputModule. ("pInputModule", POINTER(c_ubyte)), ## [in] pointer to IL or ISA - ("pBuildFlags", c_char_p), ## [in][optional] string containing compiler flags. Following options are supported. + ("pBuildFlags", c_char_p), ## [in][optional] string containing one or more (comma-separated) + ## compiler flags. If unsupported, flag is ignored with a warning. ## - "-ze-opt-disable" ## - Disable optimizations ## - "-ze-opt-level" @@ -2916,6 +2924,77 @@ class ze_memory_sub_allocations_exp_properties_t(Structure): ## driver shall only retrieve properties for that number of sub-allocations. ] +############################################################################### +## @brief Event Query Kernel Timestamps Extension Name +ZE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_NAME = "ZE_extension_event_query_kernel_timestamps" + +############################################################################### +## @brief Event Query Kernel Timestamps Extension Version(s) +class ze_event_query_kernel_timestamps_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_event_query_kernel_timestamps_ext_version_t(c_int): + def __str__(self): + return str(ze_event_query_kernel_timestamps_ext_version_v(self.value)) + + +############################################################################### +## @brief Event query kernel timestamps flags +class ze_event_query_kernel_timestamps_ext_flags_v(IntEnum): + KERNEL = ZE_BIT(0) ## Kernel timestamp results + SYNCHRONIZED = ZE_BIT(1) ## Device event timestamps synchronized to the host time domain + +class ze_event_query_kernel_timestamps_ext_flags_t(c_int): + def __str__(self): + return hex(self.value) + + +############################################################################### +## @brief Event query kernel timestamps properties +## +## @details +## - This structure may be returned from ::zeDeviceGetProperties, via +## `pNext` member of ::ze_device_properties_t. +class ze_event_query_kernel_timestamps_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_event_query_kernel_timestamps_ext_flags_t) ## [out] 0 or some combination of + ## ::ze_event_query_kernel_timestamps_ext_flag_t flags + ] + +############################################################################### +## @brief Kernel timestamp clock data synchronized to the host time domain +class ze_synchronized_timestamp_data_ext_t(Structure): + _fields_ = [ + ("kernelStart", c_ulonglong), ## [out] synchronized clock at start of kernel execution + ("kernelEnd", c_ulonglong) ## [out] synchronized clock at end of kernel execution + ] + +############################################################################### +## @brief Synchronized kernel timestamp result +class ze_synchronized_timestamp_result_ext_t(Structure): + _fields_ = [ + ("global", ze_synchronized_timestamp_data_ext_t), ## [out] wall-clock data + ("context", ze_synchronized_timestamp_data_ext_t) ## [out] context-active data; only includes clocks while device context + ## was actively executing. + ] + +############################################################################### +## @brief Event query kernel timestamps results properties +class ze_event_query_kernel_timestamps_results_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). + ("pKernelTimestampsBuffer", POINTER(ze_kernel_timestamp_result_t)), ## [in,out][optional][range(0, *pCount)] pointer to destination buffer of + ## kernel timestamp results + ("pSynchronizedTimestampsBuffer", POINTER(ze_synchronized_timestamp_result_ext_t)) ## [in,out][optional][range(0, *pCount)] pointer to destination buffer of + ## synchronized timestamp results + ] + ############################################################################### __use_win_types = "Windows" == platform.uname()[0] @@ -2976,6 +3055,13 @@ class _ze_global_dditable_t(Structure): else: _zeDriverGetExtensionFunctionAddress_t = CFUNCTYPE( ze_result_t, ze_driver_handle_t, c_char_p, POINTER(c_void_p) ) +############################################################################### +## @brief Function-pointer for zeDriverGetLastErrorDescription +if __use_win_types: + _zeDriverGetLastErrorDescription_t = WINFUNCTYPE( ze_result_t, ze_driver_handle_t, POINTER(c_char_p) ) +else: + _zeDriverGetLastErrorDescription_t = CFUNCTYPE( ze_result_t, ze_driver_handle_t, POINTER(c_char_p) ) + ############################################################################### ## @brief Table of Driver functions pointers @@ -2986,7 +3072,8 @@ class _ze_driver_dditable_t(Structure): ("pfnGetProperties", c_void_p), ## _zeDriverGetProperties_t ("pfnGetIpcProperties", c_void_p), ## _zeDriverGetIpcProperties_t ("pfnGetExtensionProperties", c_void_p), ## _zeDriverGetExtensionProperties_t - ("pfnGetExtensionFunctionAddress", c_void_p) ## _zeDriverGetExtensionFunctionAddress_t + ("pfnGetExtensionFunctionAddress", c_void_p), ## _zeDriverGetExtensionFunctionAddress_t + ("pfnGetLastErrorDescription", c_void_p) ## _zeDriverGetLastErrorDescription_t ] ############################################################################### @@ -3469,6 +3556,13 @@ class _ze_command_queue_dditable_t(Structure): else: _zeCommandListAppendImageCopyFromMemoryExt_t = CFUNCTYPE( ze_result_t, ze_command_list_handle_t, ze_image_handle_t, c_void_p, POINTER(ze_image_region_t), c_ulong, c_ulong, ze_event_handle_t, c_ulong, POINTER(ze_event_handle_t) ) +############################################################################### +## @brief Function-pointer for zeCommandListHostSynchronize +if __use_win_types: + _zeCommandListHostSynchronize_t = WINFUNCTYPE( ze_result_t, ze_command_list_handle_t, c_ulonglong ) +else: + _zeCommandListHostSynchronize_t = CFUNCTYPE( ze_result_t, ze_command_list_handle_t, c_ulonglong ) + ############################################################################### ## @brief Table of CommandList functions pointers @@ -3501,7 +3595,8 @@ class _ze_command_list_dditable_t(Structure): ("pfnAppendLaunchKernelIndirect", c_void_p), ## _zeCommandListAppendLaunchKernelIndirect_t ("pfnAppendLaunchMultipleKernelsIndirect", c_void_p), ## _zeCommandListAppendLaunchMultipleKernelsIndirect_t ("pfnAppendImageCopyToMemoryExt", c_void_p), ## _zeCommandListAppendImageCopyToMemoryExt_t - ("pfnAppendImageCopyFromMemoryExt", c_void_p) ## _zeCommandListAppendImageCopyFromMemoryExt_t + ("pfnAppendImageCopyFromMemoryExt", c_void_p), ## _zeCommandListAppendImageCopyFromMemoryExt_t + ("pfnHostSynchronize", c_void_p) ## _zeCommandListHostSynchronize_t ] ############################################################################### @@ -3656,6 +3751,13 @@ class _ze_fence_dditable_t(Structure): else: _zeEventPoolCloseIpcHandle_t = CFUNCTYPE( ze_result_t, ze_event_pool_handle_t ) +############################################################################### +## @brief Function-pointer for zeEventPoolPutIpcHandle +if __use_win_types: + _zeEventPoolPutIpcHandle_t = WINFUNCTYPE( ze_result_t, ze_context_handle_t, ze_ipc_event_pool_handle_t ) +else: + _zeEventPoolPutIpcHandle_t = CFUNCTYPE( ze_result_t, ze_context_handle_t, ze_ipc_event_pool_handle_t ) + ############################################################################### ## @brief Table of EventPool functions pointers @@ -3665,7 +3767,8 @@ class _ze_event_pool_dditable_t(Structure): ("pfnDestroy", c_void_p), ## _zeEventPoolDestroy_t ("pfnGetIpcHandle", c_void_p), ## _zeEventPoolGetIpcHandle_t ("pfnOpenIpcHandle", c_void_p), ## _zeEventPoolOpenIpcHandle_t - ("pfnCloseIpcHandle", c_void_p) ## _zeEventPoolCloseIpcHandle_t + ("pfnCloseIpcHandle", c_void_p), ## _zeEventPoolCloseIpcHandle_t + ("pfnPutIpcHandle", c_void_p) ## _zeEventPoolPutIpcHandle_t ] ############################################################################### @@ -3717,6 +3820,13 @@ class _ze_event_pool_dditable_t(Structure): else: _zeEventQueryKernelTimestamp_t = CFUNCTYPE( ze_result_t, ze_event_handle_t, POINTER(ze_kernel_timestamp_result_t) ) +############################################################################### +## @brief Function-pointer for zeEventQueryKernelTimestampsExt +if __use_win_types: + _zeEventQueryKernelTimestampsExt_t = WINFUNCTYPE( ze_result_t, ze_event_handle_t, ze_device_handle_t, POINTER(c_ulong), POINTER(ze_event_query_kernel_timestamps_results_ext_properties_t) ) +else: + _zeEventQueryKernelTimestampsExt_t = CFUNCTYPE( ze_result_t, ze_event_handle_t, ze_device_handle_t, POINTER(c_ulong), POINTER(ze_event_query_kernel_timestamps_results_ext_properties_t) ) + ############################################################################### ## @brief Table of Event functions pointers @@ -3728,7 +3838,8 @@ class _ze_event_dditable_t(Structure): ("pfnHostSynchronize", c_void_p), ## _zeEventHostSynchronize_t ("pfnQueryStatus", c_void_p), ## _zeEventQueryStatus_t ("pfnHostReset", c_void_p), ## _zeEventHostReset_t - ("pfnQueryKernelTimestamp", c_void_p) ## _zeEventQueryKernelTimestamp_t + ("pfnQueryKernelTimestamp", c_void_p), ## _zeEventQueryKernelTimestamp_t + ("pfnQueryKernelTimestampsExt", c_void_p) ## _zeEventQueryKernelTimestampsExt_t ] ############################################################################### @@ -4090,6 +4201,13 @@ class _ze_physical_mem_dditable_t(Structure): else: _zeMemFreeExt_t = CFUNCTYPE( ze_result_t, ze_context_handle_t, POINTER(ze_memory_free_ext_desc_t), c_void_p ) +############################################################################### +## @brief Function-pointer for zeMemPutIpcHandle +if __use_win_types: + _zeMemPutIpcHandle_t = WINFUNCTYPE( ze_result_t, ze_context_handle_t, ze_ipc_mem_handle_t ) +else: + _zeMemPutIpcHandle_t = CFUNCTYPE( ze_result_t, ze_context_handle_t, ze_ipc_mem_handle_t ) + ############################################################################### ## @brief Table of Mem functions pointers @@ -4104,7 +4222,31 @@ class _ze_mem_dditable_t(Structure): ("pfnGetIpcHandle", c_void_p), ## _zeMemGetIpcHandle_t ("pfnOpenIpcHandle", c_void_p), ## _zeMemOpenIpcHandle_t ("pfnCloseIpcHandle", c_void_p), ## _zeMemCloseIpcHandle_t - ("pfnFreeExt", c_void_p) ## _zeMemFreeExt_t + ("pfnFreeExt", c_void_p), ## _zeMemFreeExt_t + ("pfnPutIpcHandle", c_void_p) ## _zeMemPutIpcHandle_t + ] + +############################################################################### +## @brief Function-pointer for zeMemGetIpcHandleFromFileDescriptorExp +if __use_win_types: + _zeMemGetIpcHandleFromFileDescriptorExp_t = WINFUNCTYPE( ze_result_t, ze_context_handle_t, c_ulonglong, POINTER(ze_ipc_mem_handle_t) ) +else: + _zeMemGetIpcHandleFromFileDescriptorExp_t = CFUNCTYPE( ze_result_t, ze_context_handle_t, c_ulonglong, POINTER(ze_ipc_mem_handle_t) ) + +############################################################################### +## @brief Function-pointer for zeMemGetFileDescriptorFromIpcHandleExp +if __use_win_types: + _zeMemGetFileDescriptorFromIpcHandleExp_t = WINFUNCTYPE( ze_result_t, ze_context_handle_t, ze_ipc_mem_handle_t, POINTER(c_ulonglong) ) +else: + _zeMemGetFileDescriptorFromIpcHandleExp_t = CFUNCTYPE( ze_result_t, ze_context_handle_t, ze_ipc_mem_handle_t, POINTER(c_ulonglong) ) + + +############################################################################### +## @brief Table of MemExp functions pointers +class _ze_mem_exp_dditable_t(Structure): + _fields_ = [ + ("pfnGetIpcHandleFromFileDescriptorExp", c_void_p), ## _zeMemGetIpcHandleFromFileDescriptorExp_t + ("pfnGetFileDescriptorFromIpcHandleExp", c_void_p) ## _zeMemGetFileDescriptorFromIpcHandleExp_t ] ############################################################################### @@ -4263,6 +4405,7 @@ class _ze_dditable_t(Structure): ("Sampler", _ze_sampler_dditable_t), ("PhysicalMem", _ze_physical_mem_dditable_t), ("Mem", _ze_mem_dditable_t), + ("MemExp", _ze_mem_exp_dditable_t), ("VirtualMem", _ze_virtual_mem_dditable_t), ("FabricVertexExp", _ze_fabric_vertex_exp_dditable_t), ("FabricEdgeExp", _ze_fabric_edge_exp_dditable_t) @@ -4305,6 +4448,7 @@ def __init__(self, version : ze_api_version_t): self.zeDriverGetIpcProperties = _zeDriverGetIpcProperties_t(self.__dditable.Driver.pfnGetIpcProperties) self.zeDriverGetExtensionProperties = _zeDriverGetExtensionProperties_t(self.__dditable.Driver.pfnGetExtensionProperties) self.zeDriverGetExtensionFunctionAddress = _zeDriverGetExtensionFunctionAddress_t(self.__dditable.Driver.pfnGetExtensionFunctionAddress) + self.zeDriverGetLastErrorDescription = _zeDriverGetLastErrorDescription_t(self.__dditable.Driver.pfnGetLastErrorDescription) # call driver to get function pointers _Device = _ze_device_dditable_t() @@ -4410,6 +4554,7 @@ def __init__(self, version : ze_api_version_t): self.zeCommandListAppendLaunchMultipleKernelsIndirect = _zeCommandListAppendLaunchMultipleKernelsIndirect_t(self.__dditable.CommandList.pfnAppendLaunchMultipleKernelsIndirect) self.zeCommandListAppendImageCopyToMemoryExt = _zeCommandListAppendImageCopyToMemoryExt_t(self.__dditable.CommandList.pfnAppendImageCopyToMemoryExt) self.zeCommandListAppendImageCopyFromMemoryExt = _zeCommandListAppendImageCopyFromMemoryExt_t(self.__dditable.CommandList.pfnAppendImageCopyFromMemoryExt) + self.zeCommandListHostSynchronize = _zeCommandListHostSynchronize_t(self.__dditable.CommandList.pfnHostSynchronize) # call driver to get function pointers _Image = _ze_image_dditable_t() @@ -4463,6 +4608,7 @@ def __init__(self, version : ze_api_version_t): self.zeEventPoolGetIpcHandle = _zeEventPoolGetIpcHandle_t(self.__dditable.EventPool.pfnGetIpcHandle) self.zeEventPoolOpenIpcHandle = _zeEventPoolOpenIpcHandle_t(self.__dditable.EventPool.pfnOpenIpcHandle) self.zeEventPoolCloseIpcHandle = _zeEventPoolCloseIpcHandle_t(self.__dditable.EventPool.pfnCloseIpcHandle) + self.zeEventPoolPutIpcHandle = _zeEventPoolPutIpcHandle_t(self.__dditable.EventPool.pfnPutIpcHandle) # call driver to get function pointers _Event = _ze_event_dditable_t() @@ -4479,6 +4625,7 @@ def __init__(self, version : ze_api_version_t): self.zeEventQueryStatus = _zeEventQueryStatus_t(self.__dditable.Event.pfnQueryStatus) self.zeEventHostReset = _zeEventHostReset_t(self.__dditable.Event.pfnHostReset) self.zeEventQueryKernelTimestamp = _zeEventQueryKernelTimestamp_t(self.__dditable.Event.pfnQueryKernelTimestamp) + self.zeEventQueryKernelTimestampsExt = _zeEventQueryKernelTimestampsExt_t(self.__dditable.Event.pfnQueryKernelTimestampsExt) # call driver to get function pointers _EventExp = _ze_event_exp_dditable_t() @@ -4591,6 +4738,18 @@ def __init__(self, version : ze_api_version_t): self.zeMemOpenIpcHandle = _zeMemOpenIpcHandle_t(self.__dditable.Mem.pfnOpenIpcHandle) self.zeMemCloseIpcHandle = _zeMemCloseIpcHandle_t(self.__dditable.Mem.pfnCloseIpcHandle) self.zeMemFreeExt = _zeMemFreeExt_t(self.__dditable.Mem.pfnFreeExt) + self.zeMemPutIpcHandle = _zeMemPutIpcHandle_t(self.__dditable.Mem.pfnPutIpcHandle) + + # call driver to get function pointers + _MemExp = _ze_mem_exp_dditable_t() + r = ze_result_v(self.__dll.zeGetMemExpProcAddrTable(version, byref(_MemExp))) + if r != ze_result_v.SUCCESS: + raise Exception(r) + self.__dditable.MemExp = _MemExp + + # attach function interface to function address + self.zeMemGetIpcHandleFromFileDescriptorExp = _zeMemGetIpcHandleFromFileDescriptorExp_t(self.__dditable.MemExp.pfnGetIpcHandleFromFileDescriptorExp) + self.zeMemGetFileDescriptorFromIpcHandleExp = _zeMemGetFileDescriptorFromIpcHandleExp_t(self.__dditable.MemExp.pfnGetFileDescriptorFromIpcHandleExp) # call driver to get function pointers _VirtualMem = _ze_virtual_mem_dditable_t() diff --git a/include/ze_api.h b/include/ze_api.h index 04626d73..021a4388 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.5-r1.5.17 + * @version v1.6-r1.6.0 * */ #ifndef _ZE_API_H @@ -302,6 +302,8 @@ typedef enum _ze_structure_type_t ZE_STRUCTURE_TYPE_DEVICE_MEMORY_EXT_PROPERTIES = 0x1000e, ///< ::ze_device_memory_ext_properties_t ZE_STRUCTURE_TYPE_DEVICE_IP_VERSION_EXT = 0x1000f, ///< ::ze_device_ip_version_ext_t ZE_STRUCTURE_TYPE_IMAGE_VIEW_PLANAR_EXT_DESC = 0x10010, ///< ::ze_image_view_planar_ext_desc_t + ZE_STRUCTURE_TYPE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_PROPERTIES = 0x10011, ///< ::ze_event_query_kernel_timestamps_ext_properties_t + ZE_STRUCTURE_TYPE_EVENT_QUERY_KERNEL_TIMESTAMPS_RESULTS_EXT_PROPERTIES = 0x10012, ///< ::ze_event_query_kernel_timestamps_results_ext_properties_t ZE_STRUCTURE_TYPE_RELAXED_ALLOCATION_LIMITS_EXP_DESC = 0x00020001, ///< ::ze_relaxed_allocation_limits_exp_desc_t ZE_STRUCTURE_TYPE_MODULE_PROGRAM_EXP_DESC = 0x00020002, ///< ::ze_module_program_exp_desc_t ZE_STRUCTURE_TYPE_SCHEDULING_HINT_EXP_PROPERTIES = 0x00020003, ///< ::ze_scheduling_hint_exp_properties_t @@ -753,6 +755,22 @@ typedef struct _ze_sub_allocation_t ze_sub_allocation_t; /// @brief Forward-declare ze_memory_sub_allocations_exp_properties_t typedef struct _ze_memory_sub_allocations_exp_properties_t ze_memory_sub_allocations_exp_properties_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare ze_event_query_kernel_timestamps_ext_properties_t +typedef struct _ze_event_query_kernel_timestamps_ext_properties_t ze_event_query_kernel_timestamps_ext_properties_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare ze_synchronized_timestamp_data_ext_t +typedef struct _ze_synchronized_timestamp_data_ext_t ze_synchronized_timestamp_data_ext_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare ze_synchronized_timestamp_result_ext_t +typedef struct _ze_synchronized_timestamp_result_ext_t ze_synchronized_timestamp_result_ext_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare ze_event_query_kernel_timestamps_results_ext_properties_t +typedef struct _ze_event_query_kernel_timestamps_results_ext_properties_t ze_event_query_kernel_timestamps_results_ext_properties_t; + #if !defined(__GNUC__) #pragma endregion @@ -853,7 +871,8 @@ typedef enum _ze_api_version_t ZE_API_VERSION_1_3 = ZE_MAKE_VERSION( 1, 3 ), ///< version 1.3 ZE_API_VERSION_1_4 = ZE_MAKE_VERSION( 1, 4 ), ///< version 1.4 ZE_API_VERSION_1_5 = ZE_MAKE_VERSION( 1, 5 ), ///< version 1.5 - ZE_API_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 5 ), ///< latest known version + ZE_API_VERSION_1_6 = ZE_MAKE_VERSION( 1, 6 ), ///< version 1.6 + ZE_API_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 6 ), ///< latest known version ZE_API_VERSION_FORCE_UINT32 = 0x7fffffff } ze_api_version_t; @@ -1060,6 +1079,36 @@ zeDriverGetExtensionFunctionAddress( void** ppFunctionAddress ///< [out] pointer to function pointer ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Retrieves a string describing the last error code returned by the +/// driver in the current thread. +/// +/// @details +/// - String returned is thread local. +/// - String is only updated on calls returning an error, i.e., not on calls +/// returning ::ZE_RESULT_SUCCESS. +/// - String may be empty if driver considers error code is already explicit +/// enough to describe cause. +/// - Memory pointed to by ppString is owned by the driver. +/// - String returned is null-terminated. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hDriver` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == ppString` +ZE_APIEXPORT ze_result_t ZE_APICALL +zeDriverGetLastErrorDescription( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + const char** ppString ///< [in,out] pointer to a null-terminated array of characters describing + ///< cause of error. + ); + #if !defined(__GNUC__) #pragma endregion #endif @@ -2514,6 +2563,44 @@ zeCommandListAppendWriteGlobalTimestamp( ///< on before executing query ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Synchronizes an immediate command list by waiting on the host for the +/// completion of all commands previously submitted to it. +/// +/// @details +/// - The application must call this function only with command lists +/// created with ::zeCommandListCreateImmediate. +/// - Waiting on one immediate command list shall not block the concurrent +/// execution of commands appended to other +/// immediate command lists created with either a different ordinal or +/// different index. +/// - 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 == hCommandList` +/// - ::ZE_RESULT_NOT_READY +/// + timeout expired +/// - ::ZE_RESULT_ERROR_INVALID_ARGUMENT +/// + handle does not correspond to an immediate command list +ZE_APIEXPORT ze_result_t ZE_APICALL +zeCommandListHostSynchronize( + ze_command_list_handle_t hCommandList, ///< [in] handle of the immediate command list + uint64_t timeout ///< [in] if non-zero, then indicates the maximum time (in nanoseconds) to + ///< yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; + ///< if zero, then immediately returns the status of the immediate command list; + ///< if UINT64_MAX, then function will not return until complete or device + ///< is lost. + ///< Due to external dependencies, timeout may be rounded to the closest + ///< value allowed by the accuracy of those dependencies. + ); + #if !defined(__GNUC__) #pragma endregion #endif @@ -3193,6 +3280,9 @@ typedef enum _ze_event_pool_flag_t ZE_EVENT_POOL_FLAG_HOST_VISIBLE = ZE_BIT(0), ///< signals and waits are also visible to host ZE_EVENT_POOL_FLAG_IPC = ZE_BIT(1), ///< signals and waits may be shared across processes ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP = ZE_BIT(2),///< Indicates all events in pool will contain kernel timestamps + ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP = ZE_BIT(3), ///< Indicates all events in pool will contain kernel timestamps + ///< synchronized to host time domain; cannot be combined with + ///< ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP ZE_EVENT_POOL_FLAG_FORCE_UINT32 = 0x7fffffff } ze_event_pool_flag_t; @@ -3233,7 +3323,7 @@ typedef struct _ze_event_pool_desc_t /// + `nullptr == desc` /// + `nullptr == phEventPool` /// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION -/// + `0x7 < desc->flags` +/// + `0xf < desc->flags` /// - ::ZE_RESULT_ERROR_INVALID_SIZE /// + `0 == desc->count` /// + `(nullptr == phDevices) && (0 < numDevices)` @@ -3409,6 +3499,37 @@ zeEventPoolGetIpcHandle( ze_ipc_event_pool_handle_t* phIpc ///< [out] Returned IPC event handle ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Returns an IPC event pool handle to the driver +/// +/// @details +/// - This call must be used for IPC handles previously obtained with +/// ::zeEventPoolGetIpcHandle. +/// - Upon call, driver may release any underlying resources associated with +/// the IPC handle. +/// For instance, it may close the file descriptor contained in the IPC +/// handle, if such type of handle is being used by the driver. +/// - This call does not destroy the original event pool for which the IPC +/// handle was created. +/// - This function may **not** be called from simultaneous threads with the +/// same IPC 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 == hContext` +ZE_APIEXPORT ze_result_t ZE_APICALL +zeEventPoolPutIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object associated with the IPC event pool + ///< handle + ze_ipc_event_pool_handle_t hIpc ///< [in] IPC event pool handle + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Opens an IPC event pool handle to retrieve an event pool handle from /// another process. @@ -3467,7 +3588,8 @@ zeEventPoolCloseIpcHandle( /// - The application must ensure the events are accessible by the device on /// which the command list was created. /// - The duration of an event created from an event pool that was created -/// using ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP flag is undefined. +/// using ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP or +/// ::ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP flags is undefined. /// However, for consistency and orthogonality the event will report /// correctly as signaled when used by other event API functionality. /// - The application must ensure the command list and events were created @@ -3533,7 +3655,8 @@ zeCommandListAppendWaitOnEvents( /// /// @details /// - The duration of an event created from an event pool that was created -/// using ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP flag is undefined. +/// using ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP or +/// ::ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP flags is undefined. /// However, for consistency and orthogonality the event will report /// correctly as signaled when used by other event API functionality. /// - The application may call this function from simultaneous threads. @@ -3707,7 +3830,8 @@ typedef struct _ze_kernel_timestamp_result_t /// /// @details /// - The application must ensure the event was created from an event pool -/// that was created using ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP flag. +/// that was created using ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP or +/// ::ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP flag. /// - The destination memory will be unmodified if the event has not been /// signaled. /// - The application may call this function from simultaneous threads. @@ -4078,9 +4202,9 @@ typedef enum _ze_image_format_swizzle_t /// @brief Image format typedef struct _ze_image_format_t { - ze_image_format_layout_t layout; ///< [in] image format component layout - ze_image_format_type_t type; ///< [in] image format type. Media formats can't be used for - ///< ::ZE_IMAGE_TYPE_BUFFER. + ze_image_format_layout_t layout; ///< [in] image format component layout (e.g. N-component layouts and media + ///< formats) + ze_image_format_type_t type; ///< [in] image format type ze_image_format_swizzle_t x; ///< [in] image component swizzle into channel x ze_image_format_swizzle_t y; ///< [in] image component swizzle into channel y ze_image_format_swizzle_t z; ///< [in] image component swizzle into channel z @@ -4098,7 +4222,8 @@ typedef struct _ze_image_desc_t ze_image_flags_t flags; ///< [in] creation flags. ///< must be 0 (default) or a valid combination of ::ze_image_flag_t; ///< default is read-only, cached access. - ze_image_type_t type; ///< [in] image type + ze_image_type_t type; ///< [in] image type. Media format layouts are unsupported for + ///< ::ZE_IMAGE_TYPE_BUFFER ze_image_format_t format; ///< [in] image format uint64_t width; ///< [in] width dimension. ///< ::ZE_IMAGE_TYPE_BUFFER: size in bytes; see @@ -4580,6 +4705,90 @@ zeMemGetIpcHandle( ze_ipc_mem_handle_t* pIpcHandle ///< [out] Returned IPC memory handle ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Creates an IPC memory handle out of a file descriptor +/// +/// @details +/// - Handle passed must be a valid file descriptor obtained with +/// ::ze_external_memory_export_fd_t via ::zeMemGetAllocProperties. +/// - Returned IPC handle may contain metadata in addition to the file +/// descriptor. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pIpcHandle` +ZE_APIEXPORT ze_result_t ZE_APICALL +zeMemGetIpcHandleFromFileDescriptorExp( + ze_context_handle_t hContext, ///< [in] handle of the context object + uint64_t handle, ///< [in] file descriptor + ze_ipc_mem_handle_t* pIpcHandle ///< [out] Returned IPC memory handle + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Gets the file descriptor contained in an IPC memory handle +/// +/// @details +/// - IPC memory handle must be a valid handle obtained with +/// ::zeMemGetIpcHandle. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pHandle` +ZE_APIEXPORT ze_result_t ZE_APICALL +zeMemGetFileDescriptorFromIpcHandleExp( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_ipc_mem_handle_t ipcHandle, ///< [in] IPC memory handle + uint64_t* pHandle ///< [out] Returned file descriptor + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Returns an IPC memory handle to the driver +/// +/// @details +/// - This call may be used for IPC handles previously obtained with either +/// ::zeMemGetIpcHandle or with ::ze_external_memory_export_fd_t via ::zeMemGetAllocProperties. +/// - Upon call, driver may release any underlying resources associated with +/// the IPC handle. +/// For instance, it may close the file descriptor contained in the IPC +/// handle, if such type of handle is being used by the driver. +/// - This call does not free the original allocation for which the IPC +/// handle was created. +/// - This function may **not** be called from simultaneous threads with the +/// same IPC 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 == hContext` +ZE_APIEXPORT ze_result_t ZE_APICALL +zeMemPutIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_ipc_mem_handle_t handle ///< [in] IPC memory handle + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Supported IPC memory flags typedef uint32_t ze_ipc_memory_flags_t; @@ -4808,7 +5017,8 @@ typedef struct _ze_module_desc_t ze_module_format_t format; ///< [in] Module format passed in with pInputModule size_t inputSize; ///< [in] size of input IL or ISA from pInputModule. const uint8_t* pInputModule; ///< [in] pointer to IL or ISA - const char* pBuildFlags; ///< [in][optional] string containing compiler flags. Following options are supported. + const char* pBuildFlags; ///< [in][optional] string containing one or more (comma-separated) + ///< compiler flags. If unsupported, flag is ignored with a warning. ///< - "-ze-opt-disable" ///< - Disable optimizations ///< - "-ze-opt-level" @@ -8586,6 +8796,145 @@ typedef struct _ze_memory_sub_allocations_exp_properties_t } ze_memory_sub_allocations_exp_properties_t; +#if !defined(__GNUC__) +#pragma endregion +#endif +// Intel 'oneAPI' Level-Zero Extension for supporting the querying of synchronized event timestamps. +#if !defined(__GNUC__) +#pragma region eventQueryKernelTimestamps +#endif +/////////////////////////////////////////////////////////////////////////////// +#ifndef ZE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_NAME +/// @brief Event Query Kernel Timestamps Extension Name +#define ZE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_NAME "ZE_extension_event_query_kernel_timestamps" +#endif // ZE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_NAME + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Event Query Kernel Timestamps Extension Version(s) +typedef enum _ze_event_query_kernel_timestamps_ext_version_t +{ + ZE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 + ZE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 0 ), ///< latest known version + ZE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_VERSION_FORCE_UINT32 = 0x7fffffff + +} ze_event_query_kernel_timestamps_ext_version_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Event query kernel timestamps flags +typedef uint32_t ze_event_query_kernel_timestamps_ext_flags_t; +typedef enum _ze_event_query_kernel_timestamps_ext_flag_t +{ + ZE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_FLAG_KERNEL = ZE_BIT(0), ///< Kernel timestamp results + ZE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_FLAG_SYNCHRONIZED = ZE_BIT(1), ///< Device event timestamps synchronized to the host time domain + ZE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_FLAG_FORCE_UINT32 = 0x7fffffff + +} ze_event_query_kernel_timestamps_ext_flag_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Event query kernel timestamps properties +/// +/// @details +/// - This structure may be returned from ::zeDeviceGetProperties, via +/// `pNext` member of ::ze_device_properties_t. +typedef struct _ze_event_query_kernel_timestamps_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_event_query_kernel_timestamps_ext_flags_t flags; ///< [out] 0 or some combination of + ///< ::ze_event_query_kernel_timestamps_ext_flag_t flags + +} ze_event_query_kernel_timestamps_ext_properties_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Kernel timestamp clock data synchronized to the host time domain +typedef struct _ze_synchronized_timestamp_data_ext_t +{ + uint64_t kernelStart; ///< [out] synchronized clock at start of kernel execution + uint64_t kernelEnd; ///< [out] synchronized clock at end of kernel execution + +} ze_synchronized_timestamp_data_ext_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Synchronized kernel timestamp result +typedef struct _ze_synchronized_timestamp_result_ext_t +{ + ze_synchronized_timestamp_data_ext_t global; ///< [out] wall-clock data + ze_synchronized_timestamp_data_ext_t context; ///< [out] context-active data; only includes clocks while device context + ///< was actively executing. + +} ze_synchronized_timestamp_result_ext_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Event query kernel timestamps results properties +typedef struct _ze_event_query_kernel_timestamps_results_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_kernel_timestamp_result_t* pKernelTimestampsBuffer; ///< [in,out][optional][range(0, *pCount)] pointer to destination buffer of + ///< kernel timestamp results + ze_synchronized_timestamp_result_ext_t* pSynchronizedTimestampsBuffer; ///< [in,out][optional][range(0, *pCount)] pointer to destination buffer of + ///< synchronized timestamp results + +} ze_event_query_kernel_timestamps_results_ext_properties_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Query an event's timestamp value on the host, with domain preference. +/// +/// @details +/// - For collecting *only* kernel timestamps, the application must ensure +/// the event was created from an event pool that was created using +/// ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP flag. +/// - For collecting synchronized timestamps, the application must ensure +/// the event was created from an event pool that was created using +/// ::ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP flag. Kernel timestamps +/// are also available from this type of event pool, but there is a +/// performance cost. +/// - The destination memory will be unmodified if the event has not been +/// signaled. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// - The implementation must support +/// ::ZE_extension_event_query_kernel_timestamps. +/// - The implementation must return all timestamps for the specified event +/// and device pair. +/// - The implementation must return all timestamps for all sub-devices when +/// device handle is parent device. +/// - The implementation may return all timestamps for sub-devices when +/// device handle is sub-device or may return 0 for count. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hEvent` +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCount` +ZE_APIEXPORT ze_result_t ZE_APICALL +zeEventQueryKernelTimestampsExt( + ze_event_handle_t hEvent, ///< [in] handle of the event + ze_device_handle_t hDevice, ///< [in] handle of the device to query + uint32_t* pCount, ///< [in,out] pointer to the number of event packets available. + ///< - This value is implementation specific. + ///< - if `*pCount` is zero, then the driver shall update the value with + ///< the total number of event packets available. + ///< - if `*pCount` is greater than the number of event packets + ///< available, the driver shall update the value with the correct value. + ///< - Buffer(s) for query results must be sized by the application to + ///< accommodate a minimum of `*pCount` elements. + ze_event_query_kernel_timestamps_results_ext_properties_t* pResults ///< [in][optional] pointer to event query properties structure(s). + ///< - This parameter may be null when `*pCount` is zero. + ///< - if `*pCount` is less than the number of event packets available, + ///< the driver may only update `*pCount` elements, starting at element zero. + ///< - if `*pCount` is greater than the number of event packets + ///< available, the driver may only update the valid elements. + ); + #if !defined(__GNUC__) #pragma endregion #endif diff --git a/include/ze_ddi.h b/include/ze_ddi.h index 78c55d43..dc4a5080 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.5-r1.5.17 + * @version v1.6-r1.6.0 * */ #ifndef _ZE_DDI_H @@ -98,6 +98,13 @@ typedef ze_result_t (ZE_APICALL *ze_pfnDriverGetExtensionFunctionAddress_t)( void** ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zeDriverGetLastErrorDescription +typedef ze_result_t (ZE_APICALL *ze_pfnDriverGetLastErrorDescription_t)( + ze_driver_handle_t, + const char** + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Table of Driver functions pointers typedef struct _ze_driver_dditable_t @@ -108,6 +115,7 @@ typedef struct _ze_driver_dditable_t ze_pfnDriverGetIpcProperties_t pfnGetIpcProperties; ze_pfnDriverGetExtensionProperties_t pfnGetExtensionProperties; ze_pfnDriverGetExtensionFunctionAddress_t pfnGetExtensionFunctionAddress; + ze_pfnDriverGetLastErrorDescription_t pfnGetLastErrorDescription; } ze_driver_dditable_t; /////////////////////////////////////////////////////////////////////////////// @@ -818,6 +826,13 @@ typedef ze_result_t (ZE_APICALL *ze_pfnCommandListAppendImageCopyFromMemoryExt_t ze_event_handle_t* ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zeCommandListHostSynchronize +typedef ze_result_t (ZE_APICALL *ze_pfnCommandListHostSynchronize_t)( + ze_command_list_handle_t, + uint64_t + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Table of CommandList functions pointers typedef struct _ze_command_list_dditable_t @@ -850,6 +865,7 @@ typedef struct _ze_command_list_dditable_t ze_pfnCommandListAppendLaunchMultipleKernelsIndirect_t pfnAppendLaunchMultipleKernelsIndirect; ze_pfnCommandListAppendImageCopyToMemoryExt_t pfnAppendImageCopyToMemoryExt; ze_pfnCommandListAppendImageCopyFromMemoryExt_t pfnAppendImageCopyFromMemoryExt; + ze_pfnCommandListHostSynchronize_t pfnHostSynchronize; } ze_command_list_dditable_t; /////////////////////////////////////////////////////////////////////////////// @@ -1098,6 +1114,13 @@ typedef ze_result_t (ZE_APICALL *ze_pfnEventPoolCloseIpcHandle_t)( ze_event_pool_handle_t ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zeEventPoolPutIpcHandle +typedef ze_result_t (ZE_APICALL *ze_pfnEventPoolPutIpcHandle_t)( + ze_context_handle_t, + ze_ipc_event_pool_handle_t + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Table of EventPool functions pointers typedef struct _ze_event_pool_dditable_t @@ -1107,6 +1130,7 @@ typedef struct _ze_event_pool_dditable_t ze_pfnEventPoolGetIpcHandle_t pfnGetIpcHandle; ze_pfnEventPoolOpenIpcHandle_t pfnOpenIpcHandle; ze_pfnEventPoolCloseIpcHandle_t pfnCloseIpcHandle; + ze_pfnEventPoolPutIpcHandle_t pfnPutIpcHandle; } ze_event_pool_dditable_t; /////////////////////////////////////////////////////////////////////////////// @@ -1177,6 +1201,15 @@ typedef ze_result_t (ZE_APICALL *ze_pfnEventQueryKernelTimestamp_t)( ze_kernel_timestamp_result_t* ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zeEventQueryKernelTimestampsExt +typedef ze_result_t (ZE_APICALL *ze_pfnEventQueryKernelTimestampsExt_t)( + ze_event_handle_t, + ze_device_handle_t, + uint32_t*, + ze_event_query_kernel_timestamps_results_ext_properties_t* + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Table of Event functions pointers typedef struct _ze_event_dditable_t @@ -1188,6 +1221,7 @@ typedef struct _ze_event_dditable_t ze_pfnEventQueryStatus_t pfnQueryStatus; ze_pfnEventHostReset_t pfnHostReset; ze_pfnEventQueryKernelTimestamp_t pfnQueryKernelTimestamp; + ze_pfnEventQueryKernelTimestampsExt_t pfnQueryKernelTimestampsExt; } ze_event_dditable_t; /////////////////////////////////////////////////////////////////////////////// @@ -1767,6 +1801,13 @@ typedef ze_result_t (ZE_APICALL *ze_pfnMemFreeExt_t)( void* ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zeMemPutIpcHandle +typedef ze_result_t (ZE_APICALL *ze_pfnMemPutIpcHandle_t)( + ze_context_handle_t, + ze_ipc_mem_handle_t + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Table of Mem functions pointers typedef struct _ze_mem_dditable_t @@ -1781,6 +1822,7 @@ typedef struct _ze_mem_dditable_t ze_pfnMemOpenIpcHandle_t pfnOpenIpcHandle; ze_pfnMemCloseIpcHandle_t pfnCloseIpcHandle; ze_pfnMemFreeExt_t pfnFreeExt; + ze_pfnMemPutIpcHandle_t pfnPutIpcHandle; } ze_mem_dditable_t; /////////////////////////////////////////////////////////////////////////////// @@ -1805,6 +1847,52 @@ typedef ze_result_t (ZE_APICALL *ze_pfnGetMemProcAddrTable_t)( ze_mem_dditable_t* ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zeMemGetIpcHandleFromFileDescriptorExp +typedef ze_result_t (ZE_APICALL *ze_pfnMemGetIpcHandleFromFileDescriptorExp_t)( + ze_context_handle_t, + uint64_t, + ze_ipc_mem_handle_t* + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zeMemGetFileDescriptorFromIpcHandleExp +typedef ze_result_t (ZE_APICALL *ze_pfnMemGetFileDescriptorFromIpcHandleExp_t)( + ze_context_handle_t, + ze_ipc_mem_handle_t, + uint64_t* + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Table of MemExp functions pointers +typedef struct _ze_mem_exp_dditable_t +{ + ze_pfnMemGetIpcHandleFromFileDescriptorExp_t pfnGetIpcHandleFromFileDescriptorExp; + ze_pfnMemGetFileDescriptorFromIpcHandleExp_t pfnGetFileDescriptorFromIpcHandleExp; +} ze_mem_exp_dditable_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's MemExp table +/// with current process' addresses +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION +ZE_DLLEXPORT ze_result_t ZE_APICALL +zeGetMemExpProcAddrTable( + ze_api_version_t version, ///< [in] API version requested + ze_mem_exp_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zeGetMemExpProcAddrTable +typedef ze_result_t (ZE_APICALL *ze_pfnGetMemExpProcAddrTable_t)( + ze_api_version_t, + ze_mem_exp_dditable_t* + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for zeVirtualMemReserve typedef ze_result_t (ZE_APICALL *ze_pfnVirtualMemReserve_t)( @@ -2045,6 +2133,7 @@ typedef struct _ze_dditable_t ze_sampler_dditable_t Sampler; ze_physical_mem_dditable_t PhysicalMem; ze_mem_dditable_t Mem; + ze_mem_exp_dditable_t MemExp; ze_virtual_mem_dditable_t VirtualMem; ze_fabric_vertex_exp_dditable_t FabricVertexExp; ze_fabric_edge_exp_dditable_t FabricEdgeExp; diff --git a/include/zes.py b/include/zes.py index 68b14405..250b11b7 100644 --- a/include/zes.py +++ b/include/zes.py @@ -4,7 +4,7 @@ SPDX-License-Identifier: MIT @file zes.py - @version v1.5-r1.5.17 + @version v1.6-r1.6.0 """ import platform @@ -1185,6 +1185,7 @@ class zes_firmware_properties_t(Structure): class zes_freq_domain_v(IntEnum): GPU = 0 ## GPU Core Domain. MEMORY = 1 ## Local Memory Domain. + MEDIA = 2 ## GPU Media Domain. class zes_freq_domain_t(c_int): def __str__(self): diff --git a/include/zes_api.h b/include/zes_api.h index b0868763..f46c991f 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.5-r1.5.17 + * @version v1.6-r1.6.0 * */ #ifndef _ZES_API_H @@ -3222,6 +3222,7 @@ typedef enum _zes_freq_domain_t { ZES_FREQ_DOMAIN_GPU = 0, ///< GPU Core Domain. ZES_FREQ_DOMAIN_MEMORY = 1, ///< Local Memory Domain. + ZES_FREQ_DOMAIN_MEDIA = 2, ///< GPU Media Domain. ZES_FREQ_DOMAIN_FORCE_UINT32 = 0x7fffffff } zes_freq_domain_t; diff --git a/include/zes_ddi.h b/include/zes_ddi.h index 36f89ad8..f293bf1e 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.5-r1.5.17 + * @version v1.6-r1.6.0 * */ #ifndef _ZES_DDI_H diff --git a/include/zet.py b/include/zet.py index cdcb7b17..d6fedf81 100644 --- a/include/zet.py +++ b/include/zet.py @@ -4,7 +4,7 @@ SPDX-License-Identifier: MIT @file zet.py - @version v1.5-r1.5.17 + @version v1.6-r1.6.0 """ import platform diff --git a/include/zet_api.h b/include/zet_api.h index 5e01ed7a..29457f51 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.5-r1.5.17 + * @version v1.6-r1.6.0 * */ #ifndef _ZET_API_H diff --git a/include/zet_ddi.h b/include/zet_ddi.h index 3c504012..2532095a 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.5-r1.5.17 + * @version v1.6-r1.6.0 * */ #ifndef _ZET_DDI_H diff --git a/scripts/input.json b/scripts/input.json index c4931126..22dd75f5 100644 --- a/scripts/input.json +++ b/scripts/input.json @@ -866,6 +866,7 @@ "Close", "Reset", "AppendWriteGlobalTimestamp", + "HostSynchronize", "AppendMemoryCopy", "AppendMemoryFill", "AppendMemoryCopyRegion", @@ -1075,7 +1076,8 @@ "GetProperties", "GetIpcProperties", "GetExtensionProperties", - "GetExtensionFunctionAddress" + "GetExtensionFunctionAddress", + "GetLastErrorDescription" ], "handle": [ "$x_driver_handle_t" @@ -1099,7 +1101,8 @@ }, "$xEvent": { "enum": [ - "$x_event_scope_flags_t" + "$x_event_scope_flags_t", + "$x_event_query_kernel_timestamps_ext_flags_t" ], "function": [ "Create", @@ -1109,6 +1112,7 @@ "QueryStatus", "HostReset", "QueryKernelTimestamp", + "QueryKernelTimestampsExt", "QueryTimestampsExp" ], "handle": [ @@ -1124,7 +1128,9 @@ "struct": [ "$x_event_desc_t", "$x_kernel_timestamp_data_t", - "$x_kernel_timestamp_result_t" + "$x_kernel_timestamp_result_t", + "$x_synchronized_timestamp_data_ext_t", + "$x_synchronized_timestamp_result_ext_t" ] }, "$xEventPool": { @@ -1135,6 +1141,7 @@ "Create", "Destroy", "GetIpcHandle", + "PutIpcHandle", "OpenIpcHandle", "CloseIpcHandle" ], @@ -1326,6 +1333,9 @@ "GetAllocProperties", "GetAddressRange", "GetIpcHandle", + "GetIpcHandleFromFileDescriptorExp", + "GetFileDescriptorFromIpcHandleExp", + "PutIpcHandle", "OpenIpcHandle", "CloseIpcHandle", "FreeExt" @@ -1610,9 +1620,10 @@ "class": "$sDevice", "etors": [ "$S_FREQ_DOMAIN_GPU", - "$S_FREQ_DOMAIN_MEMORY" + "$S_FREQ_DOMAIN_MEMORY", + "$S_FREQ_DOMAIN_MEDIA" ], - "max": "$S_FREQ_DOMAIN_MEMORY" + "max": "$S_FREQ_DOMAIN_MEDIA" }, "$s_freq_throttle_reason_flags_t": { "class": "$sFrequency", @@ -2153,6 +2164,7 @@ "$X_API_VERSION_1_3", "$X_API_VERSION_1_4", "$X_API_VERSION_1_5", + "$X_API_VERSION_1_6", "$X_API_VERSION_CURRENT" ], "max": "$X_API_VERSION_CURRENT" @@ -2426,9 +2438,26 @@ "etors": [ "$X_EVENT_POOL_FLAG_HOST_VISIBLE", "$X_EVENT_POOL_FLAG_IPC", - "$X_EVENT_POOL_FLAG_KERNEL_TIMESTAMP" + "$X_EVENT_POOL_FLAG_KERNEL_TIMESTAMP", + "$X_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP" ], - "max": "0x7" + "max": "0xf" + }, + "$x_event_query_kernel_timestamps_ext_flags_t": { + "class": "$xEvent", + "etors": [ + "$X_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_FLAG_KERNEL", + "$X_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_FLAG_SYNCHRONIZED" + ], + "max": "0x3" + }, + "$x_event_query_kernel_timestamps_ext_version_t": { + "class": "", + "etors": [ + "$X_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_VERSION_1_0", + "$X_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_VERSION_CURRENT" + ], + "max": "$X_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_VERSION_CURRENT" }, "$x_event_query_timestamps_exp_version_t": { "class": "", @@ -3061,6 +3090,8 @@ "$X_STRUCTURE_TYPE_DEVICE_MEMORY_EXT_PROPERTIES", "$X_STRUCTURE_TYPE_DEVICE_IP_VERSION_EXT", "$X_STRUCTURE_TYPE_IMAGE_VIEW_PLANAR_EXT_DESC", + "$X_STRUCTURE_TYPE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_PROPERTIES", + "$X_STRUCTURE_TYPE_EVENT_QUERY_KERNEL_TIMESTAMPS_RESULTS_EXT_PROPERTIES", "$X_STRUCTURE_TYPE_RELAXED_ALLOCATION_LIMITS_EXP_DESC", "$X_STRUCTURE_TYPE_MODULE_PROGRAM_EXP_DESC", "$X_STRUCTURE_TYPE_SCHEDULING_HINT_EXP_PROPERTIES", @@ -5865,6 +5896,17 @@ } ] }, + "$xCommandListHostSynchronize": { + "class": "$xCommandList", + "params": [ + { + "type": "$x_command_list_handle_t" + }, + { + "type": "uint64_t" + } + ] + }, "$xCommandListReset": { "class": "$xCommandList", "params": [ @@ -6349,6 +6391,17 @@ } ] }, + "$xDriverGetLastErrorDescription": { + "class": "$xDriver", + "params": [ + { + "type": "$x_driver_handle_t" + }, + { + "type": "const char**" + } + ] + }, "$xDriverGetProperties": { "class": "$xDriver", "params": [ @@ -6470,6 +6523,17 @@ } ] }, + "$xEventPoolPutIpcHandle": { + "class": "$xEventPool", + "params": [ + { + "type": "$x_context_handle_t" + }, + { + "type": "$x_ipc_event_pool_handle_t" + } + ] + }, "$xEventQueryKernelTimestamp": { "class": "$xEvent", "params": [ @@ -6481,6 +6545,23 @@ } ] }, + "$xEventQueryKernelTimestampsExt": { + "class": "$xEvent", + "params": [ + { + "type": "$x_event_handle_t" + }, + { + "type": "$x_device_handle_t" + }, + { + "type": "uint32_t*" + }, + { + "type": "$x_event_query_kernel_timestamps_results_ext_properties_t*" + } + ] + }, "$xEventQueryStatus": { "class": "$xEvent", "params": [ @@ -7091,6 +7172,20 @@ } ] }, + "$xMemGetFileDescriptorFromIpcHandleExp": { + "class": "$xMem", + "params": [ + { + "type": "$x_context_handle_t" + }, + { + "type": "$x_ipc_mem_handle_t" + }, + { + "type": "uint64_t*" + } + ] + }, "$xMemGetIpcHandle": { "class": "$xMem", "params": [ @@ -7105,6 +7200,20 @@ } ] }, + "$xMemGetIpcHandleFromFileDescriptorExp": { + "class": "$xMem", + "params": [ + { + "type": "$x_context_handle_t" + }, + { + "type": "uint64_t" + }, + { + "type": "$x_ipc_mem_handle_t*" + } + ] + }, "$xMemOpenIpcHandle": { "class": "$xMem", "params": [ @@ -7125,6 +7234,17 @@ } ] }, + "$xMemPutIpcHandle": { + "class": "$xMem", + "params": [ + { + "type": "$x_context_handle_t" + }, + { + "type": "$x_ipc_mem_handle_t" + } + ] + }, "$xModuleBuildLogDestroy": { "class": "$xModuleBuildLog", "params": [ @@ -7779,6 +7899,12 @@ "\"$X_extension_eu_count\"" ] }, + "$X_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_NAME": { + "class": "", + "values": [ + "\"$X_extension_event_query_kernel_timestamps\"" + ] + }, "$X_EVENT_QUERY_TIMESTAMPS_EXP_NAME": { "class": "", "values": [ @@ -11272,6 +11398,34 @@ } ] }, + "$x_event_query_kernel_timestamps_ext_properties_t": { + "class": "", + "members": [ + { + "desc": "[out] 0 or some combination of $x_event_query_kernel_timestamps_ext_flag_t flags", + "init": null, + "name": "flags", + "type": "$x_event_query_kernel_timestamps_ext_flags_t" + } + ] + }, + "$x_event_query_kernel_timestamps_results_ext_properties_t": { + "class": "", + "members": [ + { + "desc": "[in,out][optional][range(0, *pCount)] pointer to destination buffer of kernel timestamp results", + "init": "nullptr", + "name": "pKernelTimestampsBuffer", + "type": "$x_kernel_timestamp_result_t*" + }, + { + "desc": "[in,out][optional][range(0, *pCount)] pointer to destination buffer of synchronized timestamp results", + "init": "nullptr", + "name": "pSynchronizedTimestampsBuffer", + "type": "$x_synchronized_timestamp_result_ext_t*" + } + ] + }, "$x_external_memory_export_desc_t": { "class": "$xMem", "members": [ @@ -11551,7 +11705,7 @@ "type": "$x_image_flags_t" }, { - "desc": "[in] image type", + "desc": "[in] image type. Media format layouts are unsupported for $X_IMAGE_TYPE_BUFFER", "init": null, "name": "type", "type": "$x_image_type_t" @@ -11598,13 +11752,13 @@ "class": "$xImage", "members": [ { - "desc": "[in] image format component layout", + "desc": "[in] image format component layout (e.g. N-component layouts and media formats)", "init": null, "name": "layout", "type": "$x_image_format_layout_t" }, { - "desc": "[in] image format type. Media formats can't be used for $X_IMAGE_TYPE_BUFFER.", + "desc": "[in] image format type", "init": null, "name": "type", "type": "$x_image_format_type_t" @@ -12039,7 +12193,7 @@ "type": "const uint8_t*" }, { - "desc": "[in][optional] string containing compiler flags. Following options are supported.\n - \"-$x-opt-disable\"\n - Disable optimizations\n - \"-$x-opt-level\"\n - Specifies optimization level for compiler. Levels are implementation specific.\n - 0 is no optimizations (equivalent to -$x-opt-disable)\n - 1 is optimize minimally (may be the same as 2)\n - 2 is optimize more (default)\n - \"-$x-opt-greater-than-4GB-buffer-required\"\n - Use 64-bit offset calculations for buffers.\n - \"-$x-opt-large-register-file\"\n - Increase number of registers available to threads.\n - \"-$x-opt-has-buffer-offset-arg\"\n - Extend stateless to stateful optimization to more\n cases with the use of additional offset (e.g. 64-bit\n pointer to binding table with 32-bit offset).\n - \"-g\"\n - Include debugging information.\n", + "desc": "[in][optional] string containing one or more (comma-separated) compiler flags. If unsupported, flag is ignored with a warning.\n - \"-$x-opt-disable\"\n - Disable optimizations\n - \"-$x-opt-level\"\n - Specifies optimization level for compiler. Levels are implementation specific.\n - 0 is no optimizations (equivalent to -$x-opt-disable)\n - 1 is optimize minimally (may be the same as 2)\n - 2 is optimize more (default)\n - \"-$x-opt-greater-than-4GB-buffer-required\"\n - Use 64-bit offset calculations for buffers.\n - \"-$x-opt-large-register-file\"\n - Increase number of registers available to threads.\n - \"-$x-opt-has-buffer-offset-arg\"\n - Extend stateless to stateful optimization to more\n cases with the use of additional offset (e.g. 64-bit\n pointer to binding table with 32-bit offset).\n - \"-g\"\n - Include debugging information.\n", "init": "nullptr", "name": "pBuildFlags", "type": "const char*" @@ -12290,6 +12444,40 @@ } ] }, + "$x_synchronized_timestamp_data_ext_t": { + "class": "$xEvent", + "members": [ + { + "desc": "[out] synchronized clock at start of kernel execution", + "init": null, + "name": "kernelStart", + "type": "uint64_t" + }, + { + "desc": "[out] synchronized clock at end of kernel execution", + "init": null, + "name": "kernelEnd", + "type": "uint64_t" + } + ] + }, + "$x_synchronized_timestamp_result_ext_t": { + "class": "$xEvent", + "members": [ + { + "desc": "[out] wall-clock data", + "init": null, + "name": "global", + "type": "$x_synchronized_timestamp_data_ext_t" + }, + { + "desc": "[out] context-active data; only includes clocks while device context was actively executing.", + "init": null, + "name": "context", + "type": "$x_synchronized_timestamp_data_ext_t" + } + ] + }, "$x_uuid_t": { "class": "", "members": [ @@ -13270,10 +13458,16 @@ "value": "ZE_MAKE_VERSION( 1, 5 )", "version": "1.5" }, + { + "desc": "version 1.6", + "name": "ZE_API_VERSION_1_6", + "value": "ZE_MAKE_VERSION( 1, 6 )", + "version": "1.6" + }, { "desc": "latest known version", "name": "ZE_API_VERSION_CURRENT", - "value": "ZE_MAKE_VERSION( 1, 5 )" + "value": "ZE_MAKE_VERSION( 1, 6 )" } ], "name": "ze_api_version_t", @@ -14007,11 +14201,54 @@ "desc": "Indicates all events in pool will contain kernel timestamps", "name": "ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP", "value": "ZE_BIT(2)" + }, + { + "desc": "Indicates all events in pool will contain kernel timestamps synchronized to host time domain; cannot be combined with ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP", + "name": "ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP", + "value": "ZE_BIT(3)", + "version": "1.6" } ], "name": "ze_event_pool_flags_t", "type": "enum" }, + "ze_event_query_kernel_timestamps_ext_flags_t": { + "class": "zeEvent", + "desc": "Event query kernel timestamps flags", + "etors": [ + { + "desc": "Kernel timestamp results", + "name": "ZE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_FLAG_KERNEL", + "value": "ZE_BIT(0)" + }, + { + "desc": "Device event timestamps synchronized to the host time domain", + "name": "ZE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_FLAG_SYNCHRONIZED", + "value": "ZE_BIT(1)" + } + ], + "name": "ze_event_query_kernel_timestamps_ext_flags_t", + "type": "enum", + "version": "1.6" + }, + "ze_event_query_kernel_timestamps_ext_version_t": { + "desc": "Event Query Kernel Timestamps Extension Version(s)", + "etors": [ + { + "desc": "version 1.0", + "name": "ZE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_VERSION_1_0", + "value": "ZE_MAKE_VERSION( 1, 0 )" + }, + { + "desc": "latest known version", + "name": "ZE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_VERSION_CURRENT", + "value": "ZE_MAKE_VERSION( 1, 0 )" + } + ], + "name": "ze_event_query_kernel_timestamps_ext_version_t", + "type": "enum", + "version": "1.6" + }, "ze_event_query_timestamps_exp_version_t": { "desc": "Event Query Timestamps Extension Version(s)", "etors": [ @@ -15944,6 +16181,18 @@ "value": "0x10010", "version": "1.5" }, + { + "desc": "ze_event_query_kernel_timestamps_ext_properties_t", + "name": "ZE_STRUCTURE_TYPE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_PROPERTIES", + "value": "0x10011", + "version": "1.6" + }, + { + "desc": "ze_event_query_kernel_timestamps_results_ext_properties_t", + "name": "ZE_STRUCTURE_TYPE_EVENT_QUERY_KERNEL_TIMESTAMPS_RESULTS_EXT_PROPERTIES", + "value": "0x10012", + "version": "1.6" + }, { "desc": "ze_relaxed_allocation_limits_exp_desc_t", "name": "ZE_STRUCTURE_TYPE_RELAXED_ALLOCATION_LIMITS_EXP_DESC", @@ -16494,6 +16743,12 @@ "desc": "Local Memory Domain.", "name": "ZES_FREQ_DOMAIN_MEMORY", "value": "1" + }, + { + "desc": "GPU Media Domain.", + "name": "ZES_FREQ_DOMAIN_MEDIA", + "value": "2", + "version": "1.6" } ], "name": "zes_freq_domain_t", @@ -20531,7 +20786,7 @@ "desc": "Appends a signal of the event from the device into a command list.", "details": [ "The application must ensure the events are accessible by the device on which the command list was created.", - "The duration of an event created from an event pool that was created using ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP flag is undefined. However, for consistency and orthogonality the event will report correctly as signaled when used by other event API functionality.", + "The duration of an event created from an event pool that was created using ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP or ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP flags is undefined. However, for consistency and orthogonality the event will report correctly as signaled when used by other event API functionality.", "The application must ensure the command list and events were created on the same context.", "The application must **not** call this function from simultaneous threads with the same command list handle.", "The implementation of this function should be lock-free." @@ -25061,6 +25316,64 @@ "type": "function", "version": "1.4" }, + "GetFileDescriptorFromIpcHandleExp": { + "class": "zeMem", + "decl": "static", + "desc": "Gets the file descriptor contained in an IPC memory handle", + "details": [ + "IPC memory handle must be a valid handle obtained with zeMemGetIpcHandle.", + "The application may call this function from simultaneous threads.", + "The implementation of this function must be thread-safe." + ], + "hash": "4f0cd196b792fa6c5010f1779f899fc5252608ccded499cc460199f47343f4b6", + "name": "GetFileDescriptorFromIpcHandleExp", + "params": [ + { + "desc": "[in] handle of the context object", + "name": "hContext", + "type": "ze_context_handle_t" + }, + { + "desc": "[in] IPC memory handle", + "name": "ipcHandle", + "type": "ze_ipc_mem_handle_t" + }, + { + "desc": "[out] Returned file descriptor", + "name": "pHandle", + "type": "uint64_t*" + } + ], + "returns": [ + { + "ZE_RESULT_SUCCESS": [] + }, + { + "ZE_RESULT_ERROR_UNINITIALIZED": [] + }, + { + "ZE_RESULT_ERROR_DEVICE_LOST": [] + }, + { + "ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY": [] + }, + { + "ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY": [] + }, + { + "ZE_RESULT_ERROR_INVALID_NULL_HANDLE": [ + "`nullptr == hContext`" + ] + }, + { + "ZE_RESULT_ERROR_INVALID_NULL_POINTER": [ + "`nullptr == pHandle`" + ] + } + ], + "type": "function", + "version": "1.6" + }, "GetFunctionPointer": { "class": "zeModule", "desc": "Retrieve a function pointer from a module by name", @@ -25470,6 +25783,65 @@ ], "type": "function" }, + "GetIpcHandleFromFileDescriptorExp": { + "class": "zeMem", + "decl": "static", + "desc": "Creates an IPC memory handle out of a file descriptor", + "details": [ + "Handle passed must be a valid file descriptor obtained with ze_external_memory_export_fd_t via zeMemGetAllocProperties.", + "Returned IPC handle may contain metadata in addition to the file descriptor.", + "The application may call this function from simultaneous threads.", + "The implementation of this function must be thread-safe." + ], + "hash": "85dd8fd011ef561b945d46995f774fa76385cef8b350475fb4fa35684277399e", + "name": "GetIpcHandleFromFileDescriptorExp", + "params": [ + { + "desc": "[in] handle of the context object", + "name": "hContext", + "type": "ze_context_handle_t" + }, + { + "desc": "[in] file descriptor", + "name": "handle", + "type": "uint64_t" + }, + { + "desc": "[out] Returned IPC memory handle", + "name": "pIpcHandle", + "type": "ze_ipc_mem_handle_t*" + } + ], + "returns": [ + { + "ZE_RESULT_SUCCESS": [] + }, + { + "ZE_RESULT_ERROR_UNINITIALIZED": [] + }, + { + "ZE_RESULT_ERROR_DEVICE_LOST": [] + }, + { + "ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY": [] + }, + { + "ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY": [] + }, + { + "ZE_RESULT_ERROR_INVALID_NULL_HANDLE": [ + "`nullptr == hContext`" + ] + }, + { + "ZE_RESULT_ERROR_INVALID_NULL_POINTER": [ + "`nullptr == pIpcHandle`" + ] + } + ], + "type": "function", + "version": "1.6" + }, "GetIpcProperties": { "class": "zeDriver", "desc": "Retrieves IPC attributes of the driver", @@ -25576,6 +25948,60 @@ ], "type": "function" }, + "GetLastErrorDescription": { + "class": "zeDriver", + "desc": "Retrieves a string describing the last error code returned by the driver in the current thread.", + "details": [ + "String returned is thread local.", + "String is only updated on calls returning an error, i.e., not on calls returning ZE_RESULT_SUCCESS.", + "String may be empty if driver considers error code is already explicit enough to describe cause.", + "Memory pointed to by ppString is owned by the driver.", + "String returned is null-terminated." + ], + "hash": "a3ac6b1e67b0b263ef01af2319655f3a1efe1b2d8483fa6eb1ce4f0e80af0612", + "name": "GetLastErrorDescription", + "params": [ + { + "desc": "[in] handle of the driver instance", + "name": "hDriver", + "type": "ze_driver_handle_t" + }, + { + "desc": "[in,out] pointer to a null-terminated array of characters describing cause of error.", + "name": "ppString", + "type": "const char**" + } + ], + "returns": [ + { + "ZE_RESULT_SUCCESS": [] + }, + { + "ZE_RESULT_ERROR_UNINITIALIZED": [] + }, + { + "ZE_RESULT_ERROR_DEVICE_LOST": [] + }, + { + "ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY": [] + }, + { + "ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY": [] + }, + { + "ZE_RESULT_ERROR_INVALID_NULL_HANDLE": [ + "`nullptr == hDriver`" + ] + }, + { + "ZE_RESULT_ERROR_INVALID_NULL_POINTER": [ + "`nullptr == ppString`" + ] + } + ], + "type": "function", + "version": "1.6" + }, "GetLimits": { "class": "zesPower", "desc": "Get power limits", @@ -27438,7 +27864,7 @@ "class": "zeEvent", "desc": "Signals a event from host.", "details": [ - "The duration of an event created from an event pool that was created using ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP flag is undefined. However, for consistency and orthogonality the event will report correctly as signaled when used by other event API functionality.", + "The duration of an event created from an event pool that was created using ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP or ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP flags is undefined. However, for consistency and orthogonality the event will report correctly as signaled when used by other event API functionality.", "The application may call this function from simultaneous threads.", "The implementation of this function should be lock-free." ], @@ -29082,11 +29508,61 @@ ], "type": "function" }, + "PutIpcHandle": { + "class": "zeMem", + "decl": "static", + "desc": "Returns an IPC memory handle to the driver", + "details": [ + "This call may be used for IPC handles previously obtained with either zeMemGetIpcHandle or with ze_external_memory_export_fd_t via zeMemGetAllocProperties.\n", + "Upon call, driver may release any underlying resources associated with the IPC handle.\nFor instance, it may close the file descriptor contained in the IPC handle, if such type of handle is being used by the driver.\n", + "This call does not free the original allocation for which the IPC handle was created.", + "This function may **not** be called from simultaneous threads with the same IPC handle.", + "The implementation of this function should be lock-free." + ], + "hash": "34244e7493a2b2f9d15f3f02f77e55814209a257d38057e839b02653d59f6608", + "name": "PutIpcHandle", + "params": [ + { + "desc": "[in] handle of the context object", + "name": "hContext", + "type": "ze_context_handle_t" + }, + { + "desc": "[in] IPC memory handle", + "name": "handle", + "type": "ze_ipc_mem_handle_t" + } + ], + "returns": [ + { + "ZE_RESULT_SUCCESS": [] + }, + { + "ZE_RESULT_ERROR_UNINITIALIZED": [] + }, + { + "ZE_RESULT_ERROR_DEVICE_LOST": [] + }, + { + "ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY": [] + }, + { + "ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY": [] + }, + { + "ZE_RESULT_ERROR_INVALID_NULL_HANDLE": [ + "`nullptr == hContext`" + ] + } + ], + "type": "function", + "version": "1.6" + }, "QueryKernelTimestamp": { "class": "zeEvent", "desc": "Queries an event's timestamp value on the host.", "details": [ - "The application must ensure the event was created from an event pool that was created using ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP flag.", + "The application must ensure the event was created from an event pool that was created using ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP or ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP flag.", "The destination memory will be unmodified if the event has not been signaled.", "The application may call this function from simultaneous threads.", "The implementation of this function should be lock-free." @@ -29142,6 +29618,75 @@ ], "type": "function" }, + "QueryKernelTimestampsExt": { + "class": "zeEvent", + "desc": "Query an event's timestamp value on the host, with domain preference.", + "details": [ + "For collecting *only* kernel timestamps, the application must ensure the event was created from an event pool that was created using ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP flag.", + "For collecting synchronized timestamps, the application must ensure the event was created from an event pool that was created using ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP flag. Kernel timestamps are also available from this type of event pool, but there is a performance cost.", + "The destination memory will be unmodified if the event has not been signaled.", + "The application may call this function from simultaneous threads.", + "The implementation of this function must be thread-safe.", + "The implementation must support ZE_extension_event_query_kernel_timestamps.", + "The implementation must return all timestamps for the specified event and device pair.", + "The implementation must return all timestamps for all sub-devices when device handle is parent device.", + "The implementation may return all timestamps for sub-devices when device handle is sub-device or may return 0 for count." + ], + "hash": "1fd7be75405b56820b9d681d430d712ad8c789c74a5cd4e3332d20245e9694c0", + "name": "QueryKernelTimestampsExt", + "params": [ + { + "desc": "[in] handle of the event", + "name": "hEvent", + "type": "ze_event_handle_t" + }, + { + "desc": "[in] handle of the device to query", + "name": "hDevice", + "type": "ze_device_handle_t" + }, + { + "desc": "[in,out] pointer to the number of event packets available.\n - This value is implementation specific.\n - if `*pCount` is zero, then the driver shall update the value with the total number of event packets available.\n - if `*pCount` is greater than the number of event packets available, the driver shall update the value with the correct value.\n - Buffer(s) for query results must be sized by the application to accommodate a minimum of `*pCount` elements.\n", + "name": "pCount", + "type": "uint32_t*" + }, + { + "desc": "[in][optional] pointer to event query properties structure(s).\n - This parameter may be null when `*pCount` is zero.\n - if `*pCount` is less than the number of event packets available, the driver may only update `*pCount` elements, starting at element zero.\n - if `*pCount` is greater than the number of event packets available, the driver may only update the valid elements.\n", + "name": "pResults", + "type": "ze_event_query_kernel_timestamps_results_ext_properties_t*" + } + ], + "returns": [ + { + "ZE_RESULT_SUCCESS": [] + }, + { + "ZE_RESULT_ERROR_UNINITIALIZED": [] + }, + { + "ZE_RESULT_ERROR_DEVICE_LOST": [] + }, + { + "ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY": [] + }, + { + "ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY": [] + }, + { + "ZE_RESULT_ERROR_INVALID_NULL_HANDLE": [ + "`nullptr == hEvent`", + "`nullptr == hDevice`" + ] + }, + { + "ZE_RESULT_ERROR_INVALID_NULL_POINTER": [ + "`nullptr == pCount`" + ] + } + ], + "type": "function", + "version": "1.6" + }, "QueryPageSize": { "class": "zeVirtualMem", "decl": "static", @@ -32933,6 +33478,13 @@ "value": "\"ZE_extension_eu_count\"", "version": "1.3" }, + "ZE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_NAME": { + "desc": "Event Query Kernel Timestamps Extension Name", + "name": "ZE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_NAME", + "type": "macro", + "value": "\"ZE_extension_event_query_kernel_timestamps\"", + "version": "1.6" + }, "ZE_EVENT_QUERY_TIMESTAMPS_EXP_NAME": { "desc": "Event Query Timestamps Extension Name", "name": "ZE_EVENT_QUERY_TIMESTAMPS_EXP_NAME", @@ -34515,6 +35067,68 @@ "name": "ze_event_pool_desc_t", "type": "struct" }, + "ze_event_query_kernel_timestamps_ext_properties_t": { + "base": "ze_base_properties_t", + "desc": "Event query kernel timestamps properties", + "details": [ + "This structure may be returned from zeDeviceGetProperties, via `pNext` member of ze_device_properties_t." + ], + "members": [ + { + "desc": "[in] type of this structure", + "init": "ZE_STRUCTURE_TYPE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_PROPERTIES", + "name": "stype", + "type": "ze_structure_type_t" + }, + { + "desc": "[in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains sType and pNext).", + "init": "nullptr", + "name": "pNext", + "type": "void*" + }, + { + "desc": "[out] 0 or some combination of ze_event_query_kernel_timestamps_ext_flag_t flags", + "name": "flags", + "type": "ze_event_query_kernel_timestamps_ext_flags_t" + } + ], + "name": "ze_event_query_kernel_timestamps_ext_properties_t", + "type": "struct", + "version": "1.6" + }, + "ze_event_query_kernel_timestamps_results_ext_properties_t": { + "base": "ze_base_properties_t", + "desc": "Event query kernel timestamps results properties", + "members": [ + { + "desc": "[in] type of this structure", + "init": "ZE_STRUCTURE_TYPE_EVENT_QUERY_KERNEL_TIMESTAMPS_RESULTS_EXT_PROPERTIES", + "name": "stype", + "type": "ze_structure_type_t" + }, + { + "desc": "[in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains sType and pNext).", + "init": "nullptr", + "name": "pNext", + "type": "void*" + }, + { + "desc": "[in,out][optional][range(0, *pCount)] pointer to destination buffer of kernel timestamp results", + "init": "nullptr", + "name": "pKernelTimestampsBuffer", + "type": "ze_kernel_timestamp_result_t*" + }, + { + "desc": "[in,out][optional][range(0, *pCount)] pointer to destination buffer of synchronized timestamp results", + "init": "nullptr", + "name": "pSynchronizedTimestampsBuffer", + "type": "ze_synchronized_timestamp_result_ext_t*" + } + ], + "name": "ze_event_query_kernel_timestamps_results_ext_properties_t", + "type": "struct", + "version": "1.6" + }, "ze_external_memory_export_desc_t": { "base": "ze_base_desc_t", "class": "zeMem", @@ -35002,7 +35616,7 @@ "type": "ze_image_flags_t" }, { - "desc": "[in] image type", + "desc": "[in] image type. Media format layouts are unsupported for ZE_IMAGE_TYPE_BUFFER", "name": "type", "type": "ze_image_type_t" }, @@ -35050,12 +35664,12 @@ "desc": "Image format ", "members": [ { - "desc": "[in] image format component layout", + "desc": "[in] image format component layout (e.g. N-component layouts and media formats)", "name": "layout", "type": "ze_image_format_layout_t" }, { - "desc": "[in] image format type. Media formats can't be used for ZE_IMAGE_TYPE_BUFFER.", + "desc": "[in] image format type", "name": "type", "type": "ze_image_format_type_t" }, @@ -35713,7 +36327,7 @@ "type": "const uint8_t*" }, { - "desc": "[in][optional] string containing compiler flags. Following options are supported.\n - \"-ze-opt-disable\"\n - Disable optimizations\n - \"-ze-opt-level\"\n - Specifies optimization level for compiler. Levels are implementation specific.\n - 0 is no optimizations (equivalent to -ze-opt-disable)\n - 1 is optimize minimally (may be the same as 2)\n - 2 is optimize more (default)\n - \"-ze-opt-greater-than-4GB-buffer-required\"\n - Use 64-bit offset calculations for buffers.\n - \"-ze-opt-large-register-file\"\n - Increase number of registers available to threads.\n - \"-ze-opt-has-buffer-offset-arg\"\n - Extend stateless to stateful optimization to more\n cases with the use of additional offset (e.g. 64-bit\n pointer to binding table with 32-bit offset).\n - \"-g\"\n - Include debugging information.\n", + "desc": "[in][optional] string containing one or more (comma-separated) compiler flags. If unsupported, flag is ignored with a warning.\n - \"-ze-opt-disable\"\n - Disable optimizations\n - \"-ze-opt-level\"\n - Specifies optimization level for compiler. Levels are implementation specific.\n - 0 is no optimizations (equivalent to -ze-opt-disable)\n - 1 is optimize minimally (may be the same as 2)\n - 2 is optimize more (default)\n - \"-ze-opt-greater-than-4GB-buffer-required\"\n - Use 64-bit offset calculations for buffers.\n - \"-ze-opt-large-register-file\"\n - Increase number of registers available to threads.\n - \"-ze-opt-has-buffer-offset-arg\"\n - Extend stateless to stateful optimization to more\n cases with the use of additional offset (e.g. 64-bit\n pointer to binding table with 32-bit offset).\n - \"-g\"\n - Include debugging information.\n", "init": "nullptr", "name": "pBuildFlags", "type": "const char*" @@ -36156,6 +36770,44 @@ "type": "struct", "version": "1.5" }, + "ze_synchronized_timestamp_data_ext_t": { + "class": "zeEvent", + "desc": "Kernel timestamp clock data synchronized to the host time domain", + "members": [ + { + "desc": "[out] synchronized clock at start of kernel execution", + "name": "kernelStart", + "type": "uint64_t" + }, + { + "desc": "[out] synchronized clock at end of kernel execution", + "name": "kernelEnd", + "type": "uint64_t" + } + ], + "name": "ze_synchronized_timestamp_data_ext_t", + "type": "struct", + "version": "1.6" + }, + "ze_synchronized_timestamp_result_ext_t": { + "class": "zeEvent", + "desc": "Synchronized kernel timestamp result", + "members": [ + { + "desc": "[out] wall-clock data", + "name": "global", + "type": "ze_synchronized_timestamp_data_ext_t" + }, + { + "desc": "[out] context-active data; only includes clocks while device context was actively executing.", + "name": "context", + "type": "ze_synchronized_timestamp_data_ext_t" + } + ], + "name": "ze_synchronized_timestamp_result_ext_t", + "type": "struct", + "version": "1.6" + }, "ze_uuid_t": { "desc": "Universal unique id (UUID)", "members": [ @@ -40006,6 +40658,18 @@ "value": "0x10010", "version": "1.5" }, + { + "desc": "$x_event_query_kernel_timestamps_ext_properties_t", + "name": "$X_STRUCTURE_TYPE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_PROPERTIES", + "value": "0x10011", + "version": "1.6" + }, + { + "desc": "$x_event_query_kernel_timestamps_results_ext_properties_t", + "name": "$X_STRUCTURE_TYPE_EVENT_QUERY_KERNEL_TIMESTAMPS_RESULTS_EXT_PROPERTIES", + "value": "0x10012", + "version": "1.6" + }, { "desc": "$x_relaxed_allocation_limits_exp_desc_t", "name": "$X_STRUCTURE_TYPE_RELAXED_ALLOCATION_LIMITS_EXP_DESC", @@ -40442,10 +41106,16 @@ "value": "$X_MAKE_VERSION( 1, 5 )", "version": "1.5" }, + { + "desc": "version 1.6", + "name": "$X_API_VERSION_1_6", + "value": "$X_MAKE_VERSION( 1, 6 )", + "version": "1.6" + }, { "desc": "latest known version", "name": "$X_API_VERSION_CURRENT", - "value": "$X_MAKE_VERSION( 1, 5 )" + "value": "$X_MAKE_VERSION( 1, 6 )" } ], "name": "$x_api_version_t", @@ -40851,6 +41521,60 @@ ], "name": "$xDriver", "type": "class" + }, + { + "class": "$xDriver", + "desc": "Retrieves a string describing the last error code returned by the driver in the current thread.", + "details": [ + "String returned is thread local.", + "String is only updated on calls returning an error, i.e., not on calls returning $X_RESULT_SUCCESS.", + "String may be empty if driver considers error code is already explicit enough to describe cause.", + "Memory pointed to by ppString is owned by the driver.", + "String returned is null-terminated." + ], + "hash": "a3ac6b1e67b0b263ef01af2319655f3a1efe1b2d8483fa6eb1ce4f0e80af0612", + "name": "GetLastErrorDescription", + "params": [ + { + "desc": "[in] handle of the driver instance", + "name": "hDriver", + "type": "$x_driver_handle_t" + }, + { + "desc": "[in,out] pointer to a null-terminated array of characters describing cause of error.", + "name": "ppString", + "type": "const char**" + } + ], + "returns": [ + { + "$X_RESULT_SUCCESS": [] + }, + { + "$X_RESULT_ERROR_UNINITIALIZED": [] + }, + { + "$X_RESULT_ERROR_DEVICE_LOST": [] + }, + { + "$X_RESULT_ERROR_OUT_OF_HOST_MEMORY": [] + }, + { + "$X_RESULT_ERROR_OUT_OF_DEVICE_MEMORY": [] + }, + { + "$X_RESULT_ERROR_INVALID_NULL_HANDLE": [ + "`nullptr == hDriver`" + ] + }, + { + "$X_RESULT_ERROR_INVALID_NULL_POINTER": [ + "`nullptr == ppString`" + ] + } + ], + "type": "function", + "version": "1.6" } ] }, @@ -43714,6 +44438,64 @@ ], "type": "function" }, + { + "class": "$xCommandList", + "desc": "Synchronizes an immediate command list by waiting on the host for the completion of all commands previously submitted to it.", + "details": [ + "The application must call this function only with command lists created with $xCommandListCreateImmediate.", + "Waiting on one immediate command list shall not block the concurrent execution of commands appended to other\nimmediate command lists created with either a different ordinal or different index.\n", + "The application may call this function from simultaneous threads.", + "The implementation of this function should be lock-free." + ], + "hash": "676e5a921f37f7e6bd62bdf18bd9d693decf69aadc86ebc33cc12bd5184a7414", + "name": "HostSynchronize", + "params": [ + { + "desc": "[in] handle of the immediate command list", + "name": "hCommandList", + "type": "$x_command_list_handle_t" + }, + { + "desc": "[in] if non-zero, then indicates the maximum time (in nanoseconds) to yield before returning $X_RESULT_SUCCESS or $X_RESULT_NOT_READY;\nif zero, then immediately returns the status of the immediate command list;\nif UINT64_MAX, then function will not return until complete or device is lost.\nDue to external dependencies, timeout may be rounded to the closest value allowed by the accuracy of those dependencies.\n", + "name": "timeout", + "type": "uint64_t" + } + ], + "returns": [ + { + "$X_RESULT_SUCCESS": [] + }, + { + "$X_RESULT_ERROR_UNINITIALIZED": [] + }, + { + "$X_RESULT_ERROR_DEVICE_LOST": [] + }, + { + "$X_RESULT_ERROR_OUT_OF_HOST_MEMORY": [] + }, + { + "$X_RESULT_ERROR_OUT_OF_DEVICE_MEMORY": [] + }, + { + "$X_RESULT_ERROR_INVALID_NULL_HANDLE": [ + "`nullptr == hCommandList`" + ] + }, + { + "$X_RESULT_NOT_READY": [ + "timeout expired" + ] + }, + { + "$X_RESULT_ERROR_INVALID_ARGUMENT": [ + "handle does not correspond to an immediate command list" + ] + } + ], + "type": "function", + "version": "1.6" + }, { "desc": "C++ wrapper for command list", "members": [ @@ -45022,6 +45804,12 @@ "desc": "Indicates all events in pool will contain kernel timestamps", "name": "$X_EVENT_POOL_FLAG_KERNEL_TIMESTAMP", "value": "$X_BIT(2)" + }, + { + "desc": "Indicates all events in pool will contain kernel timestamps synchronized to host time domain; cannot be combined with $X_EVENT_POOL_FLAG_KERNEL_TIMESTAMP", + "name": "$X_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP", + "value": "$X_BIT(3)", + "version": "1.6" } ], "name": "$x_event_pool_flags_t", @@ -45127,7 +45915,7 @@ }, { "$X_RESULT_ERROR_INVALID_ENUMERATION": [ - "`0x7 < desc->flags`" + "`0xf < desc->flags`" ] }, { @@ -45422,6 +46210,56 @@ ], "type": "function" }, + { + "class": "$xEventPool", + "decl": "static", + "desc": "Returns an IPC event pool handle to the driver", + "details": [ + "This call must be used for IPC handles previously obtained with $xEventPoolGetIpcHandle.", + "Upon call, driver may release any underlying resources associated with the IPC handle.\nFor instance, it may close the file descriptor contained in the IPC handle, if such type of handle is being used by the driver.\n", + "This call does not destroy the original event pool for which the IPC handle was created.", + "This function may **not** be called from simultaneous threads with the same IPC handle.", + "The implementation of this function should be lock-free." + ], + "hash": "2b0ef05d5c246265c1815378f9139e736a46e5a4ee09f61371d1a37db17c579f", + "name": "PutIpcHandle", + "params": [ + { + "desc": "[in] handle of the context object associated with the IPC event pool handle", + "name": "hContext", + "type": "$x_context_handle_t" + }, + { + "desc": "[in] IPC event pool handle", + "name": "hIpc", + "type": "$x_ipc_event_pool_handle_t" + } + ], + "returns": [ + { + "$X_RESULT_SUCCESS": [] + }, + { + "$X_RESULT_ERROR_UNINITIALIZED": [] + }, + { + "$X_RESULT_ERROR_DEVICE_LOST": [] + }, + { + "$X_RESULT_ERROR_OUT_OF_HOST_MEMORY": [] + }, + { + "$X_RESULT_ERROR_OUT_OF_DEVICE_MEMORY": [] + }, + { + "$X_RESULT_ERROR_INVALID_NULL_HANDLE": [ + "`nullptr == hContext`" + ] + } + ], + "type": "function", + "version": "1.6" + }, { "class": "$xEventPool", "decl": "static", @@ -45528,7 +46366,7 @@ "desc": "Appends a signal of the event from the device into a command list.", "details": [ "The application must ensure the events are accessible by the device on which the command list was created.", - "The duration of an event created from an event pool that was created using $X_EVENT_POOL_FLAG_KERNEL_TIMESTAMP flag is undefined. However, for consistency and orthogonality the event will report correctly as signaled when used by other event API functionality.", + "The duration of an event created from an event pool that was created using $X_EVENT_POOL_FLAG_KERNEL_TIMESTAMP or $X_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP flags is undefined. However, for consistency and orthogonality the event will report correctly as signaled when used by other event API functionality.", "The application must ensure the command list and events were created on the same context.", "The application must **not** call this function from simultaneous threads with the same command list handle.", "The implementation of this function should be lock-free." @@ -45642,7 +46480,7 @@ "class": "$xEvent", "desc": "Signals a event from host.", "details": [ - "The duration of an event created from an event pool that was created using $X_EVENT_POOL_FLAG_KERNEL_TIMESTAMP flag is undefined. However, for consistency and orthogonality the event will report correctly as signaled when used by other event API functionality.", + "The duration of an event created from an event pool that was created using $X_EVENT_POOL_FLAG_KERNEL_TIMESTAMP or $X_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP flags is undefined. However, for consistency and orthogonality the event will report correctly as signaled when used by other event API functionality.", "The application may call this function from simultaneous threads.", "The implementation of this function should be lock-free." ], @@ -45934,7 +46772,7 @@ "class": "$xEvent", "desc": "Queries an event's timestamp value on the host.", "details": [ - "The application must ensure the event was created from an event pool that was created using $X_EVENT_POOL_FLAG_KERNEL_TIMESTAMP flag.", + "The application must ensure the event was created from an event pool that was created using $X_EVENT_POOL_FLAG_KERNEL_TIMESTAMP or $X_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP flag.", "The destination memory will be unmodified if the event has not been signaled.", "The application may call this function from simultaneous threads.", "The implementation of this function should be lock-free." @@ -46842,12 +47680,12 @@ "desc": "Image format ", "members": [ { - "desc": "[in] image format component layout", + "desc": "[in] image format component layout (e.g. N-component layouts and media formats)", "name": "layout", "type": "$x_image_format_layout_t" }, { - "desc": "[in] image format type. Media formats can't be used for $X_IMAGE_TYPE_BUFFER.", + "desc": "[in] image format type", "name": "type", "type": "$x_image_format_type_t" }, @@ -46898,7 +47736,7 @@ "type": "$x_image_flags_t" }, { - "desc": "[in] image type", + "desc": "[in] image type. Media format layouts are unsupported for $X_IMAGE_TYPE_BUFFER", "name": "type", "type": "$x_image_type_t" }, @@ -47771,7 +48609,126 @@ { "$X_RESULT_ERROR_INVALID_NULL_POINTER": [ "`nullptr == ptr`", - "`nullptr == pMemAllocProperties`" + "`nullptr == pMemAllocProperties`" + ] + } + ], + "type": "function" + }, + { + "class": "$xMem", + "decl": "static", + "desc": "Retrieves the base address and/or size of an allocation", + "details": [ + "The application may call this function from simultaneous threads." + ], + "hash": "972da021a01a0357817c10cdfccea16c42a3cca55a6c36436267aa45e7a55dab", + "name": "GetAddressRange", + "params": [ + { + "desc": "[in] handle of the context object", + "name": "hContext", + "type": "$x_context_handle_t" + }, + { + "desc": "[in] memory pointer to query", + "name": "ptr", + "type": "const void*" + }, + { + "desc": "[in,out][optional] base address of the allocation", + "name": "pBase", + "type": "void**" + }, + { + "desc": "[in,out][optional] size of the allocation", + "name": "pSize", + "type": "size_t*" + } + ], + "returns": [ + { + "$X_RESULT_SUCCESS": [] + }, + { + "$X_RESULT_ERROR_UNINITIALIZED": [] + }, + { + "$X_RESULT_ERROR_DEVICE_LOST": [] + }, + { + "$X_RESULT_ERROR_OUT_OF_HOST_MEMORY": [] + }, + { + "$X_RESULT_ERROR_OUT_OF_DEVICE_MEMORY": [] + }, + { + "$X_RESULT_ERROR_INVALID_NULL_HANDLE": [ + "`nullptr == hContext`" + ] + }, + { + "$X_RESULT_ERROR_INVALID_NULL_POINTER": [ + "`nullptr == ptr`" + ] + } + ], + "type": "function" + }, + { + "class": "$xMem", + "decl": "static", + "desc": "Creates an IPC memory handle for the specified allocation", + "details": [ + "Takes a pointer to a device memory allocation and creates an IPC memory handle for exporting it for use in another process.", + "The pointer must be base pointer of a device or host memory allocation; i.e. the value returned from $xMemAllocDevice or from $xMemAllocHost, respectively.", + "The application may call this function from simultaneous threads.", + "The implementation of this function must be thread-safe." + ], + "hash": "0c93fecc4e19c55c79ca9d1b7001f7c9fcdc783c6cb181c18cae4924ae0e7b4a", + "name": "GetIpcHandle", + "params": [ + { + "desc": "[in] handle of the context object", + "name": "hContext", + "type": "$x_context_handle_t" + }, + { + "desc": "[in] pointer to the device memory allocation", + "name": "ptr", + "type": "const void*" + }, + { + "desc": "[out] Returned IPC memory handle", + "name": "pIpcHandle", + "type": "$x_ipc_mem_handle_t*" + } + ], + "returns": [ + { + "$X_RESULT_SUCCESS": [] + }, + { + "$X_RESULT_ERROR_UNINITIALIZED": [] + }, + { + "$X_RESULT_ERROR_DEVICE_LOST": [] + }, + { + "$X_RESULT_ERROR_OUT_OF_HOST_MEMORY": [] + }, + { + "$X_RESULT_ERROR_OUT_OF_DEVICE_MEMORY": [] + }, + { + "$X_RESULT_ERROR_INVALID_NULL_HANDLE": [ + "`nullptr == hContext`" + ] + }, + { + "$X_RESULT_ERROR_INVALID_NULL_POINTER": [ + "`nullptr == ptr`", + "`nullptr == pIpcHandle`" ] } ], @@ -47780,12 +48737,15 @@ { "class": "$xMem", "decl": "static", - "desc": "Retrieves the base address and/or size of an allocation", + "desc": "Creates an IPC memory handle out of a file descriptor", "details": [ - "The application may call this function from simultaneous threads." + "Handle passed must be a valid file descriptor obtained with $x_external_memory_export_fd_t via $xMemGetAllocProperties.", + "Returned IPC handle may contain metadata in addition to the file descriptor.", + "The application may call this function from simultaneous threads.", + "The implementation of this function must be thread-safe." ], - "hash": "972da021a01a0357817c10cdfccea16c42a3cca55a6c36436267aa45e7a55dab", - "name": "GetAddressRange", + "hash": "85dd8fd011ef561b945d46995f774fa76385cef8b350475fb4fa35684277399e", + "name": "GetIpcHandleFromFileDescriptorExp", "params": [ { "desc": "[in] handle of the context object", @@ -47793,19 +48753,14 @@ "type": "$x_context_handle_t" }, { - "desc": "[in] memory pointer to query", - "name": "ptr", - "type": "const void*" - }, - { - "desc": "[in,out][optional] base address of the allocation", - "name": "pBase", - "type": "void**" + "desc": "[in] file descriptor", + "name": "handle", + "type": "uint64_t" }, { - "desc": "[in,out][optional] size of the allocation", - "name": "pSize", - "type": "size_t*" + "desc": "[out] Returned IPC memory handle", + "name": "pIpcHandle", + "type": "$x_ipc_mem_handle_t*" } ], "returns": [ @@ -47831,24 +48786,24 @@ }, { "$X_RESULT_ERROR_INVALID_NULL_POINTER": [ - "`nullptr == ptr`" + "`nullptr == pIpcHandle`" ] } ], - "type": "function" + "type": "function", + "version": "1.6" }, { "class": "$xMem", "decl": "static", - "desc": "Creates an IPC memory handle for the specified allocation", + "desc": "Gets the file descriptor contained in an IPC memory handle", "details": [ - "Takes a pointer to a device memory allocation and creates an IPC memory handle for exporting it for use in another process.", - "The pointer must be base pointer of a device or host memory allocation; i.e. the value returned from $xMemAllocDevice or from $xMemAllocHost, respectively.", + "IPC memory handle must be a valid handle obtained with $xMemGetIpcHandle.", "The application may call this function from simultaneous threads.", "The implementation of this function must be thread-safe." ], - "hash": "0c93fecc4e19c55c79ca9d1b7001f7c9fcdc783c6cb181c18cae4924ae0e7b4a", - "name": "GetIpcHandle", + "hash": "4f0cd196b792fa6c5010f1779f899fc5252608ccded499cc460199f47343f4b6", + "name": "GetFileDescriptorFromIpcHandleExp", "params": [ { "desc": "[in] handle of the context object", @@ -47856,14 +48811,14 @@ "type": "$x_context_handle_t" }, { - "desc": "[in] pointer to the device memory allocation", - "name": "ptr", - "type": "const void*" + "desc": "[in] IPC memory handle", + "name": "ipcHandle", + "type": "$x_ipc_mem_handle_t" }, { - "desc": "[out] Returned IPC memory handle", - "name": "pIpcHandle", - "type": "$x_ipc_mem_handle_t*" + "desc": "[out] Returned file descriptor", + "name": "pHandle", + "type": "uint64_t*" } ], "returns": [ @@ -47889,12 +48844,62 @@ }, { "$X_RESULT_ERROR_INVALID_NULL_POINTER": [ - "`nullptr == ptr`", - "`nullptr == pIpcHandle`" + "`nullptr == pHandle`" ] } ], - "type": "function" + "type": "function", + "version": "1.6" + }, + { + "class": "$xMem", + "decl": "static", + "desc": "Returns an IPC memory handle to the driver", + "details": [ + "This call may be used for IPC handles previously obtained with either $xMemGetIpcHandle or with $x_external_memory_export_fd_t via $xMemGetAllocProperties.\n", + "Upon call, driver may release any underlying resources associated with the IPC handle.\nFor instance, it may close the file descriptor contained in the IPC handle, if such type of handle is being used by the driver.\n", + "This call does not free the original allocation for which the IPC handle was created.", + "This function may **not** be called from simultaneous threads with the same IPC handle.", + "The implementation of this function should be lock-free." + ], + "hash": "34244e7493a2b2f9d15f3f02f77e55814209a257d38057e839b02653d59f6608", + "name": "PutIpcHandle", + "params": [ + { + "desc": "[in] handle of the context object", + "name": "hContext", + "type": "$x_context_handle_t" + }, + { + "desc": "[in] IPC memory handle", + "name": "handle", + "type": "$x_ipc_mem_handle_t" + } + ], + "returns": [ + { + "$X_RESULT_SUCCESS": [] + }, + { + "$X_RESULT_ERROR_UNINITIALIZED": [] + }, + { + "$X_RESULT_ERROR_DEVICE_LOST": [] + }, + { + "$X_RESULT_ERROR_OUT_OF_HOST_MEMORY": [] + }, + { + "$X_RESULT_ERROR_OUT_OF_DEVICE_MEMORY": [] + }, + { + "$X_RESULT_ERROR_INVALID_NULL_HANDLE": [ + "`nullptr == hContext`" + ] + } + ], + "type": "function", + "version": "1.6" }, { "class": "$xMem", @@ -48324,7 +49329,7 @@ "type": "const uint8_t*" }, { - "desc": "[in][optional] string containing compiler flags. Following options are supported.\n - \"-$x-opt-disable\"\n - Disable optimizations\n - \"-$x-opt-level\"\n - Specifies optimization level for compiler. Levels are implementation specific.\n - 0 is no optimizations (equivalent to -$x-opt-disable)\n - 1 is optimize minimally (may be the same as 2)\n - 2 is optimize more (default)\n - \"-$x-opt-greater-than-4GB-buffer-required\"\n - Use 64-bit offset calculations for buffers.\n - \"-$x-opt-large-register-file\"\n - Increase number of registers available to threads.\n - \"-$x-opt-has-buffer-offset-arg\"\n - Extend stateless to stateful optimization to more\n cases with the use of additional offset (e.g. 64-bit\n pointer to binding table with 32-bit offset).\n - \"-g\"\n - Include debugging information.\n", + "desc": "[in][optional] string containing one or more (comma-separated) compiler flags. If unsupported, flag is ignored with a warning.\n - \"-$x-opt-disable\"\n - Disable optimizations\n - \"-$x-opt-level\"\n - Specifies optimization level for compiler. Levels are implementation specific.\n - 0 is no optimizations (equivalent to -$x-opt-disable)\n - 1 is optimize minimally (may be the same as 2)\n - 2 is optimize more (default)\n - \"-$x-opt-greater-than-4GB-buffer-required\"\n - Use 64-bit offset calculations for buffers.\n - \"-$x-opt-large-register-file\"\n - Increase number of registers available to threads.\n - \"-$x-opt-has-buffer-offset-arg\"\n - Extend stateless to stateful optimization to more\n cases with the use of additional offset (e.g. 64-bit\n pointer to binding table with 32-bit offset).\n - \"-g\"\n - Include debugging information.\n", "init": "nullptr", "name": "pBuildFlags", "type": "const char*" @@ -55695,6 +56700,230 @@ "version": "1.5" } ] + }, + { + "header": { + "desc": "Intel $OneApi Level-Zero Extension for supporting the querying of synchronized event timestamps.", + "ordinal": 1600, + "type": "header", + "version": "1.6" + }, + "name": "eventQueryKernelTimestamps", + "objects": [ + { + "desc": "Event Query Kernel Timestamps Extension Name", + "name": "$X_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_NAME", + "type": "macro", + "value": "\"$X_extension_event_query_kernel_timestamps\"", + "version": "1.6" + }, + { + "desc": "Event Query Kernel Timestamps Extension Version(s)", + "etors": [ + { + "desc": "version 1.0", + "name": "$X_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_VERSION_1_0", + "value": "$X_MAKE_VERSION( 1, 0 )" + }, + { + "desc": "latest known version", + "name": "$X_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_VERSION_CURRENT", + "value": "$X_MAKE_VERSION( 1, 0 )" + } + ], + "name": "$x_event_query_kernel_timestamps_ext_version_t", + "type": "enum", + "version": "1.6" + }, + { + "class": "$xEvent", + "desc": "Event query kernel timestamps flags", + "etors": [ + { + "desc": "Kernel timestamp results", + "name": "$X_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_FLAG_KERNEL", + "value": "$X_BIT(0)" + }, + { + "desc": "Device event timestamps synchronized to the host time domain", + "name": "$X_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_FLAG_SYNCHRONIZED", + "value": "$X_BIT(1)" + } + ], + "name": "$x_event_query_kernel_timestamps_ext_flags_t", + "type": "enum", + "version": "1.6" + }, + { + "base": "$x_base_properties_t", + "desc": "Event query kernel timestamps properties", + "details": [ + "This structure may be returned from $xDeviceGetProperties, via `pNext` member of $x_device_properties_t." + ], + "members": [ + { + "desc": "[in] type of this structure", + "init": "$X_STRUCTURE_TYPE_EVENT_QUERY_KERNEL_TIMESTAMPS_EXT_PROPERTIES", + "name": "stype", + "type": "$x_structure_type_t" + }, + { + "desc": "[in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains sType and pNext).", + "init": "nullptr", + "name": "pNext", + "type": "void*" + }, + { + "desc": "[out] 0 or some combination of $x_event_query_kernel_timestamps_ext_flag_t flags", + "name": "flags", + "type": "$x_event_query_kernel_timestamps_ext_flags_t" + } + ], + "name": "$x_event_query_kernel_timestamps_ext_properties_t", + "type": "struct", + "version": "1.6" + }, + { + "class": "$xEvent", + "desc": "Kernel timestamp clock data synchronized to the host time domain", + "members": [ + { + "desc": "[out] synchronized clock at start of kernel execution", + "name": "kernelStart", + "type": "uint64_t" + }, + { + "desc": "[out] synchronized clock at end of kernel execution", + "name": "kernelEnd", + "type": "uint64_t" + } + ], + "name": "$x_synchronized_timestamp_data_ext_t", + "type": "struct", + "version": "1.6" + }, + { + "class": "$xEvent", + "desc": "Synchronized kernel timestamp result", + "members": [ + { + "desc": "[out] wall-clock data", + "name": "global", + "type": "$x_synchronized_timestamp_data_ext_t" + }, + { + "desc": "[out] context-active data; only includes clocks while device context was actively executing.", + "name": "context", + "type": "$x_synchronized_timestamp_data_ext_t" + } + ], + "name": "$x_synchronized_timestamp_result_ext_t", + "type": "struct", + "version": "1.6" + }, + { + "base": "$x_base_properties_t", + "desc": "Event query kernel timestamps results properties", + "members": [ + { + "desc": "[in] type of this structure", + "init": "$X_STRUCTURE_TYPE_EVENT_QUERY_KERNEL_TIMESTAMPS_RESULTS_EXT_PROPERTIES", + "name": "stype", + "type": "$x_structure_type_t" + }, + { + "desc": "[in,out][optional] must be null or a pointer to an extension-specific structure (i.e. contains sType and pNext).", + "init": "nullptr", + "name": "pNext", + "type": "void*" + }, + { + "desc": "[in,out][optional][range(0, *pCount)] pointer to destination buffer of kernel timestamp results", + "init": "nullptr", + "name": "pKernelTimestampsBuffer", + "type": "$x_kernel_timestamp_result_t*" + }, + { + "desc": "[in,out][optional][range(0, *pCount)] pointer to destination buffer of synchronized timestamp results", + "init": "nullptr", + "name": "pSynchronizedTimestampsBuffer", + "type": "$x_synchronized_timestamp_result_ext_t*" + } + ], + "name": "$x_event_query_kernel_timestamps_results_ext_properties_t", + "type": "struct", + "version": "1.6" + }, + { + "class": "$xEvent", + "desc": "Query an event's timestamp value on the host, with domain preference.", + "details": [ + "For collecting *only* kernel timestamps, the application must ensure the event was created from an event pool that was created using $X_EVENT_POOL_FLAG_KERNEL_TIMESTAMP flag.", + "For collecting synchronized timestamps, the application must ensure the event was created from an event pool that was created using $X_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP flag. Kernel timestamps are also available from this type of event pool, but there is a performance cost.", + "The destination memory will be unmodified if the event has not been signaled.", + "The application may call this function from simultaneous threads.", + "The implementation of this function must be thread-safe.", + "The implementation must support $X_extension_event_query_kernel_timestamps.", + "The implementation must return all timestamps for the specified event and device pair.", + "The implementation must return all timestamps for all sub-devices when device handle is parent device.", + "The implementation may return all timestamps for sub-devices when device handle is sub-device or may return 0 for count." + ], + "hash": "1fd7be75405b56820b9d681d430d712ad8c789c74a5cd4e3332d20245e9694c0", + "name": "QueryKernelTimestampsExt", + "params": [ + { + "desc": "[in] handle of the event", + "name": "hEvent", + "type": "$x_event_handle_t" + }, + { + "desc": "[in] handle of the device to query", + "name": "hDevice", + "type": "$x_device_handle_t" + }, + { + "desc": "[in,out] pointer to the number of event packets available.\n - This value is implementation specific.\n - if `*pCount` is zero, then the driver shall update the value with the total number of event packets available.\n - if `*pCount` is greater than the number of event packets available, the driver shall update the value with the correct value.\n - Buffer(s) for query results must be sized by the application to accommodate a minimum of `*pCount` elements.\n", + "name": "pCount", + "type": "uint32_t*" + }, + { + "desc": "[in][optional] pointer to event query properties structure(s).\n - This parameter may be null when `*pCount` is zero.\n - if `*pCount` is less than the number of event packets available, the driver may only update `*pCount` elements, starting at element zero.\n - if `*pCount` is greater than the number of event packets available, the driver may only update the valid elements.\n", + "name": "pResults", + "type": "$x_event_query_kernel_timestamps_results_ext_properties_t*" + } + ], + "returns": [ + { + "$X_RESULT_SUCCESS": [] + }, + { + "$X_RESULT_ERROR_UNINITIALIZED": [] + }, + { + "$X_RESULT_ERROR_DEVICE_LOST": [] + }, + { + "$X_RESULT_ERROR_OUT_OF_HOST_MEMORY": [] + }, + { + "$X_RESULT_ERROR_OUT_OF_DEVICE_MEMORY": [] + }, + { + "$X_RESULT_ERROR_INVALID_NULL_HANDLE": [ + "`nullptr == hEvent`", + "`nullptr == hDevice`" + ] + }, + { + "$X_RESULT_ERROR_INVALID_NULL_POINTER": [ + "`nullptr == pCount`" + ] + } + ], + "type": "function", + "version": "1.6" + } + ] } ], [ @@ -65627,6 +66856,12 @@ "desc": "Local Memory Domain.", "name": "$S_FREQ_DOMAIN_MEMORY", "value": "1" + }, + { + "desc": "GPU Media Domain.", + "name": "$S_FREQ_DOMAIN_MEDIA", + "value": "2", + "version": "1.6" } ], "name": "$s_freq_domain_t", diff --git a/scripts/templates/libddi.cpp.mako b/scripts/templates/libddi.cpp.mako index 3a4cf761..ae33de76 100644 --- a/scripts/templates/libddi.cpp.mako +++ b/scripts/templates/libddi.cpp.mako @@ -35,7 +35,7 @@ namespace ${x}_lib { auto getTable = reinterpret_cast<${tbl['pfn']}>( GET_FUNCTION_PTR(loader, "${tbl['export']['name']}") ); - result = getTable( ${X}_API_VERSION_1_5, &${n}DdiTable.${tbl['name']} ); + result = getTable( ${X}_API_VERSION_CURRENT, &${n}DdiTable.${tbl['name']} ); } %endfor @@ -49,7 +49,7 @@ namespace ${x}_lib %for tbl in th.get_pfntables(specs, meta, n, tags): if( ${X}_RESULT_SUCCESS == result ) { - result = ${tbl['export']['name']}( ${X}_API_VERSION_1_5, &${n}DdiTable.${tbl['name']} ); + result = ${tbl['export']['name']}( ${X}_API_VERSION_CURRENT, &${n}DdiTable.${tbl['name']} ); } %endfor diff --git a/source/drivers/null/ze_null.h b/source/drivers/null/ze_null.h index d15570d8..b603e2ad 100644 --- a/source/drivers/null/ze_null.h +++ b/source/drivers/null/ze_null.h @@ -21,7 +21,7 @@ namespace driver class __zedlllocal context_t { public: - ze_api_version_t version = ZE_API_VERSION_1_5; + ze_api_version_t version = ZE_API_VERSION_CURRENT; ze_dditable_t zeDdiTable = {}; zet_dditable_t zetDdiTable = {}; diff --git a/source/drivers/null/ze_nullddi.cpp b/source/drivers/null/ze_nullddi.cpp index f0bf4c63..5bccc7c1 100644 --- a/source/drivers/null/ze_nullddi.cpp +++ b/source/drivers/null/ze_nullddi.cpp @@ -198,6 +198,31 @@ namespace driver return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDriverGetLastErrorDescription + __zedlllocal ze_result_t ZE_APICALL + zeDriverGetLastErrorDescription( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + const char** ppString ///< [in,out] pointer to a null-terminated array of characters describing + ///< cause of error. + ) + { + 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 pfnGetLastErrorDescription = context.zeDdiTable.Driver.pfnGetLastErrorDescription; + if( nullptr != pfnGetLastErrorDescription ) + { + result = pfnGetLastErrorDescription( hDriver, ppString ); + } + else + { + // generic implementation + } + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeDeviceGet __zedlllocal ze_result_t ZE_APICALL @@ -985,6 +1010,36 @@ namespace driver return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListHostSynchronize + __zedlllocal ze_result_t ZE_APICALL + zeCommandListHostSynchronize( + ze_command_list_handle_t hCommandList, ///< [in] handle of the immediate command list + uint64_t timeout ///< [in] if non-zero, then indicates the maximum time (in nanoseconds) to + ///< yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; + ///< if zero, then immediately returns the status of the immediate command list; + ///< if UINT64_MAX, then function will not return until complete or device + ///< is lost. + ///< Due to external dependencies, timeout may be rounded to the closest + ///< value allowed by the accuracy of those dependencies. + ) + { + 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 pfnHostSynchronize = context.zeDdiTable.CommandList.pfnHostSynchronize; + if( nullptr != pfnHostSynchronize ) + { + result = pfnHostSynchronize( hCommandList, timeout ); + } + else + { + // generic implementation + } + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeCommandListAppendBarrier __zedlllocal ze_result_t ZE_APICALL @@ -1511,6 +1566,31 @@ namespace driver return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventPoolPutIpcHandle + __zedlllocal ze_result_t ZE_APICALL + zeEventPoolPutIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object associated with the IPC event pool + ///< handle + ze_ipc_event_pool_handle_t hIpc ///< [in] IPC event pool handle + ) + { + 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 pfnPutIpcHandle = context.zeDdiTable.EventPool.pfnPutIpcHandle; + if( nullptr != pfnPutIpcHandle ) + { + result = pfnPutIpcHandle( hContext, hIpc ); + } + else + { + // generic implementation + } + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeEventPoolOpenIpcHandle __zedlllocal ze_result_t ZE_APICALL @@ -2192,6 +2272,80 @@ namespace driver return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemGetIpcHandleFromFileDescriptorExp + __zedlllocal ze_result_t ZE_APICALL + zeMemGetIpcHandleFromFileDescriptorExp( + ze_context_handle_t hContext, ///< [in] handle of the context object + uint64_t handle, ///< [in] file descriptor + ze_ipc_mem_handle_t* pIpcHandle ///< [out] Returned IPC memory handle + ) + { + 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 pfnGetIpcHandleFromFileDescriptorExp = context.zeDdiTable.MemExp.pfnGetIpcHandleFromFileDescriptorExp; + if( nullptr != pfnGetIpcHandleFromFileDescriptorExp ) + { + result = pfnGetIpcHandleFromFileDescriptorExp( hContext, handle, pIpcHandle ); + } + else + { + // generic implementation + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemGetFileDescriptorFromIpcHandleExp + __zedlllocal ze_result_t ZE_APICALL + zeMemGetFileDescriptorFromIpcHandleExp( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_ipc_mem_handle_t ipcHandle, ///< [in] IPC memory handle + uint64_t* pHandle ///< [out] Returned file descriptor + ) + { + 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 pfnGetFileDescriptorFromIpcHandleExp = context.zeDdiTable.MemExp.pfnGetFileDescriptorFromIpcHandleExp; + if( nullptr != pfnGetFileDescriptorFromIpcHandleExp ) + { + result = pfnGetFileDescriptorFromIpcHandleExp( hContext, ipcHandle, pHandle ); + } + else + { + // generic implementation + } + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemPutIpcHandle + __zedlllocal ze_result_t ZE_APICALL + zeMemPutIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_ipc_mem_handle_t handle ///< [in] IPC memory handle + ) + { + 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 pfnPutIpcHandle = context.zeDdiTable.Mem.pfnPutIpcHandle; + if( nullptr != pfnPutIpcHandle ) + { + result = pfnPutIpcHandle( hContext, handle ); + } + else + { + // generic implementation + } + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeMemOpenIpcHandle __zedlllocal ze_result_t ZE_APICALL @@ -3969,6 +4123,44 @@ namespace driver return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventQueryKernelTimestampsExt + __zedlllocal ze_result_t ZE_APICALL + zeEventQueryKernelTimestampsExt( + ze_event_handle_t hEvent, ///< [in] handle of the event + ze_device_handle_t hDevice, ///< [in] handle of the device to query + uint32_t* pCount, ///< [in,out] pointer to the number of event packets available. + ///< - This value is implementation specific. + ///< - if `*pCount` is zero, then the driver shall update the value with + ///< the total number of event packets available. + ///< - if `*pCount` is greater than the number of event packets + ///< available, the driver shall update the value with the correct value. + ///< - Buffer(s) for query results must be sized by the application to + ///< accommodate a minimum of `*pCount` elements. + ze_event_query_kernel_timestamps_results_ext_properties_t* pResults ///< [in][optional] pointer to event query properties structure(s). + ///< - This parameter may be null when `*pCount` is zero. + ///< - if `*pCount` is less than the number of event packets available, + ///< the driver may only update `*pCount` elements, starting at element zero. + ///< - if `*pCount` is greater than the number of event packets + ///< available, the driver may only update the valid elements. + ) + { + 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 pfnQueryKernelTimestampsExt = context.zeDdiTable.Event.pfnQueryKernelTimestampsExt; + if( nullptr != pfnQueryKernelTimestampsExt ) + { + result = pfnQueryKernelTimestampsExt( hEvent, hDevice, pCount, pResults ); + } + else + { + // generic implementation + } + + return result; + } + } // namespace driver #if defined(__cplusplus) @@ -4036,6 +4228,8 @@ zeGetDriverProcAddrTable( pDdiTable->pfnGetExtensionFunctionAddress = driver::zeDriverGetExtensionFunctionAddress; + pDdiTable->pfnGetLastErrorDescription = driver::zeDriverGetLastErrorDescription; + return result; } @@ -4281,6 +4475,8 @@ zeGetCommandListProcAddrTable( pDdiTable->pfnAppendImageCopyFromMemoryExt = driver::zeCommandListAppendImageCopyFromMemoryExt; + pDdiTable->pfnHostSynchronize = driver::zeCommandListHostSynchronize; + return result; } @@ -4320,6 +4516,8 @@ zeGetEventProcAddrTable( pDdiTable->pfnQueryKernelTimestamp = driver::zeEventQueryKernelTimestamp; + pDdiTable->pfnQueryKernelTimestampsExt = driver::zeEventQueryKernelTimestampsExt; + return result; } @@ -4382,6 +4580,8 @@ zeGetEventPoolProcAddrTable( pDdiTable->pfnCloseIpcHandle = driver::zeEventPoolCloseIpcHandle; + pDdiTable->pfnPutIpcHandle = driver::zeEventPoolPutIpcHandle; + return result; } @@ -4604,6 +4804,37 @@ zeGetMemProcAddrTable( pDdiTable->pfnFreeExt = driver::zeMemFreeExt; + pDdiTable->pfnPutIpcHandle = driver::zeMemPutIpcHandle; + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's MemExp table +/// with current process' addresses +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION +ZE_DLLEXPORT ze_result_t ZE_APICALL +zeGetMemExpProcAddrTable( + ze_api_version_t version, ///< [in] API version requested + ze_mem_exp_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers + ) +{ + if( nullptr == pDdiTable ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( driver::context.version < version ) + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + + ze_result_t result = ZE_RESULT_SUCCESS; + + pDdiTable->pfnGetIpcHandleFromFileDescriptorExp = driver::zeMemGetIpcHandleFromFileDescriptorExp; + + pDdiTable->pfnGetFileDescriptorFromIpcHandleExp = driver::zeMemGetFileDescriptorFromIpcHandleExp; + return result; } diff --git a/source/layers/tracing/ze_tracing_cb_structs.h b/source/layers/tracing/ze_tracing_cb_structs.h index 9d613ed4..7c756bb8 100644 --- a/source/layers/tracing/ze_tracing_cb_structs.h +++ b/source/layers/tracing/ze_tracing_cb_structs.h @@ -35,6 +35,7 @@ typedef struct _zel_driver_callbacks_t ze_pfnDriverGetIpcPropertiesCb_t pfnGetIpcPropertiesCb; ze_pfnDriverGetExtensionPropertiesCb_t pfnGetExtensionPropertiesCb; ze_pfnDriverGetExtensionFunctionAddressCb_t pfnGetExtensionFunctionAddressCb; + ze_pfnDriverGetLastErrorDescriptionCb_t pfnGetLastErrorDescriptionCb; } zel_driver_callbacks_t; /////////////////////////////////////////////////////////////////////////////// @@ -119,6 +120,7 @@ typedef struct _zel_command_list_callbacks_t ze_pfnCommandListAppendLaunchMultipleKernelsIndirectCb_t pfnAppendLaunchMultipleKernelsIndirectCb; ze_pfnCommandListAppendImageCopyToMemoryExtCb_t pfnAppendImageCopyToMemoryExtCb; ze_pfnCommandListAppendImageCopyFromMemoryExtCb_t pfnAppendImageCopyFromMemoryExtCb; + ze_pfnCommandListHostSynchronizeCb_t pfnHostSynchronizeCb; } zel_command_list_callbacks_t; /////////////////////////////////////////////////////////////////////////////// @@ -133,6 +135,7 @@ typedef struct _zel_event_callbacks_t ze_pfnEventHostResetCb_t pfnHostResetCb; ze_pfnEventQueryKernelTimestampCb_t pfnQueryKernelTimestampCb; ze_pfnEventQueryTimestampsExpCb_t pfnQueryTimestampsExpCb; + ze_pfnEventQueryKernelTimestampsExtCb_t pfnQueryKernelTimestampsExtCb; } zel_event_callbacks_t; /////////////////////////////////////////////////////////////////////////////// @@ -144,6 +147,7 @@ typedef struct _zel_event_pool_callbacks_t ze_pfnEventPoolGetIpcHandleCb_t pfnGetIpcHandleCb; ze_pfnEventPoolOpenIpcHandleCb_t pfnOpenIpcHandleCb; ze_pfnEventPoolCloseIpcHandleCb_t pfnCloseIpcHandleCb; + ze_pfnEventPoolPutIpcHandleCb_t pfnPutIpcHandleCb; } zel_event_pool_callbacks_t; /////////////////////////////////////////////////////////////////////////////// @@ -204,6 +208,9 @@ typedef struct _zel_mem_callbacks_t ze_pfnMemOpenIpcHandleCb_t pfnOpenIpcHandleCb; ze_pfnMemCloseIpcHandleCb_t pfnCloseIpcHandleCb; ze_pfnMemFreeExtCb_t pfnFreeExtCb; + ze_pfnMemGetIpcHandleFromFileDescriptorExpCb_t pfnGetIpcHandleFromFileDescriptorExpCb; + ze_pfnMemGetFileDescriptorFromIpcHandleExpCb_t pfnGetFileDescriptorFromIpcHandleExpCb; + ze_pfnMemPutIpcHandleCb_t pfnPutIpcHandleCb; } zel_mem_callbacks_t; /////////////////////////////////////////////////////////////////////////////// diff --git a/source/layers/tracing/ze_tracing_layer.h b/source/layers/tracing/ze_tracing_layer.h index be6f5599..245a8816 100644 --- a/source/layers/tracing/ze_tracing_layer.h +++ b/source/layers/tracing/ze_tracing_layer.h @@ -17,7 +17,7 @@ namespace tracing_layer class __zedlllocal context_t { public: - ze_api_version_t version = ZE_API_VERSION_1_5; + ze_api_version_t version = ZE_API_VERSION_CURRENT; ze_dditable_t zeDdiTable = {}; diff --git a/source/layers/tracing/ze_tracing_register_cb.cpp b/source/layers/tracing/ze_tracing_register_cb.cpp index 31d3d989..5fcbe6d1 100644 --- a/source/layers/tracing/ze_tracing_register_cb.cpp +++ b/source/layers/tracing/ze_tracing_register_cb.cpp @@ -131,6 +131,22 @@ zelTracerDriverGetExtensionFunctionAddressRegisterCallback( } +ZE_DLLEXPORT ze_result_t ZE_APICALL +zelTracerDriverGetLastErrorDescriptionRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnDriverGetLastErrorDescriptionCb_t pfnGetLastErrorDescriptionCb + ) { + + ze_result_t result; + auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result); + if (result == ZE_RESULT_SUCCESS) + cbs.Driver.pfnGetLastErrorDescriptionCb = pfnGetLastErrorDescriptionCb; + + return result; +} + + ZE_DLLEXPORT ze_result_t ZE_APICALL zelTracerDeviceGetRegisterCallback( zel_tracer_handle_t hTracer, @@ -595,6 +611,22 @@ zelTracerCommandListAppendWriteGlobalTimestampRegisterCallback( } +ZE_DLLEXPORT ze_result_t ZE_APICALL +zelTracerCommandListHostSynchronizeRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListHostSynchronizeCb_t pfnHostSynchronizeCb + ) { + + ze_result_t result; + auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result); + if (result == ZE_RESULT_SUCCESS) + cbs.CommandList.pfnHostSynchronizeCb = pfnHostSynchronizeCb; + + return result; +} + + ZE_DLLEXPORT ze_result_t ZE_APICALL zelTracerCommandListAppendBarrierRegisterCallback( zel_tracer_handle_t hTracer, @@ -883,6 +915,22 @@ zelTracerEventPoolGetIpcHandleRegisterCallback( } +ZE_DLLEXPORT ze_result_t ZE_APICALL +zelTracerEventPoolPutIpcHandleRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnEventPoolPutIpcHandleCb_t pfnPutIpcHandleCb + ) { + + ze_result_t result; + auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result); + if (result == ZE_RESULT_SUCCESS) + cbs.EventPool.pfnPutIpcHandleCb = pfnPutIpcHandleCb; + + return result; +} + + ZE_DLLEXPORT ze_result_t ZE_APICALL zelTracerEventPoolOpenIpcHandleRegisterCallback( zel_tracer_handle_t hTracer, @@ -1299,6 +1347,54 @@ zelTracerMemGetIpcHandleRegisterCallback( } +ZE_DLLEXPORT ze_result_t ZE_APICALL +zelTracerMemGetIpcHandleFromFileDescriptorExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnMemGetIpcHandleFromFileDescriptorExpCb_t pfnGetIpcHandleFromFileDescriptorExpCb + ) { + + ze_result_t result; + auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result); + if (result == ZE_RESULT_SUCCESS) + cbs.Mem.pfnGetIpcHandleFromFileDescriptorExpCb = pfnGetIpcHandleFromFileDescriptorExpCb; + + return result; +} + + +ZE_DLLEXPORT ze_result_t ZE_APICALL +zelTracerMemGetFileDescriptorFromIpcHandleExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnMemGetFileDescriptorFromIpcHandleExpCb_t pfnGetFileDescriptorFromIpcHandleExpCb + ) { + + ze_result_t result; + auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result); + if (result == ZE_RESULT_SUCCESS) + cbs.Mem.pfnGetFileDescriptorFromIpcHandleExpCb = pfnGetFileDescriptorFromIpcHandleExpCb; + + return result; +} + + +ZE_DLLEXPORT ze_result_t ZE_APICALL +zelTracerMemPutIpcHandleRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnMemPutIpcHandleCb_t pfnPutIpcHandleCb + ) { + + ze_result_t result; + auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result); + if (result == ZE_RESULT_SUCCESS) + cbs.Mem.pfnPutIpcHandleCb = pfnPutIpcHandleCb; + + return result; +} + + ZE_DLLEXPORT ze_result_t ZE_APICALL zelTracerMemOpenIpcHandleRegisterCallback( zel_tracer_handle_t hTracer, @@ -2339,5 +2435,21 @@ zelTracerFabricEdgeGetPropertiesExpRegisterCallback( } +ZE_DLLEXPORT ze_result_t ZE_APICALL +zelTracerEventQueryKernelTimestampsExtRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnEventQueryKernelTimestampsExtCb_t pfnQueryKernelTimestampsExtCb + ) { + + ze_result_t result; + auto& cbs = tracing_layer::APITracer::fromHandle(hTracer)->getProEpilogues(callback_type, result); + if (result == ZE_RESULT_SUCCESS) + cbs.Event.pfnQueryKernelTimestampsExtCb = pfnQueryKernelTimestampsExtCb; + + return result; +} + + } //extern C \ No newline at end of file diff --git a/source/layers/tracing/ze_trcddi.cpp b/source/layers/tracing/ze_trcddi.cpp index 438bb606..990e1b8c 100644 --- a/source/layers/tracing/ze_trcddi.cpp +++ b/source/layers/tracing/ze_trcddi.cpp @@ -276,6 +276,42 @@ namespace tracing_layer *tracerParams.pppFunctionAddress); } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDriverGetLastErrorDescription + __zedlllocal ze_result_t ZE_APICALL + zeDriverGetLastErrorDescription( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + const char** ppString ///< [in,out] pointer to a null-terminated array of characters describing + ///< cause of error. + ) + { + auto pfnGetLastErrorDescription = context.zeDdiTable.Driver.pfnGetLastErrorDescription; + + if( nullptr == pfnGetLastErrorDescription) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.Driver.pfnGetLastErrorDescription, hDriver, ppString); + + // capture parameters + ze_driver_get_last_error_description_params_t tracerParams = { + &hDriver, + &ppString + }; + + tracing_layer::APITracerCallbackDataImp apiCallbackData; + + ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnDriverGetLastErrorDescriptionCb_t, Driver, pfnGetLastErrorDescriptionCb); + + + return tracing_layer::APITracerWrapperImp(context.zeDdiTable.Driver.pfnGetLastErrorDescription, + &tracerParams, + apiCallbackData.apiOrdinal, + apiCallbackData.prologCallbacks, + apiCallbackData.epilogCallbacks, + *tracerParams.phDriver, + *tracerParams.pppString); + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeDeviceGet __zedlllocal ze_result_t ZE_APICALL @@ -1395,6 +1431,47 @@ namespace tracing_layer *tracerParams.pphWaitEvents); } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListHostSynchronize + __zedlllocal ze_result_t ZE_APICALL + zeCommandListHostSynchronize( + ze_command_list_handle_t hCommandList, ///< [in] handle of the immediate command list + uint64_t timeout ///< [in] if non-zero, then indicates the maximum time (in nanoseconds) to + ///< yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; + ///< if zero, then immediately returns the status of the immediate command list; + ///< if UINT64_MAX, then function will not return until complete or device + ///< is lost. + ///< Due to external dependencies, timeout may be rounded to the closest + ///< value allowed by the accuracy of those dependencies. + ) + { + auto pfnHostSynchronize = context.zeDdiTable.CommandList.pfnHostSynchronize; + + if( nullptr == pfnHostSynchronize) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.CommandList.pfnHostSynchronize, hCommandList, timeout); + + // capture parameters + ze_command_list_host_synchronize_params_t tracerParams = { + &hCommandList, + &timeout + }; + + tracing_layer::APITracerCallbackDataImp apiCallbackData; + + ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnCommandListHostSynchronizeCb_t, CommandList, pfnHostSynchronizeCb); + + + return tracing_layer::APITracerWrapperImp(context.zeDdiTable.CommandList.pfnHostSynchronize, + &tracerParams, + apiCallbackData.apiOrdinal, + apiCallbackData.prologCallbacks, + apiCallbackData.epilogCallbacks, + *tracerParams.phCommandList, + *tracerParams.ptimeout); + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeCommandListAppendBarrier __zedlllocal ze_result_t ZE_APICALL @@ -2233,6 +2310,42 @@ namespace tracing_layer *tracerParams.pphIpc); } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventPoolPutIpcHandle + __zedlllocal ze_result_t ZE_APICALL + zeEventPoolPutIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object associated with the IPC event pool + ///< handle + ze_ipc_event_pool_handle_t hIpc ///< [in] IPC event pool handle + ) + { + auto pfnPutIpcHandle = context.zeDdiTable.EventPool.pfnPutIpcHandle; + + if( nullptr == pfnPutIpcHandle) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.EventPool.pfnPutIpcHandle, hContext, hIpc); + + // capture parameters + ze_event_pool_put_ipc_handle_params_t tracerParams = { + &hContext, + &hIpc + }; + + tracing_layer::APITracerCallbackDataImp apiCallbackData; + + ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnEventPoolPutIpcHandleCb_t, EventPool, pfnPutIpcHandleCb); + + + return tracing_layer::APITracerWrapperImp(context.zeDdiTable.EventPool.pfnPutIpcHandle, + &tracerParams, + apiCallbackData.apiOrdinal, + apiCallbackData.prologCallbacks, + apiCallbackData.epilogCallbacks, + *tracerParams.phContext, + *tracerParams.phIpc); + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeEventPoolOpenIpcHandle __zedlllocal ze_result_t ZE_APICALL @@ -3231,6 +3344,117 @@ namespace tracing_layer *tracerParams.ppIpcHandle); } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemGetIpcHandleFromFileDescriptorExp + __zedlllocal ze_result_t ZE_APICALL + zeMemGetIpcHandleFromFileDescriptorExp( + ze_context_handle_t hContext, ///< [in] handle of the context object + uint64_t handle, ///< [in] file descriptor + ze_ipc_mem_handle_t* pIpcHandle ///< [out] Returned IPC memory handle + ) + { + auto pfnGetIpcHandleFromFileDescriptorExp = context.zeDdiTable.MemExp.pfnGetIpcHandleFromFileDescriptorExp; + + if( nullptr == pfnGetIpcHandleFromFileDescriptorExp) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.MemExp.pfnGetIpcHandleFromFileDescriptorExp, hContext, handle, pIpcHandle); + + // capture parameters + ze_mem_get_ipc_handle_from_file_descriptor_exp_params_t tracerParams = { + &hContext, + &handle, + &pIpcHandle + }; + + tracing_layer::APITracerCallbackDataImp apiCallbackData; + + ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnMemGetIpcHandleFromFileDescriptorExpCb_t, Mem, pfnGetIpcHandleFromFileDescriptorExpCb); + + + return tracing_layer::APITracerWrapperImp(context.zeDdiTable.MemExp.pfnGetIpcHandleFromFileDescriptorExp, + &tracerParams, + apiCallbackData.apiOrdinal, + apiCallbackData.prologCallbacks, + apiCallbackData.epilogCallbacks, + *tracerParams.phContext, + *tracerParams.phandle, + *tracerParams.ppIpcHandle); + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemGetFileDescriptorFromIpcHandleExp + __zedlllocal ze_result_t ZE_APICALL + zeMemGetFileDescriptorFromIpcHandleExp( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_ipc_mem_handle_t ipcHandle, ///< [in] IPC memory handle + uint64_t* pHandle ///< [out] Returned file descriptor + ) + { + auto pfnGetFileDescriptorFromIpcHandleExp = context.zeDdiTable.MemExp.pfnGetFileDescriptorFromIpcHandleExp; + + if( nullptr == pfnGetFileDescriptorFromIpcHandleExp) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.MemExp.pfnGetFileDescriptorFromIpcHandleExp, hContext, ipcHandle, pHandle); + + // capture parameters + ze_mem_get_file_descriptor_from_ipc_handle_exp_params_t tracerParams = { + &hContext, + &ipcHandle, + &pHandle + }; + + tracing_layer::APITracerCallbackDataImp apiCallbackData; + + ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnMemGetFileDescriptorFromIpcHandleExpCb_t, Mem, pfnGetFileDescriptorFromIpcHandleExpCb); + + + return tracing_layer::APITracerWrapperImp(context.zeDdiTable.MemExp.pfnGetFileDescriptorFromIpcHandleExp, + &tracerParams, + apiCallbackData.apiOrdinal, + apiCallbackData.prologCallbacks, + apiCallbackData.epilogCallbacks, + *tracerParams.phContext, + *tracerParams.pipcHandle, + *tracerParams.ppHandle); + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemPutIpcHandle + __zedlllocal ze_result_t ZE_APICALL + zeMemPutIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_ipc_mem_handle_t handle ///< [in] IPC memory handle + ) + { + auto pfnPutIpcHandle = context.zeDdiTable.Mem.pfnPutIpcHandle; + + if( nullptr == pfnPutIpcHandle) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.Mem.pfnPutIpcHandle, hContext, handle); + + // capture parameters + ze_mem_put_ipc_handle_params_t tracerParams = { + &hContext, + &handle + }; + + tracing_layer::APITracerCallbackDataImp apiCallbackData; + + ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnMemPutIpcHandleCb_t, Mem, pfnPutIpcHandleCb); + + + return tracing_layer::APITracerWrapperImp(context.zeDdiTable.Mem.pfnPutIpcHandle, + &tracerParams, + apiCallbackData.apiOrdinal, + apiCallbackData.prologCallbacks, + apiCallbackData.epilogCallbacks, + *tracerParams.phContext, + *tracerParams.phandle); + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeMemOpenIpcHandle __zedlllocal ze_result_t ZE_APICALL @@ -5883,6 +6107,59 @@ namespace tracing_layer *tracerParams.ppEdgeProperties); } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventQueryKernelTimestampsExt + __zedlllocal ze_result_t ZE_APICALL + zeEventQueryKernelTimestampsExt( + ze_event_handle_t hEvent, ///< [in] handle of the event + ze_device_handle_t hDevice, ///< [in] handle of the device to query + uint32_t* pCount, ///< [in,out] pointer to the number of event packets available. + ///< - This value is implementation specific. + ///< - if `*pCount` is zero, then the driver shall update the value with + ///< the total number of event packets available. + ///< - if `*pCount` is greater than the number of event packets + ///< available, the driver shall update the value with the correct value. + ///< - Buffer(s) for query results must be sized by the application to + ///< accommodate a minimum of `*pCount` elements. + ze_event_query_kernel_timestamps_results_ext_properties_t* pResults ///< [in][optional] pointer to event query properties structure(s). + ///< - This parameter may be null when `*pCount` is zero. + ///< - if `*pCount` is less than the number of event packets available, + ///< the driver may only update `*pCount` elements, starting at element zero. + ///< - if `*pCount` is greater than the number of event packets + ///< available, the driver may only update the valid elements. + ) + { + auto pfnQueryKernelTimestampsExt = context.zeDdiTable.Event.pfnQueryKernelTimestampsExt; + + if( nullptr == pfnQueryKernelTimestampsExt) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + ZE_HANDLE_TRACER_RECURSION(context.zeDdiTable.Event.pfnQueryKernelTimestampsExt, hEvent, hDevice, pCount, pResults); + + // capture parameters + ze_event_query_kernel_timestamps_ext_params_t tracerParams = { + &hEvent, + &hDevice, + &pCount, + &pResults + }; + + tracing_layer::APITracerCallbackDataImp apiCallbackData; + + ZE_GEN_PER_API_CALLBACK_STATE(apiCallbackData, ze_pfnEventQueryKernelTimestampsExtCb_t, Event, pfnQueryKernelTimestampsExtCb); + + + return tracing_layer::APITracerWrapperImp(context.zeDdiTable.Event.pfnQueryKernelTimestampsExt, + &tracerParams, + apiCallbackData.apiOrdinal, + apiCallbackData.prologCallbacks, + apiCallbackData.epilogCallbacks, + *tracerParams.phEvent, + *tracerParams.phDevice, + *tracerParams.ppCount, + *tracerParams.ppResults); + } + } // namespace tracing_layer #if defined(__cplusplus) @@ -5963,6 +6240,9 @@ zeGetDriverProcAddrTable( dditable.pfnGetExtensionFunctionAddress = pDdiTable->pfnGetExtensionFunctionAddress; pDdiTable->pfnGetExtensionFunctionAddress = tracing_layer::zeDriverGetExtensionFunctionAddress; + dditable.pfnGetLastErrorDescription = pDdiTable->pfnGetLastErrorDescription; + pDdiTable->pfnGetLastErrorDescription = tracing_layer::zeDriverGetLastErrorDescription; + return result; } @@ -6283,6 +6563,9 @@ zeGetCommandListProcAddrTable( dditable.pfnAppendImageCopyFromMemoryExt = pDdiTable->pfnAppendImageCopyFromMemoryExt; pDdiTable->pfnAppendImageCopyFromMemoryExt = tracing_layer::zeCommandListAppendImageCopyFromMemoryExt; + dditable.pfnHostSynchronize = pDdiTable->pfnHostSynchronize; + pDdiTable->pfnHostSynchronize = tracing_layer::zeCommandListHostSynchronize; + return result; } @@ -6332,6 +6615,9 @@ zeGetEventProcAddrTable( dditable.pfnQueryKernelTimestamp = pDdiTable->pfnQueryKernelTimestamp; pDdiTable->pfnQueryKernelTimestamp = tracing_layer::zeEventQueryKernelTimestamp; + dditable.pfnQueryKernelTimestampsExt = pDdiTable->pfnQueryKernelTimestampsExt; + pDdiTable->pfnQueryKernelTimestampsExt = tracing_layer::zeEventQueryKernelTimestampsExt; + return result; } @@ -6406,6 +6692,9 @@ zeGetEventPoolProcAddrTable( dditable.pfnCloseIpcHandle = pDdiTable->pfnCloseIpcHandle; pDdiTable->pfnCloseIpcHandle = tracing_layer::zeEventPoolCloseIpcHandle; + dditable.pfnPutIpcHandle = pDdiTable->pfnPutIpcHandle; + pDdiTable->pfnPutIpcHandle = tracing_layer::zeEventPoolPutIpcHandle; + return result; } @@ -6682,6 +6971,43 @@ zeGetMemProcAddrTable( dditable.pfnFreeExt = pDdiTable->pfnFreeExt; pDdiTable->pfnFreeExt = tracing_layer::zeMemFreeExt; + dditable.pfnPutIpcHandle = pDdiTable->pfnPutIpcHandle; + pDdiTable->pfnPutIpcHandle = tracing_layer::zeMemPutIpcHandle; + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's MemExp table +/// with current process' addresses +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION +ZE_DLLEXPORT ze_result_t ZE_APICALL +zeGetMemExpProcAddrTable( + ze_api_version_t version, ///< [in] API version requested + ze_mem_exp_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers + ) +{ + auto& dditable = tracing_layer::context.zeDdiTable.MemExp; + + if( nullptr == pDdiTable ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if (ZE_MAJOR_VERSION(tracing_layer::context.version) != ZE_MAJOR_VERSION(version) || + ZE_MINOR_VERSION(tracing_layer::context.version) > ZE_MINOR_VERSION(version)) + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + + ze_result_t result = ZE_RESULT_SUCCESS; + + dditable.pfnGetIpcHandleFromFileDescriptorExp = pDdiTable->pfnGetIpcHandleFromFileDescriptorExp; + pDdiTable->pfnGetIpcHandleFromFileDescriptorExp = tracing_layer::zeMemGetIpcHandleFromFileDescriptorExp; + + dditable.pfnGetFileDescriptorFromIpcHandleExp = pDdiTable->pfnGetFileDescriptorFromIpcHandleExp; + pDdiTable->pfnGetFileDescriptorFromIpcHandleExp = tracing_layer::zeMemGetFileDescriptorFromIpcHandleExp; + return result; } diff --git a/source/layers/validation/common/ze_entry_points.h b/source/layers/validation/common/ze_entry_points.h index fc589fd3..b1d981b0 100644 --- a/source/layers/validation/common/ze_entry_points.h +++ b/source/layers/validation/common/ze_entry_points.h @@ -24,6 +24,7 @@ class ZEValidationEntryPoints { virtual ze_result_t zeDriverGetIpcProperties( ze_driver_handle_t hDriver, ze_driver_ipc_properties_t* pIpcProperties ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeDriverGetExtensionProperties( ze_driver_handle_t hDriver, uint32_t* pCount, ze_driver_extension_properties_t* pExtensionProperties ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeDriverGetExtensionFunctionAddress( ze_driver_handle_t hDriver, const char* name, void** ppFunctionAddress ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeDriverGetLastErrorDescription( ze_driver_handle_t hDriver, const char** ppString ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeDeviceGet( ze_driver_handle_t hDriver, uint32_t* pCount, ze_device_handle_t* phDevices ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeDeviceGetSubDevices( ze_device_handle_t hDevice, uint32_t* pCount, ze_device_handle_t* phSubdevices ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeDeviceGetProperties( ze_device_handle_t hDevice, ze_device_properties_t* pDeviceProperties ) {return ZE_RESULT_SUCCESS;} @@ -53,6 +54,7 @@ class ZEValidationEntryPoints { virtual ze_result_t zeCommandListClose( ze_command_list_handle_t hCommandList ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeCommandListReset( ze_command_list_handle_t hCommandList ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeCommandListAppendWriteGlobalTimestamp( ze_command_list_handle_t hCommandList, uint64_t* dstptr, ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeCommandListHostSynchronize( ze_command_list_handle_t hCommandList, uint64_t timeout ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeCommandListAppendBarrier( ze_command_list_handle_t hCommandList, ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeCommandListAppendMemoryRangesBarrier( ze_command_list_handle_t hCommandList, uint32_t numRanges, const size_t* pRangeSizes, const void** pRanges, ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeContextSystemBarrier( ze_context_handle_t hContext, ze_device_handle_t hDevice ) {return ZE_RESULT_SUCCESS;} @@ -71,6 +73,7 @@ class ZEValidationEntryPoints { virtual ze_result_t zeEventCreate( ze_event_pool_handle_t hEventPool, const ze_event_desc_t* desc, ze_event_handle_t* phEvent ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeEventDestroy( ze_event_handle_t hEvent ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeEventPoolGetIpcHandle( ze_event_pool_handle_t hEventPool, ze_ipc_event_pool_handle_t* phIpc ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeEventPoolPutIpcHandle( ze_context_handle_t hContext, ze_ipc_event_pool_handle_t hIpc ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeEventPoolOpenIpcHandle( ze_context_handle_t hContext, ze_ipc_event_pool_handle_t hIpc, ze_event_pool_handle_t* phEventPool ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeEventPoolCloseIpcHandle( ze_event_pool_handle_t hEventPool ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeCommandListAppendSignalEvent( ze_command_list_handle_t hCommandList, ze_event_handle_t hEvent ) {return ZE_RESULT_SUCCESS;} @@ -97,6 +100,9 @@ class ZEValidationEntryPoints { virtual ze_result_t zeMemGetAllocProperties( ze_context_handle_t hContext, const void* ptr, ze_memory_allocation_properties_t* pMemAllocProperties, ze_device_handle_t* phDevice ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeMemGetAddressRange( ze_context_handle_t hContext, const void* ptr, void** pBase, size_t* pSize ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeMemGetIpcHandle( ze_context_handle_t hContext, const void* ptr, ze_ipc_mem_handle_t* pIpcHandle ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeMemGetIpcHandleFromFileDescriptorExp( ze_context_handle_t hContext, uint64_t handle, ze_ipc_mem_handle_t* pIpcHandle ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeMemGetFileDescriptorFromIpcHandleExp( ze_context_handle_t hContext, ze_ipc_mem_handle_t ipcHandle, uint64_t* pHandle ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeMemPutIpcHandle( ze_context_handle_t hContext, ze_ipc_mem_handle_t handle ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeMemOpenIpcHandle( ze_context_handle_t hContext, ze_device_handle_t hDevice, ze_ipc_mem_handle_t handle, ze_ipc_memory_flags_t flags, void** pptr ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeMemCloseIpcHandle( ze_context_handle_t hContext, const void* ptr ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeModuleCreate( ze_context_handle_t hContext, ze_device_handle_t hDevice, const ze_module_desc_t* desc, ze_module_handle_t* phModule, ze_module_build_log_handle_t* phBuildLog ) {return ZE_RESULT_SUCCESS;} @@ -162,5 +168,6 @@ class ZEValidationEntryPoints { virtual ze_result_t zeFabricEdgeGetExp( ze_fabric_vertex_handle_t hVertexA, ze_fabric_vertex_handle_t hVertexB, uint32_t* pCount, ze_fabric_edge_handle_t* phEdges ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeFabricEdgeGetVerticesExp( ze_fabric_edge_handle_t hEdge, ze_fabric_vertex_handle_t* phVertexA, ze_fabric_vertex_handle_t* phVertexB ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zeFabricEdgeGetPropertiesExp( ze_fabric_edge_handle_t hEdge, ze_fabric_edge_exp_properties_t* pEdgeProperties ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zeEventQueryKernelTimestampsExt( ze_event_handle_t hEvent, ze_device_handle_t hDevice, uint32_t* pCount, ze_event_query_kernel_timestamps_results_ext_properties_t* pResults ) {return ZE_RESULT_SUCCESS;} }; } \ No newline at end of file diff --git a/source/layers/validation/parameter_validation/ze_parameter_validation.cpp b/source/layers/validation/parameter_validation/ze_parameter_validation.cpp index aa27eaf3..bfb826ba 100644 --- a/source/layers/validation/parameter_validation/ze_parameter_validation.cpp +++ b/source/layers/validation/parameter_validation/ze_parameter_validation.cpp @@ -140,6 +140,23 @@ namespace validation_layer } + ze_result_t + ZEParameterValidation::zeDriverGetLastErrorDescription( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + const char** ppString ///< [in,out] pointer to a null-terminated array of characters describing + ///< cause of error. + ) + { + if( nullptr == hDriver ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == ppString ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + return ZE_RESULT_SUCCESS; + } + + ze_result_t ZEParameterValidation::zeDeviceGet( ze_driver_handle_t hDriver, ///< [in] handle of the driver instance @@ -721,6 +738,25 @@ namespace validation_layer } + ze_result_t + ZEParameterValidation::zeCommandListHostSynchronize( + ze_command_list_handle_t hCommandList, ///< [in] handle of the immediate command list + uint64_t timeout ///< [in] if non-zero, then indicates the maximum time (in nanoseconds) to + ///< yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; + ///< if zero, then immediately returns the status of the immediate command list; + ///< if UINT64_MAX, then function will not return until complete or device + ///< is lost. + ///< Due to external dependencies, timeout may be rounded to the closest + ///< value allowed by the accuracy of those dependencies. + ) + { + if( nullptr == hCommandList ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + return ZE_RESULT_SUCCESS; + } + + ze_result_t ZEParameterValidation::zeCommandListAppendBarrier( ze_command_list_handle_t hCommandList, ///< [in] handle of the command list @@ -1102,7 +1138,7 @@ namespace validation_layer if( nullptr == phEventPool ) return ZE_RESULT_ERROR_INVALID_NULL_POINTER; - if( 0x7 < desc->flags ) + if( 0xf < desc->flags ) return ZE_RESULT_ERROR_INVALID_ENUMERATION; if( 0 == desc->count ) @@ -1181,6 +1217,20 @@ namespace validation_layer } + ze_result_t + ZEParameterValidation::zeEventPoolPutIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object associated with the IPC event pool + ///< handle + ze_ipc_event_pool_handle_t hIpc ///< [in] IPC event pool handle + ) + { + if( nullptr == hContext ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + return ZE_RESULT_SUCCESS; + } + + ze_result_t ZEParameterValidation::zeEventPoolOpenIpcHandle( ze_context_handle_t hContext, ///< [in] handle of the context object to associate with the IPC event pool @@ -1707,6 +1757,53 @@ namespace validation_layer } + ze_result_t + ZEParameterValidation::zeMemGetIpcHandleFromFileDescriptorExp( + ze_context_handle_t hContext, ///< [in] handle of the context object + uint64_t handle, ///< [in] file descriptor + ze_ipc_mem_handle_t* pIpcHandle ///< [out] Returned IPC memory handle + ) + { + if( nullptr == hContext ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == pIpcHandle ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + return ZE_RESULT_SUCCESS; + } + + + ze_result_t + ZEParameterValidation::zeMemGetFileDescriptorFromIpcHandleExp( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_ipc_mem_handle_t ipcHandle, ///< [in] IPC memory handle + uint64_t* pHandle ///< [out] Returned file descriptor + ) + { + if( nullptr == hContext ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == pHandle ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + return ZE_RESULT_SUCCESS; + } + + + ze_result_t + ZEParameterValidation::zeMemPutIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_ipc_mem_handle_t handle ///< [in] IPC memory handle + ) + { + if( nullptr == hContext ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + return ZE_RESULT_SUCCESS; + } + + ze_result_t ZEParameterValidation::zeMemOpenIpcHandle( ze_context_handle_t hContext, ///< [in] handle of the context object @@ -3109,4 +3206,37 @@ namespace validation_layer return ParameterValidation::validateExtensions(pEdgeProperties); } + + ze_result_t + ZEParameterValidation::zeEventQueryKernelTimestampsExt( + ze_event_handle_t hEvent, ///< [in] handle of the event + ze_device_handle_t hDevice, ///< [in] handle of the device to query + uint32_t* pCount, ///< [in,out] pointer to the number of event packets available. + ///< - This value is implementation specific. + ///< - if `*pCount` is zero, then the driver shall update the value with + ///< the total number of event packets available. + ///< - if `*pCount` is greater than the number of event packets + ///< available, the driver shall update the value with the correct value. + ///< - Buffer(s) for query results must be sized by the application to + ///< accommodate a minimum of `*pCount` elements. + ze_event_query_kernel_timestamps_results_ext_properties_t* pResults ///< [in][optional] pointer to event query properties structure(s). + ///< - This parameter may be null when `*pCount` is zero. + ///< - if `*pCount` is less than the number of event packets available, + ///< the driver may only update `*pCount` elements, starting at element zero. + ///< - if `*pCount` is greater than the number of event packets + ///< available, the driver may only update the valid elements. + ) + { + if( nullptr == hEvent ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == hDevice ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == pCount ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + return ParameterValidation::validateExtensions(pResults); + } + } \ No newline at end of file diff --git a/source/layers/validation/parameter_validation/ze_parameter_validation.h b/source/layers/validation/parameter_validation/ze_parameter_validation.h index bf560878..44bf4d65 100644 --- a/source/layers/validation/parameter_validation/ze_parameter_validation.h +++ b/source/layers/validation/parameter_validation/ze_parameter_validation.h @@ -26,6 +26,7 @@ namespace validation_layer ze_result_t zeDriverGetIpcProperties ( ze_driver_handle_t hDriver, ze_driver_ipc_properties_t* pIpcProperties ) override; ze_result_t zeDriverGetExtensionProperties ( ze_driver_handle_t hDriver, uint32_t* pCount, ze_driver_extension_properties_t* pExtensionProperties ) override; ze_result_t zeDriverGetExtensionFunctionAddress ( ze_driver_handle_t hDriver, const char* name, void** ppFunctionAddress ) override; + ze_result_t zeDriverGetLastErrorDescription ( ze_driver_handle_t hDriver, const char** ppString ) override; ze_result_t zeDeviceGet ( ze_driver_handle_t hDriver, uint32_t* pCount, ze_device_handle_t* phDevices ) override; ze_result_t zeDeviceGetSubDevices ( ze_device_handle_t hDevice, uint32_t* pCount, ze_device_handle_t* phSubdevices ) override; ze_result_t zeDeviceGetProperties ( ze_device_handle_t hDevice, ze_device_properties_t* pDeviceProperties ) override; @@ -55,6 +56,7 @@ namespace validation_layer ze_result_t zeCommandListClose ( ze_command_list_handle_t hCommandList ) override; ze_result_t zeCommandListReset ( ze_command_list_handle_t hCommandList ) override; ze_result_t zeCommandListAppendWriteGlobalTimestamp ( ze_command_list_handle_t hCommandList, uint64_t* dstptr, ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) override; + ze_result_t zeCommandListHostSynchronize ( ze_command_list_handle_t hCommandList, uint64_t timeout ) override; ze_result_t zeCommandListAppendBarrier ( ze_command_list_handle_t hCommandList, ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) override; ze_result_t zeCommandListAppendMemoryRangesBarrier ( ze_command_list_handle_t hCommandList, uint32_t numRanges, const size_t* pRangeSizes, const void** pRanges, ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t* phWaitEvents ) override; ze_result_t zeContextSystemBarrier ( ze_context_handle_t hContext, ze_device_handle_t hDevice ) override; @@ -73,6 +75,7 @@ namespace validation_layer ze_result_t zeEventCreate ( ze_event_pool_handle_t hEventPool, const ze_event_desc_t* desc, ze_event_handle_t* phEvent ) override; ze_result_t zeEventDestroy ( ze_event_handle_t hEvent ) override; ze_result_t zeEventPoolGetIpcHandle ( ze_event_pool_handle_t hEventPool, ze_ipc_event_pool_handle_t* phIpc ) override; + ze_result_t zeEventPoolPutIpcHandle ( ze_context_handle_t hContext, ze_ipc_event_pool_handle_t hIpc ) override; ze_result_t zeEventPoolOpenIpcHandle ( ze_context_handle_t hContext, ze_ipc_event_pool_handle_t hIpc, ze_event_pool_handle_t* phEventPool ) override; ze_result_t zeEventPoolCloseIpcHandle ( ze_event_pool_handle_t hEventPool ) override; ze_result_t zeCommandListAppendSignalEvent ( ze_command_list_handle_t hCommandList, ze_event_handle_t hEvent ) override; @@ -99,6 +102,9 @@ namespace validation_layer ze_result_t zeMemGetAllocProperties ( ze_context_handle_t hContext, const void* ptr, ze_memory_allocation_properties_t* pMemAllocProperties, ze_device_handle_t* phDevice ) override; ze_result_t zeMemGetAddressRange ( ze_context_handle_t hContext, const void* ptr, void** pBase, size_t* pSize ) override; ze_result_t zeMemGetIpcHandle ( ze_context_handle_t hContext, const void* ptr, ze_ipc_mem_handle_t* pIpcHandle ) override; + ze_result_t zeMemGetIpcHandleFromFileDescriptorExp ( ze_context_handle_t hContext, uint64_t handle, ze_ipc_mem_handle_t* pIpcHandle ) override; + ze_result_t zeMemGetFileDescriptorFromIpcHandleExp ( ze_context_handle_t hContext, ze_ipc_mem_handle_t ipcHandle, uint64_t* pHandle ) override; + ze_result_t zeMemPutIpcHandle ( ze_context_handle_t hContext, ze_ipc_mem_handle_t handle ) override; ze_result_t zeMemOpenIpcHandle ( ze_context_handle_t hContext, ze_device_handle_t hDevice, ze_ipc_mem_handle_t handle, ze_ipc_memory_flags_t flags, void** pptr ) override; ze_result_t zeMemCloseIpcHandle ( ze_context_handle_t hContext, const void* ptr ) override; ze_result_t zeModuleCreate ( ze_context_handle_t hContext, ze_device_handle_t hDevice, const ze_module_desc_t* desc, ze_module_handle_t* phModule, ze_module_build_log_handle_t* phBuildLog ) override; @@ -164,6 +170,7 @@ namespace validation_layer ze_result_t zeFabricEdgeGetExp ( ze_fabric_vertex_handle_t hVertexA, ze_fabric_vertex_handle_t hVertexB, uint32_t* pCount, ze_fabric_edge_handle_t* phEdges ) override; ze_result_t zeFabricEdgeGetVerticesExp ( ze_fabric_edge_handle_t hEdge, ze_fabric_vertex_handle_t* phVertexA, ze_fabric_vertex_handle_t* phVertexB ) override; ze_result_t zeFabricEdgeGetPropertiesExp ( ze_fabric_edge_handle_t hEdge, ze_fabric_edge_exp_properties_t* pEdgeProperties ) override; + ze_result_t zeEventQueryKernelTimestampsExt ( ze_event_handle_t hEvent, ze_device_handle_t hDevice, uint32_t* pCount, ze_event_query_kernel_timestamps_results_ext_properties_t* pResults ) override; }; } \ No newline at end of file diff --git a/source/layers/validation/ze_valddi.cpp b/source/layers/validation/ze_valddi.cpp index 6e9b73f6..fa6c8a80 100644 --- a/source/layers/validation/ze_valddi.cpp +++ b/source/layers/validation/ze_valddi.cpp @@ -239,6 +239,37 @@ namespace validation_layer return pfnGetExtensionFunctionAddress( hDriver, name, ppFunctionAddress ); } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDriverGetLastErrorDescription + __zedlllocal ze_result_t ZE_APICALL + zeDriverGetLastErrorDescription( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + const char** ppString ///< [in,out] pointer to a null-terminated array of characters describing + ///< cause of error. + ) + { + auto pfnGetLastErrorDescription = context.zeDdiTable.Driver.pfnGetLastErrorDescription; + + if( nullptr == pfnGetLastErrorDescription ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + if( context.enableParameterValidation ) + { + auto result = context.paramValidation->zeParamValidation.zeDriverGetLastErrorDescription( hDriver, ppString ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + if( context.enableHandleLifetime ){ + //Unimplemented + } + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + return pfnGetLastErrorDescription( hDriver, ppString ); + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeDeviceGet __zedlllocal ze_result_t ZE_APICALL @@ -1181,6 +1212,42 @@ namespace validation_layer return pfnAppendWriteGlobalTimestamp( hCommandList, dstptr, hSignalEvent, numWaitEvents, phWaitEvents ); } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListHostSynchronize + __zedlllocal ze_result_t ZE_APICALL + zeCommandListHostSynchronize( + ze_command_list_handle_t hCommandList, ///< [in] handle of the immediate command list + uint64_t timeout ///< [in] if non-zero, then indicates the maximum time (in nanoseconds) to + ///< yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; + ///< if zero, then immediately returns the status of the immediate command list; + ///< if UINT64_MAX, then function will not return until complete or device + ///< is lost. + ///< Due to external dependencies, timeout may be rounded to the closest + ///< value allowed by the accuracy of those dependencies. + ) + { + auto pfnHostSynchronize = context.zeDdiTable.CommandList.pfnHostSynchronize; + + if( nullptr == pfnHostSynchronize ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + if( context.enableParameterValidation ) + { + auto result = context.paramValidation->zeParamValidation.zeCommandListHostSynchronize( hCommandList, timeout ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + if( context.enableHandleLifetime ){ + //Unimplemented + } + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + return pfnHostSynchronize( hCommandList, timeout ); + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeCommandListAppendBarrier __zedlllocal ze_result_t ZE_APICALL @@ -1809,6 +1876,37 @@ namespace validation_layer return pfnGetIpcHandle( hEventPool, phIpc ); } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventPoolPutIpcHandle + __zedlllocal ze_result_t ZE_APICALL + zeEventPoolPutIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object associated with the IPC event pool + ///< handle + ze_ipc_event_pool_handle_t hIpc ///< [in] IPC event pool handle + ) + { + auto pfnPutIpcHandle = context.zeDdiTable.EventPool.pfnPutIpcHandle; + + if( nullptr == pfnPutIpcHandle ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + if( context.enableParameterValidation ) + { + auto result = context.paramValidation->zeParamValidation.zeEventPoolPutIpcHandle( hContext, hIpc ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + if( context.enableHandleLifetime ){ + //Unimplemented + } + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + return pfnPutIpcHandle( hContext, hIpc ); + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeEventPoolOpenIpcHandle __zedlllocal ze_result_t ZE_APICALL @@ -2635,6 +2733,98 @@ namespace validation_layer return pfnGetIpcHandle( hContext, ptr, pIpcHandle ); } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemGetIpcHandleFromFileDescriptorExp + __zedlllocal ze_result_t ZE_APICALL + zeMemGetIpcHandleFromFileDescriptorExp( + ze_context_handle_t hContext, ///< [in] handle of the context object + uint64_t handle, ///< [in] file descriptor + ze_ipc_mem_handle_t* pIpcHandle ///< [out] Returned IPC memory handle + ) + { + auto pfnGetIpcHandleFromFileDescriptorExp = context.zeDdiTable.MemExp.pfnGetIpcHandleFromFileDescriptorExp; + + if( nullptr == pfnGetIpcHandleFromFileDescriptorExp ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + if( context.enableParameterValidation ) + { + auto result = context.paramValidation->zeParamValidation.zeMemGetIpcHandleFromFileDescriptorExp( hContext, handle, pIpcHandle ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + if( context.enableHandleLifetime ){ + //Unimplemented + } + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + return pfnGetIpcHandleFromFileDescriptorExp( hContext, handle, pIpcHandle ); + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemGetFileDescriptorFromIpcHandleExp + __zedlllocal ze_result_t ZE_APICALL + zeMemGetFileDescriptorFromIpcHandleExp( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_ipc_mem_handle_t ipcHandle, ///< [in] IPC memory handle + uint64_t* pHandle ///< [out] Returned file descriptor + ) + { + auto pfnGetFileDescriptorFromIpcHandleExp = context.zeDdiTable.MemExp.pfnGetFileDescriptorFromIpcHandleExp; + + if( nullptr == pfnGetFileDescriptorFromIpcHandleExp ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + if( context.enableParameterValidation ) + { + auto result = context.paramValidation->zeParamValidation.zeMemGetFileDescriptorFromIpcHandleExp( hContext, ipcHandle, pHandle ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + if( context.enableHandleLifetime ){ + //Unimplemented + } + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + return pfnGetFileDescriptorFromIpcHandleExp( hContext, ipcHandle, pHandle ); + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemPutIpcHandle + __zedlllocal ze_result_t ZE_APICALL + zeMemPutIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_ipc_mem_handle_t handle ///< [in] IPC memory handle + ) + { + auto pfnPutIpcHandle = context.zeDdiTable.Mem.pfnPutIpcHandle; + + if( nullptr == pfnPutIpcHandle ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + if( context.enableParameterValidation ) + { + auto result = context.paramValidation->zeParamValidation.zeMemPutIpcHandle( hContext, handle ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + if( context.enableHandleLifetime ){ + //Unimplemented + } + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + return pfnPutIpcHandle( hContext, handle ); + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeMemOpenIpcHandle __zedlllocal ze_result_t ZE_APICALL @@ -4762,6 +4952,50 @@ namespace validation_layer return pfnGetPropertiesExp( hEdge, pEdgeProperties ); } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventQueryKernelTimestampsExt + __zedlllocal ze_result_t ZE_APICALL + zeEventQueryKernelTimestampsExt( + ze_event_handle_t hEvent, ///< [in] handle of the event + ze_device_handle_t hDevice, ///< [in] handle of the device to query + uint32_t* pCount, ///< [in,out] pointer to the number of event packets available. + ///< - This value is implementation specific. + ///< - if `*pCount` is zero, then the driver shall update the value with + ///< the total number of event packets available. + ///< - if `*pCount` is greater than the number of event packets + ///< available, the driver shall update the value with the correct value. + ///< - Buffer(s) for query results must be sized by the application to + ///< accommodate a minimum of `*pCount` elements. + ze_event_query_kernel_timestamps_results_ext_properties_t* pResults ///< [in][optional] pointer to event query properties structure(s). + ///< - This parameter may be null when `*pCount` is zero. + ///< - if `*pCount` is less than the number of event packets available, + ///< the driver may only update `*pCount` elements, starting at element zero. + ///< - if `*pCount` is greater than the number of event packets + ///< available, the driver may only update the valid elements. + ) + { + auto pfnQueryKernelTimestampsExt = context.zeDdiTable.Event.pfnQueryKernelTimestampsExt; + + if( nullptr == pfnQueryKernelTimestampsExt ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + if( context.enableParameterValidation ) + { + auto result = context.paramValidation->zeParamValidation.zeEventQueryKernelTimestampsExt( hEvent, hDevice, pCount, pResults ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + if( context.enableHandleLifetime ){ + //Unimplemented + } + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + return pfnQueryKernelTimestampsExt( hEvent, hDevice, pCount, pResults ); + } + } // namespace validation_layer #if defined(__cplusplus) @@ -4842,6 +5076,9 @@ zeGetDriverProcAddrTable( dditable.pfnGetExtensionFunctionAddress = pDdiTable->pfnGetExtensionFunctionAddress; pDdiTable->pfnGetExtensionFunctionAddress = validation_layer::zeDriverGetExtensionFunctionAddress; + dditable.pfnGetLastErrorDescription = pDdiTable->pfnGetLastErrorDescription; + pDdiTable->pfnGetLastErrorDescription = validation_layer::zeDriverGetLastErrorDescription; + return result; } @@ -5162,6 +5399,9 @@ zeGetCommandListProcAddrTable( dditable.pfnAppendImageCopyFromMemoryExt = pDdiTable->pfnAppendImageCopyFromMemoryExt; pDdiTable->pfnAppendImageCopyFromMemoryExt = validation_layer::zeCommandListAppendImageCopyFromMemoryExt; + dditable.pfnHostSynchronize = pDdiTable->pfnHostSynchronize; + pDdiTable->pfnHostSynchronize = validation_layer::zeCommandListHostSynchronize; + return result; } @@ -5211,6 +5451,9 @@ zeGetEventProcAddrTable( dditable.pfnQueryKernelTimestamp = pDdiTable->pfnQueryKernelTimestamp; pDdiTable->pfnQueryKernelTimestamp = validation_layer::zeEventQueryKernelTimestamp; + dditable.pfnQueryKernelTimestampsExt = pDdiTable->pfnQueryKernelTimestampsExt; + pDdiTable->pfnQueryKernelTimestampsExt = validation_layer::zeEventQueryKernelTimestampsExt; + return result; } @@ -5285,6 +5528,9 @@ zeGetEventPoolProcAddrTable( dditable.pfnCloseIpcHandle = pDdiTable->pfnCloseIpcHandle; pDdiTable->pfnCloseIpcHandle = validation_layer::zeEventPoolCloseIpcHandle; + dditable.pfnPutIpcHandle = pDdiTable->pfnPutIpcHandle; + pDdiTable->pfnPutIpcHandle = validation_layer::zeEventPoolPutIpcHandle; + return result; } @@ -5561,6 +5807,43 @@ zeGetMemProcAddrTable( dditable.pfnFreeExt = pDdiTable->pfnFreeExt; pDdiTable->pfnFreeExt = validation_layer::zeMemFreeExt; + dditable.pfnPutIpcHandle = pDdiTable->pfnPutIpcHandle; + pDdiTable->pfnPutIpcHandle = validation_layer::zeMemPutIpcHandle; + + return result; +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's MemExp table +/// with current process' addresses +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION +ZE_DLLEXPORT ze_result_t ZE_APICALL +zeGetMemExpProcAddrTable( + ze_api_version_t version, ///< [in] API version requested + ze_mem_exp_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers + ) +{ + auto& dditable = validation_layer::context.zeDdiTable.MemExp; + + if( nullptr == pDdiTable ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if (ZE_MAJOR_VERSION(validation_layer::context.version) != ZE_MAJOR_VERSION(version) || + ZE_MINOR_VERSION(validation_layer::context.version) > ZE_MINOR_VERSION(version)) + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + + ze_result_t result = ZE_RESULT_SUCCESS; + + dditable.pfnGetIpcHandleFromFileDescriptorExp = pDdiTable->pfnGetIpcHandleFromFileDescriptorExp; + pDdiTable->pfnGetIpcHandleFromFileDescriptorExp = validation_layer::zeMemGetIpcHandleFromFileDescriptorExp; + + dditable.pfnGetFileDescriptorFromIpcHandleExp = pDdiTable->pfnGetFileDescriptorFromIpcHandleExp; + pDdiTable->pfnGetFileDescriptorFromIpcHandleExp = validation_layer::zeMemGetFileDescriptorFromIpcHandleExp; + return result; } diff --git a/source/layers/validation/ze_validation_layer.h b/source/layers/validation/ze_validation_layer.h index 7f4d9bc8..dc484891 100644 --- a/source/layers/validation/ze_validation_layer.h +++ b/source/layers/validation/ze_validation_layer.h @@ -24,7 +24,7 @@ namespace validation_layer class __zedlllocal context_t { public: - ze_api_version_t version = ZE_API_VERSION_1_5; + ze_api_version_t version = ZE_API_VERSION_CURRENT; bool enableParameterValidation = false; bool enableHandleLifetime = false; diff --git a/source/lib/ze_libapi.cpp b/source/lib/ze_libapi.cpp index 8cdf0fb1..e61bd8e1 100644 --- a/source/lib/ze_libapi.cpp +++ b/source/lib/ze_libapi.cpp @@ -301,6 +301,47 @@ zeDriverGetExtensionFunctionAddress( return pfnGetExtensionFunctionAddress( hDriver, name, ppFunctionAddress ); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Retrieves a string describing the last error code returned by the +/// driver in the current thread. +/// +/// @details +/// - String returned is thread local. +/// - String is only updated on calls returning an error, i.e., not on calls +/// returning ::ZE_RESULT_SUCCESS. +/// - String may be empty if driver considers error code is already explicit +/// enough to describe cause. +/// - Memory pointed to by ppString is owned by the driver. +/// - String returned is null-terminated. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hDriver` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == ppString` +ze_result_t ZE_APICALL +zeDriverGetLastErrorDescription( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + const char** ppString ///< [in,out] pointer to a null-terminated array of characters describing + ///< cause of error. + ) +{ + auto pfnGetLastErrorDescription = ze_lib::context->zeDdiTable.Driver.pfnGetLastErrorDescription; + if( nullptr == pfnGetLastErrorDescription ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnGetLastErrorDescription( hDriver, ppString ); +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Retrieves devices within a driver /// @@ -1541,6 +1582,55 @@ zeCommandListAppendWriteGlobalTimestamp( return pfnAppendWriteGlobalTimestamp( hCommandList, dstptr, hSignalEvent, numWaitEvents, phWaitEvents ); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Synchronizes an immediate command list by waiting on the host for the +/// completion of all commands previously submitted to it. +/// +/// @details +/// - The application must call this function only with command lists +/// created with ::zeCommandListCreateImmediate. +/// - Waiting on one immediate command list shall not block the concurrent +/// execution of commands appended to other +/// immediate command lists created with either a different ordinal or +/// different index. +/// - 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 == hCommandList` +/// - ::ZE_RESULT_NOT_READY +/// + timeout expired +/// - ::ZE_RESULT_ERROR_INVALID_ARGUMENT +/// + handle does not correspond to an immediate command list +ze_result_t ZE_APICALL +zeCommandListHostSynchronize( + ze_command_list_handle_t hCommandList, ///< [in] handle of the immediate command list + uint64_t timeout ///< [in] if non-zero, then indicates the maximum time (in nanoseconds) to + ///< yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; + ///< if zero, then immediately returns the status of the immediate command list; + ///< if UINT64_MAX, then function will not return until complete or device + ///< is lost. + ///< Due to external dependencies, timeout may be rounded to the closest + ///< value allowed by the accuracy of those dependencies. + ) +{ + auto pfnHostSynchronize = ze_lib::context->zeDdiTable.CommandList.pfnHostSynchronize; + if( nullptr == pfnHostSynchronize ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnHostSynchronize( hCommandList, timeout ); +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Appends an execution and global memory barrier into a command list. /// @@ -2311,7 +2401,7 @@ zeCommandListAppendMemAdvise( /// + `nullptr == desc` /// + `nullptr == phEventPool` /// - ::ZE_RESULT_ERROR_INVALID_ENUMERATION -/// + `0x7 < desc->flags` +/// + `0xf < desc->flags` /// - ::ZE_RESULT_ERROR_INVALID_SIZE /// + `0 == desc->count` /// + `(nullptr == phDevices) && (0 < numDevices)` @@ -2505,6 +2595,48 @@ zeEventPoolGetIpcHandle( return pfnGetIpcHandle( hEventPool, phIpc ); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Returns an IPC event pool handle to the driver +/// +/// @details +/// - This call must be used for IPC handles previously obtained with +/// ::zeEventPoolGetIpcHandle. +/// - Upon call, driver may release any underlying resources associated with +/// the IPC handle. +/// For instance, it may close the file descriptor contained in the IPC +/// handle, if such type of handle is being used by the driver. +/// - This call does not destroy the original event pool for which the IPC +/// handle was created. +/// - This function may **not** be called from simultaneous threads with the +/// same IPC 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 == hContext` +ze_result_t ZE_APICALL +zeEventPoolPutIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object associated with the IPC event pool + ///< handle + ze_ipc_event_pool_handle_t hIpc ///< [in] IPC event pool handle + ) +{ + auto pfnPutIpcHandle = ze_lib::context->zeDdiTable.EventPool.pfnPutIpcHandle; + if( nullptr == pfnPutIpcHandle ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnPutIpcHandle( hContext, hIpc ); +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Opens an IPC event pool handle to retrieve an event pool handle from /// another process. @@ -2585,7 +2717,8 @@ zeEventPoolCloseIpcHandle( /// - The application must ensure the events are accessible by the device on /// which the command list was created. /// - The duration of an event created from an event pool that was created -/// using ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP flag is undefined. +/// using ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP or +/// ::ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP flags is undefined. /// However, for consistency and orthogonality the event will report /// correctly as signaled when used by other event API functionality. /// - The application must ensure the command list and events were created @@ -2673,7 +2806,8 @@ zeCommandListAppendWaitOnEvents( /// /// @details /// - The duration of an event created from an event pool that was created -/// using ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP flag is undefined. +/// using ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP or +/// ::ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP flags is undefined. /// However, for consistency and orthogonality the event will report /// correctly as signaled when used by other event API functionality. /// - The application may call this function from simultaneous threads. @@ -2877,7 +3011,8 @@ zeEventHostReset( /// /// @details /// - The application must ensure the event was created from an event pool -/// that was created using ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP flag. +/// that was created using ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP or +/// ::ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP flag. /// - The destination memory will be unmodified if the event has not been /// signaled. /// - The application may call this function from simultaneous threads. @@ -3636,6 +3771,123 @@ zeMemGetIpcHandle( return pfnGetIpcHandle( hContext, ptr, pIpcHandle ); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Creates an IPC memory handle out of a file descriptor +/// +/// @details +/// - Handle passed must be a valid file descriptor obtained with +/// ::ze_external_memory_export_fd_t via ::zeMemGetAllocProperties. +/// - Returned IPC handle may contain metadata in addition to the file +/// descriptor. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pIpcHandle` +ze_result_t ZE_APICALL +zeMemGetIpcHandleFromFileDescriptorExp( + ze_context_handle_t hContext, ///< [in] handle of the context object + uint64_t handle, ///< [in] file descriptor + ze_ipc_mem_handle_t* pIpcHandle ///< [out] Returned IPC memory handle + ) +{ + auto pfnGetIpcHandleFromFileDescriptorExp = ze_lib::context->zeDdiTable.MemExp.pfnGetIpcHandleFromFileDescriptorExp; + if( nullptr == pfnGetIpcHandleFromFileDescriptorExp ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnGetIpcHandleFromFileDescriptorExp( hContext, handle, pIpcHandle ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Gets the file descriptor contained in an IPC memory handle +/// +/// @details +/// - IPC memory handle must be a valid handle obtained with +/// ::zeMemGetIpcHandle. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hContext` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pHandle` +ze_result_t ZE_APICALL +zeMemGetFileDescriptorFromIpcHandleExp( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_ipc_mem_handle_t ipcHandle, ///< [in] IPC memory handle + uint64_t* pHandle ///< [out] Returned file descriptor + ) +{ + auto pfnGetFileDescriptorFromIpcHandleExp = ze_lib::context->zeDdiTable.MemExp.pfnGetFileDescriptorFromIpcHandleExp; + if( nullptr == pfnGetFileDescriptorFromIpcHandleExp ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnGetFileDescriptorFromIpcHandleExp( hContext, ipcHandle, pHandle ); +} + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Returns an IPC memory handle to the driver +/// +/// @details +/// - This call may be used for IPC handles previously obtained with either +/// ::zeMemGetIpcHandle or with ::ze_external_memory_export_fd_t via ::zeMemGetAllocProperties. +/// - Upon call, driver may release any underlying resources associated with +/// the IPC handle. +/// For instance, it may close the file descriptor contained in the IPC +/// handle, if such type of handle is being used by the driver. +/// - This call does not free the original allocation for which the IPC +/// handle was created. +/// - This function may **not** be called from simultaneous threads with the +/// same IPC 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 == hContext` +ze_result_t ZE_APICALL +zeMemPutIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_ipc_mem_handle_t handle ///< [in] IPC memory handle + ) +{ + auto pfnPutIpcHandle = ze_lib::context->zeDdiTable.Mem.pfnPutIpcHandle; + if( nullptr == pfnPutIpcHandle ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnPutIpcHandle( hContext, handle ); +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Opens an IPC memory handle to retrieve a device pointer on the /// context. @@ -6476,4 +6728,71 @@ zeFabricEdgeGetPropertiesExp( return pfnGetPropertiesExp( hEdge, pEdgeProperties ); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Query an event's timestamp value on the host, with domain preference. +/// +/// @details +/// - For collecting *only* kernel timestamps, the application must ensure +/// the event was created from an event pool that was created using +/// ::ZE_EVENT_POOL_FLAG_KERNEL_TIMESTAMP flag. +/// - For collecting synchronized timestamps, the application must ensure +/// the event was created from an event pool that was created using +/// ::ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP flag. Kernel timestamps +/// are also available from this type of event pool, but there is a +/// performance cost. +/// - The destination memory will be unmodified if the event has not been +/// signaled. +/// - The application may call this function from simultaneous threads. +/// - The implementation of this function must be thread-safe. +/// - The implementation must support +/// ::ZE_extension_event_query_kernel_timestamps. +/// - The implementation must return all timestamps for the specified event +/// and device pair. +/// - The implementation must return all timestamps for all sub-devices when +/// device handle is parent device. +/// - The implementation may return all timestamps for sub-devices when +/// device handle is sub-device or may return 0 for count. +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_DEVICE_LOST +/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY +/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY +/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE +/// + `nullptr == hEvent` +/// + `nullptr == hDevice` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == pCount` +ze_result_t ZE_APICALL +zeEventQueryKernelTimestampsExt( + ze_event_handle_t hEvent, ///< [in] handle of the event + ze_device_handle_t hDevice, ///< [in] handle of the device to query + uint32_t* pCount, ///< [in,out] pointer to the number of event packets available. + ///< - This value is implementation specific. + ///< - if `*pCount` is zero, then the driver shall update the value with + ///< the total number of event packets available. + ///< - if `*pCount` is greater than the number of event packets + ///< available, the driver shall update the value with the correct value. + ///< - Buffer(s) for query results must be sized by the application to + ///< accommodate a minimum of `*pCount` elements. + ze_event_query_kernel_timestamps_results_ext_properties_t* pResults ///< [in][optional] pointer to event query properties structure(s). + ///< - This parameter may be null when `*pCount` is zero. + ///< - if `*pCount` is less than the number of event packets available, + ///< the driver may only update `*pCount` elements, starting at element zero. + ///< - if `*pCount` is greater than the number of event packets + ///< available, the driver may only update the valid elements. + ) +{ + auto pfnQueryKernelTimestampsExt = ze_lib::context->zeDdiTable.Event.pfnQueryKernelTimestampsExt; + if( nullptr == pfnQueryKernelTimestampsExt ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnQueryKernelTimestampsExt( hEvent, hDevice, pCount, pResults ); +} + } // extern "C" diff --git a/source/lib/ze_libddi.cpp b/source/lib/ze_libddi.cpp index 5c57671d..69cdb8ea 100644 --- a/source/lib/ze_libddi.cpp +++ b/source/lib/ze_libddi.cpp @@ -25,161 +25,168 @@ namespace ze_lib { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetGlobalProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.Global ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.Global ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetDriverProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.Driver ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.Driver ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetDeviceProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.Device ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.Device ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetDeviceExpProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.DeviceExp ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.DeviceExp ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetContextProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.Context ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.Context ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetCommandQueueProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.CommandQueue ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.CommandQueue ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetCommandListProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.CommandList ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.CommandList ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetEventProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.Event ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.Event ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetEventExpProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.EventExp ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.EventExp ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetEventPoolProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.EventPool ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.EventPool ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetFenceProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.Fence ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.Fence ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetImageProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.Image ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.Image ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetImageExpProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.ImageExp ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.ImageExp ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetKernelProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.Kernel ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.Kernel ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetKernelExpProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.KernelExp ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.KernelExp ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetMemProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.Mem ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.Mem ); + } + + if( ZE_RESULT_SUCCESS == result ) + { + auto getTable = reinterpret_cast( + GET_FUNCTION_PTR(loader, "zeGetMemExpProcAddrTable") ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.MemExp ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetModuleProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.Module ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.Module ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetModuleBuildLogProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.ModuleBuildLog ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.ModuleBuildLog ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetPhysicalMemProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.PhysicalMem ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.PhysicalMem ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetSamplerProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.Sampler ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.Sampler ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetVirtualMemProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.VirtualMem ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.VirtualMem ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetFabricEdgeExpProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.FabricEdgeExp ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.FabricEdgeExp ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zeGetFabricVertexExpProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zeDdiTable.FabricVertexExp ); + result = getTable( ZE_API_VERSION_CURRENT, &zeDdiTable.FabricVertexExp ); } return result; @@ -191,117 +198,122 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - result = zeGetGlobalProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.Global ); + result = zeGetGlobalProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.Global ); + } + + if( ZE_RESULT_SUCCESS == result ) + { + result = zeGetDriverProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.Driver ); } if( ZE_RESULT_SUCCESS == result ) { - result = zeGetDriverProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.Driver ); + result = zeGetDeviceProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.Device ); } if( ZE_RESULT_SUCCESS == result ) { - result = zeGetDeviceProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.Device ); + result = zeGetDeviceExpProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.DeviceExp ); } if( ZE_RESULT_SUCCESS == result ) { - result = zeGetDeviceExpProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.DeviceExp ); + result = zeGetContextProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.Context ); } if( ZE_RESULT_SUCCESS == result ) { - result = zeGetContextProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.Context ); + result = zeGetCommandQueueProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.CommandQueue ); } if( ZE_RESULT_SUCCESS == result ) { - result = zeGetCommandQueueProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.CommandQueue ); + result = zeGetCommandListProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.CommandList ); } if( ZE_RESULT_SUCCESS == result ) { - result = zeGetCommandListProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.CommandList ); + result = zeGetEventProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.Event ); } if( ZE_RESULT_SUCCESS == result ) { - result = zeGetEventProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.Event ); + result = zeGetEventExpProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.EventExp ); } if( ZE_RESULT_SUCCESS == result ) { - result = zeGetEventExpProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.EventExp ); + result = zeGetEventPoolProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.EventPool ); } if( ZE_RESULT_SUCCESS == result ) { - result = zeGetEventPoolProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.EventPool ); + result = zeGetFenceProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.Fence ); } if( ZE_RESULT_SUCCESS == result ) { - result = zeGetFenceProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.Fence ); + result = zeGetImageProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.Image ); } if( ZE_RESULT_SUCCESS == result ) { - result = zeGetImageProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.Image ); + result = zeGetImageExpProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.ImageExp ); } if( ZE_RESULT_SUCCESS == result ) { - result = zeGetImageExpProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.ImageExp ); + result = zeGetKernelProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.Kernel ); } if( ZE_RESULT_SUCCESS == result ) { - result = zeGetKernelProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.Kernel ); + result = zeGetKernelExpProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.KernelExp ); } if( ZE_RESULT_SUCCESS == result ) { - result = zeGetKernelExpProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.KernelExp ); + result = zeGetMemProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.Mem ); } if( ZE_RESULT_SUCCESS == result ) { - result = zeGetMemProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.Mem ); + result = zeGetMemExpProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.MemExp ); } if( ZE_RESULT_SUCCESS == result ) { - result = zeGetModuleProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.Module ); + result = zeGetModuleProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.Module ); } if( ZE_RESULT_SUCCESS == result ) { - result = zeGetModuleBuildLogProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.ModuleBuildLog ); + result = zeGetModuleBuildLogProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.ModuleBuildLog ); } if( ZE_RESULT_SUCCESS == result ) { - result = zeGetPhysicalMemProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.PhysicalMem ); + result = zeGetPhysicalMemProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.PhysicalMem ); } if( ZE_RESULT_SUCCESS == result ) { - result = zeGetSamplerProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.Sampler ); + result = zeGetSamplerProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.Sampler ); } if( ZE_RESULT_SUCCESS == result ) { - result = zeGetVirtualMemProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.VirtualMem ); + result = zeGetVirtualMemProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.VirtualMem ); } if( ZE_RESULT_SUCCESS == result ) { - result = zeGetFabricEdgeExpProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.FabricEdgeExp ); + result = zeGetFabricEdgeExpProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.FabricEdgeExp ); } if( ZE_RESULT_SUCCESS == result ) { - result = zeGetFabricVertexExpProcAddrTable( ZE_API_VERSION_1_5, &zeDdiTable.FabricVertexExp ); + result = zeGetFabricVertexExpProcAddrTable( ZE_API_VERSION_CURRENT, &zeDdiTable.FabricVertexExp ); } return result; diff --git a/source/lib/ze_tracing_register_cb_libapi.cpp b/source/lib/ze_tracing_register_cb_libapi.cpp index 8373fc40..92dea941 100644 --- a/source/lib/ze_tracing_register_cb_libapi.cpp +++ b/source/lib/ze_tracing_register_cb_libapi.cpp @@ -193,6 +193,31 @@ zelTracerDriverGetExtensionFunctionAddressRegisterCallback( } +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerDriverGetLastErrorDescriptionRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnDriverGetLastErrorDescriptionCb_t pfnGetLastErrorDescriptionCb + ) { + + 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_pfnDriverGetLastErrorDescriptionCb_t pfnGetLastErrorDescriptionCb + ); + + auto func = reinterpret_cast( + GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "zelTracerDriverGetLastErrorDescriptionRegisterCallback") ); + + if(func) + return func(hTracer, callback_type, pfnGetLastErrorDescriptionCb); + + return ZE_RESULT_ERROR_UNINITIALIZED; +} + + ZE_APIEXPORT ze_result_t ZE_APICALL zelTracerDeviceGetRegisterCallback( zel_tracer_handle_t hTracer, @@ -918,6 +943,31 @@ zelTracerCommandListAppendWriteGlobalTimestampRegisterCallback( } +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerCommandListHostSynchronizeRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnCommandListHostSynchronizeCb_t pfnHostSynchronizeCb + ) { + + 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_pfnCommandListHostSynchronizeCb_t pfnHostSynchronizeCb + ); + + auto func = reinterpret_cast( + GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "zelTracerCommandListHostSynchronizeRegisterCallback") ); + + if(func) + return func(hTracer, callback_type, pfnHostSynchronizeCb); + + return ZE_RESULT_ERROR_UNINITIALIZED; +} + + ZE_APIEXPORT ze_result_t ZE_APICALL zelTracerCommandListAppendBarrierRegisterCallback( zel_tracer_handle_t hTracer, @@ -1368,6 +1418,31 @@ zelTracerEventPoolGetIpcHandleRegisterCallback( } +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerEventPoolPutIpcHandleRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnEventPoolPutIpcHandleCb_t pfnPutIpcHandleCb + ) { + + 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_pfnEventPoolPutIpcHandleCb_t pfnPutIpcHandleCb + ); + + auto func = reinterpret_cast( + GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "zelTracerEventPoolPutIpcHandleRegisterCallback") ); + + if(func) + return func(hTracer, callback_type, pfnPutIpcHandleCb); + + return ZE_RESULT_ERROR_UNINITIALIZED; +} + + ZE_APIEXPORT ze_result_t ZE_APICALL zelTracerEventPoolOpenIpcHandleRegisterCallback( zel_tracer_handle_t hTracer, @@ -2018,6 +2093,81 @@ zelTracerMemGetIpcHandleRegisterCallback( } +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerMemGetIpcHandleFromFileDescriptorExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnMemGetIpcHandleFromFileDescriptorExpCb_t pfnGetIpcHandleFromFileDescriptorExpCb + ) { + + 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_pfnMemGetIpcHandleFromFileDescriptorExpCb_t pfnGetIpcHandleFromFileDescriptorExpCb + ); + + auto func = reinterpret_cast( + GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "zelTracerMemGetIpcHandleFromFileDescriptorExpRegisterCallback") ); + + if(func) + return func(hTracer, callback_type, pfnGetIpcHandleFromFileDescriptorExpCb); + + return ZE_RESULT_ERROR_UNINITIALIZED; +} + + +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerMemGetFileDescriptorFromIpcHandleExpRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnMemGetFileDescriptorFromIpcHandleExpCb_t pfnGetFileDescriptorFromIpcHandleExpCb + ) { + + 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_pfnMemGetFileDescriptorFromIpcHandleExpCb_t pfnGetFileDescriptorFromIpcHandleExpCb + ); + + auto func = reinterpret_cast( + GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "zelTracerMemGetFileDescriptorFromIpcHandleExpRegisterCallback") ); + + if(func) + return func(hTracer, callback_type, pfnGetFileDescriptorFromIpcHandleExpCb); + + return ZE_RESULT_ERROR_UNINITIALIZED; +} + + +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerMemPutIpcHandleRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnMemPutIpcHandleCb_t pfnPutIpcHandleCb + ) { + + 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_pfnMemPutIpcHandleCb_t pfnPutIpcHandleCb + ); + + auto func = reinterpret_cast( + GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "zelTracerMemPutIpcHandleRegisterCallback") ); + + if(func) + return func(hTracer, callback_type, pfnPutIpcHandleCb); + + return ZE_RESULT_ERROR_UNINITIALIZED; +} + + ZE_APIEXPORT ze_result_t ZE_APICALL zelTracerMemOpenIpcHandleRegisterCallback( zel_tracer_handle_t hTracer, @@ -3643,4 +3793,29 @@ zelTracerFabricEdgeGetPropertiesExpRegisterCallback( } +ZE_APIEXPORT ze_result_t ZE_APICALL +zelTracerEventQueryKernelTimestampsExtRegisterCallback( + zel_tracer_handle_t hTracer, + zel_tracer_reg_t callback_type, + ze_pfnEventQueryKernelTimestampsExtCb_t pfnQueryKernelTimestampsExtCb + ) { + + 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_pfnEventQueryKernelTimestampsExtCb_t pfnQueryKernelTimestampsExtCb + ); + + auto func = reinterpret_cast( + GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "zelTracerEventQueryKernelTimestampsExtRegisterCallback") ); + + if(func) + return func(hTracer, callback_type, pfnQueryKernelTimestampsExtCb); + + return ZE_RESULT_ERROR_UNINITIALIZED; +} + + } //Extern C \ No newline at end of file diff --git a/source/lib/zel_tracing_libddi.cpp b/source/lib/zel_tracing_libddi.cpp index 1981445f..442e9702 100644 --- a/source/lib/zel_tracing_libddi.cpp +++ b/source/lib/zel_tracing_libddi.cpp @@ -23,7 +23,7 @@ namespace ze_lib { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zelGetTracerApiProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zelTracingDdiTable.Tracer); + result = getTable( ZE_API_VERSION_CURRENT, &zelTracingDdiTable.Tracer); } return result; @@ -32,7 +32,7 @@ namespace ze_lib __zedlllocal ze_result_t context_t::zelTracingInit() { ze_result_t result; - result = zelGetTracerApiProcAddrTable( ZE_API_VERSION_1_5, &zelTracingDdiTable.Tracer); + result = zelGetTracerApiProcAddrTable( ZE_API_VERSION_CURRENT, &zelTracingDdiTable.Tracer); return result; } #endif diff --git a/source/lib/zes_libddi.cpp b/source/lib/zes_libddi.cpp index 795e3a17..e970d798 100644 --- a/source/lib/zes_libddi.cpp +++ b/source/lib/zes_libddi.cpp @@ -25,133 +25,133 @@ namespace ze_lib { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetGlobalProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zesDdiTable.Global ); + result = getTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Global ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetDeviceProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zesDdiTable.Device ); + result = getTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Device ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetDriverProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zesDdiTable.Driver ); + result = getTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Driver ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetDiagnosticsProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zesDdiTable.Diagnostics ); + result = getTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Diagnostics ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetEngineProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zesDdiTable.Engine ); + result = getTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Engine ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetFabricPortProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zesDdiTable.FabricPort ); + result = getTable( ZE_API_VERSION_CURRENT, &zesDdiTable.FabricPort ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetFanProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zesDdiTable.Fan ); + result = getTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Fan ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetFirmwareProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zesDdiTable.Firmware ); + result = getTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Firmware ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetFrequencyProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zesDdiTable.Frequency ); + result = getTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Frequency ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetLedProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zesDdiTable.Led ); + result = getTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Led ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetMemoryProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zesDdiTable.Memory ); + result = getTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Memory ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetOverclockProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zesDdiTable.Overclock ); + result = getTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Overclock ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetPerformanceFactorProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zesDdiTable.PerformanceFactor ); + result = getTable( ZE_API_VERSION_CURRENT, &zesDdiTable.PerformanceFactor ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetPowerProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zesDdiTable.Power ); + result = getTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Power ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetPsuProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zesDdiTable.Psu ); + result = getTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Psu ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetRasProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zesDdiTable.Ras ); + result = getTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Ras ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetSchedulerProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zesDdiTable.Scheduler ); + result = getTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Scheduler ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetStandbyProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zesDdiTable.Standby ); + result = getTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Standby ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zesGetTemperatureProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zesDdiTable.Temperature ); + result = getTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Temperature ); } return result; @@ -163,97 +163,97 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - result = zesGetGlobalProcAddrTable( ZE_API_VERSION_1_5, &zesDdiTable.Global ); + result = zesGetGlobalProcAddrTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Global ); } if( ZE_RESULT_SUCCESS == result ) { - result = zesGetDeviceProcAddrTable( ZE_API_VERSION_1_5, &zesDdiTable.Device ); + result = zesGetDeviceProcAddrTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Device ); } if( ZE_RESULT_SUCCESS == result ) { - result = zesGetDriverProcAddrTable( ZE_API_VERSION_1_5, &zesDdiTable.Driver ); + result = zesGetDriverProcAddrTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Driver ); } if( ZE_RESULT_SUCCESS == result ) { - result = zesGetDiagnosticsProcAddrTable( ZE_API_VERSION_1_5, &zesDdiTable.Diagnostics ); + result = zesGetDiagnosticsProcAddrTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Diagnostics ); } if( ZE_RESULT_SUCCESS == result ) { - result = zesGetEngineProcAddrTable( ZE_API_VERSION_1_5, &zesDdiTable.Engine ); + result = zesGetEngineProcAddrTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Engine ); } if( ZE_RESULT_SUCCESS == result ) { - result = zesGetFabricPortProcAddrTable( ZE_API_VERSION_1_5, &zesDdiTable.FabricPort ); + result = zesGetFabricPortProcAddrTable( ZE_API_VERSION_CURRENT, &zesDdiTable.FabricPort ); } if( ZE_RESULT_SUCCESS == result ) { - result = zesGetFanProcAddrTable( ZE_API_VERSION_1_5, &zesDdiTable.Fan ); + result = zesGetFanProcAddrTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Fan ); } if( ZE_RESULT_SUCCESS == result ) { - result = zesGetFirmwareProcAddrTable( ZE_API_VERSION_1_5, &zesDdiTable.Firmware ); + result = zesGetFirmwareProcAddrTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Firmware ); } if( ZE_RESULT_SUCCESS == result ) { - result = zesGetFrequencyProcAddrTable( ZE_API_VERSION_1_5, &zesDdiTable.Frequency ); + result = zesGetFrequencyProcAddrTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Frequency ); } if( ZE_RESULT_SUCCESS == result ) { - result = zesGetLedProcAddrTable( ZE_API_VERSION_1_5, &zesDdiTable.Led ); + result = zesGetLedProcAddrTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Led ); } if( ZE_RESULT_SUCCESS == result ) { - result = zesGetMemoryProcAddrTable( ZE_API_VERSION_1_5, &zesDdiTable.Memory ); + result = zesGetMemoryProcAddrTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Memory ); } if( ZE_RESULT_SUCCESS == result ) { - result = zesGetOverclockProcAddrTable( ZE_API_VERSION_1_5, &zesDdiTable.Overclock ); + result = zesGetOverclockProcAddrTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Overclock ); } if( ZE_RESULT_SUCCESS == result ) { - result = zesGetPerformanceFactorProcAddrTable( ZE_API_VERSION_1_5, &zesDdiTable.PerformanceFactor ); + result = zesGetPerformanceFactorProcAddrTable( ZE_API_VERSION_CURRENT, &zesDdiTable.PerformanceFactor ); } if( ZE_RESULT_SUCCESS == result ) { - result = zesGetPowerProcAddrTable( ZE_API_VERSION_1_5, &zesDdiTable.Power ); + result = zesGetPowerProcAddrTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Power ); } if( ZE_RESULT_SUCCESS == result ) { - result = zesGetPsuProcAddrTable( ZE_API_VERSION_1_5, &zesDdiTable.Psu ); + result = zesGetPsuProcAddrTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Psu ); } if( ZE_RESULT_SUCCESS == result ) { - result = zesGetRasProcAddrTable( ZE_API_VERSION_1_5, &zesDdiTable.Ras ); + result = zesGetRasProcAddrTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Ras ); } if( ZE_RESULT_SUCCESS == result ) { - result = zesGetSchedulerProcAddrTable( ZE_API_VERSION_1_5, &zesDdiTable.Scheduler ); + result = zesGetSchedulerProcAddrTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Scheduler ); } if( ZE_RESULT_SUCCESS == result ) { - result = zesGetStandbyProcAddrTable( ZE_API_VERSION_1_5, &zesDdiTable.Standby ); + result = zesGetStandbyProcAddrTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Standby ); } if( ZE_RESULT_SUCCESS == result ) { - result = zesGetTemperatureProcAddrTable( ZE_API_VERSION_1_5, &zesDdiTable.Temperature ); + result = zesGetTemperatureProcAddrTable( ZE_API_VERSION_CURRENT, &zesDdiTable.Temperature ); } return result; diff --git a/source/lib/zet_libddi.cpp b/source/lib/zet_libddi.cpp index 738d6a0d..0bae500a 100644 --- a/source/lib/zet_libddi.cpp +++ b/source/lib/zet_libddi.cpp @@ -25,91 +25,91 @@ namespace ze_lib { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zetGetDeviceProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zetDdiTable.Device ); + result = getTable( ZE_API_VERSION_CURRENT, &zetDdiTable.Device ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zetGetContextProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zetDdiTable.Context ); + result = getTable( ZE_API_VERSION_CURRENT, &zetDdiTable.Context ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zetGetCommandListProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zetDdiTable.CommandList ); + result = getTable( ZE_API_VERSION_CURRENT, &zetDdiTable.CommandList ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zetGetKernelProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zetDdiTable.Kernel ); + result = getTable( ZE_API_VERSION_CURRENT, &zetDdiTable.Kernel ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zetGetModuleProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zetDdiTable.Module ); + result = getTable( ZE_API_VERSION_CURRENT, &zetDdiTable.Module ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zetGetDebugProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zetDdiTable.Debug ); + result = getTable( ZE_API_VERSION_CURRENT, &zetDdiTable.Debug ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zetGetMetricProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zetDdiTable.Metric ); + result = getTable( ZE_API_VERSION_CURRENT, &zetDdiTable.Metric ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zetGetMetricGroupProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zetDdiTable.MetricGroup ); + result = getTable( ZE_API_VERSION_CURRENT, &zetDdiTable.MetricGroup ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zetGetMetricGroupExpProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zetDdiTable.MetricGroupExp ); + result = getTable( ZE_API_VERSION_CURRENT, &zetDdiTable.MetricGroupExp ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zetGetMetricQueryProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zetDdiTable.MetricQuery ); + result = getTable( ZE_API_VERSION_CURRENT, &zetDdiTable.MetricQuery ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zetGetMetricQueryPoolProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zetDdiTable.MetricQueryPool ); + result = getTable( ZE_API_VERSION_CURRENT, &zetDdiTable.MetricQueryPool ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zetGetMetricStreamerProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zetDdiTable.MetricStreamer ); + result = getTable( ZE_API_VERSION_CURRENT, &zetDdiTable.MetricStreamer ); } if( ZE_RESULT_SUCCESS == result ) { auto getTable = reinterpret_cast( GET_FUNCTION_PTR(loader, "zetGetTracerExpProcAddrTable") ); - result = getTable( ZE_API_VERSION_1_5, &zetDdiTable.TracerExp ); + result = getTable( ZE_API_VERSION_CURRENT, &zetDdiTable.TracerExp ); } return result; @@ -121,67 +121,67 @@ namespace ze_lib if( ZE_RESULT_SUCCESS == result ) { - result = zetGetDeviceProcAddrTable( ZE_API_VERSION_1_5, &zetDdiTable.Device ); + result = zetGetDeviceProcAddrTable( ZE_API_VERSION_CURRENT, &zetDdiTable.Device ); } if( ZE_RESULT_SUCCESS == result ) { - result = zetGetContextProcAddrTable( ZE_API_VERSION_1_5, &zetDdiTable.Context ); + result = zetGetContextProcAddrTable( ZE_API_VERSION_CURRENT, &zetDdiTable.Context ); } if( ZE_RESULT_SUCCESS == result ) { - result = zetGetCommandListProcAddrTable( ZE_API_VERSION_1_5, &zetDdiTable.CommandList ); + result = zetGetCommandListProcAddrTable( ZE_API_VERSION_CURRENT, &zetDdiTable.CommandList ); } if( ZE_RESULT_SUCCESS == result ) { - result = zetGetKernelProcAddrTable( ZE_API_VERSION_1_5, &zetDdiTable.Kernel ); + result = zetGetKernelProcAddrTable( ZE_API_VERSION_CURRENT, &zetDdiTable.Kernel ); } if( ZE_RESULT_SUCCESS == result ) { - result = zetGetModuleProcAddrTable( ZE_API_VERSION_1_5, &zetDdiTable.Module ); + result = zetGetModuleProcAddrTable( ZE_API_VERSION_CURRENT, &zetDdiTable.Module ); } if( ZE_RESULT_SUCCESS == result ) { - result = zetGetDebugProcAddrTable( ZE_API_VERSION_1_5, &zetDdiTable.Debug ); + result = zetGetDebugProcAddrTable( ZE_API_VERSION_CURRENT, &zetDdiTable.Debug ); } if( ZE_RESULT_SUCCESS == result ) { - result = zetGetMetricProcAddrTable( ZE_API_VERSION_1_5, &zetDdiTable.Metric ); + result = zetGetMetricProcAddrTable( ZE_API_VERSION_CURRENT, &zetDdiTable.Metric ); } if( ZE_RESULT_SUCCESS == result ) { - result = zetGetMetricGroupProcAddrTable( ZE_API_VERSION_1_5, &zetDdiTable.MetricGroup ); + result = zetGetMetricGroupProcAddrTable( ZE_API_VERSION_CURRENT, &zetDdiTable.MetricGroup ); } if( ZE_RESULT_SUCCESS == result ) { - result = zetGetMetricGroupExpProcAddrTable( ZE_API_VERSION_1_5, &zetDdiTable.MetricGroupExp ); + result = zetGetMetricGroupExpProcAddrTable( ZE_API_VERSION_CURRENT, &zetDdiTable.MetricGroupExp ); } if( ZE_RESULT_SUCCESS == result ) { - result = zetGetMetricQueryProcAddrTable( ZE_API_VERSION_1_5, &zetDdiTable.MetricQuery ); + result = zetGetMetricQueryProcAddrTable( ZE_API_VERSION_CURRENT, &zetDdiTable.MetricQuery ); } if( ZE_RESULT_SUCCESS == result ) { - result = zetGetMetricQueryPoolProcAddrTable( ZE_API_VERSION_1_5, &zetDdiTable.MetricQueryPool ); + result = zetGetMetricQueryPoolProcAddrTable( ZE_API_VERSION_CURRENT, &zetDdiTable.MetricQueryPool ); } if( ZE_RESULT_SUCCESS == result ) { - result = zetGetMetricStreamerProcAddrTable( ZE_API_VERSION_1_5, &zetDdiTable.MetricStreamer ); + result = zetGetMetricStreamerProcAddrTable( ZE_API_VERSION_CURRENT, &zetDdiTable.MetricStreamer ); } if( ZE_RESULT_SUCCESS == result ) { - result = zetGetTracerExpProcAddrTable( ZE_API_VERSION_1_5, &zetDdiTable.TracerExp ); + result = zetGetTracerExpProcAddrTable( ZE_API_VERSION_CURRENT, &zetDdiTable.TracerExp ); } return result; diff --git a/source/loader/ze_ldrddi.cpp b/source/loader/ze_ldrddi.cpp index 5566e8b5..f73f46f8 100644 --- a/source/loader/ze_ldrddi.cpp +++ b/source/loader/ze_ldrddi.cpp @@ -255,6 +255,32 @@ namespace loader return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeDriverGetLastErrorDescription + __zedlllocal ze_result_t ZE_APICALL + zeDriverGetLastErrorDescription( + ze_driver_handle_t hDriver, ///< [in] handle of the driver instance + const char** ppString ///< [in,out] pointer to a null-terminated array of characters describing + ///< cause of error. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hDriver )->dditable; + auto pfnGetLastErrorDescription = dditable->ze.Driver.pfnGetLastErrorDescription; + if( nullptr == pfnGetLastErrorDescription ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hDriver = reinterpret_cast( hDriver )->handle; + + // forward to device-driver + result = pfnGetLastErrorDescription( hDriver, ppString ); + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeDeviceGet __zedlllocal ze_result_t ZE_APICALL @@ -1209,6 +1235,37 @@ namespace loader return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeCommandListHostSynchronize + __zedlllocal ze_result_t ZE_APICALL + zeCommandListHostSynchronize( + ze_command_list_handle_t hCommandList, ///< [in] handle of the immediate command list + uint64_t timeout ///< [in] if non-zero, then indicates the maximum time (in nanoseconds) to + ///< yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY; + ///< if zero, then immediately returns the status of the immediate command list; + ///< if UINT64_MAX, then function will not return until complete or device + ///< is lost. + ///< Due to external dependencies, timeout may be rounded to the closest + ///< value allowed by the accuracy of those dependencies. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hCommandList )->dditable; + auto pfnHostSynchronize = dditable->ze.CommandList.pfnHostSynchronize; + if( nullptr == pfnHostSynchronize ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hCommandList = reinterpret_cast( hCommandList )->handle; + + // forward to device-driver + result = pfnHostSynchronize( hCommandList, timeout ); + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeCommandListAppendBarrier __zedlllocal ze_result_t ZE_APICALL @@ -1910,6 +1967,32 @@ namespace loader return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventPoolPutIpcHandle + __zedlllocal ze_result_t ZE_APICALL + zeEventPoolPutIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object associated with the IPC event pool + ///< handle + ze_ipc_event_pool_handle_t hIpc ///< [in] IPC event pool handle + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hContext )->dditable; + auto pfnPutIpcHandle = dditable->ze.EventPool.pfnPutIpcHandle; + if( nullptr == pfnPutIpcHandle ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hContext = reinterpret_cast( hContext )->handle; + + // forward to device-driver + result = pfnPutIpcHandle( hContext, hIpc ); + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeEventPoolOpenIpcHandle __zedlllocal ze_result_t ZE_APICALL @@ -2722,6 +2805,83 @@ namespace loader return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemGetIpcHandleFromFileDescriptorExp + __zedlllocal ze_result_t ZE_APICALL + zeMemGetIpcHandleFromFileDescriptorExp( + ze_context_handle_t hContext, ///< [in] handle of the context object + uint64_t handle, ///< [in] file descriptor + ze_ipc_mem_handle_t* pIpcHandle ///< [out] Returned IPC memory handle + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hContext )->dditable; + auto pfnGetIpcHandleFromFileDescriptorExp = dditable->ze.MemExp.pfnGetIpcHandleFromFileDescriptorExp; + if( nullptr == pfnGetIpcHandleFromFileDescriptorExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hContext = reinterpret_cast( hContext )->handle; + + // forward to device-driver + result = pfnGetIpcHandleFromFileDescriptorExp( hContext, handle, pIpcHandle ); + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemGetFileDescriptorFromIpcHandleExp + __zedlllocal ze_result_t ZE_APICALL + zeMemGetFileDescriptorFromIpcHandleExp( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_ipc_mem_handle_t ipcHandle, ///< [in] IPC memory handle + uint64_t* pHandle ///< [out] Returned file descriptor + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hContext )->dditable; + auto pfnGetFileDescriptorFromIpcHandleExp = dditable->ze.MemExp.pfnGetFileDescriptorFromIpcHandleExp; + if( nullptr == pfnGetFileDescriptorFromIpcHandleExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hContext = reinterpret_cast( hContext )->handle; + + // forward to device-driver + result = pfnGetFileDescriptorFromIpcHandleExp( hContext, ipcHandle, pHandle ); + + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeMemPutIpcHandle + __zedlllocal ze_result_t ZE_APICALL + zeMemPutIpcHandle( + ze_context_handle_t hContext, ///< [in] handle of the context object + ze_ipc_mem_handle_t handle ///< [in] IPC memory handle + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hContext )->dditable; + auto pfnPutIpcHandle = dditable->ze.Mem.pfnPutIpcHandle; + if( nullptr == pfnPutIpcHandle ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hContext = reinterpret_cast( hContext )->handle; + + // forward to device-driver + result = pfnPutIpcHandle( hContext, handle ); + + return result; + } + /////////////////////////////////////////////////////////////////////////////// /// @brief Intercept function for zeMemOpenIpcHandle __zedlllocal ze_result_t ZE_APICALL @@ -4938,6 +5098,48 @@ namespace loader return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zeEventQueryKernelTimestampsExt + __zedlllocal ze_result_t ZE_APICALL + zeEventQueryKernelTimestampsExt( + ze_event_handle_t hEvent, ///< [in] handle of the event + ze_device_handle_t hDevice, ///< [in] handle of the device to query + uint32_t* pCount, ///< [in,out] pointer to the number of event packets available. + ///< - This value is implementation specific. + ///< - if `*pCount` is zero, then the driver shall update the value with + ///< the total number of event packets available. + ///< - if `*pCount` is greater than the number of event packets + ///< available, the driver shall update the value with the correct value. + ///< - Buffer(s) for query results must be sized by the application to + ///< accommodate a minimum of `*pCount` elements. + ze_event_query_kernel_timestamps_results_ext_properties_t* pResults ///< [in][optional] pointer to event query properties structure(s). + ///< - This parameter may be null when `*pCount` is zero. + ///< - if `*pCount` is less than the number of event packets available, + ///< the driver may only update `*pCount` elements, starting at element zero. + ///< - if `*pCount` is greater than the number of event packets + ///< available, the driver may only update the valid elements. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hEvent )->dditable; + auto pfnQueryKernelTimestampsExt = dditable->ze.Event.pfnQueryKernelTimestampsExt; + if( nullptr == pfnQueryKernelTimestampsExt ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hEvent = reinterpret_cast( hEvent )->handle; + + // convert loader handle to driver handle + hDevice = reinterpret_cast( hDevice )->handle; + + // forward to device-driver + result = pfnQueryKernelTimestampsExt( hEvent, hDevice, pCount, pResults ); + + return result; + } + } // namespace loader #if defined(__cplusplus) @@ -5088,6 +5290,7 @@ zeGetDriverProcAddrTable( pDdiTable->pfnGetIpcProperties = loader::zeDriverGetIpcProperties; pDdiTable->pfnGetExtensionProperties = loader::zeDriverGetExtensionProperties; pDdiTable->pfnGetExtensionFunctionAddress = loader::zeDriverGetExtensionFunctionAddress; + pDdiTable->pfnGetLastErrorDescription = loader::zeDriverGetLastErrorDescription; } else { @@ -5562,6 +5765,7 @@ zeGetCommandListProcAddrTable( pDdiTable->pfnAppendLaunchMultipleKernelsIndirect = loader::zeCommandListAppendLaunchMultipleKernelsIndirect; pDdiTable->pfnAppendImageCopyToMemoryExt = loader::zeCommandListAppendImageCopyToMemoryExt; pDdiTable->pfnAppendImageCopyFromMemoryExt = loader::zeCommandListAppendImageCopyFromMemoryExt; + pDdiTable->pfnHostSynchronize = loader::zeCommandListHostSynchronize; } else { @@ -5653,6 +5857,7 @@ zeGetEventProcAddrTable( pDdiTable->pfnQueryStatus = loader::zeEventQueryStatus; pDdiTable->pfnHostReset = loader::zeEventHostReset; pDdiTable->pfnQueryKernelTimestamp = loader::zeEventQueryKernelTimestamp; + pDdiTable->pfnQueryKernelTimestampsExt = loader::zeEventQueryKernelTimestampsExt; } else { @@ -5821,6 +6026,7 @@ zeGetEventPoolProcAddrTable( pDdiTable->pfnGetIpcHandle = loader::zeEventPoolGetIpcHandle; pDdiTable->pfnOpenIpcHandle = loader::zeEventPoolOpenIpcHandle; pDdiTable->pfnCloseIpcHandle = loader::zeEventPoolCloseIpcHandle; + pDdiTable->pfnPutIpcHandle = loader::zeEventPoolPutIpcHandle; } else { @@ -6349,6 +6555,7 @@ zeGetMemProcAddrTable( pDdiTable->pfnOpenIpcHandle = loader::zeMemOpenIpcHandle; pDdiTable->pfnCloseIpcHandle = loader::zeMemCloseIpcHandle; pDdiTable->pfnFreeExt = loader::zeMemFreeExt; + pDdiTable->pfnPutIpcHandle = loader::zeMemPutIpcHandle; } else { @@ -6380,6 +6587,86 @@ zeGetMemProcAddrTable( return result; } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's MemExp table +/// with current process' addresses +/// +/// @returns +/// - ::ZE_RESULT_SUCCESS +/// - ::ZE_RESULT_ERROR_UNINITIALIZED +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION +ZE_DLLEXPORT ze_result_t ZE_APICALL +zeGetMemExpProcAddrTable( + ze_api_version_t version, ///< [in] API version requested + ze_mem_exp_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers + ) +{ + if( loader::context->drivers.size() < 1 ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + if( nullptr == pDdiTable ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( loader::context->version < version ) + return ZE_RESULT_ERROR_UNSUPPORTED_VERSION; + + ze_result_t result = ZE_RESULT_SUCCESS; + + bool atLeastOneDriverValid = false; + // Load the device-driver DDI tables + for( auto& drv : loader::context->drivers ) + { + if(drv.initStatus != ZE_RESULT_SUCCESS) + continue; + auto getTable = reinterpret_cast( + GET_FUNCTION_PTR( drv.handle, "zeGetMemExpProcAddrTable") ); + if(!getTable) + continue; + auto getTableResult = getTable( version, &drv.dditable.ze.MemExp); + if(getTableResult == ZE_RESULT_SUCCESS) + atLeastOneDriverValid = true; + } + + + if( ZE_RESULT_SUCCESS == result ) + { + if( ( loader::context->drivers.size() > 1 ) || loader::context->forceIntercept ) + { + // return pointers to loader's DDIs + pDdiTable->pfnGetIpcHandleFromFileDescriptorExp = loader::zeMemGetIpcHandleFromFileDescriptorExp; + pDdiTable->pfnGetFileDescriptorFromIpcHandleExp = loader::zeMemGetFileDescriptorFromIpcHandleExp; + } + else + { + // return pointers directly to driver's DDIs + *pDdiTable = loader::context->drivers.front().dditable.ze.MemExp; + } + } + + // If the validation layer is enabled, then intercept the loader's DDIs + if(( ZE_RESULT_SUCCESS == result ) && ( nullptr != loader::context->validationLayer )) + { + auto getTable = reinterpret_cast( + GET_FUNCTION_PTR(loader::context->validationLayer, "zeGetMemExpProcAddrTable") ); + if(!getTable) + return ZE_RESULT_ERROR_UNINITIALIZED; + result = getTable( version, pDdiTable ); + } + + // If the API tracing layer is enabled, then intercept the loader's DDIs + if(( ZE_RESULT_SUCCESS == result ) && ( nullptr != loader::context->tracingLayer )) + { + auto getTable = reinterpret_cast( + GET_FUNCTION_PTR(loader::context->tracingLayer, "zeGetMemExpProcAddrTable") ); + if(!getTable) + return ZE_RESULT_ERROR_UNINITIALIZED; + result = getTable( version, pDdiTable ); + } + + return result; +} + /////////////////////////////////////////////////////////////////////////////// /// @brief Exported function for filling application's Module table /// with current process' addresses diff --git a/source/loader/ze_loader_internal.h b/source/loader/ze_loader_internal.h index 95cda548..c9749709 100644 --- a/source/loader/ze_loader_internal.h +++ b/source/loader/ze_loader_internal.h @@ -38,7 +38,7 @@ namespace loader class context_t { public: - ze_api_version_t version = ZE_API_VERSION_1_5; + ze_api_version_t version = ZE_API_VERSION_CURRENT; driver_vector_t drivers;