mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
fix: capability to write memory chunk in aub/tbx mode
Related-To: GSD-6604 Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
faaceaaff8
commit
25195ebc96
@@ -33,6 +33,14 @@ struct WaitUserFenceParams {
|
||||
bool forceRetStatusValue = true;
|
||||
};
|
||||
|
||||
struct WriteMemoryParams {
|
||||
GraphicsAllocation *latestGfxAllocation = nullptr;
|
||||
uint64_t latestGpuVaChunkOffset = 0;
|
||||
size_t latestChunkSize = 0;
|
||||
uint32_t callCount = 0;
|
||||
bool latestChunkedMode = false;
|
||||
};
|
||||
|
||||
template <typename GfxFamily>
|
||||
class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, public NonCopyableOrMovableClass {
|
||||
using BaseClass = CommandStreamReceiverHw<GfxFamily>;
|
||||
@@ -207,6 +215,17 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
|
||||
return BaseClass::flushImmediateTask(immediateCommandStream, immediateCommandStreamStart, dispatchFlags, device);
|
||||
}
|
||||
|
||||
bool writeMemory(GraphicsAllocation &gfxAllocation, bool isChunkCopy, uint64_t gpuVaChunkOffset, size_t chunkSize) override {
|
||||
writeMemoryParams.callCount++;
|
||||
|
||||
writeMemoryParams.latestGfxAllocation = &gfxAllocation;
|
||||
writeMemoryParams.latestChunkedMode = isChunkCopy;
|
||||
writeMemoryParams.latestGpuVaChunkOffset = gpuVaChunkOffset;
|
||||
writeMemoryParams.latestChunkSize = chunkSize;
|
||||
|
||||
return BaseClass::writeMemory(gfxAllocation, isChunkCopy, gpuVaChunkOffset, chunkSize);
|
||||
}
|
||||
|
||||
size_t getPreferredTagPoolSize() const override {
|
||||
return BaseClass::getPreferredTagPoolSize() + 1;
|
||||
}
|
||||
@@ -447,6 +466,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
|
||||
TaskCountType latestSentTaskCountValueDuringFlush = 0;
|
||||
WaitParams latestWaitForCompletionWithTimeoutWaitParams{0};
|
||||
WaitUserFenceParams waitUserFenecParams;
|
||||
WriteMemoryParams writeMemoryParams;
|
||||
TaskCountType flushBcsTaskReturnValue{};
|
||||
|
||||
LinearStream *lastFlushedCommandStream = nullptr;
|
||||
|
||||
@@ -103,8 +103,8 @@ struct MockAubCsr : public AUBCommandStreamReceiverHw<GfxFamily> {
|
||||
batchBufferGpuAddressPassed = batchBufferGpuAddress;
|
||||
}
|
||||
|
||||
void writeMemoryWithAubManager(GraphicsAllocation &graphicsAllocation) override {
|
||||
CommandStreamReceiverSimulatedHw<GfxFamily>::writeMemoryWithAubManager(graphicsAllocation);
|
||||
void writeMemoryWithAubManager(GraphicsAllocation &graphicsAllocation, bool isChunkCopy, uint64_t gpuVaChunkOffset, size_t chunkSize) override {
|
||||
CommandStreamReceiverSimulatedHw<GfxFamily>::writeMemoryWithAubManager(graphicsAllocation, isChunkCopy, gpuVaChunkOffset, chunkSize);
|
||||
writeMemoryWithAubManagerCalled = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ class MockTbxCsr : public TbxCommandStreamReceiverHw<GfxFamily> {
|
||||
initializeEngineCalled = true;
|
||||
}
|
||||
|
||||
void writeMemoryWithAubManager(GraphicsAllocation &graphicsAllocation) override {
|
||||
CommandStreamReceiverSimulatedHw<GfxFamily>::writeMemoryWithAubManager(graphicsAllocation);
|
||||
void writeMemoryWithAubManager(GraphicsAllocation &graphicsAllocation, bool isChunkCopy, uint64_t gpuVaChunkOffset, size_t chunkSize) override {
|
||||
CommandStreamReceiverSimulatedHw<GfxFamily>::writeMemoryWithAubManager(graphicsAllocation, isChunkCopy, gpuVaChunkOffset, chunkSize);
|
||||
writeMemoryWithAubManagerCalled = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ struct MockAubCsrToTestDumpAubNonWritable : public AUBCommandStreamReceiverHw<Gf
|
||||
using AUBCommandStreamReceiverHw<GfxFamily>::AUBCommandStreamReceiverHw;
|
||||
using AUBCommandStreamReceiverHw<GfxFamily>::dumpAubNonWritable;
|
||||
|
||||
bool writeMemory(GraphicsAllocation &gfxAllocation) override {
|
||||
bool writeMemory(GraphicsAllocation &gfxAllocation, bool isChunkCopy, uint64_t gpuVaChunkOffset, size_t chunkSize) override {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -114,7 +114,7 @@ HWTEST_F(AubCsrTest, WhenWriteWithAubManagerIsCalledThenAubManagerIsInvokedWithC
|
||||
PreemptionHelper::getDefaultPreemptionMode(hwInfo)));
|
||||
aubCsr->setupContext(*osContext);
|
||||
|
||||
aubCsr->writeMemoryWithAubManager(*allocation);
|
||||
aubCsr->writeMemoryWithAubManager(*allocation, false, 0, 0);
|
||||
EXPECT_TRUE(aubManager.writeMemory2Called);
|
||||
EXPECT_EQ(AubMemDump::DataTypeHintValues::TraceBatchBuffer, aubManager.hintToWriteMemory);
|
||||
|
||||
@@ -122,7 +122,7 @@ HWTEST_F(AubCsrTest, WhenWriteWithAubManagerIsCalledThenAubManagerIsInvokedWithC
|
||||
|
||||
auto allocation2 = executionEnvironment->memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{rootDeviceIndex, true, MemoryConstants::pageSize, AllocationType::LINEAR_STREAM});
|
||||
|
||||
aubCsr->writeMemoryWithAubManager(*allocation2);
|
||||
aubCsr->writeMemoryWithAubManager(*allocation2, true, 1, 1);
|
||||
EXPECT_TRUE(aubManager.writeMemory2Called);
|
||||
EXPECT_EQ(AubMemDump::DataTypeHintValues::TraceNotype, aubManager.hintToWriteMemory);
|
||||
|
||||
|
||||
@@ -313,7 +313,7 @@ HWTEST_F(CommandStreamSimulatedTests, givenSimulatedCommandStreamReceiverWhenClo
|
||||
GraphicsAllocation graphicsAllocation{0, AllocationType::UNKNOWN,
|
||||
&dummy, 0, 0, sizeof(dummy), MemoryPool::MemoryNull, MemoryManager::maxOsContextCount};
|
||||
graphicsAllocation.storageInfo.cloningOfPageTables = true;
|
||||
csr->writeMemoryWithAubManager(graphicsAllocation);
|
||||
csr->writeMemoryWithAubManager(graphicsAllocation, false, 0, 0);
|
||||
|
||||
EXPECT_FALSE(mockHardwareContext->writeMemory2Called);
|
||||
EXPECT_TRUE(mockManager->writeMemory2Called);
|
||||
@@ -339,7 +339,7 @@ HWTEST_F(CommandStreamSimulatedTests, givenCompressedAllocationWhenCloningPageTa
|
||||
|
||||
graphicsAllocation.setDefaultGmm(&gmm);
|
||||
|
||||
csr->writeMemoryWithAubManager(graphicsAllocation);
|
||||
csr->writeMemoryWithAubManager(graphicsAllocation, false, 0, 0);
|
||||
|
||||
EXPECT_FALSE(mockHardwareContext->writeMemory2Called);
|
||||
EXPECT_TRUE(mockManager->writeMemory2Called);
|
||||
@@ -369,7 +369,7 @@ HWTEST_F(CommandStreamSimulatedTests, givenUncachedAllocationWhenCloningPageTabl
|
||||
|
||||
graphicsAllocation.setDefaultGmm(&gmm);
|
||||
|
||||
csr->writeMemoryWithAubManager(graphicsAllocation);
|
||||
csr->writeMemoryWithAubManager(graphicsAllocation, false, 0, 0);
|
||||
|
||||
EXPECT_FALSE(mockHardwareContext->writeMemory2Called);
|
||||
EXPECT_TRUE(mockManager->writeMemory2Called);
|
||||
@@ -396,7 +396,7 @@ HWTEST_F(CommandStreamSimulatedTests, givenTileInstancedAllocationWhenWriteMemor
|
||||
graphicsAllocation.storageInfo.cloningOfPageTables = false;
|
||||
graphicsAllocation.storageInfo.tileInstanced = true;
|
||||
graphicsAllocation.storageInfo.memoryBanks = 0b11u;
|
||||
csr->writeMemoryWithAubManager(graphicsAllocation);
|
||||
csr->writeMemoryWithAubManager(graphicsAllocation, false, 0, 0);
|
||||
|
||||
EXPECT_TRUE(firstMockHardwareContext->writeMemory2Called);
|
||||
EXPECT_EQ(0b01u, firstMockHardwareContext->memoryBanksPassed);
|
||||
@@ -431,7 +431,7 @@ HWTEST_F(CommandStreamSimulatedTests, givenCompressedTileInstancedAllocationWhen
|
||||
|
||||
graphicsAllocation.setDefaultGmm(&gmm);
|
||||
|
||||
csr->writeMemoryWithAubManager(graphicsAllocation);
|
||||
csr->writeMemoryWithAubManager(graphicsAllocation, false, 0, 0);
|
||||
|
||||
EXPECT_TRUE(firstMockHardwareContext->writeMemory2Called);
|
||||
EXPECT_EQ(1u, firstMockHardwareContext->storedAllocationParams.size());
|
||||
@@ -470,7 +470,7 @@ HWTEST_F(CommandStreamSimulatedTests, givenUncachedTileInstancedAllocationWhenWr
|
||||
|
||||
graphicsAllocation.setDefaultGmm(&gmm);
|
||||
|
||||
csr->writeMemoryWithAubManager(graphicsAllocation);
|
||||
csr->writeMemoryWithAubManager(graphicsAllocation, false, 0, 0);
|
||||
|
||||
EXPECT_TRUE(firstMockHardwareContext->writeMemory2Called);
|
||||
EXPECT_EQ(1u, firstMockHardwareContext->storedAllocationParams.size());
|
||||
@@ -500,7 +500,7 @@ HWTEST_F(CommandStreamSimulatedTests, givenTileInstancedAllocationWithMissingMem
|
||||
graphicsAllocation.storageInfo.cloningOfPageTables = false;
|
||||
graphicsAllocation.storageInfo.tileInstanced = true;
|
||||
graphicsAllocation.storageInfo.memoryBanks = 2u;
|
||||
EXPECT_THROW(csr->writeMemoryWithAubManager(graphicsAllocation), std::exception);
|
||||
EXPECT_THROW(csr->writeMemoryWithAubManager(graphicsAllocation, false, 0, 0), std::exception);
|
||||
EXPECT_FALSE(firstMockHardwareContext->writeMemory2Called);
|
||||
EXPECT_FALSE(secondMockHardwareContext->writeMemory2Called);
|
||||
}
|
||||
@@ -514,7 +514,7 @@ HWTEST_F(CommandStreamSimulatedTests, givenCommandBufferAllocationWhenWriteMemor
|
||||
GraphicsAllocation graphicsAllocation{0, AllocationType::COMMAND_BUFFER,
|
||||
&dummy, 0, 0, sizeof(dummy), MemoryPool::MemoryNull, MemoryManager::maxOsContextCount};
|
||||
graphicsAllocation.storageInfo.cloningOfPageTables = true;
|
||||
csr->writeMemoryWithAubManager(graphicsAllocation);
|
||||
csr->writeMemoryWithAubManager(graphicsAllocation, false, 0, 0);
|
||||
|
||||
EXPECT_EQ(AubMemDump::DataTypeHintValues::TraceBatchBuffer, mockManager->hintToWriteMemory);
|
||||
EXPECT_TRUE(mockManager->writeMemory2Called);
|
||||
@@ -548,13 +548,13 @@ HWTEST_F(CommandStreamSimulatedTests, givenSpecificMemoryPoolAllocationWhenWrite
|
||||
GraphicsAllocation graphicsAllocation{0, AllocationType::COMMAND_BUFFER,
|
||||
&dummy, 0, 0, sizeof(dummy), poolsWith4kPages[i], MemoryManager::maxOsContextCount};
|
||||
graphicsAllocation.storageInfo.cloningOfPageTables = true;
|
||||
csr->writeMemoryWithAubManager(graphicsAllocation);
|
||||
csr->writeMemoryWithAubManager(graphicsAllocation, false, 0, 0);
|
||||
|
||||
EXPECT_TRUE(mockManager->writeMemory2Called);
|
||||
EXPECT_EQ(MemoryConstants::pageSize, mockManager->writeMemoryPageSizePassed);
|
||||
|
||||
graphicsAllocation.storageInfo.cloningOfPageTables = false;
|
||||
csr->writeMemoryWithAubManager(graphicsAllocation);
|
||||
csr->writeMemoryWithAubManager(graphicsAllocation, false, 0, 0);
|
||||
|
||||
if (graphicsAllocation.isAllocatedInLocalMemoryPool()) {
|
||||
EXPECT_TRUE(mockHardwareContext->writeMemory2Called);
|
||||
@@ -581,13 +581,13 @@ HWTEST_F(CommandStreamSimulatedTests, givenSpecificMemoryPoolAllocationWhenWrite
|
||||
GraphicsAllocation graphicsAllocation{0, AllocationType::COMMAND_BUFFER,
|
||||
&dummy, 0, 0, sizeof(dummy), poolsWith64kPages[i], MemoryManager::maxOsContextCount};
|
||||
graphicsAllocation.storageInfo.cloningOfPageTables = true;
|
||||
csr->writeMemoryWithAubManager(graphicsAllocation);
|
||||
csr->writeMemoryWithAubManager(graphicsAllocation, false, 0, 0);
|
||||
|
||||
EXPECT_TRUE(mockManager->writeMemory2Called);
|
||||
EXPECT_EQ(MemoryConstants::pageSize64k, mockManager->writeMemoryPageSizePassed);
|
||||
|
||||
graphicsAllocation.storageInfo.cloningOfPageTables = false;
|
||||
csr->writeMemoryWithAubManager(graphicsAllocation);
|
||||
csr->writeMemoryWithAubManager(graphicsAllocation, false, 0, 0);
|
||||
|
||||
if (graphicsAllocation.isAllocatedInLocalMemoryPool()) {
|
||||
EXPECT_TRUE(mockHardwareContext->writeMemory2Called);
|
||||
|
||||
@@ -1454,6 +1454,19 @@ TEST(CommandStreamReceiverSimpleTest, givenVariousDataSetsWhenVerifyingMemoryThe
|
||||
EXPECT_TRUE(csr.expectMemory(setA2, setB2, setSize, compareNotEqual));
|
||||
}
|
||||
|
||||
TEST(CommandStreamReceiverSimpleTest, givenBaseCsrWhenWritingMemoryThenReturnFalse) {
|
||||
MockExecutionEnvironment executionEnvironment;
|
||||
executionEnvironment.prepareRootDeviceEnvironments(1);
|
||||
executionEnvironment.initializeMemoryManager();
|
||||
|
||||
DeviceBitfield deviceBitfield(1);
|
||||
MockCommandStreamReceiver csr(executionEnvironment, 0, deviceBitfield);
|
||||
|
||||
MockGraphicsAllocation mockAllocation;
|
||||
|
||||
EXPECT_FALSE(csr.writeMemory(mockAllocation));
|
||||
}
|
||||
|
||||
TEST(CommandStreamReceiverSimpleTest, givenNewResourceFlushDisabledWhenProvidingNeverUsedAllocationTaskCountThenDoNotMarkNewResourceTrue) {
|
||||
MockExecutionEnvironment executionEnvironment;
|
||||
executionEnvironment.prepareRootDeviceEnvironments(1);
|
||||
|
||||
@@ -305,6 +305,43 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
|
||||
memoryManager->freeGraphicsMemoryImpl(gfxAllocation);
|
||||
}
|
||||
|
||||
HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAubDumpWhenWriteMemoryIsCalledThenBothCommandStreamReceiversAreCalled) {
|
||||
MockGraphicsAllocation mockAllocation;
|
||||
|
||||
EXPECT_EQ(0u, csrWithAubDump->writeMemoryParams.callCount);
|
||||
if (createAubCSR) {
|
||||
EXPECT_EQ(0u, csrWithAubDump->getAubMockCsr().writeMemoryParams.callCount);
|
||||
}
|
||||
|
||||
csrWithAubDump->writeMemory(mockAllocation, false, 0, 0);
|
||||
|
||||
EXPECT_EQ(1u, csrWithAubDump->writeMemoryParams.callCount);
|
||||
EXPECT_EQ(&mockAllocation, csrWithAubDump->writeMemoryParams.latestGfxAllocation);
|
||||
EXPECT_FALSE(csrWithAubDump->writeMemoryParams.latestChunkedMode);
|
||||
|
||||
if (createAubCSR) {
|
||||
EXPECT_EQ(1u, csrWithAubDump->getAubMockCsr().writeMemoryParams.callCount);
|
||||
EXPECT_EQ(&mockAllocation, csrWithAubDump->getAubMockCsr().writeMemoryParams.latestGfxAllocation);
|
||||
EXPECT_FALSE(csrWithAubDump->getAubMockCsr().writeMemoryParams.latestChunkedMode);
|
||||
}
|
||||
|
||||
csrWithAubDump->writeMemory(mockAllocation, true, 1, 2);
|
||||
|
||||
EXPECT_EQ(2u, csrWithAubDump->writeMemoryParams.callCount);
|
||||
EXPECT_TRUE(csrWithAubDump->writeMemoryParams.latestChunkedMode);
|
||||
EXPECT_EQ(&mockAllocation, csrWithAubDump->writeMemoryParams.latestGfxAllocation);
|
||||
EXPECT_EQ(1u, csrWithAubDump->writeMemoryParams.latestGpuVaChunkOffset);
|
||||
EXPECT_EQ(2u, csrWithAubDump->writeMemoryParams.latestChunkSize);
|
||||
|
||||
if (createAubCSR) {
|
||||
EXPECT_EQ(2u, csrWithAubDump->getAubMockCsr().writeMemoryParams.callCount);
|
||||
EXPECT_TRUE(csrWithAubDump->getAubMockCsr().writeMemoryParams.latestChunkedMode);
|
||||
EXPECT_EQ(&mockAllocation, csrWithAubDump->getAubMockCsr().writeMemoryParams.latestGfxAllocation);
|
||||
EXPECT_EQ(1u, csrWithAubDump->getAubMockCsr().writeMemoryParams.latestGpuVaChunkOffset);
|
||||
EXPECT_EQ(2u, csrWithAubDump->getAubMockCsr().writeMemoryParams.latestChunkSize);
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenCsrWithAubDumpWhenCreatingAubCsrThenInitializeTagAllocation) {
|
||||
auto executionEnvironment = pDevice->getExecutionEnvironment();
|
||||
executionEnvironment->initializeMemoryManager();
|
||||
|
||||
@@ -72,7 +72,7 @@ struct MockTbxCsrToTestDumpTbxNonWritable : public TbxCommandStreamReceiverHw<Gf
|
||||
using TbxCommandStreamReceiverHw<GfxFamily>::TbxCommandStreamReceiverHw;
|
||||
using TbxCommandStreamReceiverHw<GfxFamily>::dumpTbxNonWritable;
|
||||
|
||||
bool writeMemory(GraphicsAllocation &gfxAllocation) override {
|
||||
bool writeMemory(GraphicsAllocation &gfxAllocation, bool isChunkCopy, uint64_t gpuVaChunkOffset, size_t chunkSize) override {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
* Copyright (C) 2021-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -28,8 +28,8 @@ class MockSimulatedCsrHw : public CommandStreamReceiverSimulatedHw<GfxFamily> {
|
||||
bool writeMemory(GraphicsAllocation &gfxAllocation) override {
|
||||
return true;
|
||||
}
|
||||
void writeMemoryWithAubManager(GraphicsAllocation &graphicsAllocation) override {
|
||||
CommandStreamReceiverSimulatedHw<GfxFamily>::writeMemoryWithAubManager(graphicsAllocation);
|
||||
void writeMemoryWithAubManager(GraphicsAllocation &graphicsAllocation, bool isChunkCopy, uint64_t gpuVaChunkOffset, size_t chunkSize) override {
|
||||
CommandStreamReceiverSimulatedHw<GfxFamily>::writeMemoryWithAubManager(graphicsAllocation, isChunkCopy, gpuVaChunkOffset, chunkSize);
|
||||
}
|
||||
void writeMMIO(uint32_t offset, uint32_t value) override {}
|
||||
bool isMultiOsContextCapable() const override {
|
||||
|
||||
Reference in New Issue
Block a user