mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-10 07:08:04 +08:00
Move tests to shared
memory manager allocate in device pool storage info Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
b03119b964
commit
14acaf677d
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2020-2021 Intel Corporation
|
||||
# Copyright (C) 2020-2022 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -13,12 +13,14 @@ target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gfx_partition_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/graphics_allocation_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/local_memory_usage_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_manager_allocate_in_device_pool_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory_pool_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/multi_graphics_allocation_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/page_table_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/physical_address_allocator_hw_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/physical_address_allocator_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/special_heap_pool_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/storage_info_tests.cpp
|
||||
)
|
||||
|
||||
add_subdirectories()
|
||||
|
||||
@@ -0,0 +1,630 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/aub/aub_helper.h"
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/gmm_helper/gmm_helper.h"
|
||||
#include "shared/source/helpers/memory_properties_helpers.h"
|
||||
#include "shared/source/memory_manager/os_agnostic_memory_manager.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_execution_environment.h"
|
||||
#include "shared/test/common/mocks/mock_gmm.h"
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
TEST(MemoryManagerTest, givenSetUseSytemMemoryWhenGraphicsAllocationInDevicePoolIsAllocatedThenNullptrIsReturned) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||
AllocationData allocData;
|
||||
allocData.size = MemoryConstants::pageSize;
|
||||
allocData.flags.useSystemMemory = true;
|
||||
allocData.flags.allocateMemory = true;
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
EXPECT_EQ(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryManager::AllocationStatus::RetryInNonDevicePool, status);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenAllowed32BitAndFroce32BitWhenGraphicsAllocationInDevicePoolIsAllocatedThenNullptrIsReturned) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
memoryManager.setForce32BitAllocations(true);
|
||||
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||
AllocationData allocData;
|
||||
allocData.size = MemoryConstants::pageSize;
|
||||
allocData.flags.allow32Bit = true;
|
||||
allocData.flags.allocateMemory = true;
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
EXPECT_EQ(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryManager::AllocationStatus::RetryInNonDevicePool, status);
|
||||
}
|
||||
|
||||
TEST(AllocationFlagsTest, givenAllocateMemoryFlagWhenGetAllocationFlagsIsCalledThenAllocateFlagIsCorrectlySet) {
|
||||
HardwareInfo hwInfo(*defaultHwInfo);
|
||||
UltDeviceFactory deviceFactory{1, 0};
|
||||
auto pDevice = deviceFactory.rootDevices[0];
|
||||
MemoryProperties memoryProperties{};
|
||||
memoryProperties.pDevice = pDevice;
|
||||
auto allocationProperties = MemoryPropertiesHelper::getAllocationProperties(0, memoryProperties, true, 0, AllocationType::BUFFER, false, hwInfo, {}, true);
|
||||
EXPECT_TRUE(allocationProperties.flags.allocateMemory);
|
||||
|
||||
auto allocationProperties2 = MemoryPropertiesHelper::getAllocationProperties(0, memoryProperties, false, 0, AllocationType::BUFFER, false, hwInfo, {}, true);
|
||||
EXPECT_FALSE(allocationProperties2.flags.allocateMemory);
|
||||
}
|
||||
|
||||
TEST(UncacheableFlagsTest, givenUncachedResourceFlagWhenGetAllocationFlagsIsCalledThenUncacheableFlagIsCorrectlySet) {
|
||||
UltDeviceFactory deviceFactory{1, 0};
|
||||
auto pDevice = deviceFactory.rootDevices[0];
|
||||
|
||||
MemoryProperties memoryProperties{};
|
||||
memoryProperties.pDevice = pDevice;
|
||||
memoryProperties.flags.locallyUncachedResource = true;
|
||||
auto allocationFlags = MemoryPropertiesHelper::getAllocationProperties(
|
||||
0, memoryProperties, false, 0, AllocationType::BUFFER, false, pDevice->getHardwareInfo(), {}, true);
|
||||
EXPECT_TRUE(allocationFlags.flags.uncacheable);
|
||||
|
||||
memoryProperties.flags.locallyUncachedResource = false;
|
||||
auto allocationFlags2 = MemoryPropertiesHelper::getAllocationProperties(
|
||||
0, memoryProperties, false, 0, AllocationType::BUFFER, false, pDevice->getHardwareInfo(), {}, true);
|
||||
EXPECT_FALSE(allocationFlags2.flags.uncacheable);
|
||||
}
|
||||
|
||||
TEST(AllocationFlagsTest, givenReadOnlyResourceFlagWhenGetAllocationFlagsIsCalledThenFlushL3FlagsAreCorrectlySet) {
|
||||
UltDeviceFactory deviceFactory{1, 2};
|
||||
auto pDevice = deviceFactory.rootDevices[0];
|
||||
|
||||
MemoryProperties memoryProperties{};
|
||||
memoryProperties.pDevice = pDevice;
|
||||
memoryProperties.flags.readOnly = true;
|
||||
|
||||
auto allocationFlags =
|
||||
MemoryPropertiesHelper::getAllocationProperties(
|
||||
0, memoryProperties, true, 0, AllocationType::BUFFER, false, pDevice->getHardwareInfo(), {}, false);
|
||||
EXPECT_FALSE(allocationFlags.flags.flushL3RequiredForRead);
|
||||
EXPECT_FALSE(allocationFlags.flags.flushL3RequiredForWrite);
|
||||
|
||||
memoryProperties.flags.readOnly = false;
|
||||
auto allocationFlags2 = MemoryPropertiesHelper::getAllocationProperties(
|
||||
0, memoryProperties, true, 0, AllocationType::BUFFER, false, pDevice->getHardwareInfo(), {}, false);
|
||||
EXPECT_TRUE(allocationFlags2.flags.flushL3RequiredForRead);
|
||||
EXPECT_TRUE(allocationFlags2.flags.flushL3RequiredForWrite);
|
||||
}
|
||||
|
||||
TEST(StorageInfoTest, whenStorageInfoIsCreatedWithDefaultConstructorThenReturnsOneHandle) {
|
||||
StorageInfo storageInfo;
|
||||
EXPECT_EQ(1u, storageInfo.getNumBanks());
|
||||
}
|
||||
|
||||
class MockMemoryManagerBaseImplementationOfDevicePool : public MemoryManagerCreate<OsAgnosticMemoryManager> {
|
||||
public:
|
||||
using MemoryManagerCreate<OsAgnosticMemoryManager>::MemoryManagerCreate;
|
||||
|
||||
GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) override {
|
||||
if (failInAllocate) {
|
||||
return nullptr;
|
||||
}
|
||||
return OsAgnosticMemoryManager::allocateGraphicsMemoryInDevicePool(allocationData, status);
|
||||
}
|
||||
|
||||
GraphicsAllocation *allocateGraphicsMemoryWithAlignment(const AllocationData &allocationData) override {
|
||||
if (failInAllocate) {
|
||||
return nullptr;
|
||||
}
|
||||
return OsAgnosticMemoryManager::allocateGraphicsMemoryWithAlignment(allocationData);
|
||||
}
|
||||
|
||||
void *allocateSystemMemory(size_t size, size_t alignment) override {
|
||||
if (failInAllocate) {
|
||||
return nullptr;
|
||||
}
|
||||
return OsAgnosticMemoryManager::allocateSystemMemory(size, alignment);
|
||||
}
|
||||
bool failInAllocate = false;
|
||||
};
|
||||
|
||||
using MemoryManagerTests = ::testing::Test;
|
||||
|
||||
TEST(MemoryManagerTest, givenNotSetUseSystemMemoryWhenGraphicsAllocationInDevicePoolIsAllocatedThenLocalMemoryAllocationIsReturned) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Error;
|
||||
AllocationData allocData;
|
||||
allocData.allFlags = 0;
|
||||
allocData.size = MemoryConstants::pageSize;
|
||||
allocData.flags.allocateMemory = true;
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryManager::AllocationStatus::Success, status);
|
||||
EXPECT_EQ(MemoryPool::LocalMemory, allocation->getMemoryPool());
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenNotSetUseSystemMemoryWhenGraphicsAllocationInDevicePoolIsAllocatedThenLocalMemoryAllocationHasCorrectStorageInfoAndFlushL3IsSet) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Error;
|
||||
AllocationData allocData;
|
||||
allocData.allFlags = 0;
|
||||
allocData.size = MemoryConstants::pageSize;
|
||||
allocData.flags.allocateMemory = true;
|
||||
allocData.storageInfo.memoryBanks = 0x1;
|
||||
allocData.storageInfo.pageTablesVisibility = 0x2;
|
||||
allocData.storageInfo.cloningOfPageTables = false;
|
||||
allocData.flags.flushL3 = true;
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
|
||||
EXPECT_EQ(allocData.storageInfo.memoryBanks, allocation->storageInfo.memoryBanks);
|
||||
EXPECT_EQ(allocData.storageInfo.pageTablesVisibility, allocation->storageInfo.pageTablesVisibility);
|
||||
EXPECT_FALSE(allocation->storageInfo.cloningOfPageTables);
|
||||
EXPECT_TRUE(allocation->isFlushL3Required());
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenEnabledLocalMemoryAndUseSytemMemoryWhenGraphicsAllocationInDevicePoolIsAllocatedThenNullptrIsReturned) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||
AllocationData allocData;
|
||||
allocData.allFlags = 0;
|
||||
allocData.size = MemoryConstants::pageSize;
|
||||
allocData.flags.useSystemMemory = true;
|
||||
allocData.flags.allocateMemory = true;
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
EXPECT_EQ(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryManager::AllocationStatus::RetryInNonDevicePool, status);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenEnabledLocalMemoryAndAllowed32BitAndForce32BitWhenGraphicsAllocationInDevicePoolIsAllocatedThenNullptrIsReturned) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
memoryManager.setForce32BitAllocations(true);
|
||||
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||
AllocationData allocData;
|
||||
allocData.allFlags = 0;
|
||||
allocData.size = MemoryConstants::pageSize;
|
||||
allocData.flags.allow32Bit = true;
|
||||
allocData.flags.allocateMemory = true;
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
EXPECT_EQ(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryManager::AllocationStatus::RetryInNonDevicePool, status);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenEnabledLocalMemoryAndAllowed32BitWhen32BitIsNotForcedThenGraphicsAllocationInDevicePoolReturnsLocalMemoryAllocation) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
memoryManager.setForce32BitAllocations(false);
|
||||
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||
AllocationData allocData;
|
||||
allocData.allFlags = 0;
|
||||
allocData.size = MemoryConstants::pageSize;
|
||||
allocData.flags.allow32Bit = true;
|
||||
allocData.flags.allocateMemory = true;
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryManager::AllocationStatus::Success, status);
|
||||
EXPECT_EQ(MemoryPool::LocalMemory, allocation->getMemoryPool());
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenEnabledLocalMemoryWhenAllocate32BitFailsThenGraphicsAllocationInDevicePoolReturnsError) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||
AllocationData allocData;
|
||||
allocData.type = AllocationType::KERNEL_ISA; // HEAP_INTERNAL will be used
|
||||
allocData.allFlags = 0;
|
||||
allocData.size = MemoryConstants::pageSize;
|
||||
allocData.flags.allocateMemory = true;
|
||||
|
||||
memoryManager.failAllocate32Bit = true;
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
EXPECT_EQ(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryManager::AllocationStatus::Error, status);
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
HWTEST_F(MemoryManagerTests, givenEnabledLocalMemoryWhenAllocatingDebugAreaThenHeapInternalDeviceFrontWindowIsUsed) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> osAgnosticMemoryManager(false, true, executionEnvironment);
|
||||
|
||||
NEO::AllocationProperties properties{0, true, MemoryConstants::pageSize64k,
|
||||
NEO::AllocationType::DEBUG_MODULE_AREA,
|
||||
false,
|
||||
mockDeviceBitfield};
|
||||
properties.flags.use32BitFrontWindow = true;
|
||||
|
||||
auto &hwHelper = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily);
|
||||
auto systemMemoryPlacement = hwHelper.useSystemMemoryPlacementForISA(*defaultHwInfo);
|
||||
|
||||
HeapIndex expectedHeap = HeapIndex::TOTAL_HEAPS;
|
||||
HeapIndex baseHeap = HeapIndex::TOTAL_HEAPS;
|
||||
if (systemMemoryPlacement) {
|
||||
expectedHeap = HeapIndex::HEAP_INTERNAL_FRONT_WINDOW;
|
||||
baseHeap = HeapIndex::HEAP_INTERNAL;
|
||||
} else {
|
||||
expectedHeap = HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW;
|
||||
baseHeap = HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY;
|
||||
}
|
||||
auto moduleDebugArea = osAgnosticMemoryManager.allocateGraphicsMemoryWithProperties(properties);
|
||||
auto gpuAddress = moduleDebugArea->getGpuAddress();
|
||||
EXPECT_LE(GmmHelper::canonize(osAgnosticMemoryManager.getGfxPartition(0)->getHeapBase(expectedHeap)), gpuAddress);
|
||||
EXPECT_GT(GmmHelper::canonize(osAgnosticMemoryManager.getGfxPartition(0)->getHeapLimit(expectedHeap)), gpuAddress);
|
||||
EXPECT_EQ(GmmHelper::canonize(osAgnosticMemoryManager.getGfxPartition(0)->getHeapBase(expectedHeap)), moduleDebugArea->getGpuBaseAddress());
|
||||
EXPECT_EQ(GmmHelper::canonize(osAgnosticMemoryManager.getGfxPartition(0)->getHeapBase(baseHeap)), moduleDebugArea->getGpuBaseAddress());
|
||||
|
||||
osAgnosticMemoryManager.freeGraphicsMemory(moduleDebugArea);
|
||||
}
|
||||
|
||||
TEST(BaseMemoryManagerTest, givenMemoryManagerWithForced32BitsWhenSystemMemoryIsNotSetAnd32BitNotAllowedThenAllocateInDevicePoolReturnsLocalMemory) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MockMemoryManagerBaseImplementationOfDevicePool memoryManager(false, true, executionEnvironment);
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Error;
|
||||
AllocationData allocData;
|
||||
allocData.allFlags = 0;
|
||||
allocData.size = MemoryConstants::pageSize;
|
||||
allocData.flags.allocateMemory = true;
|
||||
|
||||
memoryManager.setForce32BitAllocations(true);
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryManager::AllocationStatus::Success, status);
|
||||
EXPECT_EQ(MemoryPool::LocalMemory, allocation->getMemoryPool());
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST(BaseMemoryManagerTest, givenDebugVariableSetWhenCompressedBufferIsCreatedThenCreateCompressedGmm) {
|
||||
DebugManagerStateRestore restore;
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
executionEnvironment.initGmm();
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, true, executionEnvironment);
|
||||
|
||||
AllocationProperties allocPropertiesBuffer(mockRootDeviceIndex, 1, AllocationType::BUFFER, mockDeviceBitfield);
|
||||
AllocationProperties allocPropertiesBufferCompressed(mockRootDeviceIndex, 1, AllocationType::BUFFER, mockDeviceBitfield);
|
||||
allocPropertiesBufferCompressed.flags.preferCompressed = true;
|
||||
|
||||
DebugManager.flags.RenderCompressedBuffersEnabled.set(1);
|
||||
auto allocationBuffer = memoryManager.allocateGraphicsMemoryInPreferredPool(allocPropertiesBuffer, nullptr);
|
||||
auto allocationBufferCompressed = memoryManager.allocateGraphicsMemoryInPreferredPool(allocPropertiesBufferCompressed, nullptr);
|
||||
EXPECT_EQ(nullptr, allocationBuffer->getDefaultGmm());
|
||||
EXPECT_NE(nullptr, allocationBufferCompressed->getDefaultGmm());
|
||||
EXPECT_TRUE(allocationBufferCompressed->getDefaultGmm()->isCompressionEnabled);
|
||||
memoryManager.freeGraphicsMemory(allocationBuffer);
|
||||
memoryManager.freeGraphicsMemory(allocationBufferCompressed);
|
||||
|
||||
DebugManager.flags.RenderCompressedBuffersEnabled.set(0);
|
||||
allocationBuffer = memoryManager.allocateGraphicsMemoryInPreferredPool(allocPropertiesBuffer, nullptr);
|
||||
allocationBufferCompressed = memoryManager.allocateGraphicsMemoryInPreferredPool(allocPropertiesBufferCompressed, nullptr);
|
||||
EXPECT_EQ(nullptr, allocationBuffer->getDefaultGmm());
|
||||
EXPECT_EQ(nullptr, allocationBufferCompressed->getDefaultGmm());
|
||||
memoryManager.freeGraphicsMemory(allocationBuffer);
|
||||
memoryManager.freeGraphicsMemory(allocationBufferCompressed);
|
||||
}
|
||||
|
||||
TEST(BaseMemoryManagerTest, givenMemoryManagerWithForced32BitsWhenSystemMemoryIsNotSetAnd32BitAllowedThenAllocateInDevicePoolReturnsRetryInNonDevicePool) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MockMemoryManagerBaseImplementationOfDevicePool memoryManager(false, true, executionEnvironment);
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Error;
|
||||
AllocationData allocData;
|
||||
allocData.allFlags = 0;
|
||||
allocData.size = MemoryConstants::pageSize;
|
||||
allocData.flags.allocateMemory = true;
|
||||
allocData.flags.allow32Bit = true;
|
||||
|
||||
memoryManager.setForce32BitAllocations(true);
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
EXPECT_EQ(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryManager::AllocationStatus::RetryInNonDevicePool, status);
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST(BaseMemoryManagerTest, givenMemoryManagerWhenAllocateFailsThenAllocateInDevicePoolReturnsError) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MockMemoryManagerBaseImplementationOfDevicePool memoryManager(false, true, executionEnvironment);
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Error;
|
||||
AllocationData allocData;
|
||||
allocData.allFlags = 0;
|
||||
allocData.size = MemoryConstants::pageSize;
|
||||
allocData.flags.allocateMemory = true;
|
||||
allocData.flags.allow32Bit = true;
|
||||
|
||||
memoryManager.failInAllocate = true;
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
EXPECT_EQ(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryManager::AllocationStatus::Error, status);
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST(BaseMemoryManagerTest, givenSvmGpuAllocationTypeWhenAllocateSystemMemoryFailsThenReturnNull) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
|
||||
if (!executionEnvironment.rootDeviceEnvironments[0]->isFullRangeSvm()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MockMemoryManagerBaseImplementationOfDevicePool memoryManager(false, true, executionEnvironment);
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Error;
|
||||
AllocationData allocData;
|
||||
|
||||
allocData.allFlags = 0;
|
||||
allocData.size = MemoryConstants::pageSize;
|
||||
allocData.type = AllocationType::SVM_GPU;
|
||||
allocData.hostPtr = reinterpret_cast<void *>(0x1000);
|
||||
|
||||
memoryManager.failInAllocate = true;
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
EXPECT_EQ(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryManager::AllocationStatus::Error, status);
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST(BaseMemoryManagerTest, givenSvmGpuAllocationTypeWhenAllocationSucceedThenReturnGpuAddressAsHostPtrAndCpuAllocation) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
|
||||
if (!executionEnvironment.rootDeviceEnvironments[0]->isFullRangeSvm()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MockMemoryManagerBaseImplementationOfDevicePool memoryManager(false, true, executionEnvironment);
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Error;
|
||||
AllocationData allocData;
|
||||
|
||||
allocData.allFlags = 0;
|
||||
allocData.size = MemoryConstants::pageSize;
|
||||
allocData.type = AllocationType::SVM_GPU;
|
||||
allocData.hostPtr = reinterpret_cast<void *>(0x1000);
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryManager::AllocationStatus::Success, status);
|
||||
EXPECT_EQ(reinterpret_cast<uint64_t>(allocData.hostPtr), allocation->getGpuAddress());
|
||||
EXPECT_NE(reinterpret_cast<uint64_t>(allocation->getUnderlyingBuffer()), allocation->getGpuAddress());
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST(MemoryAllocationTest, givenMultiTileVisiblityWhenAskedForFlagsThenL3NeedsToBeFlushed) {
|
||||
UltDeviceFactory deviceFactory{1, 2};
|
||||
auto pDevice = deviceFactory.rootDevices[0];
|
||||
MemoryProperties memoryProperties{};
|
||||
memoryProperties.pDevice = pDevice;
|
||||
auto allocationFlags = MemoryPropertiesHelper::getAllocationProperties(0, memoryProperties, true, 0, AllocationType::BUFFER, false, pDevice->getHardwareInfo(), {}, false);
|
||||
EXPECT_TRUE(allocationFlags.flags.flushL3RequiredForRead);
|
||||
EXPECT_TRUE(allocationFlags.flags.flushL3RequiredForWrite);
|
||||
}
|
||||
|
||||
TEST(MemoryAllocationTest, givenMultiTileVisiblityAndUncachedWhenAskedForFlagsThenL3DoesNotNeedToBeFlushed) {
|
||||
UltDeviceFactory deviceFactory{1, 2};
|
||||
auto pDevice = deviceFactory.rootDevices[0];
|
||||
MemoryProperties memoryProperties{};
|
||||
memoryProperties.pDevice = pDevice;
|
||||
memoryProperties.flags.locallyUncachedResource = true;
|
||||
|
||||
auto allocationFlags = MemoryPropertiesHelper::getAllocationProperties(
|
||||
0, memoryProperties, true, 0, AllocationType::BUFFER, false, pDevice->getHardwareInfo(), {}, false);
|
||||
EXPECT_FALSE(allocationFlags.flags.flushL3RequiredForRead);
|
||||
EXPECT_FALSE(allocationFlags.flags.flushL3RequiredForWrite);
|
||||
}
|
||||
|
||||
TEST(MemoryAllocationTest, givenAubDumpForceAllToLocalMemoryWhenMemoryAllocationIsCreatedThenItHasLocalMemoryPool) {
|
||||
DebugManagerStateRestore debugRestorer;
|
||||
DebugManager.flags.AUBDumpForceAllToLocalMemory.set(true);
|
||||
|
||||
MemoryAllocation allocation(mockRootDeviceIndex, AllocationType::UNKNOWN, nullptr, reinterpret_cast<void *>(0x1000), 0x1000,
|
||||
0x1000, 0, MemoryPool::System4KBPages, false, false, MemoryManager::maxOsContextCount);
|
||||
EXPECT_EQ(MemoryPool::LocalMemory, allocation.getMemoryPool());
|
||||
}
|
||||
|
||||
TEST(MemoryAllocationTest, givenAubDumpForceAllToLocalMemoryWhenMemoryAllocationIsOverridenThenItHasLocalMemoryPool) {
|
||||
DebugManagerStateRestore debugRestorer;
|
||||
DebugManager.flags.AUBDumpForceAllToLocalMemory.set(true);
|
||||
|
||||
MemoryAllocation allocation(mockRootDeviceIndex, AllocationType::UNKNOWN, nullptr, reinterpret_cast<void *>(0x1000), 0x1000,
|
||||
0x1000, 0, MemoryPool::System4KBPages, false, false, MemoryManager::maxOsContextCount);
|
||||
allocation.overrideMemoryPool(MemoryPool::System64KBPages);
|
||||
EXPECT_EQ(MemoryPool::LocalMemory, allocation.getMemoryPool());
|
||||
}
|
||||
|
||||
HWTEST_F(MemoryManagerTests, givenEnabledLocalMemoryWhenAllocateInternalAllocationInDevicePoolThen32BitAllocationIsCreated) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInPreferredPool({mockRootDeviceIndex, MemoryConstants::pageSize, AllocationType::INTERNAL_HEAP, mockDeviceBitfield}, nullptr);
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
EXPECT_TRUE(allocation->is32BitAllocation());
|
||||
EXPECT_TRUE(memoryManager.allocationInDevicePoolCreated);
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenDisabledLocalMemoryWhenAllocateInternalAllocationInDevicePoolThen32BitAllocationIsCreatedInNonDevicePool) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInPreferredPool({mockRootDeviceIndex, MemoryConstants::pageSize, AllocationType::INTERNAL_HEAP, mockDeviceBitfield}, nullptr);
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
EXPECT_TRUE(allocation->is32BitAllocation());
|
||||
EXPECT_NE(MemoryPool::LocalMemory, allocation->getMemoryPool());
|
||||
EXPECT_FALSE(memoryManager.allocationInDevicePoolCreated);
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenOsAgnosticMemoryManagerWhenGetLocalMemoryIsCalledThenSizeOfLocalMemoryIsReturned) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
|
||||
auto hwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo();
|
||||
|
||||
auto subDevicesCount = HwHelper::getSubDevicesCount(hwInfo);
|
||||
uint32_t deviceMask = static_cast<uint32_t>(maxNBitValue(subDevicesCount));
|
||||
|
||||
EXPECT_EQ(AubHelper::getPerTileLocalMemorySize(hwInfo) * subDevicesCount, memoryManager.getLocalMemorySize(0u, deviceMask));
|
||||
}
|
||||
|
||||
HWTEST_F(MemoryManagerTests, givenEnabledLocalMemoryWhenAllocatingKernelIsaThenLocalMemoryPoolIsUsed) {
|
||||
auto hwInfo = *defaultHwInfo;
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.EnableLocalMemory.set(true);
|
||||
hwInfo.featureTable.flags.ftrLocalMemory = true;
|
||||
|
||||
MockExecutionEnvironment executionEnvironment(&hwInfo);
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInPreferredPool({mockRootDeviceIndex, MemoryConstants::pageSize, AllocationType::KERNEL_ISA, mockDeviceBitfield}, nullptr);
|
||||
EXPECT_EQ(MemoryPool::LocalMemory, allocation->getMemoryPool());
|
||||
EXPECT_TRUE(memoryManager.allocationInDevicePoolCreated);
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
|
||||
allocation = memoryManager.allocateGraphicsMemoryInPreferredPool({mockRootDeviceIndex, MemoryConstants::pageSize, AllocationType::KERNEL_ISA_INTERNAL, mockDeviceBitfield}, nullptr);
|
||||
EXPECT_EQ(MemoryPool::LocalMemory, allocation->getMemoryPool());
|
||||
EXPECT_TRUE(memoryManager.allocationInDevicePoolCreated);
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
HWTEST_F(MemoryManagerTests, givenEnabledLocalMemoryWhenAllocateKernelIsaInDevicePoolThenLocalMemoryPoolIsUsed) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInPreferredPool({mockRootDeviceIndex, MemoryConstants::pageSize, AllocationType::INTERNAL_HEAP, mockDeviceBitfield}, nullptr);
|
||||
EXPECT_EQ(MemoryPool::LocalMemory, allocation->getMemoryPool());
|
||||
EXPECT_TRUE(memoryManager.allocationInDevicePoolCreated);
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
HWTEST_F(MemoryManagerTests, givenEnabledLocalMemoryWhenLinearStreamIsAllocatedInDevicePoolThenLocalMemoryPoolIsUsed) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInPreferredPool({mockRootDeviceIndex, MemoryConstants::pageSize, AllocationType::LINEAR_STREAM, mockDeviceBitfield}, nullptr);
|
||||
EXPECT_EQ(MemoryPool::LocalMemory, allocation->getMemoryPool());
|
||||
EXPECT_TRUE(memoryManager.allocationInDevicePoolCreated);
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST(StorageInfoTest, whenMemoryBanksAreSetToZeroThenOneHandleIsReturned) {
|
||||
StorageInfo storageInfo;
|
||||
storageInfo.memoryBanks = 0u;
|
||||
EXPECT_EQ(1u, storageInfo.getNumBanks());
|
||||
}
|
||||
|
||||
TEST(StorageInfoTest, whenMemoryBanksAreNotSetToZeroThenNumberOfEnabledBitsIsReturnedAsNumberOfHandles) {
|
||||
StorageInfo storageInfo;
|
||||
storageInfo.memoryBanks = 0b001;
|
||||
EXPECT_EQ(1u, storageInfo.getNumBanks());
|
||||
storageInfo.memoryBanks = 0b010;
|
||||
EXPECT_EQ(1u, storageInfo.getNumBanks());
|
||||
storageInfo.memoryBanks = 0b100;
|
||||
EXPECT_EQ(1u, storageInfo.getNumBanks());
|
||||
storageInfo.memoryBanks = 0b011;
|
||||
EXPECT_EQ(2u, storageInfo.getNumBanks());
|
||||
storageInfo.memoryBanks = 0b101;
|
||||
EXPECT_EQ(2u, storageInfo.getNumBanks());
|
||||
storageInfo.memoryBanks = 0b110;
|
||||
EXPECT_EQ(2u, storageInfo.getNumBanks());
|
||||
storageInfo.memoryBanks = 0b111;
|
||||
EXPECT_EQ(3u, storageInfo.getNumBanks());
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenNotSetUseSystemMemoryWhenGraphicsAllocationInDevicePoolIsAllocatedThenlocalMemoryUsageIsUpdated) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
|
||||
AllocationProperties allocProperties(mockRootDeviceIndex, MemoryConstants::pageSize, AllocationType::BUFFER, mockDeviceBitfield);
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInPreferredPool(allocProperties, nullptr);
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryPool::LocalMemory, allocation->getMemoryPool());
|
||||
EXPECT_EQ(allocation->getUnderlyingBufferSize(), memoryManager.getLocalMemoryUsageBankSelector(allocation->getAllocationType(), allocation->getRootDeviceIndex())->getOccupiedMemorySizeForBank(0));
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
EXPECT_EQ(0u, memoryManager.getLocalMemoryUsageBankSelector(AllocationType::EXTERNAL_HOST_PTR, mockRootDeviceIndex)->getOccupiedMemorySizeForBank(0));
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenSetUseSystemMemoryWhenGraphicsAllocationInDevicePoolIsAllocatedThenlocalMemoryUsageIsNotUpdated) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
|
||||
AllocationProperties allocProperties(mockRootDeviceIndex, MemoryConstants::pageSize, AllocationType::EXTERNAL_HOST_PTR, mockDeviceBitfield);
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInPreferredPool(allocProperties, nullptr);
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(0u, memoryManager.getLocalMemoryUsageBankSelector(allocation->getAllocationType(), allocation->getRootDeviceIndex())->getOccupiedMemorySizeForBank(0));
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
EXPECT_EQ(0u, memoryManager.getLocalMemoryUsageBankSelector(AllocationType::EXTERNAL_HOST_PTR, mockRootDeviceIndex)->getOccupiedMemorySizeForBank(0));
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenInternalAllocationTypeWhenIsAllocatedInDevicePoolThenIntenalUsageBankSelectorIsUpdated) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
|
||||
AllocationProperties allocProperties(mockRootDeviceIndex, MemoryConstants::pageSize, AllocationType::SEMAPHORE_BUFFER, mockDeviceBitfield);
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInPreferredPool(allocProperties, nullptr);
|
||||
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(0u, memoryManager.externalLocalMemoryUsageBankSelector[allocation->getRootDeviceIndex()]->getOccupiedMemorySizeForBank(0));
|
||||
|
||||
if (allocation->getMemoryPool() == MemoryPool::LocalMemory) {
|
||||
EXPECT_EQ(allocation->getUnderlyingBufferSize(), memoryManager.internalLocalMemoryUsageBankSelector[allocation->getRootDeviceIndex()]->getOccupiedMemorySizeForBank(0));
|
||||
EXPECT_EQ(memoryManager.getLocalMemoryUsageBankSelector(allocation->getAllocationType(), allocation->getRootDeviceIndex()), memoryManager.internalLocalMemoryUsageBankSelector[allocation->getRootDeviceIndex()].get());
|
||||
}
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
|
||||
EXPECT_EQ(0u, memoryManager.externalLocalMemoryUsageBankSelector[mockRootDeviceIndex]->getOccupiedMemorySizeForBank(0));
|
||||
EXPECT_EQ(0u, memoryManager.internalLocalMemoryUsageBankSelector[mockRootDeviceIndex]->getOccupiedMemorySizeForBank(0));
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenExternalAllocationTypeWhenIsAllocatedInDevicePoolThenIntenalUsageBankSelectorIsUpdated) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
|
||||
AllocationProperties allocProperties(mockRootDeviceIndex, MemoryConstants::pageSize, AllocationType::BUFFER, mockDeviceBitfield);
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInPreferredPool(allocProperties, nullptr);
|
||||
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(0u, memoryManager.internalLocalMemoryUsageBankSelector[allocation->getRootDeviceIndex()]->getOccupiedMemorySizeForBank(0));
|
||||
|
||||
if (allocation->getMemoryPool() == MemoryPool::LocalMemory) {
|
||||
EXPECT_EQ(allocation->getUnderlyingBufferSize(), memoryManager.externalLocalMemoryUsageBankSelector[allocation->getRootDeviceIndex()]->getOccupiedMemorySizeForBank(0));
|
||||
EXPECT_EQ(memoryManager.getLocalMemoryUsageBankSelector(allocation->getAllocationType(), allocation->getRootDeviceIndex()), memoryManager.externalLocalMemoryUsageBankSelector[allocation->getRootDeviceIndex()].get());
|
||||
}
|
||||
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
|
||||
EXPECT_EQ(0u, memoryManager.externalLocalMemoryUsageBankSelector[mockRootDeviceIndex]->getOccupiedMemorySizeForBank(0));
|
||||
EXPECT_EQ(0u, memoryManager.internalLocalMemoryUsageBankSelector[mockRootDeviceIndex]->getOccupiedMemorySizeForBank(0));
|
||||
}
|
||||
464
shared/test/unit_test/memory_manager/storage_info_tests.cpp
Normal file
464
shared/test/unit_test/memory_manager/storage_info_tests.cpp
Normal file
@@ -0,0 +1,464 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||
#include "shared/source/command_stream/linear_stream.h"
|
||||
#include "shared/source/device/root_device.h"
|
||||
#include "shared/source/device/sub_device.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/ult_hw_config.h"
|
||||
#include "shared/test/common/helpers/variable_backup.h"
|
||||
#include "shared/test/common/libult/ult_command_stream_receiver.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
struct MultiDeviceStorageInfoTest : public ::testing::Test {
|
||||
void SetUp() override {
|
||||
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
||||
DebugManager.flags.CreateMultipleSubDevices.set(numDevices);
|
||||
DebugManager.flags.EnableLocalMemory.set(true);
|
||||
memoryManager = static_cast<MockMemoryManager *>(factory.rootDevices[0]->getMemoryManager());
|
||||
}
|
||||
const uint32_t numDevices = 4u;
|
||||
const DeviceBitfield allTilesMask{maxNBitValue(4u)};
|
||||
const uint32_t tileIndex = 2u;
|
||||
const DeviceBitfield singleTileMask{static_cast<uint32_t>(1u << tileIndex)};
|
||||
DebugManagerStateRestore restorer;
|
||||
UltDeviceFactory factory{1, numDevices};
|
||||
VariableBackup<UltHwConfig> backup{&ultHwConfig};
|
||||
MockMemoryManager *memoryManager;
|
||||
};
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenEnabledFlagForMultiTileIsaPlacementWhenCreatingStorageInfoForKernelIsaThenAllMemoryBanksAreOnAndPageTableClonningIsNotRequired) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.MultiTileIsaPlacement.set(1);
|
||||
|
||||
AllocationType isaTypes[] = {AllocationType::KERNEL_ISA, AllocationType::KERNEL_ISA_INTERNAL};
|
||||
|
||||
for (uint32_t i = 0; i < 2; i++) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 0u, isaTypes[i], false, false, singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_FALSE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.memoryBanks);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.pageTablesVisibility);
|
||||
EXPECT_TRUE(storageInfo.tileInstanced);
|
||||
|
||||
properties.flags.multiOsContextCapable = true;
|
||||
auto storageInfo2 = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_FALSE(storageInfo2.cloningOfPageTables);
|
||||
EXPECT_EQ(allTilesMask, storageInfo2.memoryBanks);
|
||||
EXPECT_EQ(allTilesMask, storageInfo2.pageTablesVisibility);
|
||||
EXPECT_TRUE(storageInfo2.tileInstanced);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenDefaultFlagForMultiTileIsaPlacementWhenCreatingStorageInfoForKernelIsaThenSingleMemoryBanksIsOnAndPageTableClonningIsRequired) {
|
||||
|
||||
AllocationType isaTypes[] = {AllocationType::KERNEL_ISA, AllocationType::KERNEL_ISA_INTERNAL};
|
||||
|
||||
for (uint32_t i = 0; i < 2; i++) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 0u, isaTypes[i], false, false, singleTileMask};
|
||||
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_TRUE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_EQ(singleTileMask, storageInfo.memoryBanks);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.pageTablesVisibility);
|
||||
EXPECT_FALSE(storageInfo.tileInstanced);
|
||||
|
||||
properties.flags.multiOsContextCapable = true;
|
||||
auto storageInfo2 = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_TRUE(storageInfo2.cloningOfPageTables);
|
||||
EXPECT_EQ(singleTileMask, storageInfo2.memoryBanks);
|
||||
EXPECT_EQ(allTilesMask, storageInfo2.pageTablesVisibility);
|
||||
EXPECT_FALSE(storageInfo2.tileInstanced);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenDisabledFlagForMultiTileIsaPlacementWhenCreatingStorageInfoForKernelIsaThenSingleMemoryBanksIsOnAndPageTableClonningIsRequired) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.MultiTileIsaPlacement.set(0);
|
||||
|
||||
AllocationType isaTypes[] = {AllocationType::KERNEL_ISA, AllocationType::KERNEL_ISA_INTERNAL};
|
||||
|
||||
for (uint32_t i = 0; i < 2; i++) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 0u, isaTypes[i], false, false, singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_TRUE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_EQ(singleTileMask, storageInfo.memoryBanks.to_ulong());
|
||||
EXPECT_EQ(allTilesMask, storageInfo.pageTablesVisibility);
|
||||
EXPECT_FALSE(storageInfo.tileInstanced);
|
||||
|
||||
properties.flags.multiOsContextCapable = true;
|
||||
auto storageInfo2 = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_TRUE(storageInfo2.cloningOfPageTables);
|
||||
EXPECT_EQ(singleTileMask, storageInfo2.memoryBanks.to_ulong());
|
||||
EXPECT_EQ(allTilesMask, storageInfo.pageTablesVisibility);
|
||||
EXPECT_FALSE(storageInfo2.tileInstanced);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, whenCreatingStorageInfoForPrivateSurfaceWithOneTileThenOnlySingleBankIsUsed) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 0u, AllocationType::PRIVATE_SURFACE, false, false, singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_FALSE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_EQ(singleTileMask, storageInfo.memoryBanks);
|
||||
EXPECT_EQ(singleTileMask, storageInfo.pageTablesVisibility);
|
||||
EXPECT_FALSE(storageInfo.tileInstanced);
|
||||
EXPECT_EQ(1u, storageInfo.getNumBanks());
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, whenCreatingStorageInfoForPrivateSurfaceThenAllMemoryBanksAreOnAndPageTableClonningIsNotRequired) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 0u, AllocationType::PRIVATE_SURFACE, false, false, allTilesMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_FALSE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.memoryBanks);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.pageTablesVisibility);
|
||||
EXPECT_TRUE(storageInfo.tileInstanced);
|
||||
EXPECT_EQ(4u, storageInfo.getNumBanks());
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenMultiTileCsrWhenCreatingStorageInfoForInternalHeapThenSingleMemoryBankIsOnAndPageTableClonningIsRequired) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 0u, AllocationType::INTERNAL_HEAP, true, false, singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_TRUE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_EQ(singleTileMask, storageInfo.memoryBanks);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.pageTablesVisibility);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenSingleTileCsrWhenCreatingStorageInfoForInternalHeapThenSingleMemoryBankIsOnAndPageTableClonningIsNotRequired) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 0u, AllocationType::INTERNAL_HEAP, false, false, singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_FALSE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_EQ(singleTileMask, storageInfo.memoryBanks);
|
||||
EXPECT_EQ(singleTileMask, storageInfo.pageTablesVisibility);
|
||||
EXPECT_FALSE(storageInfo.tileInstanced);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenMultiTileCsrWhenCreatingStorageInfoForLinearStreamThenSingleMemoryBankIsOnAndPageTableClonningIsRequired) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 0u, AllocationType::LINEAR_STREAM, true, false, singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_TRUE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_EQ(singleTileMask, storageInfo.memoryBanks);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.pageTablesVisibility);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenSingleTileCsrWhenCreatingStorageInfoForLinearStreamThenSingleMemoryBankIsOnAndPageTableClonningIsNotRequired) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 0u, AllocationType::LINEAR_STREAM, false, false, singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_FALSE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_EQ(singleTileMask, storageInfo.memoryBanks);
|
||||
EXPECT_EQ(singleTileMask, storageInfo.pageTablesVisibility);
|
||||
EXPECT_FALSE(storageInfo.tileInstanced);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenMultiTileCsrWhenCreatingStorageInfoForCommandBufferThenSingleMemoryBankIsOnAndPageTableClonningIsRequired) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 0u, AllocationType::COMMAND_BUFFER, true, false, singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_TRUE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_EQ(singleTileMask, storageInfo.memoryBanks);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.pageTablesVisibility);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenSingleTileCsrWhenCreatingStorageInfoForCommandBufferThenSingleMemoryBankIsOnAndPageTableClonningIsNotRequired) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 0u, AllocationType::COMMAND_BUFFER, false, false, singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_FALSE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_FALSE(storageInfo.tileInstanced);
|
||||
EXPECT_EQ(singleTileMask, storageInfo.memoryBanks);
|
||||
EXPECT_EQ(singleTileMask, storageInfo.pageTablesVisibility);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenMultiTileCsrWhenCreatingStorageInfoForScratchSpaceThenAllMemoryBankAreOnAndPageTableClonningIsNotRequired) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 0u, AllocationType::SCRATCH_SURFACE, true, false, singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_FALSE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_TRUE(storageInfo.tileInstanced);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.memoryBanks);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.pageTablesVisibility);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenSingleTileCsrWhenCreatingStorageInfoForScratchSpaceThenSingleMemoryBankIsOnAndPageTableClonningIsRequired) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 0u, AllocationType::SCRATCH_SURFACE, false, false, singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_TRUE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_EQ(singleTileMask, storageInfo.memoryBanks);
|
||||
EXPECT_EQ(singleTileMask, storageInfo.pageTablesVisibility);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenMultiTileCsrWhenCreatingStorageInfoForPreemptionAllocationThenAllMemoryBankAreOnAndPageTableClonningIsNotRequired) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 0u, AllocationType::PREEMPTION, true, false, singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_FALSE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_TRUE(storageInfo.tileInstanced);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.memoryBanks);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.pageTablesVisibility);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenSingleTileCsrWhenCreatingStorageInfoForPreemptionAllocationThenSingleMemoryBankIsOnAndPageTableClonningIsRequired) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 0u, AllocationType::PREEMPTION, false, false, singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_TRUE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_EQ(singleTileMask, storageInfo.memoryBanks);
|
||||
EXPECT_EQ(singleTileMask, storageInfo.pageTablesVisibility);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, whenCreatingStorageInfoForWorkPartitionSurfaceThenAllMemoryBankAreOnAndPageTableClonningIsNotRequired) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 0u, AllocationType::WORK_PARTITION_SURFACE, true, false, singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_FALSE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_TRUE(storageInfo.tileInstanced);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.memoryBanks);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.pageTablesVisibility);
|
||||
}
|
||||
|
||||
HWTEST_F(MultiDeviceStorageInfoTest, givenSingleTileCsrWhenAllocatingCsrSpecificAllocationsThenStoreThemInSystemMemory) {
|
||||
auto commandStreamReceiver = static_cast<UltCommandStreamReceiver<FamilyType> *>(factory.rootDevices[0]->getSubDevice(tileIndex)->getDefaultEngine().commandStreamReceiver);
|
||||
auto &heap = commandStreamReceiver->getIndirectHeap(IndirectHeap::Type::INDIRECT_OBJECT, MemoryConstants::pageSize64k);
|
||||
auto heapAllocation = heap.getGraphicsAllocation();
|
||||
if (commandStreamReceiver->canUse4GbHeaps) {
|
||||
EXPECT_EQ(AllocationType::INTERNAL_HEAP, heapAllocation->getAllocationType());
|
||||
} else {
|
||||
EXPECT_EQ(AllocationType::LINEAR_STREAM, heapAllocation->getAllocationType());
|
||||
}
|
||||
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(heap, heap.getAvailableSpace() + 1, 0u);
|
||||
auto commandBufferAllocation = heap.getGraphicsAllocation();
|
||||
EXPECT_EQ(AllocationType::COMMAND_BUFFER, commandBufferAllocation->getAllocationType());
|
||||
EXPECT_NE(heapAllocation, commandBufferAllocation);
|
||||
EXPECT_NE(commandBufferAllocation->getMemoryPool(), MemoryPool::LocalMemory);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, whenCreatingStorageInfoForBufferCompressedThenAllMemoryBanksAreOnAndPageTableClonningIsRequired) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, numDevices * MemoryConstants::pageSize64k, AllocationType::BUFFER, true, allTilesMask};
|
||||
properties.flags.preferCompressed = true;
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_TRUE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.memoryBanks);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.pageTablesVisibility);
|
||||
EXPECT_TRUE(storageInfo.multiStorage);
|
||||
EXPECT_EQ(storageInfo.colouringGranularity, MemoryConstants::pageSize64k);
|
||||
EXPECT_EQ(storageInfo.colouringPolicy, ColouringPolicy::DeviceCountBased);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, whenCreatingStorageInfoForBufferThenAllMemoryBanksAreOnAndPageTableClonningIsRequired) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, numDevices * MemoryConstants::pageSize64k, AllocationType::BUFFER, true, allTilesMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_TRUE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.memoryBanks);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.pageTablesVisibility);
|
||||
EXPECT_TRUE(storageInfo.multiStorage);
|
||||
EXPECT_EQ(storageInfo.colouringGranularity, MemoryConstants::pageSize64k);
|
||||
EXPECT_EQ(storageInfo.colouringPolicy, ColouringPolicy::DeviceCountBased);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, whenCreatingStorageInfoForSVMGPUThenAllMemoryBanksAreOnAndPageTableClonningIsRequired) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, numDevices * MemoryConstants::pageSize64k, AllocationType::SVM_GPU, true, allTilesMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_TRUE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.memoryBanks);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.pageTablesVisibility);
|
||||
EXPECT_TRUE(storageInfo.multiStorage);
|
||||
EXPECT_EQ(storageInfo.colouringGranularity, MemoryConstants::pageSize64k);
|
||||
EXPECT_EQ(storageInfo.colouringPolicy, ColouringPolicy::DeviceCountBased);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenMultiStorageGranularityWhenCreatingStorageInfoThenProperGranularityIsSet) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.MultiStorageGranularity.set(128);
|
||||
DebugManager.flags.MultiStoragePolicy.set(1);
|
||||
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 10 * MemoryConstants::pageSize64k, AllocationType::SVM_GPU, true, allTilesMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_TRUE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.memoryBanks);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.pageTablesVisibility);
|
||||
EXPECT_TRUE(storageInfo.multiStorage);
|
||||
EXPECT_EQ(storageInfo.colouringGranularity, MemoryConstants::kiloByte * 128);
|
||||
EXPECT_EQ(storageInfo.colouringPolicy, ColouringPolicy::ChunkSizeBased);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenTwoPagesAllocationSizeWhenCreatingStorageInfoForBufferThenSingleMemoryBankIsOnAndPageTableClonningIsRequired) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 2 * MemoryConstants::pageSize64k, AllocationType::BUFFER, true, allTilesMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_TRUE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_EQ(1lu, storageInfo.memoryBanks.to_ulong());
|
||||
EXPECT_EQ(allTilesMask, storageInfo.pageTablesVisibility);
|
||||
EXPECT_FALSE(storageInfo.multiStorage);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenSpecifiedDeviceIndexWhenCreatingStorageInfoForBufferThenSingleMemoryBankIsOnAndPageTableClonningIsRequired) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, numDevices * MemoryConstants::pageSize64k, AllocationType::BUFFER, true, false, singleTileMask};
|
||||
properties.multiStorageResource = true;
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_TRUE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_EQ(singleTileMask, storageInfo.memoryBanks);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.pageTablesVisibility);
|
||||
EXPECT_FALSE(storageInfo.multiStorage);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenResourceColouringNotSupportedWhenCreatingStorageInfoForBufferThenSingleMemoryBankIsOnAndPageTableClonningIsRequired) {
|
||||
memoryManager->supportsMultiStorageResources = false;
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, numDevices * MemoryConstants::pageSize64k, AllocationType::BUFFER, true, singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_TRUE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_EQ(1lu, storageInfo.memoryBanks.count());
|
||||
EXPECT_EQ(allTilesMask, storageInfo.pageTablesVisibility);
|
||||
EXPECT_FALSE(storageInfo.multiStorage);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenNonMultiStorageResourceWhenCreatingStorageInfoForBufferThenSingleMemoryBankIsOnAndPageTableClonningIsRequired) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, numDevices * MemoryConstants::pageSize64k, AllocationType::BUFFER, false, singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_TRUE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_EQ(1lu, storageInfo.memoryBanks.count());
|
||||
EXPECT_EQ(allTilesMask, storageInfo.pageTablesVisibility);
|
||||
EXPECT_FALSE(storageInfo.multiStorage);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, whenCreatingStorageInfoForBufferThenLocalOnlyFlagIsRequired) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, numDevices * MemoryConstants::pageSize64k, AllocationType::BUFFER, false, singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_TRUE(storageInfo.localOnlyRequired);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, whenCreatingStorageInfoForBufferCompressedThenLocalOnlyFlagIsRequired) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, numDevices * MemoryConstants::pageSize64k, AllocationType::BUFFER, false, singleTileMask};
|
||||
properties.flags.preferCompressed = true;
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_TRUE(storageInfo.localOnlyRequired);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, whenCreatingStorageInfoForSvmGpuThenLocalOnlyFlagIsRequired) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, numDevices * MemoryConstants::pageSize64k, AllocationType::SVM_GPU, false, singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_TRUE(storageInfo.localOnlyRequired);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, whenCreatingStorageInfoForShareableSvmGpuThenLocalOnlyFlagIsRequiredAndIsNotLocable) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, numDevices * MemoryConstants::pageSize64k, AllocationType::SVM_GPU, false, singleTileMask};
|
||||
properties.flags.shareable = 1u;
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_TRUE(storageInfo.localOnlyRequired);
|
||||
EXPECT_FALSE(storageInfo.isLockable);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenReadOnlyBufferToBeCopiedAcrossTilesWhenCreatingStorageInfoThenCorrectValuesAreSet) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 1u, AllocationType::BUFFER, false, singleTileMask};
|
||||
properties.flags.readOnlyMultiStorage = true;
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.memoryBanks);
|
||||
EXPECT_FALSE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_TRUE(storageInfo.readOnlyMultiStorage);
|
||||
EXPECT_TRUE(storageInfo.tileInstanced);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenReadOnlyBufferToBeCopiedAcrossTilesWhenDebugVariableIsSetThenOnlyCertainBanksAreUsed) {
|
||||
DebugManagerStateRestore restorer;
|
||||
auto proposedTiles = allTilesMask;
|
||||
proposedTiles[1] = 0;
|
||||
|
||||
DebugManager.flags.OverrideMultiStoragePlacement.set(proposedTiles.to_ulong());
|
||||
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 64 * KB * 40, AllocationType::BUFFER, true, allTilesMask};
|
||||
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_EQ(proposedTiles, storageInfo.memoryBanks);
|
||||
EXPECT_TRUE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_FALSE(storageInfo.tileInstanced);
|
||||
EXPECT_EQ(3u, storageInfo.getNumBanks());
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenLeastOccupiedBankAndOtherBitsEnabledInSubDeviceBitfieldWhenCreateStorageInfoThenTakeLeastOccupiedBankAsMemoryBank) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 1u, AllocationType::UNKNOWN, false, singleTileMask};
|
||||
auto leastOccupiedBank = memoryManager->getLocalMemoryUsageBankSelector(properties.allocationType, properties.rootDeviceIndex)->getLeastOccupiedBank(properties.subDevicesBitfield);
|
||||
properties.subDevicesBitfield.set(leastOccupiedBank);
|
||||
properties.subDevicesBitfield.set(leastOccupiedBank + 1);
|
||||
EXPECT_EQ(2u, properties.subDevicesBitfield.count());
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_EQ(1u, storageInfo.memoryBanks.count());
|
||||
EXPECT_TRUE(storageInfo.memoryBanks.test(leastOccupiedBank));
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenNoSubdeviceBitfieldWhenCreateStorageInfoThenReturnEmptyStorageInfo) {
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 1u, AllocationType::UNKNOWN, false, {}};
|
||||
StorageInfo emptyInfo{};
|
||||
EXPECT_EQ(memoryManager->createStorageInfoFromProperties(properties).getMemoryBanks(), emptyInfo.getMemoryBanks());
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenGraphicsAllocationWithCpuAccessRequiredWhenCreatingStorageInfoThenSetCpuVisibleSegmentIsRequiredAndIsLockableFlagIsEnabled) {
|
||||
auto firstAllocationIdx = static_cast<int>(AllocationType::UNKNOWN);
|
||||
auto lastAllocationIdx = static_cast<int>(AllocationType::COUNT);
|
||||
|
||||
for (int allocationIdx = firstAllocationIdx; allocationIdx != lastAllocationIdx; allocationIdx++) {
|
||||
auto allocationType = static_cast<AllocationType>(allocationIdx);
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 1u, allocationType, false, singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
if (GraphicsAllocation::isCpuAccessRequired(properties.allocationType)) {
|
||||
EXPECT_TRUE(storageInfo.cpuVisibleSegment);
|
||||
EXPECT_TRUE(storageInfo.isLockable);
|
||||
} else {
|
||||
EXPECT_FALSE(storageInfo.cpuVisibleSegment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenGraphicsAllocationThatIsLockableWhenCreatingStorageInfoThenIsLockableFlagIsEnabled) {
|
||||
auto firstAllocationIdx = static_cast<int>(AllocationType::UNKNOWN);
|
||||
auto lastAllocationIdx = static_cast<int>(AllocationType::COUNT);
|
||||
|
||||
for (int allocationIdx = firstAllocationIdx; allocationIdx != lastAllocationIdx; allocationIdx++) {
|
||||
auto allocationType = static_cast<AllocationType>(allocationIdx);
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 1u, allocationType, false, singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
if (GraphicsAllocation::isLockable(properties.allocationType)) {
|
||||
EXPECT_TRUE(storageInfo.isLockable);
|
||||
} else {
|
||||
EXPECT_FALSE(storageInfo.isLockable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenGpuTimestampAllocationWhenUsingSingleTileDeviceThenExpectRegularAllocationStorageInfo) {
|
||||
AllocationProperties properties{mockRootDeviceIndex,
|
||||
false,
|
||||
1u,
|
||||
AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER,
|
||||
singleTileMask.count() > 1u,
|
||||
false,
|
||||
singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
EXPECT_EQ(singleTileMask, storageInfo.memoryBanks);
|
||||
EXPECT_TRUE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_FALSE(storageInfo.tileInstanced);
|
||||
EXPECT_EQ(singleTileMask, storageInfo.pageTablesVisibility);
|
||||
}
|
||||
|
||||
TEST_F(MultiDeviceStorageInfoTest,
|
||||
givenGpuTimestampAllocationWhenUsingMultiTileDeviceThenExpectColoringAndCloningPagesAllocationStorageInfo) {
|
||||
AllocationProperties properties{mockRootDeviceIndex,
|
||||
false,
|
||||
1u,
|
||||
AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER,
|
||||
allTilesMask.count() > 1u,
|
||||
false,
|
||||
allTilesMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
|
||||
auto leastOccupiedBank = memoryManager->getLocalMemoryUsageBankSelector(properties.allocationType, properties.rootDeviceIndex)->getLeastOccupiedBank(properties.subDevicesBitfield);
|
||||
DeviceBitfield allocationMask;
|
||||
allocationMask.set(leastOccupiedBank);
|
||||
|
||||
EXPECT_EQ(allocationMask, storageInfo.memoryBanks);
|
||||
EXPECT_TRUE(storageInfo.cloningOfPageTables);
|
||||
EXPECT_FALSE(storageInfo.tileInstanced);
|
||||
EXPECT_EQ(allTilesMask, storageInfo.pageTablesVisibility);
|
||||
}
|
||||
Reference in New Issue
Block a user