Correct createMultiGraphicsAllocationInSystemMemoryPool logic
isUSMHostAllocation flag will be set according to limited range product setup Related-To: NEO-5508 Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
parent
827f75da14
commit
274d2ff4b4
|
@ -85,3 +85,32 @@ TEST_P(MemoryManagerMultiDeviceTest, givenRootDeviceIndexSpecifiedWhenAllocateGr
|
||||||
}
|
}
|
||||||
delete tagsMultiAllocation;
|
delete tagsMultiAllocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_P(MemoryManagerMultiDeviceTest, givenRootDeviceIndexSpecifiedWhenAllocateGraphicsMemoryIsCalledThenAllocationPropertiesUsmFlagIsSetAccordingToAddressRange) {
|
||||||
|
std::vector<uint32_t> rootDeviceIndices;
|
||||||
|
|
||||||
|
for (uint32_t rootDeviceIndex = 0; rootDeviceIndex < getNumRootDevices(); ++rootDeviceIndex) {
|
||||||
|
rootDeviceIndices.push_back(rootDeviceIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto maxRootDeviceIndex = *std::max_element(rootDeviceIndices.begin(), rootDeviceIndices.end(), std::less<uint32_t const>());
|
||||||
|
auto tagsMultiAllocation = new MultiGraphicsAllocation(maxRootDeviceIndex);
|
||||||
|
|
||||||
|
AllocationProperties unifiedMemoryProperties{rootDeviceIndices.at(0), MemoryConstants::pageSize, GraphicsAllocation::AllocationType::TAG_BUFFER, systemMemoryBitfield};
|
||||||
|
|
||||||
|
memoryManager->createMultiGraphicsAllocationInSystemMemoryPool(rootDeviceIndices, unifiedMemoryProperties, *tagsMultiAllocation);
|
||||||
|
EXPECT_NE(nullptr, tagsMultiAllocation);
|
||||||
|
|
||||||
|
for (auto rootDeviceIndex : rootDeviceIndices) {
|
||||||
|
if (memoryManager->isLimitedRange(rootDeviceIndex)) {
|
||||||
|
EXPECT_EQ(unifiedMemoryProperties.flags.isUSMHostAllocation, false);
|
||||||
|
} else {
|
||||||
|
EXPECT_EQ(unifiedMemoryProperties.flags.isUSMHostAllocation, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto graphicsAllocation : tagsMultiAllocation->getGraphicsAllocations()) {
|
||||||
|
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||||
|
}
|
||||||
|
delete tagsMultiAllocation;
|
||||||
|
}
|
||||||
|
|
|
@ -1110,7 +1110,11 @@ TEST_F(DrmMemoryManagerTest, GivenMisalignedHostPtrAndMultiplePagesSizeWhenAsked
|
||||||
|
|
||||||
auto hostPtrManager = static_cast<MockHostPtrManager *>(memoryManager->getHostPtrManager());
|
auto hostPtrManager = static_cast<MockHostPtrManager *>(memoryManager->getHostPtrManager());
|
||||||
|
|
||||||
ASSERT_EQ(3u, hostPtrManager->getFragmentCount());
|
if (memoryManager->isLimitedRange(rootDeviceIndex)) {
|
||||||
|
ASSERT_EQ(6u, hostPtrManager->getFragmentCount());
|
||||||
|
} else {
|
||||||
|
ASSERT_EQ(3u, hostPtrManager->getFragmentCount());
|
||||||
|
}
|
||||||
|
|
||||||
auto reqs = MockHostPtrManager::getAllocationRequirements(rootDeviceIndex, ptr, size);
|
auto reqs = MockHostPtrManager::getAllocationRequirements(rootDeviceIndex, ptr, size);
|
||||||
|
|
||||||
|
@ -1120,7 +1124,12 @@ TEST_F(DrmMemoryManagerTest, GivenMisalignedHostPtrAndMultiplePagesSizeWhenAsked
|
||||||
EXPECT_EQ(reqs.allocationFragments[i].allocationPtr, reinterpret_cast<void *>(graphicsAllocation->fragmentsStorage.fragmentStorageData[i].osHandleStorage->bo->peekAddress()));
|
EXPECT_EQ(reqs.allocationFragments[i].allocationPtr, reinterpret_cast<void *>(graphicsAllocation->fragmentsStorage.fragmentStorageData[i].osHandleStorage->bo->peekAddress()));
|
||||||
}
|
}
|
||||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||||
EXPECT_EQ(0u, hostPtrManager->getFragmentCount());
|
|
||||||
|
if (memoryManager->isLimitedRange(rootDeviceIndex)) {
|
||||||
|
EXPECT_EQ(3u, hostPtrManager->getFragmentCount());
|
||||||
|
} else {
|
||||||
|
EXPECT_EQ(0u, hostPtrManager->getFragmentCount());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedFor32BitAllocationThen32BitDrmAllocationIsBeingReturned) {
|
TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedFor32BitAllocationThen32BitDrmAllocationIsBeingReturned) {
|
||||||
|
|
|
@ -144,9 +144,14 @@ void *MemoryManager::createMultiGraphicsAllocationInSystemMemoryPool(std::vector
|
||||||
|
|
||||||
for (auto &rootDeviceIndex : rootDeviceIndices) {
|
for (auto &rootDeviceIndex : rootDeviceIndices) {
|
||||||
properties.rootDeviceIndex = rootDeviceIndex;
|
properties.rootDeviceIndex = rootDeviceIndex;
|
||||||
|
properties.flags.isUSMHostAllocation = true;
|
||||||
|
|
||||||
|
if (isLimitedRange(properties.rootDeviceIndex)) {
|
||||||
|
properties.flags.isUSMHostAllocation = false;
|
||||||
|
DEBUG_BREAK_IF(rootDeviceIndices.size() > 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (!ptr) {
|
if (!ptr) {
|
||||||
properties.flags.isUSMHostAllocation = true;
|
|
||||||
auto graphicsAllocation = allocateGraphicsMemoryWithProperties(properties);
|
auto graphicsAllocation = allocateGraphicsMemoryWithProperties(properties);
|
||||||
if (!graphicsAllocation) {
|
if (!graphicsAllocation) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -155,7 +160,6 @@ void *MemoryManager::createMultiGraphicsAllocationInSystemMemoryPool(std::vector
|
||||||
ptr = reinterpret_cast<void *>(graphicsAllocation->getUnderlyingBuffer());
|
ptr = reinterpret_cast<void *>(graphicsAllocation->getUnderlyingBuffer());
|
||||||
} else {
|
} else {
|
||||||
properties.flags.allocateMemory = false;
|
properties.flags.allocateMemory = false;
|
||||||
properties.flags.isUSMHostAllocation = true;
|
|
||||||
|
|
||||||
auto graphicsAllocation = createGraphicsAllocationFromExistingStorage(properties, ptr, multiGraphicsAllocation);
|
auto graphicsAllocation = createGraphicsAllocationFromExistingStorage(properties, ptr, multiGraphicsAllocation);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue