Skip to content

Commit 23fcbb3

Browse files
WriteMemory support in HardwareContextController
Change-Id: Ie63b12fb8fb78a2d68b8ed84c1ebe9d634e9804b Signed-off-by: Dunajski, Bartosz <[email protected]>
1 parent 5dae278 commit 23fcbb3

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

runtime/helpers/hardware_context_controller.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ void HardwareContextController::submit(uint64_t batchBufferGpuAddress, const voi
5050
}
5151
}
5252

53+
void HardwareContextController::writeMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t memoryBanks, int hint, size_t pageSize) {
54+
for (auto &hardwareContext : hardwareContexts) {
55+
hardwareContext->writeMemory(gfxAddress, memory, size, memoryBanks, hint, pageSize);
56+
}
57+
}
58+
5359
void HardwareContextController::dumpBufferBIN(uint64_t gfxAddress, size_t size) {
5460
hardwareContexts[0]->dumpBufferBIN(gfxAddress, size);
5561
}

runtime/helpers/hardware_context_controller.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class HardwareContextController {
2525
void pollForCompletion();
2626
void expectMemory(uint64_t gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation);
2727
void submit(uint64_t batchBufferGpuAddress, const void *batchBuffer, size_t batchBufferSize, uint32_t memoryBank, uint64_t entryBits);
28+
void writeMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t memoryBanks, int hint, size_t pageSize);
2829

2930
void dumpBufferBIN(uint64_t gfxAddress, size_t size);
3031
void readMemory(uint64_t gfxAddress, void *memory, size_t size, uint32_t memoryBanks, size_t pageSize);

unit_tests/command_stream/aub_command_stream_receiver_1_tests.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,10 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess
699699

700700
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMemoryIsCalledOnBufferAndImageTypeAllocationsThenAllocationsHaveAubWritableSetToFalse) {
701701
std::unique_ptr<MemoryManager> memoryManager(nullptr);
702+
702703
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, *pDevice->executionEnvironment));
704+
aubCsr->setupContext(*pDevice->getDefaultEngine().osContext);
705+
703706
memoryManager.reset(aubCsr->createMemoryManager(false, false));
704707

705708
auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
@@ -819,6 +822,8 @@ HWTEST_F(AubCommandStreamReceiverTests, givenOsContextWithMultipleDevicesSupport
819822
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphicsAllocationTypeIsntNonAubWritableThenWriteMemoryIsAllowed) {
820823
std::unique_ptr<MemoryManager> memoryManager(nullptr);
821824
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, *pDevice->executionEnvironment));
825+
aubCsr->setupContext(*pDevice->getDefaultEngine().osContext);
826+
822827
memoryManager.reset(aubCsr->createMemoryManager(false, false));
823828

824829
auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
@@ -850,6 +855,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphic
850855

851856
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAllocationDataIsPassedInAllocationViewThenWriteMemoryIsAllowed) {
852857
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(*platformDevices[0], "", true, *pDevice->executionEnvironment);
858+
aubCsr->setupContext(*pDevice->getDefaultEngine().osContext);
853859
size_t size = 100;
854860
auto ptr = std::make_unique<char[]>(size);
855861
auto addr = reinterpret_cast<uint64_t>(ptr.get());
@@ -1153,11 +1159,14 @@ TEST_F(HardwareContextContainerTests, givenMultipleHwContextWhenSingleMethodIsCa
11531159
EXPECT_FALSE(mockHwContext1->expectMemoryCalled);
11541160
EXPECT_FALSE(mockHwContext0->submitCalled);
11551161
EXPECT_FALSE(mockHwContext1->submitCalled);
1162+
EXPECT_FALSE(mockHwContext0->writeMemoryCalled);
1163+
EXPECT_FALSE(mockHwContext1->writeMemoryCalled);
11561164

11571165
hwContextContainer.initialize();
11581166
hwContextContainer.pollForCompletion();
11591167
hwContextContainer.expectMemory(1, reinterpret_cast<const void *>(0x123), 2, 0);
11601168
hwContextContainer.submit(1, reinterpret_cast<const void *>(0x123), 2, 0, 1);
1169+
hwContextContainer.writeMemory(1, reinterpret_cast<const void *>(0x123), 2, 3, 4, 5);
11611170

11621171
EXPECT_TRUE(mockHwContext0->initializeCalled);
11631172
EXPECT_TRUE(mockHwContext1->initializeCalled);
@@ -1167,6 +1176,8 @@ TEST_F(HardwareContextContainerTests, givenMultipleHwContextWhenSingleMethodIsCa
11671176
EXPECT_TRUE(mockHwContext1->expectMemoryCalled);
11681177
EXPECT_TRUE(mockHwContext0->submitCalled);
11691178
EXPECT_TRUE(mockHwContext1->submitCalled);
1179+
EXPECT_TRUE(mockHwContext0->writeMemoryCalled);
1180+
EXPECT_TRUE(mockHwContext1->writeMemoryCalled);
11701181
}
11711182

11721183
TEST_F(HardwareContextContainerTests, givenMultipleHwContextWhenSingleMethodIsCalledThenUseFirstContext) {

unit_tests/command_stream/aub_command_stream_receiver_2_tests.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,11 @@ HWTEST_F(AubCommandStreamReceiverNoHostPtrTests, givenAubCommandStreamReceiverWh
476476
ExecutionEnvironment executionEnvironment;
477477
auto memoryManager = new OsAgnosticMemoryManagerForImagesWithNoHostPtr(executionEnvironment);
478478
executionEnvironment.memoryManager.reset(memoryManager);
479+
auto engineInstance = HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0];
479480

481+
OsContext osContext(nullptr, 0, 1, engineInstance, PreemptionMode::Disabled);
480482
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, executionEnvironment));
483+
aubCsr->setupContext(osContext);
481484

482485
cl_image_desc imgDesc = {};
483486
imgDesc.image_width = 512;

0 commit comments

Comments
 (0)