mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-22 01:48:50 +08:00
Refactor Drm::queryTopology() to take struct
Related-To: NEO-5640 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
495841812f
commit
f83b51e628
@@ -301,8 +301,8 @@ TEST_F(HwInfoConfigTestLinuxDummy, givenInvalidTopologyDataWhenConfiguringThenRe
|
|||||||
drm->StoredSSVal = storedSSVal;
|
drm->StoredSSVal = storedSSVal;
|
||||||
drm->StoredEUVal = 0;
|
drm->StoredEUVal = 0;
|
||||||
|
|
||||||
int sliceCount, subSliceCount, euCount;
|
Drm::QueryTopologyData topologyData = {};
|
||||||
EXPECT_FALSE(drm->queryTopology(outHwInfo, sliceCount, subSliceCount, euCount));
|
EXPECT_FALSE(drm->queryTopology(outHwInfo, topologyData));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -311,8 +311,8 @@ TEST_F(HwInfoConfigTestLinuxDummy, givenInvalidTopologyDataWhenConfiguringThenRe
|
|||||||
drm->StoredSSVal = 0;
|
drm->StoredSSVal = 0;
|
||||||
drm->StoredEUVal = storedEUVal;
|
drm->StoredEUVal = storedEUVal;
|
||||||
|
|
||||||
int sliceCount, subSliceCount, euCount;
|
Drm::QueryTopologyData topologyData = {};
|
||||||
EXPECT_FALSE(drm->queryTopology(outHwInfo, sliceCount, subSliceCount, euCount));
|
EXPECT_FALSE(drm->queryTopology(outHwInfo, topologyData));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -321,8 +321,8 @@ TEST_F(HwInfoConfigTestLinuxDummy, givenInvalidTopologyDataWhenConfiguringThenRe
|
|||||||
drm->StoredSSVal = storedSSVal;
|
drm->StoredSSVal = storedSSVal;
|
||||||
drm->StoredEUVal = storedEUVal;
|
drm->StoredEUVal = storedEUVal;
|
||||||
|
|
||||||
int sliceCount, subSliceCount, euCount;
|
Drm::QueryTopologyData topologyData = {};
|
||||||
EXPECT_FALSE(drm->queryTopology(outHwInfo, sliceCount, subSliceCount, euCount));
|
EXPECT_FALSE(drm->queryTopology(outHwInfo, topologyData));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -307,33 +307,40 @@ int Drm::getErrno() {
|
|||||||
int Drm::setupHardwareInfo(DeviceDescriptor *device, bool setupFeatureTableAndWorkaroundTable) {
|
int Drm::setupHardwareInfo(DeviceDescriptor *device, bool setupFeatureTableAndWorkaroundTable) {
|
||||||
HardwareInfo *hwInfo = const_cast<HardwareInfo *>(device->pHwInfo);
|
HardwareInfo *hwInfo = const_cast<HardwareInfo *>(device->pHwInfo);
|
||||||
int ret;
|
int ret;
|
||||||
int sliceTotal;
|
|
||||||
int subSliceTotal;
|
|
||||||
int euTotal;
|
|
||||||
|
|
||||||
bool status = queryTopology(*hwInfo, sliceTotal, subSliceTotal, euTotal);
|
Drm::QueryTopologyData topologyData = {};
|
||||||
|
|
||||||
|
bool status = queryTopology(*hwInfo, topologyData);
|
||||||
|
|
||||||
if (!status) {
|
if (!status) {
|
||||||
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Topology query failed!\n");
|
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Topology query failed!\n");
|
||||||
|
|
||||||
sliceTotal = hwInfo->gtSystemInfo.SliceCount;
|
topologyData.sliceCount = hwInfo->gtSystemInfo.SliceCount;
|
||||||
|
|
||||||
ret = getEuTotal(euTotal);
|
ret = getEuTotal(topologyData.euCount);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query EU total parameter!\n");
|
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query EU total parameter!\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = getSubsliceTotal(subSliceTotal);
|
ret = getSubsliceTotal(topologyData.subSliceCount);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query subslice total parameter!\n");
|
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query subslice total parameter!\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
topologyData.maxEuCount = topologyData.euCount;
|
||||||
|
topologyData.maxSliceCount = topologyData.sliceCount;
|
||||||
|
topologyData.maxSubSliceCount = topologyData.subSliceCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
hwInfo->gtSystemInfo.SliceCount = static_cast<uint32_t>(sliceTotal);
|
hwInfo->gtSystemInfo.SliceCount = static_cast<uint32_t>(topologyData.sliceCount);
|
||||||
hwInfo->gtSystemInfo.SubSliceCount = static_cast<uint32_t>(subSliceTotal);
|
hwInfo->gtSystemInfo.SubSliceCount = static_cast<uint32_t>(topologyData.subSliceCount);
|
||||||
hwInfo->gtSystemInfo.EUCount = static_cast<uint32_t>(euTotal);
|
hwInfo->gtSystemInfo.EUCount = static_cast<uint32_t>(topologyData.euCount);
|
||||||
|
|
||||||
|
hwInfo->gtSystemInfo.MaxSubSlicesSupported = topologyData.maxSubSliceCount;
|
||||||
|
hwInfo->gtSystemInfo.MaxDualSubSlicesSupported = topologyData.maxSubSliceCount;
|
||||||
|
hwInfo->gtSystemInfo.MaxSlicesSupported = topologyData.maxSliceCount;
|
||||||
|
|
||||||
status = querySystemInfo();
|
status = querySystemInfo();
|
||||||
if (!status) {
|
if (!status) {
|
||||||
|
|||||||
@@ -65,6 +65,16 @@ class Drm {
|
|||||||
MaxSize
|
MaxSize
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct QueryTopologyData {
|
||||||
|
int sliceCount;
|
||||||
|
int subSliceCount;
|
||||||
|
int euCount;
|
||||||
|
|
||||||
|
int maxSliceCount;
|
||||||
|
int maxSubSliceCount;
|
||||||
|
int maxEuCount;
|
||||||
|
};
|
||||||
|
|
||||||
virtual ~Drm();
|
virtual ~Drm();
|
||||||
|
|
||||||
virtual int ioctl(unsigned long request, void *arg);
|
virtual int ioctl(unsigned long request, void *arg);
|
||||||
@@ -104,7 +114,7 @@ class Drm {
|
|||||||
MOCKABLE_VIRTUAL bool querySystemInfo();
|
MOCKABLE_VIRTUAL bool querySystemInfo();
|
||||||
MOCKABLE_VIRTUAL bool queryEngineInfo();
|
MOCKABLE_VIRTUAL bool queryEngineInfo();
|
||||||
MOCKABLE_VIRTUAL bool queryMemoryInfo();
|
MOCKABLE_VIRTUAL bool queryMemoryInfo();
|
||||||
bool queryTopology(const HardwareInfo &hwInfo, int &sliceCount, int &subSliceCount, int &euCount);
|
bool queryTopology(const HardwareInfo &hwInfo, QueryTopologyData &data);
|
||||||
bool createVirtualMemoryAddressSpace(uint32_t vmCount);
|
bool createVirtualMemoryAddressSpace(uint32_t vmCount);
|
||||||
void destroyVirtualMemoryAddressSpace();
|
void destroyVirtualMemoryAddressSpace();
|
||||||
uint32_t getVirtualMemoryAddressSpace(uint32_t vmId);
|
uint32_t getVirtualMemoryAddressSpace(uint32_t vmId);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
|
|
||||||
bool Drm::queryTopology(const HardwareInfo &hwInfo, int &sliceCount, int &subSliceCount, int &euCount) {
|
bool Drm::queryTopology(const HardwareInfo &hwInfo, QueryTopologyData &topologyData) {
|
||||||
int32_t length;
|
int32_t length;
|
||||||
auto dataQuery = this->query(DRM_I915_QUERY_TOPOLOGY_INFO, DrmQueryItemFlags::topology, length);
|
auto dataQuery = this->query(DRM_I915_QUERY_TOPOLOGY_INFO, DrmQueryItemFlags::topology, length);
|
||||||
auto data = reinterpret_cast<drm_i915_query_topology_info *>(dataQuery.get());
|
auto data = reinterpret_cast<drm_i915_query_topology_info *>(dataQuery.get());
|
||||||
@@ -20,7 +20,11 @@ bool Drm::queryTopology(const HardwareInfo &hwInfo, int &sliceCount, int &subSli
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return translateTopologyInfo(data, sliceCount, subSliceCount, euCount);
|
topologyData.maxSliceCount = data->max_slices;
|
||||||
|
topologyData.maxSubSliceCount = data->max_subslices;
|
||||||
|
topologyData.maxEuCount = data->max_eus_per_subslice;
|
||||||
|
|
||||||
|
return translateTopologyInfo(data, topologyData.sliceCount, topologyData.subSliceCount, topologyData.euCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Drm::isDebugAttachAvailable() {
|
bool Drm::isDebugAttachAvailable() {
|
||||||
|
|||||||
@@ -90,37 +90,43 @@ int HwInfoConfig::configureHwInfo(const HardwareInfo *inHwInfo, HardwareInfo *ou
|
|||||||
}
|
}
|
||||||
platform->usRevId = static_cast<unsigned short>(val);
|
platform->usRevId = static_cast<unsigned short>(val);
|
||||||
|
|
||||||
int sliceCount;
|
Drm::QueryTopologyData topologyData = {};
|
||||||
int subSliceCount;
|
|
||||||
int euCount;
|
|
||||||
|
|
||||||
bool status = drm->queryTopology(*outHwInfo, sliceCount, subSliceCount, euCount);
|
bool status = drm->queryTopology(*outHwInfo, topologyData);
|
||||||
|
|
||||||
if (!status) {
|
if (!status) {
|
||||||
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Topology query failed!\n");
|
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Topology query failed!\n");
|
||||||
|
|
||||||
sliceCount = gtSystemInfo->SliceCount;
|
topologyData.sliceCount = gtSystemInfo->SliceCount;
|
||||||
|
|
||||||
ret = drm->getEuTotal(euCount);
|
ret = drm->getEuTotal(topologyData.euCount);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query EU total parameter!\n");
|
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query EU total parameter!\n");
|
||||||
*outHwInfo = {};
|
*outHwInfo = {};
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = drm->getSubsliceTotal(subSliceCount);
|
ret = drm->getSubsliceTotal(topologyData.subSliceCount);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query subslice total parameter!\n");
|
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "FATAL: Cannot query subslice total parameter!\n");
|
||||||
*outHwInfo = {};
|
*outHwInfo = {};
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
topologyData.maxEuCount = topologyData.euCount / topologyData.subSliceCount;
|
||||||
|
topologyData.maxSliceCount = topologyData.sliceCount;
|
||||||
|
topologyData.maxSubSliceCount = topologyData.subSliceCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtSystemInfo->SliceCount = static_cast<uint32_t>(sliceCount);
|
gtSystemInfo->SliceCount = static_cast<uint32_t>(topologyData.sliceCount);
|
||||||
gtSystemInfo->SubSliceCount = static_cast<uint32_t>(subSliceCount);
|
gtSystemInfo->SubSliceCount = static_cast<uint32_t>(topologyData.subSliceCount);
|
||||||
gtSystemInfo->EUCount = static_cast<uint32_t>(euCount);
|
gtSystemInfo->EUCount = static_cast<uint32_t>(topologyData.euCount);
|
||||||
gtSystemInfo->ThreadCount = this->threadsPerEu * gtSystemInfo->EUCount;
|
gtSystemInfo->ThreadCount = this->threadsPerEu * gtSystemInfo->EUCount;
|
||||||
|
|
||||||
|
gtSystemInfo->MaxEuPerSubSlice = topologyData.maxEuCount;
|
||||||
|
gtSystemInfo->MaxSubSlicesSupported = topologyData.maxSubSliceCount;
|
||||||
|
gtSystemInfo->MaxSlicesSupported = topologyData.maxSliceCount;
|
||||||
|
|
||||||
uint64_t gttSizeQuery = 0;
|
uint64_t gttSizeQuery = 0;
|
||||||
featureTable->ftrSVM = true;
|
featureTable->ftrSVM = true;
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,12 @@
|
|||||||
|
|
||||||
#include "shared/source/helpers/file_io.h"
|
#include "shared/source/helpers/file_io.h"
|
||||||
#include "shared/source/helpers/hw_info.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 "shared/test/common/helpers/default_hw_info.h"
|
||||||
|
|
||||||
#include "opencl/test/unit_test/os_interface/linux/drm_mock.h"
|
#include "opencl/test/unit_test/os_interface/linux/drm_mock.h"
|
||||||
|
#include "test.h"
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
@@ -43,3 +46,53 @@ TEST(DrmQueryTest, WhenCallingIsDebugAttachAvailableThenReturnValueIsFalse) {
|
|||||||
|
|
||||||
EXPECT_FALSE(drm.isDebugAttachAvailable());
|
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;
|
||||||
|
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);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user