Skip to content

Commit 41c51df

Browse files
Revert "Recycle old command buffers of immediate command lists"
This reverts commit 8f93f4f. Signed-off-by: Compute-Runtime-Validation <[email protected]>
1 parent fe53879 commit 41c51df

File tree

8 files changed

+28
-96
lines changed

8 files changed

+28
-96
lines changed

shared/source/command_container/cmdcontainer.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -229,16 +229,12 @@ IndirectHeap *CommandContainer::getHeapWithRequiredSizeAndAlignment(HeapType hea
229229

230230
void CommandContainer::handleCmdBufferAllocations(size_t startIndex) {
231231
for (size_t i = startIndex; i < cmdBufferAllocations.size(); i++) {
232-
handleCmdBufferAllocation(cmdBufferAllocations[i]);
233-
}
234-
}
235-
236-
void CommandContainer::handleCmdBufferAllocation(GraphicsAllocation *allocation) {
237-
if (this->reusableAllocationList) {
238-
this->device->getMemoryManager()->handleFenceCompletion(allocation);
239-
reusableAllocationList->pushFrontOne(*allocation);
240-
} else {
241-
this->device->getMemoryManager()->freeGraphicsMemory(allocation);
232+
if (this->reusableAllocationList) {
233+
this->device->getMemoryManager()->handleFenceCompletion(cmdBufferAllocations[i]);
234+
reusableAllocationList->pushFrontOne(*cmdBufferAllocations[i]);
235+
} else {
236+
this->device->getMemoryManager()->freeGraphicsMemory(cmdBufferAllocations[i]);
237+
}
242238
}
243239
}
244240

@@ -268,11 +264,6 @@ void CommandContainer::allocateNextCommandBuffer() {
268264
auto cmdBufferAllocation = this->obtainNextCommandBufferAllocation();
269265
UNRECOVERABLE_IF(!cmdBufferAllocation);
270266

271-
if (getFlushTaskUsedForImmediate()) {
272-
NEO::GraphicsAllocation *oldCmdBuffer = cmdBufferAllocations.back();
273-
handleCmdBufferAllocation(oldCmdBuffer);
274-
cmdBufferAllocations.pop_back();
275-
}
276267
cmdBufferAllocations.push_back(cmdBufferAllocation);
277268

278269
size_t alignedSize = alignUp<size_t>(totalCmdBufferSize, MemoryConstants::pageSize64k);

shared/source/command_container/cmdcontainer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ class CommandContainer : public NonCopyableOrMovableClass {
8888
void closeAndAllocateNextCommandBuffer();
8989

9090
void handleCmdBufferAllocations(size_t startIndex);
91-
void handleCmdBufferAllocation(GraphicsAllocation *allocation);
9291
GraphicsAllocation *obtainNextCommandBufferAllocation();
9392

9493
void reset();

shared/test/common/fixtures/command_container_fixture.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,28 @@
99
#include "shared/source/command_container/command_encoder.h"
1010
#include "shared/source/kernel/kernel_descriptor.h"
1111
#include "shared/test/common/fixtures/device_fixture.h"
12-
#include "shared/test/common/mocks/mock_command_container.h"
1312
#include "shared/test/common/test_macros/test.h"
1413

1514
namespace NEO {
1615

1716
class CommandEncodeStatesFixture : public DeviceFixture {
1817
public:
18+
class MyMockCommandContainer : public CommandContainer {
19+
public:
20+
using CommandContainer::dirtyHeaps;
21+
};
22+
1923
void SetUp() {
2024
DeviceFixture::SetUp();
21-
cmdContainer = std::make_unique<MockCommandContainer>();
25+
cmdContainer = std::make_unique<MyMockCommandContainer>();
2226
cmdContainer->initialize(pDevice, nullptr);
2327
cmdContainer->setDirtyStateForAllHeaps(false);
2428
}
2529
void TearDown() {
2630
cmdContainer.reset();
2731
DeviceFixture::TearDown();
2832
}
29-
std::unique_ptr<MockCommandContainer> cmdContainer;
33+
std::unique_ptr<MyMockCommandContainer> cmdContainer;
3034
KernelDescriptor descriptor;
3135

3236
EncodeDispatchKernelArgs createDefaultDispatchKernelArgs(Device *device,

shared/test/common/mocks/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ set(NEO_CORE_tests_mocks
2727
${CMAKE_CURRENT_SOURCE_DIR}/mock_builtinslib.h
2828
${CMAKE_CURRENT_SOURCE_DIR}/mock_cif.cpp
2929
${CMAKE_CURRENT_SOURCE_DIR}/mock_cif.h
30-
${CMAKE_CURRENT_SOURCE_DIR}/mock_command_container.h
3130
${CMAKE_CURRENT_SOURCE_DIR}/mock_command_stream_receiver.cpp
3231
${CMAKE_CURRENT_SOURCE_DIR}/mock_command_stream_receiver.h
3332
${CMAKE_CURRENT_SOURCE_DIR}/mock_compiler_interface_spirv.cpp

shared/test/common/mocks/mock_command_container.h

Lines changed: 0 additions & 16 deletions
This file was deleted.

shared/test/unit_test/command_container/command_container_tests.cpp

Lines changed: 9 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "shared/source/memory_manager/allocations_list.h"
1111
#include "shared/test/common/fixtures/device_fixture.h"
1212
#include "shared/test/common/helpers/debug_manager_state_restore.h"
13-
#include "shared/test/common/mocks/mock_command_container.h"
1413
#include "shared/test/common/mocks/mock_graphics_allocation.h"
1514
#include "shared/test/common/mocks/mock_memory_manager.h"
1615
#include "shared/test/common/test_macros/test.h"
@@ -28,17 +27,18 @@ class CommandContainerTest : public DeviceFixture,
2827
DeviceFixture::SetUp();
2928
}
3029
void TearDown() override {
31-
allocList.freeAllGraphicsAllocations(pDevice);
32-
3330
DeviceFixture::TearDown();
3431
::testing::Test::TearDown();
3532
}
36-
37-
AllocationsList allocList;
3833
};
3934

4035
struct CommandContainerHeapStateTests : public ::testing::Test {
41-
MockCommandContainer myCommandContainer;
36+
class MyMockCommandContainer : public CommandContainer {
37+
public:
38+
using CommandContainer::dirtyHeaps;
39+
};
40+
41+
MyMockCommandContainer myCommandContainer;
4242
};
4343

4444
TEST_F(CommandContainerHeapStateTests, givenDirtyHeapsWhenSettingStateForAllThenValuesAreCorrect) {
@@ -173,6 +173,7 @@ TEST_F(CommandContainerTest, givenCommandContainerDuringInitWhenAllocateGfxMemor
173173
}
174174

175175
TEST_F(CommandContainerTest, givenCmdContainerWithAllocsListWhenAllocateAndResetThenCmdBufferAllocIsReused) {
176+
AllocationsList allocList;
176177
auto cmdContainer = std::make_unique<CommandContainer>();
177178
cmdContainer->initialize(pDevice, &allocList);
178179
auto &cmdBufferAllocs = cmdContainer->getCmdBufferAllocations();
@@ -202,6 +203,7 @@ TEST_F(CommandContainerTest, givenCmdContainerWithAllocsListWhenAllocateAndReset
202203
cmdContainer.reset();
203204
EXPECT_EQ(memoryManager->handleFenceCompletionCalled, 3u);
204205
EXPECT_FALSE(allocList.peekIsEmpty());
206+
allocList.freeAllGraphicsAllocations(pDevice);
205207
}
206208

207209
TEST_F(CommandContainerTest, givenCommandContainerDuringInitWhenAllocateHeapMemoryFailsThenErrorIsReturned) {
@@ -726,49 +728,4 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenCloseAndAllocateNextCommandBuf
726728
EXPECT_EQ(cmdContainer.getCmdBufferAllocations().size(), 1u);
727729
cmdContainer.closeAndAllocateNextCommandBuffer();
728730
EXPECT_EQ(cmdContainer.getCmdBufferAllocations().size(), 2u);
729-
}
730-
731-
TEST_F(CommandContainerTest, givenFlushTaskCmdContainerWithAllocationListWhenNewCmdBufferAllocatedThenOldCmdBufferIsStored) {
732-
auto cmdContainer = std::make_unique<MockCommandContainer>();
733-
cmdContainer->isFlushTaskUsedForImmediate = true;
734-
cmdContainer->initialize(pDevice, &allocList);
735-
736-
auto &cmdBufferAllocs = cmdContainer->cmdBufferAllocations;
737-
auto memoryManager = static_cast<MockMemoryManager *>(pDevice->getMemoryManager());
738-
EXPECT_EQ(0u, memoryManager->handleFenceCompletionCalled);
739-
EXPECT_EQ(1u, cmdBufferAllocs.size());
740-
EXPECT_TRUE(allocList.peekIsEmpty());
741-
GraphicsAllocation *oldAllocation = cmdContainer->getCommandStream()->getGraphicsAllocation();
742-
743-
cmdContainer->allocateNextCommandBuffer();
744-
EXPECT_EQ(1u, cmdBufferAllocs.size());
745-
746-
auto cmdBuffer0 = cmdBufferAllocs[0];
747-
EXPECT_EQ(cmdBuffer0, cmdContainer->getCommandStream()->getGraphicsAllocation());
748-
EXPECT_NE(cmdBuffer0, oldAllocation);
749-
750-
EXPECT_EQ(0u, memoryManager->freeGraphicsMemoryCalled);
751-
EXPECT_EQ(1u, memoryManager->handleFenceCompletionCalled);
752-
EXPECT_FALSE(allocList.peekIsEmpty());
753-
}
754-
755-
TEST_F(CommandContainerTest, givenFlushTaskCmdContainerWithoutAllocationListWhenNewCmdBufferAllocatedThenOldCmdBufferIsFreed) {
756-
auto cmdContainer = std::make_unique<MockCommandContainer>();
757-
cmdContainer->isFlushTaskUsedForImmediate = true;
758-
cmdContainer->initialize(pDevice, nullptr);
759-
760-
auto &cmdBufferAllocs = cmdContainer->cmdBufferAllocations;
761-
auto memoryManager = static_cast<MockMemoryManager *>(pDevice->getMemoryManager());
762-
EXPECT_EQ(0u, memoryManager->handleFenceCompletionCalled);
763-
EXPECT_EQ(1u, cmdBufferAllocs.size());
764-
GraphicsAllocation *oldAllocation = cmdContainer->getCommandStream()->getGraphicsAllocation();
765-
766-
cmdContainer->allocateNextCommandBuffer();
767-
EXPECT_EQ(1u, cmdBufferAllocs.size());
768-
769-
auto cmdBuffer0 = cmdBufferAllocs[0];
770-
EXPECT_EQ(cmdBuffer0, cmdContainer->getCommandStream()->getGraphicsAllocation());
771-
EXPECT_NE(cmdBuffer0, oldAllocation);
772-
773-
EXPECT_EQ(1u, memoryManager->freeGraphicsMemoryCalled);
774-
}
731+
}

shared/test/unit_test/encoders/test_encode_dispatch_kernel.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "shared/test/common/fixtures/command_container_fixture.h"
1616
#include "shared/test/common/fixtures/front_window_fixture.h"
1717
#include "shared/test/common/helpers/debug_manager_state_restore.h"
18-
#include "shared/test/common/mocks/mock_command_container.h"
1918
#include "shared/test/common/mocks/mock_device.h"
2019
#include "shared/test/common/mocks/mock_dispatch_kernel_encoder_interface.h"
2120
#include "shared/test/common/test_macros/matchers.h"
@@ -462,7 +461,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandEncodeStatesTest, givenForceBtpPrefetchModeDe
462461

463462
{
464463
DebugManager.flags.ForceBtpPrefetchMode.set(-1);
465-
cmdContainer.reset(new MockCommandContainer());
464+
cmdContainer.reset(new MyMockCommandContainer());
466465
cmdContainer->initialize(pDevice, nullptr);
467466
bool requiresUncachedMocs = false;
468467
EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs);
@@ -493,7 +492,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandEncodeStatesTest, givenForceBtpPrefetchModeDe
493492

494493
{
495494
DebugManager.flags.ForceBtpPrefetchMode.set(0);
496-
cmdContainer.reset(new MockCommandContainer());
495+
cmdContainer.reset(new MyMockCommandContainer());
497496
cmdContainer->initialize(pDevice, nullptr);
498497

499498
bool requiresUncachedMocs = false;
@@ -520,7 +519,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandEncodeStatesTest, givenForceBtpPrefetchModeDe
520519

521520
{
522521
DebugManager.flags.ForceBtpPrefetchMode.set(1);
523-
cmdContainer.reset(new MockCommandContainer());
522+
cmdContainer.reset(new MyMockCommandContainer());
524523
cmdContainer->initialize(pDevice, nullptr);
525524

526525
bool requiresUncachedMocs = false;

shared/test/unit_test/encoders/test_encode_dispatch_kernel_xehp_and_later.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "shared/test/common/fixtures/command_container_fixture.h"
1919
#include "shared/test/common/helpers/debug_manager_state_restore.h"
2020
#include "shared/test/common/helpers/variable_backup.h"
21-
#include "shared/test/common/mocks/mock_command_container.h"
2221
#include "shared/test/common/mocks/mock_device.h"
2322
#include "shared/test/common/mocks/mock_dispatch_kernel_encoder_interface.h"
2423
#include "shared/test/common/test_macros/test.h"
@@ -364,7 +363,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncodeStatesTest, givenForceBtpPrefetchModeD
364363

365364
{
366365
DebugManager.flags.ForceBtpPrefetchMode.set(-1);
367-
cmdContainer.reset(new MockCommandContainer());
366+
cmdContainer.reset(new MyMockCommandContainer());
368367
cmdContainer->initialize(pDevice, nullptr);
369368

370369
bool requiresUncachedMocs = false;
@@ -395,7 +394,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncodeStatesTest, givenForceBtpPrefetchModeD
395394

396395
{
397396
DebugManager.flags.ForceBtpPrefetchMode.set(0);
398-
cmdContainer.reset(new MockCommandContainer());
397+
cmdContainer.reset(new MyMockCommandContainer());
399398
cmdContainer->initialize(pDevice, nullptr);
400399

401400
bool requiresUncachedMocs = false;
@@ -417,7 +416,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncodeStatesTest, givenForceBtpPrefetchModeD
417416

418417
{
419418
DebugManager.flags.ForceBtpPrefetchMode.set(1);
420-
cmdContainer.reset(new MockCommandContainer());
419+
cmdContainer.reset(new MyMockCommandContainer());
421420
cmdContainer->initialize(pDevice, nullptr);
422421

423422
bool requiresUncachedMocs = false;

0 commit comments

Comments
 (0)