|
|
|
@ -148,6 +148,7 @@ struct SvmAllocationCacheTestFixture {
|
|
|
|
|
void tearDown() {
|
|
|
|
|
}
|
|
|
|
|
static constexpr size_t allocationSizeBasis = MemoryConstants::pageSize64k;
|
|
|
|
|
static constexpr uint64_t alwaysLimited = 0u;
|
|
|
|
|
MockExecutionEnvironment executionEnvironment;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -166,11 +167,11 @@ TEST_F(SvmDeviceAllocationCacheTest, givenAllocationCacheDisabledWhenCheckingIfE
|
|
|
|
|
|
|
|
|
|
TEST_F(SvmDeviceAllocationCacheTest, givenAllocationCacheEnabledAndMaxSizeZeroWhenCallingCleanupThenNoError) {
|
|
|
|
|
DebugManagerStateRestore restorer;
|
|
|
|
|
debugManager.flags.ExperimentalEnableDeviceAllocationCache.set(1);
|
|
|
|
|
std::unique_ptr<UltDeviceFactory> deviceFactory(new UltDeviceFactory(1, 1));
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(device->getMemoryManager(), false);
|
|
|
|
|
debugManager.flags.ExperimentalEnableDeviceAllocationCache.set(1);
|
|
|
|
|
device->maxAllocationsSavedForReuseSize = 0u;
|
|
|
|
|
device->usmReuseInfo.init(0, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
EXPECT_NE(nullptr, svmManager->usmDeviceAllocationsCache);
|
|
|
|
|
svmManager->cleanupUSMAllocCaches();
|
|
|
|
@ -185,8 +186,8 @@ HWTEST_F(SvmDeviceAllocationCacheTest, givenOclApiSpecificConfigWhenCheckingIfEn
|
|
|
|
|
device->mockAilConfigurationHelper = &mockAilConfigurationHelper;
|
|
|
|
|
{
|
|
|
|
|
raii.mockProductHelper->isDeviceUsmAllocationReuseSupportedResult = false;
|
|
|
|
|
device->initUsmReuseMaxSize();
|
|
|
|
|
EXPECT_EQ(0u, device->getMaxAllocationsSavedForReuseSize());
|
|
|
|
|
device->initUsmReuseLimits();
|
|
|
|
|
EXPECT_EQ(0u, device->usmReuseInfo.getMaxAllocationsSavedForReuseSize());
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(device->getMemoryManager(), false);
|
|
|
|
|
EXPECT_EQ(nullptr, svmManager->usmDeviceAllocationsCache);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
@ -194,23 +195,23 @@ HWTEST_F(SvmDeviceAllocationCacheTest, givenOclApiSpecificConfigWhenCheckingIfEn
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
raii.mockProductHelper->isDeviceUsmAllocationReuseSupportedResult = true;
|
|
|
|
|
device->initUsmReuseMaxSize();
|
|
|
|
|
device->initUsmReuseLimits();
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(device->getMemoryManager(), false);
|
|
|
|
|
EXPECT_EQ(nullptr, svmManager->usmDeviceAllocationsCache);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
EXPECT_NE(nullptr, svmManager->usmDeviceAllocationsCache);
|
|
|
|
|
const auto expectedMaxSize = static_cast<size_t>(0.08 * device->getGlobalMemorySize(static_cast<uint32_t>(device->getDeviceBitfield().to_ullong())));
|
|
|
|
|
EXPECT_EQ(expectedMaxSize, device->getMaxAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(expectedMaxSize, device->usmReuseInfo.getMaxAllocationsSavedForReuseSize());
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
raii.mockProductHelper->isDeviceUsmAllocationReuseSupportedResult = true;
|
|
|
|
|
mockAilConfigurationHelper.limitAmountOfDeviceMemoryForRecyclingReturn = true;
|
|
|
|
|
device->initUsmReuseMaxSize();
|
|
|
|
|
device->initUsmReuseLimits();
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(device->getMemoryManager(), false);
|
|
|
|
|
EXPECT_EQ(nullptr, svmManager->usmDeviceAllocationsCache);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
EXPECT_NE(nullptr, svmManager->usmDeviceAllocationsCache);
|
|
|
|
|
EXPECT_EQ(0u, device->getMaxAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, device->usmReuseInfo.getMaxAllocationsSavedForReuseSize());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -231,6 +232,36 @@ TEST_F(SvmDeviceAllocationCacheTest, givenAllocationCacheEnabledWhenDirectSubmis
|
|
|
|
|
EXPECT_FALSE(device->getExecutionEnvironment()->unifiedMemoryReuseCleaner.get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(SvmDeviceAllocationCacheTest, givenReuseLimitFlagWhenInitUsmReuseLimitCalledThenLimitThresholdSetCorrectly) {
|
|
|
|
|
std::unique_ptr<UltDeviceFactory> deviceFactory(new UltDeviceFactory(1, 1));
|
|
|
|
|
RootDeviceIndicesContainer rootDeviceIndices = {mockRootDeviceIndex};
|
|
|
|
|
std::map<uint32_t, DeviceBitfield> deviceBitfields{{mockRootDeviceIndex, mockDeviceBitfield}};
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
DebugManagerStateRestore restore;
|
|
|
|
|
debugManager.flags.ExperimentalUSMAllocationReuseLimitThreshold.set(0);
|
|
|
|
|
device->initUsmReuseLimits();
|
|
|
|
|
const auto expectedLimitThreshold = std::numeric_limits<uint64_t>::max();
|
|
|
|
|
EXPECT_EQ(expectedLimitThreshold, device->usmReuseInfo.getLimitAllocationsReuseThreshold());
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
DebugManagerStateRestore restore;
|
|
|
|
|
debugManager.flags.ExperimentalUSMAllocationReuseLimitThreshold.set(80);
|
|
|
|
|
device->initUsmReuseLimits();
|
|
|
|
|
const auto totalDeviceMemory = device->getGlobalMemorySize(static_cast<uint32_t>(device->getDeviceBitfield().to_ulong()));
|
|
|
|
|
const auto expectedLimitThreshold = static_cast<uint64_t>(0.8 * totalDeviceMemory);
|
|
|
|
|
EXPECT_EQ(expectedLimitThreshold, device->usmReuseInfo.getLimitAllocationsReuseThreshold());
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
DebugManagerStateRestore restore;
|
|
|
|
|
debugManager.flags.ExperimentalUSMAllocationReuseLimitThreshold.set(-1);
|
|
|
|
|
device->initUsmReuseLimits();
|
|
|
|
|
const auto expectedLimitThreshold = std::numeric_limits<uint64_t>::max();
|
|
|
|
|
EXPECT_EQ(expectedLimitThreshold, device->usmReuseInfo.getLimitAllocationsReuseThreshold());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct SvmDeviceAllocationCacheSimpleTestDataType {
|
|
|
|
|
size_t allocationSize;
|
|
|
|
|
void *allocation;
|
|
|
|
@ -244,7 +275,7 @@ TEST_F(SvmDeviceAllocationCacheTest, givenAllocationCacheEnabledWhenFreeingDevic
|
|
|
|
|
debugManager.flags.ExperimentalEnableDeviceAllocationCache.set(1);
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(device->getMemoryManager(), false);
|
|
|
|
|
device->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
device->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
ASSERT_NE(nullptr, svmManager->usmDeviceAllocationsCache);
|
|
|
|
|
|
|
|
|
@ -294,7 +325,7 @@ TEST_F(SvmDeviceAllocationCacheTest, givenAllocationCacheEnabledWhenInitializedT
|
|
|
|
|
ASSERT_NE(nullptr, svmManager->usmDeviceAllocationsCache);
|
|
|
|
|
|
|
|
|
|
auto expectedMaxSize = static_cast<uint64_t>(device->getGlobalMemorySize(static_cast<uint32_t>(mockDeviceBitfield.to_ulong())) * 0.02);
|
|
|
|
|
EXPECT_EQ(expectedMaxSize, device->getMaxAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(expectedMaxSize, device->usmReuseInfo.getMaxAllocationsSavedForReuseSize());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(SvmDeviceAllocationCacheTest, givenAllocationCacheEnabledWhenFreeingDeviceAllocationThenItIsPutIntoCacheOnlyIfMaxSizeWillNotBeExceeded) {
|
|
|
|
@ -306,7 +337,7 @@ TEST_F(SvmDeviceAllocationCacheTest, givenAllocationCacheEnabledWhenFreeingDevic
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(device->getMemoryManager(), false);
|
|
|
|
|
constexpr auto allocationSize = MemoryConstants::pageSize64k;
|
|
|
|
|
device->maxAllocationsSavedForReuseSize = allocationSize;
|
|
|
|
|
device->usmReuseInfo.init(allocationSize, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
ASSERT_NE(nullptr, svmManager->usmDeviceAllocationsCache);
|
|
|
|
|
|
|
|
|
@ -318,26 +349,26 @@ TEST_F(SvmDeviceAllocationCacheTest, givenAllocationCacheEnabledWhenFreeingDevic
|
|
|
|
|
auto allocation2 = svmManager->createUnifiedMemoryAllocation(allocationSize, unifiedMemoryProperties);
|
|
|
|
|
ASSERT_NE(allocation2, nullptr);
|
|
|
|
|
EXPECT_EQ(0u, svmManager->usmDeviceAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(0u, device->getAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, device->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
svmManager->freeSVMAlloc(allocation);
|
|
|
|
|
EXPECT_EQ(1u, svmManager->usmDeviceAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(allocationSize, device->getAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(allocationSize, device->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
svmManager->freeSVMAlloc(allocation2);
|
|
|
|
|
EXPECT_EQ(1u, svmManager->usmDeviceAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(allocationSize, device->getAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(allocationSize, device->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
auto recycledAllocation = svmManager->createUnifiedMemoryAllocation(allocationSize, unifiedMemoryProperties);
|
|
|
|
|
EXPECT_EQ(recycledAllocation, allocation);
|
|
|
|
|
EXPECT_EQ(svmManager->usmDeviceAllocationsCache->allocations.size(), 0u);
|
|
|
|
|
EXPECT_EQ(0u, device->getAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, device->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
svmManager->freeSVMAlloc(recycledAllocation);
|
|
|
|
|
|
|
|
|
|
svmManager->trimUSMDeviceAllocCache();
|
|
|
|
|
EXPECT_EQ(svmManager->usmDeviceAllocationsCache->allocations.size(), 0u);
|
|
|
|
|
EXPECT_EQ(0u, device->getAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, device->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
auto allocation = svmManager->createUnifiedMemoryAllocation(allocationSize, unifiedMemoryProperties);
|
|
|
|
@ -345,26 +376,26 @@ TEST_F(SvmDeviceAllocationCacheTest, givenAllocationCacheEnabledWhenFreeingDevic
|
|
|
|
|
auto allocation2 = svmManager->createUnifiedMemoryAllocation(allocationSize, unifiedMemoryProperties);
|
|
|
|
|
ASSERT_NE(allocation2, nullptr);
|
|
|
|
|
EXPECT_EQ(0u, svmManager->usmDeviceAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(0u, device->getAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, device->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
svmManager->freeSVMAllocDefer(allocation);
|
|
|
|
|
EXPECT_EQ(1u, svmManager->usmDeviceAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(allocationSize, device->getAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(allocationSize, device->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
svmManager->freeSVMAllocDefer(allocation2);
|
|
|
|
|
EXPECT_EQ(1u, svmManager->usmDeviceAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(allocationSize, device->getAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(allocationSize, device->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
auto recycledAllocation = svmManager->createUnifiedMemoryAllocation(allocationSize, unifiedMemoryProperties);
|
|
|
|
|
EXPECT_EQ(recycledAllocation, allocation);
|
|
|
|
|
EXPECT_EQ(svmManager->usmDeviceAllocationsCache->allocations.size(), 0u);
|
|
|
|
|
EXPECT_EQ(0u, device->getAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, device->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
svmManager->freeSVMAllocDefer(recycledAllocation);
|
|
|
|
|
|
|
|
|
|
svmManager->trimUSMDeviceAllocCache();
|
|
|
|
|
EXPECT_EQ(svmManager->usmDeviceAllocationsCache->allocations.size(), 0u);
|
|
|
|
|
EXPECT_EQ(0u, device->getAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, device->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -378,7 +409,7 @@ TEST_F(SvmDeviceAllocationCacheTest, givenAllocationCacheEnabledAndMultipleSVMMa
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(device->getMemoryManager(), false);
|
|
|
|
|
auto secondSvmManager = std::make_unique<MockSVMAllocsManager>(device->getMemoryManager(), false);
|
|
|
|
|
constexpr auto allocationSize = MemoryConstants::pageSize64k;
|
|
|
|
|
device->maxAllocationsSavedForReuseSize = allocationSize;
|
|
|
|
|
device->usmReuseInfo.init(allocationSize, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
secondSvmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
ASSERT_NE(nullptr, svmManager->usmDeviceAllocationsCache);
|
|
|
|
@ -394,22 +425,22 @@ TEST_F(SvmDeviceAllocationCacheTest, givenAllocationCacheEnabledAndMultipleSVMMa
|
|
|
|
|
|
|
|
|
|
svmManager->freeSVMAlloc(allocation);
|
|
|
|
|
EXPECT_EQ(1u, svmManager->usmDeviceAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(allocationSize, device->getAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(allocationSize, device->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
secondSvmManager->freeSVMAlloc(allocation2);
|
|
|
|
|
EXPECT_EQ(0u, secondSvmManager->usmDeviceAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(allocationSize, device->getAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(allocationSize, device->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
auto recycledAllocation = svmManager->createUnifiedMemoryAllocation(allocationSize, unifiedMemoryProperties);
|
|
|
|
|
EXPECT_EQ(recycledAllocation, allocation);
|
|
|
|
|
EXPECT_EQ(0u, svmManager->usmDeviceAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(0u, device->getAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, device->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
svmManager->freeSVMAlloc(recycledAllocation);
|
|
|
|
|
|
|
|
|
|
svmManager->trimUSMDeviceAllocCache();
|
|
|
|
|
EXPECT_EQ(svmManager->usmDeviceAllocationsCache->allocations.size(), 0u);
|
|
|
|
|
EXPECT_EQ(0u, device->getAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, device->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
auto allocation = svmManager->createUnifiedMemoryAllocation(allocationSize, unifiedMemoryProperties);
|
|
|
|
@ -419,22 +450,22 @@ TEST_F(SvmDeviceAllocationCacheTest, givenAllocationCacheEnabledAndMultipleSVMMa
|
|
|
|
|
|
|
|
|
|
secondSvmManager->freeSVMAlloc(allocation2);
|
|
|
|
|
EXPECT_EQ(1u, secondSvmManager->usmDeviceAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(allocationSize, device->getAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(allocationSize, device->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
svmManager->freeSVMAlloc(allocation);
|
|
|
|
|
EXPECT_EQ(0u, svmManager->usmDeviceAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(allocationSize, device->getAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(allocationSize, device->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
auto recycledAllocation = secondSvmManager->createUnifiedMemoryAllocation(allocationSize, unifiedMemoryProperties);
|
|
|
|
|
EXPECT_EQ(recycledAllocation, allocation2);
|
|
|
|
|
EXPECT_EQ(0u, secondSvmManager->usmDeviceAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(0u, device->getAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, device->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
secondSvmManager->freeSVMAlloc(recycledAllocation);
|
|
|
|
|
|
|
|
|
|
secondSvmManager->trimUSMDeviceAllocCache();
|
|
|
|
|
EXPECT_EQ(secondSvmManager->usmDeviceAllocationsCache->allocations.size(), 0u);
|
|
|
|
|
EXPECT_EQ(0u, device->getAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, device->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -446,7 +477,7 @@ TEST_F(SvmDeviceAllocationCacheTest, givenAllocationsWithDifferentSizesWhenAlloc
|
|
|
|
|
debugManager.flags.ExperimentalEnableDeviceAllocationCache.set(1);
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(device->getMemoryManager(), false);
|
|
|
|
|
device->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
device->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
ASSERT_NE(nullptr, svmManager->usmDeviceAllocationsCache);
|
|
|
|
|
|
|
|
|
@ -495,7 +526,7 @@ TEST_F(SvmDeviceAllocationCacheTest, givenAllocationWithDifferentSizeWhenAllocat
|
|
|
|
|
debugManager.flags.ExperimentalEnableDeviceAllocationCache.set(1);
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(device->getMemoryManager(), false);
|
|
|
|
|
device->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
device->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
EXPECT_NE(nullptr, svmManager->usmDeviceAllocationsCache);
|
|
|
|
|
|
|
|
|
@ -540,7 +571,7 @@ TEST_F(SvmDeviceAllocationCacheTest, givenAllocationsWithDifferentSizesWhenAlloc
|
|
|
|
|
debugManager.flags.ExperimentalEnableDeviceAllocationCache.set(1);
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(device->getMemoryManager(), false);
|
|
|
|
|
device->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
device->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
ASSERT_NE(nullptr, svmManager->usmDeviceAllocationsCache);
|
|
|
|
|
|
|
|
|
@ -580,7 +611,7 @@ TEST_F(SvmDeviceAllocationCacheTest, givenAllocationOverSizeLimitWhenAllocatingA
|
|
|
|
|
debugManager.flags.ExperimentalEnableDeviceAllocationCache.set(1);
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(device->getMemoryManager(), false);
|
|
|
|
|
device->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
device->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
ASSERT_NE(nullptr, svmManager->usmDeviceAllocationsCache);
|
|
|
|
|
const auto notAcceptedAllocSize = SVMAllocsManager::SvmAllocationCache::maxServicedSize + 1;
|
|
|
|
@ -610,7 +641,7 @@ TEST_F(SvmDeviceAllocationCacheTest, givenMultipleAllocationsWhenAllocatingAfter
|
|
|
|
|
debugManager.flags.ExperimentalEnableDeviceAllocationCache.set(1);
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(device->getMemoryManager(), false);
|
|
|
|
|
device->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
device->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
ASSERT_NE(nullptr, svmManager->usmDeviceAllocationsCache);
|
|
|
|
|
|
|
|
|
@ -688,9 +719,9 @@ TEST_F(SvmDeviceAllocationCacheTest, givenAllocationsWithDifferentFlagsWhenAlloc
|
|
|
|
|
auto secondRootDevice = deviceFactory->rootDevices[1];
|
|
|
|
|
auto subDevice1 = reinterpret_cast<MockSubDevice *>(deviceFactory->subDevices[0]);
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(rootDevice->getMemoryManager(), false);
|
|
|
|
|
rootDevice->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
secondRootDevice->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
subDevice1->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
rootDevice->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
secondRootDevice->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
subDevice1->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*rootDevice);
|
|
|
|
|
ASSERT_NE(nullptr, svmManager->usmDeviceAllocationsCache);
|
|
|
|
|
|
|
|
|
@ -763,7 +794,8 @@ TEST_F(SvmDeviceAllocationCacheTest, givenDeviceOutOfMemoryWhenAllocatingThenCac
|
|
|
|
|
device->injectMemoryManager(new MockMemoryManagerWithCapacity(*device->getExecutionEnvironment()));
|
|
|
|
|
MockMemoryManagerWithCapacity *memoryManager = static_cast<MockMemoryManagerWithCapacity *>(device->getMemoryManager());
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(memoryManager, false);
|
|
|
|
|
device->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
device->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
memoryManager->usmReuseInfo.init(0u, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
ASSERT_NE(nullptr, svmManager->usmDeviceAllocationsCache);
|
|
|
|
|
|
|
|
|
@ -801,7 +833,7 @@ TEST_F(SvmDeviceAllocationCacheTest, givenAllocationWithIsInternalAllocationSetW
|
|
|
|
|
debugManager.flags.ExperimentalEnableDeviceAllocationCache.set(1);
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(device->getMemoryManager(), false);
|
|
|
|
|
device->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
device->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
EXPECT_NE(nullptr, svmManager->usmDeviceAllocationsCache);
|
|
|
|
|
|
|
|
|
@ -833,7 +865,7 @@ TEST_F(SvmDeviceAllocationCacheTest, givenAllocationInUsageWhenAllocatingAfterFr
|
|
|
|
|
debugManager.flags.ExperimentalEnableDeviceAllocationCache.set(1);
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(device->getMemoryManager(), false);
|
|
|
|
|
device->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
device->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
EXPECT_NE(nullptr, svmManager->usmDeviceAllocationsCache);
|
|
|
|
|
|
|
|
|
@ -869,7 +901,7 @@ TEST_F(SvmDeviceAllocationCacheTest, givenUsmReuseCleanerWhenTrimOldInCachesCall
|
|
|
|
|
device->executionEnvironment->unifiedMemoryReuseCleaner.reset(new MockUnifiedMemoryReuseCleaner);
|
|
|
|
|
auto mockUnifiedMemoryReuseCleaner = reinterpret_cast<MockUnifiedMemoryReuseCleaner *>(device->executionEnvironment->unifiedMemoryReuseCleaner.get());
|
|
|
|
|
EXPECT_EQ(0u, mockUnifiedMemoryReuseCleaner->svmAllocationCaches.size());
|
|
|
|
|
device->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
device->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
EXPECT_NE(nullptr, svmManager->usmDeviceAllocationsCache);
|
|
|
|
|
EXPECT_EQ(1u, mockUnifiedMemoryReuseCleaner->svmAllocationCaches.size());
|
|
|
|
@ -910,6 +942,49 @@ TEST_F(SvmDeviceAllocationCacheTest, givenUsmReuseCleanerWhenTrimOldInCachesCall
|
|
|
|
|
EXPECT_EQ(0u, mockUnifiedMemoryReuseCleaner->svmAllocationCaches.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(SvmDeviceAllocationCacheTest, givenUsmReuseCleanerWhenTrimOldInCachesCalledAndShouldLimitUsmReuseThenAllOldAllocationsAreRemovedEvenIfDeferredDeleterHasWork) {
|
|
|
|
|
std::unique_ptr<UltDeviceFactory> deviceFactory(new UltDeviceFactory(1, 1));
|
|
|
|
|
RootDeviceIndicesContainer rootDeviceIndices = {mockRootDeviceIndex};
|
|
|
|
|
std::map<uint32_t, DeviceBitfield> deviceBitfields{{mockRootDeviceIndex, mockDeviceBitfield}};
|
|
|
|
|
DebugManagerStateRestore restore;
|
|
|
|
|
debugManager.flags.ExperimentalEnableDeviceAllocationCache.set(1);
|
|
|
|
|
debugManager.flags.ExperimentalEnableHostAllocationCache.set(0);
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
auto memoryManager = reinterpret_cast<MockMemoryManager *>(device->getMemoryManager());
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(memoryManager, false);
|
|
|
|
|
device->executionEnvironment->unifiedMemoryReuseCleaner.reset(new MockUnifiedMemoryReuseCleaner);
|
|
|
|
|
auto mockUnifiedMemoryReuseCleaner = reinterpret_cast<MockUnifiedMemoryReuseCleaner *>(device->executionEnvironment->unifiedMemoryReuseCleaner.get());
|
|
|
|
|
EXPECT_EQ(0u, mockUnifiedMemoryReuseCleaner->svmAllocationCaches.size());
|
|
|
|
|
device->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
EXPECT_NE(nullptr, svmManager->usmDeviceAllocationsCache);
|
|
|
|
|
EXPECT_EQ(1u, mockUnifiedMemoryReuseCleaner->svmAllocationCaches.size());
|
|
|
|
|
EXPECT_EQ(svmManager->usmDeviceAllocationsCache.get(), mockUnifiedMemoryReuseCleaner->svmAllocationCaches[0]);
|
|
|
|
|
|
|
|
|
|
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::deviceUnifiedMemory, 1, rootDeviceIndices, deviceBitfields);
|
|
|
|
|
unifiedMemoryProperties.device = device;
|
|
|
|
|
auto allocation = svmManager->createUnifiedMemoryAllocation(10u, unifiedMemoryProperties);
|
|
|
|
|
auto allocation2 = svmManager->createUnifiedMemoryAllocation(10u, unifiedMemoryProperties);
|
|
|
|
|
EXPECT_NE(allocation, nullptr);
|
|
|
|
|
EXPECT_NE(allocation2, nullptr);
|
|
|
|
|
svmManager->freeSVMAlloc(allocation);
|
|
|
|
|
svmManager->freeSVMAlloc(allocation2);
|
|
|
|
|
EXPECT_EQ(svmManager->usmDeviceAllocationsCache->allocations.size(), 2u);
|
|
|
|
|
|
|
|
|
|
const auto baseTimePoint = std::chrono::high_resolution_clock::now();
|
|
|
|
|
const auto oldTimePoint = baseTimePoint - UnifiedMemoryReuseCleaner::limitedHoldTime;
|
|
|
|
|
|
|
|
|
|
svmManager->usmDeviceAllocationsCache->allocations[0].saveTime = oldTimePoint;
|
|
|
|
|
svmManager->usmDeviceAllocationsCache->allocations[1].saveTime = oldTimePoint;
|
|
|
|
|
|
|
|
|
|
memoryManager->setDeferredDeleter(new MockDeferredDeleter);
|
|
|
|
|
memoryManager->usmReuseInfo.init(1 * MemoryConstants::gigaByte, alwaysLimited);
|
|
|
|
|
mockUnifiedMemoryReuseCleaner->trimOldInCaches();
|
|
|
|
|
EXPECT_EQ(0u, svmManager->usmDeviceAllocationsCache->allocations.size());
|
|
|
|
|
|
|
|
|
|
svmManager->cleanupUSMAllocCaches();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(SvmDeviceAllocationCacheTest, givenAllocationsInReuseWhenTrimOldAllocsCalledThenTrimAllocationsSavedBeforeTimePoint) {
|
|
|
|
|
std::unique_ptr<UltDeviceFactory> deviceFactory(new UltDeviceFactory(1, 1));
|
|
|
|
|
RootDeviceIndicesContainer rootDeviceIndices = {mockRootDeviceIndex};
|
|
|
|
@ -918,7 +993,7 @@ TEST_F(SvmDeviceAllocationCacheTest, givenAllocationsInReuseWhenTrimOldAllocsCal
|
|
|
|
|
debugManager.flags.ExperimentalEnableDeviceAllocationCache.set(1);
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(device->getMemoryManager(), false);
|
|
|
|
|
device->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
device->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
EXPECT_NE(nullptr, svmManager->usmDeviceAllocationsCache);
|
|
|
|
|
|
|
|
|
@ -942,13 +1017,13 @@ TEST_F(SvmDeviceAllocationCacheTest, givenAllocationsInReuseWhenTrimOldAllocsCal
|
|
|
|
|
svmManager->usmDeviceAllocationsCache->allocations[1].saveTime = baseTimePoint + timeDiff;
|
|
|
|
|
svmManager->usmDeviceAllocationsCache->allocations[2].saveTime = baseTimePoint + timeDiff * 2;
|
|
|
|
|
|
|
|
|
|
svmManager->usmDeviceAllocationsCache->trimOldAllocs(baseTimePoint + timeDiff);
|
|
|
|
|
svmManager->usmDeviceAllocationsCache->trimOldAllocs(baseTimePoint + timeDiff, false);
|
|
|
|
|
EXPECT_EQ(2u, svmManager->usmDeviceAllocationsCache->allocations.size());
|
|
|
|
|
|
|
|
|
|
svmManager->usmDeviceAllocationsCache->trimOldAllocs(baseTimePoint + timeDiff);
|
|
|
|
|
svmManager->usmDeviceAllocationsCache->trimOldAllocs(baseTimePoint + timeDiff, false);
|
|
|
|
|
EXPECT_EQ(1u, svmManager->usmDeviceAllocationsCache->allocations.size());
|
|
|
|
|
|
|
|
|
|
svmManager->usmDeviceAllocationsCache->trimOldAllocs(baseTimePoint + timeDiff);
|
|
|
|
|
svmManager->usmDeviceAllocationsCache->trimOldAllocs(baseTimePoint + timeDiff, false);
|
|
|
|
|
EXPECT_EQ(1u, svmManager->usmDeviceAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(baseTimePoint + timeDiff * 2, svmManager->usmDeviceAllocationsCache->allocations[0].saveTime);
|
|
|
|
|
|
|
|
|
@ -987,7 +1062,7 @@ HWTEST_F(SvmHostAllocationCacheTest, givenOclApiSpecificConfigWhenCheckingIfEnab
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
RAIIProductHelperFactory<MockProductHelper> raii(*device->getExecutionEnvironment()->rootDeviceEnvironments[0]);
|
|
|
|
|
const auto expectedMaxSize = static_cast<size_t>(0.02 * device->getMemoryManager()->getSystemSharedMemory(0u));
|
|
|
|
|
EXPECT_EQ(expectedMaxSize, device->getMemoryManager()->getMaxAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(expectedMaxSize, device->getMemoryManager()->usmReuseInfo.getMaxAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
raii.mockProductHelper->isHostUsmAllocationReuseSupportedResult = false;
|
|
|
|
@ -1005,6 +1080,37 @@ HWTEST_F(SvmHostAllocationCacheTest, givenOclApiSpecificConfigWhenCheckingIfEnab
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(SvmHostAllocationCacheTest, givenReuseLimitFlagWhenInitUsmReuseLimitCalledThenLimitThresholdSetCorrectly) {
|
|
|
|
|
std::unique_ptr<UltDeviceFactory> deviceFactory(new UltDeviceFactory(1, 1));
|
|
|
|
|
RootDeviceIndicesContainer rootDeviceIndices = {mockRootDeviceIndex};
|
|
|
|
|
std::map<uint32_t, DeviceBitfield> deviceBitfields{{mockRootDeviceIndex, mockDeviceBitfield}};
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
auto memoryManager = reinterpret_cast<MockMemoryManager *>(device->getMemoryManager());
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
DebugManagerStateRestore restore;
|
|
|
|
|
debugManager.flags.ExperimentalUSMAllocationReuseLimitThreshold.set(0);
|
|
|
|
|
memoryManager->initUsmReuseLimits();
|
|
|
|
|
const auto expectedLimitThreshold = std::numeric_limits<uint64_t>::max();
|
|
|
|
|
EXPECT_EQ(expectedLimitThreshold, memoryManager->usmReuseInfo.getLimitAllocationsReuseThreshold());
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
DebugManagerStateRestore restore;
|
|
|
|
|
debugManager.flags.ExperimentalUSMAllocationReuseLimitThreshold.set(80);
|
|
|
|
|
memoryManager->initUsmReuseLimits();
|
|
|
|
|
const auto systemSharedMemory = memoryManager->getSystemSharedMemory(device->getRootDeviceIndex());
|
|
|
|
|
const auto expectedLimitThreshold = static_cast<uint64_t>(0.8 * systemSharedMemory);
|
|
|
|
|
EXPECT_EQ(expectedLimitThreshold, memoryManager->usmReuseInfo.getLimitAllocationsReuseThreshold());
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
DebugManagerStateRestore restore;
|
|
|
|
|
debugManager.flags.ExperimentalUSMAllocationReuseLimitThreshold.set(-1);
|
|
|
|
|
memoryManager->initUsmReuseLimits();
|
|
|
|
|
const auto expectedLimitThreshold = std::numeric_limits<uint64_t>::max();
|
|
|
|
|
EXPECT_EQ(expectedLimitThreshold, memoryManager->usmReuseInfo.getLimitAllocationsReuseThreshold());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct SvmHostAllocationCacheSimpleTestDataType {
|
|
|
|
|
size_t allocationSize;
|
|
|
|
|
void *allocation;
|
|
|
|
@ -1019,7 +1125,7 @@ TEST_F(SvmHostAllocationCacheTest, givenAllocationCacheEnabledWhenFreeingHostAll
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
auto memoryManager = reinterpret_cast<MockMemoryManager *>(device->getMemoryManager());
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(memoryManager, false);
|
|
|
|
|
memoryManager->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
memoryManager->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
ASSERT_NE(nullptr, svmManager->usmHostAllocationsCache);
|
|
|
|
|
|
|
|
|
@ -1068,7 +1174,7 @@ TEST_F(SvmHostAllocationCacheTest, givenAllocationCacheEnabledWhenInitializedThe
|
|
|
|
|
ASSERT_NE(nullptr, svmManager->usmHostAllocationsCache);
|
|
|
|
|
|
|
|
|
|
auto expectedMaxSize = static_cast<size_t>(svmManager->memoryManager->getSystemSharedMemory(mockRootDeviceIndex) * 0.02);
|
|
|
|
|
EXPECT_EQ(expectedMaxSize, device->getMemoryManager()->getMaxAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(expectedMaxSize, device->getMemoryManager()->usmReuseInfo.getMaxAllocationsSavedForReuseSize());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(SvmHostAllocationCacheTest, givenAllocationCacheEnabledWhenFreeingHostAllocationThenItIsPutIntoCacheOnlyIfMaxSizeWillNotBeExceeded) {
|
|
|
|
@ -1081,7 +1187,7 @@ TEST_F(SvmHostAllocationCacheTest, givenAllocationCacheEnabledWhenFreeingHostAll
|
|
|
|
|
auto memoryManager = reinterpret_cast<MockMemoryManager *>(device->getMemoryManager());
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(memoryManager, false);
|
|
|
|
|
constexpr auto allocationSize = MemoryConstants::pageSize64k;
|
|
|
|
|
memoryManager->maxAllocationsSavedForReuseSize = allocationSize;
|
|
|
|
|
memoryManager->usmReuseInfo.init(allocationSize, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
ASSERT_NE(nullptr, svmManager->usmHostAllocationsCache);
|
|
|
|
|
|
|
|
|
@ -1092,26 +1198,26 @@ TEST_F(SvmHostAllocationCacheTest, givenAllocationCacheEnabledWhenFreeingHostAll
|
|
|
|
|
auto allocation2 = svmManager->createHostUnifiedMemoryAllocation(1u, unifiedMemoryProperties);
|
|
|
|
|
ASSERT_NE(allocation2, nullptr);
|
|
|
|
|
EXPECT_EQ(0u, svmManager->usmHostAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->getHostAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
svmManager->freeSVMAlloc(allocation);
|
|
|
|
|
EXPECT_EQ(1u, svmManager->usmHostAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(allocationSize, memoryManager->getHostAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(allocationSize, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
svmManager->freeSVMAlloc(allocation2);
|
|
|
|
|
EXPECT_EQ(1u, svmManager->usmHostAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(allocationSize, memoryManager->getHostAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(allocationSize, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
auto recycledAllocation = svmManager->createHostUnifiedMemoryAllocation(allocationSize, unifiedMemoryProperties);
|
|
|
|
|
EXPECT_EQ(recycledAllocation, allocation);
|
|
|
|
|
EXPECT_EQ(svmManager->usmHostAllocationsCache->allocations.size(), 0u);
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->getHostAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
svmManager->freeSVMAlloc(recycledAllocation);
|
|
|
|
|
|
|
|
|
|
svmManager->trimUSMHostAllocCache();
|
|
|
|
|
EXPECT_EQ(svmManager->usmHostAllocationsCache->allocations.size(), 0u);
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->getHostAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
auto allocation = svmManager->createHostUnifiedMemoryAllocation(allocationSize, unifiedMemoryProperties);
|
|
|
|
@ -1119,29 +1225,62 @@ TEST_F(SvmHostAllocationCacheTest, givenAllocationCacheEnabledWhenFreeingHostAll
|
|
|
|
|
auto allocation2 = svmManager->createHostUnifiedMemoryAllocation(1u, unifiedMemoryProperties);
|
|
|
|
|
ASSERT_NE(allocation2, nullptr);
|
|
|
|
|
EXPECT_EQ(0u, svmManager->usmHostAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->getHostAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
svmManager->freeSVMAllocDefer(allocation);
|
|
|
|
|
EXPECT_EQ(1u, svmManager->usmHostAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(allocationSize, memoryManager->getHostAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(allocationSize, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
svmManager->freeSVMAllocDefer(allocation2);
|
|
|
|
|
EXPECT_EQ(1u, svmManager->usmHostAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(allocationSize, memoryManager->getHostAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(allocationSize, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
auto recycledAllocation = svmManager->createHostUnifiedMemoryAllocation(allocationSize, unifiedMemoryProperties);
|
|
|
|
|
EXPECT_EQ(recycledAllocation, allocation);
|
|
|
|
|
EXPECT_EQ(svmManager->usmHostAllocationsCache->allocations.size(), 0u);
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->getHostAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
svmManager->freeSVMAllocDefer(recycledAllocation);
|
|
|
|
|
|
|
|
|
|
svmManager->trimUSMHostAllocCache();
|
|
|
|
|
EXPECT_EQ(svmManager->usmHostAllocationsCache->allocations.size(), 0u);
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->getHostAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(SvmHostAllocationCacheTest, givenAllocationCacheEnabledWhenFreeingHostAllocationAndShouldLimitUsmReuseThenItIsNotPutIntoCache) {
|
|
|
|
|
std::unique_ptr<UltDeviceFactory> deviceFactory(new UltDeviceFactory(1, 1));
|
|
|
|
|
RootDeviceIndicesContainer rootDeviceIndices = {mockRootDeviceIndex};
|
|
|
|
|
std::map<uint32_t, DeviceBitfield> deviceBitfields{{mockRootDeviceIndex, mockDeviceBitfield}};
|
|
|
|
|
DebugManagerStateRestore restore;
|
|
|
|
|
debugManager.flags.ExperimentalEnableHostAllocationCache.set(1);
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
auto memoryManager = reinterpret_cast<MockMemoryManager *>(device->getMemoryManager());
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(memoryManager, false);
|
|
|
|
|
constexpr auto allocationSize = MemoryConstants::pageSize64k;
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
ASSERT_NE(nullptr, svmManager->usmHostAllocationsCache);
|
|
|
|
|
|
|
|
|
|
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::hostUnifiedMemory, 1, rootDeviceIndices, deviceBitfields);
|
|
|
|
|
auto allocation = svmManager->createHostUnifiedMemoryAllocation(allocationSize, unifiedMemoryProperties);
|
|
|
|
|
ASSERT_NE(allocation, nullptr);
|
|
|
|
|
auto allocation2 = svmManager->createHostUnifiedMemoryAllocation(allocationSize, unifiedMemoryProperties);
|
|
|
|
|
ASSERT_NE(allocation2, nullptr);
|
|
|
|
|
EXPECT_EQ(0u, svmManager->usmHostAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
svmManager->freeSVMAlloc(allocation);
|
|
|
|
|
EXPECT_EQ(1u, svmManager->usmHostAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(allocationSize, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
memoryManager->usmReuseInfo.init(1 * MemoryConstants::gigaByte, alwaysLimited);
|
|
|
|
|
svmManager->freeSVMAlloc(allocation2);
|
|
|
|
|
EXPECT_EQ(1u, svmManager->usmHostAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(allocationSize, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
svmManager->cleanupUSMAllocCaches();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(SvmHostAllocationCacheTest, givenAllocationCacheEnabledAndMultipleSVMManagersWhenFreeingHostAllocationThenItIsPutIntoCacheOnlyIfMaxSizeWillNotBeExceeded) {
|
|
|
|
|
std::unique_ptr<UltDeviceFactory> deviceFactory(new UltDeviceFactory(1, 1));
|
|
|
|
|
RootDeviceIndicesContainer rootDeviceIndices = {mockRootDeviceIndex};
|
|
|
|
@ -1153,7 +1292,7 @@ TEST_F(SvmHostAllocationCacheTest, givenAllocationCacheEnabledAndMultipleSVMMana
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(memoryManager, false);
|
|
|
|
|
auto secondSvmManager = std::make_unique<MockSVMAllocsManager>(memoryManager, false);
|
|
|
|
|
constexpr auto allocationSize = MemoryConstants::pageSize64k;
|
|
|
|
|
memoryManager->maxAllocationsSavedForReuseSize = allocationSize;
|
|
|
|
|
memoryManager->usmReuseInfo.init(allocationSize, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
secondSvmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
ASSERT_NE(nullptr, svmManager->usmHostAllocationsCache);
|
|
|
|
@ -1167,26 +1306,26 @@ TEST_F(SvmHostAllocationCacheTest, givenAllocationCacheEnabledAndMultipleSVMMana
|
|
|
|
|
ASSERT_NE(allocation2, nullptr);
|
|
|
|
|
EXPECT_EQ(0u, svmManager->usmHostAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(0u, secondSvmManager->usmHostAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->getHostAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
svmManager->freeSVMAlloc(allocation);
|
|
|
|
|
EXPECT_EQ(1u, svmManager->usmHostAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(allocationSize, memoryManager->getHostAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(allocationSize, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
secondSvmManager->freeSVMAlloc(allocation2);
|
|
|
|
|
EXPECT_EQ(0u, secondSvmManager->usmHostAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(allocationSize, memoryManager->getHostAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(allocationSize, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
auto recycledAllocation = svmManager->createHostUnifiedMemoryAllocation(allocationSize, unifiedMemoryProperties);
|
|
|
|
|
EXPECT_EQ(recycledAllocation, allocation);
|
|
|
|
|
EXPECT_EQ(svmManager->usmHostAllocationsCache->allocations.size(), 0u);
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->getHostAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
svmManager->freeSVMAlloc(recycledAllocation);
|
|
|
|
|
|
|
|
|
|
svmManager->trimUSMHostAllocCache();
|
|
|
|
|
EXPECT_EQ(svmManager->usmHostAllocationsCache->allocations.size(), 0u);
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->getHostAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
auto allocation = svmManager->createHostUnifiedMemoryAllocation(allocationSize, unifiedMemoryProperties);
|
|
|
|
@ -1195,26 +1334,26 @@ TEST_F(SvmHostAllocationCacheTest, givenAllocationCacheEnabledAndMultipleSVMMana
|
|
|
|
|
ASSERT_NE(allocation2, nullptr);
|
|
|
|
|
EXPECT_EQ(0u, svmManager->usmHostAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(0u, secondSvmManager->usmHostAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->getHostAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
secondSvmManager->freeSVMAlloc(allocation2);
|
|
|
|
|
EXPECT_EQ(1u, secondSvmManager->usmHostAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(allocationSize, memoryManager->getHostAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(allocationSize, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
svmManager->freeSVMAlloc(allocation);
|
|
|
|
|
EXPECT_EQ(0u, svmManager->usmHostAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(allocationSize, memoryManager->getHostAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(allocationSize, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
auto recycledAllocation = secondSvmManager->createHostUnifiedMemoryAllocation(allocationSize, unifiedMemoryProperties);
|
|
|
|
|
EXPECT_EQ(recycledAllocation, allocation2);
|
|
|
|
|
EXPECT_EQ(secondSvmManager->usmHostAllocationsCache->allocations.size(), 0u);
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->getHostAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
|
|
|
|
|
secondSvmManager->freeSVMAlloc(recycledAllocation);
|
|
|
|
|
|
|
|
|
|
secondSvmManager->trimUSMHostAllocCache();
|
|
|
|
|
EXPECT_EQ(secondSvmManager->usmHostAllocationsCache->allocations.size(), 0u);
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->getHostAllocationsSavedForReuseSize());
|
|
|
|
|
EXPECT_EQ(0u, memoryManager->usmReuseInfo.getAllocationsSavedForReuseSize());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1227,7 +1366,7 @@ TEST_F(SvmHostAllocationCacheTest, givenAllocationsWithDifferentSizesWhenAllocat
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
auto memoryManager = reinterpret_cast<MockMemoryManager *>(device->getMemoryManager());
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(memoryManager, false);
|
|
|
|
|
memoryManager->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
memoryManager->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
ASSERT_NE(nullptr, svmManager->usmHostAllocationsCache);
|
|
|
|
|
|
|
|
|
@ -1279,7 +1418,7 @@ TEST_F(SvmHostAllocationCacheTest, givenAllocationsWithDifferentSizesWhenAllocat
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
auto memoryManager = reinterpret_cast<MockMemoryManager *>(device->getMemoryManager());
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(memoryManager, false);
|
|
|
|
|
memoryManager->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
memoryManager->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
ASSERT_NE(nullptr, svmManager->usmHostAllocationsCache);
|
|
|
|
|
|
|
|
|
@ -1319,7 +1458,7 @@ TEST_F(SvmHostAllocationCacheTest, givenAllocationOverSizeLimitWhenAllocatingAft
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
auto memoryManager = reinterpret_cast<MockMemoryManager *>(device->getMemoryManager());
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(memoryManager, false);
|
|
|
|
|
memoryManager->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
memoryManager->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
ASSERT_NE(nullptr, svmManager->usmHostAllocationsCache);
|
|
|
|
|
const auto notAcceptedAllocSize = SVMAllocsManager::SvmAllocationCache::maxServicedSize + 1;
|
|
|
|
@ -1348,7 +1487,7 @@ TEST_F(SvmHostAllocationCacheTest, givenMultipleAllocationsWhenAllocatingAfterFr
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
auto memoryManager = reinterpret_cast<MockMemoryManager *>(device->getMemoryManager());
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(memoryManager, false);
|
|
|
|
|
memoryManager->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
memoryManager->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
ASSERT_NE(nullptr, svmManager->usmHostAllocationsCache);
|
|
|
|
|
|
|
|
|
@ -1424,7 +1563,7 @@ TEST_F(SvmHostAllocationCacheTest, givenAllocationsWithDifferentFlagsWhenAllocat
|
|
|
|
|
auto rootDevice = deviceFactory->rootDevices[0];
|
|
|
|
|
auto memoryManager = reinterpret_cast<MockMemoryManager *>(rootDevice->getMemoryManager());
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(memoryManager, false);
|
|
|
|
|
memoryManager->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
memoryManager->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*rootDevice);
|
|
|
|
|
ASSERT_NE(nullptr, svmManager->usmHostAllocationsCache);
|
|
|
|
|
|
|
|
|
@ -1491,7 +1630,7 @@ TEST_F(SvmHostAllocationCacheTest, givenHostOutOfMemoryWhenAllocatingThenCacheIs
|
|
|
|
|
device->injectMemoryManager(new MockMemoryManagerWithCapacity(*device->getExecutionEnvironment()));
|
|
|
|
|
MockMemoryManagerWithCapacity *memoryManager = static_cast<MockMemoryManagerWithCapacity *>(device->getMemoryManager());
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(memoryManager, false);
|
|
|
|
|
memoryManager->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
memoryManager->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
ASSERT_NE(nullptr, svmManager->usmHostAllocationsCache);
|
|
|
|
|
|
|
|
|
@ -1529,7 +1668,7 @@ TEST_F(SvmHostAllocationCacheTest, givenAllocationInUsageWhenAllocatingAfterFree
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
auto memoryManager = reinterpret_cast<MockMemoryManager *>(device->getMemoryManager());
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(memoryManager, false);
|
|
|
|
|
memoryManager->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
memoryManager->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
EXPECT_NE(nullptr, svmManager->usmHostAllocationsCache);
|
|
|
|
|
|
|
|
|
@ -1560,7 +1699,7 @@ TEST_F(SvmHostAllocationCacheTest, givenAllocationsInReuseWhenTrimOldAllocsCalle
|
|
|
|
|
auto device = deviceFactory->rootDevices[0];
|
|
|
|
|
auto memoryManager = reinterpret_cast<MockMemoryManager *>(device->getMemoryManager());
|
|
|
|
|
auto svmManager = std::make_unique<MockSVMAllocsManager>(memoryManager, false);
|
|
|
|
|
memoryManager->maxAllocationsSavedForReuseSize = 1 * MemoryConstants::gigaByte;
|
|
|
|
|
memoryManager->usmReuseInfo.init(1 * MemoryConstants::gigaByte, UsmReuseInfo::notLimited);
|
|
|
|
|
svmManager->initUsmAllocationsCaches(*device);
|
|
|
|
|
EXPECT_NE(nullptr, svmManager->usmHostAllocationsCache);
|
|
|
|
|
|
|
|
|
@ -1583,13 +1722,13 @@ TEST_F(SvmHostAllocationCacheTest, givenAllocationsInReuseWhenTrimOldAllocsCalle
|
|
|
|
|
svmManager->usmHostAllocationsCache->allocations[1].saveTime = baseTimePoint + timeDiff;
|
|
|
|
|
svmManager->usmHostAllocationsCache->allocations[2].saveTime = baseTimePoint + timeDiff * 2;
|
|
|
|
|
|
|
|
|
|
svmManager->usmHostAllocationsCache->trimOldAllocs(baseTimePoint + timeDiff);
|
|
|
|
|
svmManager->usmHostAllocationsCache->trimOldAllocs(baseTimePoint + timeDiff, false);
|
|
|
|
|
EXPECT_EQ(2u, svmManager->usmHostAllocationsCache->allocations.size());
|
|
|
|
|
|
|
|
|
|
svmManager->usmHostAllocationsCache->trimOldAllocs(baseTimePoint + timeDiff);
|
|
|
|
|
svmManager->usmHostAllocationsCache->trimOldAllocs(baseTimePoint + timeDiff, false);
|
|
|
|
|
EXPECT_EQ(1u, svmManager->usmHostAllocationsCache->allocations.size());
|
|
|
|
|
|
|
|
|
|
svmManager->usmHostAllocationsCache->trimOldAllocs(baseTimePoint + timeDiff);
|
|
|
|
|
svmManager->usmHostAllocationsCache->trimOldAllocs(baseTimePoint + timeDiff, false);
|
|
|
|
|
EXPECT_EQ(1u, svmManager->usmHostAllocationsCache->allocations.size());
|
|
|
|
|
EXPECT_EQ(baseTimePoint + timeDiff * 2, svmManager->usmHostAllocationsCache->allocations[0].saveTime);
|
|
|
|
|
|
|
|
|
|