Set isLockable if size small enough for cpu memcpy

Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
Szymon Morek
2022-12-06 10:19:05 +00:00
committed by Compute-Runtime-Automation
parent 336c8c10d5
commit 41a80072b9
9 changed files with 124 additions and 17 deletions

View File

@@ -1433,3 +1433,23 @@ TEST(GfxCoreHelperTests, whenIsDynamicallyPopulatedisTrueThengetHighestEnabledSl
auto maxSlice = gfxCoreHelper.getHighestEnabledSlice(hwInfo);
EXPECT_EQ(maxSlice, 7u);
}
TEST(GfxCoreHelperTests, whenGetCpuCopyThresholdsThenCorrectValueSet) {
size_t h2DThreshold = 0;
size_t d2HThreshold = 0;
GfxCoreHelper::getCpuCopyThresholds(h2DThreshold, d2HThreshold);
EXPECT_EQ(h2DThreshold, NonUsmCpuCopyConstants::h2DThreshold);
EXPECT_EQ(d2HThreshold, NonUsmCpuCopyConstants::d2HThreshold);
}
TEST(GfxCoreHelperTests, givenThresholdChangedWhenGetCpuCopyThresholdsThenCorrectValueSet) {
DebugManagerStateRestore restore;
DebugManager.flags.ExperimentalH2DCpuCopyThreshold.set(2048);
DebugManager.flags.ExperimentalD2HCpuCopyThreshold.set(2048);
size_t h2DThreshold = 0;
size_t d2HThreshold = 0;
GfxCoreHelper::getCpuCopyThresholds(h2DThreshold, d2HThreshold);
EXPECT_EQ(h2DThreshold, 2048u);
EXPECT_EQ(d2HThreshold, 2048u);
}

View File

@@ -92,3 +92,36 @@ TEST_F(SVMLocalMemoryAllocatorTest, givenKmdMigratedSharedAllocationWhenPrefetch
svmManager->freeSVMAlloc(ptr);
}
TEST_F(SVMLocalMemoryAllocatorTest, whenCreateUnifiedMemoryAllocationWithSmallSizeThenSetLockable) {
DebugManagerStateRestore restore;
DebugManager.flags.ForceLocalMemoryAccessMode.set(0);
DebugManager.flags.EnableLocalMemory.set(1);
std::unique_ptr<UltDeviceFactory> deviceFactory(new UltDeviceFactory(1, 2));
auto device = deviceFactory->rootDevices[0];
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY, rootDeviceIndices, deviceBitfields);
unifiedMemoryProperties.device = device;
auto ptr = svmManager->createUnifiedMemoryAllocation(4096u, unifiedMemoryProperties);
EXPECT_NE(nullptr, ptr);
EXPECT_TRUE(svmManager->getSVMAlloc(ptr)->gpuAllocations.getGraphicsAllocation(mockRootDeviceIndex)->storageInfo.isLockable);
svmManager->freeSVMAlloc(ptr);
}
TEST_F(SVMLocalMemoryAllocatorTest, whenCreateUnifiedMemoryAllocationWithLargeSizeThenSetLockable) {
if (HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->isStorageInfoAdjustmentRequired()) {
GTEST_SKIP();
}
DebugManagerStateRestore restore;
DebugManager.flags.ForceLocalMemoryAccessMode.set(0);
DebugManager.flags.EnableLocalMemory.set(1);
std::unique_ptr<UltDeviceFactory> deviceFactory(new UltDeviceFactory(1, 2));
auto device = deviceFactory->rootDevices[0];
size_t largeSize = std::max(NonUsmCpuCopyConstants::d2HThreshold, NonUsmCpuCopyConstants::h2DThreshold) + 1;
SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY, rootDeviceIndices, deviceBitfields);
unifiedMemoryProperties.device = device;
auto ptr = svmManager->createUnifiedMemoryAllocation(largeSize, unifiedMemoryProperties);
EXPECT_NE(nullptr, ptr);
EXPECT_FALSE(svmManager->getSVMAlloc(ptr)->gpuAllocations.getGraphicsAllocation(mockRootDeviceIndex)->storageInfo.isLockable);
svmManager->freeSVMAlloc(ptr);
}