fix: create dedicated class for root device indices to store unique values

remove method to removing duplicates from StackVec as the method
implicitly sorted the vector

Related-To: GSD-4692
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2023-06-12 13:52:45 +00:00
committed by Compute-Runtime-Automation
parent 52651991c2
commit 4f72835b7d
31 changed files with 184 additions and 172 deletions

View File

@@ -230,10 +230,9 @@ bool Context::createImpl(const cl_context_properties *properties,
bool containsDeviceWithSubdevices = false;
for (const auto &device : inputDevices) {
rootDeviceIndices.push_back(device->getRootDeviceIndex());
rootDeviceIndices.pushUnique(device->getRootDeviceIndex());
containsDeviceWithSubdevices |= device->getNumGenericSubDevices() > 1;
}
rootDeviceIndices.remove_duplicates();
this->driverDiagnostics = driverDiagnostics.release();
if (rootDeviceIndices.size() > 1 && containsDeviceWithSubdevices && !DebugManager.flags.EnableMultiRootDeviceContexts.get()) {

View File

@@ -276,11 +276,10 @@ Buffer *Buffer::create(Context *context,
pRootDeviceIndices = &context->getRootDeviceIndices();
} else {
for (const auto &device : memoryProperties.associatedDevices) {
rootDeviceIndices.push_back(device->getRootDeviceIndex());
rootDeviceIndices.pushUnique(device->getRootDeviceIndex());
}
defaultDevice = memoryProperties.associatedDevices[0];
defaultRootDeviceIndex = rootDeviceIndices[0];
rootDeviceIndices.remove_duplicates();
pRootDeviceIndices = &rootDeviceIndices;
}

View File

@@ -143,11 +143,10 @@ Image *Image::create(Context *context,
pRootDeviceIndices = &context->getRootDeviceIndices();
} else {
for (const auto &device : memoryProperties.associatedDevices) {
rootDeviceIndices.push_back(device->getRootDeviceIndex());
rootDeviceIndices.pushUnique(device->getRootDeviceIndex());
}
defaultDevice = memoryProperties.associatedDevices[0];
defaultRootDeviceIndex = rootDeviceIndices[0];
rootDeviceIndices.remove_duplicates();
pRootDeviceIndices = &rootDeviceIndices;
}

View File

@@ -1790,10 +1790,9 @@ HWTEST_F(CreateHostUnifiedMemoryAllocationTest,
auto maxRootDeviceIndex = numDevices - 1u;
RootDeviceIndicesContainer rootDeviceIndices;
rootDeviceIndices.reserve(numDevices);
rootDeviceIndices.push_back(0u);
rootDeviceIndices.push_back(1u);
rootDeviceIndices.push_back(2u);
rootDeviceIndices.pushUnique(0u);
rootDeviceIndices.pushUnique(1u);
rootDeviceIndices.pushUnique(2u);
auto rootDeviceIndex = rootDeviceIndices.at(0);
auto deviceBitfield = device0->getDeviceBitfield();
@@ -1836,9 +1835,8 @@ HWTEST_F(CreateHostUnifiedMemoryAllocationTest,
auto maxRootDeviceIndex = numDevices - 1u;
RootDeviceIndicesContainer rootDeviceIndices;
rootDeviceIndices.reserve(numDevices);
rootDeviceIndices.push_back(0u);
rootDeviceIndices.push_back(2u);
rootDeviceIndices.pushUnique(0u);
rootDeviceIndices.pushUnique(2u);
auto noProgramedRootDeviceIndex = 1u;
auto rootDeviceIndex = rootDeviceIndices.at(0);

View File

@@ -3045,7 +3045,7 @@ TEST(MemoryManagerTest, givenMemoryManagerWithLocalMemoryWhenCreatingMultiGraphi
memoryManager.freeGraphicsMemory(localMemoryAllocation);
RootDeviceIndicesContainer rootDeviceIndices;
rootDeviceIndices.push_back(mockRootDeviceIndex);
rootDeviceIndices.pushUnique(mockRootDeviceIndex);
MultiGraphicsAllocation multiGraphicsAllocation(mockRootDeviceIndex);
@@ -3067,11 +3067,11 @@ TEST(MemoryManagerTest, givenDuplicateRootDeviceIndicesWhenCreatingMultiGraphics
AllocationProperties allocationProperties{mockRootDeviceIndex, MemoryConstants::pageSize, AllocationType::SVM_GPU, systemMemoryBitfield};
RootDeviceIndicesContainer rootDeviceIndices;
rootDeviceIndices.push_back(mockRootDeviceIndex);
rootDeviceIndices.push_back(mockRootDeviceIndex);
rootDeviceIndices.push_back(mockRootDeviceIndex);
rootDeviceIndices.pushUnique(mockRootDeviceIndex);
rootDeviceIndices.pushUnique(mockRootDeviceIndex);
rootDeviceIndices.pushUnique(mockRootDeviceIndex);
EXPECT_EQ(3u, rootDeviceIndices.size());
EXPECT_EQ(1u, rootDeviceIndices.size());
MultiGraphicsAllocation multiGraphicsAllocation(mockRootDeviceIndex);

View File

@@ -100,9 +100,8 @@ std::unique_ptr<AsyncEventsHandler> &MockContext::getAsyncEventsHandlerUniquePtr
void MockContext::initializeWithDevices(const ClDeviceVector &devices, bool noSpecialQueue) {
for (auto &pClDevice : devices) {
pClDevice->incRefInternal();
rootDeviceIndices.push_back(pClDevice->getRootDeviceIndex());
rootDeviceIndices.pushUnique(pClDevice->getRootDeviceIndex());
}
rootDeviceIndices.remove_duplicates();
maxRootDeviceIndex = *std::max_element(rootDeviceIndices.begin(), rootDeviceIndices.end(), std::less<uint32_t const>());
specialQueues.resize(maxRootDeviceIndex + 1u);

View File

@@ -625,10 +625,10 @@ TEST_F(WddmMemoryManagerSimpleTest, givenNonZeroFenceValueOnSomeOfMultipleEngine
}
TEST_F(WddmMemoryManagerSimpleTest, givenWddmMemoryManagerWhenGpuAddressIsReservedAndFreedThenAddressRangeIsNonZero) {
RootDeviceIndicesContainer rootDevices;
rootDevices.push_back(0);
RootDeviceIndicesContainer rootDeviceIndices;
rootDeviceIndices.pushUnique(0);
uint32_t rootDeviceIndexReserved = 1;
auto addressRange = memoryManager->reserveGpuAddress(0ull, MemoryConstants::pageSize64k, rootDevices, &rootDeviceIndexReserved);
auto addressRange = memoryManager->reserveGpuAddress(0ull, MemoryConstants::pageSize64k, rootDeviceIndices, &rootDeviceIndexReserved);
auto gmmHelper = memoryManager->getGmmHelper(0);
EXPECT_EQ(0u, rootDeviceIndexReserved);
EXPECT_NE(0u, gmmHelper->decanonize(addressRange.address));