Revert "fix: initialize tile only when gt type main on xe kmd"

This reverts commit cbde47d638.

Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
Compute-Runtime-Validation 2023-10-19 07:11:43 +02:00 committed by Compute-Runtime-Automation
parent f156a74f54
commit 096e424428
3 changed files with 56 additions and 259 deletions

View File

@ -45,7 +45,7 @@ namespace NEO {
int IoctlHelperXe::xeGetQuery(Query *data) {
if (data->numItems == 1) {
QueryItem *queryItem = reinterpret_cast<QueryItem *>(data->itemsPtr);
std::vector<uint32_t> *queryData = nullptr;
std::vector<uint64_t> *queryData = nullptr;
switch (queryItem->queryId) {
case static_cast<int>(DrmParam::QueryHwconfigTable):
queryData = &hwconfigFakei915;
@ -54,7 +54,7 @@ int IoctlHelperXe::xeGetQuery(Query *data) {
xeLog("error: bad query 0x%x\n", queryItem->queryId);
return -1;
}
auto queryDataSize = static_cast<int32_t>(queryData->size() * sizeof(uint32_t));
auto queryDataSize = static_cast<int32_t>(queryData->size() * sizeof(uint64_t));
if (queryItem->length == 0) {
queryItem->length = queryDataSize;
return 0;
@ -165,8 +165,7 @@ bool IoctlHelperXe::initialize() {
memset(&queryConfig, 0, sizeof(queryConfig));
queryConfig.query = DRM_XE_DEVICE_QUERY_HWCONFIG;
IoctlHelper::ioctl(DrmIoctl::Query, &queryConfig);
auto newSize = queryConfig.size / sizeof(uint32_t);
hwconfigFakei915.resize(newSize);
hwconfigFakei915.resize(queryConfig.size);
queryConfig.data = castToUint64(hwconfigFakei915.data());
IoctlHelper::ioctl(DrmIoctl::Query, &queryConfig);
@ -292,20 +291,17 @@ std::unique_ptr<MemoryInfo> IoctlHelperXe::createMemoryInfo() {
}
for (auto i = 0u; i < xeGtsData->num_gt; i++) {
if (xeGtsData->gts[i].type == XE_QUERY_GT_TYPE_MAIN) {
uint64_t nativeMemRegions = xeGtsData->gts[i].native_mem_regions;
auto regionIndex = Math::log2(nativeMemRegions);
UNRECOVERABLE_IF(!memoryRegionInstances[regionIndex]);
regionsContainer.push_back(createMemoryRegionFromXeMemRegion(*memoryRegionInstances[regionIndex]));
uint64_t nativeMemRegions = xeGtsData->gts[i].native_mem_regions;
auto regionIndex = Math::log2(nativeMemRegions);
UNRECOVERABLE_IF(!memoryRegionInstances[regionIndex]);
regionsContainer.push_back(createMemoryRegionFromXeMemRegion(*memoryRegionInstances[regionIndex]));
xeTimestampFrequency = xeGtsData->gts[i].clock_freq;
}
xeTimestampFrequency = xeGtsData->gts[i].clock_freq;
}
return std::make_unique<MemoryInfo>(regionsContainer, drm);
}
void IoctlHelperXe::getTopologyData(size_t nTiles, std::vector<std::bitset<8>> *geomDss, std::vector<std::bitset<8>> *computeDss,
std::vector<std::bitset<8>> *euDss, DrmQueryTopologyData &topologyData, bool &isComputeDssEmpty) {
void IoctlHelperXe::getTopologyData(uint32_t nTiles, std::vector<std::bitset<8>> geomDss[2], std::vector<std::bitset<8>> computeDss[2], std::vector<std::bitset<8>> euDss[2], DrmQueryTopologyData &topologyData, bool &isComputeDssEmpty) {
int subSliceCount = 0;
int euPerDss = 0;
@ -344,7 +340,7 @@ void IoctlHelperXe::getTopologyData(size_t nTiles, std::vector<std::bitset<8>> *
topologyData.maxSliceCount = 1;
}
void IoctlHelperXe::getTopologyMap(size_t nTiles, std::vector<std::bitset<8>> *dssInfo, TopologyMap &topologyMap) {
void IoctlHelperXe::getTopologyMap(uint32_t nTiles, std::vector<std::bitset<8>> dssInfo[2], TopologyMap &topologyMap) {
for (auto tileId = 0u; tileId < nTiles; tileId++) {
std::vector<int> sliceIndices;
std::vector<int> subSliceIndices;
@ -375,49 +371,34 @@ bool IoctlHelperXe::getTopologyDataAndMap(const HardwareInfo &hwInfo, DrmQueryTo
}
};
StackVec<std::vector<std::bitset<8>>, 2> geomDss;
StackVec<std::vector<std::bitset<8>>, 2> computeDss;
StackVec<std::vector<std::bitset<8>>, 2> euDss;
StackVec<int, 2> gtIdToTile{-1};
std::vector<std::bitset<8>> geomDss[2];
std::vector<std::bitset<8>> computeDss[2];
std::vector<std::bitset<8>> euDss[2];
auto topologySize = queryGtTopology.size();
auto dataPtr = queryGtTopology.data();
auto gtsData = queryData<uint64_t>(DRM_XE_DEVICE_QUERY_GTS);
auto xeGtsData = reinterpret_cast<drm_xe_query_gts *>(gtsData.data());
gtIdToTile.resize(xeGtsData->num_gt, -1);
auto nTiles = 1u;
auto tileIndex = 0u;
for (auto gt = 0u; gt < gtIdToTile.size(); gt++) {
if (xeGtsData->gts[gt].type == XE_QUERY_GT_TYPE_MAIN) {
gtIdToTile[gt] = tileIndex++;
}
}
geomDss.resize(tileIndex);
computeDss.resize(tileIndex);
euDss.resize(tileIndex);
while (topologySize >= sizeof(drm_xe_query_topology_mask)) {
drm_xe_query_topology_mask *topo = reinterpret_cast<drm_xe_query_topology_mask *>(dataPtr);
UNRECOVERABLE_IF(topo == nullptr);
uint32_t gtId = topo->gt_id;
uint32_t tileId = topo->gt_id;
nTiles = std::max(tileId + 1, nTiles);
if (xeGtsData->gts[gtId].type == XE_QUERY_GT_TYPE_MAIN) {
switch (topo->type) {
case XE_TOPO_DSS_GEOMETRY:
fillMask(geomDss[gtIdToTile[gtId]], topo);
break;
case XE_TOPO_DSS_COMPUTE:
fillMask(computeDss[gtIdToTile[gtId]], topo);
break;
case XE_TOPO_EU_PER_DSS:
fillMask(euDss[gtIdToTile[gtId]], topo);
break;
default:
xeLog("Unhandle GT Topo type: %d\n", topo->type);
return false;
}
switch (topo->type) {
case XE_TOPO_DSS_GEOMETRY:
fillMask(geomDss[tileId], topo);
break;
case XE_TOPO_DSS_COMPUTE:
fillMask(computeDss[tileId], topo);
break;
case XE_TOPO_EU_PER_DSS:
fillMask(euDss[tileId], topo);
break;
default:
xeLog("Unhandle GT Topo type: %d\n", topo->type);
return false;
}
uint32_t itemSize = sizeof(drm_xe_query_topology_mask) + topo->num_bytes;
@ -426,10 +407,10 @@ bool IoctlHelperXe::getTopologyDataAndMap(const HardwareInfo &hwInfo, DrmQueryTo
}
bool isComputeDssEmpty = false;
getTopologyData(tileIndex, geomDss.begin(), computeDss.begin(), euDss.begin(), topologyData, isComputeDssEmpty);
getTopologyData(nTiles, geomDss, computeDss, euDss, topologyData, isComputeDssEmpty);
auto &dssInfo = isComputeDssEmpty ? geomDss : computeDss;
getTopologyMap(tileIndex, dssInfo.begin(), topologyMap);
getTopologyMap(nTiles, dssInfo, topologyMap);
return true;
}

View File

@ -105,8 +105,8 @@ class IoctlHelperXe : public IoctlHelper {
bool isWaitBeforeBindRequired(bool bind) const override;
std::unique_ptr<EngineInfo> createEngineInfo(bool isSysmanEnabled) override;
std::unique_ptr<MemoryInfo> createMemoryInfo() override;
void getTopologyData(size_t nTiles, std::vector<std::bitset<8>> *geomDss, std::vector<std::bitset<8>> *computeDss, std::vector<std::bitset<8>> *euDss, DrmQueryTopologyData &topologyData, bool &isComputeDssEmpty);
void getTopologyMap(size_t nTiles, std::vector<std::bitset<8>> *dssInfo, TopologyMap &topologyMap);
void getTopologyData(uint32_t nTiles, std::vector<std::bitset<8>> geomDss[2], std::vector<std::bitset<8>> computeDss[2], std::vector<std::bitset<8>> euDss[2], DrmQueryTopologyData &topologyData, bool &isComputeDssEmpty);
void getTopologyMap(uint32_t nTiles, std::vector<std::bitset<8>> dssInfo[2], TopologyMap &topologyMap);
void fillBindInfoForIpcHandle(uint32_t handle, size_t size) override;
bool isImmediateVmBindRequired() const override;
@ -146,7 +146,7 @@ class IoctlHelperXe : public IoctlHelper {
std::vector<BindInfo> bindInfo;
int instance = 0;
uint32_t xeTimestampFrequency = 0;
std::vector<uint32_t> hwconfigFakei915;
std::vector<uint64_t> hwconfigFakei915;
std::vector<drm_xe_engine_class_instance> contextParamEngine;
std::vector<drm_xe_engine_class_instance> allEngines;
};

View File

@ -145,8 +145,8 @@ class DrmMockXe : public DrmMockCustom {
MemoryConstants::gigaByte // used size
};
auto xeQueryGts = reinterpret_cast<drm_xe_query_gts *>(queryGts.begin());
xeQueryGts->num_gt = 3;
auto xeQueryGts = reinterpret_cast<drm_xe_query_gts *>(queryGts);
xeQueryGts->num_gt = 2;
xeQueryGts->gts[0] = {
XE_QUERY_GT_TYPE_MAIN, // type
0, // instance
@ -157,22 +157,13 @@ class DrmMockXe : public DrmMockCustom {
0 // inaccessible mem regions
};
xeQueryGts->gts[1] = {
XE_QUERY_GT_TYPE_MEDIA, // type
1, // instance
12500000, // clock freq
0, // features
0b001, // native mem regions
0x110, // slow mem regions
0 // inaccessible mem regions
};
xeQueryGts->gts[2] = {
XE_QUERY_GT_TYPE_MAIN, // type
0, // instance
12500000, // clock freq
0, // features
0b010, // native mem regions
0x101, // slow mem regions
0 // inaccessible mem regions
XE_QUERY_GT_TYPE_REMOTE, // type
1, // instance
12500000, // clock freq
0, // features
0b010, // native mem regions
0x101, // slow mem regions
0 // inaccessible mem regions
};
}
@ -259,7 +250,7 @@ class DrmMockXe : public DrmMockCustom {
break;
case DRM_XE_DEVICE_QUERY_GTS:
if (deviceQuery->data) {
memcpy_s(reinterpret_cast<void *>(deviceQuery->data), deviceQuery->size, queryGts.begin(), sizeof(queryGts));
memcpy_s(reinterpret_cast<void *>(deviceQuery->data), deviceQuery->size, queryGts, sizeof(queryGts));
}
deviceQuery->size = sizeof(queryGts);
break;
@ -336,7 +327,7 @@ class DrmMockXe : public DrmMockCustom {
static_assert(sizeof(drm_xe_query_mem_region) == 12 * sizeof(uint64_t), "");
uint64_t queryMemUsage[37]{}; // 1 qword for num regions and 12 qwords per region
static_assert(sizeof(drm_xe_query_gts::drm_xe_query_gt) == 13 * sizeof(uint64_t), "");
StackVec<uint64_t, 40> queryGts{}; // 1 qword for num gts and 13 qwords per gt
uint64_t queryGts[27]{}; // 1 qword for num gts and 13 qwords per gt
std::vector<uint8_t> queryTopology;
StackVec<drm_xe_wait_user_fence, 1> waitUserFenceInputs;
StackVec<drm_xe_vm_bind, 1> vmBindInputs;
@ -941,11 +932,11 @@ TEST(IoctlHelperXeTest, givenGeomDssWhenGetTopologyDataAndMapThenResultsAreCorre
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
uint16_t tileId = 0;
for (auto gtId = 0u; gtId < 3u; gtId++) {
drm.addMockedQueryTopologyData(gtId, XE_TOPO_DSS_GEOMETRY, 8, {0b11'1111, 0, 0, 0, 0, 0, 0, 0});
drm.addMockedQueryTopologyData(gtId, XE_TOPO_DSS_COMPUTE, 8, {0, 0, 0, 0, 0, 0, 0, 0});
drm.addMockedQueryTopologyData(gtId, XE_TOPO_EU_PER_DSS, 8, {0b1111'1111, 0b1111'1111, 0, 0, 0, 0, 0, 0});
}
drm.addMockedQueryTopologyData(tileId, XE_TOPO_DSS_GEOMETRY, 8, {0b11'1111, 0, 0, 0, 0, 0, 0, 0});
drm.addMockedQueryTopologyData(tileId, XE_TOPO_DSS_COMPUTE, 8, {0, 0, 0, 0, 0, 0, 0, 0});
drm.addMockedQueryTopologyData(tileId, XE_TOPO_EU_PER_DSS, 8, {0b1111'1111, 0b1111'1111, 0, 0, 0, 0, 0, 0});
DrmQueryTopologyData topologyData{};
TopologyMap topologyMap{};
@ -988,11 +979,9 @@ TEST(IoctlHelperXeTest, givenComputeDssWhenGetTopologyDataAndMapThenResultsAreCo
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
uint16_t tileId = 0;
for (auto gtId = 0u; gtId < 3u; gtId++) {
drm.addMockedQueryTopologyData(gtId, XE_TOPO_DSS_GEOMETRY, 8, {0, 0, 0, 0, 0, 0, 0, 0});
drm.addMockedQueryTopologyData(gtId, XE_TOPO_DSS_COMPUTE, 8, {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff});
drm.addMockedQueryTopologyData(gtId, XE_TOPO_EU_PER_DSS, 8, {0b1111'1111, 0, 0, 0, 0, 0, 0, 0});
}
drm.addMockedQueryTopologyData(tileId, XE_TOPO_DSS_GEOMETRY, 8, {0, 0, 0, 0, 0, 0, 0, 0});
drm.addMockedQueryTopologyData(tileId, XE_TOPO_DSS_COMPUTE, 8, {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff});
drm.addMockedQueryTopologyData(tileId, XE_TOPO_EU_PER_DSS, 8, {0b1111'1111, 0, 0, 0, 0, 0, 0, 0});
DrmQueryTopologyData topologyData{};
TopologyMap topologyMap{};
@ -1033,183 +1022,10 @@ TEST(IoctlHelperXeTest, givenComputeDssWhenGetTopologyDataAndMapThenResultsAreCo
}
}
TEST(IoctlHelperXeTest, givenOnlyMediaTypeWhenGetTopologyDataAndMapThenSubsliceIndicesNotSet) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]};
auto xeQueryGts = reinterpret_cast<drm_xe_query_gts *>(drm.queryGts.begin());
xeQueryGts->num_gt = 1;
xeQueryGts->gts[0] = {
XE_QUERY_GT_TYPE_MEDIA, // type
0, // instance
12500000, // clock freq
0, // features
0b100, // native mem regions
0x011, // slow mem regions
0 // inaccessible mem regions
};
auto &hwInfo = *executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo();
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
uint16_t tileId = 0;
drm.addMockedQueryTopologyData(tileId, XE_TOPO_DSS_GEOMETRY, 8, {0, 0, 0, 0, 0, 0, 0, 0});
drm.addMockedQueryTopologyData(tileId, XE_TOPO_DSS_COMPUTE, 8, {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff});
drm.addMockedQueryTopologyData(tileId, XE_TOPO_EU_PER_DSS, 8, {0b1111'1111, 0, 0, 0, 0, 0, 0, 0});
DrmQueryTopologyData topologyData{};
TopologyMap topologyMap{};
auto result = xeIoctlHelper->getTopologyDataAndMap(hwInfo, topologyData, topologyMap);
ASSERT_TRUE(result);
// verify topology data
EXPECT_EQ(1, topologyData.sliceCount);
EXPECT_EQ(1, topologyData.maxSliceCount);
EXPECT_EQ(0, topologyData.subSliceCount);
EXPECT_EQ(0, topologyData.maxSubSliceCount);
EXPECT_EQ(0, topologyData.euCount);
EXPECT_EQ(0, topologyData.maxEuPerSubSlice);
// verify topology map
ASSERT_EQ(0u, topologyMap[tileId].sliceIndices.size());
ASSERT_EQ(0u, topologyMap[tileId].subsliceIndices.size());
}
TEST(IoctlHelperXeTest, givenMainAndMediaTypesWhenGetTopologyDataAndMapThenResultsAreCorrect) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]};
drm.queryGts.resize(53);
auto xeQueryGts = reinterpret_cast<drm_xe_query_gts *>(drm.queryGts.begin());
xeQueryGts->num_gt = 4;
xeQueryGts->gts[0] = {
XE_QUERY_GT_TYPE_MAIN, // type
0, // instance
12500000, // clock freq
0, // features
0b100, // native mem regions
0x011, // slow mem regions
0 // inaccessible mem regions
};
xeQueryGts->gts[1] = {
XE_QUERY_GT_TYPE_MEDIA, // type
0, // instance
12500000, // clock freq
0, // features
0b100, // native mem regions
0x011, // slow mem regions
0 // inaccessible mem regions
};
xeQueryGts->gts[2] = {
XE_QUERY_GT_TYPE_MAIN, // type
0, // instance
12500000, // clock freq
0, // features
0b010, // native mem regions
0x101, // slow mem regions
0 // inaccessible mem regions
};
xeQueryGts->gts[3] = {
XE_QUERY_GT_TYPE_MEDIA, // type
0, // instance
12500000, // clock freq
0, // features
0b001, // native mem regions
0x100, // slow mem regions
0 // inaccessible mem regions
};
auto &hwInfo = *executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo();
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
for (auto tileId = 0; tileId < 4; tileId++) {
drm.addMockedQueryTopologyData(tileId, XE_TOPO_DSS_GEOMETRY, 8, {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff});
drm.addMockedQueryTopologyData(tileId, XE_TOPO_DSS_COMPUTE, 8, {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff});
drm.addMockedQueryTopologyData(tileId, XE_TOPO_EU_PER_DSS, 8, {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff});
}
DrmQueryTopologyData topologyData{};
TopologyMap topologyMap{};
auto result = xeIoctlHelper->getTopologyDataAndMap(hwInfo, topologyData, topologyMap);
ASSERT_TRUE(result);
// verify topology data
EXPECT_EQ(1, topologyData.sliceCount);
EXPECT_EQ(1, topologyData.maxSliceCount);
EXPECT_EQ(64, topologyData.subSliceCount);
EXPECT_EQ(64, topologyData.maxSubSliceCount);
EXPECT_EQ(4096, topologyData.euCount);
EXPECT_EQ(64, topologyData.maxEuPerSubSlice);
EXPECT_EQ(2u, topologyMap.size());
// verify topology map
for (auto tileId : {0u, 1u}) {
ASSERT_EQ(1u, topologyMap[tileId].sliceIndices.size());
ASSERT_EQ(64u, topologyMap[tileId].subsliceIndices.size());
}
}
struct DrmMockXe2T : public DrmMockXe {
DrmMockXe2T(RootDeviceEnvironment &rootDeviceEnvironment) : DrmMockXe(rootDeviceEnvironment) {
auto xeQueryMemUsage = reinterpret_cast<drm_xe_query_mem_usage *>(queryMemUsage);
xeQueryMemUsage->num_regions = 3;
xeQueryMemUsage->regions[0] = {
XE_MEM_REGION_CLASS_VRAM, // class
1, // instance
0, // padding
MemoryConstants::pageSize, // min page size
2 * MemoryConstants::gigaByte, // total size
MemoryConstants::megaByte // used size
};
xeQueryMemUsage->regions[1] = {
XE_MEM_REGION_CLASS_SYSMEM, // class
0, // instance
0, // padding
MemoryConstants::pageSize, // min page size
MemoryConstants::gigaByte, // total size
MemoryConstants::kiloByte // used size
};
xeQueryMemUsage->regions[2] = {
XE_MEM_REGION_CLASS_VRAM, // class
2, // instance
0, // padding
MemoryConstants::pageSize, // min page size
4 * MemoryConstants::gigaByte, // total size
MemoryConstants::gigaByte // used size
};
queryGts.resize(27);
auto xeQueryGts = reinterpret_cast<drm_xe_query_gts *>(queryGts.begin());
xeQueryGts->num_gt = 2;
xeQueryGts->gts[0] = {
XE_QUERY_GT_TYPE_MAIN, // type
0, // instance
12500000, // clock freq
0, // features
0b100, // native mem regions
0x011, // slow mem regions
0 // inaccessible mem regions
};
xeQueryGts->gts[1] = {
XE_QUERY_GT_TYPE_MAIN, // type
0, // instance
12500000, // clock freq
0, // features
0b010, // native mem regions
0x101, // slow mem regions
0 // inaccessible mem regions
};
}
};
TEST(IoctlHelperXeTest, given2TileAndComputeDssWhenGetTopologyDataAndMapThenResultsAreCorrect) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmMockXe2T drm{*executionEnvironment->rootDeviceEnvironments[0]};
DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]};
auto &hwInfo = *executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo();
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
@ -1264,7 +1080,7 @@ TEST(IoctlHelperXeTest, given2TileAndComputeDssWhenGetTopologyDataAndMapThenResu
TEST(IoctlHelperXeTest, given2TileWithDisabledDssOn1TileAndComputeDssWhenGetTopologyDataAndMapThenResultsAreCorrect) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmMockXe2T drm{*executionEnvironment->rootDeviceEnvironments[0]};
DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]};
auto &hwInfo = *executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo();
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
@ -1330,7 +1146,7 @@ TEST(IoctlHelperXeTest, given2TileWithDisabledDssOn1TileAndComputeDssWhenGetTopo
TEST(IoctlHelperXeTest, given2TileWithDisabledEvenDssAndComputeDssWhenGetTopologyDataAndMapThenResultsAreCorrect) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmMockXe2T drm{*executionEnvironment->rootDeviceEnvironments[0]};
DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]};
auto &hwInfo = *executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo();
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);