fix: accept more than 16 root devices

Related-To: GSD-5892
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2023-09-05 15:33:39 +00:00
committed by Compute-Runtime-Automation
parent 73682494bc
commit 3845eb3b90
3 changed files with 11 additions and 8 deletions

View File

@@ -8,6 +8,7 @@
#pragma once
#include "shared/source/os_interface/linux/ioctl_helper.h"
#include <bitset>
#include <mutex>
struct drm_xe_engine_class_instance;

View File

@@ -10,7 +10,6 @@
#include "shared/source/helpers/debug_helpers.h"
#include <algorithm>
#include <bitset>
#include <cstdint>
#include <limits>
#include <tuple>
@@ -476,13 +475,16 @@ class RootDeviceIndicesContainer : protected StackVec<uint32_t, MaxRootDeviceInd
using StackVec<uint32_t, MaxRootDeviceIndices>::operator[];
inline void pushUnique(uint32_t rootDeviceIndex) {
if (!indexPresent.test(rootDeviceIndex)) {
if (indexPresent.size() <= rootDeviceIndex) {
indexPresent.resize(rootDeviceIndex + 1);
}
if (!indexPresent[rootDeviceIndex]) {
push_back(rootDeviceIndex);
indexPresent.set(rootDeviceIndex);
indexPresent[rootDeviceIndex] = 1;
}
}
protected:
std::bitset<MaxRootDeviceIndices> indexPresent{};
StackVec<int8_t, MaxRootDeviceIndices> indexPresent;
};
using RootDeviceIndicesMap = StackVec<std::tuple<uint32_t, uint32_t>, MaxRootDeviceIndices>;

View File

@@ -1705,8 +1705,8 @@ TEST(StackVec, GivenStackVecWithDynamicMemWhenSelfAssignedThenMemoryIsReused) {
}
TEST(StackVec, whenPushingUniqueToRootDeviceIndicesContainerThenOnlyUniqueValuesArePopulated) {
StackVec<uint32_t, 8> input = {6, 5, 4, 3, 2, 1, 5, 4, 5, 4, 2, 4, 3, 1, 6, 1};
ASSERT_EQ(input.size(), 16u);
StackVec<uint32_t, 8> input = {6, 5, 4, 3, 2, 1, 5, 4, 5, 4, 2, 4, 3, 1, 6, 1, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0};
ASSERT_EQ(input.size(), 27u);
RootDeviceIndicesContainer rootDeviceIndices{};
@@ -1714,8 +1714,8 @@ TEST(StackVec, whenPushingUniqueToRootDeviceIndicesContainerThenOnlyUniqueValues
rootDeviceIndices.pushUnique(index);
}
EXPECT_EQ(rootDeviceIndices.size(), 6u);
const RootDeviceIndicesContainer expectedContainer = {6, 5, 4, 3, 2, 1};
EXPECT_EQ(rootDeviceIndices.size(), 17u);
const RootDeviceIndicesContainer expectedContainer = {6, 5, 4, 3, 2, 1, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0};
for (auto i = 0u; i < rootDeviceIndices.size(); i++) {
EXPECT_EQ(rootDeviceIndices[i], expectedContainer[i]);
}