Debug option to flatten main and chained batch buffer in AUB dump.

New debug option FlattenBatchBufferForAUBDump has been added. When set it
modifies AUB dump in such way that commands from main and chained batch
buffer are dumped as single allocation. Commands from chained batch buffer are
dumped directly after commands from main batch buffer without
MI_BATCH_BUFFER_START. This feature also requires ImmediateDispatch mode which
can be forced using debug option CsrDispatchMode = 1.

Change-Id: I730760791693a748e7f4e1463ce8e7af94287b93
This commit is contained in:
Pawel Wilma 2018-02-28 22:50:41 +01:00 committed by sys_ocldev
parent 5ab43a9757
commit c4c35955d1
14 changed files with 320 additions and 94 deletions

View File

@ -86,5 +86,7 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverHw<GfxFamily> {
PDPE ggtt;
// remap CPU VA -> GGTT VA
AddressMapper gttRemap;
MOCKABLE_VIRTUAL void *flattenBatchBuffer(BatchBuffer &batchBuffer, size_t &sizeBatchBuffer);
};
} // namespace OCLRT

View File

@ -27,6 +27,7 @@
#include "runtime/memory_manager/graphics_allocation.h"
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
#include "runtime/gmm_helper/gmm_helper.h"
#include "runtime/helpers/string.h"
#include <cstring>
namespace OCLRT {
@ -212,21 +213,20 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
DEBUG_BREAK_IF(!engineInfo.pLRCA);
}
if (this->standalone) {
if (this->dispatchMode == CommandStreamReceiver::DispatchMode::ImmediateDispatch) {
makeResident(*batchBuffer.commandBufferAllocation);
} else {
allocationsForResidency->push_back(batchBuffer.commandBufferAllocation);
batchBuffer.commandBufferAllocation->residencyTaskCount = this->taskCount;
}
processResidency(allocationsForResidency);
}
// Write our batch buffer
auto pBatchBuffer = ptrOffset(batchBuffer.commandBufferAllocation->getUnderlyingBuffer(), batchBuffer.startOffset);
auto currentOffset = batchBuffer.usedSize;
DEBUG_BREAK_IF(currentOffset < batchBuffer.startOffset);
auto sizeBatchBuffer = currentOffset - batchBuffer.startOffset;
std::unique_ptr<void, std::function<void(void *)>> flatBatchBuffer(nullptr, [&](void *ptr) { this->getMemoryManager()->alignedFreeWrapper(ptr); });
if (DebugManager.flags.FlattenBatchBufferForAUBDump.get() && (this->dispatchMode == CommandStreamReceiver::DispatchMode::ImmediateDispatch)) {
flatBatchBuffer.reset(flattenBatchBuffer(batchBuffer, sizeBatchBuffer));
if (flatBatchBuffer.get() != nullptr) {
pBatchBuffer = flatBatchBuffer.get();
}
}
{
{
std::ostringstream str;
@ -246,6 +246,18 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
AubMemDump::DataTypeHintValues::TraceBatchBufferPrimary);
}
if (this->standalone) {
if (this->dispatchMode == CommandStreamReceiver::DispatchMode::ImmediateDispatch) {
if (!DebugManager.flags.FlattenBatchBufferForAUBDump.get()) {
makeResident(*batchBuffer.commandBufferAllocation);
}
} else {
allocationsForResidency->push_back(batchBuffer.commandBufferAllocation);
batchBuffer.commandBufferAllocation->residencyTaskCount = this->taskCount;
}
processResidency(allocationsForResidency);
}
// Add a batch buffer start to the ring buffer
auto previousTail = engineInfo.tailRingBuffer;
{
@ -370,6 +382,25 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
return 0;
}
template <typename GfxFamily>
void *AUBCommandStreamReceiverHw<GfxFamily>::flattenBatchBuffer(BatchBuffer &batchBuffer, size_t &sizeBatchBuffer) {
void *flatBatchBuffer = nullptr;
if (batchBuffer.chainedBatchBuffer) {
batchBuffer.chainedBatchBuffer->setAllocationType(batchBuffer.chainedBatchBuffer->getAllocationType() | GraphicsAllocation::ALLOCATION_TYPE_NON_AUB_WRITABLE);
auto sizeMainBatchBuffer = batchBuffer.chainedBatchBufferStartOffset - batchBuffer.startOffset;
auto flatBatchBufferSize = alignUp(sizeMainBatchBuffer + batchBuffer.chainedBatchBuffer->getUnderlyingBufferSize(), MemoryConstants::pageSize);
flatBatchBuffer = this->getMemoryManager()->alignedMallocWrapper(flatBatchBufferSize, MemoryConstants::pageSize);
UNRECOVERABLE_IF(flatBatchBuffer == nullptr);
// Copy FLB
memcpy_s(flatBatchBuffer, sizeMainBatchBuffer, ptrOffset(batchBuffer.commandBufferAllocation->getUnderlyingBuffer(), batchBuffer.startOffset), sizeMainBatchBuffer);
// Copy SLB
memcpy_s(ptrOffset(flatBatchBuffer, sizeMainBatchBuffer), batchBuffer.chainedBatchBuffer->getUnderlyingBufferSize(), batchBuffer.chainedBatchBuffer->getUnderlyingBuffer(), batchBuffer.chainedBatchBuffer->getUnderlyingBufferSize());
sizeBatchBuffer = flatBatchBufferSize;
}
return flatBatchBuffer;
}
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::submitLRCA(EngineType engineType, const typename AUBCommandStreamReceiverHw<GfxFamily>::MiContextDescriptorReg &contextDescriptor) {
auto mmioBase = getCsTraits(engineType).mmioBase;

View File

@ -312,6 +312,8 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
bool submitCommandStreamFromCsr = false;
void *bbEndLocation = nullptr;
auto bbEndPaddingSize = this->dispatchMode == DispatchMode::ImmediateDispatch ? 0 : sizeof(MI_BATCH_BUFFER_START) - sizeof(MI_BATCH_BUFFER_END);
size_t chainedBatchBufferStartOffset = 0;
GraphicsAllocation *chainedBatchBuffer = nullptr;
if (submitTask) {
this->addBatchBufferEnd(commandStreamTask, &bbEndLocation);
@ -319,6 +321,8 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
this->alignToCacheLine(commandStreamTask);
if (submitCSR) {
chainedBatchBufferStartOffset = commandStreamCSR.getUsed();
chainedBatchBuffer = commandStreamTask.getGraphicsAllocation();
// Add MI_BATCH_BUFFER_START to chain from CSR -> Task
auto pBBS = reinterpret_cast<MI_BATCH_BUFFER_START *>(commandStreamCSR.getSpace(sizeof(MI_BATCH_BUFFER_START)));
addBatchBufferStart(pBBS, ptrOffset(commandStreamTask.getGraphicsAllocation()->getGpuAddress(), commandStreamStartTask));
@ -340,7 +344,7 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
size_t startOffset = submitCommandStreamFromCsr ? commandStreamStartCSR : commandStreamStartTask;
auto &streamToSubmit = submitCommandStreamFromCsr ? commandStreamCSR : commandStreamTask;
BatchBuffer batchBuffer{streamToSubmit.getGraphicsAllocation(), startOffset, dispatchFlags.requiresCoherency, dispatchFlags.lowPriority, dispatchFlags.throttle, streamToSubmit.getUsed(), &streamToSubmit};
BatchBuffer batchBuffer{streamToSubmit.getGraphicsAllocation(), startOffset, chainedBatchBufferStartOffset, chainedBatchBuffer, dispatchFlags.requiresCoherency, dispatchFlags.lowPriority, dispatchFlags.throttle, streamToSubmit.getUsed(), &streamToSubmit};
EngineType engineType = device->getEngineType();
if (submitCSR | submitTask) {

View File

@ -106,7 +106,7 @@ void OCLRT::SubmissionAggregator::aggregateCommandBuffers(ResourcePackage &resou
}
}
OCLRT::BatchBuffer::BatchBuffer(GraphicsAllocation *commandBufferAllocation, size_t startOffset, bool requiresCoherency, bool lowPriority, QueueThrottle throttle, size_t usedSize, LinearStream *stream) : commandBufferAllocation(commandBufferAllocation), startOffset(startOffset), requiresCoherency(requiresCoherency), low_priority(lowPriority), throttle(throttle), usedSize(usedSize), stream(stream) {
OCLRT::BatchBuffer::BatchBuffer(GraphicsAllocation *commandBufferAllocation, size_t startOffset, size_t chainedBatchBufferStartOffset, GraphicsAllocation *chainedBatchBuffer, bool requiresCoherency, bool lowPriority, QueueThrottle throttle, size_t usedSize, LinearStream *stream) : commandBufferAllocation(commandBufferAllocation), startOffset(startOffset), chainedBatchBufferStartOffset(chainedBatchBufferStartOffset), chainedBatchBuffer(chainedBatchBuffer), requiresCoherency(requiresCoherency), low_priority(lowPriority), throttle(throttle), usedSize(usedSize), stream(stream) {
}
OCLRT::CommandBuffer::CommandBuffer() {

View File

@ -33,6 +33,8 @@ class FlushStampTracker;
struct BatchBuffer {
BatchBuffer(GraphicsAllocation *commandBufferAllocation,
size_t startOffset,
size_t chainedBatchBufferStartOffset,
GraphicsAllocation *chainedBatchBuffer,
bool requiresCoherency,
bool lowPriority,
QueueThrottle throttle,
@ -41,6 +43,8 @@ struct BatchBuffer {
BatchBuffer() {}
GraphicsAllocation *commandBufferAllocation = nullptr;
size_t startOffset = 0u;
size_t chainedBatchBufferStartOffset = 0u;
GraphicsAllocation *chainedBatchBuffer = nullptr;
bool requiresCoherency = false;
bool low_priority = false;
QueueThrottle throttle = QueueThrottle::MEDIUM;

View File

@ -60,6 +60,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, TbxPort, 4321, "TCP-IP port of TBX server")
DECLARE_DEBUG_VARIABLE(std::string, ProductFamilyOverride, "unk", "Specify product for use in AUB/TBX")
DECLARE_DEBUG_VARIABLE(bool, DisableAUBBufferDump, false, "Avoid dumping buffers in AUB files")
DECLARE_DEBUG_VARIABLE(bool, DisableAUBImageDump, false, "Avoid dumping images in AUB files")
DECLARE_DEBUG_VARIABLE(bool, FlattenBatchBufferForAUBDump, false, "Dump multi-level batch buffers to AUB as single, flat batch buffer")
/*FEATURE FLAGS*/
DECLARE_DEBUG_VARIABLE(bool, EnableNV12, true, "Enables NV12 extension")
DECLARE_DEBUG_VARIABLE(bool, EnablePackedYuv, true, "Enables cl_packed_yuv extension")

View File

@ -27,6 +27,7 @@
#include "unit_tests/fixtures/hello_world_fixture.h"
#include "unit_tests/fixtures/simple_arg_fixture.h"
#include "unit_tests/fixtures/two_walker_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "test.h"
using namespace OCLRT;
@ -267,6 +268,33 @@ HWTEST_F(AUBSimpleArg, simple) {
EXPECT_EQ(0, memcmp(pISA, pExpectedISA, expectedSize));
}
HWTEST_F(AUBSimpleArg, givenAubCommandStreamerReceiverWhenBatchBufferFlateningIsForcedThenDumpedAubIsStillValid) {
cl_uint workDim = 1;
size_t globalWorkOffset[3] = {0, 0, 0};
size_t globalWorkSize[3] = {1, 1, 1};
size_t localWorkSize[3] = {1, 1, 1};
cl_uint numEventsInWaitList = 0;
cl_event *eventWaitList = nullptr;
cl_event *event = nullptr;
DebugManagerStateRestore dbgRestore;
DebugManager.flags.FlattenBatchBufferForAUBDump.set(true);
pCmdQ->getDevice().getCommandStreamReceiver().overrideDispatchPolicy(CommandStreamReceiver::DispatchMode::ImmediateDispatch);
auto retVal = pCmdQ->enqueueKernel(
pKernel,
workDim,
globalWorkOffset,
globalWorkSize,
localWorkSize,
numEventsInWaitList,
eventWaitList,
event);
ASSERT_EQ(CL_SUCCESS, retVal);
}
struct AUBSimpleArgIntegrateTest : public SimpleArgFixture<AUBSimpleArgFixtureFactory>,
public ::testing::TestWithParam<std::tuple<uint32_t /*cl_uint*/, TestParam>> {
typedef SimpleArgFixture<AUBSimpleArgFixtureFactory> ParentClass;

View File

@ -68,7 +68,7 @@ struct AUBFixture : public AUBCommandStreamFixture,
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(*pCS, nullptr);
CommandStreamReceiverHw<FamilyType>::alignToCacheLine(*pCS);
BatchBuffer batchBuffer{pCS->getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, pCS->getUsed(), pCS};
BatchBuffer batchBuffer{pCS->getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, pCS->getUsed(), pCS};
ResidencyContainer allocationsForResidency;
pCommandStreamReceiver->flush(batchBuffer, engineType, &allocationsForResidency);
@ -82,10 +82,10 @@ typedef Test<AUBFixture> AUBcommandstreamTests;
HWTEST_F(AUBcommandstreamTests, testFlushTwice) {
CommandStreamReceiverHw<FamilyType>::addBatchBufferEnd(*pCS, nullptr);
CommandStreamReceiverHw<FamilyType>::alignToCacheLine(*pCS);
BatchBuffer batchBuffer{pCS->getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, pCS->getUsed(), pCS};
BatchBuffer batchBuffer{pCS->getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, pCS->getUsed(), pCS};
ResidencyContainer allocationsForResidency;
pCommandStreamReceiver->flush(batchBuffer, EngineType::ENGINE_RCS, &allocationsForResidency);
BatchBuffer batchBuffer2{pCS->getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, pCS->getUsed(), pCS};
BatchBuffer batchBuffer2{pCS->getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, pCS->getUsed(), pCS};
ResidencyContainer allocationsForResidency2;
pCommandStreamReceiver->flush(batchBuffer2, EngineType::ENGINE_RCS, &allocationsForResidency);
}

View File

@ -39,8 +39,11 @@ using OCLRT::HardwareInfo;
using OCLRT::LinearStream;
using OCLRT::MemoryManager;
using OCLRT::ObjectNotResident;
using OCLRT::platformDevices;
using OCLRT::ResidencyContainer;
using OCLRT::platformDevices;
using ::testing::Return;
using ::testing::_;
typedef Test<DeviceFixture> AubCommandStreamReceiverTests;
@ -51,6 +54,8 @@ struct MockAubCsr : public AUBCommandStreamReceiverHw<GfxFamily> {
CommandStreamReceiver::DispatchMode peekDispatchMode() const {
return this->dispatchMode;
}
MOCK_METHOD2(flattenBatchBuffer, void *(BatchBuffer &batchBuffer, size_t &sizeBatchBuffer));
};
TEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenItIsCreatedWithWrongGfxCoreFamilyThenNullPointerShouldBeReturned) {
@ -88,8 +93,9 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenItIsCre
}
HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWhenMakeResidentCalledMultipleTimesAffectsResidencyOnce) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MemoryManager> memoryManager(aubCsr->createMemoryManager(false));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
// First makeResident marks the allocation resident
@ -115,12 +121,12 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWhenMakeResidentC
EXPECT_EQ(1u, memoryManager->getEvictionAllocations().size());
memoryManager->freeGraphicsMemoryImpl(gfxAllocation);
aubCsr->setMemoryManager(nullptr);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenItShouldLeaveProperRingTailAlignment) {
auto aubCsr = new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true);
auto memoryManager = aubCsr->createMemoryManager(false);
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
memoryManager.reset(aubCsr->createMemoryManager(false));
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
ASSERT_NE(nullptr, commandBuffer);
@ -129,7 +135,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenFlushIs
auto engineType = OCLRT::ENGINE_RCS;
auto ringTailAlignment = sizeof(uint64_t);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
// First flush typically includes a preamble and chain to command buffer
aubCsr->overrideDispatchPolicy(CommandStreamReceiver::DispatchMode::ImmediateDispatch);
@ -142,19 +148,18 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenFlushIs
EXPECT_EQ(0ull, aubCsr->engineInfoTable[engineType].tailRingBuffer % ringTailAlignment);
memoryManager->freeGraphicsMemory(commandBuffer);
delete aubCsr;
delete memoryManager;
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneModeWhenFlushIsCalledThenItShouldCallMakeResidentOnCommandBufferAllocation) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MemoryManager> memoryManager(aubCsr->createMemoryManager(false));
memoryManager.reset(aubCsr->createMemoryManager(false));
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount);
@ -169,19 +174,19 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount);
memoryManager->freeGraphicsMemoryImpl(commandBuffer);
aubCsr->setMemoryManager(nullptr);
memoryManager->freeGraphicsMemory(commandBuffer);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNoneStandaloneModeWhenFlushIsCalledThenItShouldNotCallMakeResidentOnCommandBufferAllocation) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], false));
std::unique_ptr<MemoryManager> memoryManager(aubCsr->createMemoryManager(false));
memoryManager.reset(aubCsr->createMemoryManager(false));
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount);
@ -190,20 +195,22 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNoneStand
EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount);
memoryManager->freeGraphicsMemoryImpl(commandBuffer);
memoryManager->freeGraphicsMemory(commandBuffer);
aubCsr->setMemoryManager(nullptr);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneModeWhenFlushIsCalledThenItShouldCallMakeResidentOnResidencyAllocations) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MemoryManager> memoryManager(aubCsr->createMemoryManager(false));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency = {gfxAllocation};
@ -225,20 +232,20 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon
EXPECT_EQ(ObjectNotResident, commandBuffer->residencyTaskCount);
memoryManager->freeGraphicsMemory(commandBuffer);
memoryManager->freeGraphicsMemoryImpl(gfxAllocation);
aubCsr->setMemoryManager(nullptr);
memoryManager->freeGraphicsMemory(gfxAllocation);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNoneStandaloneModeWhenFlushIsCalledThenItShouldNotCallMakeResidentOnResidencyAllocations) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], false));
std::unique_ptr<MemoryManager> memoryManager(aubCsr->createMemoryManager(false));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency = {gfxAllocation};
@ -252,23 +259,25 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNoneStand
memoryManager->freeGraphicsMemoryImpl(commandBuffer);
memoryManager->freeGraphicsMemoryImpl(gfxAllocation);
aubCsr->setMemoryManager(nullptr);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphicsAllocationIsCreatedThenItDoesntHaveTypeNonAubWritable) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MemoryManager> memoryManager(aubCsr->createMemoryManager(false));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
EXPECT_FALSE(!!(gfxAllocation->getAllocationType() & GraphicsAllocation::ALLOCATION_TYPE_NON_AUB_WRITABLE));
memoryManager->freeGraphicsMemoryImpl(gfxAllocation);
aubCsr->setMemoryManager(nullptr);
memoryManager->freeGraphicsMemory(gfxAllocation);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcessResidencyIsCalledOnDefaultAllocationThenAllocationTypeShouldNotBeMadeNonAubWritable) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MemoryManager> memoryManager(aubCsr->createMemoryManager(false));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto gfxDefaultAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
ResidencyContainer allocationsForResidency = {gfxDefaultAllocation};
@ -276,13 +285,13 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess
EXPECT_FALSE(!!(gfxDefaultAllocation->getAllocationType() & GraphicsAllocation::ALLOCATION_TYPE_NON_AUB_WRITABLE));
memoryManager->freeGraphicsMemoryImpl(gfxDefaultAllocation);
aubCsr->setMemoryManager(nullptr);
memoryManager->freeGraphicsMemory(gfxDefaultAllocation);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcessResidencyIsCalledOnBufferAndImageAllocationsThenAllocationsTypesShouldBeMadeNonAubWritable) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MemoryManager> memoryManager(aubCsr->createMemoryManager(false));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto gfxBufferAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
gfxBufferAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_BUFFER);
@ -296,32 +305,33 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcess
EXPECT_TRUE(!!(gfxBufferAllocation->getAllocationType() & GraphicsAllocation::ALLOCATION_TYPE_NON_AUB_WRITABLE));
EXPECT_TRUE(!!(gfxImageAllocation->getAllocationType() & GraphicsAllocation::ALLOCATION_TYPE_NON_AUB_WRITABLE));
memoryManager->freeGraphicsMemoryImpl(gfxBufferAllocation);
memoryManager->freeGraphicsMemoryImpl(gfxImageAllocation);
aubCsr->setMemoryManager(nullptr);
memoryManager->freeGraphicsMemory(gfxBufferAllocation);
memoryManager->freeGraphicsMemory(gfxImageAllocation);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphicsAllocationTypeIsntNonAubWritableThenWriteMemoryIsAllowed) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MemoryManager> memoryManager(aubCsr->createMemoryManager(false));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
EXPECT_TRUE(aubCsr->writeMemory(*gfxAllocation));
memoryManager->freeGraphicsMemoryImpl(gfxAllocation);
aubCsr->setMemoryManager(nullptr);
memoryManager->freeGraphicsMemory(gfxAllocation);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphicsAllocationTypeIsNonAubWritableThenWriteMemoryIsNotAllowed) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<MemoryManager> memoryManager(aubCsr->createMemoryManager(false));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto gfxAllocation = memoryManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
gfxAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_NON_AUB_WRITABLE);
EXPECT_FALSE(aubCsr->writeMemory(*gfxAllocation));
memoryManager->freeGraphicsMemoryImpl(gfxAllocation);
aubCsr->setMemoryManager(nullptr);
memoryManager->freeGraphicsMemory(gfxAllocation);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphicsAllocationSizeIsZeroThenWriteMemoryIsNotAllowed) {
@ -331,6 +341,151 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphic
EXPECT_FALSE(aubCsr->writeMemory(gfxAllocation));
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedBatchBufferFlatteningThenNewCombinedBatchBufferIsCreated) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
memoryManager.reset(aubCsr->createMemoryManager(false));
auto chainedBatchBuffer = memoryManager->allocateGraphicsMemory(128u, 64u, false, false);
auto otherAllocation = memoryManager->allocateGraphicsMemory(128u, 64u, false, false);
ASSERT_NE(nullptr, chainedBatchBuffer);
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 128u, chainedBatchBuffer, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
size_t sizeBatchBuffer = 0xffffu;
std::unique_ptr<void, std::function<void(void *)>> flatBatchBuffer(aubCsr->flattenBatchBuffer(batchBuffer, sizeBatchBuffer), [&](void *ptr) { memoryManager->alignedFreeWrapper(ptr); });
EXPECT_NE(nullptr, flatBatchBuffer.get());
EXPECT_EQ(alignUp(128u + 128u, 0x1000), sizeBatchBuffer);
memoryManager->freeGraphicsMemory(commandBuffer);
memoryManager->freeGraphicsMemory(chainedBatchBuffer);
memoryManager->freeGraphicsMemory(otherAllocation);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedBatchBufferAndNoChainedBatchBufferThenCombinedBatchBufferIsNotCreated) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
memoryManager.reset(aubCsr->createMemoryManager(false));
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 128u, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
size_t sizeBatchBuffer = 0xffffu;
std::unique_ptr<void, std::function<void(void *)>> flatBatchBuffer(aubCsr->flattenBatchBuffer(batchBuffer, sizeBatchBuffer), [&](void *ptr) { memoryManager->alignedFreeWrapper(ptr); });
EXPECT_EQ(nullptr, flatBatchBuffer.get());
EXPECT_EQ(0xffffu, sizeBatchBuffer);
memoryManager->freeGraphicsMemory(commandBuffer);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenDefaultDebugConfigThenExpectxpectFlattenBatchBufferIsNotCalled) {
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
memoryManager.reset(aubCsr->createMemoryManager(false));
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency = {};
EXPECT_CALL(*aubCsr, flattenBatchBuffer(_, _)).Times(0);
aubCsr->flush(batchBuffer, engineType, &allocationsForResidency);
memoryManager->freeGraphicsMemory(commandBuffer);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedFlattenBatchBufferAndImmediateDispatchModeThenExpectFlattenBatchBufferIsCalled) {
DebugManagerStateRestore dbgRestore;
DebugManager.flags.FlattenBatchBufferForAUBDump.set(true);
DebugManager.flags.CsrDispatchMode.set(CommandStreamReceiver::DispatchMode::ImmediateDispatch);
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
memoryManager.reset(aubCsr->createMemoryManager(false));
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
auto chainedBatchBuffer = memoryManager->allocateGraphicsMemory(128u, 64u, false, false);
ASSERT_NE(nullptr, chainedBatchBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 128u, chainedBatchBuffer, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
aubCsr->makeResident(*chainedBatchBuffer);
std::unique_ptr<void, decltype(alignedFree) *> ptr(alignedMalloc(4096, 4096), alignedFree);
EXPECT_CALL(*aubCsr, flattenBatchBuffer(_, _)).WillOnce(Return(ptr.release()));
aubCsr->flush(batchBuffer, engineType, nullptr);
memoryManager->freeGraphicsMemory(commandBuffer);
memoryManager->freeGraphicsMemory(chainedBatchBuffer);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedFlattenBatchBufferAndImmediateDispatchModeAndTheresNoChainedBatchBufferThenExpectFlattenBatchBufferIsCalledAnyway) {
DebugManagerStateRestore dbgRestore;
DebugManager.flags.FlattenBatchBufferForAUBDump.set(true);
DebugManager.flags.CsrDispatchMode.set(CommandStreamReceiver::DispatchMode::ImmediateDispatch);
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
memoryManager.reset(aubCsr->createMemoryManager(false));
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 128u, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
EXPECT_CALL(*aubCsr, flattenBatchBuffer(_, _)).Times(1);
aubCsr->flush(batchBuffer, engineType, nullptr);
memoryManager->freeGraphicsMemory(commandBuffer);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenDispatchModeIsNotImmediateThenExpectFlattenBatchBufferIsNotCalled) {
DebugManagerStateRestore dbgRestore;
DebugManager.flags.FlattenBatchBufferForAUBDump.set(true);
std::unique_ptr<MemoryManager> memoryManager(nullptr);
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], true));
memoryManager.reset(aubCsr->createMemoryManager(false));
aubCsr->overrideDispatchPolicy(CommandStreamReceiver::DispatchMode::BatchedDispatch);
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096);
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
auto chainedBatchBuffer = memoryManager->allocateGraphicsMemory(128u, 64u, false, false);
ASSERT_NE(nullptr, chainedBatchBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 128u, chainedBatchBuffer, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency = {chainedBatchBuffer};
EXPECT_CALL(*aubCsr, flattenBatchBuffer(_, _)).Times(0);
aubCsr->flush(batchBuffer, engineType, &allocationsForResidency);
memoryManager->freeGraphicsMemory(commandBuffer);
memoryManager->freeGraphicsMemory(chainedBatchBuffer);
}
class OsAgnosticMemoryManagerForImagesWithNoHostPtr : public OsAgnosticMemoryManager {
public:
GraphicsAllocation *allocateGraphicsMemoryForImage(ImageInfo &imgInfo, Gmm *gmm) override {
@ -369,8 +524,9 @@ class OsAgnosticMemoryManagerForImagesWithNoHostPtr : public OsAgnosticMemoryMan
};
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMemoryIsCalledOnImageWithNoHostPtrThenResourceShouldBeLockedToGetCpuAddress) {
std::unique_ptr<OsAgnosticMemoryManagerForImagesWithNoHostPtr> memoryManager(nullptr);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], true));
std::unique_ptr<OsAgnosticMemoryManagerForImagesWithNoHostPtr> memoryManager(new OsAgnosticMemoryManagerForImagesWithNoHostPtr);
memoryManager.reset(new OsAgnosticMemoryManagerForImagesWithNoHostPtr);
aubCsr->setMemoryManager(memoryManager.get());
cl_image_desc imgDesc = {};
@ -394,6 +550,5 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMe
EXPECT_EQ(imageAllocation, memoryManager->unlockResourceParam.inImageAllocation);
queryGmm.release();
memoryManager->freeGraphicsMemoryImpl(imageAllocation);
aubCsr->setMemoryManager(nullptr);
memoryManager->freeGraphicsMemory(imageAllocation);
}

