feature: initial support for MetricGroupGetExportData

Related-To: LOCI-4356, LOCI-4357

Signed-off-by: Joshua Santosh Ranjan <joshua.santosh.ranjan@intel.com>
This commit is contained in:
Joshua Santosh Ranjan 2023-06-22 12:41:54 +00:00 committed by Compute-Runtime-Automation
parent ba4c4a5af0
commit 0853cb71b7
20 changed files with 3175 additions and 7 deletions

View File

@ -235,6 +235,8 @@ zetGetMetricGroupExpProcAddrTable(
ze_result_t result = ZE_RESULT_SUCCESS;
pDdiTable->pfnCalculateMultipleMetricValuesExp = L0::zetMetricGroupCalculateMultipleMetricValuesExp;
pDdiTable->pfnGetGlobalTimestampsExp = L0::zetMetricGroupGetGlobalTimestampsExp;
pDdiTable->pfnGetExportDataExp = L0::zetMetricGroupGetExportDataExp;
pDdiTable->pfnCalculateMetricExportDataExp = L0::zetDriverCalculateMetricExportDataExp;
return result;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2022 Intel Corporation
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -146,6 +146,31 @@ ze_result_t zetMetricQueryGetData(
return L0::MetricQuery::fromHandle(hMetricQuery)->getData(pRawDataSize, pRawData);
}
ze_result_t ZE_APICALL
zetMetricGroupGetExportDataExp(
zet_metric_group_handle_t hMetricGroup,
const uint8_t *pRawData,
size_t rawDataSize,
size_t *pExportDataSize,
uint8_t *pExportData) {
return L0::MetricGroup::fromHandle(hMetricGroup)->getExportData(pRawData, rawDataSize, pExportDataSize, pExportData);
}
ze_result_t ZE_APICALL
zetDriverCalculateMetricExportDataExp(
ze_driver_handle_t hDriver,
zet_metric_group_calculation_type_t type,
size_t exportDataSize,
const uint8_t *pExportData,
zet_metric_calculate_exp_desc_t *pCalculateDescriptor,
uint32_t *pSetCount,
uint32_t *pTotalMetricValueCount,
uint32_t *pMetricCounts,
zet_typed_value_t *pMetricValues) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
} // namespace L0
extern "C" {
@ -336,4 +361,29 @@ ZE_APIEXPORT ze_result_t ZE_APICALL zetMetricQueryGetData(
pRawDataSize,
pRawData);
}
ZE_APIEXPORT ze_result_t ZE_APICALL
zetMetricGroupGetExportDataExp(
zet_metric_group_handle_t hMetricGroup,
const uint8_t *pRawData,
size_t rawDataSize,
size_t *pExportDataSize,
uint8_t *pExportData) {
return L0::zetMetricGroupGetExportDataExp(hMetricGroup, pRawData, rawDataSize, pExportDataSize, pExportData);
}
ZE_APIEXPORT ze_result_t ZE_APICALL
zetDriverCalculateMetricExportDataExp(
ze_driver_handle_t hDriver,
zet_metric_group_calculation_type_t type,
size_t exportDataSize,
const uint8_t *pExportData,
zet_metric_calculate_exp_desc_t *pCalculateDescriptor,
uint32_t *pSetCount,
uint32_t *pTotalMetricValueCount,
uint32_t *pMetricCounts,
zet_typed_value_t *pMetricValues) {
return L0::zetDriverCalculateMetricExportDataExp(hDriver, type, exportDataSize, pExportData, pCalculateDescriptor,
pSetCount, pTotalMetricValueCount, pMetricCounts, pMetricValues);
}
}

View File

@ -0,0 +1,461 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#ifndef _ZET_INTEL_GPU_METRIC_H
#define _ZET_INTEL_GPU_METRIC_H
#include <level_zero/ze_api.h>
#if defined(__cplusplus)
#pragma once
extern "C" {
#endif
#include <stdint.h>
#define ZET_INTEL_GPU_METRIC_VERSION_MAJOR 0
#define ZET_INTEL_GPU_METRIC_VERSION_MINOR 1
#pragma pack(push, 1)
#define ZET_INTEL_GPU_METRIC_INVALID_OFFSET ((ptrdiff_t)0u)
#define zet_intel_metric_df_gpu_offset_to_ptr(type, offset, base) \
type##_to_pointer(offset, base);
typedef ptrdiff_t uint8_offset_t;
typedef ptrdiff_t cstring_offset_t;
typedef ptrdiff_t zet_intel_metric_df_gpu_equation_element_0_1_offset_t;
typedef ptrdiff_t zet_intel_metric_df_gpu_information_params_0_1_offset_t;
typedef ptrdiff_t zet_intel_metric_df_gpu_metric_params_0_1_offset_t;
typedef ptrdiff_t zet_intel_metric_df_gpu_global_symbol_0_1_offset_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_apiversion_0_1_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_apiversion_0_1_t {
uint32_t majorNumber;
uint32_t minorNumber;
uint32_t buildNumber;
} zet_intel_metric_df_gpu_apiversion_0_1_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_adapter_id_type_t
//////////////////////////////////////////////////////////////////////////////////
typedef enum _zet_intel_metric_df_gpu_adapter_id_type_t {
ZET_INTEL_METRIC_DF_ADAPTER_ID_TYPE_UNDEFINED = 0,
ZET_INTEL_METRIC_DF_ADAPTER_ID_TYPE_LUID,
ZET_INTEL_METRIC_DF_ADAPTER_ID_TYPE_MAJOR_MINOR,
ZET_INTEL_METRIC_DF_ADAPTER_ID_TYPE_FORCE_UINT32 = 0x7fffffff
} zet_intel_metric_df_gpu_adapter_id_type_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_adapter_id_luid_0_1_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_adapter_id_luid_0_1_t {
uint32_t lowPart;
int32_t highPart;
} zet_intel_metric_df_gpu_adapter_id_luid_0_1_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_adapter_id_major_minor_0_1_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_adapter_id_major_minor_0_1_t {
int32_t major;
int32_t minor;
} zet_intel_metric_df_gpu_adapter_id_major_minor_0_1_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_adapter_id_0_1_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_adapter_id_0_1_t {
zet_intel_metric_df_gpu_adapter_id_type_t type;
union {
zet_intel_metric_df_gpu_adapter_id_luid_0_1_t luid;
zet_intel_metric_df_gpu_adapter_id_major_minor_0_1_t majorMinor;
};
} zet_intel_metric_df_gpu_adapter_id_0_1_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_adapter_params_0_1_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_adapter_params_0_1_t {
zet_intel_metric_df_gpu_adapter_id_0_1_t systemId; // Operating system specific adapter id
uint32_t busNumber;
uint32_t deviceNumber;
uint32_t functionNumber;
uint32_t domainNumber;
} zet_intel_metric_df_gpu_adapter_params_0_1_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_metrics_device_params_0_1_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_metrics_device_params_0_1_t {
// API version
zet_intel_metric_df_gpu_apiversion_0_1_t version;
uint32_t globalSymbolsCount;
} zet_intel_metric_df_gpu_metrics_device_params_0_1_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_value_type_t
//////////////////////////////////////////////////////////////////////////////////
typedef enum _zet_intel_metric_df_gpu_value_type_t {
ZET_INTEL_METRIC_DF_VALUE_TYPE_UINT32,
ZET_INTEL_METRIC_DF_VALUE_TYPE_UINT64,
ZET_INTEL_METRIC_DF_VALUE_TYPE_FLOAT,
ZET_INTEL_METRIC_DF_VALUE_TYPE_BOOL,
ZET_INTEL_METRIC_DF_VALUE_TYPE_CSTRING,
ZET_INTEL_METRIC_DF_VALUE_TYPE_BYTEARRAY,
ZET_INTEL_METRIC_DF_VALUE_TYPE_FORCE_UINT32 = 0x7fffffff
} zet_intel_metric_df_gpu_value_type_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_byte_array_0_1_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_byte_array_0_1_t {
uint8_offset_t data;
uint32_t size;
} zet_intel_metric_df_gpu_byte_array_0_1_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_typed_value_0_1_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_typed_value_0_1_t {
union {
uint32_t valueUInt32;
uint64_t valueUInt64;
struct {
uint32_t low;
uint32_t high;
} valueUInt64Fields;
float valueFloat;
bool valueBool;
cstring_offset_t valueCString;
zet_intel_metric_df_gpu_byte_array_0_1_t valueByteArray;
};
zet_intel_metric_df_gpu_value_type_t valueType;
} zet_intel_metric_df_gpu_typed_value_0_1_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_global_symbol_0_1_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_global_symbol_0_1_t {
cstring_offset_t symbolName;
zet_intel_metric_df_gpu_typed_value_0_1_t symbolTypedValue;
} zet_intel_metric_df_gpu_global_symbol_0_1_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_equation_element_type_t
//////////////////////////////////////////////////////////////////////////////////
typedef enum _zet_intel_metric_df_gpu_equation_element_type_t {
ZET_INTEL_METRIC_DF_EQUATION_ELEM_OPERATION, // See Tequation_operation enumeration
ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_BITFIELD, //
ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_UINT8, //
ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_UINT16, //
ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_UINT32, //
ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_UINT64, //
ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_FLOAT, //
ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_40BIT_CNTR, // Assemble 40 bit counter that is in two locations, result in unsigned integer 64b
ZET_INTEL_METRIC_DF_EQUATION_ELEM_IMM_UINT64, //
ZET_INTEL_METRIC_DF_EQUATION_ELEM_IMM_FLOAT, //
ZET_INTEL_METRIC_DF_EQUATION_ELEM_SELF_COUNTER_VALUE, // Defined by $Self token, the UINT64 result of delta_function for IO or QueryReadEquation
ZET_INTEL_METRIC_DF_EQUATION_ELEM_GLOBAL_SYMBOL, // Defined by $"SymbolName", available in MetricsDevice SymbolTable
ZET_INTEL_METRIC_DF_EQUATION_ELEM_LOCAL_COUNTER_SYMBOL, // Defined by $"SymbolName", refers to counter delta value in the local set
ZET_INTEL_METRIC_DF_EQUATION_ELEM_OTHER_SET_COUNTER_SYMBOL, // Defined by concatenated string of $"setSymbolName/SymbolName", refers to counter
// Delta value in the other set
ZET_INTEL_METRIC_DF_EQUATION_ELEM_LOCAL_METRIC_SYMBOL, // Defined by $$"SymbolName", refers to metric normalized value in the local set
ZET_INTEL_METRIC_DF_EQUATION_ELEM_OTHER_SET_METRIC_SYMBOL, // Defined by concatenated string of $$"setSymbolName/SymbolName", refers to metric
// Normalized value in the other set
ZET_INTEL_METRIC_DF_EQUATION_ELEM_INFORMATION_SYMBOL, // Defined by i$"SymbolName", refers to information value type only
ZET_INTEL_METRIC_DF_EQUATION_ELEM_STD_NORM_GPU_DURATION, // Action is $Self $GpuCoreClocks FDIV 100 FMUL
ZET_INTEL_METRIC_DF_EQUATION_ELEM_STD_NORM_EU_AGGR_DURATION, // Action is $Self $GpuCoreClocks $EuCoresTotalCount UMUL FDIV 100 FMUL
ZET_INTEL_METRIC_DF_EQUATION_ELEM_MASK,
ZET_INTEL_METRIC_DF_EQUATION_ELEM_FORCE_UINT32 = 0x7fffffff
} zet_intel_metric_df_gpu_equation_element_type_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_equation_operation_t
//////////////////////////////////////////////////////////////////////////////////
typedef enum _zet_intel_metric_df_gpu_equation_operation_t {
ZET_INTEL_METRIC_DF_EQUATION_OPER_RSHIFT, // 64b unsigned integer right shift
ZET_INTEL_METRIC_DF_EQUATION_OPER_LSHIFT, // 64b unsigned integer left shift
ZET_INTEL_METRIC_DF_EQUATION_OPER_AND, // Bitwise AND of two unsigned integers, 64b each
ZET_INTEL_METRIC_DF_EQUATION_OPER_OR, // Bitwise OR of two unsigned integers, 64b each
ZET_INTEL_METRIC_DF_EQUATION_OPER_XOR, // Bitwise XOR of two unsigned integers, 64b each
ZET_INTEL_METRIC_DF_EQUATION_OPER_XNOR, // Bitwise XNOR of two unsigned integers, 64b each
ZET_INTEL_METRIC_DF_EQUATION_OPER_AND_L, // Logical AND (C-like "&&") of two unsigned integers, 64b each, result is true(1) if both values are true(greater than 0)
ZET_INTEL_METRIC_DF_EQUATION_OPER_EQUALS, // Equality (C-like "==") of two unsigned integers, 64b each, result is true(1) or false(0)
ZET_INTEL_METRIC_DF_EQUATION_OPER_UADD, // Unsigned integer add, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b
ZET_INTEL_METRIC_DF_EQUATION_OPER_USUB, // Unsigned integer subtract, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b
ZET_INTEL_METRIC_DF_EQUATION_OPER_UMUL, // Unsigned integer mul, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b
ZET_INTEL_METRIC_DF_EQUATION_OPER_UDIV, // Unsigned integer div, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b
ZET_INTEL_METRIC_DF_EQUATION_OPER_FADD, // Floating point add, arguments are casted to be 32b floating points, result is a 32b float
ZET_INTEL_METRIC_DF_EQUATION_OPER_FSUB, // Floating point subtract, arguments are casted to be 32b floating points, result is a 32b float
ZET_INTEL_METRIC_DF_EQUATION_OPER_FMUL, // Floating point multiply, arguments are casted to be 32b floating points, result is a 32b float
ZET_INTEL_METRIC_DF_EQUATION_OPER_FDIV, // Floating point divide, arguments are casted to be 32b floating points, result is a 32b float
ZET_INTEL_METRIC_DF_EQUATION_OPER_UGT, // 64b unsigned integers comparison of is greater than, result is bool true(1) or false(0)
ZET_INTEL_METRIC_DF_EQUATION_OPER_ULT, // 64b unsigned integers comparison of is less than, result is bool true(1) or false(0)
ZET_INTEL_METRIC_DF_EQUATION_OPER_UGTE, // 64b unsigned integers comparison of is greater than or equal, result is bool true(1) or false(0)
ZET_INTEL_METRIC_DF_EQUATION_OPER_ULTE, // 64b unsigned integers comparison of is less than or equal, result is bool true(1) or false(0)
ZET_INTEL_METRIC_DF_EQUATION_OPER_FGT, // 32b floating point numbers comparison of is greater than, result is bool true(1) or false(0)
ZET_INTEL_METRIC_DF_EQUATION_OPER_FLT, // 32b floating point numbers comparison of is less than, result is bool true(1) or false(0)
ZET_INTEL_METRIC_DF_EQUATION_OPER_FGTE, // 32b floating point numbers comparison of is greater than or equal, result is bool true(1) or false(0)
ZET_INTEL_METRIC_DF_EQUATION_OPER_FLTE, // 32b floating point numbers comparison of is less than or equal, result is bool true(1) or false(0)
ZET_INTEL_METRIC_DF_EQUATION_OPER_UMIN, // Unsigned integer MIN function, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b
ZET_INTEL_METRIC_DF_EQUATION_OPER_UMAX, // Unsigned integer MAX function, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b
ZET_INTEL_METRIC_DF_EQUATION_OPER_FMIN, // Floating point MIN function, arguments are casted to be 32b floating points, result is a 32b float
ZET_INTEL_METRIC_DF_EQUATION_OPER_FMAX, // Floating point MAX function, arguments are casted to be 32b floating points, result is a 32b float
ZET_INTEL_METRIC_DF_EQUATION_OPER_FORCE_UINT32 = 0x7fffffff
} zet_intel_metric_df_gpu_equation_operation_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_read_params_0_1_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_read_params_0_1_t {
uint32_t byteOffset;
uint32_t bitOffset;
uint32_t bitsCount;
uint32_t byteOffsetExt;
} zet_intel_metric_df_gpu_read_params_0_1_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_equation_element_0_1_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_equation_element_0_1_t {
cstring_offset_t symbolName;
union {
uint64_t immediateUInt64;
float immediateFloat;
zet_intel_metric_df_gpu_byte_array_0_1_t mask;
zet_intel_metric_df_gpu_equation_operation_t operation;
zet_intel_metric_df_gpu_read_params_0_1_t readParams;
};
zet_intel_metric_df_gpu_equation_element_type_t type;
} zet_intel_metric_df_gpu_equation_element_0_1_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_equation_0_1_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_equation_0_1_t {
uint32_t elementCount;
zet_intel_metric_df_gpu_equation_element_0_1_offset_t elements;
} zet_intel_metric_df_gpu_equation_0_1_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_metric_result_type_t
//////////////////////////////////////////////////////////////////////////////////
typedef enum _zet_intel_metric_df_gpu_metric_result_type_t {
ZET_INTEL_METRIC_DF_RESULT_UINT32,
ZET_INTEL_METRIC_DF_RESULT_UINT64,
ZET_INTEL_METRIC_DF_RESULT_BOOL,
ZET_INTEL_METRIC_DF_RESULT_FLOAT,
ZET_INTEL_METRIC_DF_RESULT_FORCE_UINT32 = 0x7fffffff
} zet_intel_metric_df_gpu_metric_result_type_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_delta_function_type_t
//////////////////////////////////////////////////////////////////////////////////
typedef enum _zet_intel_metric_df_gpu_delta_function_type_t {
ZET_INTEL_METRIC_DF_DELTA_FUNCTION_NULL = 0,
ZET_INTEL_METRIC_DF_DELTA_N_BITS,
ZET_INTEL_METRIC_DF_DELTA_BOOL_OR, // Logic OR - good for exceptions
ZET_INTEL_METRIC_DF_DELTA_BOOL_XOR, // Logic XOR - good to check if bits were changed
ZET_INTEL_METRIC_DF_DELTA_GET_PREVIOUS, // Preserve previous value
ZET_INTEL_METRIC_DF_DELTA_GET_LAST, // Preserve last value
ZET_INTEL_METRIC_DF_DELTA_NS_TIME, // Delta for nanosecond timestamps (GPU timestamp wraps at 32 bits but was value multiplied by 80)
ZET_INTEL_METRIC_DF_DELTA_FORCE_UINT32 = 0x7fffffff
} zet_intel_metric_df_gpu_delta_function_type_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_metric_type_t
//////////////////////////////////////////////////////////////////////////////////
typedef enum _zet_intel_metric_df_gpu_metric_type_t {
ZET_INTEL_METRIC_DF_METRIC_TYPE_DURATION,
ZET_INTEL_METRIC_DF_METRIC_TYPE_EVENT,
ZET_INTEL_METRIC_DF_METRIC_TYPE_EVENT_WITH_RANGE,
ZET_INTEL_METRIC_DF_METRIC_TYPE_THROUGHPUT,
ZET_INTEL_METRIC_DF_METRIC_TYPE_TIMESTAMP,
ZET_INTEL_METRIC_DF_METRIC_TYPE_FLAG,
ZET_INTEL_METRIC_DF_METRIC_TYPE_RATIO,
ZET_INTEL_METRIC_DF_METRIC_TYPE_RAW,
ZET_INTEL_METRIC_DF_METRIC_TYPE_FORCE_UINT32 = 0x7fffffff
} zet_intel_metric_df_gpu_metric_type_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_delta_function_0_1_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_delta_function_0_1_t {
zet_intel_metric_df_gpu_delta_function_type_t functionType;
union {
uint32_t bitsCount; // Used for DELTA_N_BITS to specify bits count
};
} zet_intel_metric_df_gpu_delta_function_0_1_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_metric_params_0_1_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_metric_params_0_1_t {
cstring_offset_t symbolName; // Symbol name, used in equations
cstring_offset_t shortName; // Consistent metric name, not changed platform to platform
cstring_offset_t groupName; // VertexShader for example
cstring_offset_t longName; // Hint about the metric shown to users
uint32_t idInSet; // Position in set (may change after SetApiFiltering)
uint32_t apiMask; //
cstring_offset_t metricResultUnits; //
zet_intel_metric_df_gpu_metric_type_t metricType; //
zet_intel_metric_df_gpu_equation_0_1_t ioReadEquation; // Read equation specification for IO stream (accessing raw values potentially spread in report in several locations)
zet_intel_metric_df_gpu_equation_0_1_t queryReadEquation; // Read equation specification for query (accessing calculated delta values)
zet_intel_metric_df_gpu_delta_function_0_1_t deltaFunction; //
zet_intel_metric_df_gpu_equation_0_1_t normEquation; // Normalization equation to get normalized value to bytes transfered or to a percentage of utilization
zet_intel_metric_df_gpu_equation_0_1_t maxValueEquation; // To calculate metrics max value as a function of other metrics and device parameters (e.g. 100 for percentage)
uint32_t usageFlagsMask;
zet_intel_metric_df_gpu_metric_result_type_t resultType;
} zet_intel_metric_df_gpu_metric_params_0_1_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_information_type_t
//////////////////////////////////////////////////////////////////////////////////
typedef enum _zet_intel_metric_df_gpu_information_type_t {
ZET_INTEL_METRIC_DF_INFORMATION_TYPE_REPORT_REASON,
ZET_INTEL_METRIC_DF_INFORMATION_TYPE_VALUE,
ZET_INTEL_METRIC_DF_INFORMATION_TYPE_FLAG,
ZET_INTEL_METRIC_DF_INFORMATION_TYPE_TIMESTAMP,
ZET_INTEL_METRIC_DF_INFORMATION_TYPE_CONTEXT_ID_TAG,
ZET_INTEL_METRIC_DF_INFORMATION_TYPE_SAMPLE_PHASE,
ZET_INTEL_METRIC_DF_INFORMATION_TYPE_GPU_NODE,
ZET_INTEL_METRIC_DF_INFORMATION_TYPE_FORCE_UINT32 = 0x7fffffff
} zet_intel_metric_df_gpu_information_type_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_information_params_0_1_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_information_params_0_1_t {
cstring_offset_t symbolName; // Symbol name, used in equations
cstring_offset_t shortName; // Consistent name, not changed platform to platform
cstring_offset_t groupName; // Some more global context of the information
cstring_offset_t longName; // Hint about the information shown to users
uint32_t idInSet;
uint32_t apiMask; //
zet_intel_metric_df_gpu_information_type_t infoType; //
cstring_offset_t infoUnits; //
zet_intel_metric_df_gpu_equation_0_1_t ioReadEquation; // Read equation specification for IO stream (accessing raw values potentially spread in report in several locations)
zet_intel_metric_df_gpu_equation_0_1_t queryReadEquation; // Read equation specification for query (accessing calculated delta values)
zet_intel_metric_df_gpu_delta_function_0_1_t overflowFunction; //
} zet_intel_metric_df_gpu_information_params_0_1_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_metric_set_params_0_1_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_metric_set_params_0_1_t {
cstring_offset_t symbolName; // For example "Dx11Tessellation"
cstring_offset_t shortName; // For example "DX11 Tessellation Metrics Set"
uint32_t apiMask;
uint32_t metricsCount;
uint32_t informationCount;
cstring_offset_t availabilityEquation;
} zet_intel_metric_df_gpu_metric_set_params_0_1_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_concurrent_group_params_0_1_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_concurrent_group_params_0_1_t {
cstring_offset_t symbolName; // For example "OA" or "OAM0" or "PipeStats"
cstring_offset_t description; // For example "OA Unit Metrics"
uint32_t ioMeasurementInformationCount;
uint32_t ioGpuContextInformationCount;
} zet_intel_metric_df_gpu_concurrent_group_params_0_1_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_concurrent_group_0_1_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_concurrent_group_0_1_t {
zet_intel_metric_df_gpu_concurrent_group_params_0_1_t params;
zet_intel_metric_df_gpu_information_params_0_1_offset_t ioMeasurementInformation;
zet_intel_metric_df_gpu_information_params_0_1_offset_t ioGpuContextInformation;
} zet_intel_metric_df_gpu_concurrent_group_0_1_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_metric_set_0_1_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_metric_set_0_1_t {
zet_intel_metric_df_gpu_metric_set_params_0_1_t params;
zet_intel_metric_df_gpu_information_params_0_1_offset_t informationParams;
zet_intel_metric_df_gpu_metric_params_0_1_offset_t metricParams;
} zet_intel_metric_df_gpu_metric_set_0_1_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_metric_oa_calc_0_1_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_metric_oa_calc_0_1_t {
zet_intel_metric_df_gpu_metrics_device_params_0_1_t deviceParams;
zet_intel_metric_df_gpu_global_symbol_0_1_offset_t globalSymbols;
zet_intel_metric_df_gpu_adapter_params_0_1_t adapterParams;
zet_intel_metric_df_gpu_concurrent_group_0_1_t concurrentGroup;
zet_intel_metric_df_gpu_metric_set_0_1_t metricSet;
} zet_intel_metric_df_gpu_metric_oa_calc_0_1_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_export_data_format_0_1_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_export_data_format_0_1_t {
union {
zet_intel_metric_df_gpu_metric_oa_calc_0_1_t oaData;
};
} zet_intel_metric_df_gpu_export_data_format_0_1_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_metric_source_type_t
//////////////////////////////////////////////////////////////////////////////////
typedef enum _zet_intel_metric_df_gpu_metric_source_type_t {
ZET_INTEL_METRIC_DF_SOURCE_TYPE_OA,
ZET_INTEL_METRIC_DF_SOURCE_TYPE_IPSAMPLING,
ZET_INTEL_METRIC_DF_SOURCE_TYPE_FORCE_UINT32 = 0x7fffffff
} zet_intel_metric_df_gpu_metric_source_type_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_metric_version_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_metric_version_t {
uint32_t major;
uint32_t minor;
uint32_t reserved[2];
} zet_intel_metric_df_gpu_metric_version_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_header_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_header_t {
zet_intel_metric_df_gpu_metric_source_type_t type;
zet_intel_metric_df_gpu_metric_version_t version;
ze_device_type_t deviceType;
uint64_t rawDataOffset;
uint64_t rawDataSize;
uint8_t reserved[256];
} zet_intel_metric_df_gpu_header_t;
//////////////////////////////////////////////////////////////////////////////////
// zet_intel_metric_df_gpu_export_data_format_t
//////////////////////////////////////////////////////////////////////////////////
typedef struct _zet_intel_metric_df_gpu_export_data_format_t {
zet_intel_metric_df_gpu_header_t header;
zet_intel_metric_df_gpu_export_data_format_0_1_t format01;
} zet_intel_metric_df_gpu_export_data_format_t;
#define offset_to_pointer(offset, base) (ZET_INTEL_GPU_METRIC_INVALID_OFFSET == offset ? nullptr : (uint8_t *)base + offset)
#define uint8_offset_t_to_pointer(offset, base) (uint8_t *)offset_to_pointer(offset, base)
#define cstring_offset_t_to_pointer(offset, base) (const char *)offset_to_pointer(offset, base)
#define zet_intel_metric_df_gpu_equation_element_0_1_offset_t_to_pointer(offset, base) (zet_intel_metric_df_gpu_equation_element_0_1_t *)offset_to_pointer(offset, base)
#define zet_intel_metric_df_gpu_information_params_0_1_offset_t_to_pointer(offset, base) (zet_intel_metric_df_gpu_information_params_0_1_t *)offset_to_pointer(offset, base)
#define zet_intel_metric_df_gpu_metric_params_0_1_offset_t_to_pointer(offset, base) (zet_intel_metric_df_gpu_metric_params_0_1_t *)offset_to_pointer(offset, base)
#define zet_intel_metric_df_gpu_global_symbol_0_1_offset_t_to_pointer(offset, base) (zet_intel_metric_df_gpu_global_symbol_0_1_t *)offset_to_pointer(offset, base)
#pragma pack(pop)
#if defined(__cplusplus)
} // extern "C"
#endif
#endif // _ZET_INTEL_GPU_METRIC_H

