mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-06 19:20:51 +08:00
fix: when gt type media on xe kmd then do not inizialize
also use proper size when query config Related-To: HSD-18034189281 Signed-off-by: Katarzyna Cencelewska <katarzyna.cencelewska@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
456f07212d
commit
ff1a8770fe
@@ -45,7 +45,7 @@ namespace NEO {
|
|||||||
int IoctlHelperXe::xeGetQuery(Query *data) {
|
int IoctlHelperXe::xeGetQuery(Query *data) {
|
||||||
if (data->numItems == 1) {
|
if (data->numItems == 1) {
|
||||||
QueryItem *queryItem = reinterpret_cast<QueryItem *>(data->itemsPtr);
|
QueryItem *queryItem = reinterpret_cast<QueryItem *>(data->itemsPtr);
|
||||||
std::vector<uint64_t> *queryData = nullptr;
|
std::vector<uint32_t> *queryData = nullptr;
|
||||||
switch (queryItem->queryId) {
|
switch (queryItem->queryId) {
|
||||||
case static_cast<int>(DrmParam::QueryHwconfigTable):
|
case static_cast<int>(DrmParam::QueryHwconfigTable):
|
||||||
queryData = &hwconfigFakei915;
|
queryData = &hwconfigFakei915;
|
||||||
@@ -54,7 +54,7 @@ int IoctlHelperXe::xeGetQuery(Query *data) {
|
|||||||
xeLog("error: bad query 0x%x\n", queryItem->queryId);
|
xeLog("error: bad query 0x%x\n", queryItem->queryId);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
auto queryDataSize = static_cast<int32_t>(queryData->size() * sizeof(uint64_t));
|
auto queryDataSize = static_cast<int32_t>(queryData->size() * sizeof(uint32_t));
|
||||||
if (queryItem->length == 0) {
|
if (queryItem->length == 0) {
|
||||||
queryItem->length = queryDataSize;
|
queryItem->length = queryDataSize;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -165,7 +165,8 @@ bool IoctlHelperXe::initialize() {
|
|||||||
memset(&queryConfig, 0, sizeof(queryConfig));
|
memset(&queryConfig, 0, sizeof(queryConfig));
|
||||||
queryConfig.query = DRM_XE_DEVICE_QUERY_HWCONFIG;
|
queryConfig.query = DRM_XE_DEVICE_QUERY_HWCONFIG;
|
||||||
IoctlHelper::ioctl(DrmIoctl::Query, &queryConfig);
|
IoctlHelper::ioctl(DrmIoctl::Query, &queryConfig);
|
||||||
hwconfigFakei915.resize(queryConfig.size);
|
auto newSize = queryConfig.size / sizeof(uint32_t);
|
||||||
|
hwconfigFakei915.resize(newSize);
|
||||||
queryConfig.data = castToUint64(hwconfigFakei915.data());
|
queryConfig.data = castToUint64(hwconfigFakei915.data());
|
||||||
IoctlHelper::ioctl(DrmIoctl::Query, &queryConfig);
|
IoctlHelper::ioctl(DrmIoctl::Query, &queryConfig);
|
||||||
|
|
||||||
@@ -291,17 +292,20 @@ std::unique_ptr<MemoryInfo> IoctlHelperXe::createMemoryInfo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (auto i = 0u; i < xeGtsData->num_gt; i++) {
|
for (auto i = 0u; i < xeGtsData->num_gt; i++) {
|
||||||
uint64_t nativeMemRegions = xeGtsData->gts[i].native_mem_regions;
|
if (xeGtsData->gts[i].type != XE_QUERY_GT_TYPE_MEDIA) {
|
||||||
auto regionIndex = Math::log2(nativeMemRegions);
|
uint64_t nativeMemRegions = xeGtsData->gts[i].native_mem_regions;
|
||||||
UNRECOVERABLE_IF(!memoryRegionInstances[regionIndex]);
|
auto regionIndex = Math::log2(nativeMemRegions);
|
||||||
regionsContainer.push_back(createMemoryRegionFromXeMemRegion(*memoryRegionInstances[regionIndex]));
|
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);
|
return std::make_unique<MemoryInfo>(regionsContainer, drm);
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
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) {
|
||||||
int subSliceCount = 0;
|
int subSliceCount = 0;
|
||||||
int euPerDss = 0;
|
int euPerDss = 0;
|
||||||
|
|
||||||
@@ -340,7 +344,7 @@ void IoctlHelperXe::getTopologyData(uint32_t nTiles, std::vector<std::bitset<8>>
|
|||||||
topologyData.maxSliceCount = 1;
|
topologyData.maxSliceCount = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IoctlHelperXe::getTopologyMap(uint32_t nTiles, std::vector<std::bitset<8>> dssInfo[2], TopologyMap &topologyMap) {
|
void IoctlHelperXe::getTopologyMap(size_t nTiles, std::vector<std::bitset<8>> *dssInfo, TopologyMap &topologyMap) {
|
||||||
for (auto tileId = 0u; tileId < nTiles; tileId++) {
|
for (auto tileId = 0u; tileId < nTiles; tileId++) {
|
||||||
std::vector<int> sliceIndices;
|
std::vector<int> sliceIndices;
|
||||||
std::vector<int> subSliceIndices;
|
std::vector<int> subSliceIndices;
|
||||||
@@ -371,34 +375,49 @@ bool IoctlHelperXe::getTopologyDataAndMap(const HardwareInfo &hwInfo, DrmQueryTo
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<std::bitset<8>> geomDss[2];
|
StackVec<std::vector<std::bitset<8>>, 2> geomDss;
|
||||||
std::vector<std::bitset<8>> computeDss[2];
|
StackVec<std::vector<std::bitset<8>>, 2> computeDss;
|
||||||
std::vector<std::bitset<8>> euDss[2];
|
StackVec<std::vector<std::bitset<8>>, 2> euDss;
|
||||||
|
StackVec<int, 2> gtIdToTile{-1};
|
||||||
|
|
||||||
auto topologySize = queryGtTopology.size();
|
auto topologySize = queryGtTopology.size();
|
||||||
auto dataPtr = queryGtTopology.data();
|
auto dataPtr = queryGtTopology.data();
|
||||||
|
|
||||||
auto nTiles = 1u;
|
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 tileIndex = 0u;
|
||||||
|
for (auto gt = 0u; gt < gtIdToTile.size(); gt++) {
|
||||||
|
if (xeGtsData->gts[gt].type != XE_QUERY_GT_TYPE_MEDIA) {
|
||||||
|
gtIdToTile[gt] = tileIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
geomDss.resize(tileIndex);
|
||||||
|
computeDss.resize(tileIndex);
|
||||||
|
euDss.resize(tileIndex);
|
||||||
while (topologySize >= sizeof(drm_xe_query_topology_mask)) {
|
while (topologySize >= sizeof(drm_xe_query_topology_mask)) {
|
||||||
drm_xe_query_topology_mask *topo = reinterpret_cast<drm_xe_query_topology_mask *>(dataPtr);
|
drm_xe_query_topology_mask *topo = reinterpret_cast<drm_xe_query_topology_mask *>(dataPtr);
|
||||||
UNRECOVERABLE_IF(topo == nullptr);
|
UNRECOVERABLE_IF(topo == nullptr);
|
||||||
|
|
||||||
uint32_t tileId = topo->gt_id;
|
uint32_t gtId = topo->gt_id;
|
||||||
nTiles = std::max(tileId + 1, nTiles);
|
|
||||||
|
|
||||||
switch (topo->type) {
|
if (xeGtsData->gts[gtId].type != XE_QUERY_GT_TYPE_MEDIA) {
|
||||||
case XE_TOPO_DSS_GEOMETRY:
|
switch (topo->type) {
|
||||||
fillMask(geomDss[tileId], topo);
|
case XE_TOPO_DSS_GEOMETRY:
|
||||||
break;
|
fillMask(geomDss[gtIdToTile[gtId]], topo);
|
||||||
case XE_TOPO_DSS_COMPUTE:
|
break;
|
||||||
fillMask(computeDss[tileId], topo);
|
case XE_TOPO_DSS_COMPUTE:
|
||||||
break;
|
fillMask(computeDss[gtIdToTile[gtId]], topo);
|
||||||
case XE_TOPO_EU_PER_DSS:
|
break;
|
||||||
fillMask(euDss[tileId], topo);
|
case XE_TOPO_EU_PER_DSS:
|
||||||
break;
|
fillMask(euDss[gtIdToTile[gtId]], topo);
|
||||||
default:
|
break;
|
||||||
xeLog("Unhandle GT Topo type: %d\n", topo->type);
|
default:
|
||||||
return false;
|
xeLog("Unhandle GT Topo type: %d\n", topo->type);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t itemSize = sizeof(drm_xe_query_topology_mask) + topo->num_bytes;
|
uint32_t itemSize = sizeof(drm_xe_query_topology_mask) + topo->num_bytes;
|
||||||
@@ -407,10 +426,10 @@ bool IoctlHelperXe::getTopologyDataAndMap(const HardwareInfo &hwInfo, DrmQueryTo
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool isComputeDssEmpty = false;
|
bool isComputeDssEmpty = false;
|
||||||
getTopologyData(nTiles, geomDss, computeDss, euDss, topologyData, isComputeDssEmpty);
|
getTopologyData(tileIndex, geomDss.begin(), computeDss.begin(), euDss.begin(), topologyData, isComputeDssEmpty);
|
||||||
|
|
||||||
auto &dssInfo = isComputeDssEmpty ? geomDss : computeDss;
|
auto &dssInfo = isComputeDssEmpty ? geomDss : computeDss;
|
||||||
getTopologyMap(nTiles, dssInfo, topologyMap);
|
getTopologyMap(tileIndex, dssInfo.begin(), topologyMap);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,8 +105,8 @@ class IoctlHelperXe : public IoctlHelper {
|
|||||||
bool isWaitBeforeBindRequired(bool bind) const override;
|
bool isWaitBeforeBindRequired(bool bind) const override;
|
||||||
std::unique_ptr<EngineInfo> createEngineInfo(bool isSysmanEnabled) override;
|
std::unique_ptr<EngineInfo> createEngineInfo(bool isSysmanEnabled) override;
|
||||||
std::unique_ptr<MemoryInfo> createMemoryInfo() override;
|
std::unique_ptr<MemoryInfo> createMemoryInfo() override;
|
||||||
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 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(uint32_t nTiles, std::vector<std::bitset<8>> dssInfo[2], TopologyMap &topologyMap);
|
void getTopologyMap(size_t nTiles, std::vector<std::bitset<8>> *dssInfo, TopologyMap &topologyMap);
|
||||||
void fillBindInfoForIpcHandle(uint32_t handle, size_t size) override;
|
void fillBindInfoForIpcHandle(uint32_t handle, size_t size) override;
|
||||||
bool isImmediateVmBindRequired() const override;
|
bool isImmediateVmBindRequired() const override;
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ class IoctlHelperXe : public IoctlHelper {
|
|||||||
std::vector<BindInfo> bindInfo;
|
std::vector<BindInfo> bindInfo;
|
||||||
int instance = 0;
|
int instance = 0;
|
||||||
uint32_t xeTimestampFrequency = 0;
|
uint32_t xeTimestampFrequency = 0;
|
||||||
std::vector<uint64_t> hwconfigFakei915;
|
std::vector<uint32_t> hwconfigFakei915;
|
||||||
std::vector<drm_xe_engine_class_instance> contextParamEngine;
|
std::vector<drm_xe_engine_class_instance> contextParamEngine;
|
||||||
std::vector<drm_xe_engine_class_instance> allEngines;
|
std::vector<drm_xe_engine_class_instance> allEngines;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -145,8 +145,8 @@ class DrmMockXe : public DrmMockCustom {
|
|||||||
MemoryConstants::gigaByte // used size
|
MemoryConstants::gigaByte // used size
|
||||||
};
|
};
|
||||||
|
|
||||||
auto xeQueryGts = reinterpret_cast<drm_xe_query_gts *>(queryGts);
|
auto xeQueryGts = reinterpret_cast<drm_xe_query_gts *>(queryGts.begin());
|
||||||
xeQueryGts->num_gt = 2;
|
xeQueryGts->num_gt = 3;
|
||||||
xeQueryGts->gts[0] = {
|
xeQueryGts->gts[0] = {
|
||||||
XE_QUERY_GT_TYPE_MAIN, // type
|
XE_QUERY_GT_TYPE_MAIN, // type
|
||||||
0, // instance
|
0, // instance
|
||||||
@@ -157,13 +157,22 @@ class DrmMockXe : public DrmMockCustom {
|
|||||||
0 // inaccessible mem regions
|
0 // inaccessible mem regions
|
||||||
};
|
};
|
||||||
xeQueryGts->gts[1] = {
|
xeQueryGts->gts[1] = {
|
||||||
XE_QUERY_GT_TYPE_REMOTE, // type
|
XE_QUERY_GT_TYPE_MEDIA, // type
|
||||||
1, // instance
|
1, // instance
|
||||||
12500000, // clock freq
|
12500000, // clock freq
|
||||||
0, // features
|
0, // features
|
||||||
0b010, // native mem regions
|
0b001, // native mem regions
|
||||||
0x101, // slow mem regions
|
0x110, // slow mem regions
|
||||||
0 // inaccessible 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
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,7 +259,7 @@ class DrmMockXe : public DrmMockCustom {
|
|||||||
break;
|
break;
|
||||||
case DRM_XE_DEVICE_QUERY_GTS:
|
case DRM_XE_DEVICE_QUERY_GTS:
|
||||||
if (deviceQuery->data) {
|
if (deviceQuery->data) {
|
||||||
memcpy_s(reinterpret_cast<void *>(deviceQuery->data), deviceQuery->size, queryGts, sizeof(queryGts));
|
memcpy_s(reinterpret_cast<void *>(deviceQuery->data), deviceQuery->size, queryGts.begin(), sizeof(queryGts));
|
||||||
}
|
}
|
||||||
deviceQuery->size = sizeof(queryGts);
|
deviceQuery->size = sizeof(queryGts);
|
||||||
break;
|
break;
|
||||||
@@ -327,7 +336,7 @@ class DrmMockXe : public DrmMockCustom {
|
|||||||
static_assert(sizeof(drm_xe_query_mem_region) == 12 * sizeof(uint64_t), "");
|
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
|
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), "");
|
static_assert(sizeof(drm_xe_query_gts::drm_xe_query_gt) == 13 * sizeof(uint64_t), "");
|
||||||
uint64_t queryGts[27]{}; // 1 qword for num gts and 13 qwords per gt
|
StackVec<uint64_t, 40> queryGts{}; // 1 qword for num gts and 13 qwords per gt
|
||||||
std::vector<uint8_t> queryTopology;
|
std::vector<uint8_t> queryTopology;
|
||||||
StackVec<drm_xe_wait_user_fence, 1> waitUserFenceInputs;
|
StackVec<drm_xe_wait_user_fence, 1> waitUserFenceInputs;
|
||||||
StackVec<drm_xe_vm_bind, 1> vmBindInputs;
|
StackVec<drm_xe_vm_bind, 1> vmBindInputs;
|
||||||
@@ -932,11 +941,11 @@ TEST(IoctlHelperXeTest, givenGeomDssWhenGetTopologyDataAndMapThenResultsAreCorre
|
|||||||
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
|
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
|
||||||
|
|
||||||
uint16_t tileId = 0;
|
uint16_t tileId = 0;
|
||||||
|
for (auto gtId = 0u; gtId < 3u; gtId++) {
|
||||||
drm.addMockedQueryTopologyData(tileId, XE_TOPO_DSS_GEOMETRY, 8, {0b11'1111, 0, 0, 0, 0, 0, 0, 0});
|
drm.addMockedQueryTopologyData(gtId, 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(gtId, 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});
|
drm.addMockedQueryTopologyData(gtId, XE_TOPO_EU_PER_DSS, 8, {0b1111'1111, 0b1111'1111, 0, 0, 0, 0, 0, 0});
|
||||||
|
}
|
||||||
DrmQueryTopologyData topologyData{};
|
DrmQueryTopologyData topologyData{};
|
||||||
TopologyMap topologyMap{};
|
TopologyMap topologyMap{};
|
||||||
|
|
||||||
@@ -979,9 +988,11 @@ TEST(IoctlHelperXeTest, givenComputeDssWhenGetTopologyDataAndMapThenResultsAreCo
|
|||||||
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
|
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
|
||||||
|
|
||||||
uint16_t tileId = 0;
|
uint16_t tileId = 0;
|
||||||
drm.addMockedQueryTopologyData(tileId, XE_TOPO_DSS_GEOMETRY, 8, {0, 0, 0, 0, 0, 0, 0, 0});
|
for (auto gtId = 0u; gtId < 3u; gtId++) {
|
||||||
drm.addMockedQueryTopologyData(tileId, XE_TOPO_DSS_COMPUTE, 8, {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff});
|
drm.addMockedQueryTopologyData(gtId, XE_TOPO_DSS_GEOMETRY, 8, {0, 0, 0, 0, 0, 0, 0, 0});
|
||||||
drm.addMockedQueryTopologyData(tileId, XE_TOPO_EU_PER_DSS, 8, {0b1111'1111, 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});
|
||||||
|
}
|
||||||
|
|
||||||
DrmQueryTopologyData topologyData{};
|
DrmQueryTopologyData topologyData{};
|
||||||
TopologyMap topologyMap{};
|
TopologyMap topologyMap{};
|
||||||
@@ -1022,10 +1033,183 @@ TEST(IoctlHelperXeTest, givenComputeDssWhenGetTopologyDataAndMapThenResultsAreCo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(IoctlHelperXeTest, given2TileAndComputeDssWhenGetTopologyDataAndMapThenResultsAreCorrect) {
|
TEST(IoctlHelperXeTest, givenOnlyMediaTypeWhenGetTopologyDataAndMapThenSubsliceIndicesNotSet) {
|
||||||
|
|
||||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||||
DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
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]};
|
||||||
auto &hwInfo = *executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo();
|
auto &hwInfo = *executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo();
|
||||||
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
|
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
|
||||||
|
|
||||||
@@ -1080,7 +1264,7 @@ TEST(IoctlHelperXeTest, given2TileAndComputeDssWhenGetTopologyDataAndMapThenResu
|
|||||||
|
|
||||||
TEST(IoctlHelperXeTest, given2TileWithDisabledDssOn1TileAndComputeDssWhenGetTopologyDataAndMapThenResultsAreCorrect) {
|
TEST(IoctlHelperXeTest, given2TileWithDisabledDssOn1TileAndComputeDssWhenGetTopologyDataAndMapThenResultsAreCorrect) {
|
||||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||||
DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
DrmMockXe2T drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||||
auto &hwInfo = *executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo();
|
auto &hwInfo = *executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo();
|
||||||
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
|
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
|
||||||
|
|
||||||
@@ -1146,7 +1330,7 @@ TEST(IoctlHelperXeTest, given2TileWithDisabledDssOn1TileAndComputeDssWhenGetTopo
|
|||||||
TEST(IoctlHelperXeTest, given2TileWithDisabledEvenDssAndComputeDssWhenGetTopologyDataAndMapThenResultsAreCorrect) {
|
TEST(IoctlHelperXeTest, given2TileWithDisabledEvenDssAndComputeDssWhenGetTopologyDataAndMapThenResultsAreCorrect) {
|
||||||
|
|
||||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||||
DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
DrmMockXe2T drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||||
auto &hwInfo = *executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo();
|
auto &hwInfo = *executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo();
|
||||||
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
|
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user