Task VA tracking for RelaxedOrdering mode

Related-To: NEO-7458

Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2022-11-18 21:02:29 +00:00
committed by Compute-Runtime-Automation
parent 6cee15ef56
commit bc5d9d149d
26 changed files with 308 additions and 189 deletions

View File

@ -10,6 +10,7 @@
#include "shared/source/command_stream/command_stream_receiver_hw.h"
#include "shared/source/os_interface/os_context.h"
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
#include "shared/test/common/helpers/batch_buffer_helper.h"
#include "shared/test/common/mocks/mock_os_context.h"
#include "shared/test/common/test_macros/hw_test.h"
@ -60,7 +61,8 @@ struct AUBFixture : public AUBCommandStreamFixture,
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(*pCS, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(*pCS);
BatchBuffer batchBuffer{pCS->getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, pCS->getUsed(), pCS, nullptr, false};
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(pCS->getGraphicsAllocation(), pCS, pCS->getUsed());
ResidencyContainer allocationsForResidency;
pCommandStreamReceiver->flush(batchBuffer, allocationsForResidency);
@ -75,11 +77,11 @@ using AUBcommandstreamTests = Test<AUBFixture>;
HWTEST_F(AUBcommandstreamTests, WhenFlushingTwiceThenCompletes) {
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(*pCS, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(*pCS);
BatchBuffer batchBuffer{pCS->getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, pCS->getUsed(), pCS, nullptr, false};
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(pCS->getGraphicsAllocation(), pCS, pCS->getUsed());
ResidencyContainer allocationsForResidency;
pCommandStreamReceiver->flush(batchBuffer, allocationsForResidency);
BatchBuffer batchBuffer2{pCS->getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, pCS->getUsed(), pCS, nullptr, false};
BatchBuffer batchBuffer2 = BatchBufferHelper::createDefaultBatchBuffer(pCS->getGraphicsAllocation(), pCS, pCS->getUsed());
pCommandStreamReceiver->flush(batchBuffer2, allocationsForResidency);
AUBCommandStreamFixture::getSimulatedCsr<FamilyType>()->pollForCompletion();
}

View File

@ -69,25 +69,25 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenFlushTas
EXPECT_EQ(cmdBufferList.peekHead(), cmdBufferList.peekTail());
auto cmdBuffer = cmdBufferList.peekHead();
//two more because of preemption allocation and sipKernel in Mid Thread preemption mode
// two more because of preemption allocation and sipKernel in Mid Thread preemption mode
size_t csrSurfaceCount = (pDevice->getPreemptionMode() == PreemptionMode::MidThread) ? 2 : 0;
csrSurfaceCount -= pDevice->getHardwareInfo().capabilityTable.supportsImages ? 0 : 1;
csrSurfaceCount += mockCsr->globalFenceAllocation ? 1 : 0;
csrSurfaceCount += mockCsr->clearColorAllocation ? 1 : 0;
csrSurfaceCount += mockCsr->getKernelArgsBufferAllocation() ? 1 : 0;
//we should have 3 heaps, tag allocation and csr command stream + cq
// we should have 3 heaps, tag allocation and csr command stream + cq
EXPECT_EQ(5u + csrSurfaceCount, cmdBuffer->surfaces.size());
EXPECT_EQ(0, mockCsr->flushCalledCount);
//we should be submitting via csr
// we should be submitting via csr
EXPECT_EQ(cmdBuffer->batchBuffer.commandBufferAllocation, mockCsr->commandStream.getGraphicsAllocation());
EXPECT_EQ(cmdBuffer->batchBuffer.startOffset, 0u);
EXPECT_FALSE(cmdBuffer->batchBuffer.requiresCoherency);
EXPECT_FALSE(cmdBuffer->batchBuffer.low_priority);
//find BB END
// find BB END
parseCommands<FamilyType>(commandStream, 0);
auto itBBend = find<MI_BATCH_BUFFER_END *>(cmdList.begin(), cmdList.end());
@ -96,6 +96,35 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenFlushTas
EXPECT_EQ(bbEndAddress, cmdBuffer->batchBufferEndLocation);
}
HWTEST_F(CommandStreamReceiverFlushTaskTests, givenTaskStreamWhenFlushingThenStoreTaskStartAddress) {
typedef typename FamilyType::MI_BATCH_BUFFER_END MI_BATCH_BUFFER_END;
CommandQueueHw<FamilyType> commandQueue(nullptr, pClDevice, 0, false);
auto &commandStream = commandQueue.getCS(4096u);
auto mockCsr = new MockCsrHw2<FamilyType>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
pDevice->resetCommandStreamReceiver(mockCsr);
mockCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch);
auto mockedSubmissionsAggregator = new mockSubmissionsAggregator();
mockCsr->overrideSubmissionAggregator(mockedSubmissionsAggregator);
DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags();
size_t startOffset = 0x1234;
mockCsr->flushTask(commandStream, startOffset, &dsh, &ioh, &ssh, taskLevel, dispatchFlags, *pDevice);
auto &cmdBufferList = mockedSubmissionsAggregator->peekCommandBuffers();
EXPECT_FALSE(cmdBufferList.peekIsEmpty());
EXPECT_EQ(cmdBufferList.peekHead(), cmdBufferList.peekTail());
auto cmdBuffer = cmdBufferList.peekHead();
uint64_t expectedAddress = commandStream.getGpuBase() + startOffset;
EXPECT_EQ(cmdBuffer->batchBuffer.taskStartAddress, expectedAddress);
}
HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeAndTwoRecordedCommandBuffersWhenFlushTaskIsCalledThenBatchBuffersAreCombined) {
typedef typename FamilyType::MI_BATCH_BUFFER_END MI_BATCH_BUFFER_END;
@ -328,7 +357,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenFlushTas
dispatchFlags,
*pDevice);
//ensure command stream still used
// ensure command stream still used
EXPECT_EQ(initialBase, commandStream.getCpuBase());
auto baseAfterFirstFlushTask = commandStream.getCpuBase();
auto usedAfterFirstFlushTask = commandStream.getUsed();
@ -417,13 +446,13 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenCsrInBatch
EXPECT_FALSE(cmdBufferList.peekIsEmpty());
auto cmdBuffer = cmdBufferList.peekHead();
//preemption allocation + sip kernel
// preemption allocation + sip kernel
size_t csrSurfaceCount = (pDevice->getPreemptionMode() == PreemptionMode::MidThread) ? 2 : 0;
csrSurfaceCount += mockCsr->globalFenceAllocation ? 1 : 0;
EXPECT_EQ(4u + csrSurfaceCount, cmdBuffer->surfaces.size());
//copy those surfaces
// copy those surfaces
std::vector<GraphicsAllocation *> residentSurfaces = cmdBuffer->surfaces;
for (auto &graphicsAllocation : residentSurfaces) {
@ -761,7 +790,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenEnqueueI
EXPECT_EQ(expectedUsed, mockCsr->peekTotalMemoryUsed());
//after flush it goes to 0
// after flush it goes to 0
mockCsr->flushBatchedSubmissions();
EXPECT_EQ(0u, mockCsr->peekTotalMemoryUsed());
@ -882,7 +911,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenTotalRes
dispatchFlags,
*pDevice);
//expect 2 flushes, since we cannot batch those submissions
// expect 2 flushes, since we cannot batch those submissions
EXPECT_EQ(2u, mockCsr->peekLatestFlushedTaskCount());
EXPECT_EQ(0u, mockCsr->peekTotalMemoryUsed());
EXPECT_TRUE(mockedSubmissionsAggregator->peekCommandBuffers().peekIsEmpty());
@ -918,7 +947,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests,
dispatchFlags,
*pDevice);
//now emit with the same taskLevel
// now emit with the same taskLevel
mockCsr->flushTask(commandStream,
0,
&dsh,
@ -930,7 +959,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests,
EXPECT_EQ(taskLevelPriorToSubmission, mockCsr->peekTaskLevel());
//validate if we recorded ppc positions
// validate if we recorded ppc positions
auto firstCmdBuffer = mockedSubmissionsAggregator->peekCommandBuffers().peekHead();
EXPECT_NE(nullptr, firstCmdBuffer->pipeControlThatMayBeErasedLocation);
auto secondCmdBuffer = firstCmdBuffer->next;
@ -942,18 +971,18 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests,
auto ppc2 = genCmdCast<typename FamilyType::PIPE_CONTROL *>(secondCmdBuffer->pipeControlThatMayBeErasedLocation);
EXPECT_NE(nullptr, ppc2);
//flush needs to bump the taskLevel
// flush needs to bump the taskLevel
mockCsr->flushBatchedSubmissions();
EXPECT_EQ(taskLevelPriorToSubmission + 1, mockCsr->peekTaskLevel());
//decode commands to confirm no pipe controls between Walkers
// decode commands to confirm no pipe controls between Walkers
parseCommands<FamilyType>(commandQueue);
auto itorBatchBufferStartFirst = find<typename FamilyType::MI_BATCH_BUFFER_START *>(cmdList.begin(), cmdList.end());
auto itorBatchBufferStartSecond = find<typename FamilyType::MI_BATCH_BUFFER_START *>(++itorBatchBufferStartFirst, cmdList.end());
//make sure they are not the same
// make sure they are not the same
EXPECT_NE(cmdList.end(), itorBatchBufferStartFirst);
EXPECT_NE(cmdList.end(), itorBatchBufferStartSecond);
EXPECT_NE(itorBatchBufferStartFirst, itorBatchBufferStartSecond);
@ -961,7 +990,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests,
auto itorPipeControl = find<typename FamilyType::PIPE_CONTROL *>(itorBatchBufferStartFirst, itorBatchBufferStartSecond);
EXPECT_EQ(itorPipeControl, itorBatchBufferStartSecond);
//first pipe control is nooped, second pipe control is untouched
// first pipe control is nooped, second pipe control is untouched
auto noop1 = genCmdCast<typename FamilyType::MI_NOOP *>(ppc);
auto noop2 = genCmdCast<typename FamilyType::MI_NOOP *>(ppc2);
EXPECT_NE(nullptr, noop1);
@ -1353,7 +1382,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests,
dispatchFlags,
*pDevice);
//now emit with the same taskLevel
// now emit with the same taskLevel
mockCsr->flushTask(commandStream,
0,
&dsh,
@ -1365,7 +1394,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests,
EXPECT_EQ(taskLevelPriorToSubmission, mockCsr->peekTaskLevel());
//validate if we recorded ppc positions
// validate if we recorded ppc positions
auto firstCmdBuffer = mockedSubmissionsAggregator->peekCommandBuffers().peekHead();
EXPECT_EQ(nullptr, firstCmdBuffer->pipeControlThatMayBeErasedLocation);
auto secondCmdBuffer = firstCmdBuffer->next;
@ -1373,7 +1402,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests,
mockCsr->flushBatchedSubmissions();
//decode commands to confirm no pipe controls between Walkers
// decode commands to confirm no pipe controls between Walkers
parseCommands<FamilyType>(commandQueue);
@ -1453,7 +1482,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenPipeCont
dispatchFlags,
*pDevice);
//now emit with the same taskLevel
// now emit with the same taskLevel
mockCsr->flushTask(commandStream,
0,
&dsh,
@ -1463,7 +1492,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenPipeCont
dispatchFlags,
*pDevice);
//validate if we recorded ppc positions
// validate if we recorded ppc positions
auto firstCmdBuffer = mockedSubmissionsAggregator->peekCommandBuffers().peekHead();
auto ppc1Location = firstCmdBuffer->pipeControlThatMayBeErasedLocation;
@ -1472,11 +1501,11 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenPipeCont
auto ppc = genCmdCast<typename FamilyType::PIPE_CONTROL *>(ppc1Location);
EXPECT_NE(nullptr, ppc);
//call flush, both pipe controls must remain untouched
// call flush, both pipe controls must remain untouched
mockCsr->flushBatchedSubmissions();
EXPECT_EQ(taskLevelPriorToSubmission + 1, mockCsr->peekTaskLevel());
//decode commands to confirm no pipe controls between Walkers
// decode commands to confirm no pipe controls between Walkers
parseCommands<FamilyType>(commandQueue);
auto itorBatchBufferStartFirst = find<typename FamilyType::MI_BATCH_BUFFER_START *>(cmdList.begin(), cmdList.end());
@ -1516,7 +1545,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests,
dispatchFlags,
*pDevice);
//now emit with the same taskLevel
// now emit with the same taskLevel
mockCsr->flushTask(commandStream,
0,
&dsh,
@ -1537,7 +1566,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests,
EXPECT_EQ(taskLevelPriorToSubmission, mockCsr->peekTaskLevel());
//validate if we recorded ppc positions
// validate if we recorded ppc positions
auto firstCmdBuffer = mockedSubmissionsAggregator->peekCommandBuffers().peekHead();
auto secondCmdBuffer = firstCmdBuffer->next;
auto thirdCmdBuffer = firstCmdBuffer->next->next;
@ -1551,11 +1580,11 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests,
EXPECT_NE(nullptr, ppc2);
EXPECT_NE(nullptr, ppc3);
//flush needs to bump the taskLevel
// flush needs to bump the taskLevel
mockCsr->flushBatchedSubmissions();
EXPECT_EQ(taskLevelPriorToSubmission + 1, mockCsr->peekTaskLevel());
//decode commands to confirm no pipe controls between Walkers
// decode commands to confirm no pipe controls between Walkers
parseCommands<FamilyType>(commandQueue);
@ -1563,7 +1592,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests,
auto itorBatchBufferStartSecond = find<typename FamilyType::MI_BATCH_BUFFER_START *>(++itorBatchBufferStartFirst, cmdList.end());
auto itorBatchBufferStartThird = find<typename FamilyType::MI_BATCH_BUFFER_START *>(++itorBatchBufferStartSecond, cmdList.end());
//make sure they are not the same
// make sure they are not the same
EXPECT_NE(cmdList.end(), itorBatchBufferStartFirst);
EXPECT_NE(cmdList.end(), itorBatchBufferStartSecond);
EXPECT_NE(cmdList.end(), itorBatchBufferStartThird);
@ -1576,7 +1605,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests,
itorPipeControl = find<typename FamilyType::PIPE_CONTROL *>(itorBatchBufferStartSecond, itorBatchBufferStartThird);
EXPECT_EQ(itorPipeControl, itorBatchBufferStartThird);
//first pipe control is nooped, second pipe control is untouched
// first pipe control is nooped, second pipe control is untouched
auto noop1 = genCmdCast<typename FamilyType::MI_NOOP *>(ppc);
auto noop2 = genCmdCast<typename FamilyType::MI_NOOP *>(ppc2);
auto noop3 = genCmdCast<typename FamilyType::MI_NOOP *>(ppc3);

View File

@ -605,6 +605,33 @@ HWTEST_F(BcsTests, givenBufferWhenBlitCalledThenFlushCommandBuffer) {
EXPECT_EQ(newTaskCount, csr.latestWaitForCompletionWithTimeoutTaskCount.load());
}
HWTEST_F(BcsTests, givenTaskStreamWhenFlushingThenStoreTaskStartAddress) {
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
csr.recordFlusheBatchBuffer = true;
cl_int retVal = CL_SUCCESS;
auto buffer = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
constexpr size_t hostAllocationSize = MemoryConstants::pageSize;
auto hostAllocationPtr = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr = reinterpret_cast<void *>(hostAllocationPtr.get());
auto graphicsAllocation = buffer->getGraphicsAllocation(pDevice->getRootDeviceIndex());
auto &commandStream = csr.getCS(MemoryConstants::pageSize);
size_t commandStreamOffset = 4;
commandStream.getSpace(commandStreamOffset);
auto blitProperties = BlitProperties::constructPropertiesForReadWrite(BlitterConstants::BlitDirection::HostPtrToBuffer,
csr, graphicsAllocation, nullptr, hostPtr,
graphicsAllocation->getGpuAddress(), 0,
0, 0, {1, 1, 1}, 0, 0, 0, 0);
flushBcsTask(&csr, blitProperties, true, *pDevice);
EXPECT_EQ((commandStream.getGpuBase() + commandStreamOffset), csr.latestFlushedBatchBuffer.taskStartAddress);
}
template <typename FamilyType>
class MyMockCsr : public UltCommandStreamReceiver<FamilyType> {
public:
@ -1291,7 +1318,7 @@ HWTEST_F(BcsTests, givenBufferWithBigSizesWhenBlitOperationCalledThenProgramCorr
flushBcsTask(&csr, blitProperties, true, *pDevice);
hwParser.parseCommands<FamilyType>(csr.commandStream, offset);
//1st rectangle xCopy = maxWidthToCopy, yCopy = maxHeightToCopy, zCopy = 1
// 1st rectangle xCopy = maxWidthToCopy, yCopy = maxHeightToCopy, zCopy = 1
auto cmdIterator = find<typename FamilyType::XY_COPY_BLT *>(hwParser.cmdList.begin(), hwParser.cmdList.end());
ASSERT_NE(hwParser.cmdList.end(), cmdIterator);
auto bltCmd = genCmdCast<typename FamilyType::XY_COPY_BLT *>(*cmdIterator);
@ -1334,7 +1361,7 @@ HWTEST_F(BcsTests, givenBufferWithBigSizesWhenBlitOperationCalledThenProgramCorr
srcAddressOffset += maxWidthToCopy;
dstAddressOffset += maxWidthToCopy;
//4th rectangle xCopy = (region[0] - maxWidthToCopy), yCopy = (region[0] - maxHeightToCopy), zCopy = 1
// 4th rectangle xCopy = (region[0] - maxWidthToCopy), yCopy = (region[0] - maxHeightToCopy), zCopy = 1
cmdIterator = find<typename FamilyType::XY_COPY_BLT *>(++cmdIterator, hwParser.cmdList.end());
ASSERT_NE(hwParser.cmdList.end(), cmdIterator);
bltCmd = genCmdCast<typename FamilyType::XY_COPY_BLT *>(*cmdIterator);
@ -1353,7 +1380,7 @@ HWTEST_F(BcsTests, givenBufferWithBigSizesWhenBlitOperationCalledThenProgramCorr
dstAddressOffset += (dstRowPitch * (region[1] - maxHeightToCopy - 1));
dstAddressOffset += (dstSlicePitch - (dstRowPitch * region[1]));
//5th rectangle xCopy = maxWidthToCopy, yCopy = maxHeightToCopy, zCopy = 1
// 5th rectangle xCopy = maxWidthToCopy, yCopy = maxHeightToCopy, zCopy = 1
cmdIterator = find<typename FamilyType::XY_COPY_BLT *>(++cmdIterator, hwParser.cmdList.end());
ASSERT_NE(hwParser.cmdList.end(), cmdIterator);
bltCmd = genCmdCast<typename FamilyType::XY_COPY_BLT *>(*cmdIterator);

View File

@ -19,6 +19,7 @@
#include "shared/source/utilities/tag_allocator.h"
#include "shared/test/common/fixtures/device_fixture.h"
#include "shared/test/common/fixtures/mock_aub_center_fixture.h"
#include "shared/test/common/helpers/batch_buffer_helper.h"
#include "shared/test/common/helpers/engine_descriptor_helper.h"
#include "shared/test/common/libult/ult_command_stream_receiver.h"
#include "shared/test/common/mocks/mock_allocation_properties.h"
@ -510,7 +511,7 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
auto engineType = csrWithAubDump->getOsContext().getEngineType();
ResidencyContainer allocationsForResidency;
@ -553,7 +554,7 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csrWithAubDump->getRootDeviceIndex(), MemoryConstants::pageSize});
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csrWithAubDump->getRootDeviceIndex(), MemoryConstants::pageSize});
ASSERT_NE(nullptr, gfxAllocation);
@ -578,7 +579,7 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csrWithAubDump->getRootDeviceIndex(), MemoryConstants::pageSize});
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
ResidencyContainer allocationsForResidency;