View File

@ -16,6 +16,8 @@ target_sources(${L0_STATIC_LIB_NAME}
${CMAKE_CURRENT_SOURCE_DIR}/metric_oa_query_imp.h
${CMAKE_CURRENT_SOURCE_DIR}/metric_oa_source.cpp
${CMAKE_CURRENT_SOURCE_DIR}/metric_oa_source.h
${CMAKE_CURRENT_SOURCE_DIR}/metric_oa_export_data.cpp
${CMAKE_CURRENT_SOURCE_DIR}/metric_oa_export_data.h
${CMAKE_CURRENT_SOURCE_DIR}/metric_ip_sampling_source.h
${CMAKE_CURRENT_SOURCE_DIR}/metric_ip_sampling_source.cpp
${CMAKE_CURRENT_SOURCE_DIR}/metric_ip_sampling_streamer.h

View File

@ -119,6 +119,8 @@ struct MetricGroup : _zet_metric_group_handle_t {
const zet_metric_query_pool_desc_t *desc,
zet_metric_query_pool_handle_t *phMetricQueryPool) = 0;
ze_result_t getMetricGroupExtendedProperties(MetricSource &metricSource, void *pnext);
virtual ze_result_t getExportData(const uint8_t *pRawData, size_t rawDataSize, size_t *pExportDataSize,
uint8_t *pExportData) = 0;
};
struct MetricGroupCalculateHeader {

View File

@ -13,6 +13,7 @@
#include "level_zero/core/source/device/device.h"
#include "level_zero/core/source/device/device_imp.h"
#include "level_zero/include/zet_intel_gpu_metric.h"
#include "level_zero/tools/source/metrics/metric.h"
#include "level_zero/tools/source/metrics/metric_ip_sampling_streamer.h"
#include "level_zero/tools/source/metrics/os_interface_metric.h"
@ -148,6 +149,35 @@ void IpSamplingMetricSourceImp::setMetricOsInterface(std::unique_ptr<MetricIpSam
this->metricIPSamplingpOsInterface = std::move(metricIPSamplingpOsInterface);
}
ze_result_t IpSamplingMetricGroupBase::getExportData(const uint8_t *pRawData, size_t rawDataSize, size_t *pExportDataSize,
uint8_t *pExportData) {
const auto expectedExportDataSize = sizeof(zet_intel_metric_df_gpu_export_data_format_t) + rawDataSize;
if (*pExportDataSize == 0u) {
*pExportDataSize = expectedExportDataSize;
return ZE_RESULT_SUCCESS;
}
if (*pExportDataSize < expectedExportDataSize) {
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr,
"Error:Incorrect Size Passed at %s():%d returning 0x%x\n",
__FUNCTION__, __LINE__, ZE_RESULT_ERROR_INVALID_SIZE);
return ZE_RESULT_ERROR_INVALID_SIZE;
}
zet_intel_metric_df_gpu_export_data_format_t *exportData = reinterpret_cast<zet_intel_metric_df_gpu_export_data_format_t *>(pExportData);
exportData->header.type = ZET_INTEL_METRIC_DF_SOURCE_TYPE_IPSAMPLING;
exportData->header.version.major = ZET_INTEL_GPU_METRIC_VERSION_MAJOR;
exportData->header.version.minor = ZET_INTEL_GPU_METRIC_VERSION_MINOR;
exportData->header.rawDataOffset = sizeof(zet_intel_metric_df_gpu_export_data_format_t);
exportData->header.rawDataSize = rawDataSize;
// Append the rawData
memcpy_s(reinterpret_cast<void *>(pExportData + exportData->header.rawDataOffset), rawDataSize, pRawData, rawDataSize);
return ZE_RESULT_SUCCESS;
}
IpSamplingMetricGroupImp::IpSamplingMetricGroupImp(IpSamplingMetricSourceImp &metricSource,
std::vector<IpSamplingMetricImp> &metrics) : metricSource(metricSource) {
this->metrics.reserve(metrics.size());

View File

@ -65,6 +65,7 @@ struct IpSamplingMetricGroupBase : public MetricGroup {
zet_device_handle_t hDevice,
const zet_metric_query_pool_desc_t *desc,
zet_metric_query_pool_handle_t *phMetricQueryPool) override { return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; }
ze_result_t getExportData(const uint8_t *pRawData, size_t rawDataSize, size_t *pExportDataSize, uint8_t *pExportData) override;
};
struct IpSamplingMetricGroupImp : public IpSamplingMetricGroupBase {

View File

@ -1031,6 +1031,15 @@ const MetricEnumeration &OaMetricGroupImp::getMetricEnumeration() const {
return metricSource->getMetricEnumeration();
}
void OaMetricGroupImp::setCachedExportDataHeapSize(size_t size) {
for (auto &metricGroupHanlde : metricGroups) {
auto metricGroup = L0::MetricGroup::fromHandle(metricGroupHanlde);
auto oaMetricGroupImp = static_cast<OaMetricGroupImp *>(metricGroup);
oaMetricGroupImp->setCachedExportDataHeapSize(size);
}
cachedExportDataHeapSize = size;
}
ze_result_t OaMetricImp::getProperties(zet_metric_properties_t *pProperties) {
copyProperties(properties, *pProperties);
return ZE_RESULT_SUCCESS;

View File

@ -37,6 +37,9 @@ struct MetricEnumeration {
bool readGlobalSymbol(const char *name, uint64_t &symbolValue);
MetricsDiscovery::IMetricsDevice_1_5 *getMetricDevice() { return pMetricsDevice; };
MetricsDiscovery::IMetricsDevice_1_5 *getMdapiDevice() { return pMetricsDevice; }
MetricsDiscovery::IAdapter_1_9 *getMdapiAdapter() { return pAdapter; }
protected:
ze_result_t initialize();
@ -130,6 +133,8 @@ struct OaMetricGroupImp : MetricGroup {
zet_device_handle_t hDevice,
const zet_metric_query_pool_desc_t *desc,
zet_metric_query_pool_handle_t *phMetricQueryPool) override;
ze_result_t getExportData(const uint8_t *pRawData, size_t rawDataSize, size_t *pExportDataSize,
uint8_t *pExportData) override;
static MetricGroup *create(zet_metric_group_properties_t &properties,
MetricsDiscovery::IMetricSet_1_5 &metricSet,
MetricsDiscovery::IConcurrentGroup_1_5 &concurrentGroup,
@ -140,6 +145,7 @@ struct OaMetricGroupImp : MetricGroup {
static ze_result_t getProperties(const zet_metric_group_handle_t handle, zet_metric_group_properties_t *pProperties);
uint32_t getRawReportSize();
const MetricEnumeration &getMetricEnumeration() const;
void setCachedExportDataHeapSize(size_t size);
protected:
void copyProperties(const zet_metric_group_properties_t &source,
@ -153,6 +159,7 @@ struct OaMetricGroupImp : MetricGroup {
ze_result_t getCalculatedMetricValues(const zet_metric_group_calculation_type_t, const size_t rawDataSize, const uint8_t *pRawData,
uint32_t &metricValueCount,
zet_typed_value_t *pCalculatedData);
ze_result_t getExportDataHeapSize(size_t &exportDataHeapSize);
// Cached metrics.
std::vector<Metric *> metrics;
@ -161,8 +168,8 @@ struct OaMetricGroupImp : MetricGroup {
MetricsDiscovery::IConcurrentGroup_1_5 *pReferenceConcurrentGroup = nullptr;
std::vector<zet_metric_group_handle_t> metricGroups;
OaMetricSourceImp *metricSource;
size_t cachedExportDataHeapSize = 0;
private:
ze_result_t openForDevice(Device *pDevice, zet_metric_streamer_desc_t &desc,

View File

@ -0,0 +1,795 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/tools/source/metrics/metric_oa_export_data.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/helpers/string.h"
#include "level_zero/tools/source/metrics/metric_oa_enumeration_imp.h"
#include "level_zero/tools/source/metrics/metric_oa_source.h"
#include <algorithm>
#include <map>
namespace L0 {
HeapUsageTracker::HeapUsageTracker(uintptr_t startAddress,
uintptr_t endAddress,
OperationMode mode) : currentAddress(startAddress),
endAddress(endAddress),
operationMode(mode) {
currentOffset = sizeof(zet_intel_metric_df_gpu_export_data_format_t);
}
template <typename T>
std::pair<T *, ptrdiff_t> HeapUsageTracker::allocate(uint64_t count) {
const auto size = count * sizeof(T);
std::pair<T *, ptrdiff_t> returnVal{};
if (operationMode == OperationModeTrackAndAllocate) {
UNRECOVERABLE_IF(currentAddress + size > endAddress);
returnVal = {reinterpret_cast<T *>(currentAddress), currentOffset};
currentAddress += size;
} else {
returnVal = {nullptr, currentOffset};
}
currentOffset += size;
return returnVal;
}
size_t HeapUsageTracker::getUsedBytes() {
return static_cast<size_t>(currentOffset - sizeof(zet_intel_metric_df_gpu_export_data_format_t));
}
MetricOaExporter01::MetricOaExporter01(MetricsDiscovery::IMetricsDevice_1_5 &mdDevice,
MetricsDiscovery::IAdapter_1_9 &mdAdapter,
MetricsDiscovery::IMetricSet_1_5 &mdMetricSet,
MetricsDiscovery::IConcurrentGroup_1_5 &mdConcurrentGroup,
HeapUsageTracker &heapUsageTracker) : mdDevice(mdDevice), adapter(mdAdapter),
mdMetricSet(mdMetricSet),
concurrentGroup(mdConcurrentGroup),
heapUsageTracker(heapUsageTracker) {
if (heapUsageTracker.getOperationMode() == HeapUsageTracker::OperationModeTrackAndAllocate) {
currOperationMode = OperationModeGetExportData;
} else {
currOperationMode = OperationModeGetHeapSize;
}
}
template <typename T>
void MetricOaExporter01::assignUnaligned(T *unAlignedData, T *alignedData) {
memcpy_s(unAlignedData, sizeof(T), alignedData, sizeof(T));
}
void MetricOaExporter01::updateMetricApiVersion(zet_intel_metric_df_gpu_apiversion_0_1_t *apiVersion) {
MetricsDiscovery::TMetricsDeviceParams_1_2 *metricsDeviceParams = mdDevice.GetParams();
DEBUG_BREAK_IF(metricsDeviceParams == nullptr);
assignUnaligned(&apiVersion->majorNumber, &metricsDeviceParams->Version.MajorNumber);
assignUnaligned(&apiVersion->minorNumber, &metricsDeviceParams->Version.MinorNumber);
assignUnaligned(&apiVersion->buildNumber, &metricsDeviceParams->Version.BuildNumber);
}
void MetricOaExporter01::assignCstringOffset(cstring_offset_t *cStringOffset, const char *stringValue) {
if (stringValue == nullptr) {
cstring_offset_t offset = ZET_INTEL_GPU_METRIC_INVALID_OFFSET;
assignUnaligned(cStringOffset, &offset);
return;
}
auto bytesNecessary = strnlen_s(stringValue, 512u) + 1;
auto [address, offset] = heapUsageTracker.allocate<uint8_t>(bytesNecessary);
if (currOperationMode == OperationModeGetExportData) {
strcpy_s(reinterpret_cast<char *>(address), bytesNecessary, stringValue);
assignUnaligned(cStringOffset, &offset);
}
}
void MetricOaExporter01::assignByteArray(zet_intel_metric_df_gpu_byte_array_0_1_t *byteArray, MetricsDiscovery::TByteArray_1_0 *mdByteArray) {
auto bytesNecessary = mdByteArray->Size;
auto [address, offset] = heapUsageTracker.allocate<uint8_t>(bytesNecessary);
if (currOperationMode == OperationModeGetExportData) {
memcpy_s(address, bytesNecessary, mdByteArray->Data, bytesNecessary);
assignUnaligned(&byteArray->data, &offset);
assignUnaligned(&byteArray->size, &bytesNecessary);
}
}
ze_result_t MetricOaExporter01::assignTypedValue(zet_intel_metric_df_gpu_typed_value_0_1_t *typedValue, MetricsDiscovery::TTypedValue_1_0 &mdTypedValue) {
auto type = ZET_INTEL_METRIC_DF_VALUE_TYPE_FORCE_UINT32;
switch (mdTypedValue.ValueType) {
case MetricsDiscovery::VALUE_TYPE_UINT32:
type = ZET_INTEL_METRIC_DF_VALUE_TYPE_UINT32;
assignUnaligned(&typedValue->valueUInt32, &mdTypedValue.ValueUInt32);
break;
case MetricsDiscovery::VALUE_TYPE_UINT64:
type = ZET_INTEL_METRIC_DF_VALUE_TYPE_UINT64;
assignUnaligned(&typedValue->valueUInt64, &mdTypedValue.ValueUInt64);
break;
case MetricsDiscovery::VALUE_TYPE_FLOAT:
type = ZET_INTEL_METRIC_DF_VALUE_TYPE_FLOAT;
assignUnaligned(&typedValue->valueFloat, &mdTypedValue.ValueFloat);
break;
case MetricsDiscovery::VALUE_TYPE_BOOL:
type = ZET_INTEL_METRIC_DF_VALUE_TYPE_BOOL;
assignUnaligned(&typedValue->valueBool, &mdTypedValue.ValueBool);
break;
case MetricsDiscovery::VALUE_TYPE_CSTRING:
type = ZET_INTEL_METRIC_DF_VALUE_TYPE_CSTRING;
assignCstringOffset(&typedValue->valueCString, mdTypedValue.ValueCString);
break;
case MetricsDiscovery::VALUE_TYPE_BYTEARRAY:
type = ZET_INTEL_METRIC_DF_VALUE_TYPE_BYTEARRAY;
assignByteArray(&typedValue->valueByteArray, mdTypedValue.ValueByteArray);
break;
default:
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr,
"Error: Unknown Typed value 0x%x at %s():%d returning 0x%x\n",
static_cast<uint32_t>(mdTypedValue.ValueType),
__FUNCTION__, __LINE__, ZE_RESULT_ERROR_UNSUPPORTED_VERSION);
return ZE_RESULT_ERROR_UNSUPPORTED_VERSION;
}
assignUnaligned(&typedValue->valueType, &type);
return ZE_RESULT_SUCCESS;
}
ze_result_t MetricOaExporter01::assignAdapterId(zet_intel_metric_df_gpu_adapter_id_0_1_t *adapterId, MetricsDiscovery::TAdapterId_1_6 *mAdapterId) {
auto type = ZET_INTEL_METRIC_DF_ADAPTER_ID_TYPE_FORCE_UINT32;
switch (mAdapterId->Type) {
case MetricsDiscovery::ADAPTER_ID_TYPE_LUID:
type = ZET_INTEL_METRIC_DF_ADAPTER_ID_TYPE_LUID;
assignUnaligned(&adapterId->luid.lowPart, &mAdapterId->Luid.LowPart);
assignUnaligned(&adapterId->luid.highPart, &mAdapterId->Luid.HighPart);
break;
case MetricsDiscovery::ADAPTER_ID_TYPE_MAJOR_MINOR:
type = ZET_INTEL_METRIC_DF_ADAPTER_ID_TYPE_MAJOR_MINOR;
assignUnaligned(&adapterId->majorMinor.major, &mAdapterId->MajorMinor.Major);
assignUnaligned(&adapterId->majorMinor.minor, &mAdapterId->MajorMinor.Minor);
break;
default:
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr,
"Error: Unknown Adapter Type 0x%x at %s():%d returning 0x%x\n",
static_cast<uint32_t>(mAdapterId->Type),
__FUNCTION__, __LINE__, ZE_RESULT_ERROR_UNSUPPORTED_VERSION);
return ZE_RESULT_ERROR_UNSUPPORTED_VERSION;
}
assignUnaligned(&adapterId->type, &type);
return ZE_RESULT_SUCCESS;
}
ze_result_t MetricOaExporter01::getEquationOperation(zet_intel_metric_df_gpu_equation_operation_t &equationOperation,
const MetricsDiscovery::TEquationOperation mdEquationOperation) {
std::map<MetricsDiscovery::TEquationOperation, zet_intel_metric_df_gpu_equation_operation_t> equationOperationMap = {
{MetricsDiscovery::EQUATION_OPER_RSHIFT, ZET_INTEL_METRIC_DF_EQUATION_OPER_RSHIFT},
{MetricsDiscovery::EQUATION_OPER_LSHIFT, ZET_INTEL_METRIC_DF_EQUATION_OPER_LSHIFT},
{MetricsDiscovery::EQUATION_OPER_AND, ZET_INTEL_METRIC_DF_EQUATION_OPER_AND},
{MetricsDiscovery::EQUATION_OPER_OR, ZET_INTEL_METRIC_DF_EQUATION_OPER_OR},
{MetricsDiscovery::EQUATION_OPER_XOR, ZET_INTEL_METRIC_DF_EQUATION_OPER_XOR},
{MetricsDiscovery::EQUATION_OPER_XNOR, ZET_INTEL_METRIC_DF_EQUATION_OPER_XNOR},
{MetricsDiscovery::EQUATION_OPER_AND_L, ZET_INTEL_METRIC_DF_EQUATION_OPER_AND_L},
{MetricsDiscovery::EQUATION_OPER_EQUALS, ZET_INTEL_METRIC_DF_EQUATION_OPER_EQUALS},
{MetricsDiscovery::EQUATION_OPER_UADD, ZET_INTEL_METRIC_DF_EQUATION_OPER_UADD},
{MetricsDiscovery::EQUATION_OPER_USUB, ZET_INTEL_METRIC_DF_EQUATION_OPER_USUB},
{MetricsDiscovery::EQUATION_OPER_UMUL, ZET_INTEL_METRIC_DF_EQUATION_OPER_UMUL},
{MetricsDiscovery::EQUATION_OPER_UDIV, ZET_INTEL_METRIC_DF_EQUATION_OPER_UDIV},
{MetricsDiscovery::EQUATION_OPER_FADD, ZET_INTEL_METRIC_DF_EQUATION_OPER_FADD},
{MetricsDiscovery::EQUATION_OPER_FSUB, ZET_INTEL_METRIC_DF_EQUATION_OPER_FSUB},
{MetricsDiscovery::EQUATION_OPER_FMUL, ZET_INTEL_METRIC_DF_EQUATION_OPER_FMUL},
{MetricsDiscovery::EQUATION_OPER_FDIV, ZET_INTEL_METRIC_DF_EQUATION_OPER_FDIV},
{MetricsDiscovery::EQUATION_OPER_UGT, ZET_INTEL_METRIC_DF_EQUATION_OPER_UGT},
{MetricsDiscovery::EQUATION_OPER_ULT, ZET_INTEL_METRIC_DF_EQUATION_OPER_ULT},
{MetricsDiscovery::EQUATION_OPER_UGTE, ZET_INTEL_METRIC_DF_EQUATION_OPER_UGTE},
{MetricsDiscovery::EQUATION_OPER_ULTE, ZET_INTEL_METRIC_DF_EQUATION_OPER_ULTE},
{MetricsDiscovery::EQUATION_OPER_FGT, ZET_INTEL_METRIC_DF_EQUATION_OPER_FGT},
{MetricsDiscovery::EQUATION_OPER_FLT, ZET_INTEL_METRIC_DF_EQUATION_OPER_FLT},
{MetricsDiscovery::EQUATION_OPER_FGTE, ZET_INTEL_METRIC_DF_EQUATION_OPER_FGTE},
{MetricsDiscovery::EQUATION_OPER_FLTE, ZET_INTEL_METRIC_DF_EQUATION_OPER_FLTE},
{MetricsDiscovery::EQUATION_OPER_UMIN, ZET_INTEL_METRIC_DF_EQUATION_OPER_UMIN},
{MetricsDiscovery::EQUATION_OPER_UMAX, ZET_INTEL_METRIC_DF_EQUATION_OPER_UMAX},
{MetricsDiscovery::EQUATION_OPER_FMIN, ZET_INTEL_METRIC_DF_EQUATION_OPER_FMIN},
{MetricsDiscovery::EQUATION_OPER_FMAX, ZET_INTEL_METRIC_DF_EQUATION_OPER_FMAX},
};
if (equationOperationMap.find(mdEquationOperation) == equationOperationMap.end()) {
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr,
"Error: Unknown Equation Operation 0x%x at %s():%d returning 0x%x\n",
static_cast<uint32_t>(mdEquationOperation),
__FUNCTION__, __LINE__, ZE_RESULT_ERROR_UNSUPPORTED_VERSION);
return ZE_RESULT_ERROR_UNSUPPORTED_VERSION;
}
assignUnaligned(&equationOperation, &equationOperationMap[mdEquationOperation]);
return ZE_RESULT_SUCCESS;
}
ze_result_t MetricOaExporter01::assignEquation(zet_intel_metric_df_gpu_equation_0_1_t &equation, MetricsDiscovery::IEquation_1_0 *mdEquation) {
if (mdEquation == nullptr) {
equation.elementCount = 0;
equation.elements = ZET_INTEL_GPU_METRIC_INVALID_OFFSET;
return ZE_RESULT_SUCCESS;
}
const auto elementCount = mdEquation->GetEquationElementsCount();
auto [elementBase, offset] = heapUsageTracker.allocate<zet_intel_metric_df_gpu_equation_element_0_1_t>(elementCount);
for (auto elemIdx = 0u; elemIdx < elementCount; elemIdx++) {
zet_intel_metric_df_gpu_equation_element_0_1_t currElement{};
auto mdElement = mdEquation->GetEquationElement(elemIdx);
auto status = ZE_RESULT_SUCCESS;
zet_intel_metric_df_gpu_equation_element_type_t type = ZET_INTEL_METRIC_DF_EQUATION_ELEM_FORCE_UINT32;
assignCstringOffset(&currElement.symbolName, mdElement->SymbolName);
switch (mdElement->Type) {
case MetricsDiscovery::EQUATION_ELEM_OPERATION:
status = getEquationOperation(currElement.operation, mdElement->Operation);
type = ZET_INTEL_METRIC_DF_EQUATION_ELEM_OPERATION;
break;
case MetricsDiscovery::EQUATION_ELEM_RD_BITFIELD:
type = ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_BITFIELD;
assignUnaligned(&currElement.readParams.byteOffset, &mdElement->ReadParams.ByteOffset);
assignUnaligned(&currElement.readParams.bitOffset, &mdElement->ReadParams.BitOffset);
assignUnaligned(&currElement.readParams.bitsCount, &mdElement->ReadParams.BitsCount);
break;
case MetricsDiscovery::EQUATION_ELEM_RD_UINT8:
type = ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_UINT8;
assignUnaligned(&currElement.readParams.byteOffset, &mdElement->ReadParams.ByteOffset);
break;
case MetricsDiscovery::EQUATION_ELEM_RD_UINT16:
type = ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_UINT16;
assignUnaligned(&currElement.readParams.byteOffset, &mdElement->ReadParams.ByteOffset);
break;
case MetricsDiscovery::EQUATION_ELEM_RD_UINT32:
type = ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_UINT32;
assignUnaligned(&currElement.readParams.byteOffset, &mdElement->ReadParams.ByteOffset);
break;
case MetricsDiscovery::EQUATION_ELEM_RD_UINT64:
type = ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_UINT64;
assignUnaligned(&currElement.readParams.byteOffset, &mdElement->ReadParams.ByteOffset);
break;
case MetricsDiscovery::EQUATION_ELEM_RD_FLOAT:
type = ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_FLOAT;
assignUnaligned(&currElement.readParams.byteOffset, &mdElement->ReadParams.ByteOffset);
break;
case MetricsDiscovery::EQUATION_ELEM_RD_40BIT_CNTR:
type = ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_40BIT_CNTR;
assignUnaligned(&currElement.readParams.byteOffset, &mdElement->ReadParams.ByteOffset);
assignUnaligned(&currElement.readParams.byteOffsetExt, &mdElement->ReadParams.ByteOffsetExt);
break;
case MetricsDiscovery::EQUATION_ELEM_IMM_UINT64:
type = ZET_INTEL_METRIC_DF_EQUATION_ELEM_IMM_UINT64;
assignUnaligned(&currElement.immediateUInt64, &mdElement->ImmediateUInt64);
break;
case MetricsDiscovery::EQUATION_ELEM_IMM_FLOAT:
type = ZET_INTEL_METRIC_DF_EQUATION_ELEM_IMM_FLOAT;
assignUnaligned(&currElement.immediateFloat, &mdElement->ImmediateFloat);
break;
case MetricsDiscovery::EQUATION_ELEM_SELF_COUNTER_VALUE:
type = ZET_INTEL_METRIC_DF_EQUATION_ELEM_SELF_COUNTER_VALUE;
break;
case MetricsDiscovery::EQUATION_ELEM_GLOBAL_SYMBOL:
type = ZET_INTEL_METRIC_DF_EQUATION_ELEM_GLOBAL_SYMBOL;
status = getEquationOperation(currElement.operation, mdElement->Operation);
break;
case MetricsDiscovery::EQUATION_ELEM_LOCAL_COUNTER_SYMBOL:
type = ZET_INTEL_METRIC_DF_EQUATION_ELEM_LOCAL_COUNTER_SYMBOL;
status = getEquationOperation(currElement.operation, mdElement->Operation);
break;
case MetricsDiscovery::EQUATION_ELEM_OTHER_SET_COUNTER_SYMBOL:
type = ZET_INTEL_METRIC_DF_EQUATION_ELEM_OTHER_SET_COUNTER_SYMBOL;
status = getEquationOperation(currElement.operation, mdElement->Operation);
break;
case MetricsDiscovery::EQUATION_ELEM_LOCAL_METRIC_SYMBOL:
type = ZET_INTEL_METRIC_DF_EQUATION_ELEM_LOCAL_METRIC_SYMBOL;
break;
case MetricsDiscovery::EQUATION_ELEM_OTHER_SET_METRIC_SYMBOL:
type = ZET_INTEL_METRIC_DF_EQUATION_ELEM_OTHER_SET_METRIC_SYMBOL;
break;
case MetricsDiscovery::EQUATION_ELEM_INFORMATION_SYMBOL:
type = ZET_INTEL_METRIC_DF_EQUATION_ELEM_INFORMATION_SYMBOL;
break;
case MetricsDiscovery::EQUATION_ELEM_STD_NORM_GPU_DURATION:
type = ZET_INTEL_METRIC_DF_EQUATION_ELEM_STD_NORM_GPU_DURATION;
break;
case MetricsDiscovery::EQUATION_ELEM_STD_NORM_EU_AGGR_DURATION:
type = ZET_INTEL_METRIC_DF_EQUATION_ELEM_STD_NORM_EU_AGGR_DURATION;
break;
case MetricsDiscovery::EQUATION_ELEM_MASK:
type = ZET_INTEL_METRIC_DF_EQUATION_ELEM_MASK;
assignByteArray(&currElement.mask, &mdElement->Mask);
break;
default:
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr,
"Error: Unknown Equation Element Type 0x%x at %s():%d returning 0x%x\n",
static_cast<uint32_t>(mdElement->Type),
__FUNCTION__, __LINE__, ZE_RESULT_ERROR_UNSUPPORTED_VERSION);
return ZE_RESULT_ERROR_UNSUPPORTED_VERSION;
}
if (status != ZE_RESULT_SUCCESS) {
return status;
}
assignUnaligned(&currElement.type, &type);
if (currOperationMode == OperationModeGetExportData) {
assignUnaligned(&elementBase[elemIdx], &currElement);
}
}
equation.elementCount = elementCount;
equation.elements = offset;
return ZE_RESULT_SUCCESS;
}
ze_result_t MetricOaExporter01::getDeltaFunction(zet_intel_metric_df_gpu_delta_function_0_1_t &deltaFunction, MetricsDiscovery::TDeltaFunction_1_0 &mdDeltaFunction) {
std::map<MetricsDiscovery::TDeltaFunctionType, zet_intel_metric_df_gpu_delta_function_type_t> deltaFunctionMap = {
{MetricsDiscovery::DELTA_FUNCTION_NULL, ZET_INTEL_METRIC_DF_DELTA_FUNCTION_NULL},
{MetricsDiscovery::DELTA_N_BITS, ZET_INTEL_METRIC_DF_DELTA_N_BITS},
{MetricsDiscovery::DELTA_BOOL_OR, ZET_INTEL_METRIC_DF_DELTA_BOOL_OR},
{MetricsDiscovery::DELTA_BOOL_XOR, ZET_INTEL_METRIC_DF_DELTA_BOOL_XOR},
{MetricsDiscovery::DELTA_GET_PREVIOUS, ZET_INTEL_METRIC_DF_DELTA_GET_PREVIOUS},
{MetricsDiscovery::DELTA_GET_LAST, ZET_INTEL_METRIC_DF_DELTA_GET_LAST},
{MetricsDiscovery::DELTA_NS_TIME, ZET_INTEL_METRIC_DF_DELTA_NS_TIME},
};
if (deltaFunctionMap.find(mdDeltaFunction.FunctionType) == deltaFunctionMap.end()) {
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr,
"Error: Unknown Delta Function Type 0x%x at %s():%d returning 0x%x\n",
static_cast<uint32_t>(mdDeltaFunction.FunctionType),
__FUNCTION__, __LINE__, ZE_RESULT_ERROR_UNSUPPORTED_VERSION);
return ZE_RESULT_ERROR_UNSUPPORTED_VERSION;
}
assignUnaligned(&deltaFunction.bitsCount, &mdDeltaFunction.BitsCount);
assignUnaligned(&deltaFunction.functionType, &deltaFunctionMap[mdDeltaFunction.FunctionType]);
return ZE_RESULT_SUCCESS;
}
ze_result_t MetricOaExporter01::getInformationType(zet_intel_metric_df_gpu_information_type_t &infoType, const MetricsDiscovery::TInformationType mdInfoType) {
std::map<MetricsDiscovery::TInformationType, zet_intel_metric_df_gpu_information_type_t> informationTypeMap = {
{MetricsDiscovery::INFORMATION_TYPE_REPORT_REASON, ZET_INTEL_METRIC_DF_INFORMATION_TYPE_REPORT_REASON},
{MetricsDiscovery::INFORMATION_TYPE_VALUE, ZET_INTEL_METRIC_DF_INFORMATION_TYPE_VALUE},
{MetricsDiscovery::INFORMATION_TYPE_FLAG, ZET_INTEL_METRIC_DF_INFORMATION_TYPE_FLAG},
{MetricsDiscovery::INFORMATION_TYPE_TIMESTAMP, ZET_INTEL_METRIC_DF_INFORMATION_TYPE_TIMESTAMP},
{MetricsDiscovery::INFORMATION_TYPE_CONTEXT_ID_TAG, ZET_INTEL_METRIC_DF_INFORMATION_TYPE_CONTEXT_ID_TAG},
{MetricsDiscovery::INFORMATION_TYPE_SAMPLE_PHASE, ZET_INTEL_METRIC_DF_INFORMATION_TYPE_SAMPLE_PHASE},
{MetricsDiscovery::INFORMATION_TYPE_GPU_NODE, ZET_INTEL_METRIC_DF_INFORMATION_TYPE_GPU_NODE}};
if (informationTypeMap.find(mdInfoType) == informationTypeMap.end()) {
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr,
"Error: Unknown Information Type 0x%x at %s():%d returning 0x%x\n",
static_cast<uint32_t>(mdInfoType),
__FUNCTION__, __LINE__, ZE_RESULT_ERROR_UNSUPPORTED_VERSION);
return ZE_RESULT_ERROR_UNSUPPORTED_VERSION;
}
assignUnaligned(&infoType, &informationTypeMap[mdInfoType]);
return ZE_RESULT_SUCCESS;
}
ze_result_t MetricOaExporter01::assignInformationParams(zet_intel_metric_df_gpu_information_params_0_1_t *infoParams, MetricsDiscovery::TInformationParams_1_0 *mdInfoParams) {
assignUnaligned(&infoParams->idInSet, &mdInfoParams->IdInSet);
assignCstringOffset(&infoParams->symbolName, mdInfoParams->SymbolName);
assignCstringOffset(&infoParams->shortName, mdInfoParams->ShortName);
assignCstringOffset(&infoParams->groupName, mdInfoParams->GroupName);
assignCstringOffset(&infoParams->longName, mdInfoParams->LongName);
assignUnaligned(&infoParams->apiMask, &mdInfoParams->ApiMask);
auto status = getInformationType(infoParams->infoType, mdInfoParams->InfoType);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
assignCstringOffset(&infoParams->infoUnits, mdInfoParams->InfoUnits);
status = assignEquation(infoParams->ioReadEquation, mdInfoParams->IoReadEquation);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
status = assignEquation(infoParams->queryReadEquation, mdInfoParams->QueryReadEquation);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
status = getDeltaFunction(infoParams->overflowFunction, mdInfoParams->OverflowFunction);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
return status;
}
ze_result_t MetricOaExporter01::assignIoMeaurementInformationOffset(zet_intel_metric_df_gpu_information_params_0_1_offset_t *ioMeasurementInformationOffset) {
MetricsDiscovery::TConcurrentGroupParams_1_0 *mdConcGroupParams = concurrentGroup.GetParams();
DEBUG_BREAK_IF(mdConcGroupParams == nullptr);
const auto count = mdConcGroupParams->IoMeasurementInformationCount;
auto [informationParamsBase, offset] = heapUsageTracker.allocate<zet_intel_metric_df_gpu_information_params_0_1_t>(count);
zet_intel_metric_df_gpu_information_params_0_1_t paramsForSizeCalculation{};
for (auto index = 0u; index < count; index++) {
MetricsDiscovery::IInformation_1_0 *info = concurrentGroup.GetIoMeasurementInformation(index);
DEBUG_BREAK_IF(info == nullptr);
MetricsDiscovery::TInformationParams_1_0 *infoParams = info->GetParams();
DEBUG_BREAK_IF(infoParams == nullptr);
auto status = assignInformationParams(&paramsForSizeCalculation, infoParams);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
if (currOperationMode == OperationModeGetExportData) {
assignUnaligned(&informationParamsBase[index], &paramsForSizeCalculation);
}
}
assignUnaligned(ioMeasurementInformationOffset, &offset);
return ZE_RESULT_SUCCESS;
}
ze_result_t MetricOaExporter01::assignIoGpuContextInformationOffset(zet_intel_metric_df_gpu_information_params_0_1_offset_t *ioGpuContextInformationOffset) {
MetricsDiscovery::TConcurrentGroupParams_1_0 *mdConcGroupParams = concurrentGroup.GetParams();
const auto count = mdConcGroupParams->IoGpuContextInformationCount;
auto [informationParamsBase, offset] = heapUsageTracker.allocate<zet_intel_metric_df_gpu_information_params_0_1_t>(count);
zet_intel_metric_df_gpu_information_params_0_1_t paramsForSizeCalculation{};
for (auto index = 0u; index < count; index++) {
MetricsDiscovery::IInformation_1_0 *info = concurrentGroup.GetIoGpuContextInformation(index);
DEBUG_BREAK_IF(info == nullptr);
MetricsDiscovery::TInformationParams_1_0 *infoParams = info->GetParams();
DEBUG_BREAK_IF(infoParams == nullptr);
auto status = assignInformationParams(&paramsForSizeCalculation, infoParams);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
if (currOperationMode == OperationModeGetExportData) {
assignUnaligned(&informationParamsBase[index], &paramsForSizeCalculation);
}
}
assignUnaligned(ioGpuContextInformationOffset, &offset);
return ZE_RESULT_SUCCESS;
}
ze_result_t MetricOaExporter01::assignMetricSetInformationOffset(zet_intel_metric_df_gpu_information_params_0_1_offset_t *metricSetInfoParamsOffset) {
auto count = mdMetricSet.GetParams()->InformationCount;
auto [informationParamsBase, offset] = heapUsageTracker.allocate<zet_intel_metric_df_gpu_information_params_0_1_t>(count);
zet_intel_metric_df_gpu_information_params_0_1_t paramsForSizeCalculation{};
for (auto index = 0u; index < count; index++) {
MetricsDiscovery::IInformation_1_0 *info = mdMetricSet.GetInformation(index);
DEBUG_BREAK_IF(info == nullptr);
MetricsDiscovery::TInformationParams_1_0 *infoParams = info->GetParams();
DEBUG_BREAK_IF(infoParams == nullptr);
auto status = assignInformationParams(&paramsForSizeCalculation, infoParams);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
if (currOperationMode == OperationModeGetExportData) {
assignUnaligned<zet_intel_metric_df_gpu_information_params_0_1_t>(&informationParamsBase[index], &paramsForSizeCalculation);
}
}
assignUnaligned<zet_intel_metric_df_gpu_information_params_0_1_offset_t>(metricSetInfoParamsOffset, &offset);
return ZE_RESULT_SUCCESS;
}
ze_result_t MetricOaExporter01::getMetricType(zet_intel_metric_df_gpu_metric_type_t &metricType, const MetricsDiscovery::TMetricType mdMetricType) {
std::map<MetricsDiscovery::TMetricType, zet_intel_metric_df_gpu_metric_type_t> metricTypeMap = {
{MetricsDiscovery::METRIC_TYPE_DURATION, ZET_INTEL_METRIC_DF_METRIC_TYPE_DURATION},
{MetricsDiscovery::METRIC_TYPE_EVENT, ZET_INTEL_METRIC_DF_METRIC_TYPE_EVENT},
{MetricsDiscovery::METRIC_TYPE_EVENT_WITH_RANGE, ZET_INTEL_METRIC_DF_METRIC_TYPE_EVENT_WITH_RANGE},
{MetricsDiscovery::METRIC_TYPE_THROUGHPUT, ZET_INTEL_METRIC_DF_METRIC_TYPE_THROUGHPUT},
{MetricsDiscovery::METRIC_TYPE_TIMESTAMP, ZET_INTEL_METRIC_DF_METRIC_TYPE_TIMESTAMP},
{MetricsDiscovery::METRIC_TYPE_FLAG, ZET_INTEL_METRIC_DF_METRIC_TYPE_FLAG},
{MetricsDiscovery::METRIC_TYPE_RATIO, ZET_INTEL_METRIC_DF_METRIC_TYPE_RATIO},
{MetricsDiscovery::METRIC_TYPE_RAW, ZET_INTEL_METRIC_DF_METRIC_TYPE_RAW},
};
if (metricTypeMap.find(mdMetricType) == metricTypeMap.end()) {
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr,
"Error: Unknown Metric Type 0x%x at %s():%d returning 0x%x\n",
static_cast<uint32_t>(mdMetricType),
__FUNCTION__, __LINE__, ZE_RESULT_ERROR_UNSUPPORTED_VERSION);
return ZE_RESULT_ERROR_UNSUPPORTED_VERSION;
}
assignUnaligned(&metricType, &metricTypeMap[mdMetricType]);
return ZE_RESULT_SUCCESS;
}
ze_result_t MetricOaExporter01::getMetricResultType(zet_intel_metric_df_gpu_metric_result_type_t &resltType, const MetricsDiscovery::TMetricResultType mdResultType) {
std::map<MetricsDiscovery::TMetricResultType, zet_intel_metric_df_gpu_metric_result_type_t> resultTypeMap = {
{MetricsDiscovery::RESULT_UINT32, ZET_INTEL_METRIC_DF_RESULT_UINT32},
{MetricsDiscovery::RESULT_UINT64, ZET_INTEL_METRIC_DF_RESULT_UINT64},
{MetricsDiscovery::RESULT_BOOL, ZET_INTEL_METRIC_DF_RESULT_BOOL},
{MetricsDiscovery::RESULT_FLOAT, ZET_INTEL_METRIC_DF_RESULT_FLOAT},
};
if (resultTypeMap.find(mdResultType) == resultTypeMap.end()) {
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr,
"Error: Unknown Metric Result Type 0x%x at %s():%d returning 0x%x\n",
static_cast<uint32_t>(mdResultType),
__FUNCTION__, __LINE__, ZE_RESULT_ERROR_UNSUPPORTED_VERSION);
return ZE_RESULT_ERROR_UNSUPPORTED_VERSION;
}
assignUnaligned(&resltType, &resultTypeMap[mdResultType]);
return ZE_RESULT_SUCCESS;
}
ze_result_t MetricOaExporter01::assignMetricParamsOffset(zet_intel_metric_df_gpu_metric_params_0_1_offset_t *metricParamsOffset) {
auto count = mdMetricSet.GetParams()->MetricsCount;
auto [metricParamsBase, offset] = heapUsageTracker.allocate<zet_intel_metric_df_gpu_metric_params_0_1_t>(count);
for (auto index = 0u; index < count; index++) {
zet_intel_metric_df_gpu_metric_params_0_1_t paramsForSizeCalculation{};
MetricsDiscovery::IMetric_1_0 *metric = mdMetricSet.GetMetric(index);
DEBUG_BREAK_IF(metric == nullptr);
MetricsDiscovery::TMetricParams_1_0 *mdMetricParams = metric->GetParams();
DEBUG_BREAK_IF(mdMetricParams == nullptr);
assignUnaligned(&paramsForSizeCalculation.idInSet, &mdMetricParams->IdInSet);
assignCstringOffset(&paramsForSizeCalculation.symbolName, mdMetricParams->SymbolName);
assignCstringOffset(&paramsForSizeCalculation.shortName, mdMetricParams->ShortName);
assignCstringOffset(&paramsForSizeCalculation.groupName, mdMetricParams->GroupName);
assignCstringOffset(&paramsForSizeCalculation.longName, mdMetricParams->LongName);
assignUnaligned(&paramsForSizeCalculation.apiMask, &mdMetricParams->ApiMask);
assignCstringOffset(&paramsForSizeCalculation.metricResultUnits, mdMetricParams->MetricResultUnits);
assignUnaligned(&paramsForSizeCalculation.usageFlagsMask, &mdMetricParams->UsageFlagsMask);
auto status = getMetricResultType(paramsForSizeCalculation.resultType, mdMetricParams->ResultType);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
status = getMetricType(paramsForSizeCalculation.metricType, mdMetricParams->MetricType);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
status = assignEquation(paramsForSizeCalculation.ioReadEquation, mdMetricParams->IoReadEquation);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
status = assignEquation(paramsForSizeCalculation.queryReadEquation, mdMetricParams->QueryReadEquation);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
status = getDeltaFunction(paramsForSizeCalculation.deltaFunction, mdMetricParams->DeltaFunction);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
status = assignEquation(paramsForSizeCalculation.normEquation, mdMetricParams->NormEquation);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
status = assignEquation(paramsForSizeCalculation.maxValueEquation, mdMetricParams->MaxValueEquation);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
if (currOperationMode == OperationModeGetExportData) {
assignUnaligned<zet_intel_metric_df_gpu_metric_params_0_1_t>(&metricParamsBase[index], &paramsForSizeCalculation);
}
}
assignUnaligned(metricParamsOffset, &offset);
return ZE_RESULT_SUCCESS;
}
void MetricOaExporter01::updateConcurrentGroupParams(zet_intel_metric_df_gpu_concurrent_group_params_0_1_t *concGroupParams) {
MetricsDiscovery::TConcurrentGroupParams_1_0 *mdConcGroupParams = concurrentGroup.GetParams();
DEBUG_BREAK_IF(mdConcGroupParams == nullptr);
assignCstringOffset(&concGroupParams->symbolName, mdConcGroupParams->SymbolName);
assignCstringOffset(&concGroupParams->description, mdConcGroupParams->Description);
assignUnaligned(&concGroupParams->ioMeasurementInformationCount, &mdConcGroupParams->IoMeasurementInformationCount);
assignUnaligned(&concGroupParams->ioGpuContextInformationCount, &mdConcGroupParams->IoGpuContextInformationCount);
}
ze_result_t MetricOaExporter01::updateConcurrentGroup(zet_intel_metric_df_gpu_concurrent_group_0_1_t *concGroup) {
updateConcurrentGroupParams(&concGroup->params);
zet_intel_metric_df_gpu_information_params_0_1_offset_t offset;
auto status = assignIoMeaurementInformationOffset(&offset);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
assignUnaligned(&concGroup->ioMeasurementInformation, &offset);
status = assignIoGpuContextInformationOffset(&offset);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
assignUnaligned(&concGroup->ioGpuContextInformation, &offset);
return status;
}
void MetricOaExporter01::updateMetricSetParams(zet_intel_metric_df_gpu_metric_set_params_0_1_t *params) {
MetricsDiscovery::TMetricSetParams_1_0 *mdMetricParams = mdMetricSet.GetParams();
DEBUG_BREAK_IF(mdMetricParams == nullptr);
assignCstringOffset(&params->symbolName, mdMetricParams->SymbolName);
assignCstringOffset(&params->shortName, mdMetricParams->ShortName);
assignUnaligned(&params->apiMask, &mdMetricParams->ApiMask);
assignUnaligned(&params->metricsCount, &mdMetricParams->MetricsCount);
assignUnaligned(&params->informationCount, &mdMetricParams->InformationCount);
MetricsDiscovery::TApiVersion_1_0 *apiVersion = &mdDevice.GetParams()->Version;
DEBUG_BREAK_IF(apiVersion == nullptr);
if (apiVersion->MajorNumber > 1 || (apiVersion->MajorNumber == 1 && apiVersion->MinorNumber >= 11)) {
MetricsDiscovery::TMetricSetParams_1_11 *mdMetricSetParamsLatest = static_cast<MetricsDiscovery::TMetricSetParams_1_11 *>(mdMetricParams);
assignCstringOffset(&params->availabilityEquation, mdMetricSetParamsLatest->AvailabilityEquation);
} else {
auto equation = ZET_INTEL_GPU_METRIC_INVALID_OFFSET;
assignUnaligned(&params->availabilityEquation, &equation);
}
}
ze_result_t MetricOaExporter01::updateMetricSet(zet_intel_metric_df_gpu_metric_set_0_1_t *metricSet) {
updateMetricSetParams(&metricSet->params);
auto status = assignMetricSetInformationOffset(&metricSet->informationParams);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
return assignMetricParamsOffset(&metricSet->metricParams);
}
ze_result_t MetricOaExporter01::updateAdapterParams(zet_intel_metric_df_gpu_adapter_params_0_1_t *adapterParams) {
auto mdAdapterParams = const_cast<MetricsDiscovery::TAdapterParams_1_9 *>(adapter.GetParams());
DEBUG_BREAK_IF(mdAdapterParams == nullptr);
assignUnaligned(&adapterParams->busNumber, &mdAdapterParams->BusNumber);
assignUnaligned(&adapterParams->deviceNumber, &mdAdapterParams->DeviceNumber);
assignUnaligned(&adapterParams->functionNumber, &mdAdapterParams->FunctionNumber);
assignUnaligned(&adapterParams->domainNumber, &mdAdapterParams->DomainNumber);
return assignAdapterId(&adapterParams->systemId, &mdAdapterParams->SystemId);
}
ze_result_t MetricOaExporter01::updateGlobalSymbolOffsetAndValues(zet_intel_metric_df_gpu_global_symbol_0_1_offset_t *globalSymbolsOffset) {
MetricsDiscovery::TMetricsDeviceParams_1_2 *pMetricsDeviceParams = mdDevice.GetParams();
DEBUG_BREAK_IF(pMetricsDeviceParams == nullptr);
const auto globalSymbolsCount = pMetricsDeviceParams->GlobalSymbolsCount;
auto [globalSymbolsBase, offset] = heapUsageTracker.allocate<zet_intel_metric_df_gpu_global_symbol_0_1_t>(globalSymbolsCount);
zet_intel_metric_df_gpu_global_symbol_0_1_t symbolForSizeCalculation;
zet_intel_metric_df_gpu_global_symbol_0_1_t *currSymbol = &symbolForSizeCalculation;
for (uint32_t index = 0; index < globalSymbolsCount; index++) {
if (currOperationMode != OperationModeGetHeapSize) {
currSymbol = &globalSymbolsBase[index];
}
MetricsDiscovery::TGlobalSymbol_1_0 *symbol = mdDevice.GetGlobalSymbol(index);
DEBUG_BREAK_IF(symbol == nullptr);
assignCstringOffset(&currSymbol->symbolName, symbol->SymbolName);
const auto status = assignTypedValue(&currSymbol->symbolTypedValue, symbol->SymbolTypedValue);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
}
assignUnaligned(globalSymbolsOffset, &offset);
return ZE_RESULT_SUCCESS;
}
void MetricOaExporter01::updateMetricsDeviceParams(zet_intel_metric_df_gpu_metrics_device_params_0_1_t *deviceParams) {
updateMetricApiVersion(&deviceParams->version);
MetricsDiscovery::TMetricsDeviceParams_1_2 *pMetricsDeviceParams = mdDevice.GetParams();
DEBUG_BREAK_IF(pMetricsDeviceParams == nullptr);
assignUnaligned(&deviceParams->globalSymbolsCount, &pMetricsDeviceParams->GlobalSymbolsCount);
}
ze_result_t MetricOaExporter01::getExportData(zet_intel_metric_df_gpu_metric_oa_calc_0_1_t *oaCalcData) {
updateMetricsDeviceParams(&oaCalcData->deviceParams);
ze_result_t status = updateGlobalSymbolOffsetAndValues(&oaCalcData->globalSymbols);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
status = updateAdapterParams(&oaCalcData->adapterParams);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
status = updateConcurrentGroup(&oaCalcData->concurrentGroup);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
return updateMetricSet(&oaCalcData->metricSet);
}
ze_result_t OaMetricGroupImp::getExportDataHeapSize(size_t &exportDataHeapSize) {
if (cachedExportDataHeapSize != 0) {
exportDataHeapSize = cachedExportDataHeapSize;
return ZE_RESULT_SUCCESS;
}
HeapUsageTracker memoryTracker(0, 0, HeapUsageTracker::OperationModeTrackOnly);
MetricsDiscovery::IMetricsDevice_1_5 *mdDevice = metricSource->getMetricEnumeration().getMdapiDevice();
MetricsDiscovery::IAdapter_1_9 *mdAdapter = metricSource->getMetricEnumeration().getMdapiAdapter();
MetricOaExporter01 exporter01(*mdDevice, *mdAdapter, *pReferenceMetricSet, *pReferenceConcurrentGroup, memoryTracker);
zet_intel_metric_df_gpu_export_data_format_t exportData{};
const auto status = exporter01.getExportData(&exportData.format01.oaData);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
cachedExportDataHeapSize = exportDataHeapSize = memoryTracker.getUsedBytes();
return ZE_RESULT_SUCCESS;
}
ze_result_t OaMetricGroupImp::getExportData(const uint8_t *pRawData,
size_t rawDataSize,
size_t *pExportDataSize,
uint8_t *pExportData) {
if (metricGroups.size() != 0) {
auto metricGroupSubDevice = MetricGroup::fromHandle(metricGroups[0]);
return metricGroupSubDevice->getExportData(pRawData, rawDataSize, pExportDataSize, pExportData);
}
size_t requiredHeapSize = 0;
ze_result_t status = getExportDataHeapSize(requiredHeapSize);
if (status != ZE_RESULT_SUCCESS) {
return status;
}
const size_t expectedExportDataSize = sizeof(zet_intel_metric_df_gpu_export_data_format_t) + requiredHeapSize + rawDataSize;
if (*pExportDataSize == 0u) {
*pExportDataSize = expectedExportDataSize;
return ZE_RESULT_SUCCESS;
}
if (*pExportDataSize < expectedExportDataSize) {
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr,
"Error:Incorrect Size Passed at %s():%d returning 0x%x\n",
__FUNCTION__, __LINE__, ZE_RESULT_ERROR_INVALID_SIZE);
return ZE_RESULT_ERROR_INVALID_SIZE;
}
uintptr_t startHeapAddress = reinterpret_cast<uintptr_t>(pExportData + sizeof(zet_intel_metric_df_gpu_export_data_format_t));
uintptr_t endHeapAddress = startHeapAddress + requiredHeapSize;
HeapUsageTracker memoryTracker(startHeapAddress, endHeapAddress);
MetricsDiscovery::IMetricsDevice_1_5 *mdDevice = metricSource->getMetricEnumeration().getMdapiDevice();
MetricsDiscovery::IAdapter_1_9 *mdAdapter = metricSource->getMetricEnumeration().getMdapiAdapter();
MetricOaExporter01 exporter01(*mdDevice, *mdAdapter, *pReferenceMetricSet, *pReferenceConcurrentGroup, memoryTracker);
zet_intel_metric_df_gpu_export_data_format_t *exportData = reinterpret_cast<zet_intel_metric_df_gpu_export_data_format_t *>(pExportData);
// read and update the export data
status = exporter01.getExportData(&exportData->format01.oaData);
if (status != ZE_RESULT_SUCCESS) {
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr,
"Error: ExportData_0_1 Failed at %s():%d returning 0x%x\n",
__FUNCTION__, __LINE__, status);
return status;
}
DEBUG_BREAK_IF(memoryTracker.getUsedBytes() != requiredHeapSize);
// Update header after updating the export data
exportData->header.type = ZET_INTEL_METRIC_DF_SOURCE_TYPE_OA;
exportData->header.version.major = ZET_INTEL_GPU_METRIC_VERSION_MAJOR;
exportData->header.version.minor = ZET_INTEL_GPU_METRIC_VERSION_MINOR;
exportData->header.rawDataOffset = sizeof(zet_intel_metric_df_gpu_export_data_format_t) + memoryTracker.getUsedBytes();
exportData->header.rawDataSize = rawDataSize;
// Append the rawData
memcpy_s(reinterpret_cast<void *>(endHeapAddress), expectedExportDataSize - exportData->header.rawDataOffset, pRawData, rawDataSize);
return ZE_RESULT_SUCCESS;
}
} // namespace L0

