Skip to content

Commit ffd97a1

Browse files
Make preallocated heaps resident immediately
Signed-off-by: Szymon Morek <[email protected]>
1 parent 87822f9 commit ffd97a1

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

shared/source/command_container/cmdcontainer.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ void CommandContainer::fillReusableAllocationLists() {
398398
heapSize,
399399
alignedSize,
400400
device->getRootDeviceIndex());
401+
this->immediateCmdListCsr->makeResident(*heapToReuse);
401402
this->heapHelper->storeHeapAllocation(heapToReuse);
402403
}
403404
}

shared/test/unit_test/command_container/command_container_tests.cpp

+19-3
Original file line numberDiff line numberDiff line change
@@ -992,18 +992,25 @@ struct MockHeapHelper : public HeapHelper {
992992
using HeapHelper::storageForReuse;
993993
};
994994

995-
TEST_F(CommandContainerTest, givenCmdContainerWhenFillReusableAllocationListsThenAllocListsNotEmpty) {
995+
TEST_F(CommandContainerTest, givenCmdContainerWhenFillReusableAllocationListsThenAllocListsNotEmptyAndMadeResident) {
996996
DebugManagerStateRestore dbgRestore;
997997
DebugManager.flags.SetAmountOfReusableAllocations.set(1);
998998
auto cmdContainer = std::make_unique<CommandContainer>();
999+
auto csr = pDevice->getDefaultEngine().commandStreamReceiver;
1000+
9991001
AllocationsList allocList;
10001002
cmdContainer->initialize(pDevice, &allocList, true);
1003+
cmdContainer->setImmediateCmdListCsr(csr);
1004+
auto heapHelper = reinterpret_cast<MockHeapHelper *>(cmdContainer->getHeapHelper());
10011005

10021006
EXPECT_TRUE(allocList.peekIsEmpty());
1003-
EXPECT_TRUE(reinterpret_cast<MockHeapHelper *>(cmdContainer->getHeapHelper())->storageForReuse->getAllocationsForReuse().peekIsEmpty());
1007+
EXPECT_TRUE(heapHelper->storageForReuse->getAllocationsForReuse().peekIsEmpty());
1008+
auto actualResidencyContainerSize = cmdContainer->getResidencyContainer().size();
10041009
cmdContainer->fillReusableAllocationLists();
10051010
EXPECT_FALSE(allocList.peekIsEmpty());
1006-
EXPECT_FALSE(reinterpret_cast<MockHeapHelper *>(cmdContainer->getHeapHelper())->storageForReuse->getAllocationsForReuse().peekIsEmpty());
1011+
EXPECT_FALSE(heapHelper->storageForReuse->getAllocationsForReuse().peekIsEmpty());
1012+
EXPECT_EQ(heapHelper->storageForReuse->getAllocationsForReuse().peekHead()->getResidencyTaskCount(csr->getOsContext().getContextId()), 1u);
1013+
EXPECT_EQ(cmdContainer->getResidencyContainer().size(), actualResidencyContainerSize + 1);
10071014

10081015
cmdContainer.reset();
10091016
allocList.freeAllGraphicsAllocations(pDevice);
@@ -1013,9 +1020,12 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenFillReusableAllocationListsWit
10131020
DebugManagerStateRestore dbgRestore;
10141021
DebugManager.flags.SetAmountOfReusableAllocations.set(1);
10151022
auto cmdContainer = std::make_unique<CommandContainer>();
1023+
auto csr = pDevice->getDefaultEngine().commandStreamReceiver;
1024+
10161025
AllocationsList allocList;
10171026
cmdContainer->enableHeapSharing();
10181027
cmdContainer->initialize(pDevice, &allocList, true);
1028+
cmdContainer->setImmediateCmdListCsr(csr);
10191029

10201030
auto &reusableHeapsList = reinterpret_cast<MockHeapHelper *>(cmdContainer->getHeapHelper())->storageForReuse->getAllocationsForReuse();
10211031

@@ -1031,9 +1041,11 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenFillReusableAllocationListsWit
10311041
TEST_F(CommandContainerTest, givenCmdContainerWhenFillReusableAllocationListsWithBindlessModeEnabledThenOnlyOneHeapFilled) {
10321042
DebugManagerStateRestore dbgRestore;
10331043
DebugManager.flags.SetAmountOfReusableAllocations.set(1);
1044+
auto csr = pDevice->getDefaultEngine().commandStreamReceiver;
10341045
auto cmdContainer = std::make_unique<CommandContainer>();
10351046
AllocationsList allocList;
10361047
cmdContainer->initialize(pDevice, &allocList, true);
1048+
cmdContainer->setImmediateCmdListCsr(csr);
10371049

10381050
auto &reusableHeapsList = reinterpret_cast<MockHeapHelper *>(cmdContainer->getHeapHelper())->storageForReuse->getAllocationsForReuse();
10391051

@@ -1067,8 +1079,10 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenFillReusableAllocationListsWit
10671079
DebugManagerStateRestore dbgRestore;
10681080
DebugManager.flags.SetAmountOfReusableAllocations.set(10);
10691081
auto cmdContainer = std::make_unique<CommandContainer>();
1082+
auto csr = pDevice->getDefaultEngine().commandStreamReceiver;
10701083
AllocationsList allocList;
10711084
cmdContainer->initialize(pDevice, &allocList, false);
1085+
cmdContainer->setImmediateCmdListCsr(csr);
10721086

10731087
EXPECT_TRUE(allocList.peekIsEmpty());
10741088
cmdContainer->fillReusableAllocationLists();
@@ -1106,8 +1120,10 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenFillReusableAllocationListsAnd
11061120
DebugManagerStateRestore dbgRestore;
11071121
DebugManager.flags.SetAmountOfReusableAllocations.set(0);
11081122
auto cmdContainer = std::make_unique<CommandContainer>();
1123+
auto csr = pDevice->getDefaultEngine().commandStreamReceiver;
11091124
AllocationsList allocList;
11101125
cmdContainer->initialize(pDevice, &allocList, false);
1126+
cmdContainer->setImmediateCmdListCsr(csr);
11111127

11121128
EXPECT_TRUE(allocList.peekIsEmpty());
11131129
cmdContainer->fillReusableAllocationLists();

0 commit comments

Comments
 (0)