View File

@ -21,6 +21,7 @@
#include "shared/source/os_interface/os_context.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/test/common/cmd_parse/hw_parse.h"
#include "shared/test/common/helpers/batch_buffer_helper.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/dispatch_flags_helper.h"
#include "shared/test/common/helpers/execution_environment_helper.h"
@ -55,7 +56,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenCommandStreamWhenItIsFlush
EncodeNoop<FamilyType>::alignToCacheLine(cs);
auto storedBase = cs.getCpuBase();
auto storedGraphicsAllocation = cs.getGraphicsAllocation();
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_EQ(cs.getCpuBase(), storedBase);
EXPECT_EQ(cs.getGraphicsAllocation(), storedGraphicsAllocation);
@ -87,7 +88,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenTaskThatRequiresLargeResou
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_EQ(11u, this->mock->execBuffer.getBufferCount());
@ -159,7 +160,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenCommandStreamWithDuplicate
EncodeNoop<FamilyType>::alignToCacheLine(cs);
auto storedBase = cs.getCpuBase();
auto storedGraphicsAllocation = cs.getGraphicsAllocation();
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_EQ(cs.getCpuBase(), storedBase);
EXPECT_EQ(cs.getGraphicsAllocation(), storedGraphicsAllocation);
@ -177,7 +178,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenDebugFlagSetWhenFlushingTh
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
{
DebugManager.flags.ReadBackCommandBufferAllocation.set(1);
@ -506,7 +507,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, WhenFlushingThenSucceeds) {
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_NE(cs.getCpuBase(), nullptr);
EXPECT_NE(cs.getGraphicsAllocation(), nullptr);
@ -550,14 +551,14 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, GivenFlushMultipleTimesThenSucc
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
csr->flush(batchBuffer, csr->getResidencyAllocations());
cs.replaceBuffer(commandBuffer->getUnderlyingBuffer(), commandBuffer->getUnderlyingBufferSize());
cs.replaceGraphicsAllocation(commandBuffer);
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer2{cs.getGraphicsAllocation(), 8, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer2{cs.getGraphicsAllocation(), 8, 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
csr->flush(batchBuffer2, csr->getResidencyAllocations());
auto allocation = mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
@ -576,7 +577,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, GivenFlushMultipleTimesThenSucc
cs.replaceGraphicsAllocation(commandBuffer2);
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer3{cs.getGraphicsAllocation(), 16, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer3{cs.getGraphicsAllocation(), 16, 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
csr->flush(batchBuffer3, csr->getResidencyAllocations());
csr->makeSurfacePackNonResident(csr->getResidencyAllocations(), true);
mm->freeGraphicsMemory(allocation);
@ -589,7 +590,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, GivenFlushMultipleTimesThenSucc
cs.replaceGraphicsAllocation(commandBuffer2);
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer4{cs.getGraphicsAllocation(), 24, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer4{cs.getGraphicsAllocation(), 24, 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
csr->flush(batchBuffer4, csr->getResidencyAllocations());
}
@ -602,7 +603,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, GivenNotEmptyBbWhenFlushingThen
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
csr->flush(batchBuffer, csr->getResidencyAllocations());
}
@ -615,7 +616,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, GivenNotEmptyNotPaddedBbWhenFlu
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
csr->flush(batchBuffer, csr->getResidencyAllocations());
}
@ -628,7 +629,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedWithFailingExec, GivenFailingExecThen
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
NEO::SubmissionStatus ret = csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_EQ(ret, NEO::SubmissionStatus::FAILED);
}
@ -643,7 +644,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, GivenNotAlignedWhenFlushingThen
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
csr->flush(batchBuffer, csr->getResidencyAllocations());
}
@ -660,7 +661,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, GivenCheckDrmFreeWhenFlushingTh
csr->makeResident(*allocation);
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
csr->flush(batchBuffer, csr->getResidencyAllocations());
csr->makeNonResident(*allocation);
mm->freeGraphicsMemory(allocation);
@ -972,7 +973,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest,
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
testedCsr->latestSentTaskCount = 160u;
testedCsr->flush(batchBuffer, testedCsr->getResidencyAllocations());
@ -1003,7 +1004,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest,
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
DrmAllocation *alloc = static_cast<DrmAllocation *>(cs.getGraphicsAllocation());
auto boHandle = static_cast<FlushStamp>(alloc->getBO()->peekHandle());
@ -1037,7 +1038,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest,
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
DrmAllocation *alloc = static_cast<DrmAllocation *>(cs.getGraphicsAllocation());
auto boHandle = static_cast<FlushStamp>(alloc->getBO()->peekHandle());
@ -1377,7 +1378,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenMergeWithResidencyContaine
LinearStream cs(commandBuffer);
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
MockDrmCsr mockCsr(*executionEnvironment, rootDeviceIndex, 1, gemCloseWorkerMode::gemCloseWorkerInactive);
mockCsr.setupContext(*osContext.get());
@ -1408,7 +1409,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenMergeWithResidencyContaine
LinearStream cs(commandBuffer);
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
MockDrmCsr mockCsr(*executionEnvironment, rootDeviceIndex, 1, gemCloseWorkerMode::gemCloseWorkerInactive);
mockCsr.setupContext(*osContext.get());
@ -1442,7 +1443,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenNoAllocsInMemoryOperationH
LinearStream cs(commandBuffer);
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
MockDrmCsr mockCsr(*executionEnvironment, rootDeviceIndex, 1, gemCloseWorkerMode::gemCloseWorkerInactive);
mockCsr.setupContext(*osContext.get());
@ -1476,7 +1477,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenAllocsInMemoryOperationHan
LinearStream cs(commandBuffer);
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
MockDrmCsr mockCsr(*executionEnvironment, rootDeviceIndex, 1, gemCloseWorkerMode::gemCloseWorkerInactive);
mockCsr.setupContext(*osContext.get());
@ -1491,7 +1492,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenAllocInMemoryOperationsInt
LinearStream cs(commandBuffer);
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(cs, nullptr);
EncodeNoop<FamilyType>::alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs, nullptr, false};
BatchBuffer batchBuffer = BatchBufferHelper::createDefaultBatchBuffer(cs.getGraphicsAllocation(), &cs, cs.getUsed());
auto allocation = mm->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize});
executionEnvironment->rootDeviceEnvironments[csr->getRootDeviceIndex()]->memoryOperationsInterface->makeResident(device.get(), ArrayRef<GraphicsAllocation *>(&allocation, 1));