@@ -1391,6 +1391,36 @@ HWTEST_F(EnqueueSvmTest, whenInternalAllocationsAreAddedToResidencyContainerThen
13911391
13921392 svmManager->freeSVMAlloc (unifiedMemoryPtr);
13931393}
1394+
1395+ HWTEST_F (EnqueueSvmTest, whenInternalAllocationIsTriedToBeAddedTwiceToResidencyContainerThenOnlyOnceIsAdded) {
1396+ SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties (InternalMemoryType::DEVICE_UNIFIED_MEMORY, pDevice->getDeviceBitfield ());
1397+ unifiedMemoryProperties.device = pDevice;
1398+ auto allocationSize = 4096u ;
1399+ auto svmManager = this ->context ->getSVMAllocsManager ();
1400+ EXPECT_NE (0u , svmManager->getNumAllocs ());
1401+ auto unifiedMemoryPtr = svmManager->createUnifiedMemoryAllocation (pDevice->getRootDeviceIndex (), allocationSize, unifiedMemoryProperties);
1402+ EXPECT_NE (nullptr , unifiedMemoryPtr);
1403+ EXPECT_EQ (2u , svmManager->getNumAllocs ());
1404+
1405+ ResidencyContainer residencyContainer;
1406+ EXPECT_EQ (0u , residencyContainer.size ());
1407+
1408+ svmManager->addInternalAllocationsToResidencyContainer (pDevice->getRootDeviceIndex (),
1409+ residencyContainer,
1410+ InternalMemoryType::DEVICE_UNIFIED_MEMORY);
1411+
1412+ // only unified memory allocation is added to residency container
1413+ EXPECT_EQ (1u , residencyContainer.size ());
1414+ EXPECT_EQ (residencyContainer[0 ]->getGpuAddress (), castToUint64 (unifiedMemoryPtr));
1415+
1416+ svmManager->addInternalAllocationsToResidencyContainer (pDevice->getRootDeviceIndex (),
1417+ residencyContainer,
1418+ InternalMemoryType::DEVICE_UNIFIED_MEMORY);
1419+ EXPECT_EQ (1u , residencyContainer.size ());
1420+
1421+ svmManager->freeSVMAlloc (unifiedMemoryPtr);
1422+ }
1423+
13941424struct createHostUnifiedMemoryAllocationTest : public ::testing::Test {
13951425 void SetUp () override {
13961426 device0 = context.pRootDevice0 ;
0 commit comments