View File

@ -0,0 +1,94 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "level_zero/include/zet_intel_gpu_metric.h"
#include <level_zero/zet_api.h>
#include "metrics_discovery_api.h"
#include <utility>
namespace L0 {
class HeapUsageTracker {
public:
enum OperationMode {
OperationModeTrackOnly = 0u,
OperationModeTrackAndAllocate
};
HeapUsageTracker() = delete;
HeapUsageTracker(uintptr_t startAddress,
uintptr_t endAddress,
OperationMode mode = OperationModeTrackAndAllocate);
template <typename T>
std::pair<T *, ptrdiff_t> allocate(uint64_t count);
size_t getUsedBytes();
OperationMode getOperationMode() const { return operationMode; }
protected:
uintptr_t currentAddress = reinterpret_cast<uintptr_t>(nullptr);
const uintptr_t endAddress;
ptrdiff_t currentOffset = 0;
const OperationMode operationMode;
};
class MetricOaExporter01 {
public:
MetricOaExporter01() = delete;
MetricOaExporter01(MetricsDiscovery::IMetricsDevice_1_5 &mdDevice,
MetricsDiscovery::IAdapter_1_9 &mdAdapter,
MetricsDiscovery::IMetricSet_1_5 &mdMetricSet,
MetricsDiscovery::IConcurrentGroup_1_5 &mdConcurrentGroup,
HeapUsageTracker &heapUsageTracker);
ze_result_t getExportData(zet_intel_metric_df_gpu_metric_oa_calc_0_1_t *oaCalcData);
protected:
enum OperationMode : uint32_t {
OperationModeGetHeapSize = 0u,
OperationModeGetExportData
};
void updateMetricApiVersion(zet_intel_metric_df_gpu_apiversion_0_1_t *apiVersion);
void assignCstringOffset(cstring_offset_t *cStringOffset, const char *stringValue);
void assignByteArray(zet_intel_metric_df_gpu_byte_array_0_1_t *byteArray, MetricsDiscovery::TByteArray_1_0 *mdByteArray);
ze_result_t assignTypedValue(zet_intel_metric_df_gpu_typed_value_0_1_t *typedValue, MetricsDiscovery::TTypedValue_1_0 &mdTypedValue);
ze_result_t assignAdapterId(zet_intel_metric_df_gpu_adapter_id_0_1_t *adapterId, MetricsDiscovery::TAdapterId_1_6 *mAdapterId);
ze_result_t getEquationOperation(zet_intel_metric_df_gpu_equation_operation_t &equationOperation,
const MetricsDiscovery::TEquationOperation mdEquationOperation);
ze_result_t assignEquation(zet_intel_metric_df_gpu_equation_0_1_t &equation, MetricsDiscovery::IEquation_1_0 *mdEquation);
ze_result_t getDeltaFunction(zet_intel_metric_df_gpu_delta_function_0_1_t &deltaFunction, MetricsDiscovery::TDeltaFunction_1_0 &mdDeltaFunction);
ze_result_t getInformationType(zet_intel_metric_df_gpu_information_type_t &infoType, const MetricsDiscovery::TInformationType mdInfoType);
ze_result_t assignInformationParams(zet_intel_metric_df_gpu_information_params_0_1_t *infoParams, MetricsDiscovery::TInformationParams_1_0 *mdInfoParams);
ze_result_t assignIoMeaurementInformationOffset(zet_intel_metric_df_gpu_information_params_0_1_offset_t *ioMeasurementInformationOffset);
ze_result_t assignIoGpuContextInformationOffset(zet_intel_metric_df_gpu_information_params_0_1_offset_t *ioGpuContextInformationOffset);
ze_result_t assignMetricSetInformationOffset(zet_intel_metric_df_gpu_information_params_0_1_offset_t *metricSetInfoParamsOffset);
ze_result_t getMetricType(zet_intel_metric_df_gpu_metric_type_t &metricType, const MetricsDiscovery::TMetricType mdMetricType);
ze_result_t assignMetricParamsOffset(zet_intel_metric_df_gpu_metric_params_0_1_offset_t *metricParamsOffset);
void updateConcurrentGroupParams(zet_intel_metric_df_gpu_concurrent_group_params_0_1_t *concGroupParams);
ze_result_t updateConcurrentGroup(zet_intel_metric_df_gpu_concurrent_group_0_1_t *concGroup);
void updateMetricSetParams(zet_intel_metric_df_gpu_metric_set_params_0_1_t *params);
ze_result_t updateMetricSet(zet_intel_metric_df_gpu_metric_set_0_1_t *metricSet);
ze_result_t updateAdapterParams(zet_intel_metric_df_gpu_adapter_params_0_1_t *adapterParams);
ze_result_t updateGlobalSymbolOffsetAndValues(zet_intel_metric_df_gpu_global_symbol_0_1_offset_t *globalSymbolsOffset);
ze_result_t getMetricResultType(zet_intel_metric_df_gpu_metric_result_type_t &resltType, const MetricsDiscovery::TMetricResultType mdResultType);
void updateMetricsDeviceParams(zet_intel_metric_df_gpu_metrics_device_params_0_1_t *deviceParams);
template <typename T>
void assignUnaligned(T *unAlignedData, T *alignedData);
MetricsDiscovery::IMetricsDevice_1_5 &mdDevice;
MetricsDiscovery::IAdapter_1_9 &adapter;
MetricsDiscovery::IMetricSet_1_5 &mdMetricSet;
MetricsDiscovery::IConcurrentGroup_1_5 &concurrentGroup;
HeapUsageTracker &heapUsageTracker;
OperationMode currOperationMode = OperationModeGetExportData;
};
} // namespace L0

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2022 Intel Corporation
# Copyright (C) 2022-2023 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
@ -13,6 +13,7 @@ if(UNIX)
zello_metrics_workload.cpp
zello_metrics.cpp
zello_metrics_util.cpp
zello_metrics_export.cpp
zello_metrics_util.h
zello_metrics.h
)

