Refactor Drm::queryTopology() to take struct

- set max values in SystemInfo based on topology

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2021-04-27 14:45:13 +00:00
committed by Compute-Runtime-Automation
parent c0b0013bfc
commit 2d07d6a3d7
8 changed files with 196 additions and 31 deletions

View File

@@ -7,9 +7,12 @@
#include "shared/source/helpers/file_io.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/os_interface/hw_info_config.h"
#include "shared/source/os_interface/linux/os_interface.h"
#include "shared/test/common/helpers/default_hw_info.h"
#include "opencl/test/unit_test/os_interface/linux/drm_mock.h"
#include "test.h"
#include "gtest/gtest.h"
@@ -43,3 +46,58 @@ TEST(DrmQueryTest, WhenCallingIsDebugAttachAvailableThenReturnValueIsFalse) {
EXPECT_FALSE(drm.isDebugAttachAvailable());
}
TEST(DrmQueryTest, GivenDrmWhenQueryingTopologyInfoCorrectMaxValuesAreSet) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
*executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo() = *NEO::defaultHwInfo.get();
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
Drm::QueryTopologyData topologyData = {};
EXPECT_TRUE(drm.queryTopology(*executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo(), topologyData));
EXPECT_EQ(drm.StoredSVal, topologyData.sliceCount);
EXPECT_EQ(drm.StoredSSVal, topologyData.subSliceCount);
EXPECT_EQ(drm.StoredEUVal, topologyData.euCount);
EXPECT_EQ(drm.StoredSVal, topologyData.maxSliceCount);
EXPECT_EQ(drm.StoredSSVal / drm.StoredSVal, topologyData.maxSubSliceCount);
EXPECT_EQ(drm.StoredEUVal / drm.StoredSSVal, topologyData.maxEuCount);
}
using HwConfigTopologyQuery = ::testing::Test;
HWTEST2_F(HwConfigTopologyQuery, WhenGettingTopologyFailsThenSetMaxValuesBasedOnEuAndSubsliceIoctlQueries, MatchAny) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->prepareRootDeviceEnvironments(1);
*executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo() = *NEO::defaultHwInfo.get();
auto drm = new DrmMock(*executionEnvironment->rootDeviceEnvironments[0]);
drm->setGtType(GTTYPE_GT1);
auto osInterface = std::make_unique<OSInterface>();
osInterface->get()->setDrm(static_cast<Drm *>(drm));
drm->failRetTopology = true;
auto hwInfo = *executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo();
HardwareInfo outHwInfo;
hwInfo.gtSystemInfo.MaxSlicesSupported = 0;
hwInfo.gtSystemInfo.MaxSubSlicesSupported = 0;
hwInfo.gtSystemInfo.MaxEuPerSubSlice = 0;
auto hwConfig = HwInfoConfigHw<productFamily>::get();
int ret = hwConfig->configureHwInfo(&hwInfo, &outHwInfo, osInterface.get());
EXPECT_NE(-1, ret);
EXPECT_EQ(outHwInfo.gtSystemInfo.EUCount / outHwInfo.gtSystemInfo.SubSliceCount, outHwInfo.gtSystemInfo.MaxEuPerSubSlice);
EXPECT_EQ(outHwInfo.gtSystemInfo.SubSliceCount, outHwInfo.gtSystemInfo.MaxSubSlicesSupported);
EXPECT_EQ(hwInfo.gtSystemInfo.SliceCount, outHwInfo.gtSystemInfo.MaxSlicesSupported);
EXPECT_EQ(static_cast<uint32_t>(drm->StoredEUVal), outHwInfo.gtSystemInfo.EUCount);
EXPECT_EQ(static_cast<uint32_t>(drm->StoredSSVal), outHwInfo.gtSystemInfo.SubSliceCount);
}