diff --git a/CHANGELOG.md b/CHANGELOG.md index cd4f401a..1febc6de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Level zero loader changelog +## v1.9.9 +* Update to spec 1.5.17 +* Fix for calling zeInit in zesInit path +* Added readme for validation layer +* Refactor of validation layer to prepare for future enhancements +* Updated Contributing Document with more guidance + ## v1.9.4 * Add support for Level Zero spec v1.5 * Fix some compilation issues with windows non-vc compiler diff --git a/include/ze.py b/include/ze.py index ce1c943d..abee040f 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.8 + @version v1.5-r1.5.17 """ import platform @@ -517,6 +517,7 @@ class ze_device_properties_t(Structure): ("type", ze_device_type_t), ## [out] generic device type ("vendorId", c_ulong), ## [out] vendor id from PCI configuration ("deviceId", c_ulong), ## [out] device id from PCI configuration + ## Note, the device id uses little-endian format. ("flags", ze_device_property_flags_t), ## [out] 0 (none) or a valid combination of ::ze_device_property_flag_t ("subdeviceId", c_ulong), ## [out] sub-device id. Only valid if ::ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE ## is set. @@ -2839,6 +2840,38 @@ class ze_device_ip_version_ext_t(Structure): ## version than older devices. ] +############################################################################### +## @brief Kernel Max Group Size Properties Extension Name +ZE_KERNEL_MAX_GROUP_SIZE_PROPERTIES_EXT_NAME = "ZE_extension_kernel_max_group_size_properties" + +############################################################################### +## @brief Kernel Max Group Size Properties Extension Version(s) +class ze_kernel_max_group_size_properties_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_kernel_max_group_size_properties_ext_version_t(c_int): + def __str__(self): + return str(ze_kernel_max_group_size_properties_ext_version_v(self.value)) + + +############################################################################### +## @brief Additional kernel max group size properties +## +## @details +## - This structure may be passed to ::zeKernelGetProperties, via the +## `pNext` member of ::ze_kernel_properties_t, to query additional kernel +## max group size properties. +class ze_kernel_max_group_size_properties_ext_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). + ("maxGroupSize", c_ulong) ## [out] maximum group size that can be used to execute the kernel. This + ## value may be less than or equal to the `maxTotalGroupSize` member of + ## ::ze_device_compute_properties_t. + ] + ############################################################################### ## @brief Sub-Allocations Properties Extension Name ZE_SUB_ALLOCATIONS_EXP_NAME = "ZE_experimental_sub_allocations" diff --git a/include/ze_api.h b/include/ze_api.h index d31c947e..04626d73 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.8 + * @version v1.5-r1.5.17 * */ #ifndef _ZE_API_H @@ -741,6 +741,10 @@ typedef struct _ze_device_memory_ext_properties_t ze_device_memory_ext_propertie /// @brief Forward-declare ze_device_ip_version_ext_t typedef struct _ze_device_ip_version_ext_t ze_device_ip_version_ext_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare ze_kernel_max_group_size_properties_ext_t +typedef struct _ze_kernel_max_group_size_properties_ext_t ze_kernel_max_group_size_properties_ext_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Forward-declare ze_sub_allocation_t typedef struct _ze_sub_allocation_t ze_sub_allocation_t; @@ -1192,6 +1196,7 @@ typedef struct _ze_device_properties_t ze_device_type_t type; ///< [out] generic device type uint32_t vendorId; ///< [out] vendor id from PCI configuration uint32_t deviceId; ///< [out] device id from PCI configuration + ///< Note, the device id uses little-endian format. ze_device_property_flags_t flags; ///< [out] 0 (none) or a valid combination of ::ze_device_property_flag_t uint32_t subdeviceId; ///< [out] sub-device id. Only valid if ::ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE ///< is set. @@ -5449,14 +5454,18 @@ zeKernelGetIndirectAccess( /// + `nullptr == hKernel` /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER /// + `nullptr == pSize` -/// + `nullptr == pString` ZE_APIEXPORT ze_result_t ZE_APICALL zeKernelGetSourceAttributes( ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object - uint32_t* pSize, ///< [in,out] pointer to size of string in bytes. - char** pString ///< [in,out] pointer to null-terminated string, whose lifetime is tied to - ///< the kernel object, where kernel source attributes are separated by - ///< space. + uint32_t* pSize, ///< [in,out] pointer to size of string in bytes, including + ///< null-terminating character. + char** pString ///< [in,out][optional] pointer to application-managed character array + ///< (string data). + ///< If NULL, the string length of the kernel source attributes, including + ///< a null-terminating character, is returned in pSize. + ///< Otherwise, pString must point to valid application memory that is + ///< greater than or equal to *pSize bytes in length, and on return the + ///< pointed-to string will contain a space-separated list of kernel source attributes. ); /////////////////////////////////////////////////////////////////////////////// @@ -8482,6 +8491,47 @@ typedef struct _ze_device_ip_version_ext_t } ze_device_ip_version_ext_t; +#if !defined(__GNUC__) +#pragma endregion +#endif +// Intel 'oneAPI' Level-Zero Extension for querying kernel max group size properties. +#if !defined(__GNUC__) +#pragma region kernelMaxGroupSizeProperties +#endif +/////////////////////////////////////////////////////////////////////////////// +#ifndef ZE_KERNEL_MAX_GROUP_SIZE_PROPERTIES_EXT_NAME +/// @brief Kernel Max Group Size Properties Extension Name +#define ZE_KERNEL_MAX_GROUP_SIZE_PROPERTIES_EXT_NAME "ZE_extension_kernel_max_group_size_properties" +#endif // ZE_KERNEL_MAX_GROUP_SIZE_PROPERTIES_EXT_NAME + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Kernel Max Group Size Properties Extension Version(s) +typedef enum _ze_kernel_max_group_size_properties_ext_version_t +{ + ZE_KERNEL_MAX_GROUP_SIZE_PROPERTIES_EXT_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 + ZE_KERNEL_MAX_GROUP_SIZE_PROPERTIES_EXT_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 0 ), ///< latest known version + ZE_KERNEL_MAX_GROUP_SIZE_PROPERTIES_EXT_VERSION_FORCE_UINT32 = 0x7fffffff + +} ze_kernel_max_group_size_properties_ext_version_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Additional kernel max group size properties +/// +/// @details +/// - This structure may be passed to ::zeKernelGetProperties, via the +/// `pNext` member of ::ze_kernel_properties_t, to query additional kernel +/// max group size properties. +typedef struct _ze_kernel_max_group_size_properties_ext_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). + uint32_t maxGroupSize; ///< [out] maximum group size that can be used to execute the kernel. This + ///< value may be less than or equal to the `maxTotalGroupSize` member of + ///< ::ze_device_compute_properties_t. + +} ze_kernel_max_group_size_properties_ext_t; + #if !defined(__GNUC__) #pragma endregion #endif diff --git a/include/ze_ddi.h b/include/ze_ddi.h index d87fa653..78c55d43 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.8 + * @version v1.5-r1.5.17 * */ #ifndef _ZE_DDI_H diff --git a/include/zes.py b/include/zes.py index 060633fa..68b14405 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.8 + @version v1.5-r1.5.17 """ import platform @@ -1513,7 +1513,7 @@ class zes_mem_bandwidth_t(Structure): ("readCounter", c_ulonglong), ## [out] Total bytes read from memory ("writeCounter", c_ulonglong), ## [out] Total bytes written to memory ("maxBandwidth", c_ulonglong), ## [out] Current maximum bandwidth in units of bytes/sec - ("timestamp", c_ulonglong) ## [out] The timestamp when these measurements were sampled. + ("timestamp", c_ulonglong) ## [out] The timestamp in microseconds when these measurements were sampled. ## This timestamp should only be used to calculate delta time between ## snapshots of this structure. ## Never take the delta of this timestamp with the timestamp from a @@ -1781,7 +1781,7 @@ def __str__(self): ############################################################################### ## @brief The maximum number of categories -ZES_MAX_RAS_ERROR_CATEGORY_COUNT = 7 +ZES_MAX_RAS_ERROR_CATEGORY_COUNT = 10 ############################################################################### ## @brief RAS properties diff --git a/include/zes_api.h b/include/zes_api.h index fc8428af..b0868763 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.8 + * @version v1.5-r1.5.17 * */ #ifndef _ZES_API_H @@ -4223,7 +4223,7 @@ typedef struct _zes_mem_bandwidth_t uint64_t readCounter; ///< [out] Total bytes read from memory uint64_t writeCounter; ///< [out] Total bytes written to memory uint64_t maxBandwidth; ///< [out] Current maximum bandwidth in units of bytes/sec - uint64_t timestamp; ///< [out] The timestamp when these measurements were sampled. + uint64_t timestamp; ///< [out] The timestamp in microseconds when these measurements were sampled. ///< This timestamp should only be used to calculate delta time between ///< snapshots of this structure. ///< Never take the delta of this timestamp with the timestamp from a @@ -5050,7 +5050,7 @@ typedef enum _zes_ras_error_cat_t /////////////////////////////////////////////////////////////////////////////// #ifndef ZES_MAX_RAS_ERROR_CATEGORY_COUNT /// @brief The maximum number of categories -#define ZES_MAX_RAS_ERROR_CATEGORY_COUNT 7 +#define ZES_MAX_RAS_ERROR_CATEGORY_COUNT 10 #endif // ZES_MAX_RAS_ERROR_CATEGORY_COUNT /////////////////////////////////////////////////////////////////////////////// diff --git a/include/zes_ddi.h b/include/zes_ddi.h index 6c6f2345..36f89ad8 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.8 + * @version v1.5-r1.5.17 * */ #ifndef _ZES_DDI_H diff --git a/include/zet.py b/include/zet.py index 603547c2..cdcb7b17 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.8 + @version v1.5-r1.5.17 """ import platform @@ -90,6 +90,7 @@ class zet_structure_type_v(IntEnum): DEVICE_DEBUG_PROPERTIES = 0x6 ## ::zet_device_debug_properties_t DEBUG_MEMORY_SPACE_DESC = 0x7 ## ::zet_debug_memory_space_desc_t DEBUG_REGSET_PROPERTIES = 0x8 ## ::zet_debug_regset_properties_t + GLOBAL_METRICS_TIMESTAMPS_EXP_PROPERTIES = 0x9 ## ::zet_metric_global_timestamps_resolution_exp_t TRACER_EXP_DESC = 0x00010001 ## ::zet_tracer_exp_desc_t class zet_structure_type_t(c_int): @@ -573,6 +574,38 @@ def __str__(self): return str(ze_calculate_multiple_metrics_exp_version_v(self.value)) +############################################################################### +## @brief Global Metric Timestamps Experimental Extension Name +ZET_GLOBAL_METRICS_TIMESTAMPS_EXP_NAME = "ZET_experimental_global_metric_timestamps" + +############################################################################### +## @brief Global Metric Timestamps Experimental Extension Version(s) +class ze_metric_global_timestamps_exp_version_v(IntEnum): + _1_0 = ZE_MAKE_VERSION( 1, 0 ) ## version 1.0 + CURRENT = ZE_MAKE_VERSION( 1, 0 ) ## latest known version + +class ze_metric_global_timestamps_exp_version_t(c_int): + def __str__(self): + return str(ze_metric_global_timestamps_exp_version_v(self.value)) + + +############################################################################### +## @brief Metric timestamps resolution +## +## @details +## - This structure may be returned from ::zetMetricGroupGetProperties via +## `pNext` member of ::zet_metric_group_properties_t +## - Used for mapping metric timestamps to other timers. +class zet_metric_global_timestamps_resolution_exp_t(Structure): + _fields_ = [ + ("stype", ze_structure_type_t), ## [in] type of this structure + ("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific + ## structure (i.e. contains sType and pNext). + ("timerResolution", c_ulonglong), ## [out] Returns the resolution of device timer in nanoseconds used for + ## timestamps. + ("timestampValidBits", c_ulonglong) ## [out] Returns the number of valid bits in the timestamp value. + ] + ############################################################################### __use_win_types = "Windows" == platform.uname()[0] @@ -675,6 +708,29 @@ class _zet_kernel_dditable_t(Structure): ("pfnGetProfileInfo", c_void_p) ## _zetKernelGetProfileInfo_t ] +############################################################################### +## @brief Function-pointer for zetMetricGet +if __use_win_types: + _zetMetricGet_t = WINFUNCTYPE( ze_result_t, zet_metric_group_handle_t, POINTER(c_ulong), POINTER(zet_metric_handle_t) ) +else: + _zetMetricGet_t = CFUNCTYPE( ze_result_t, zet_metric_group_handle_t, POINTER(c_ulong), POINTER(zet_metric_handle_t) ) + +############################################################################### +## @brief Function-pointer for zetMetricGetProperties +if __use_win_types: + _zetMetricGetProperties_t = WINFUNCTYPE( ze_result_t, zet_metric_handle_t, POINTER(zet_metric_properties_t) ) +else: + _zetMetricGetProperties_t = CFUNCTYPE( ze_result_t, zet_metric_handle_t, POINTER(zet_metric_properties_t) ) + + +############################################################################### +## @brief Table of Metric functions pointers +class _zet_metric_dditable_t(Structure): + _fields_ = [ + ("pfnGet", c_void_p), ## _zetMetricGet_t + ("pfnGetProperties", c_void_p) ## _zetMetricGetProperties_t + ] + ############################################################################### ## @brief Function-pointer for zetMetricGroupGet if __use_win_types: @@ -713,35 +769,20 @@ class _zet_metric_group_dditable_t(Structure): else: _zetMetricGroupCalculateMultipleMetricValuesExp_t = CFUNCTYPE( ze_result_t, zet_metric_group_handle_t, zet_metric_group_calculation_type_t, c_size_t, POINTER(c_ubyte), POINTER(c_ulong), POINTER(c_ulong), POINTER(c_ulong), POINTER(zet_typed_value_t) ) - ############################################################################### -## @brief Table of MetricGroupExp functions pointers -class _zet_metric_group_exp_dditable_t(Structure): - _fields_ = [ - ("pfnCalculateMultipleMetricValuesExp", c_void_p) ## _zetMetricGroupCalculateMultipleMetricValuesExp_t - ] - -############################################################################### -## @brief Function-pointer for zetMetricGet +## @brief Function-pointer for zetMetricGroupGetGlobalTimestampsExp if __use_win_types: - _zetMetricGet_t = WINFUNCTYPE( ze_result_t, zet_metric_group_handle_t, POINTER(c_ulong), POINTER(zet_metric_handle_t) ) + _zetMetricGroupGetGlobalTimestampsExp_t = WINFUNCTYPE( ze_result_t, zet_metric_group_handle_t, ze_bool_t, POINTER(c_ulonglong), POINTER(c_ulonglong) ) else: - _zetMetricGet_t = CFUNCTYPE( ze_result_t, zet_metric_group_handle_t, POINTER(c_ulong), POINTER(zet_metric_handle_t) ) - -############################################################################### -## @brief Function-pointer for zetMetricGetProperties -if __use_win_types: - _zetMetricGetProperties_t = WINFUNCTYPE( ze_result_t, zet_metric_handle_t, POINTER(zet_metric_properties_t) ) -else: - _zetMetricGetProperties_t = CFUNCTYPE( ze_result_t, zet_metric_handle_t, POINTER(zet_metric_properties_t) ) + _zetMetricGroupGetGlobalTimestampsExp_t = CFUNCTYPE( ze_result_t, zet_metric_group_handle_t, ze_bool_t, POINTER(c_ulonglong), POINTER(c_ulonglong) ) ############################################################################### -## @brief Table of Metric functions pointers -class _zet_metric_dditable_t(Structure): +## @brief Table of MetricGroupExp functions pointers +class _zet_metric_group_exp_dditable_t(Structure): _fields_ = [ - ("pfnGet", c_void_p), ## _zetMetricGet_t - ("pfnGetProperties", c_void_p) ## _zetMetricGetProperties_t + ("pfnCalculateMultipleMetricValuesExp", c_void_p), ## _zetMetricGroupCalculateMultipleMetricValuesExp_t + ("pfnGetGlobalTimestampsExp", c_void_p) ## _zetMetricGroupGetGlobalTimestampsExp_t ] ############################################################################### @@ -995,9 +1036,9 @@ class _zet_dditable_t(Structure): ("CommandList", _zet_command_list_dditable_t), ("Module", _zet_module_dditable_t), ("Kernel", _zet_kernel_dditable_t), + ("Metric", _zet_metric_dditable_t), ("MetricGroup", _zet_metric_group_dditable_t), ("MetricGroupExp", _zet_metric_group_exp_dditable_t), - ("Metric", _zet_metric_dditable_t), ("MetricStreamer", _zet_metric_streamer_dditable_t), ("MetricQueryPool", _zet_metric_query_pool_dditable_t), ("MetricQuery", _zet_metric_query_dditable_t), @@ -1071,6 +1112,17 @@ def __init__(self, version : ze_api_version_t): # attach function interface to function address self.zetKernelGetProfileInfo = _zetKernelGetProfileInfo_t(self.__dditable.Kernel.pfnGetProfileInfo) + # call driver to get function pointers + _Metric = _zet_metric_dditable_t() + r = ze_result_v(self.__dll.zetGetMetricProcAddrTable(version, byref(_Metric))) + if r != ze_result_v.SUCCESS: + raise Exception(r) + self.__dditable.Metric = _Metric + + # attach function interface to function address + self.zetMetricGet = _zetMetricGet_t(self.__dditable.Metric.pfnGet) + self.zetMetricGetProperties = _zetMetricGetProperties_t(self.__dditable.Metric.pfnGetProperties) + # call driver to get function pointers _MetricGroup = _zet_metric_group_dditable_t() r = ze_result_v(self.__dll.zetGetMetricGroupProcAddrTable(version, byref(_MetricGroup))) @@ -1092,17 +1144,7 @@ def __init__(self, version : ze_api_version_t): # attach function interface to function address self.zetMetricGroupCalculateMultipleMetricValuesExp = _zetMetricGroupCalculateMultipleMetricValuesExp_t(self.__dditable.MetricGroupExp.pfnCalculateMultipleMetricValuesExp) - - # call driver to get function pointers - _Metric = _zet_metric_dditable_t() - r = ze_result_v(self.__dll.zetGetMetricProcAddrTable(version, byref(_Metric))) - if r != ze_result_v.SUCCESS: - raise Exception(r) - self.__dditable.Metric = _Metric - - # attach function interface to function address - self.zetMetricGet = _zetMetricGet_t(self.__dditable.Metric.pfnGet) - self.zetMetricGetProperties = _zetMetricGetProperties_t(self.__dditable.Metric.pfnGetProperties) + self.zetMetricGroupGetGlobalTimestampsExp = _zetMetricGroupGetGlobalTimestampsExp_t(self.__dditable.MetricGroupExp.pfnGetGlobalTimestampsExp) # call driver to get function pointers _MetricStreamer = _zet_metric_streamer_dditable_t() diff --git a/include/zet_api.h b/include/zet_api.h index 3947fdab..5e01ed7a 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.8 + * @version v1.5-r1.5.17 * */ #ifndef _ZET_API_H @@ -89,6 +89,7 @@ typedef enum _zet_structure_type_t ZET_STRUCTURE_TYPE_DEVICE_DEBUG_PROPERTIES = 0x6, ///< ::zet_device_debug_properties_t ZET_STRUCTURE_TYPE_DEBUG_MEMORY_SPACE_DESC = 0x7, ///< ::zet_debug_memory_space_desc_t ZET_STRUCTURE_TYPE_DEBUG_REGSET_PROPERTIES = 0x8, ///< ::zet_debug_regset_properties_t + ZET_STRUCTURE_TYPE_GLOBAL_METRICS_TIMESTAMPS_EXP_PROPERTIES = 0x9, ///< ::zet_metric_global_timestamps_resolution_exp_t ZET_STRUCTURE_TYPE_TRACER_EXP_DESC = 0x00010001,///< ::zet_tracer_exp_desc_t ZET_STRUCTURE_TYPE_FORCE_UINT32 = 0x7fffffff @@ -236,6 +237,10 @@ typedef struct _zet_profile_register_sequence_t zet_profile_register_sequence_t; /// @brief Forward-declare zet_tracer_exp_desc_t typedef struct _zet_tracer_exp_desc_t zet_tracer_exp_desc_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Forward-declare zet_metric_global_timestamps_resolution_exp_t +typedef struct _zet_metric_global_timestamps_resolution_exp_t zet_metric_global_timestamps_resolution_exp_t; + #if !defined(__GNUC__) #pragma endregion @@ -1854,6 +1859,75 @@ zetMetricGroupCalculateMultipleMetricValuesExp( ///< then driver shall only calculate that number of metric values. ); +#if !defined(__GNUC__) +#pragma endregion +#endif +// Intel 'oneAPI' Level-Zero Tool Experimental Extension for Global Metric Timestamps +#if !defined(__GNUC__) +#pragma region GlobalTimestamps +#endif +/////////////////////////////////////////////////////////////////////////////// +#ifndef ZET_GLOBAL_METRICS_TIMESTAMPS_EXP_NAME +/// @brief Global Metric Timestamps Experimental Extension Name +#define ZET_GLOBAL_METRICS_TIMESTAMPS_EXP_NAME "ZET_experimental_global_metric_timestamps" +#endif // ZET_GLOBAL_METRICS_TIMESTAMPS_EXP_NAME + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Global Metric Timestamps Experimental Extension Version(s) +typedef enum _ze_metric_global_timestamps_exp_version_t +{ + ZE_METRIC_GLOBAL_TIMESTAMPS_EXP_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0 + ZE_METRIC_GLOBAL_TIMESTAMPS_EXP_VERSION_CURRENT = ZE_MAKE_VERSION( 1, 0 ), ///< latest known version + ZE_METRIC_GLOBAL_TIMESTAMPS_EXP_VERSION_FORCE_UINT32 = 0x7fffffff + +} ze_metric_global_timestamps_exp_version_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Metric timestamps resolution +/// +/// @details +/// - This structure may be returned from ::zetMetricGroupGetProperties via +/// `pNext` member of ::zet_metric_group_properties_t +/// - Used for mapping metric timestamps to other timers. +typedef struct _zet_metric_global_timestamps_resolution_exp_t +{ + ze_structure_type_t stype; ///< [in] type of this structure + const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific + ///< structure (i.e. contains sType and pNext). + uint64_t timerResolution; ///< [out] Returns the resolution of device timer in nanoseconds used for + ///< timestamps. + uint64_t timestampValidBits; ///< [out] Returns the number of valid bits in the timestamp value. + +} zet_metric_global_timestamps_resolution_exp_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Returns metric timestamps synchronized with global device timestamps, +/// optionally synchronized with host +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - By default, the global and metrics timestamps are synchronized to the +/// device. +/// +/// @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 == hMetricGroup` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == globalTimestamp` +/// + `nullptr == metricTimestamp` +ZE_APIEXPORT ze_result_t ZE_APICALL +zetMetricGroupGetGlobalTimestampsExp( + zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group + ze_bool_t synchronizedWithHost, ///< [in] Returns the timestamps synchronized to the host or the device. + uint64_t* globalTimestamp, ///< [out] Device timestamp. + uint64_t* metricTimestamp ///< [out] Metric timestamp. + ); + #if !defined(__GNUC__) #pragma endregion #endif diff --git a/include/zet_ddi.h b/include/zet_ddi.h index b8355d3f..3c504012 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.8 + * @version v1.5-r1.5.17 * */ #ifndef _ZET_DDI_H @@ -230,6 +230,51 @@ typedef ze_result_t (ZE_APICALL *zet_pfnGetKernelProcAddrTable_t)( zet_kernel_dditable_t* ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zetMetricGet +typedef ze_result_t (ZE_APICALL *zet_pfnMetricGet_t)( + zet_metric_group_handle_t, + uint32_t*, + zet_metric_handle_t* + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zetMetricGetProperties +typedef ze_result_t (ZE_APICALL *zet_pfnMetricGetProperties_t)( + zet_metric_handle_t, + zet_metric_properties_t* + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Table of Metric functions pointers +typedef struct _zet_metric_dditable_t +{ + zet_pfnMetricGet_t pfnGet; + zet_pfnMetricGetProperties_t pfnGetProperties; +} zet_metric_dditable_t; + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Exported function for filling application's Metric 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 +zetGetMetricProcAddrTable( + ze_api_version_t version, ///< [in] API version requested + zet_metric_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers + ); + +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zetGetMetricProcAddrTable +typedef ze_result_t (ZE_APICALL *zet_pfnGetMetricProcAddrTable_t)( + ze_api_version_t, + zet_metric_dditable_t* + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for zetMetricGroupGet typedef ze_result_t (ZE_APICALL *zet_pfnMetricGroupGet_t)( @@ -300,11 +345,21 @@ typedef ze_result_t (ZE_APICALL *zet_pfnMetricGroupCalculateMultipleMetricValues zet_typed_value_t* ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Function-pointer for zetMetricGroupGetGlobalTimestampsExp +typedef ze_result_t (ZE_APICALL *zet_pfnMetricGroupGetGlobalTimestampsExp_t)( + zet_metric_group_handle_t, + ze_bool_t, + uint64_t*, + uint64_t* + ); + /////////////////////////////////////////////////////////////////////////////// /// @brief Table of MetricGroupExp functions pointers typedef struct _zet_metric_group_exp_dditable_t { zet_pfnMetricGroupCalculateMultipleMetricValuesExp_t pfnCalculateMultipleMetricValuesExp; + zet_pfnMetricGroupGetGlobalTimestampsExp_t pfnGetGlobalTimestampsExp; } zet_metric_group_exp_dditable_t; /////////////////////////////////////////////////////////////////////////////// @@ -329,51 +384,6 @@ typedef ze_result_t (ZE_APICALL *zet_pfnGetMetricGroupExpProcAddrTable_t)( zet_metric_group_exp_dditable_t* ); -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for zetMetricGet -typedef ze_result_t (ZE_APICALL *zet_pfnMetricGet_t)( - zet_metric_group_handle_t, - uint32_t*, - zet_metric_handle_t* - ); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for zetMetricGetProperties -typedef ze_result_t (ZE_APICALL *zet_pfnMetricGetProperties_t)( - zet_metric_handle_t, - zet_metric_properties_t* - ); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Table of Metric functions pointers -typedef struct _zet_metric_dditable_t -{ - zet_pfnMetricGet_t pfnGet; - zet_pfnMetricGetProperties_t pfnGetProperties; -} zet_metric_dditable_t; - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Exported function for filling application's Metric 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 -zetGetMetricProcAddrTable( - ze_api_version_t version, ///< [in] API version requested - zet_metric_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers - ); - -/////////////////////////////////////////////////////////////////////////////// -/// @brief Function-pointer for zetGetMetricProcAddrTable -typedef ze_result_t (ZE_APICALL *zet_pfnGetMetricProcAddrTable_t)( - ze_api_version_t, - zet_metric_dditable_t* - ); - /////////////////////////////////////////////////////////////////////////////// /// @brief Function-pointer for zetMetricStreamerOpen typedef ze_result_t (ZE_APICALL *zet_pfnMetricStreamerOpen_t)( @@ -756,9 +766,9 @@ typedef struct _zet_dditable_t zet_command_list_dditable_t CommandList; zet_module_dditable_t Module; zet_kernel_dditable_t Kernel; + zet_metric_dditable_t Metric; zet_metric_group_dditable_t MetricGroup; zet_metric_group_exp_dditable_t MetricGroupExp; - zet_metric_dditable_t Metric; zet_metric_streamer_dditable_t MetricStreamer; zet_metric_query_pool_dditable_t MetricQueryPool; zet_metric_query_dditable_t MetricQuery; diff --git a/scripts/input.json b/scripts/input.json index 1c2329de..c4931126 100644 --- a/scripts/input.json +++ b/scripts/input.json @@ -711,6 +711,7 @@ "ordinal": 1000, "owner": "$tMetricGroup", "struct": [ + "$t_metric_global_timestamps_resolution_exp_t", "$t_metric_properties_t" ] }, @@ -720,6 +721,7 @@ "$t_metric_group_calculation_type_t" ], "function": [ + "GetGlobalTimestampsExp", "Get", "GetProperties", "CalculateMetricValues", @@ -1300,6 +1302,7 @@ "ordinal": 1000, "owner": "$xModule", "struct": [ + "$x_kernel_max_group_size_properties_ext_t", "$x_scheduling_hint_exp_desc_t", "$x_kernel_desc_t", "$x_kernel_properties_t", @@ -2125,6 +2128,7 @@ "$T_STRUCTURE_TYPE_DEVICE_DEBUG_PROPERTIES", "$T_STRUCTURE_TYPE_DEBUG_MEMORY_SPACE_DESC", "$T_STRUCTURE_TYPE_DEBUG_REGSET_PROPERTIES", + "$T_STRUCTURE_TYPE_GLOBAL_METRICS_TIMESTAMPS_EXP_PROPERTIES", "$T_STRUCTURE_TYPE_TRACER_EXP_DESC" ], "max": "$T_STRUCTURE_TYPE_TRACER_EXP_DESC" @@ -2707,6 +2711,14 @@ ], "max": "0x7" }, + "$x_kernel_max_group_size_properties_ext_version_t": { + "class": "", + "etors": [ + "$X_KERNEL_MAX_GROUP_SIZE_PROPERTIES_EXT_VERSION_1_0", + "$X_KERNEL_MAX_GROUP_SIZE_PROPERTIES_EXT_VERSION_CURRENT" + ], + "max": "$X_KERNEL_MAX_GROUP_SIZE_PROPERTIES_EXT_VERSION_CURRENT" + }, "$x_latency_unit_t": { "class": "", "etors": [ @@ -2809,6 +2821,14 @@ ], "max": "$X_MEMORY_TYPE_SHARED" }, + "$x_metric_global_timestamps_exp_version_t": { + "class": "", + "etors": [ + "$X_METRIC_GLOBAL_TIMESTAMPS_EXP_VERSION_1_0", + "$X_METRIC_GLOBAL_TIMESTAMPS_EXP_VERSION_CURRENT" + ], + "max": "$X_METRIC_GLOBAL_TIMESTAMPS_EXP_VERSION_CURRENT" + }, "$x_module_format_t": { "class": "$xModule", "etors": [ @@ -5022,6 +5042,23 @@ } ] }, + "$tMetricGroupGetGlobalTimestampsExp": { + "class": "$tMetricGroup", + "params": [ + { + "type": "$t_metric_group_handle_t" + }, + { + "type": "$x_bool_t" + }, + { + "type": "uint64_t*" + }, + { + "type": "uint64_t*" + } + ] + }, "$tMetricGroupGetProperties": { "class": "$tMetricGroup", "params": [ @@ -7592,7 +7629,7 @@ "$S_MAX_RAS_ERROR_CATEGORY_COUNT": { "class": "", "values": [ - "7" + "10" ] }, "$S_POWER_LIMITS_EXT_NAME": { @@ -7619,6 +7656,12 @@ "\"$XT_experimental_api_tracing\"" ] }, + "$T_GLOBAL_METRICS_TIMESTAMPS_EXP_NAME": { + "class": "", + "values": [ + "\"$XT_experimental_global_metric_timestamps\"" + ] + }, "$T_MAX_METRIC_COMPONENT": { "class": "", "values": [ @@ -7802,6 +7845,12 @@ "\"$X_extension_image_view_planar\"" ] }, + "$X_KERNEL_MAX_GROUP_SIZE_PROPERTIES_EXT_NAME": { + "class": "", + "values": [ + "\"$X_extension_kernel_max_group_size_properties\"" + ] + }, "$X_KERNEL_SCHEDULING_HINTS_EXP_NAME": { "class": "", "values": [ @@ -8870,7 +8919,7 @@ "type": "uint64_t" }, { - "desc": "[out] The timestamp when these measurements were sampled.\nThis timestamp should only be used to calculate delta time between snapshots of this structure.\nNever take the delta of this timestamp with the timestamp from a different structure since they are not guaranteed to have the same base.\nThe absolute value of the timestamp is only valid during within the application and may be different on the next execution.\n", + "desc": "[out] The timestamp in microseconds when these measurements were sampled.\nThis timestamp should only be used to calculate delta time between snapshots of this structure.\nNever take the delta of this timestamp with the timestamp from a different structure since they are not guaranteed to have the same base.\nThe absolute value of the timestamp is only valid during within the application and may be different on the next execution.\n", "init": null, "name": "timestamp", "type": "uint64_t" @@ -10081,6 +10130,23 @@ } ] }, + "$t_metric_global_timestamps_resolution_exp_t": { + "class": "$tMetric", + "members": [ + { + "desc": "[out] Returns the resolution of device timer in nanoseconds used for timestamps.", + "init": null, + "name": "timerResolution", + "type": "uint64_t" + }, + { + "desc": "[out] Returns the number of valid bits in the timestamp value.", + "init": null, + "name": "timestampValidBits", + "type": "uint64_t" + } + ] + }, "$t_metric_group_properties_t": { "class": "$tMetricGroup", "members": [ @@ -10928,7 +10994,7 @@ "type": "uint32_t" }, { - "desc": "[out] device id from PCI configuration", + "desc": "[out] device id from PCI configuration\nNote, the device id uses little-endian format.\n", "init": null, "name": "deviceId", "type": "uint32_t" @@ -11705,6 +11771,17 @@ } ] }, + "$x_kernel_max_group_size_properties_ext_t": { + "class": "$xKernel", + "members": [ + { + "desc": "[out] maximum group size that can be used to execute the kernel. This value may be less than or equal to the `maxTotalGroupSize` member of $x_device_compute_properties_t.", + "init": null, + "name": "maxGroupSize", + "type": "uint32_t" + } + ] + }, "$x_kernel_preferred_group_size_properties_t": { "class": "$xKernel", "members": [ @@ -14756,6 +14833,24 @@ "name": "ze_kernel_indirect_access_flags_t", "type": "enum" }, + "ze_kernel_max_group_size_properties_ext_version_t": { + "desc": "Kernel Max Group Size Properties Extension Version(s)", + "etors": [ + { + "desc": "version 1.0", + "name": "ZE_KERNEL_MAX_GROUP_SIZE_PROPERTIES_EXT_VERSION_1_0", + "value": "ZE_MAKE_VERSION( 1, 0 )" + }, + { + "desc": "latest known version", + "name": "ZE_KERNEL_MAX_GROUP_SIZE_PROPERTIES_EXT_VERSION_CURRENT", + "value": "ZE_MAKE_VERSION( 1, 0 )" + } + ], + "name": "ze_kernel_max_group_size_properties_ext_version_t", + "type": "enum", + "version": "1.5" + }, "ze_latency_unit_t": { "desc": "Latency unit", "etors": [ @@ -15029,6 +15124,24 @@ "name": "ze_memory_type_t", "type": "enum" }, + "ze_metric_global_timestamps_exp_version_t": { + "desc": "Global Metric Timestamps Experimental Extension Version(s)", + "etors": [ + { + "desc": "version 1.0", + "name": "ZE_METRIC_GLOBAL_TIMESTAMPS_EXP_VERSION_1_0", + "value": "ZE_MAKE_VERSION( 1, 0 )" + }, + { + "desc": "latest known version", + "name": "ZE_METRIC_GLOBAL_TIMESTAMPS_EXP_VERSION_CURRENT", + "value": "ZE_MAKE_VERSION( 1, 0 )" + } + ], + "name": "ze_metric_global_timestamps_exp_version_t", + "type": "enum", + "version": "1.5" + }, "ze_module_format_t": { "class": "zeModule", "desc": "Supported module creation input formats", @@ -17932,6 +18045,12 @@ "name": "ZET_STRUCTURE_TYPE_DEBUG_REGSET_PROPERTIES", "value": "0x8" }, + { + "desc": "zet_metric_global_timestamps_resolution_exp_t", + "name": "ZET_STRUCTURE_TYPE_GLOBAL_METRICS_TIMESTAMPS_EXP_PROPERTIES", + "value": "0x9", + "version": "1.5" + }, { "desc": "zet_tracer_exp_desc_t", "name": "ZET_STRUCTURE_TYPE_TRACER_EXP_DESC", @@ -25126,6 +25245,70 @@ "type": "function", "version": "1.1" }, + "GetGlobalTimestampsExp": { + "class": "zetMetricGroup", + "decl": "static", + "desc": "Returns metric timestamps synchronized with global device timestamps, optionally synchronized with host", + "details": [ + "The application may call this function from simultaneous threads.", + "By default, the global and metrics timestamps are synchronized to the device." + ], + "hash": "223592fae768685fbaf678e7be2615d9d155a4f4c8d4e984da32b75707c71394", + "name": "GetGlobalTimestampsExp", + "params": [ + { + "desc": "[in] handle of the metric group", + "name": "hMetricGroup", + "type": "zet_metric_group_handle_t" + }, + { + "desc": "[in] Returns the timestamps synchronized to the host or the device.", + "init": "false", + "name": "synchronizedWithHost", + "type": "ze_bool_t" + }, + { + "desc": "[out] Device timestamp.\n", + "name": "globalTimestamp", + "type": "uint64_t*" + }, + { + "desc": "[out] Metric timestamp.", + "name": "metricTimestamp", + "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 == hMetricGroup`" + ] + }, + { + "ZE_RESULT_ERROR_INVALID_NULL_POINTER": [ + "`nullptr == globalTimestamp`", + "`nullptr == metricTimestamp`" + ] + } + ], + "type": "function", + "version": "1.5" + }, "GetImageProperties": { "class": "zeDevice", "desc": "Retrieves image properties of the device", @@ -26400,12 +26583,12 @@ "type": "ze_kernel_handle_t" }, { - "desc": "[in,out] pointer to size of string in bytes.", + "desc": "[in,out] pointer to size of string in bytes, including null-terminating character.", "name": "pSize", "type": "uint32_t*" }, { - "desc": "[in,out] pointer to null-terminated string, whose lifetime is tied to the kernel object, where kernel source attributes are separated by space.", + "desc": "[in,out][optional] pointer to application-managed character array (string data).\nIf NULL, the string length of the kernel source attributes, including a null-terminating character, is returned in pSize.\nOtherwise, pString must point to valid application memory that is greater than or equal to *pSize bytes in length, and on return the pointed-to string will contain a space-separated list of kernel source attributes.\n", "name": "pString", "type": "char**" } @@ -26433,8 +26616,7 @@ }, { "ZE_RESULT_ERROR_INVALID_NULL_POINTER": [ - "`nullptr == pSize`", - "`nullptr == pString`" + "`nullptr == pSize`" ] } ], @@ -32588,7 +32770,7 @@ "desc": "The maximum number of categories", "name": "ZES_MAX_RAS_ERROR_CATEGORY_COUNT", "type": "macro", - "value": "7" + "value": "10" }, "ZES_POWER_LIMITS_EXT_NAME": { "desc": "Power Limits Extension Name", @@ -32615,6 +32797,13 @@ "type": "macro", "value": "\"ZET_experimental_api_tracing\"" }, + "ZET_GLOBAL_METRICS_TIMESTAMPS_EXP_NAME": { + "desc": "Global Metric Timestamps Experimental Extension Name", + "name": "ZET_GLOBAL_METRICS_TIMESTAMPS_EXP_NAME", + "type": "macro", + "value": "\"ZET_experimental_global_metric_timestamps\"", + "version": "1.5" + }, "ZET_MAX_METRIC_COMPONENT": { "desc": "Maximum metric component string size", "name": "ZET_MAX_METRIC_COMPONENT", @@ -32821,6 +33010,13 @@ "value": "\"ZE_extension_image_view_planar\"", "version": "1.5" }, + "ZE_KERNEL_MAX_GROUP_SIZE_PROPERTIES_EXT_NAME": { + "desc": "Kernel Max Group Size Properties Extension Name", + "name": "ZE_KERNEL_MAX_GROUP_SIZE_PROPERTIES_EXT_NAME", + "type": "macro", + "value": "\"ZE_extension_kernel_max_group_size_properties\"", + "version": "1.5" + }, "ZE_KERNEL_SCHEDULING_HINTS_EXP_NAME": { "desc": "Kernel Scheduling Hints Extension Name", "name": "ZE_KERNEL_SCHEDULING_HINTS_EXP_NAME", @@ -33937,7 +34133,7 @@ "type": "uint32_t" }, { - "desc": "[out] device id from PCI configuration", + "desc": "[out] device id from PCI configuration\nNote, the device id uses little-endian format.\n", "name": "deviceId", "type": "uint32_t" }, @@ -35099,6 +35295,36 @@ "name": "ze_kernel_desc_t", "type": "struct" }, + "ze_kernel_max_group_size_properties_ext_t": { + "base": "ze_base_properties_t", + "class": "zeKernel", + "desc": "Additional kernel max group size properties", + "details": [ + "This structure may be passed to zeKernelGetProperties, via the `pNext` member of ze_kernel_properties_t, to query additional kernel max group size properties." + ], + "members": [ + { + "desc": "[in] type of this structure", + "init": "ZE_STRUCTURE_TYPE_KERNEL_MAX_GROUP_SIZE_PROPERTIES_EXT", + "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] maximum group size that can be used to execute the kernel. This value may be less than or equal to the `maxTotalGroupSize` member of ze_device_compute_properties_t.", + "name": "maxGroupSize", + "type": "uint32_t" + } + ], + "name": "ze_kernel_max_group_size_properties_ext_t", + "type": "struct", + "version": "1.5" + }, "ze_kernel_preferred_group_size_properties_t": { "base": "ze_base_properties_t", "class": "zeKernel", @@ -37089,7 +37315,7 @@ "type": "uint64_t" }, { - "desc": "[out] The timestamp when these measurements were sampled.\nThis timestamp should only be used to calculate delta time between snapshots of this structure.\nNever take the delta of this timestamp with the timestamp from a different structure since they are not guaranteed to have the same base.\nThe absolute value of the timestamp is only valid during within the application and may be different on the next execution.\n", + "desc": "[out] The timestamp in microseconds when these measurements were sampled.\nThis timestamp should only be used to calculate delta time between snapshots of this structure.\nNever take the delta of this timestamp with the timestamp from a different structure since they are not guaranteed to have the same base.\nThe absolute value of the timestamp is only valid during within the application and may be different on the next execution.\n", "name": "timestamp", "type": "uint64_t" } @@ -38668,6 +38894,42 @@ "name": "zet_device_debug_properties_t", "type": "struct" }, + "zet_metric_global_timestamps_resolution_exp_t": { + "base": "ze_base_desc_t", + "class": "zetMetric", + "desc": "Metric timestamps resolution", + "details": [ + "This structure may be returned from zetMetricGroupGetProperties via `pNext` member of zet_metric_group_properties_t", + "Used for mapping metric timestamps to other timers." + ], + "members": [ + { + "desc": "[in] type of this structure", + "init": "ZET_STRUCTURE_TYPE_METRIC_GLOBAL_TIMESTAMPS_RESOLUTION_EXP", + "name": "stype", + "type": "ze_structure_type_t" + }, + { + "desc": "[in][optional] must be null or a pointer to an extension-specific structure (i.e. contains sType and pNext).", + "init": "nullptr", + "name": "pNext", + "type": "const void*" + }, + { + "desc": "[out] Returns the resolution of device timer in nanoseconds used for timestamps.", + "name": "timerResolution", + "type": "uint64_t" + }, + { + "desc": "[out] Returns the number of valid bits in the timestamp value.", + "name": "timestampValidBits", + "type": "uint64_t" + } + ], + "name": "zet_metric_global_timestamps_resolution_exp_t", + "type": "struct", + "version": "1.5" + }, "zet_metric_group_properties_t": { "base": "zet_base_properties_t", "class": "zetMetricGroup", @@ -40833,7 +41095,7 @@ "type": "uint32_t" }, { - "desc": "[out] device id from PCI configuration", + "desc": "[out] device id from PCI configuration\nNote, the device id uses little-endian format.\n", "name": "deviceId", "type": "uint32_t" }, @@ -49276,12 +49538,12 @@ "type": "$x_kernel_handle_t" }, { - "desc": "[in,out] pointer to size of string in bytes.", + "desc": "[in,out] pointer to size of string in bytes, including null-terminating character.", "name": "pSize", "type": "uint32_t*" }, { - "desc": "[in,out] pointer to null-terminated string, whose lifetime is tied to the kernel object, where kernel source attributes are separated by space.", + "desc": "[in,out][optional] pointer to application-managed character array (string data).\nIf NULL, the string length of the kernel source attributes, including a null-terminating character, is returned in pSize.\nOtherwise, pString must point to valid application memory that is greater than or equal to *pSize bytes in length, and on return the pointed-to string will contain a space-separated list of kernel source attributes.\n", "name": "pString", "type": "char**" } @@ -49309,8 +49571,7 @@ }, { "$X_RESULT_ERROR_INVALID_NULL_POINTER": [ - "`nullptr == pSize`", - "`nullptr == pString`" + "`nullptr == pSize`" ] } ], @@ -55279,6 +55540,72 @@ } ] }, + { + "header": { + "desc": "Intel $OneApi Level-Zero Extension for querying kernel max group size properties.", + "ordinal": 1500, + "type": "header", + "version": "1.5" + }, + "name": "kernelMaxGroupSizeProperties", + "objects": [ + { + "desc": "Kernel Max Group Size Properties Extension Name", + "name": "$X_KERNEL_MAX_GROUP_SIZE_PROPERTIES_EXT_NAME", + "type": "macro", + "value": "\"$X_extension_kernel_max_group_size_properties\"", + "version": "1.5" + }, + { + "desc": "Kernel Max Group Size Properties Extension Version(s)", + "etors": [ + { + "desc": "version 1.0", + "name": "$X_KERNEL_MAX_GROUP_SIZE_PROPERTIES_EXT_VERSION_1_0", + "value": "$X_MAKE_VERSION( 1, 0 )" + }, + { + "desc": "latest known version", + "name": "$X_KERNEL_MAX_GROUP_SIZE_PROPERTIES_EXT_VERSION_CURRENT", + "value": "$X_MAKE_VERSION( 1, 0 )" + } + ], + "name": "$x_kernel_max_group_size_properties_ext_version_t", + "type": "enum", + "version": "1.5" + }, + { + "base": "$x_base_properties_t", + "class": "$xKernel", + "desc": "Additional kernel max group size properties", + "details": [ + "This structure may be passed to $xKernelGetProperties, via the `pNext` member of $x_kernel_properties_t, to query additional kernel max group size properties." + ], + "members": [ + { + "desc": "[in] type of this structure", + "init": "$X_STRUCTURE_TYPE_KERNEL_MAX_GROUP_SIZE_PROPERTIES_EXT", + "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] maximum group size that can be used to execute the kernel. This value may be less than or equal to the `maxTotalGroupSize` member of $x_device_compute_properties_t.", + "name": "maxGroupSize", + "type": "uint32_t" + } + ], + "name": "$x_kernel_max_group_size_properties_ext_t", + "type": "struct", + "version": "1.5" + } + ] + }, { "header": { "desc": "Intel $OneApi Level-Zero Extension for querying sub-allocations properties.", @@ -55506,6 +55833,12 @@ "name": "$T_STRUCTURE_TYPE_DEBUG_REGSET_PROPERTIES", "value": "0x8" }, + { + "desc": "$t_metric_global_timestamps_resolution_exp_t", + "name": "$T_STRUCTURE_TYPE_GLOBAL_METRICS_TIMESTAMPS_EXP_PROPERTIES", + "value": "0x9", + "version": "1.5" + }, { "desc": "$t_tracer_exp_desc_t", "name": "$T_STRUCTURE_TYPE_TRACER_EXP_DESC", @@ -59123,6 +59456,142 @@ "version": "1.2" } ] + }, + { + "header": { + "desc": "Intel $OneApi Level-Zero Tool Experimental Extension for Global Metric Timestamps", + "ordinal": 1500, + "type": "header", + "version": "1.5" + }, + "name": "GlobalTimestamps", + "objects": [ + { + "desc": "Global Metric Timestamps Experimental Extension Name", + "name": "$T_GLOBAL_METRICS_TIMESTAMPS_EXP_NAME", + "type": "macro", + "value": "\"$XT_experimental_global_metric_timestamps\"", + "version": "1.5" + }, + { + "desc": "Global Metric Timestamps Experimental Extension Version(s)", + "etors": [ + { + "desc": "version 1.0", + "name": "$X_METRIC_GLOBAL_TIMESTAMPS_EXP_VERSION_1_0", + "value": "$X_MAKE_VERSION( 1, 0 )" + }, + { + "desc": "latest known version", + "name": "$X_METRIC_GLOBAL_TIMESTAMPS_EXP_VERSION_CURRENT", + "value": "$X_MAKE_VERSION( 1, 0 )" + } + ], + "name": "$x_metric_global_timestamps_exp_version_t", + "type": "enum", + "version": "1.5" + }, + { + "base": "$x_base_desc_t", + "class": "$tMetric", + "desc": "Metric timestamps resolution", + "details": [ + "This structure may be returned from $tMetricGroupGetProperties via `pNext` member of $t_metric_group_properties_t", + "Used for mapping metric timestamps to other timers." + ], + "members": [ + { + "desc": "[in] type of this structure", + "init": "$T_STRUCTURE_TYPE_METRIC_GLOBAL_TIMESTAMPS_RESOLUTION_EXP", + "name": "stype", + "type": "$x_structure_type_t" + }, + { + "desc": "[in][optional] must be null or a pointer to an extension-specific structure (i.e. contains sType and pNext).", + "init": "nullptr", + "name": "pNext", + "type": "const void*" + }, + { + "desc": "[out] Returns the resolution of device timer in nanoseconds used for timestamps.", + "name": "timerResolution", + "type": "uint64_t" + }, + { + "desc": "[out] Returns the number of valid bits in the timestamp value.", + "name": "timestampValidBits", + "type": "uint64_t" + } + ], + "name": "$t_metric_global_timestamps_resolution_exp_t", + "type": "struct", + "version": "1.5" + }, + { + "class": "$tMetricGroup", + "decl": "static", + "desc": "Returns metric timestamps synchronized with global device timestamps, optionally synchronized with host", + "details": [ + "The application may call this function from simultaneous threads.", + "By default, the global and metrics timestamps are synchronized to the device." + ], + "hash": "223592fae768685fbaf678e7be2615d9d155a4f4c8d4e984da32b75707c71394", + "name": "GetGlobalTimestampsExp", + "params": [ + { + "desc": "[in] handle of the metric group", + "name": "hMetricGroup", + "type": "$t_metric_group_handle_t" + }, + { + "desc": "[in] Returns the timestamps synchronized to the host or the device.", + "init": "false", + "name": "synchronizedWithHost", + "type": "$x_bool_t" + }, + { + "desc": "[out] Device timestamp.\n", + "name": "globalTimestamp", + "type": "uint64_t*" + }, + { + "desc": "[out] Metric timestamp.", + "name": "metricTimestamp", + "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 == hMetricGroup`" + ] + }, + { + "$X_RESULT_ERROR_INVALID_NULL_POINTER": [ + "`nullptr == globalTimestamp`", + "`nullptr == metricTimestamp`" + ] + } + ], + "type": "function", + "version": "1.5" + } + ] } ], [ @@ -67238,7 +67707,7 @@ "type": "uint64_t" }, { - "desc": "[out] The timestamp when these measurements were sampled.\nThis timestamp should only be used to calculate delta time between snapshots of this structure.\nNever take the delta of this timestamp with the timestamp from a different structure since they are not guaranteed to have the same base.\nThe absolute value of the timestamp is only valid during within the application and may be different on the next execution.\n", + "desc": "[out] The timestamp in microseconds when these measurements were sampled.\nThis timestamp should only be used to calculate delta time between snapshots of this structure.\nNever take the delta of this timestamp with the timestamp from a different structure since they are not guaranteed to have the same base.\nThe absolute value of the timestamp is only valid during within the application and may be different on the next execution.\n", "name": "timestamp", "type": "uint64_t" } @@ -68898,7 +69367,7 @@ "desc": "The maximum number of categories", "name": "$S_MAX_RAS_ERROR_CATEGORY_COUNT", "type": "macro", - "value": "7" + "value": "10" }, { "base": "$s_base_properties_t", diff --git a/source/drivers/null/ze_nullddi.cpp b/source/drivers/null/ze_nullddi.cpp index d30be787..f0bf4c63 100644 --- a/source/drivers/null/ze_nullddi.cpp +++ b/source/drivers/null/ze_nullddi.cpp @@ -2717,10 +2717,15 @@ namespace driver __zedlllocal ze_result_t ZE_APICALL zeKernelGetSourceAttributes( ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object - uint32_t* pSize, ///< [in,out] pointer to size of string in bytes. - char** pString ///< [in,out] pointer to null-terminated string, whose lifetime is tied to - ///< the kernel object, where kernel source attributes are separated by - ///< space. + uint32_t* pSize, ///< [in,out] pointer to size of string in bytes, including + ///< null-terminating character. + char** pString ///< [in,out][optional] pointer to application-managed character array + ///< (string data). + ///< If NULL, the string length of the kernel source attributes, including + ///< a null-terminating character, is returned in pSize. + ///< Otherwise, pString must point to valid application memory that is + ///< greater than or equal to *pSize bytes in length, and on return the + ///< pointed-to string will contain a space-separated list of kernel source attributes. ) { ze_result_t result = ZE_RESULT_SUCCESS; diff --git a/source/drivers/null/zet_nullddi.cpp b/source/drivers/null/zet_nullddi.cpp index e0257720..c9f0bef8 100644 --- a/source/drivers/null/zet_nullddi.cpp +++ b/source/drivers/null/zet_nullddi.cpp @@ -1116,6 +1116,32 @@ namespace driver return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricGroupGetGlobalTimestampsExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupGetGlobalTimestampsExp( + zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group + ze_bool_t synchronizedWithHost, ///< [in] Returns the timestamps synchronized to the host or the device. + uint64_t* globalTimestamp, ///< [out] Device timestamp. + uint64_t* metricTimestamp ///< [out] Metric timestamp. + ) + { + 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 pfnGetGlobalTimestampsExp = context.zetDdiTable.MetricGroupExp.pfnGetGlobalTimestampsExp; + if( nullptr != pfnGetGlobalTimestampsExp ) + { + result = pfnGetGlobalTimestampsExp( hMetricGroup, synchronizedWithHost, globalTimestamp, metricTimestamp ); + } + else + { + // generic implementation + } + + return result; + } + } // namespace driver #if defined(__cplusplus) @@ -1396,6 +1422,8 @@ zetGetMetricGroupExpProcAddrTable( pDdiTable->pfnCalculateMultipleMetricValuesExp = driver::zetMetricGroupCalculateMultipleMetricValuesExp; + pDdiTable->pfnGetGlobalTimestampsExp = driver::zetMetricGroupGetGlobalTimestampsExp; + return result; } diff --git a/source/layers/tracing/ze_trcddi.cpp b/source/layers/tracing/ze_trcddi.cpp index f42e905d..438bb606 100644 --- a/source/layers/tracing/ze_trcddi.cpp +++ b/source/layers/tracing/ze_trcddi.cpp @@ -4005,10 +4005,15 @@ namespace tracing_layer __zedlllocal ze_result_t ZE_APICALL zeKernelGetSourceAttributes( ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object - uint32_t* pSize, ///< [in,out] pointer to size of string in bytes. - char** pString ///< [in,out] pointer to null-terminated string, whose lifetime is tied to - ///< the kernel object, where kernel source attributes are separated by - ///< space. + uint32_t* pSize, ///< [in,out] pointer to size of string in bytes, including + ///< null-terminating character. + char** pString ///< [in,out][optional] pointer to application-managed character array + ///< (string data). + ///< If NULL, the string length of the kernel source attributes, including + ///< a null-terminating character, is returned in pSize. + ///< Otherwise, pString must point to valid application memory that is + ///< greater than or equal to *pSize bytes in length, and on return the + ///< pointed-to string will contain a space-separated list of kernel source attributes. ) { auto pfnGetSourceAttributes = context.zeDdiTable.Kernel.pfnGetSourceAttributes; diff --git a/source/layers/validation/common/zet_entry_points.h b/source/layers/validation/common/zet_entry_points.h index 79cc8615..314dec6c 100644 --- a/source/layers/validation/common/zet_entry_points.h +++ b/source/layers/validation/common/zet_entry_points.h @@ -57,5 +57,6 @@ class ZETValidationEntryPoints { virtual ze_result_t zetTracerExpSetEpilogues( zet_tracer_exp_handle_t hTracer, zet_core_callbacks_t* pCoreCbs ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zetTracerExpSetEnabled( zet_tracer_exp_handle_t hTracer, ze_bool_t enable ) {return ZE_RESULT_SUCCESS;} virtual ze_result_t zetMetricGroupCalculateMultipleMetricValuesExp( zet_metric_group_handle_t hMetricGroup, zet_metric_group_calculation_type_t type, size_t rawDataSize, const uint8_t* pRawData, uint32_t* pSetCount, uint32_t* pTotalMetricValueCount, uint32_t* pMetricCounts, zet_typed_value_t* pMetricValues ) {return ZE_RESULT_SUCCESS;} + virtual ze_result_t zetMetricGroupGetGlobalTimestampsExp( zet_metric_group_handle_t hMetricGroup, ze_bool_t synchronizedWithHost, uint64_t* globalTimestamp, uint64_t* metricTimestamp ) {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 c3a9514f..68ae7256 100644 --- a/source/layers/validation/parameter_validation/ze_parameter_validation.cpp +++ b/source/layers/validation/parameter_validation/ze_parameter_validation.cpp @@ -2070,10 +2070,15 @@ namespace validation_layer ze_result_t ZEParameterValidation::zeKernelGetSourceAttributes( ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object - uint32_t* pSize, ///< [in,out] pointer to size of string in bytes. - char** pString ///< [in,out] pointer to null-terminated string, whose lifetime is tied to - ///< the kernel object, where kernel source attributes are separated by - ///< space. + uint32_t* pSize, ///< [in,out] pointer to size of string in bytes, including + ///< null-terminating character. + char** pString ///< [in,out][optional] pointer to application-managed character array + ///< (string data). + ///< If NULL, the string length of the kernel source attributes, including + ///< a null-terminating character, is returned in pSize. + ///< Otherwise, pString must point to valid application memory that is + ///< greater than or equal to *pSize bytes in length, and on return the + ///< pointed-to string will contain a space-separated list of kernel source attributes. ) { if( nullptr == hKernel ) @@ -2082,9 +2087,6 @@ namespace validation_layer if( nullptr == pSize ) return ZE_RESULT_ERROR_INVALID_NULL_POINTER; - if( nullptr == pString ) - return ZE_RESULT_ERROR_INVALID_NULL_POINTER; - return ZE_RESULT_SUCCESS; } diff --git a/source/layers/validation/parameter_validation/zet_parameter_validation.cpp b/source/layers/validation/parameter_validation/zet_parameter_validation.cpp index 2237aff5..e0ffe8fe 100644 --- a/source/layers/validation/parameter_validation/zet_parameter_validation.cpp +++ b/source/layers/validation/parameter_validation/zet_parameter_validation.cpp @@ -808,4 +808,25 @@ namespace validation_layer return ZE_RESULT_SUCCESS; } + + ze_result_t + ZETParameterValidation::zetMetricGroupGetGlobalTimestampsExp( + zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group + ze_bool_t synchronizedWithHost, ///< [in] Returns the timestamps synchronized to the host or the device. + uint64_t* globalTimestamp, ///< [out] Device timestamp. + uint64_t* metricTimestamp ///< [out] Metric timestamp. + ) + { + if( nullptr == hMetricGroup ) + return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; + + if( nullptr == globalTimestamp ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + if( nullptr == metricTimestamp ) + return ZE_RESULT_ERROR_INVALID_NULL_POINTER; + + return ZE_RESULT_SUCCESS; + } + } \ No newline at end of file diff --git a/source/layers/validation/parameter_validation/zet_parameter_validation.h b/source/layers/validation/parameter_validation/zet_parameter_validation.h index 2861005e..87722af8 100644 --- a/source/layers/validation/parameter_validation/zet_parameter_validation.h +++ b/source/layers/validation/parameter_validation/zet_parameter_validation.h @@ -59,6 +59,7 @@ namespace validation_layer ze_result_t zetTracerExpSetEpilogues ( zet_tracer_exp_handle_t hTracer, zet_core_callbacks_t* pCoreCbs ) override; ze_result_t zetTracerExpSetEnabled ( zet_tracer_exp_handle_t hTracer, ze_bool_t enable ) override; ze_result_t zetMetricGroupCalculateMultipleMetricValuesExp ( zet_metric_group_handle_t hMetricGroup, zet_metric_group_calculation_type_t type, size_t rawDataSize, const uint8_t* pRawData, uint32_t* pSetCount, uint32_t* pTotalMetricValueCount, uint32_t* pMetricCounts, zet_typed_value_t* pMetricValues ) override; + ze_result_t zetMetricGroupGetGlobalTimestampsExp ( zet_metric_group_handle_t hMetricGroup, ze_bool_t synchronizedWithHost, uint64_t* globalTimestamp, uint64_t* metricTimestamp ) override; }; } \ No newline at end of file diff --git a/source/layers/validation/ze_valddi.cpp b/source/layers/validation/ze_valddi.cpp index 0ffb9b75..6e9b73f6 100644 --- a/source/layers/validation/ze_valddi.cpp +++ b/source/layers/validation/ze_valddi.cpp @@ -3269,10 +3269,15 @@ namespace validation_layer __zedlllocal ze_result_t ZE_APICALL zeKernelGetSourceAttributes( ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object - uint32_t* pSize, ///< [in,out] pointer to size of string in bytes. - char** pString ///< [in,out] pointer to null-terminated string, whose lifetime is tied to - ///< the kernel object, where kernel source attributes are separated by - ///< space. + uint32_t* pSize, ///< [in,out] pointer to size of string in bytes, including + ///< null-terminating character. + char** pString ///< [in,out][optional] pointer to application-managed character array + ///< (string data). + ///< If NULL, the string length of the kernel source attributes, including + ///< a null-terminating character, is returned in pSize. + ///< Otherwise, pString must point to valid application memory that is + ///< greater than or equal to *pSize bytes in length, and on return the + ///< pointed-to string will contain a space-separated list of kernel source attributes. ) { auto pfnGetSourceAttributes = context.zeDdiTable.Kernel.pfnGetSourceAttributes; diff --git a/source/layers/validation/zet_valddi.cpp b/source/layers/validation/zet_valddi.cpp index 4c39929c..9a5cdbf7 100644 --- a/source/layers/validation/zet_valddi.cpp +++ b/source/layers/validation/zet_valddi.cpp @@ -1337,6 +1337,38 @@ namespace validation_layer return pfnCalculateMultipleMetricValuesExp( hMetricGroup, type, rawDataSize, pRawData, pSetCount, pTotalMetricValueCount, pMetricCounts, pMetricValues ); } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricGroupGetGlobalTimestampsExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupGetGlobalTimestampsExp( + zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group + ze_bool_t synchronizedWithHost, ///< [in] Returns the timestamps synchronized to the host or the device. + uint64_t* globalTimestamp, ///< [out] Device timestamp. + uint64_t* metricTimestamp ///< [out] Metric timestamp. + ) + { + auto pfnGetGlobalTimestampsExp = context.zetDdiTable.MetricGroupExp.pfnGetGlobalTimestampsExp; + + if( nullptr == pfnGetGlobalTimestampsExp ) + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + + if( context.enableParameterValidation ) + { + auto result = context.paramValidation->zetParamValidation.zetMetricGroupGetGlobalTimestampsExp( hMetricGroup, synchronizedWithHost, globalTimestamp, metricTimestamp ); + if(result!=ZE_RESULT_SUCCESS) return result; + } + + if( context.enableHandleLifetime ){ + //Unimplemented + } + + if( context.enableThreadingValidation ){ + //Unimplemented + } + + return pfnGetGlobalTimestampsExp( hMetricGroup, synchronizedWithHost, globalTimestamp, metricTimestamp ); + } + } // namespace validation_layer #if defined(__cplusplus) @@ -1670,6 +1702,9 @@ zetGetMetricGroupExpProcAddrTable( dditable.pfnCalculateMultipleMetricValuesExp = pDdiTable->pfnCalculateMultipleMetricValuesExp; pDdiTable->pfnCalculateMultipleMetricValuesExp = validation_layer::zetMetricGroupCalculateMultipleMetricValuesExp; + dditable.pfnGetGlobalTimestampsExp = pDdiTable->pfnGetGlobalTimestampsExp; + pDdiTable->pfnGetGlobalTimestampsExp = validation_layer::zetMetricGroupGetGlobalTimestampsExp; + return result; } diff --git a/source/lib/ze_libapi.cpp b/source/lib/ze_libapi.cpp index 7d856061..8cdf0fb1 100644 --- a/source/lib/ze_libapi.cpp +++ b/source/lib/ze_libapi.cpp @@ -4480,14 +4480,18 @@ zeKernelGetIndirectAccess( /// + `nullptr == hKernel` /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER /// + `nullptr == pSize` -/// + `nullptr == pString` ze_result_t ZE_APICALL zeKernelGetSourceAttributes( ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object - uint32_t* pSize, ///< [in,out] pointer to size of string in bytes. - char** pString ///< [in,out] pointer to null-terminated string, whose lifetime is tied to - ///< the kernel object, where kernel source attributes are separated by - ///< space. + uint32_t* pSize, ///< [in,out] pointer to size of string in bytes, including + ///< null-terminating character. + char** pString ///< [in,out][optional] pointer to application-managed character array + ///< (string data). + ///< If NULL, the string length of the kernel source attributes, including + ///< a null-terminating character, is returned in pSize. + ///< Otherwise, pString must point to valid application memory that is + ///< greater than or equal to *pSize bytes in length, and on return the + ///< pointed-to string will contain a space-separated list of kernel source attributes. ) { auto pfnGetSourceAttributes = ze_lib::context->zeDdiTable.Kernel.pfnGetSourceAttributes; diff --git a/source/lib/zet_libapi.cpp b/source/lib/zet_libapi.cpp index 51779f53..5cf7374c 100644 --- a/source/lib/zet_libapi.cpp +++ b/source/lib/zet_libapi.cpp @@ -1568,4 +1568,43 @@ zetMetricGroupCalculateMultipleMetricValuesExp( return pfnCalculateMultipleMetricValuesExp( hMetricGroup, type, rawDataSize, pRawData, pSetCount, pTotalMetricValueCount, pMetricCounts, pMetricValues ); } +/////////////////////////////////////////////////////////////////////////////// +/// @brief Returns metric timestamps synchronized with global device timestamps, +/// optionally synchronized with host +/// +/// @details +/// - The application may call this function from simultaneous threads. +/// - By default, the global and metrics timestamps are synchronized to the +/// device. +/// +/// @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 == hMetricGroup` +/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER +/// + `nullptr == globalTimestamp` +/// + `nullptr == metricTimestamp` +ze_result_t ZE_APICALL +zetMetricGroupGetGlobalTimestampsExp( + zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group + ze_bool_t synchronizedWithHost, ///< [in] Returns the timestamps synchronized to the host or the device. + uint64_t* globalTimestamp, ///< [out] Device timestamp. + uint64_t* metricTimestamp ///< [out] Metric timestamp. + ) +{ + auto pfnGetGlobalTimestampsExp = ze_lib::context->zetDdiTable.MetricGroupExp.pfnGetGlobalTimestampsExp; + if( nullptr == pfnGetGlobalTimestampsExp ) { + if(!ze_lib::context->isInitialized) + return ZE_RESULT_ERROR_UNINITIALIZED; + else + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + return pfnGetGlobalTimestampsExp( hMetricGroup, synchronizedWithHost, globalTimestamp, metricTimestamp ); +} + } // extern "C" diff --git a/source/loader/ze_ldrddi.cpp b/source/loader/ze_ldrddi.cpp index 445b7261..5566e8b5 100644 --- a/source/loader/ze_ldrddi.cpp +++ b/source/loader/ze_ldrddi.cpp @@ -3350,10 +3350,15 @@ namespace loader __zedlllocal ze_result_t ZE_APICALL zeKernelGetSourceAttributes( ze_kernel_handle_t hKernel, ///< [in] handle of the kernel object - uint32_t* pSize, ///< [in,out] pointer to size of string in bytes. - char** pString ///< [in,out] pointer to null-terminated string, whose lifetime is tied to - ///< the kernel object, where kernel source attributes are separated by - ///< space. + uint32_t* pSize, ///< [in,out] pointer to size of string in bytes, including + ///< null-terminating character. + char** pString ///< [in,out][optional] pointer to application-managed character array + ///< (string data). + ///< If NULL, the string length of the kernel source attributes, including + ///< a null-terminating character, is returned in pSize. + ///< Otherwise, pString must point to valid application memory that is + ///< greater than or equal to *pSize bytes in length, and on return the + ///< pointed-to string will contain a space-separated list of kernel source attributes. ) { ze_result_t result = ZE_RESULT_SUCCESS; diff --git a/source/loader/zet_ldrddi.cpp b/source/loader/zet_ldrddi.cpp index 63788d21..7f5d2d5a 100644 --- a/source/loader/zet_ldrddi.cpp +++ b/source/loader/zet_ldrddi.cpp @@ -1316,6 +1316,33 @@ namespace loader return result; } + /////////////////////////////////////////////////////////////////////////////// + /// @brief Intercept function for zetMetricGroupGetGlobalTimestampsExp + __zedlllocal ze_result_t ZE_APICALL + zetMetricGroupGetGlobalTimestampsExp( + zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group + ze_bool_t synchronizedWithHost, ///< [in] Returns the timestamps synchronized to the host or the device. + uint64_t* globalTimestamp, ///< [out] Device timestamp. + uint64_t* metricTimestamp ///< [out] Metric timestamp. + ) + { + ze_result_t result = ZE_RESULT_SUCCESS; + + // extract driver's function pointer table + auto dditable = reinterpret_cast( hMetricGroup )->dditable; + auto pfnGetGlobalTimestampsExp = dditable->zet.MetricGroupExp.pfnGetGlobalTimestampsExp; + if( nullptr == pfnGetGlobalTimestampsExp ) + return ZE_RESULT_ERROR_UNINITIALIZED; + + // convert loader handle to driver handle + hMetricGroup = reinterpret_cast( hMetricGroup )->handle; + + // forward to device-driver + result = pfnGetGlobalTimestampsExp( hMetricGroup, synchronizedWithHost, globalTimestamp, metricTimestamp ); + + return result; + } + } // namespace loader #if defined(__cplusplus) @@ -1987,6 +2014,7 @@ zetGetMetricGroupExpProcAddrTable( { // return pointers to loader's DDIs pDdiTable->pfnCalculateMultipleMetricValuesExp = loader::zetMetricGroupCalculateMultipleMetricValuesExp; + pDdiTable->pfnGetGlobalTimestampsExp = loader::zetMetricGroupGetGlobalTimestampsExp; } else {