View File

@ -888,6 +888,43 @@ bool collectIndefinitely() {
return status;
}
bool testExportData() {
auto deviceId = 0;
auto subDeviceId = -1;
if (!zmu::isDeviceAvailable(deviceId, subDeviceId)) {
return false;
}
auto testSettings = zmu::TestSettings::get();
std::unique_ptr<SingleDeviceSingleQueueExecutionCtxt> executionCtxt;
executionCtxt = std::make_unique<SingleDeviceSingleQueueExecutionCtxt>(deviceId, subDeviceId);
std::unique_ptr<SingleMetricStreamerCollector> collector =
std::make_unique<SingleMetricStreamerCollector>(executionCtxt.get(), testSettings->metricGroupName.get().c_str());
uint8_t rawData[256];
size_t exportDataSize = 0;
auto res = zetMetricGroupGetExportDataExp(collector->getMetricGroup(), rawData, 256, &exportDataSize, nullptr);
if (res != ZE_RESULT_SUCCESS) {
LOG(zmu::LogLevel::DEBUG) << "export data size query status: " << res << std::endl;
return false;
}
LOG(zmu::LogLevel::INFO) << "ExportData Size: " << exportDataSize << std::endl;
std::vector<uint8_t> exportData(exportDataSize);
res = zetMetricGroupGetExportDataExp(collector->getMetricGroup(), rawData, 256, &exportDataSize, exportData.data());
if (res != ZE_RESULT_SUCCESS) {
LOG(zmu::LogLevel::DEBUG) << "export data status: " << res << std::endl;
return false;
}
zmu::showMetricsExportData(exportData.data(), exportDataSize);
return true;
}
int main(int argc, char *argv[]) {
std::map<std::string, std::function<bool()>> tests;
@ -903,6 +940,7 @@ int main(int argc, char *argv[]) {
tests["displayAllMetricGroups"] = displayAllMetricGroups;
tests["queryImmediateCommandListTest"] = queryImmediateCommandListTest;
tests["collectIndefinitely"] = collectIndefinitely;
tests["testExportData"] = testExportData;
auto testSettings = zmu::TestSettings::get();
testSettings->parseArguments(argc, argv);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2022 Intel Corporation
* Copyright (C) 2022-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -184,6 +184,9 @@ class CopyBufferToBuffer : public Workload {
class SingleMetricCollector : public Collector {
public:
zet_metric_group_handle_t getMetricGroup() { return metricGroup; }
protected:
SingleMetricCollector(ExecutionContext *executionCtxt,
const char *metricGroupName,

View File

@ -0,0 +1,545 @@
/*
* Copyright (C) 2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "level_zero/include/zet_intel_gpu_metric.h"
#include "level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics.h"
#include "level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics_util.h"
#include <map>
constexpr uint32_t indentLevelIncrement = 5;
#define SHOW(indent) LOG(LogLevel::INFO) << std::string(indent, ' ')
#define SHOW_CSTRING_OFFSET(parameter, indent) \
{ \
SHOW(indent) << #parameter << " : "; \
showCstringOffset(parameter, 1); \
SHOW(indent) << "\n"; \
}
#define SHOW_EQUATION(parameter, indent) \
{ \
SHOW(indent) << #parameter << " : \n"; \
showEquation(parameter, indent); \
SHOW(indent) << "\n"; \
}
#define SHOW_UINT32_T(parameter, indent) \
{ \
SHOW(indent) << #parameter << " : " << parameter << std::endl; \
}
namespace ZelloMetricsUtility {
class MetricOaExporter01Logger {
uintptr_t startAddress;
MetricOaExporter01Logger(){};
void showMetricApiVersion(zet_intel_metric_df_gpu_apiversion_0_1_t *apiVersion, uint32_t indent = 1) {
LOG(LogLevel::DEBUG) << "@line: " << __LINE__ << " of function " << __FUNCTION__ << std::endl;
indent += indentLevelIncrement;
SHOW_UINT32_T(apiVersion->majorNumber, indent);
SHOW_UINT32_T(apiVersion->minorNumber, indent);
SHOW_UINT32_T(apiVersion->buildNumber, indent);
}
void showCstringOffset(cstring_offset_t *cStringOffset, uint32_t indent = 1) {
LOG(LogLevel::DEBUG) << "@line: " << __LINE__ << " of function " << __FUNCTION__ << std::endl;
auto cString = zet_intel_metric_df_gpu_offset_to_ptr(cstring_offset_t, *cStringOffset, startAddress);
if (cString != nullptr) {
SHOW(indent) << std::string(cString);
}
}
void showByteArray(zet_intel_metric_df_gpu_byte_array_0_1_t *byteArray, uint32_t indent = 1) {
LOG(LogLevel::DEBUG) << "@line: " << __LINE__ << " of function " << __FUNCTION__ << std::endl;
uint8_t *baseAddr = zet_intel_metric_df_gpu_offset_to_ptr(uint8_offset_t, byteArray->data, startAddress);
for (auto index = 0u; index < byteArray->size; index++) {
SHOW(indent) << "[" << index << "]:" << static_cast<uint32_t>(baseAddr[index]) << std::endl;
}
}
void showTypedValue(zet_intel_metric_df_gpu_typed_value_0_1_t *typedValue, uint32_t indent = 1) {
LOG(LogLevel::DEBUG) << "@line: " << __LINE__ << " of function " << __FUNCTION__ << std::endl;
SHOW(indent) << "typedValue->valueType: ";
switch (typedValue->valueType) {
case ZET_INTEL_METRIC_DF_VALUE_TYPE_UINT32:
SHOW(indent) << "ZET_INTEL_METRIC_DF_VALUE_TYPE_UINT32 | " << typedValue->valueUInt32 << std::endl;
break;
case ZET_INTEL_METRIC_DF_VALUE_TYPE_UINT64:
SHOW(indent) << "ZET_INTEL_METRIC_DF_VALUE_TYPE_UINT64 | " << typedValue->valueUInt64 << std::endl;
break;
case ZET_INTEL_METRIC_DF_VALUE_TYPE_FLOAT:
SHOW(indent) << "ZET_INTEL_METRIC_DF_VALUE_TYPE_FLOAT | " << typedValue->valueFloat << std::endl;
break;
case ZET_INTEL_METRIC_DF_VALUE_TYPE_BOOL:
SHOW(indent) << "ZET_INTEL_METRIC_DF_VALUE_TYPE_BOOL | " << typedValue->valueBool << std::endl;
break;
case ZET_INTEL_METRIC_DF_VALUE_TYPE_CSTRING:
SHOW(indent) << "ZET_INTEL_METRIC_DF_VALUE_TYPE_CSTRING | ";
SHOW_CSTRING_OFFSET(&typedValue->valueCString, indent);
break;
case ZET_INTEL_METRIC_DF_VALUE_TYPE_BYTEARRAY:
SHOW(indent) << "ZET_INTEL_METRIC_DF_VALUE_TYPE_BYTEARRAY | "
<< "\n";
showByteArray(&typedValue->valueByteArray, indent);
SHOW(indent) << std::endl;
break;
default:
EXPECT(0);
break;
}
}
void showAdapterId(zet_intel_metric_df_gpu_adapter_id_0_1_t *adapterId, uint32_t indent = 1) {
LOG(LogLevel::DEBUG) << "@line: " << __LINE__ << " of function " << __FUNCTION__ << std::endl;
indent += indentLevelIncrement;
switch (adapterId->type) {
case ZET_INTEL_METRIC_DF_ADAPTER_ID_TYPE_LUID:
SHOW(indent) << "ZET_INTEL_METRIC_DF_ADAPTER_ID_TYPE_LUID | ";
SHOW(indent) << "adapterId->luid.lowPart : " << adapterId->luid.lowPart << " | ";
SHOW(indent) << "adapterId->luid.highPart : " << adapterId->luid.highPart << std::endl;
break;
case ZET_INTEL_METRIC_DF_ADAPTER_ID_TYPE_MAJOR_MINOR:
SHOW(indent) << "ZET_INTEL_METRIC_DF_ADAPTER_ID_TYPE_MAJOR_MINOR | ";
SHOW(indent) << "adapterId->majorMinor.major : " << adapterId->majorMinor.major << " | ";
SHOW(indent) << "adapterId->majorMinor.minor : " << adapterId->majorMinor.minor << std::endl;
break;
default:
EXPECT(0);
break;
}
}
void showEquationOperation(zet_intel_metric_df_gpu_equation_operation_t &equationOperation, uint32_t indent = 1) {
LOG(LogLevel::DEBUG) << "@line: " << __LINE__ << " of function " << __FUNCTION__ << std::endl;
std::map<zet_intel_metric_df_gpu_equation_operation_t, std::string> equationOperationMap = {
{ZET_INTEL_METRIC_DF_EQUATION_OPER_RSHIFT, "ZET_INTEL_METRIC_DF_EQUATION_OPER_RSHIFT"},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_LSHIFT, "ZET_INTEL_METRIC_DF_EQUATION_OPER_LSHIFT"},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_AND, "ZET_INTEL_METRIC_DF_EQUATION_OPER_AND "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_OR, "ZET_INTEL_METRIC_DF_EQUATION_OPER_OR "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_XOR, "ZET_INTEL_METRIC_DF_EQUATION_OPER_XOR "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_XNOR, "ZET_INTEL_METRIC_DF_EQUATION_OPER_XNOR "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_AND_L, "ZET_INTEL_METRIC_DF_EQUATION_OPER_AND_L "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_EQUALS, "ZET_INTEL_METRIC_DF_EQUATION_OPER_EQUALS"},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_UADD, "ZET_INTEL_METRIC_DF_EQUATION_OPER_UADD "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_USUB, "ZET_INTEL_METRIC_DF_EQUATION_OPER_USUB "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_UMUL, "ZET_INTEL_METRIC_DF_EQUATION_OPER_UMUL "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_UDIV, "ZET_INTEL_METRIC_DF_EQUATION_OPER_UDIV "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_FADD, "ZET_INTEL_METRIC_DF_EQUATION_OPER_FADD "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_FSUB, "ZET_INTEL_METRIC_DF_EQUATION_OPER_FSUB "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_FMUL, "ZET_INTEL_METRIC_DF_EQUATION_OPER_FMUL "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_FDIV, "ZET_INTEL_METRIC_DF_EQUATION_OPER_FDIV "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_UGT, "ZET_INTEL_METRIC_DF_EQUATION_OPER_UGT "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_ULT, "ZET_INTEL_METRIC_DF_EQUATION_OPER_ULT "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_UGTE, "ZET_INTEL_METRIC_DF_EQUATION_OPER_UGTE "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_ULTE, "ZET_INTEL_METRIC_DF_EQUATION_OPER_ULTE "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_FGT, "ZET_INTEL_METRIC_DF_EQUATION_OPER_FGT "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_FLT, "ZET_INTEL_METRIC_DF_EQUATION_OPER_FLT "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_FGTE, "ZET_INTEL_METRIC_DF_EQUATION_OPER_FGTE "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_FLTE, "ZET_INTEL_METRIC_DF_EQUATION_OPER_FLTE "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_UMIN, "ZET_INTEL_METRIC_DF_EQUATION_OPER_UMIN "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_UMAX, "ZET_INTEL_METRIC_DF_EQUATION_OPER_UMAX "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_FMIN, "ZET_INTEL_METRIC_DF_EQUATION_OPER_FMIN "},
{ZET_INTEL_METRIC_DF_EQUATION_OPER_FMAX, "ZET_INTEL_METRIC_DF_EQUATION_OPER_FMAX "},
};
if (equationOperationMap.find(equationOperation) == equationOperationMap.end()) {
EXPECT(0);
return;
}
SHOW(indent) << "equationOperation : " << equationOperationMap[equationOperation];
}
void showEquation(zet_intel_metric_df_gpu_equation_0_1_t &equation, uint32_t indent = 1) {
LOG(LogLevel::DEBUG) << "@line: " << __LINE__ << " of function " << __FUNCTION__ << std::endl;
if (equation.elementCount == 0) {
SHOW(indent) << " equation.elementCount == 0" << std::endl;
return;
}
SHOW(indent) << " equation.elementCount :" << equation.elementCount << std::endl;
auto elementBase = zet_intel_metric_df_gpu_offset_to_ptr(
zet_intel_metric_df_gpu_equation_element_0_1_offset_t,
equation.elements,
startAddress);
for (auto elemIdx = 0u; elemIdx < equation.elementCount; elemIdx++) {
zet_intel_metric_df_gpu_equation_element_0_1_t *currElement = &elementBase[elemIdx];
auto tabbedIndent = indent + 5;
switch (currElement->type) {
case ZET_INTEL_METRIC_DF_EQUATION_ELEM_OPERATION:
SHOW(tabbedIndent) << "ZET_INTEL_METRIC_DF_EQUATION_ELEM_OPERATION : " << std::endl;
showEquationOperation(currElement->operation, tabbedIndent + 5);
SHOW(tabbedIndent) << std::endl;
break;
case ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_BITFIELD:
SHOW(tabbedIndent) << "ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_BITFIELD: " << std::endl;
SHOW(tabbedIndent + 5) << " currElement->readParams.byteOffset: " << currElement->readParams.byteOffset << std::endl;
SHOW(tabbedIndent + 5) << " currElement->readParams.bitOffset: " << currElement->readParams.bitOffset << std::endl;
SHOW(tabbedIndent + 5) << " currElement->readParams.bitsCount: " << currElement->readParams.bitsCount << std::endl;
break;
case ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_UINT8:
SHOW(tabbedIndent) << "ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_UINT8: " << std::endl;
SHOW(tabbedIndent + 5) << " currElement->readParams.byteOffset: " << currElement->readParams.byteOffset << std::endl;
break;
case ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_UINT16:
SHOW(tabbedIndent) << "ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_UINT16: " << std::endl;
SHOW(tabbedIndent + 5) << " currElement->readParams.byteOffset: " << currElement->readParams.byteOffset << std::endl;
break;
case ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_UINT32:
SHOW(tabbedIndent) << "ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_UINT32: " << std::endl;
SHOW(tabbedIndent + 5) << " currElement->readParams.byteOffset: " << currElement->readParams.byteOffset << std::endl;
break;
case ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_UINT64:
SHOW(tabbedIndent) << "ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_UINT64: " << std::endl;
SHOW(tabbedIndent + 5) << " currElement->readParams.byteOffset: " << currElement->readParams.byteOffset << std::endl;
break;
case ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_FLOAT:
SHOW(tabbedIndent) << "ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_FLOAT: " << std::endl;
SHOW(tabbedIndent + 5) << " currElement->readParams.byteOffset: " << currElement->readParams.byteOffset << std::endl;
break;
case ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_40BIT_CNTR:
SHOW(tabbedIndent) << "ZET_INTEL_METRIC_DF_EQUATION_ELEM_RD_40BIT_CNTR: " << std::endl;
SHOW(tabbedIndent + 5) << " currElement->readParams.byteOffset: " << currElement->readParams.byteOffset << std::endl;
SHOW(tabbedIndent + 5) << " currElement->readParams.byteOffsetExt: " << currElement->readParams.byteOffsetExt << std::endl;
break;
case ZET_INTEL_METRIC_DF_EQUATION_ELEM_IMM_UINT64:
SHOW(tabbedIndent) << "ZET_INTEL_METRIC_DF_EQUATION_ELEM_IMM_UINT64: " << std::endl;
SHOW(tabbedIndent + 5) << " currElement->immediateUInt64 : " << currElement->immediateUInt64 << std::endl;
break;
case ZET_INTEL_METRIC_DF_EQUATION_ELEM_IMM_FLOAT:
SHOW(tabbedIndent) << "ZET_INTEL_METRIC_DF_EQUATION_ELEM_IMM_FLOAT: " << std::endl;
SHOW(tabbedIndent + 5) << " currElement->immediateFloat : " << currElement->immediateFloat << std::endl;
break;
case ZET_INTEL_METRIC_DF_EQUATION_ELEM_SELF_COUNTER_VALUE:
SHOW(tabbedIndent) << "ZET_INTEL_METRIC_DF_EQUATION_ELEM_SELF_COUNTER_VALUE: " << std::endl;
break;
case ZET_INTEL_METRIC_DF_EQUATION_ELEM_GLOBAL_SYMBOL:
SHOW(tabbedIndent) << "ZET_INTEL_METRIC_DF_EQUATION_ELEM_GLOBAL_SYMBOL: " << std::endl;
showEquationOperation(currElement->operation, tabbedIndent + 5);
SHOW(tabbedIndent) << std::endl;
SHOW_CSTRING_OFFSET(&currElement->symbolName, tabbedIndent + 5);
SHOW(tabbedIndent) << std::endl;
break;
case ZET_INTEL_METRIC_DF_EQUATION_ELEM_LOCAL_COUNTER_SYMBOL:
SHOW(tabbedIndent) << "ZET_INTEL_METRIC_DF_EQUATION_ELEM_LOCAL_COUNTER_SYMBOL: " << std::endl;
showEquationOperation(currElement->operation, tabbedIndent + 5);
SHOW(tabbedIndent) << std::endl;
SHOW_CSTRING_OFFSET(&currElement->symbolName, tabbedIndent + 5);
SHOW(tabbedIndent) << std::endl;
break;
case ZET_INTEL_METRIC_DF_EQUATION_ELEM_OTHER_SET_COUNTER_SYMBOL:
SHOW(tabbedIndent) << "ZET_INTEL_METRIC_DF_EQUATION_ELEM_OTHER_SET_COUNTER_SYMBOL: " << std::endl;
showEquationOperation(currElement->operation, tabbedIndent + 5);
SHOW(tabbedIndent) << std::endl;
SHOW_CSTRING_OFFSET(&currElement->symbolName, tabbedIndent + 5);
SHOW(tabbedIndent) << std::endl;
break;
case ZET_INTEL_METRIC_DF_EQUATION_ELEM_LOCAL_METRIC_SYMBOL:
SHOW(tabbedIndent) << "ZET_INTEL_METRIC_DF_EQUATION_ELEM_LOCAL_METRIC_SYMBOL: " << std::endl;
SHOW_CSTRING_OFFSET(&currElement->symbolName, tabbedIndent + 5);
SHOW(tabbedIndent) << std::endl;
break;
case ZET_INTEL_METRIC_DF_EQUATION_ELEM_OTHER_SET_METRIC_SYMBOL:
SHOW(tabbedIndent) << "ZET_INTEL_METRIC_DF_EQUATION_ELEM_OTHER_SET_METRIC_SYMBOL: " << std::endl;
SHOW_CSTRING_OFFSET(&currElement->symbolName, tabbedIndent + 5);
SHOW(tabbedIndent) << std::endl;
break;
case ZET_INTEL_METRIC_DF_EQUATION_ELEM_INFORMATION_SYMBOL:
SHOW(tabbedIndent) << "ZET_INTEL_METRIC_DF_EQUATION_ELEM_INFORMATION_SYMBOL: " << std::endl;
SHOW_CSTRING_OFFSET(&currElement->symbolName, tabbedIndent + 5);
SHOW(tabbedIndent) << std::endl;
break;
case ZET_INTEL_METRIC_DF_EQUATION_ELEM_STD_NORM_GPU_DURATION:
SHOW(tabbedIndent) << "ZET_INTEL_METRIC_DF_EQUATION_ELEM_STD_NORM_GPU_DURATION: " << std::endl;
break;
case ZET_INTEL_METRIC_DF_EQUATION_ELEM_STD_NORM_EU_AGGR_DURATION:
SHOW(tabbedIndent) << "ZET_INTEL_METRIC_DF_EQUATION_ELEM_STD_NORM_EU_AGGR_DURATION: " << std::endl;
break;
case ZET_INTEL_METRIC_DF_EQUATION_ELEM_MASK:
SHOW(tabbedIndent) << "ZET_INTEL_METRIC_DF_EQUATION_ELEM_MASK: " << std::endl;
showByteArray(&currElement->mask, tabbedIndent + 5);
SHOW(tabbedIndent) << std::endl;
break;
default:
EXPECT(0);
break;
}
}
}
void showDeltaFunction(zet_intel_metric_df_gpu_delta_function_0_1_t &deltaFunction, uint32_t indent) {
LOG(LogLevel::DEBUG) << "@line: " << __LINE__ << " of function " << __FUNCTION__ << std::endl;
SHOW(indent) << "deltaFunction.bitsCount: " << deltaFunction.bitsCount << std::endl;
std::map<zet_intel_metric_df_gpu_delta_function_type_t, std::string> deltaFunctionMap = {
{ZET_INTEL_METRIC_DF_DELTA_FUNCTION_NULL, "ZET_INTEL_METRIC_DF_DELTA_FUNCTION_NULL "},
{ZET_INTEL_METRIC_DF_DELTA_N_BITS, "ZET_INTEL_METRIC_DF_DELTA_N_BITS "},
{ZET_INTEL_METRIC_DF_DELTA_BOOL_OR, "ZET_INTEL_METRIC_DF_DELTA_BOOL_OR "},
{ZET_INTEL_METRIC_DF_DELTA_BOOL_XOR, "ZET_INTEL_METRIC_DF_DELTA_BOOL_XOR "},
{ZET_INTEL_METRIC_DF_DELTA_GET_PREVIOUS, "ZET_INTEL_METRIC_DF_DELTA_GET_PREVIOUS "},
{ZET_INTEL_METRIC_DF_DELTA_GET_LAST, "ZET_INTEL_METRIC_DF_DELTA_GET_LAST "},
{ZET_INTEL_METRIC_DF_DELTA_NS_TIME, "ZET_INTEL_METRIC_DF_DELTA_NS_TIME "},
};
if (deltaFunctionMap.find(deltaFunction.functionType) == deltaFunctionMap.end()) {
EXPECT(0);
}
SHOW(indent) << "deltaFunction.functionType :" << deltaFunctionMap[deltaFunction.functionType] << std::endl;
}
ze_result_t showInformationType(zet_intel_metric_df_gpu_information_type_t &infoType, uint32_t indent) {
LOG(LogLevel::DEBUG) << "@line: " << __LINE__ << " of function " << __FUNCTION__ << std::endl;
std::map<zet_intel_metric_df_gpu_information_type_t, std::string> informationTypeMap = {
{ZET_INTEL_METRIC_DF_INFORMATION_TYPE_REPORT_REASON, "ZET_INTEL_METRIC_DF_INFORMATION_TYPE_REPORT_REASON "},
{ZET_INTEL_METRIC_DF_INFORMATION_TYPE_VALUE, "ZET_INTEL_METRIC_DF_INFORMATION_TYPE_VALUE "},
{ZET_INTEL_METRIC_DF_INFORMATION_TYPE_FLAG, "ZET_INTEL_METRIC_DF_INFORMATION_TYPE_FLAG "},
{ZET_INTEL_METRIC_DF_INFORMATION_TYPE_TIMESTAMP, "ZET_INTEL_METRIC_DF_INFORMATION_TYPE_TIMESTAMP "},
{ZET_INTEL_METRIC_DF_INFORMATION_TYPE_CONTEXT_ID_TAG, "ZET_INTEL_METRIC_DF_INFORMATION_TYPE_CONTEXT_ID_TAG"},
{ZET_INTEL_METRIC_DF_INFORMATION_TYPE_SAMPLE_PHASE, "ZET_INTEL_METRIC_DF_INFORMATION_TYPE_SAMPLE_PHASE "},
{ZET_INTEL_METRIC_DF_INFORMATION_TYPE_GPU_NODE, "ZET_INTEL_METRIC_DF_INFORMATION_TYPE_GPU_NODE "}};
if (informationTypeMap.find(infoType) == informationTypeMap.end()) {
EXPECT(0);
}
SHOW(indent) << "infoType :" << informationTypeMap[infoType] << std::endl;
return ZE_RESULT_SUCCESS;
}
void showInformationParams(zet_intel_metric_df_gpu_information_params_0_1_t *infoParams, uint32_t indent) {
LOG(LogLevel::DEBUG) << "@line: " << __LINE__ << " of function " << __FUNCTION__ << std::endl;
SHOW(indent) << "infoParams->idInSet :" << infoParams->idInSet << std::endl;
SHOW_CSTRING_OFFSET(&infoParams->symbolName, indent);
SHOW_CSTRING_OFFSET(&infoParams->shortName, indent);
SHOW_CSTRING_OFFSET(&infoParams->groupName, indent);
SHOW_CSTRING_OFFSET(&infoParams->longName, indent);
SHOW(indent) << "infoParams->apiMask : " << infoParams->apiMask << std::endl;
SHOW(indent) << "infoParams->infoType : ";
showInformationType(infoParams->infoType, indent);
SHOW(indent) << std::endl;
SHOW_CSTRING_OFFSET(&infoParams->infoUnits, indent);
SHOW_EQUATION(infoParams->ioReadEquation, indent);
SHOW_EQUATION(infoParams->queryReadEquation, indent);
SHOW(indent) << "infoParams->overflowFunction : ";
showDeltaFunction(infoParams->overflowFunction, indent);
SHOW(indent) << std::endl;
}
void showInformationParamsOffset(zet_intel_metric_df_gpu_information_params_0_1_offset_t *informationParamsOffset, uint32_t count, uint32_t indent) {
LOG(LogLevel::DEBUG) << "@line: " << __LINE__ << " of function " << __FUNCTION__ << std::endl;
auto informationParamsBase = zet_intel_metric_df_gpu_offset_to_ptr(
zet_intel_metric_df_gpu_information_params_0_1_offset_t,
*informationParamsOffset,
startAddress);
zet_intel_metric_df_gpu_information_params_0_1_t *currInformationParams;
for (auto index = 0u; index < count; index++) {
currInformationParams = &informationParamsBase[index];
showInformationParams(currInformationParams, indent);
}
}
ze_result_t showMetricType(zet_intel_metric_df_gpu_metric_type_t &metricType, uint32_t indent) {
LOG(LogLevel::DEBUG) << "@line: " << __LINE__ << " of function " << __FUNCTION__ << std::endl;
std::map<zet_intel_metric_df_gpu_metric_type_t, std::string> metricTypeMap = {
{ZET_INTEL_METRIC_DF_METRIC_TYPE_DURATION, "ZET_INTEL_METRIC_DF_METRIC_TYPE_DURATION"},
{ZET_INTEL_METRIC_DF_METRIC_TYPE_EVENT, "ZET_INTEL_METRIC_DF_METRIC_TYPE_EVENT"},
{ZET_INTEL_METRIC_DF_METRIC_TYPE_EVENT_WITH_RANGE, "ZET_INTEL_METRIC_DF_METRIC_TYPE_EVENT_WITH_RANGE"},
{ZET_INTEL_METRIC_DF_METRIC_TYPE_THROUGHPUT, "ZET_INTEL_METRIC_DF_METRIC_TYPE_THROUGHPUT"},
{ZET_INTEL_METRIC_DF_METRIC_TYPE_TIMESTAMP, "ZET_INTEL_METRIC_DF_METRIC_TYPE_TIMESTAMP"},
{ZET_INTEL_METRIC_DF_METRIC_TYPE_FLAG, "ZET_INTEL_METRIC_DF_METRIC_TYPE_FLAG"},
{ZET_INTEL_METRIC_DF_METRIC_TYPE_RATIO, "ZET_INTEL_METRIC_DF_METRIC_TYPE_RATIO"},
{ZET_INTEL_METRIC_DF_METRIC_TYPE_RAW, "ZET_INTEL_METRIC_DF_METRIC_TYPE_RAW"},
};
if (metricTypeMap.find(metricType) == metricTypeMap.end()) {
EXPECT(0);
}
SHOW(indent) << "MetricType: " << metricTypeMap[metricType] << std::endl;
return ZE_RESULT_SUCCESS;
}
void showMetricParamsOffset(zet_intel_metric_df_gpu_metric_params_0_1_offset_t *metricParamsOffset, uint32_t count, uint32_t indent) {
LOG(LogLevel::DEBUG) << "@line: " << __LINE__ << " of function " << __FUNCTION__ << std::endl;
auto metricParamsBase = zet_intel_metric_df_gpu_offset_to_ptr(zet_intel_metric_df_gpu_metric_params_0_1_offset_t, *metricParamsOffset, startAddress);
for (auto index = 0u; index < count; index++) {
SHOW(indent) << "[" << index << "]:" << std::endl;
auto tabbedIndent = indent + 5;
auto currMetricParams = &metricParamsBase[index];
SHOW_UINT32_T(currMetricParams->idInSet, tabbedIndent);
SHOW_CSTRING_OFFSET(&currMetricParams->symbolName, tabbedIndent);
SHOW_CSTRING_OFFSET(&currMetricParams->shortName, tabbedIndent);
SHOW_CSTRING_OFFSET(&currMetricParams->groupName, tabbedIndent);
SHOW_CSTRING_OFFSET(&currMetricParams->longName, tabbedIndent);
SHOW(tabbedIndent) << "currMetricParams->apiMask: " << currMetricParams->apiMask << std::endl;
SHOW_CSTRING_OFFSET(&currMetricParams->metricResultUnits, tabbedIndent);
SHOW(tabbedIndent) << "currMetricParams->metricType: ";
showMetricType(currMetricParams->metricType, 1);
SHOW_EQUATION(currMetricParams->ioReadEquation, tabbedIndent);
SHOW_EQUATION(currMetricParams->queryReadEquation, tabbedIndent);
SHOW(tabbedIndent) << "currMetricParams->deltaFunction : ";
showDeltaFunction(currMetricParams->deltaFunction, tabbedIndent);
SHOW(tabbedIndent) << std::endl;
SHOW_EQUATION(currMetricParams->normEquation, tabbedIndent);
SHOW_EQUATION(currMetricParams->maxValueEquation, tabbedIndent);
}
}
void showConcurrentGroupParams(zet_intel_metric_df_gpu_concurrent_group_params_0_1_t *concGroupParams, uint32_t indent) {
LOG(LogLevel::DEBUG) << "@line: " << __LINE__ << " of function " << __FUNCTION__ << std::endl;
SHOW_CSTRING_OFFSET(&concGroupParams->symbolName, indent);
SHOW_CSTRING_OFFSET(&concGroupParams->description, indent);
SHOW_UINT32_T(concGroupParams->ioMeasurementInformationCount, indent);
SHOW_UINT32_T(concGroupParams->ioGpuContextInformationCount, indent);
}
void showConcurrentGroup(zet_intel_metric_df_gpu_concurrent_group_0_1_t *concGroup, uint32_t indent) {
LOG(LogLevel::DEBUG) << "@line: " << __LINE__ << " of function " << __FUNCTION__ << std::endl;
indent += indentLevelIncrement;
showConcurrentGroupParams(&concGroup->params, indent);
showInformationParamsOffset(&concGroup->ioMeasurementInformation, concGroup->params.ioMeasurementInformationCount, indent);
showInformationParamsOffset(&concGroup->ioGpuContextInformation, concGroup->params.ioGpuContextInformationCount, indent);
}
void showMetricSetParams(zet_intel_metric_df_gpu_metric_set_params_0_1_t *params, uint32_t indent) {
LOG(LogLevel::DEBUG) << "@line: " << __LINE__ << " of function " << __FUNCTION__ << std::endl;
SHOW_CSTRING_OFFSET(&params->symbolName, indent);
SHOW_CSTRING_OFFSET(&params->shortName, indent);
SHOW_UINT32_T(params->apiMask, indent);
SHOW_UINT32_T(params->metricsCount, indent);
SHOW_UINT32_T(params->informationCount, indent);
if (params->availabilityEquation == 0) {
SHOW(indent) << "params->availabilityEquation : nullptr \n";
} else {
SHOW_CSTRING_OFFSET(&params->availabilityEquation, indent);
}
}
void showMetricSet(zet_intel_metric_df_gpu_metric_set_0_1_t *metricSet, uint32_t indent) {
LOG(LogLevel::DEBUG) << "@line: " << __LINE__ << " of function " << __FUNCTION__ << std::endl;
showMetricSetParams(&metricSet->params, indent);
showInformationParamsOffset(&metricSet->informationParams, metricSet->params.informationCount, indent);
showMetricParamsOffset(&metricSet->metricParams, metricSet->params.metricsCount, indent);
}
void showAdapterParams(zet_intel_metric_df_gpu_adapter_params_0_1_t *adapterParams, uint32_t indent) {
LOG(LogLevel::DEBUG) << "@line: " << __LINE__ << " of function " << __FUNCTION__ << std::endl;
indent += indentLevelIncrement;
SHOW_UINT32_T(adapterParams->busNumber, indent);
SHOW_UINT32_T(adapterParams->deviceNumber, indent);
SHOW_UINT32_T(adapterParams->functionNumber, indent);
SHOW_UINT32_T(adapterParams->domainNumber, indent);
showAdapterId(&adapterParams->systemId, indent);
}
void showGlobalSymbolOffsetAndValues(zet_intel_metric_df_gpu_global_symbol_0_1_offset_t *globalSymbolsOffset, uint32_t globalSymbolsCount, uint32_t indent) {
LOG(LogLevel::DEBUG) << "@line: " << __LINE__ << " of function " << __FUNCTION__ << std::endl;
indent += indentLevelIncrement;
zet_intel_metric_df_gpu_global_symbol_0_1_t *globalSymbolsBase =
zet_intel_metric_df_gpu_offset_to_ptr(zet_intel_metric_df_gpu_global_symbol_0_1_offset_t, *globalSymbolsOffset, startAddress);
for (uint32_t index = 0; index < globalSymbolsCount; index++) {
auto currSymbol = &globalSymbolsBase[index];
SHOW_CSTRING_OFFSET(&currSymbol->symbolName, indent);
showTypedValue(&currSymbol->symbolTypedValue, indent);
}
}
void showMetricsDeviceParams(zet_intel_metric_df_gpu_metrics_device_params_0_1_t *deviceParams, uint32_t indent) {
LOG(LogLevel::DEBUG) << "@line: " << __LINE__ << " of function " << __FUNCTION__ << std::endl;
showMetricApiVersion(&deviceParams->version, indent);
SHOW_UINT32_T(deviceParams->globalSymbolsCount, indent);
}
public:
MetricOaExporter01Logger(uintptr_t startAddress) : startAddress(startAddress) {}
void showExportData(zet_intel_metric_df_gpu_metric_oa_calc_0_1_t *oaCalcData) {
LOG(LogLevel::DEBUG) << "@line: " << __LINE__ << " of function " << __FUNCTION__ << std::endl;
showMetricsDeviceParams(&oaCalcData->deviceParams, indentLevelIncrement);
showGlobalSymbolOffsetAndValues(&oaCalcData->globalSymbols, oaCalcData->deviceParams.globalSymbolsCount, 3);
showAdapterParams(&oaCalcData->adapterParams, indentLevelIncrement);
showConcurrentGroup(&oaCalcData->concurrentGroup, indentLevelIncrement);
showMetricSet(&oaCalcData->metricSet, indentLevelIncrement);
}
};
static void showExportHeader(zet_intel_metric_df_gpu_header_t &header, uint32_t indent = 1) {
LOG(LogLevel::DEBUG) << "@line: " << __LINE__ << " of function " << __FUNCTION__ << std::endl;
std::map<zet_intel_metric_df_gpu_metric_source_type_t, std::string> sourceTypeMap =
{
{ZET_INTEL_METRIC_DF_SOURCE_TYPE_OA, "ZET_INTEL_METRIC_DF_SOURCE_TYPE_OA"}};
if (sourceTypeMap.find(header.type) == sourceTypeMap.end()) {
EXPECT(0);
return;
}
SHOW(indent) << "sourcetype : " << sourceTypeMap[header.type] << "\n";
SHOW_UINT32_T(header.version.major, indent);
SHOW_UINT32_T(header.version.minor, indent);
SHOW_UINT32_T(header.rawDataOffset, indent);
SHOW_UINT32_T(header.rawDataSize, indent);
}
void showMetricsExportData(uint8_t *pExportData, size_t exportDataSize) {
zet_intel_metric_df_gpu_export_data_format_t *exportData =
reinterpret_cast<zet_intel_metric_df_gpu_export_data_format_t *>(pExportData);
showExportHeader(exportData->header);
MetricOaExporter01Logger exportLogger10(reinterpret_cast<uintptr_t>(pExportData));
exportLogger10.showExportData(&exportData->format01.oaData);
}
} // namespace ZelloMetricsUtility

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2022 Intel Corporation
* Copyright (C) 2022-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -94,5 +94,6 @@ zet_metric_group_handle_t findMetricGroup(const char *groupName,
ze_event_pool_handle_t createHostVisibleEventPool(ze_context_handle_t contextHandle, ze_device_handle_t deviceHandle);
ze_event_handle_t createHostVisibleEvent(ze_event_pool_handle_t hostVisibleEventPool);
void obtainCalculatedMetrics(zet_metric_group_handle_t metricGroup, uint8_t *rawData, uint32_t rawDataSize);
void showMetricsExportData(uint8_t *pExportData, size_t exportDataSize);
} // namespace ZelloMetricsUtility

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2020-2022 Intel Corporation
# Copyright (C) 2020-2023 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
@ -27,6 +27,7 @@ target_sources(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/test_metric_oa_initialization.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_metric_ip_sampling_enumeration.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_metric_ip_sampling_streamer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_metric_oa_export.cpp
)

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2022 Intel Corporation
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -278,6 +278,17 @@ IAdapter_1_6 *IAdapterGroup_1_6::GetAdapter(uint32_t index) {
return nullptr;
}
IEquation_1_0::~IEquation_1_0() {}
uint32_t IEquation_1_0::GetEquationElementsCount(void) {
UNRECOVERABLE_IF(true);
return 0;
}
TEquationElement_1_0 *IEquation_1_0::GetEquationElement(uint32_t index) {
UNRECOVERABLE_IF(true);
return nullptr;
}
IAdapterGroup_1_6 ::~IAdapterGroup_1_6() {
}

View File

@ -9,6 +9,7 @@
#include "level_zero/core/source/cmdlist/cmdlist.h"
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
#include "level_zero/include/zet_intel_gpu_metric.h"
#include "level_zero/tools/source/metrics/metric_ip_sampling_source.h"
#include "level_zero/tools/source/metrics/metric_oa_source.h"
#include "level_zero/tools/source/metrics/os_interface_metric.h"
@ -988,5 +989,69 @@ TEST_F(MetricIpSamplingEnumerationTest, GivenEnumerationIsSuccessfulWhenAppendMe
EXPECT_EQ(zetCommandListAppendMetricMemoryBarrier(commandListHandle), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
}
using MetricExportDataIpSamplingTest = MetricIpSamplingEnumerationTest;
TEST_F(MetricExportDataIpSamplingTest, WhenMetricGroupGetExportDataIsCalledThenReturnSuccess) {
EXPECT_EQ(ZE_RESULT_SUCCESS, testDevices[0]->getMetricDeviceContext().enableMetricApi());
for (auto device : testDevices) {
uint32_t metricGroupCount = 0;
zetMetricGroupGet(device->toHandle(), &metricGroupCount, nullptr);
EXPECT_EQ(metricGroupCount, 1u);
std::vector<zet_metric_group_handle_t> metricGroups;
metricGroups.resize(metricGroupCount);
ASSERT_EQ(zetMetricGroupGet(device->toHandle(), &metricGroupCount, metricGroups.data()), ZE_RESULT_SUCCESS);
ASSERT_NE(metricGroups[0], nullptr);
uint8_t dummyRawData = 8;
size_t exportDataSize = 0;
const auto dummyRawDataSize = 1u;
EXPECT_EQ(zetMetricGroupGetExportDataExp(metricGroups[0],
&dummyRawData, dummyRawDataSize, &exportDataSize, nullptr),
ZE_RESULT_SUCCESS);
EXPECT_GE(exportDataSize, 0u);
std::vector<uint8_t> exportDataMem(exportDataSize);
EXPECT_EQ(zetMetricGroupGetExportDataExp(metricGroups[0],
&dummyRawData, dummyRawDataSize, &exportDataSize, exportDataMem.data()),
ZE_RESULT_SUCCESS);
zet_intel_metric_df_gpu_export_data_format_t *exportData = reinterpret_cast<zet_intel_metric_df_gpu_export_data_format_t *>(exportDataMem.data());
EXPECT_EQ(exportData->header.type, ZET_INTEL_METRIC_DF_SOURCE_TYPE_IPSAMPLING);
EXPECT_EQ(dummyRawData, exportDataMem[exportData->header.rawDataOffset]);
}
}
TEST_F(MetricExportDataIpSamplingTest, GivenIncorrectExportDataSizeWhenMetricGroupGetExportDataIsCalledThenErrorIsReturned) {
EXPECT_EQ(ZE_RESULT_SUCCESS, testDevices[0]->getMetricDeviceContext().enableMetricApi());
for (auto device : testDevices) {
uint32_t metricGroupCount = 0;
zetMetricGroupGet(device->toHandle(), &metricGroupCount, nullptr);
EXPECT_EQ(metricGroupCount, 1u);
std::vector<zet_metric_group_handle_t> metricGroups;
metricGroups.resize(metricGroupCount);
ASSERT_EQ(zetMetricGroupGet(device->toHandle(), &metricGroupCount, metricGroups.data()), ZE_RESULT_SUCCESS);
ASSERT_NE(metricGroups[0], nullptr);
uint8_t dummyRawData = 0;
size_t exportDataSize = 0;
const auto dummyRawDataSize = 1u;
EXPECT_EQ(zetMetricGroupGetExportDataExp(metricGroups[0],
&dummyRawData, dummyRawDataSize, &exportDataSize, nullptr),
ZE_RESULT_SUCCESS);
EXPECT_GE(exportDataSize, 0u);
exportDataSize -= 1;
std::vector<uint8_t> exportDataMem(exportDataSize);
EXPECT_EQ(zetMetricGroupGetExportDataExp(metricGroups[0],
&dummyRawData, dummyRawDataSize, &exportDataSize, exportDataMem.data()),
ZE_RESULT_ERROR_INVALID_SIZE);
}
}
} // namespace ult
} // namespace L0

File diff suppressed because it is too large Load Diff