Skip to content

Commit 068a8d7

Browse files
Call submitBatchBuffer on HardwareContext
Related-To: NEO-3052 Change-Id: I51cae4d953260c0b6a49c40b8a8771630c721731 Signed-off-by: Mateusz Hoppe <[email protected]>
1 parent 92584d8 commit 068a8d7

File tree

5 files changed

+28
-3
lines changed

5 files changed

+28
-3
lines changed

runtime/helpers/hardware_context_controller.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include "runtime/helpers/hardware_context_controller.h"
99

10+
#include "runtime/aub_mem_dump/aub_mem_dump.h"
1011
#include "runtime/memory_manager/memory_constants.h"
1112
#include "runtime/os_interface/os_context.h"
1213

@@ -42,7 +43,7 @@ void HardwareContextController::expectMemory(uint64_t gfxAddress, const void *sr
4243
void HardwareContextController::submit(uint64_t batchBufferGpuAddress, const void *batchBuffer, size_t batchBufferSize,
4344
uint32_t memoryBank, uint64_t entryBits) {
4445
for (auto &hardwareContext : hardwareContexts) {
45-
hardwareContext->writeAndSubmitBatchBuffer(batchBufferGpuAddress, batchBuffer, batchBufferSize, memoryBank, MemoryConstants::pageSize64k);
46+
hardwareContext->submitBatchBuffer(batchBufferGpuAddress);
4647
}
4748
}
4849

unit_tests/command_stream/aub_command_stream_receiver_1_tests.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,24 @@ TEST_F(HardwareContextContainerTests, givenOsContextWithMultipleDevicesSupported
11201120
EXPECT_EQ(1u, mockHwContext1->deviceIndex);
11211121
}
11221122

1123+
TEST_F(HardwareContextContainerTests, givenSingleHwContextWhenSubmitMethodIsCalledOnHwContextControllerThenSubmitIsCalled) {
1124+
MockAubManager aubManager;
1125+
MockOsContext osContext(1, getDeviceBitfieldForNDevices(1), aub_stream::ENGINE_RCS, PreemptionMode::Disabled, false);
1126+
HardwareContextController hwContextContainer(aubManager, osContext, 0);
1127+
EXPECT_EQ(1u, hwContextContainer.hardwareContexts.size());
1128+
1129+
auto mockHwContext0 = static_cast<MockHardwareContext *>(hwContextContainer.hardwareContexts[0].get());
1130+
1131+
EXPECT_FALSE(mockHwContext0->writeAndSubmitCalled);
1132+
EXPECT_FALSE(mockHwContext0->writeMemoryCalled);
1133+
1134+
hwContextContainer.submit(1, reinterpret_cast<const void *>(0x123), 2, 0, 1);
1135+
1136+
EXPECT_TRUE(mockHwContext0->submitCalled);
1137+
EXPECT_FALSE(mockHwContext0->writeAndSubmitCalled);
1138+
EXPECT_FALSE(mockHwContext0->writeMemoryCalled);
1139+
}
1140+
11231141
TEST_F(HardwareContextContainerTests, givenMultipleHwContextWhenSingleMethodIsCalledThenUseAllContexts) {
11241142
MockAubManager aubManager;
11251143
MockOsContext osContext(1, getDeviceBitfieldForNDevices(2), aub_stream::ENGINE_RCS, PreemptionMode::Disabled, false);

unit_tests/command_stream/aub_file_stream_tests.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenI
549549

550550
EXPECT_TRUE(mockHardwareContext->initializeCalled);
551551
EXPECT_TRUE(mockHardwareContext->submitCalled);
552+
EXPECT_FALSE(mockHardwareContext->writeAndSubmitCalled);
552553
EXPECT_FALSE(mockHardwareContext->pollForCompletionCalled);
553554

554555
EXPECT_TRUE(aubCsr.writeMemoryWithAubManagerCalled);
@@ -570,6 +571,7 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenFlushIsCalledWithZ
570571

571572
aubCsr.flush(batchBuffer, allocationsForResidency);
572573

574+
EXPECT_FALSE(mockHardwareContext->writeAndSubmitCalled);
573575
EXPECT_FALSE(mockHardwareContext->submitCalled);
574576
pDevice->executionEnvironment->memoryManager->freeGraphicsMemory(commandBuffer);
575577
}

unit_tests/command_stream/tbx_command_stream_tests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenFlushIsCalledTh
420420
tbxCsr.flush(batchBuffer, allocationsForResidency);
421421

422422
EXPECT_TRUE(mockHardwareContext->initializeCalled);
423+
EXPECT_FALSE(mockHardwareContext->writeAndSubmitCalled);
423424
EXPECT_TRUE(mockHardwareContext->submitCalled);
424425
EXPECT_FALSE(mockHardwareContext->pollForCompletionCalled);
425426

unit_tests/mocks/mock_aub_manager.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ struct MockHardwareContext : public aub_stream::HardwareContext {
1919

2020
void initialize() override { initializeCalled = true; }
2121
void pollForCompletion() override { pollForCompletionCalled = true; }
22-
void writeAndSubmitBatchBuffer(uint64_t gfxAddress, const void *batchBuffer, size_t size, uint32_t memoryBank, size_t pageSize = 65536) override { submitCalled = true; }
23-
void submitBatchBuffer(uint64_t gfxAddress) override {}
22+
void writeAndSubmitBatchBuffer(uint64_t gfxAddress, const void *batchBuffer, size_t size, uint32_t memoryBank, size_t pageSize = 65536) override { writeAndSubmitCalled = true; }
23+
void submitBatchBuffer(uint64_t gfxAddress) override { submitCalled = true; }
2424
void writeMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t memoryBanks, int hint, size_t pageSize = 65536) override { writeMemoryCalled = true; }
2525
void freeMemory(uint64_t gfxAddress, size_t size) override { freeMemoryCalled = true; }
2626
void expectMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t compareOperation) override { expectMemoryCalled = true; }
@@ -30,6 +30,7 @@ struct MockHardwareContext : public aub_stream::HardwareContext {
3030

3131
bool initializeCalled = false;
3232
bool pollForCompletionCalled = false;
33+
bool writeAndSubmitCalled = false;
3334
bool submitCalled = false;
3435
bool writeMemoryCalled = false;
3536
bool freeMemoryCalled = false;
@@ -85,6 +86,7 @@ class MockAubManager : public aub_stream::AubManager {
8586

8687
void writeMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t memoryBanks, int hint, size_t pageSize = 65536) override {
8788
writeMemoryCalled = true;
89+
hintToWriteMemory = hint;
8890
}
8991

9092
uint32_t openCalledCnt = 0;
@@ -96,6 +98,7 @@ class MockAubManager : public aub_stream::AubManager {
9698
std::string receivedComment = "";
9799
bool writeMemoryCalled = false;
98100
uint32_t contextFlags = 0;
101+
int hintToWriteMemory = 0;
99102

100103
struct MockAubManagerParams {
101104
uint32_t productFamily = 0;

0 commit comments

Comments
 (0)