mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
Add HardwareContextController to use multiple Contexts in single AubCsr
Change-Id: Ica0f1c8c4e0f55310f4650788e468640406abf51 Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
356259b865
commit
75fe358e5d
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "runtime/aub_mem_dump/page_table_entry_bits.h"
|
||||
#include "runtime/helpers/hardware_context_controller.h"
|
||||
#include "runtime/os_interface/os_context.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
@@ -82,7 +83,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenItIsCre
|
||||
ASSERT_NE(nullptr, aubCsr);
|
||||
|
||||
EXPECT_EQ(nullptr, aubCsr->aubManager);
|
||||
EXPECT_EQ(nullptr, aubCsr->hardwareContext);
|
||||
EXPECT_EQ(nullptr, aubCsr->hardwareContextController);
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGetEngineIndexFromInstanceIsCalledForGivenEngineInstanceThenEngineIndexForThatInstanceIsReturned) {
|
||||
@@ -199,11 +200,11 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenOsContextIsSetThenCreateH
|
||||
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(reinterpret_cast<AUBCommandStreamReceiverHw<FamilyType> *>(AUBCommandStreamReceiver::create(*platformDevices[0], fileName, true, executionEnvironment)));
|
||||
aubCsr->setDeviceIndex(deviceIndex);
|
||||
EXPECT_EQ(nullptr, aubCsr->hardwareContext.get());
|
||||
EXPECT_EQ(nullptr, aubCsr->hardwareContextController.get());
|
||||
|
||||
aubCsr->setupContext(osContext);
|
||||
EXPECT_NE(nullptr, aubCsr->hardwareContext.get());
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(aubCsr->hardwareContext.get());
|
||||
EXPECT_NE(nullptr, aubCsr->hardwareContextController.get());
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(aubCsr->hardwareContextController->hardwareContexts[0].get());
|
||||
EXPECT_EQ(deviceIndex, mockHardwareContext->deviceIndex);
|
||||
EXPECT_EQ(engineIndex, mockHardwareContext->engineIndex);
|
||||
}
|
||||
@@ -218,10 +219,10 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenLowPriorityOsContextIsSet
|
||||
executionEnvironment.aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
|
||||
|
||||
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(reinterpret_cast<AUBCommandStreamReceiverHw<FamilyType> *>(AUBCommandStreamReceiver::create(*platformDevices[0], fileName, true, executionEnvironment)));
|
||||
EXPECT_EQ(nullptr, aubCsr->hardwareContext.get());
|
||||
EXPECT_EQ(nullptr, aubCsr->hardwareContextController.get());
|
||||
|
||||
aubCsr->setupContext(osContext);
|
||||
EXPECT_EQ(nullptr, aubCsr->hardwareContext.get());
|
||||
EXPECT_EQ(nullptr, aubCsr->hardwareContextController.get());
|
||||
}
|
||||
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenItIsCreatedThenFileIsNotCreated) {
|
||||
@@ -318,6 +319,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipl
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenItShouldInitializeEngineInfoTable) {
|
||||
auto aubExecutionEnvironment = getEnvironment<AUBCommandStreamReceiverHw<FamilyType>>(true, true, true);
|
||||
auto aubCsr = aubExecutionEnvironment->template getCsr<AUBCommandStreamReceiverHw<FamilyType>>();
|
||||
aubCsr->hardwareContextController.reset(nullptr);
|
||||
LinearStream cs(aubExecutionEnvironment->commandBuffer);
|
||||
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
@@ -1096,3 +1098,61 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
|
||||
EXPECT_FALSE(aubCsr->flushBatchedSubmissionsCalled);
|
||||
EXPECT_TRUE(aubCsr->initProgrammingFlagsCalled);
|
||||
}
|
||||
|
||||
using HardwareContextContainerTests = ::testing::Test;
|
||||
|
||||
TEST_F(HardwareContextContainerTests, givenMultipleHwContextWhenSingleMethodIsCalledThenUseAllContexts) {
|
||||
MockAubManager aubManager;
|
||||
HardwareContextController hwContextContainer(aubManager, 1, 2, 0);
|
||||
hwContextContainer.hardwareContexts.emplace_back(aubManager.createHardwareContext(2, 3));
|
||||
EXPECT_EQ(2u, hwContextContainer.hardwareContexts.size());
|
||||
|
||||
auto mockHwContext0 = static_cast<MockHardwareContext *>(hwContextContainer.hardwareContexts[0].get());
|
||||
auto mockHwContext1 = static_cast<MockHardwareContext *>(hwContextContainer.hardwareContexts[1].get());
|
||||
|
||||
EXPECT_FALSE(mockHwContext0->initializeCalled);
|
||||
EXPECT_FALSE(mockHwContext1->initializeCalled);
|
||||
EXPECT_FALSE(mockHwContext0->pollForCompletionCalled);
|
||||
EXPECT_FALSE(mockHwContext1->pollForCompletionCalled);
|
||||
EXPECT_FALSE(mockHwContext0->expectMemoryCalled);
|
||||
EXPECT_FALSE(mockHwContext1->expectMemoryCalled);
|
||||
EXPECT_FALSE(mockHwContext0->submitCalled);
|
||||
EXPECT_FALSE(mockHwContext1->submitCalled);
|
||||
|
||||
hwContextContainer.initialize();
|
||||
hwContextContainer.pollForCompletion();
|
||||
hwContextContainer.expectMemory(1, reinterpret_cast<const void *>(0x123), 2, 0);
|
||||
hwContextContainer.submit(1, reinterpret_cast<const void *>(0x123), 2, 0, 1);
|
||||
|
||||
EXPECT_TRUE(mockHwContext0->initializeCalled);
|
||||
EXPECT_TRUE(mockHwContext1->initializeCalled);
|
||||
EXPECT_TRUE(mockHwContext0->pollForCompletionCalled);
|
||||
EXPECT_TRUE(mockHwContext1->pollForCompletionCalled);
|
||||
EXPECT_TRUE(mockHwContext0->expectMemoryCalled);
|
||||
EXPECT_TRUE(mockHwContext1->expectMemoryCalled);
|
||||
EXPECT_TRUE(mockHwContext0->submitCalled);
|
||||
EXPECT_TRUE(mockHwContext1->submitCalled);
|
||||
}
|
||||
|
||||
TEST_F(HardwareContextContainerTests, givenMultipleHwContextWhenSingleMethodIsCalledThenUseFirstContext) {
|
||||
MockAubManager aubManager;
|
||||
HardwareContextController hwContextContainer(aubManager, 1, 2, 0);
|
||||
hwContextContainer.hardwareContexts.emplace_back(aubManager.createHardwareContext(2, 3));
|
||||
EXPECT_EQ(2u, hwContextContainer.hardwareContexts.size());
|
||||
|
||||
auto mockHwContext0 = static_cast<MockHardwareContext *>(hwContextContainer.hardwareContexts[0].get());
|
||||
auto mockHwContext1 = static_cast<MockHardwareContext *>(hwContextContainer.hardwareContexts[1].get());
|
||||
|
||||
EXPECT_FALSE(mockHwContext0->dumpBufferBINCalled);
|
||||
EXPECT_FALSE(mockHwContext1->dumpBufferBINCalled);
|
||||
EXPECT_FALSE(mockHwContext0->readMemoryCalled);
|
||||
EXPECT_FALSE(mockHwContext1->readMemoryCalled);
|
||||
|
||||
hwContextContainer.dumpBufferBIN(1, 2);
|
||||
hwContextContainer.readMemory(1, reinterpret_cast<void *>(0x123), 1, 2, 0);
|
||||
|
||||
EXPECT_TRUE(mockHwContext0->dumpBufferBINCalled);
|
||||
EXPECT_FALSE(mockHwContext1->dumpBufferBINCalled);
|
||||
EXPECT_TRUE(mockHwContext0->readMemoryCalled);
|
||||
EXPECT_FALSE(mockHwContext1->readMemoryCalled);
|
||||
}
|
||||
|
||||
@@ -7,11 +7,13 @@
|
||||
|
||||
#include "runtime/aub_mem_dump/aub_alloc_dump.h"
|
||||
#include "runtime/aub_mem_dump/page_table_entry_bits.h"
|
||||
#include "runtime/helpers/hardware_context_controller.h"
|
||||
#include "runtime/mem_obj/mem_obj_helper.h"
|
||||
#include "test.h"
|
||||
#include "third_party/aub_stream/headers/options.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "unit_tests/mocks/mock_aub_center.h"
|
||||
#include "unit_tests/mocks/mock_aub_csr.h"
|
||||
#include "unit_tests/mocks/mock_aub_file_stream.h"
|
||||
#include "unit_tests/mocks/mock_aub_manager.h"
|
||||
@@ -888,10 +890,15 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWritableWhenDumpA
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.AUBDumpBufferFormat.set("BIN");
|
||||
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "");
|
||||
mockAubCenter->aubManager = std::make_unique<MockAubManager>();
|
||||
|
||||
pDevice->executionEnvironment->aubCenter.reset(mockAubCenter);
|
||||
MockAubCsr<FamilyType> aubCsr(**platformDevices, "", true, *pDevice->executionEnvironment);
|
||||
auto mockManager = std::make_unique<MockAubManager>();
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(mockManager->createHardwareContext(0, EngineType::ENGINE_RCS));
|
||||
aubCsr.hardwareContext = std::unique_ptr<MockHardwareContext>(mockHardwareContext);
|
||||
OsContext osContext(nullptr, 0, {EngineType::ENGINE_RCS, 0}, PreemptionMode::Disabled);
|
||||
aubCsr.setupContext(osContext);
|
||||
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(aubCsr.hardwareContextController->hardwareContexts[0].get());
|
||||
|
||||
auto memoryManager = pDevice->getMemoryManager();
|
||||
auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
@@ -910,10 +917,15 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWritableWhenDumpA
|
||||
HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWritableWhenDumpAllocationIsCalledButDumpFormatIsNotSpecifiedThenGraphicsAllocationShouldNotBeDumped) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "");
|
||||
mockAubCenter->aubManager = std::make_unique<MockAubManager>();
|
||||
|
||||
pDevice->executionEnvironment->aubCenter.reset(mockAubCenter);
|
||||
MockAubCsr<FamilyType> aubCsr(**platformDevices, "", true, *pDevice->executionEnvironment);
|
||||
auto mockManager = std::make_unique<MockAubManager>();
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(mockManager->createHardwareContext(0, EngineType::ENGINE_RCS));
|
||||
aubCsr.hardwareContext = std::unique_ptr<MockHardwareContext>(mockHardwareContext);
|
||||
OsContext osContext(nullptr, 0, {EngineType::ENGINE_RCS, 0}, PreemptionMode::Disabled);
|
||||
aubCsr.setupContext(osContext);
|
||||
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(aubCsr.hardwareContextController->hardwareContexts[0].get());
|
||||
|
||||
auto memoryManager = pDevice->getMemoryManager();
|
||||
auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
@@ -933,10 +945,15 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationNonWritableWhenDu
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.AUBDumpBufferFormat.set("BIN");
|
||||
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "");
|
||||
mockAubCenter->aubManager = std::make_unique<MockAubManager>();
|
||||
|
||||
pDevice->executionEnvironment->aubCenter.reset(mockAubCenter);
|
||||
MockAubCsr<FamilyType> aubCsr(**platformDevices, "", true, *pDevice->executionEnvironment);
|
||||
auto mockManager = std::make_unique<MockAubManager>();
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(mockManager->createHardwareContext(0, EngineType::ENGINE_RCS));
|
||||
aubCsr.hardwareContext = std::unique_ptr<MockHardwareContext>(mockHardwareContext);
|
||||
OsContext osContext(nullptr, 0, {EngineType::ENGINE_RCS, 0}, PreemptionMode::Disabled);
|
||||
aubCsr.setupContext(osContext);
|
||||
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(aubCsr.hardwareContextController->hardwareContexts[0].get());
|
||||
|
||||
auto memoryManager = pDevice->getMemoryManager();
|
||||
auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
@@ -957,10 +974,15 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationNotDumpableWhenDu
|
||||
DebugManager.flags.AUBDumpAllocsOnEnqueueReadOnly.set(true);
|
||||
DebugManager.flags.AUBDumpBufferFormat.set("BIN");
|
||||
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "");
|
||||
mockAubCenter->aubManager = std::make_unique<MockAubManager>();
|
||||
|
||||
pDevice->executionEnvironment->aubCenter.reset(mockAubCenter);
|
||||
MockAubCsr<FamilyType> aubCsr(**platformDevices, "", true, *pDevice->executionEnvironment);
|
||||
auto mockManager = std::make_unique<MockAubManager>();
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(mockManager->createHardwareContext(0, EngineType::ENGINE_RCS));
|
||||
aubCsr.hardwareContext = std::unique_ptr<MockHardwareContext>(mockHardwareContext);
|
||||
OsContext osContext(nullptr, 0, {EngineType::ENGINE_RCS, 0}, PreemptionMode::Disabled);
|
||||
aubCsr.setupContext(osContext);
|
||||
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(aubCsr.hardwareContextController->hardwareContexts[0].get());
|
||||
|
||||
auto memoryManager = pDevice->getMemoryManager();
|
||||
auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
@@ -982,10 +1004,15 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationDumpableWhenDumpA
|
||||
DebugManager.flags.AUBDumpAllocsOnEnqueueReadOnly.set(true);
|
||||
DebugManager.flags.AUBDumpBufferFormat.set("BIN");
|
||||
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "");
|
||||
mockAubCenter->aubManager = std::make_unique<MockAubManager>();
|
||||
|
||||
pDevice->executionEnvironment->aubCenter.reset(mockAubCenter);
|
||||
MockAubCsr<FamilyType> aubCsr(**platformDevices, "", true, *pDevice->executionEnvironment);
|
||||
auto mockManager = std::make_unique<MockAubManager>();
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(mockManager->createHardwareContext(0, EngineType::ENGINE_RCS));
|
||||
aubCsr.hardwareContext = std::unique_ptr<MockHardwareContext>(mockHardwareContext);
|
||||
OsContext osContext(nullptr, 0, {EngineType::ENGINE_RCS, 0}, PreemptionMode::Disabled);
|
||||
aubCsr.setupContext(osContext);
|
||||
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(aubCsr.hardwareContextController->hardwareContexts[0].get());
|
||||
|
||||
auto memoryManager = pDevice->getMemoryManager();
|
||||
auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
|
||||
@@ -6,12 +6,14 @@
|
||||
*/
|
||||
|
||||
#include "runtime/aub_mem_dump/page_table_entry_bits.h"
|
||||
#include "runtime/helpers/hardware_context_controller.h"
|
||||
#include "runtime/command_stream/aub_command_stream_receiver_hw.h"
|
||||
#include "runtime/os_interface/os_context.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "unit_tests/mocks/mock_graphics_allocation.h"
|
||||
#include "unit_tests/mocks/mock_aub_center.h"
|
||||
#include "unit_tests/mocks/mock_aub_csr.h"
|
||||
#include "unit_tests/mocks/mock_aub_file_stream.h"
|
||||
#include "unit_tests/mocks/mock_aub_manager.h"
|
||||
@@ -212,38 +214,42 @@ HWTEST_F(AubFileStreamTests, givenNoNewTaskSinceLastPollWhenDeletingAubCsrThenDo
|
||||
}
|
||||
|
||||
HWTEST_F(AubFileStreamTests, givenNewTasksAndHardwareContextPresentWhenCallingPollForCompletionThenCallPollForCompletion) {
|
||||
auto mockManager = std::make_unique<MockAubManager>();
|
||||
auto hardwareContext = static_cast<MockHardwareContext *>(mockManager->createHardwareContext(0, EngineType::ENGINE_RCS));
|
||||
auto aubStream = std::make_unique<MockAubFileStream>();
|
||||
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
|
||||
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
|
||||
aubCsr->hardwareContext = std::unique_ptr<MockHardwareContext>(hardwareContext);
|
||||
aubCsr->aubManager = mockManager.get();
|
||||
aubCsr->stream = aubStream.get();
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "");
|
||||
mockAubCenter->aubManager = std::make_unique<MockAubManager>();
|
||||
|
||||
aubCsr->taskCount = 50;
|
||||
aubCsr->pollForCompletionTaskCount = 49;
|
||||
pDevice->executionEnvironment->aubCenter.reset(mockAubCenter);
|
||||
MockAubCsr<FamilyType> aubCsr(**platformDevices, "", true, *pDevice->executionEnvironment);
|
||||
OsContext osContext(nullptr, 0, {EngineType::ENGINE_RCS, 0}, PreemptionMode::Disabled);
|
||||
aubCsr.setupContext(osContext);
|
||||
auto hardwareContext = static_cast<MockHardwareContext *>(aubCsr.hardwareContextController->hardwareContexts[0].get());
|
||||
aubCsr.stream = aubStream.get();
|
||||
|
||||
aubCsr.taskCount = 50;
|
||||
aubCsr.pollForCompletionTaskCount = 49;
|
||||
ASSERT_FALSE(hardwareContext->pollForCompletionCalled);
|
||||
|
||||
aubCsr->pollForCompletion();
|
||||
aubCsr.pollForCompletion();
|
||||
EXPECT_TRUE(hardwareContext->pollForCompletionCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(AubFileStreamTests, givenNoNewTasksAndHardwareContextPresentWhenCallingPollForCompletionThenDontCallPollForCompletion) {
|
||||
auto mockManager = std::make_unique<MockAubManager>();
|
||||
auto hardwareContext = static_cast<MockHardwareContext *>(mockManager->createHardwareContext(0, EngineType::ENGINE_RCS));
|
||||
auto aubStream = std::make_unique<MockAubFileStream>();
|
||||
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
|
||||
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
|
||||
aubCsr->hardwareContext = std::unique_ptr<MockHardwareContext>(hardwareContext);
|
||||
aubCsr->aubManager = mockManager.get();
|
||||
aubCsr->stream = aubStream.get();
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "");
|
||||
mockAubCenter->aubManager = std::make_unique<MockAubManager>();
|
||||
|
||||
aubCsr->taskCount = 50;
|
||||
aubCsr->pollForCompletionTaskCount = 50;
|
||||
pDevice->executionEnvironment->aubCenter.reset(mockAubCenter);
|
||||
MockAubCsr<FamilyType> aubCsr(**platformDevices, "", true, *pDevice->executionEnvironment);
|
||||
OsContext osContext(nullptr, 0, {EngineType::ENGINE_RCS, 0}, PreemptionMode::Disabled);
|
||||
aubCsr.setupContext(osContext);
|
||||
auto hardwareContext = static_cast<MockHardwareContext *>(aubCsr.hardwareContextController->hardwareContexts[0].get());
|
||||
aubCsr.stream = aubStream.get();
|
||||
|
||||
aubCsr.taskCount = 50;
|
||||
aubCsr.pollForCompletionTaskCount = 50;
|
||||
ASSERT_FALSE(hardwareContext->pollForCompletionCalled);
|
||||
|
||||
aubCsr->pollForCompletion();
|
||||
aubCsr.pollForCompletion();
|
||||
EXPECT_FALSE(hardwareContext->pollForCompletionCalled);
|
||||
}
|
||||
|
||||
@@ -311,19 +317,26 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenExpectMemoryNotEqu
|
||||
}
|
||||
|
||||
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenItShouldCallTheExpectedHwContextFunctions) {
|
||||
auto mockManager = std::make_unique<MockAubManager>();
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(mockManager->createHardwareContext(0, EngineType::ENGINE_RCS));
|
||||
auto aubStream = std::make_unique<MockAubFileStream>();
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "");
|
||||
mockAubCenter->aubManager = std::make_unique<MockAubManager>();
|
||||
auto mockManager = static_cast<MockAubManager *>(mockAubCenter->aubManager.get());
|
||||
|
||||
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
|
||||
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
|
||||
aubCsr->hardwareContext = std::unique_ptr<MockHardwareContext>(mockHardwareContext);
|
||||
aubCsr->aubManager = mockManager.get();
|
||||
pDevice->executionEnvironment->aubCenter.reset(mockAubCenter);
|
||||
MockAubCsr<FamilyType> aubCsr(**platformDevices, "", true, *pDevice->executionEnvironment);
|
||||
OsContext osContext(nullptr, 0, {EngineType::ENGINE_RCS, 0}, PreemptionMode::Disabled);
|
||||
aubCsr.setupContext(osContext);
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(aubCsr.hardwareContextController->hardwareContexts[0].get());
|
||||
aubCsr.stream = aubStream.get();
|
||||
|
||||
LinearStream cs(aubExecutionEnvironment->commandBuffer);
|
||||
auto commandBuffer = pDevice->executionEnvironment->memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
auto tagAllocation = pDevice->executionEnvironment->memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
aubCsr.setTagAllocation(tagAllocation);
|
||||
LinearStream cs(commandBuffer);
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 1, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
ResidencyContainer allocationsForResidency;
|
||||
|
||||
aubCsr->flush(batchBuffer, allocationsForResidency);
|
||||
aubCsr.flush(batchBuffer, allocationsForResidency);
|
||||
|
||||
EXPECT_TRUE(mockHardwareContext->initializeCalled);
|
||||
EXPECT_TRUE(mockHardwareContext->submitCalled);
|
||||
@@ -332,37 +345,48 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenI
|
||||
//call writeMemory on aubManager to clone page tables
|
||||
EXPECT_FALSE(mockHardwareContext->writeMemoryCalled);
|
||||
EXPECT_TRUE(mockManager->writeMemoryCalled);
|
||||
pDevice->executionEnvironment->memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
}
|
||||
|
||||
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenFlushIsCalledWithZeroSizedBufferThenSubmitIsNotCalledOnHwContext) {
|
||||
auto mockManager = std::make_unique<MockAubManager>();
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(mockManager->createHardwareContext(0, EngineType::ENGINE_RCS));
|
||||
auto aubStream = std::make_unique<MockAubFileStream>();
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "");
|
||||
mockAubCenter->aubManager = std::make_unique<MockAubManager>();
|
||||
|
||||
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
|
||||
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
|
||||
aubCsr->hardwareContext = std::unique_ptr<MockHardwareContext>(mockHardwareContext);
|
||||
pDevice->executionEnvironment->aubCenter.reset(mockAubCenter);
|
||||
MockAubCsr<FamilyType> aubCsr(**platformDevices, "", true, *pDevice->executionEnvironment);
|
||||
OsContext osContext(nullptr, 0, {EngineType::ENGINE_RCS, 0}, PreemptionMode::Disabled);
|
||||
aubCsr.setupContext(osContext);
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(aubCsr.hardwareContextController->hardwareContexts[0].get());
|
||||
aubCsr.stream = aubStream.get();
|
||||
|
||||
LinearStream cs(aubExecutionEnvironment->commandBuffer);
|
||||
auto commandBuffer = pDevice->executionEnvironment->memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
auto tagAllocation = pDevice->executionEnvironment->memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
aubCsr.setTagAllocation(tagAllocation);
|
||||
LinearStream cs(commandBuffer);
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
ResidencyContainer allocationsForResidency;
|
||||
|
||||
aubCsr->flush(batchBuffer, allocationsForResidency);
|
||||
aubCsr.flush(batchBuffer, allocationsForResidency);
|
||||
|
||||
EXPECT_FALSE(mockHardwareContext->submitCalled);
|
||||
pDevice->executionEnvironment->memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
}
|
||||
|
||||
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenMakeResidentIsCalledThenItShouldCallTheExpectedHwContextFunctions) {
|
||||
auto mockManager = std::make_unique<MockAubManager>();
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(mockManager->createHardwareContext(0, EngineType::ENGINE_RCS));
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "");
|
||||
mockAubCenter->aubManager = std::make_unique<MockAubManager>();
|
||||
auto mockManager = static_cast<MockAubManager *>(mockAubCenter->aubManager.get());
|
||||
|
||||
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
|
||||
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
|
||||
aubCsr->hardwareContext = std::unique_ptr<MockHardwareContext>(mockHardwareContext);
|
||||
aubCsr->aubManager = mockManager.get();
|
||||
pDevice->executionEnvironment->aubCenter.reset(mockAubCenter);
|
||||
MockAubCsr<FamilyType> aubCsr(**platformDevices, "", true, *pDevice->executionEnvironment);
|
||||
OsContext osContext(nullptr, 0, {EngineType::ENGINE_RCS, 0}, PreemptionMode::Disabled);
|
||||
aubCsr.setupContext(osContext);
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(aubCsr.hardwareContextController->hardwareContexts[0].get());
|
||||
|
||||
MockGraphicsAllocation allocation(reinterpret_cast<void *>(0x1000), 0x1000);
|
||||
ResidencyContainer allocationsForResidency = {&allocation};
|
||||
aubCsr->processResidency(allocationsForResidency);
|
||||
aubCsr.processResidency(allocationsForResidency);
|
||||
|
||||
//call writeMemory on aubManager to clone page tables
|
||||
EXPECT_FALSE(mockHardwareContext->writeMemoryCalled);
|
||||
@@ -370,29 +394,33 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenMakeResidentIsCall
|
||||
}
|
||||
|
||||
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenExpectMemoryEqualIsCalledThenItShouldCallTheExpectedHwContextFunctions) {
|
||||
auto mockManager = std::make_unique<MockAubManager>();
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(mockManager->createHardwareContext(0, EngineType::ENGINE_RCS));
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "");
|
||||
mockAubCenter->aubManager = std::make_unique<MockAubManager>();
|
||||
|
||||
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
|
||||
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
|
||||
aubCsr->hardwareContext = std::unique_ptr<MockHardwareContext>(mockHardwareContext);
|
||||
pDevice->executionEnvironment->aubCenter.reset(mockAubCenter);
|
||||
MockAubCsr<FamilyType> aubCsr(**platformDevices, "", true, *pDevice->executionEnvironment);
|
||||
OsContext osContext(nullptr, 0, {EngineType::ENGINE_RCS, 0}, PreemptionMode::Disabled);
|
||||
aubCsr.setupContext(osContext);
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(aubCsr.hardwareContextController->hardwareContexts[0].get());
|
||||
|
||||
MockGraphicsAllocation allocation(reinterpret_cast<void *>(0x1000), 0x1000);
|
||||
aubCsr->expectMemoryEqual(reinterpret_cast<void *>(0x1000), reinterpret_cast<void *>(0x1000), 0x1000);
|
||||
aubCsr.expectMemoryEqual(reinterpret_cast<void *>(0x1000), reinterpret_cast<void *>(0x1000), 0x1000);
|
||||
|
||||
EXPECT_TRUE(mockHardwareContext->expectMemoryCalled);
|
||||
}
|
||||
|
||||
HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenExpectMemoryNotEqualIsCalledThenItShouldCallTheExpectedHwContextFunctions) {
|
||||
auto mockManager = std::make_unique<MockAubManager>();
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(mockManager->createHardwareContext(0, EngineType::ENGINE_RCS));
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "");
|
||||
mockAubCenter->aubManager = std::make_unique<MockAubManager>();
|
||||
|
||||
auto aubExecutionEnvironment = getEnvironment<MockAubCsr<FamilyType>>(true, true, true);
|
||||
auto aubCsr = aubExecutionEnvironment->template getCsr<MockAubCsr<FamilyType>>();
|
||||
aubCsr->hardwareContext = std::unique_ptr<MockHardwareContext>(mockHardwareContext);
|
||||
pDevice->executionEnvironment->aubCenter.reset(mockAubCenter);
|
||||
MockAubCsr<FamilyType> aubCsr(**platformDevices, "", true, *pDevice->executionEnvironment);
|
||||
OsContext osContext(nullptr, 0, {EngineType::ENGINE_RCS, 0}, PreemptionMode::Disabled);
|
||||
aubCsr.setupContext(osContext);
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(aubCsr.hardwareContextController->hardwareContexts[0].get());
|
||||
|
||||
MockGraphicsAllocation allocation(reinterpret_cast<void *>(0x1000), 0x1000);
|
||||
aubCsr->expectMemoryNotEqual(reinterpret_cast<void *>(0x1000), reinterpret_cast<void *>(0x1000), 0x1000);
|
||||
aubCsr.expectMemoryNotEqual(reinterpret_cast<void *>(0x1000), reinterpret_cast<void *>(0x1000), 0x1000);
|
||||
|
||||
EXPECT_TRUE(mockHardwareContext->expectMemoryCalled);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "runtime/command_stream/tbx_command_stream_receiver_hw.h"
|
||||
#include "runtime/command_stream/command_stream_receiver_hw.h"
|
||||
#include "runtime/helpers/ptr_math.h"
|
||||
#include "runtime/helpers/hardware_context_controller.h"
|
||||
#include "runtime/memory_manager/memory_banks.h"
|
||||
#include "runtime/os_interface/debug_settings_manager.h"
|
||||
#include "runtime/os_interface/os_context.h"
|
||||
@@ -340,20 +341,24 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenItIsCreatedWith
|
||||
}
|
||||
|
||||
HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenFlushIsCalledThenItShouldCallTheExpectedHwContextFunctions) {
|
||||
auto mockManager = std::make_unique<MockAubManager>();
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(mockManager->createHardwareContext(0, EngineType::ENGINE_RCS));
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "");
|
||||
mockAubCenter->aubManager = std::make_unique<MockAubManager>();
|
||||
auto mockManager = static_cast<MockAubManager *>(mockAubCenter->aubManager.get());
|
||||
|
||||
auto tbxExecutionEnvironment = getEnvironment<MockTbxCsr<FamilyType>>(true, true);
|
||||
auto tbxCsr = tbxExecutionEnvironment->template getCsr<MockTbxCsr<FamilyType>>();
|
||||
tbxCsr->hardwareContext = std::unique_ptr<MockHardwareContext>(mockHardwareContext);
|
||||
tbxCsr->aubManager = mockManager.get();
|
||||
pDevice->executionEnvironment->aubCenter.reset(mockAubCenter);
|
||||
MockTbxCsr<FamilyType> tbxCsr(**platformDevices, *pDevice->executionEnvironment);
|
||||
OsContext osContext(nullptr, 0, {EngineType::ENGINE_RCS, 0}, PreemptionMode::Disabled);
|
||||
tbxCsr.setupContext(osContext);
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(tbxCsr.hardwareContextController->hardwareContexts[0].get());
|
||||
|
||||
LinearStream cs(tbxExecutionEnvironment->commandBuffer);
|
||||
auto commandBuffer = pDevice->executionEnvironment->memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
|
||||
LinearStream cs(commandBuffer);
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 1, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
MockGraphicsAllocation allocation(reinterpret_cast<void *>(0x1000), 0x1000);
|
||||
ResidencyContainer allocationsForResidency = {&allocation};
|
||||
|
||||
tbxCsr->flush(batchBuffer, allocationsForResidency);
|
||||
tbxCsr.flush(batchBuffer, allocationsForResidency);
|
||||
|
||||
EXPECT_TRUE(mockHardwareContext->initializeCalled);
|
||||
EXPECT_TRUE(mockHardwareContext->submitCalled);
|
||||
@@ -362,61 +367,74 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenFlushIsCalledTh
|
||||
//call writeMemory on aubManager to clone page tables
|
||||
EXPECT_FALSE(mockHardwareContext->writeMemoryCalled);
|
||||
EXPECT_TRUE(mockManager->writeMemoryCalled);
|
||||
pDevice->executionEnvironment->memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
}
|
||||
|
||||
HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverInBatchedModeWhenFlushIsCalledThenItShouldMakeCommandBufferResident) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.CsrDispatchMode.set(static_cast<uint32_t>(DispatchMode::BatchedDispatch));
|
||||
|
||||
auto mockManager = std::make_unique<MockAubManager>();
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(mockManager->createHardwareContext(0, EngineType::ENGINE_RCS));
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "");
|
||||
mockAubCenter->aubManager = std::make_unique<MockAubManager>();
|
||||
auto mockManager = static_cast<MockAubManager *>(mockAubCenter->aubManager.get());
|
||||
|
||||
auto tbxExecutionEnvironment = getEnvironment<MockTbxCsr<FamilyType>>(true, true);
|
||||
auto tbxCsr = tbxExecutionEnvironment->template getCsr<MockTbxCsr<FamilyType>>();
|
||||
tbxCsr->hardwareContext = std::unique_ptr<MockHardwareContext>(mockHardwareContext);
|
||||
tbxCsr->aubManager = mockManager.get();
|
||||
pDevice->executionEnvironment->aubCenter.reset(mockAubCenter);
|
||||
MockTbxCsr<FamilyType> tbxCsr(**platformDevices, *pDevice->executionEnvironment);
|
||||
OsContext osContext(nullptr, 0, {EngineType::ENGINE_RCS, 0}, PreemptionMode::Disabled);
|
||||
tbxCsr.setupContext(osContext);
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(tbxCsr.hardwareContextController->hardwareContexts[0].get());
|
||||
|
||||
LinearStream cs(tbxExecutionEnvironment->commandBuffer);
|
||||
auto commandBuffer = pDevice->executionEnvironment->memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
|
||||
LinearStream cs(commandBuffer);
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 1, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
ResidencyContainer allocationsForResidency;
|
||||
|
||||
tbxCsr->flush(batchBuffer, allocationsForResidency);
|
||||
tbxCsr.flush(batchBuffer, allocationsForResidency);
|
||||
|
||||
//call writeMemory on aubManager to clone page tables
|
||||
EXPECT_FALSE(mockHardwareContext->writeMemoryCalled);
|
||||
EXPECT_TRUE(mockManager->writeMemoryCalled);
|
||||
EXPECT_EQ(1u, batchBuffer.commandBufferAllocation->getResidencyTaskCount(tbxCsr->getOsContext().getContextId()));
|
||||
EXPECT_EQ(1u, batchBuffer.commandBufferAllocation->getResidencyTaskCount(tbxCsr.getOsContext().getContextId()));
|
||||
pDevice->executionEnvironment->memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
}
|
||||
|
||||
HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenFlushIsCalledWithZeroSizedBufferThenSubmitIsNotCalledOnHwContext) {
|
||||
auto mockManager = std::make_unique<MockAubManager>();
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(mockManager->createHardwareContext(0, EngineType::ENGINE_RCS));
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "");
|
||||
mockAubCenter->aubManager = std::make_unique<MockAubManager>();
|
||||
|
||||
auto tbxExecutionEnvironment = getEnvironment<MockTbxCsr<FamilyType>>(true, true);
|
||||
auto tbxCsr = tbxExecutionEnvironment->template getCsr<MockTbxCsr<FamilyType>>();
|
||||
tbxCsr->hardwareContext = std::unique_ptr<MockHardwareContext>(mockHardwareContext);
|
||||
pDevice->executionEnvironment->aubCenter.reset(mockAubCenter);
|
||||
MockTbxCsr<FamilyType> tbxCsr(**platformDevices, *pDevice->executionEnvironment);
|
||||
OsContext osContext(nullptr, 0, {EngineType::ENGINE_RCS, 0}, PreemptionMode::Disabled);
|
||||
tbxCsr.setupContext(osContext);
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(tbxCsr.hardwareContextController->hardwareContexts[0].get());
|
||||
|
||||
LinearStream cs(tbxExecutionEnvironment->commandBuffer);
|
||||
auto commandBuffer = pDevice->executionEnvironment->memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
|
||||
LinearStream cs(commandBuffer);
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
ResidencyContainer allocationsForResidency;
|
||||
|
||||
tbxCsr->flush(batchBuffer, allocationsForResidency);
|
||||
tbxCsr.flush(batchBuffer, allocationsForResidency);
|
||||
|
||||
EXPECT_FALSE(mockHardwareContext->submitCalled);
|
||||
pDevice->executionEnvironment->memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
}
|
||||
|
||||
HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeResidentIsCalledThenItShouldCallTheExpectedHwContextFunctions) {
|
||||
auto mockManager = std::make_unique<MockAubManager>();
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(mockManager->createHardwareContext(0, EngineType::ENGINE_RCS));
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "");
|
||||
mockAubCenter->aubManager = std::make_unique<MockAubManager>();
|
||||
auto mockManager = static_cast<MockAubManager *>(mockAubCenter->aubManager.get());
|
||||
|
||||
auto tbxExecutionEnvironment = getEnvironment<MockTbxCsr<FamilyType>>(true, true);
|
||||
auto tbxCsr = tbxExecutionEnvironment->template getCsr<MockTbxCsr<FamilyType>>();
|
||||
tbxCsr->hardwareContext = std::unique_ptr<MockHardwareContext>(mockHardwareContext);
|
||||
tbxCsr->aubManager = mockManager.get();
|
||||
pDevice->executionEnvironment->aubCenter.reset(mockAubCenter);
|
||||
MockTbxCsr<FamilyType> tbxCsr(**platformDevices, *pDevice->executionEnvironment);
|
||||
OsContext osContext(nullptr, 0, {EngineType::ENGINE_RCS, 0}, PreemptionMode::Disabled);
|
||||
tbxCsr.setupContext(osContext);
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(tbxCsr.hardwareContextController->hardwareContexts[0].get());
|
||||
|
||||
MockGraphicsAllocation allocation(reinterpret_cast<void *>(0x1000), 0x1000);
|
||||
ResidencyContainer allocationsForResidency = {&allocation};
|
||||
tbxCsr->processResidency(allocationsForResidency);
|
||||
tbxCsr.processResidency(allocationsForResidency);
|
||||
|
||||
//call writeMemory on aubManager to clone page tables
|
||||
EXPECT_FALSE(mockHardwareContext->writeMemoryCalled);
|
||||
@@ -424,15 +442,17 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeResidentIsC
|
||||
}
|
||||
|
||||
HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeCoherentIsCalledThenItShouldCallTheExpectedHwContextFunctions) {
|
||||
auto mockManager = std::make_unique<MockAubManager>();
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(mockManager->createHardwareContext(0, EngineType::ENGINE_RCS));
|
||||
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, "");
|
||||
mockAubCenter->aubManager = std::make_unique<MockAubManager>();
|
||||
|
||||
auto tbxExecutionEnvironment = getEnvironment<MockTbxCsr<FamilyType>>(true, true);
|
||||
auto tbxCsr = tbxExecutionEnvironment->template getCsr<MockTbxCsr<FamilyType>>();
|
||||
tbxCsr->hardwareContext = std::unique_ptr<MockHardwareContext>(mockHardwareContext);
|
||||
pDevice->executionEnvironment->aubCenter.reset(mockAubCenter);
|
||||
MockTbxCsr<FamilyType> tbxCsr(**platformDevices, *pDevice->executionEnvironment);
|
||||
OsContext osContext(nullptr, 0, {EngineType::ENGINE_RCS, 0}, PreemptionMode::Disabled);
|
||||
tbxCsr.setupContext(osContext);
|
||||
auto mockHardwareContext = static_cast<MockHardwareContext *>(tbxCsr.hardwareContextController->hardwareContexts[0].get());
|
||||
|
||||
MockGraphicsAllocation allocation(reinterpret_cast<void *>(0x1000), 0x1000);
|
||||
tbxCsr->makeCoherent(allocation);
|
||||
tbxCsr.makeCoherent(allocation);
|
||||
|
||||
EXPECT_TRUE(mockHardwareContext->readMemoryCalled);
|
||||
}
|
||||
@@ -460,8 +480,8 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenOsContextIsSetThenCreateHardwareC
|
||||
executionEnvironment.aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
|
||||
|
||||
std::unique_ptr<TbxCommandStreamReceiverHw<FamilyType>> tbxCsr(reinterpret_cast<TbxCommandStreamReceiverHw<FamilyType> *>(TbxCommandStreamReceiver::create(*platformDevices[0], fileName, true, executionEnvironment)));
|
||||
EXPECT_EQ(nullptr, tbxCsr->hardwareContext.get());
|
||||
EXPECT_EQ(nullptr, tbxCsr->hardwareContextController.get());
|
||||
|
||||
tbxCsr->setupContext(osContext);
|
||||
EXPECT_NE(nullptr, tbxCsr->hardwareContext.get());
|
||||
EXPECT_NE(nullptr, tbxCsr->hardwareContextController.get());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user