mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Metrics: Avoid multiple metric cacheing for sub-devices
This patch fixes multiple metric cacheing for sub-devices when sub-device is enumerated before root-device Fixes : LOCI-3161 Signed-off-by: Joshua Santosh Ranjan <joshua.santosh.ranjan@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
20348b7185
commit
d4c9cca7fd
@@ -268,6 +268,39 @@ void MetricMultiDeviceFixture::openMetricsAdapterSubDevice(uint32_t subDeviceInd
|
||||
.WillOnce(Return(TCompletionCode::CC_OK));
|
||||
}
|
||||
|
||||
void MetricMultiDeviceFixture::openMetricsAdapterDeviceAndSubDeviceNoCountVerify(uint32_t subDeviceIndex) {
|
||||
|
||||
EXPECT_CALL(*mockMetricEnumeration->g_mockApi, MockOpenAdapterGroup(_))
|
||||
.WillRepeatedly(DoAll(::testing::SetArgPointee<0>(&adapterGroup), Return(TCompletionCode::CC_OK)));
|
||||
|
||||
EXPECT_CALL(adapter, OpenMetricsSubDevice(_, _))
|
||||
.WillRepeatedly(DoAll(::testing::SetArgPointee<1>(&metricsDevice), Return(TCompletionCode::CC_OK)));
|
||||
|
||||
EXPECT_CALL(adapter, CloseMetricsDevice(_))
|
||||
.WillRepeatedly(Return(TCompletionCode::CC_OK));
|
||||
|
||||
EXPECT_CALL(*mockMetricEnumeration, getMetricsAdapter())
|
||||
.WillRepeatedly(Return(&adapter));
|
||||
|
||||
EXPECT_CALL(adapterGroup, Close())
|
||||
.WillRepeatedly(Return(TCompletionCode::CC_OK));
|
||||
|
||||
EXPECT_CALL(*mockMetricEnumerationSubDevices[subDeviceIndex]->g_mockApi, MockOpenAdapterGroup(_))
|
||||
.WillRepeatedly(DoAll(::testing::SetArgPointee<0>(&adapterGroup), Return(TCompletionCode::CC_OK)));
|
||||
|
||||
EXPECT_CALL(adapter, OpenMetricsDevice(_))
|
||||
.WillRepeatedly(DoAll(::testing::SetArgPointee<0>(&metricsDevice), Return(TCompletionCode::CC_OK)));
|
||||
|
||||
EXPECT_CALL(adapter, CloseMetricsDevice(_))
|
||||
.WillRepeatedly(Return(TCompletionCode::CC_OK));
|
||||
|
||||
EXPECT_CALL(*mockMetricEnumerationSubDevices[subDeviceIndex], getMetricsAdapter())
|
||||
.WillRepeatedly(Return(&adapter));
|
||||
|
||||
EXPECT_CALL(adapterGroup, Close())
|
||||
.WillRepeatedly(Return(TCompletionCode::CC_OK));
|
||||
}
|
||||
|
||||
void MetricMultiDeviceFixture::openMetricsAdapterGroup() {
|
||||
|
||||
EXPECT_CALL(*mockMetricEnumeration, loadMetricsDiscovery())
|
||||
|
||||
@@ -175,6 +175,7 @@ class MetricMultiDeviceFixture : public MultiDeviceFixture {
|
||||
void TearDown();
|
||||
void openMetricsAdapter();
|
||||
void openMetricsAdapterSubDevice(uint32_t subDeviceIndex);
|
||||
void openMetricsAdapterDeviceAndSubDeviceNoCountVerify(uint32_t subDeviceIndex);
|
||||
void openMetricsAdapterGroup();
|
||||
|
||||
public:
|
||||
|
||||
@@ -358,6 +358,69 @@ TEST_F(MetricEnumerationMultiDeviceTest, givenValidArgumentsWhenZetMetricGetProp
|
||||
EXPECT_EQ(metricProperties.resultType, ZET_VALUE_TYPE_UINT64);
|
||||
}
|
||||
|
||||
TEST_F(MetricEnumerationMultiDeviceTest, givenRootDeviceIsEnumeratedAfterSubDeviceWhenZetMetricGetIsCalledThenMetricGroupCountIsSameForRootAndSubDevice) {
|
||||
|
||||
auto &deviceImp = *static_cast<DeviceImp *>(devices[0]);
|
||||
metricsDeviceParams.ConcurrentGroupsCount = 1;
|
||||
|
||||
Mock<IConcurrentGroup_1_5> metricsConcurrentGroup;
|
||||
TConcurrentGroupParams_1_0 metricsConcurrentGroupParams = {};
|
||||
metricsConcurrentGroupParams.MetricSetsCount = 1;
|
||||
metricsConcurrentGroupParams.SymbolName = "OA";
|
||||
metricsConcurrentGroupParams.Description = "OA description";
|
||||
|
||||
Mock<MetricsDiscovery::IMetricSet_1_5> metricsSet;
|
||||
MetricsDiscovery::TMetricSetParams_1_4 metricsSetParams = {};
|
||||
metricsSetParams.ApiMask = MetricsDiscovery::API_TYPE_OCL;
|
||||
metricsSetParams.MetricsCount = 0;
|
||||
metricsSetParams.SymbolName = "Metric set name";
|
||||
metricsSetParams.ShortName = "Metric set description";
|
||||
metricsSetParams.MetricsCount = 1;
|
||||
|
||||
Mock<IMetric_1_0> metric;
|
||||
TMetricParams_1_0 metricParams = {};
|
||||
metricParams.SymbolName = "Metric symbol name";
|
||||
metricParams.ShortName = "Metric short name";
|
||||
metricParams.LongName = "Metric long name";
|
||||
metricParams.ResultType = MetricsDiscovery::TMetricResultType::RESULT_UINT64;
|
||||
metricParams.MetricType = MetricsDiscovery::TMetricType::METRIC_TYPE_RATIO;
|
||||
|
||||
openMetricsAdapterDeviceAndSubDeviceNoCountVerify(0);
|
||||
|
||||
EXPECT_CALL(metricsDevice, GetParams())
|
||||
.WillRepeatedly(Return(&metricsDeviceParams));
|
||||
|
||||
EXPECT_CALL(metricsDevice, GetConcurrentGroup(_))
|
||||
.WillRepeatedly(Return(&metricsConcurrentGroup));
|
||||
|
||||
EXPECT_CALL(metricsConcurrentGroup, GetParams())
|
||||
.WillRepeatedly(Return(&metricsConcurrentGroupParams));
|
||||
|
||||
EXPECT_CALL(metricsConcurrentGroup, GetMetricSet(_))
|
||||
.WillRepeatedly(Return(&metricsSet));
|
||||
|
||||
EXPECT_CALL(metricsSet, GetParams())
|
||||
.WillRepeatedly(Return(&metricsSetParams));
|
||||
|
||||
EXPECT_CALL(metricsSet, GetMetric(_))
|
||||
.WillRepeatedly(Return(&metric));
|
||||
|
||||
EXPECT_CALL(metric, GetParams())
|
||||
.WillRepeatedly(Return(&metricParams));
|
||||
|
||||
EXPECT_CALL(metricsSet, SetApiFiltering(_))
|
||||
.WillRepeatedly(Return(TCompletionCode::CC_OK));
|
||||
|
||||
uint32_t subDeviceMetricGroupCount = 0;
|
||||
auto &subDeviceImp = *static_cast<DeviceImp *>(deviceImp.subDevices[0]);
|
||||
EXPECT_EQ(zetMetricGroupGet(subDeviceImp.toHandle(), &subDeviceMetricGroupCount, nullptr), ZE_RESULT_SUCCESS);
|
||||
|
||||
uint32_t rootDeviceMetricGroupCount = 0;
|
||||
EXPECT_EQ(zetMetricGroupGet(devices[0]->toHandle(), &rootDeviceMetricGroupCount, nullptr), ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(rootDeviceMetricGroupCount, 1u);
|
||||
EXPECT_EQ(subDeviceMetricGroupCount, rootDeviceMetricGroupCount);
|
||||
}
|
||||
|
||||
TEST_F(MetricEnumerationMultiDeviceTest, givenCorrectRawDataHeaderWhenZetMetricGroupCalculateMetricValuesExpIsCalledTwiceThenReturnsSuccess) {
|
||||
|
||||
auto &deviceImp = *static_cast<DeviceImp *>(devices[0]);
|
||||
|
||||
Reference in New Issue
Block a user