View File

@ -130,7 +130,7 @@ HWTEST_P(CommandStreamReceiverWithAubDumpTest, givenCommandStreamReceiverWithAub
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto engineType = OCLRT::ENGINE_RCS;
ResidencyContainer allocationsForResidency;

View File

@ -86,7 +86,7 @@ TEST_F(Tbx_command_stream, DISABLED_flush) {
memset(buffer, 0, 4096);
LinearStream cs(buffer, 4096);
size_t startOffset = 0;
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), startOffset, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), startOffset, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
pCommandStreamReceiver->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
}
@ -98,7 +98,7 @@ HWTEST_F(Tbx_command_stream, DISABLED_flushUntilTailRCSLargerThanSizeRCS) {
TbxCommandStreamReceiverHw<FamilyType> *tbxCsr = (TbxCommandStreamReceiverHw<FamilyType> *)pCommandStreamReceiver;
auto &engineInfo = tbxCsr->engineInfoTable[EngineType::ENGINE_RCS];
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), startOffset, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), startOffset, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
pCommandStreamReceiver->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
auto size = engineInfo.sizeRCS;
engineInfo.sizeRCS = 64;

View File

@ -197,7 +197,7 @@ TEST_F(DrmCommandStreamTest, Flush) {
csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
EXPECT_EQ(static_cast<uint64_t>(boHandle), flushStamp);
EXPECT_EQ(cs.getCpuBase(), nullptr);
@ -225,7 +225,7 @@ TEST_F(DrmCommandStreamTest, FlushWithLowPriorityContext) {
csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, true, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, true, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
EXPECT_EQ(cs.getCpuBase(), nullptr);
EXPECT_EQ(cs.getGraphicsAllocation(), nullptr);
@ -249,7 +249,7 @@ TEST_F(DrmCommandStreamTest, FlushInvalidAddress) {
csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
delete[] commandBuffer;
}
@ -274,7 +274,7 @@ TEST_F(DrmCommandStreamTest, FlushMultipleTimes) {
LinearStream cs(commandBuffer);
csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
EXPECT_EQ(0u, cs.getAvailableSpace());
}
@ -302,7 +302,7 @@ TEST_F(DrmCommandStreamTest, FlushNotEmptyBB) {
csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
}
@ -327,7 +327,7 @@ TEST_F(DrmCommandStreamTest, FlushNotEmptyNotPaddedBB) {
csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
}
@ -359,7 +359,7 @@ TEST_F(DrmCommandStreamTest, FlushNotAligned) {
csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
}
@ -413,7 +413,7 @@ TEST_F(DrmCommandStreamTest, FlushCheckFlags) {
csr->makeResident(allocation2);
csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
}
@ -447,7 +447,7 @@ TEST_F(DrmCommandStreamTest, CheckDrmFree) {
csr->makeResident(allocation);
csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
}
@ -489,7 +489,7 @@ TEST_F(DrmCommandStreamTest, CheckDrmFreeCloseFailed) {
csr->makeResident(allocation);
csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
}
@ -795,7 +795,7 @@ TEST_F(DrmCommandStreamGemWorkerTests, givenCommandStreamWhenItIsFlushedWithGemC
csr->alignToCacheLine(cs);
auto storedBase = cs.getCpuBase();
auto storedGraphicsAllocation = cs.getGraphicsAllocation();
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
EXPECT_EQ(cs.getCpuBase(), storedBase);
EXPECT_EQ(cs.getGraphicsAllocation(), storedGraphicsAllocation);
@ -828,7 +828,7 @@ TEST_F(DrmCommandStreamGemWorkerTests, givenTaskThatRequiresLargeResourceCountWh
csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
EXPECT_EQ(11u, this->mock->execBuffer.buffer_count);
@ -875,7 +875,7 @@ TEST_F(DrmCommandStreamGemWorkerTests, givenCommandStreamWithDuplicatesWhenItIsF
csr->alignToCacheLine(cs);
auto storedBase = cs.getCpuBase();
auto storedGraphicsAllocation = cs.getGraphicsAllocation();
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
EXPECT_EQ(cs.getCpuBase(), storedBase);
EXPECT_EQ(cs.getGraphicsAllocation(), storedGraphicsAllocation);
@ -909,7 +909,7 @@ TEST_F(DrmCommandStreamBatchingTests, givenCSRWhenFlushIsCalledThenProperFlagsAr
csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
EXPECT_EQ(3, this->mock->ioctl_cnt);
@ -1352,7 +1352,7 @@ TEST_F(DrmCommandStreamLeaksTest, Flush) {
csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
EXPECT_EQ(cs.getCpuBase(), nullptr);
EXPECT_EQ(cs.getGraphicsAllocation(), nullptr);
@ -1419,7 +1419,7 @@ TEST_F(DrmCommandStreamLeaksTest, ClearResidencyWhenFlushCalled) {
EXPECT_FALSE(isResident(allocation1->getBO()));
EXPECT_FALSE(isResident(allocation2->getBO()));
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
EXPECT_EQ(cs.getCpuBase(), nullptr);
EXPECT_EQ(cs.getGraphicsAllocation(), nullptr);
@ -1450,7 +1450,7 @@ TEST_F(DrmCommandStreamLeaksTest, FlushMultipleTimes) {
LinearStream cs(commandBuffer);
csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
commandBuffer = mm->allocateGraphicsMemory(1024, 4096);
@ -1459,7 +1459,7 @@ TEST_F(DrmCommandStreamLeaksTest, FlushMultipleTimes) {
cs.replaceGraphicsAllocation(commandBuffer);
csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs);
BatchBuffer batchBuffer2{cs.getGraphicsAllocation(), 8, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer2{cs.getGraphicsAllocation(), 8, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer2, EngineType::ENGINE_RCS, nullptr);
auto allocation = mm->allocateGraphicsMemory(1024, 4096);
@ -1476,7 +1476,7 @@ TEST_F(DrmCommandStreamLeaksTest, FlushMultipleTimes) {
cs.replaceGraphicsAllocation(commandBuffer);
csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs);
BatchBuffer batchBuffer3{cs.getGraphicsAllocation(), 16, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer3{cs.getGraphicsAllocation(), 16, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer3, EngineType::ENGINE_RCS, nullptr);
csr->makeSurfacePackNonResident(nullptr);
mm->freeGraphicsMemory(allocation);
@ -1488,7 +1488,7 @@ TEST_F(DrmCommandStreamLeaksTest, FlushMultipleTimes) {
cs.replaceGraphicsAllocation(commandBuffer);
csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs);
BatchBuffer batchBuffer4{cs.getGraphicsAllocation(), 24, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer4{cs.getGraphicsAllocation(), 24, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer4, EngineType::ENGINE_RCS, nullptr);
}
@ -1503,7 +1503,7 @@ TEST_F(DrmCommandStreamLeaksTest, FlushNotEmptyBB) {
csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
}
@ -1518,7 +1518,7 @@ TEST_F(DrmCommandStreamLeaksTest, FlushNotEmptyNotPaddedBB) {
csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
}
@ -1533,7 +1533,7 @@ TEST_F(DrmCommandStreamLeaksTest, FlushNotAligned) {
csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
}
@ -1551,7 +1551,7 @@ TEST_F(DrmCommandStreamLeaksTest, CheckDrmFree) {
csr->makeResident(*allocation);
csr->addBatchBufferEnd(cs, nullptr);
csr->alignToCacheLine(cs);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 4, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
csr->makeNonResident(*allocation);
mm->freeGraphicsMemory(allocation);

View File

@ -162,7 +162,7 @@ TEST_F(WddmCommandStreamTest, Flush) {
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
EXPECT_EQ(1u, wddm->submitResult.called);
@ -180,7 +180,7 @@ TEST_F(WddmCommandStreamTest, givenGraphicsAllocationWithDifferentGpuAddressThen
commandBuffer->setCpuPtrAndGpuAddress(cpuAddress, mockGpuAddres);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
EXPECT_EQ(mockGpuAddres, wddm->submitResult.commandBufferSubmitted);
memManager->freeGraphicsMemory(commandBuffer);
@ -191,7 +191,7 @@ TEST_F(WddmCommandStreamTest, FlushWithOffset) {
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), offset, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), offset, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
EXPECT_EQ(1u, wddm->submitResult.called);
EXPECT_TRUE(wddm->submitResult.success);
@ -205,7 +205,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledThenCoherencyRequiredFl
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
auto commandHeader = wddm->submitResult.commandHeaderSubmitted;
@ -223,7 +223,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndPreemptionIsDisabled
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
auto commandHeader = wddm->submitResult.commandHeaderSubmitted;
@ -241,7 +241,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndPreemptionIsEnabledT
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
auto commandHeader = wddm->submitResult.commandHeaderSubmitted;
@ -257,7 +257,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToLowThenS
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::LOW, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::LOW, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
auto commandHeader = wddm->submitResult.commandHeaderSubmitted;
@ -275,7 +275,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToMediumTh
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
auto commandHeader = wddm->submitResult.commandHeaderSubmitted;
@ -293,7 +293,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToHighThen
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::HIGH, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::HIGH, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
auto commandHeader = wddm->submitResult.commandHeaderSubmitted;
@ -476,7 +476,7 @@ TEST_F(WddmCommandStreamMockGdiTest, FlushCallsWddmMakeResidentForResidencyAlloc
gdi.getMakeResidentArg().NumAllocations = 0;
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
EXPECT_NE(0u, gdi.getMakeResidentArg().NumAllocations);

View File

@ -55,4 +55,5 @@ DisableAUBBufferDump = false
DisableAUBImageDump = false
UseNoRingFlushesKmdMode = false
OverrideThreadArbitrationPolicy = -1
PrintDriverDiagnostics = -1
PrintDriverDiagnostics = -1
FlattenBatchBufferForAUBDump = false