mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-30 01:35:20 +08:00
feature: expose source ids for metric groups
Related-To: NEO-13480 Signed-off-by: Joshua Santosh Ranjan <joshua.santosh.ranjan@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
b11322332c
commit
c8eb085cdb
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2024 Intel Corporation
|
||||
* Copyright (C) 2020-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -22,6 +22,12 @@
|
||||
|
||||
namespace L0 {
|
||||
|
||||
void MetricSource::getMetricGroupSourceIdProperty(zet_base_properties_t *property) {
|
||||
|
||||
zet_intel_metric_source_id_exp_t *groupProperty = reinterpret_cast<zet_intel_metric_source_id_exp_t *>(property);
|
||||
groupProperty->sourceId = type;
|
||||
}
|
||||
|
||||
MetricDeviceContext::MetricDeviceContext(Device &inputDevice) : device(inputDevice) {
|
||||
auto deviceNeo = device.getNEODevice();
|
||||
std::tuple<uint32_t, uint32_t, uint32_t> subDeviceMap;
|
||||
|
||||
@@ -93,6 +93,7 @@ class MetricSource {
|
||||
|
||||
protected:
|
||||
uint32_t type = MetricSource::metricSourceTypeUndefined;
|
||||
void getMetricGroupSourceIdProperty(zet_base_properties_t *property);
|
||||
};
|
||||
|
||||
class MultiDomainDeferredActivationTracker {
|
||||
|
||||
@@ -212,7 +212,11 @@ ze_result_t IpSamplingMetricSourceImp::handleMetricGroupExtendedProperties(zet_m
|
||||
while (pNext) {
|
||||
auto extendedProperties = reinterpret_cast<zet_base_properties_t *>(pNext);
|
||||
|
||||
if (extendedProperties->stype == ZET_STRUCTURE_TYPE_METRIC_GLOBAL_TIMESTAMPS_RESOLUTION_EXP) {
|
||||
if (extendedProperties->stype == ZET_INTEL_STRUCTURE_TYPE_METRIC_SOURCE_ID_EXP) {
|
||||
|
||||
getMetricGroupSourceIdProperty(extendedProperties);
|
||||
retVal = ZE_RESULT_SUCCESS;
|
||||
} else if (extendedProperties->stype == ZET_STRUCTURE_TYPE_METRIC_GLOBAL_TIMESTAMPS_RESOLUTION_EXP) {
|
||||
|
||||
zet_metric_global_timestamps_resolution_exp_t *metricsTimestampProperties =
|
||||
reinterpret_cast<zet_metric_global_timestamps_resolution_exp_t *>(extendedProperties);
|
||||
@@ -220,14 +224,11 @@ ze_result_t IpSamplingMetricSourceImp::handleMetricGroupExtendedProperties(zet_m
|
||||
getTimerResolution(metricsTimestampProperties->timerResolution);
|
||||
getTimestampValidBits(metricsTimestampProperties->timestampValidBits);
|
||||
retVal = ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
if (extendedProperties->stype == ZET_STRUCTURE_TYPE_METRIC_GROUP_TYPE_EXP) {
|
||||
} else if (extendedProperties->stype == ZET_STRUCTURE_TYPE_METRIC_GROUP_TYPE_EXP) {
|
||||
zet_metric_group_type_exp_t *groupType = reinterpret_cast<zet_metric_group_type_exp_t *>(extendedProperties);
|
||||
groupType->type = ZET_METRIC_GROUP_TYPE_EXP_FLAG_OTHER;
|
||||
retVal = ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
pNext = extendedProperties->pNext;
|
||||
}
|
||||
|
||||
|
||||
@@ -613,7 +613,7 @@ void MetricEnumeration::updateMetricProgrammablesFromPrototypes(
|
||||
properties.tierNumber = getMetricTierNumber(metricPrototypeParams->UsageFlagsMask);
|
||||
properties.samplingType = getSamplingTypeFromApiMask(metricPrototypeParams->ApiMask);
|
||||
properties.parameterCount = metricPrototypeParams->OptionDescriptorCount;
|
||||
properties.sourceId = oaSourceId;
|
||||
properties.sourceId = MetricSource::metricSourceTypeOa;
|
||||
auto pMetricProgrammable = OaMetricProgrammableImp::create(properties, concurrentGroup, *metricPrototype, metricSource);
|
||||
metricProgrammables.push_back(pMetricProgrammable);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2024 Intel Corporation
|
||||
* Copyright (C) 2020-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -20,7 +20,6 @@ static constexpr std::string_view globalSymbolOaMaxBufferSize = "OABufferMaxSize
|
||||
static constexpr std::string_view globalSymbolOaMaxTimestamp = "MaxTimestamp";
|
||||
|
||||
struct MetricEnumeration {
|
||||
static const uint32_t oaSourceId = 0x0A;
|
||||
MetricEnumeration(OaMetricSourceImp &metricSource);
|
||||
virtual ~MetricEnumeration();
|
||||
|
||||
|
||||
@@ -208,7 +208,11 @@ ze_result_t OaMetricSourceImp::handleMetricGroupExtendedProperties(zet_metric_gr
|
||||
while (pNext) {
|
||||
auto extendedProperties = reinterpret_cast<zet_base_properties_t *>(pNext);
|
||||
|
||||
if (extendedProperties->stype == ZET_STRUCTURE_TYPE_METRIC_GLOBAL_TIMESTAMPS_RESOLUTION_EXP) {
|
||||
if (extendedProperties->stype == ZET_INTEL_STRUCTURE_TYPE_METRIC_SOURCE_ID_EXP) {
|
||||
|
||||
getMetricGroupSourceIdProperty(extendedProperties);
|
||||
retVal = ZE_RESULT_SUCCESS;
|
||||
} else if (extendedProperties->stype == ZET_STRUCTURE_TYPE_METRIC_GLOBAL_TIMESTAMPS_RESOLUTION_EXP) {
|
||||
|
||||
zet_metric_global_timestamps_resolution_exp_t *metricsTimestampProperties =
|
||||
reinterpret_cast<zet_metric_global_timestamps_resolution_exp_t *>(extendedProperties);
|
||||
@@ -226,9 +230,7 @@ ze_result_t OaMetricSourceImp::handleMetricGroupExtendedProperties(zet_metric_gr
|
||||
metricsTimestampProperties->timestampValidBits = 0;
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
|
||||
if (extendedProperties->stype == ZET_STRUCTURE_TYPE_METRIC_GROUP_TYPE_EXP) {
|
||||
} else if (extendedProperties->stype == ZET_STRUCTURE_TYPE_METRIC_GROUP_TYPE_EXP) {
|
||||
zet_metric_group_type_exp_t *groupType = reinterpret_cast<zet_metric_group_type_exp_t *>(extendedProperties);
|
||||
groupType->type = ZET_METRIC_GROUP_TYPE_EXP_FLAG_OTHER;
|
||||
retVal = ZE_RESULT_SUCCESS;
|
||||
|
||||
@@ -132,6 +132,50 @@ HWTEST2_F(MetricIpSamplingEnumerationTest, GivenDependenciesAvailableWhenMetricG
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(MetricIpSamplingEnumerationTest, GivenDependenciesAvailableWhenMetricGroupSourceIdIsRequestedThenCorrectSourceIdIsReturned, EustallSupportedPlatforms) {
|
||||
|
||||
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);
|
||||
|
||||
zet_intel_metric_source_id_exp_t metricGroupSourceId{};
|
||||
metricGroupSourceId.sourceId = 0xFFFFFFFF;
|
||||
metricGroupSourceId.pNext = nullptr;
|
||||
metricGroupSourceId.stype = ZET_INTEL_STRUCTURE_TYPE_METRIC_SOURCE_ID_EXP;
|
||||
zet_metric_group_properties_t metricGroupProperties = {ZET_STRUCTURE_TYPE_METRIC_GROUP_PROPERTIES, &metricGroupSourceId};
|
||||
EXPECT_EQ(zetMetricGroupGetProperties(metricGroups[0], &metricGroupProperties), ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(metricGroupSourceId.sourceId, MetricSource::metricSourceTypeIpSampling);
|
||||
}
|
||||
}
|
||||
|
||||
using DriverVersionTest = Test<DeviceFixture>;
|
||||
|
||||
TEST_F(DriverVersionTest, givenSupportedExtensionsWhenCheckIfAppendMarkerIsSupportedThenCorrectResultsAreReturned) {
|
||||
uint32_t count = 0;
|
||||
ze_result_t res = driverHandle->getExtensionProperties(&count, nullptr);
|
||||
EXPECT_NE(0u, count);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
std::vector<ze_driver_extension_properties_t> extensionProperties;
|
||||
extensionProperties.resize(count);
|
||||
|
||||
res = driverHandle->getExtensionProperties(&count, extensionProperties.data());
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
auto it = std::find_if(extensionProperties.begin(), extensionProperties.end(), [](const auto &extension) { return (strcmp(extension.name, ZET_INTEL_METRIC_SOURCE_ID_EXP_NAME) == 0); });
|
||||
EXPECT_NE(it, extensionProperties.end());
|
||||
EXPECT_EQ((*it).version, ZET_INTEL_METRIC_SOURCE_ID_EXP_VERSION_CURRENT);
|
||||
}
|
||||
|
||||
struct TestMetricProperties {
|
||||
const char *name;
|
||||
const char *description;
|
||||
@@ -329,6 +373,35 @@ HWTEST2_F(MetricIpSamplingEnumerationTest, GivenEnumerationIsSuccessfulWhenQuery
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(MetricIpSamplingEnumerationTest, GivenEnumerationIsSuccessfulWhenQueryingUnsupportedPropertyThenErrorIsReturned, EustallSupportedPlatforms) {
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, testDevices[0]->getMetricDeviceContext().enableMetricApi());
|
||||
|
||||
for (auto device : testDevices) {
|
||||
|
||||
ze_device_properties_t deviceProps = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES_1_2, nullptr};
|
||||
device->getProperties(&deviceProps);
|
||||
|
||||
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);
|
||||
|
||||
zet_metric_group_type_exp_t metricGroupType{};
|
||||
metricGroupType.stype = static_cast<zet_structure_type_t>(ZET_INTEL_STRUCTURE_TYPE_METRIC_SOURCE_ID_EXP + 1);
|
||||
metricGroupType.pNext = nullptr;
|
||||
metricGroupType.type = ZET_METRIC_GROUP_TYPE_EXP_FLAG_FORCE_UINT32;
|
||||
|
||||
zet_metric_group_properties_t metricGroupProperties = {ZET_STRUCTURE_TYPE_METRIC_GROUP_PROPERTIES, &metricGroupType};
|
||||
EXPECT_EQ(zetMetricGroupGetProperties(metricGroups[0], &metricGroupProperties), ZE_RESULT_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(MetricIpSamplingEnumerationTest, GivenEnumerationIsSuccessfulOnMulitDeviceWhenReadingMetricsTimestampThenResultIsSuccess, EustallSupportedPlatforms) {
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, testDevices[0]->getMetricDeviceContext().enableMetricApi());
|
||||
|
||||
@@ -270,6 +270,78 @@ TEST_F(MetricEnumerationTest, givenValidArgumentsWhenZetGetMetricGroupProperties
|
||||
EXPECT_EQ(strcmp(metricGroupProperties.name, metricsSetParams.SymbolName), 0);
|
||||
}
|
||||
|
||||
TEST_F(MetricEnumerationTest, givenOaMetricSourceWhenQueryingSourceIdThenCorrectSourceIdIsReturned) {
|
||||
|
||||
// Metrics Discovery device.
|
||||
metricsDeviceParams.ConcurrentGroupsCount = 1;
|
||||
|
||||
// Metrics Discovery concurrent group.
|
||||
Mock<IConcurrentGroup_1_13> metricsConcurrentGroup;
|
||||
TConcurrentGroupParams_1_13 metricsConcurrentGroupParams = {};
|
||||
metricsConcurrentGroupParams.MetricSetsCount = 1;
|
||||
metricsConcurrentGroupParams.SymbolName = "OA";
|
||||
metricsConcurrentGroupParams.Description = "OA description";
|
||||
metricsConcurrentGroupParams.IoMeasurementInformationCount = 1;
|
||||
|
||||
Mock<MetricsDiscovery::IEquation_1_0> ioReadEquation;
|
||||
MetricsDiscovery::TEquationElement_1_0 ioEquationElement = {};
|
||||
ioEquationElement.Type = MetricsDiscovery::EQUATION_ELEM_IMM_UINT64;
|
||||
ioEquationElement.ImmediateUInt64 = 0;
|
||||
|
||||
ioReadEquation.getEquationElement.push_back(&ioEquationElement);
|
||||
|
||||
Mock<MetricsDiscovery::IInformation_1_0> ioMeasurement;
|
||||
MetricsDiscovery::TInformationParams_1_0 oaInformation = {};
|
||||
oaInformation.SymbolName = "BufferOverflow";
|
||||
oaInformation.IoReadEquation = &ioReadEquation;
|
||||
metricsConcurrentGroup.GetIoMeasurementInformationResult = &ioMeasurement;
|
||||
ioMeasurement.GetParamsResult = &oaInformation;
|
||||
|
||||
// Metrics Discovery:: metric set.
|
||||
Mock<MetricsDiscovery::IMetricSet_1_13> metricsSet;
|
||||
MetricsDiscovery::TMetricSetParams_1_11 metricsSetParams = {};
|
||||
metricsSetParams.ApiMask = MetricsDiscovery::API_TYPE_OCL;
|
||||
metricsSetParams.MetricsCount = 0;
|
||||
metricsSetParams.SymbolName = "Metric set name";
|
||||
metricsSetParams.ShortName = "Metric set description";
|
||||
|
||||
// One api: metric group handle.
|
||||
zet_metric_group_handle_t metricGroupHandle = {};
|
||||
zet_metric_group_properties_t metricGroupProperties = {ZET_STRUCTURE_TYPE_METRIC_GROUP_PROPERTIES, nullptr};
|
||||
|
||||
openMetricsAdapter();
|
||||
|
||||
setupDefaultMocksForMetricDevice(metricsDevice);
|
||||
|
||||
metricsDevice.getConcurrentGroupResults.push_back(&metricsConcurrentGroup);
|
||||
|
||||
metricsConcurrentGroup.GetParamsResult = &metricsConcurrentGroupParams;
|
||||
metricsConcurrentGroup.getMetricSetResult = &metricsSet;
|
||||
|
||||
metricsSet.GetParamsResult = &metricsSetParams;
|
||||
|
||||
// Metric group count.
|
||||
uint32_t metricGroupCount = 0;
|
||||
EXPECT_EQ(zetMetricGroupGet(device->toHandle(), &metricGroupCount, nullptr), ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(metricGroupCount, 1u);
|
||||
|
||||
// Metric group handle.
|
||||
EXPECT_EQ(zetMetricGroupGet(device->toHandle(), &metricGroupCount, &metricGroupHandle), ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(metricGroupCount, 1u);
|
||||
EXPECT_NE(metricGroupHandle, nullptr);
|
||||
|
||||
zet_intel_metric_source_id_exp_t metricGroupSourceId{};
|
||||
metricGroupSourceId.sourceId = 0xFFFFFFFF;
|
||||
metricGroupSourceId.pNext = nullptr;
|
||||
metricGroupSourceId.stype = ZET_INTEL_STRUCTURE_TYPE_METRIC_SOURCE_ID_EXP;
|
||||
|
||||
metricGroupProperties.pNext = &metricGroupSourceId;
|
||||
|
||||
// Metric group properties.
|
||||
EXPECT_EQ(zetMetricGroupGetProperties(metricGroupHandle, &metricGroupProperties), ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(metricGroupSourceId.sourceId, MetricSource::metricSourceTypeOa);
|
||||
}
|
||||
|
||||
TEST_F(MetricEnumerationTest, givenInvalidArgumentsWhenZetMetricGetIsCalledThenReturnsFail) {
|
||||
|
||||
// Metrics Discovery device.
|
||||
@@ -3408,9 +3480,9 @@ TEST_F(MetricEnumerationTest, givenValidArgumentsWhenAppendMarkerIsCalledThenRet
|
||||
EXPECT_EQ(zetIntelCommandListAppendMarkerExp(nullptr, metricGroupHandle, 0), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE);
|
||||
}
|
||||
|
||||
using DriverVersionTest = Test<DeviceFixture>;
|
||||
using AppendMarkerDriverVersionTest = Test<DeviceFixture>;
|
||||
|
||||
TEST_F(DriverVersionTest, givenSupportedExtensionsWhenCheckIfAppendMarkerIsSupportedThenCorrectResultsAreReturned) {
|
||||
TEST_F(AppendMarkerDriverVersionTest, givenSupportedExtensionsWhenCheckIfAppendMarkerIsSupportedThenCorrectResultsAreReturned) {
|
||||
uint32_t count = 0;
|
||||
ze_result_t res = driverHandle->getExtensionProperties(&count, nullptr);
|
||||
EXPECT_NE(0u, count);
|
||||
|
||||
Reference in New Issue
Block a user