Copy command buffer into ring buffer

Resolves: NEO-7422

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2023-02-22 07:29:42 +00:00
committed by Compute-Runtime-Automation
parent 6e39b98094
commit 2f5be7a48d
40 changed files with 557 additions and 163 deletions

View File

@@ -167,7 +167,19 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::initialize(Device *device, NEO
commandContainer.setReservedSshSize(getReserveSshSize()); commandContainer.setReservedSshSize(getReserveSshSize());
DeviceImp *deviceImp = static_cast<DeviceImp *>(device); DeviceImp *deviceImp = static_cast<DeviceImp *>(device);
auto returnValue = commandContainer.initialize(deviceImp->getActiveDevice(), deviceImp->allocationsForReuse.get(), !isCopyOnly());
auto createSecondaryCmdBufferInHostMem = this->cmdListType == TYPE_IMMEDIATE &&
this->isFlushTaskSubmissionEnabled &&
!device->isImplicitScalingCapable() &&
this->csr &&
this->csr->isAnyDirectSubmissionEnabled() &&
deviceImp->getNEODevice()->getMemoryManager()->isLocalMemorySupported(deviceImp->getRootDeviceIndex());
if (NEO::DebugManager.flags.DirectSubmissionFlatRingBuffer.get() != -1) {
createSecondaryCmdBufferInHostMem &= !!NEO::DebugManager.flags.DirectSubmissionFlatRingBuffer.get();
}
auto returnValue = commandContainer.initialize(deviceImp->getActiveDevice(), deviceImp->allocationsForReuse.get(), !isCopyOnly(), createSecondaryCmdBufferInHostMem);
if (!this->pipelineSelectStateTracking) { if (!this->pipelineSelectStateTracking) {
// allow systolic support set in container when tracking disabled // allow systolic support set in container when tracking disabled
// setting systolic support allows dispatching untracked command in legacy mode // setting systolic support allows dispatching untracked command in legacy mode

View File

@@ -147,7 +147,7 @@ struct CommandListCoreFamilyImmediate : public CommandListCoreFamily<gfxCoreFami
NEO::CompletionStamp flushRegularTask(NEO::LinearStream &cmdStreamTask, size_t taskStartOffset, bool hasStallingCmds, bool hasRelaxedOrderingDependencies); NEO::CompletionStamp flushRegularTask(NEO::LinearStream &cmdStreamTask, size_t taskStartOffset, bool hasStallingCmds, bool hasRelaxedOrderingDependencies);
NEO::CompletionStamp flushBcsTask(NEO::LinearStream &cmdStreamTask, size_t taskStartOffset, bool hasStallingCmds, bool hasRelaxedOrderingDependencies, NEO::CommandStreamReceiver *csr); NEO::CompletionStamp flushBcsTask(NEO::LinearStream &cmdStreamTask, size_t taskStartOffset, bool hasStallingCmds, bool hasRelaxedOrderingDependencies, NEO::CommandStreamReceiver *csr);
void checkAvailableSpace(uint32_t numEvents); void checkAvailableSpace(uint32_t numEvents, bool hasRelaxedOrderingDependencies);
void updateDispatchFlagsWithRequiredStreamState(NEO::DispatchFlags &dispatchFlags); void updateDispatchFlagsWithRequiredStreamState(NEO::DispatchFlags &dispatchFlags);
ze_result_t flushImmediate(ze_result_t inputRet, bool performMigration, bool hasStallingCmds, bool hasRelaxedOrderingDependencies, ze_event_handle_t hSignalEvent); ze_result_t flushImmediate(ze_result_t inputRet, bool performMigration, bool hasStallingCmds, bool hasRelaxedOrderingDependencies, ze_event_handle_t hSignalEvent);

View File

@@ -34,16 +34,26 @@ NEO::LogicalStateHelper *CommandListCoreFamilyImmediate<gfxCoreFamily>::getLogic
} }
template <GFXCORE_FAMILY gfxCoreFamily> template <GFXCORE_FAMILY gfxCoreFamily>
void CommandListCoreFamilyImmediate<gfxCoreFamily>::checkAvailableSpace(uint32_t numEvents) { void CommandListCoreFamilyImmediate<gfxCoreFamily>::checkAvailableSpace(uint32_t numEvents, bool hasRelaxedOrderingDependencies) {
this->commandContainer.fillReusableAllocationLists(); this->commandContainer.fillReusableAllocationLists();
/* Command container might has two command buffers. If it has, one is in local memory, because relaxed ordering requires that and one in system for copying it into ring buffer.
If relaxed ordering is needed in given dispatch and current command stream is in system memory, swap of command streams is required to ensure local memory. Same in the opposite scenario. */
if (hasRelaxedOrderingDependencies == NEO::MemoryPoolHelper::isSystemMemoryPool(this->commandContainer.getCommandStream()->getGraphicsAllocation()->getMemoryPool())) {
if (this->commandContainer.swapStreams()) {
this->cmdListCurrentStartOffset = this->commandContainer.getCommandStream()->getUsed();
}
}
size_t semaphoreSize = NEO::EncodeSempahore<GfxFamily>::getSizeMiSemaphoreWait() * numEvents; size_t semaphoreSize = NEO::EncodeSempahore<GfxFamily>::getSizeMiSemaphoreWait() * numEvents;
if (this->commandContainer.getCommandStream()->getAvailableSpace() < maxImmediateCommandSize + semaphoreSize) { if (this->commandContainer.getCommandStream()->getAvailableSpace() < maxImmediateCommandSize + semaphoreSize) {
bool requireSystemMemoryCommandBuffer = !hasRelaxedOrderingDependencies;
auto alloc = this->commandContainer.reuseExistingCmdBuffer(); auto alloc = this->commandContainer.reuseExistingCmdBuffer(requireSystemMemoryCommandBuffer);
this->commandContainer.addCurrentCommandBufferToReusableAllocationList(); this->commandContainer.addCurrentCommandBufferToReusableAllocationList();
if (!alloc) { if (!alloc) {
alloc = this->commandContainer.allocateCommandBuffer(); alloc = this->commandContainer.allocateCommandBuffer(requireSystemMemoryCommandBuffer);
this->commandContainer.getCmdBufferAllocations().push_back(alloc); this->commandContainer.getCmdBufferAllocations().push_back(alloc);
} }
this->commandContainer.setCmdBuffer(alloc); this->commandContainer.setCmdBuffer(alloc);
@@ -328,8 +338,10 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendLaunchKernel(
ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents, ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents,
const CmdListKernelLaunchParams &launchParams, bool relaxedOrderingDispatch) { const CmdListKernelLaunchParams &launchParams, bool relaxedOrderingDispatch) {
relaxedOrderingDispatch = isRelaxedOrderingDispatchAllowed(numWaitEvents);
if (this->isFlushTaskSubmissionEnabled) { if (this->isFlushTaskSubmissionEnabled) {
checkAvailableSpace(numWaitEvents); checkAvailableSpace(numWaitEvents, relaxedOrderingDispatch);
} }
bool hostWait = waitForEventsFromHost(); bool hostWait = waitForEventsFromHost();
if (hostWait || this->eventWaitlistSyncRequired()) { if (hostWait || this->eventWaitlistSyncRequired()) {
@@ -340,8 +352,6 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendLaunchKernel(
} }
} }
relaxedOrderingDispatch = isRelaxedOrderingDispatchAllowed(numWaitEvents);
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernel(kernelHandle, threadGroupDimensions, auto ret = CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernel(kernelHandle, threadGroupDimensions,
hSignalEvent, numWaitEvents, phWaitEvents, hSignalEvent, numWaitEvents, phWaitEvents,
launchParams, relaxedOrderingDispatch); launchParams, relaxedOrderingDispatch);
@@ -352,14 +362,13 @@ template <GFXCORE_FAMILY gfxCoreFamily>
ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendLaunchKernelIndirect( ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendLaunchKernelIndirect(
ze_kernel_handle_t kernelHandle, const ze_group_count_t *pDispatchArgumentsBuffer, ze_kernel_handle_t kernelHandle, const ze_group_count_t *pDispatchArgumentsBuffer,
ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents, bool relaxedOrderingDispatch) { ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents, bool relaxedOrderingDispatch) {
relaxedOrderingDispatch = isRelaxedOrderingDispatchAllowed(numWaitEvents);
if (this->isFlushTaskSubmissionEnabled) { if (this->isFlushTaskSubmissionEnabled) {
checkAvailableSpace(numWaitEvents); checkAvailableSpace(numWaitEvents, relaxedOrderingDispatch);
checkWaitEventsState(numWaitEvents, phWaitEvents); checkWaitEventsState(numWaitEvents, phWaitEvents);
} }
relaxedOrderingDispatch = isRelaxedOrderingDispatchAllowed(numWaitEvents);
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernelIndirect(kernelHandle, pDispatchArgumentsBuffer, auto ret = CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernelIndirect(kernelHandle, pDispatchArgumentsBuffer,
hSignalEvent, numWaitEvents, phWaitEvents, relaxedOrderingDispatch); hSignalEvent, numWaitEvents, phWaitEvents, relaxedOrderingDispatch);
return flushImmediate(ret, true, false, relaxedOrderingDispatch, hSignalEvent); return flushImmediate(ret, true, false, relaxedOrderingDispatch, hSignalEvent);
@@ -373,7 +382,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendBarrier(
ze_result_t ret = ZE_RESULT_SUCCESS; ze_result_t ret = ZE_RESULT_SUCCESS;
if (this->isFlushTaskSubmissionEnabled) { if (this->isFlushTaskSubmissionEnabled) {
checkAvailableSpace(numWaitEvents); checkAvailableSpace(numWaitEvents, false);
checkWaitEventsState(numWaitEvents, phWaitEvents); checkWaitEventsState(numWaitEvents, phWaitEvents);
} }
ret = CommandListCoreFamily<gfxCoreFamily>::appendBarrier(hSignalEvent, numWaitEvents, phWaitEvents); ret = CommandListCoreFamily<gfxCoreFamily>::appendBarrier(hSignalEvent, numWaitEvents, phWaitEvents);
@@ -390,9 +399,10 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendMemoryCopy(
ze_event_handle_t hSignalEvent, ze_event_handle_t hSignalEvent,
uint32_t numWaitEvents, uint32_t numWaitEvents,
ze_event_handle_t *phWaitEvents, bool relaxedOrderingDispatch) { ze_event_handle_t *phWaitEvents, bool relaxedOrderingDispatch) {
relaxedOrderingDispatch = isRelaxedOrderingDispatchAllowed(numWaitEvents);
if (this->isFlushTaskSubmissionEnabled) { if (this->isFlushTaskSubmissionEnabled) {
checkAvailableSpace(numWaitEvents); checkAvailableSpace(numWaitEvents, relaxedOrderingDispatch);
checkWaitEventsState(numWaitEvents, phWaitEvents); checkWaitEventsState(numWaitEvents, phWaitEvents);
} }
@@ -407,8 +417,6 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendMemoryCopy(
} }
} }
relaxedOrderingDispatch = isRelaxedOrderingDispatchAllowed(numWaitEvents);
NEO::TransferDirection direction; NEO::TransferDirection direction;
auto isSplitNeeded = this->isAppendSplitNeeded(dstptr, srcptr, size, direction); auto isSplitNeeded = this->isAppendSplitNeeded(dstptr, srcptr, size, direction);
if (isSplitNeeded) { if (isSplitNeeded) {
@@ -436,16 +444,15 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendMemoryCopyRegio
ze_event_handle_t hSignalEvent, ze_event_handle_t hSignalEvent,
uint32_t numWaitEvents, uint32_t numWaitEvents,
ze_event_handle_t *phWaitEvents, bool relaxedOrderingDispatch) { ze_event_handle_t *phWaitEvents, bool relaxedOrderingDispatch) {
relaxedOrderingDispatch = isRelaxedOrderingDispatchAllowed(numWaitEvents);
if (this->isFlushTaskSubmissionEnabled) { if (this->isFlushTaskSubmissionEnabled) {
checkAvailableSpace(numWaitEvents); checkAvailableSpace(numWaitEvents, relaxedOrderingDispatch);
checkWaitEventsState(numWaitEvents, phWaitEvents); checkWaitEventsState(numWaitEvents, phWaitEvents);
} }
ze_result_t ret; ze_result_t ret;
relaxedOrderingDispatch = isRelaxedOrderingDispatchAllowed(numWaitEvents);
NEO::TransferDirection direction; NEO::TransferDirection direction;
auto isSplitNeeded = this->isAppendSplitNeeded(dstPtr, srcPtr, this->getTotalSizeForCopyRegion(dstRegion, dstPitch, dstSlicePitch), direction); auto isSplitNeeded = this->isAppendSplitNeeded(dstPtr, srcPtr, this->getTotalSizeForCopyRegion(dstRegion, dstPitch, dstSlicePitch), direction);
if (isSplitNeeded) { if (isSplitNeeded) {
@@ -478,14 +485,13 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendMemoryFill(void
ze_event_handle_t hSignalEvent, ze_event_handle_t hSignalEvent,
uint32_t numWaitEvents, uint32_t numWaitEvents,
ze_event_handle_t *phWaitEvents, bool relaxedOrderingDispatch) { ze_event_handle_t *phWaitEvents, bool relaxedOrderingDispatch) {
relaxedOrderingDispatch = isRelaxedOrderingDispatchAllowed(numWaitEvents);
if (this->isFlushTaskSubmissionEnabled) { if (this->isFlushTaskSubmissionEnabled) {
checkAvailableSpace(numWaitEvents); checkAvailableSpace(numWaitEvents, relaxedOrderingDispatch);
checkWaitEventsState(numWaitEvents, phWaitEvents); checkWaitEventsState(numWaitEvents, phWaitEvents);
} }
relaxedOrderingDispatch = isRelaxedOrderingDispatchAllowed(numWaitEvents);
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendMemoryFill(ptr, pattern, patternSize, size, hSignalEvent, numWaitEvents, phWaitEvents, relaxedOrderingDispatch); auto ret = CommandListCoreFamily<gfxCoreFamily>::appendMemoryFill(ptr, pattern, patternSize, size, hSignalEvent, numWaitEvents, phWaitEvents, relaxedOrderingDispatch);
return flushImmediate(ret, true, false, relaxedOrderingDispatch, hSignalEvent); return flushImmediate(ret, true, false, relaxedOrderingDispatch, hSignalEvent);
@@ -497,7 +503,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendSignalEvent(ze_
ze_result_t ret = ZE_RESULT_SUCCESS; ze_result_t ret = ZE_RESULT_SUCCESS;
if (this->isFlushTaskSubmissionEnabled) { if (this->isFlushTaskSubmissionEnabled) {
checkAvailableSpace(0); checkAvailableSpace(0, false);
} }
ret = CommandListCoreFamily<gfxCoreFamily>::appendSignalEvent(hSignalEvent); ret = CommandListCoreFamily<gfxCoreFamily>::appendSignalEvent(hSignalEvent);
return flushImmediate(ret, true, true, false, hSignalEvent); return flushImmediate(ret, true, true, false, hSignalEvent);
@@ -509,7 +515,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendEventReset(ze_e
ze_result_t ret = ZE_RESULT_SUCCESS; ze_result_t ret = ZE_RESULT_SUCCESS;
if (this->isFlushTaskSubmissionEnabled) { if (this->isFlushTaskSubmissionEnabled) {
checkAvailableSpace(0); checkAvailableSpace(0, false);
} }
ret = CommandListCoreFamily<gfxCoreFamily>::appendEventReset(hSignalEvent); ret = CommandListCoreFamily<gfxCoreFamily>::appendEventReset(hSignalEvent);
return flushImmediate(ret, true, true, false, hSignalEvent); return flushImmediate(ret, true, true, false, hSignalEvent);
@@ -521,7 +527,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendPageFaultCopy(N
size_t size, bool flushHost) { size_t size, bool flushHost) {
if (this->isFlushTaskSubmissionEnabled) { if (this->isFlushTaskSubmissionEnabled) {
checkAvailableSpace(0); checkAvailableSpace(0, false);
} }
ze_result_t ret; ze_result_t ret;
@@ -557,7 +563,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendWaitOnEvents(ui
return ZE_RESULT_SUCCESS; return ZE_RESULT_SUCCESS;
} }
if (this->isFlushTaskSubmissionEnabled) { if (this->isFlushTaskSubmissionEnabled) {
checkAvailableSpace(numEvents); checkAvailableSpace(numEvents, false);
checkWaitEventsState(numEvents, phWaitEvents); checkWaitEventsState(numEvents, phWaitEvents);
} }
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendWaitOnEvents(numEvents, phWaitEvents, relaxedOrderingAllowed, trackDependencies); auto ret = CommandListCoreFamily<gfxCoreFamily>::appendWaitOnEvents(numEvents, phWaitEvents, relaxedOrderingAllowed, trackDependencies);
@@ -571,7 +577,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendWriteGlobalTime
uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents) { uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents) {
if (this->isFlushTaskSubmissionEnabled) { if (this->isFlushTaskSubmissionEnabled) {
checkAvailableSpace(numWaitEvents); checkAvailableSpace(numWaitEvents, false);
checkWaitEventsState(numWaitEvents, phWaitEvents); checkWaitEventsState(numWaitEvents, phWaitEvents);
} }
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendWriteGlobalTimestamp(dstptr, hSignalEvent, numWaitEvents, phWaitEvents); auto ret = CommandListCoreFamily<gfxCoreFamily>::appendWriteGlobalTimestamp(dstptr, hSignalEvent, numWaitEvents, phWaitEvents);
@@ -606,14 +612,13 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendImageCopyRegion
ze_event_handle_t hSignalEvent, ze_event_handle_t hSignalEvent,
uint32_t numWaitEvents, uint32_t numWaitEvents,
ze_event_handle_t *phWaitEvents, bool relaxedOrderingDispatch) { ze_event_handle_t *phWaitEvents, bool relaxedOrderingDispatch) {
relaxedOrderingDispatch = isRelaxedOrderingDispatchAllowed(numWaitEvents);
if (this->isFlushTaskSubmissionEnabled) { if (this->isFlushTaskSubmissionEnabled) {
checkAvailableSpace(numWaitEvents); checkAvailableSpace(numWaitEvents, relaxedOrderingDispatch);
checkWaitEventsState(numWaitEvents, phWaitEvents); checkWaitEventsState(numWaitEvents, phWaitEvents);
} }
relaxedOrderingDispatch = isRelaxedOrderingDispatchAllowed(numWaitEvents);
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendImageCopyRegion(hDstImage, hSrcImage, pDstRegion, pSrcRegion, hSignalEvent, auto ret = CommandListCoreFamily<gfxCoreFamily>::appendImageCopyRegion(hDstImage, hSrcImage, pDstRegion, pSrcRegion, hSignalEvent,
numWaitEvents, phWaitEvents, relaxedOrderingDispatch); numWaitEvents, phWaitEvents, relaxedOrderingDispatch);
return flushImmediate(ret, true, false, relaxedOrderingDispatch, hSignalEvent); return flushImmediate(ret, true, false, relaxedOrderingDispatch, hSignalEvent);
@@ -627,14 +632,13 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendImageCopyFromMe
ze_event_handle_t hSignalEvent, ze_event_handle_t hSignalEvent,
uint32_t numWaitEvents, uint32_t numWaitEvents,
ze_event_handle_t *phWaitEvents, bool relaxedOrderingDispatch) { ze_event_handle_t *phWaitEvents, bool relaxedOrderingDispatch) {
relaxedOrderingDispatch = isRelaxedOrderingDispatchAllowed(numWaitEvents);
if (this->isFlushTaskSubmissionEnabled) { if (this->isFlushTaskSubmissionEnabled) {
checkAvailableSpace(numWaitEvents); checkAvailableSpace(numWaitEvents, relaxedOrderingDispatch);
checkWaitEventsState(numWaitEvents, phWaitEvents); checkWaitEventsState(numWaitEvents, phWaitEvents);
} }
relaxedOrderingDispatch = isRelaxedOrderingDispatchAllowed(numWaitEvents);
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendImageCopyFromMemory(hDstImage, srcPtr, pDstRegion, hSignalEvent, auto ret = CommandListCoreFamily<gfxCoreFamily>::appendImageCopyFromMemory(hDstImage, srcPtr, pDstRegion, hSignalEvent,
numWaitEvents, phWaitEvents, relaxedOrderingDispatch); numWaitEvents, phWaitEvents, relaxedOrderingDispatch);
@@ -649,14 +653,13 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendImageCopyToMemo
ze_event_handle_t hSignalEvent, ze_event_handle_t hSignalEvent,
uint32_t numWaitEvents, uint32_t numWaitEvents,
ze_event_handle_t *phWaitEvents, bool relaxedOrderingDispatch) { ze_event_handle_t *phWaitEvents, bool relaxedOrderingDispatch) {
relaxedOrderingDispatch = isRelaxedOrderingDispatchAllowed(numWaitEvents);
if (this->isFlushTaskSubmissionEnabled) { if (this->isFlushTaskSubmissionEnabled) {
checkAvailableSpace(numWaitEvents); checkAvailableSpace(numWaitEvents, relaxedOrderingDispatch);
checkWaitEventsState(numWaitEvents, phWaitEvents); checkWaitEventsState(numWaitEvents, phWaitEvents);
} }
relaxedOrderingDispatch = isRelaxedOrderingDispatchAllowed(numWaitEvents);
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendImageCopyToMemory(dstPtr, hSrcImage, pSrcRegion, hSignalEvent, auto ret = CommandListCoreFamily<gfxCoreFamily>::appendImageCopyToMemory(dstPtr, hSrcImage, pSrcRegion, hSignalEvent,
numWaitEvents, phWaitEvents, relaxedOrderingDispatch); numWaitEvents, phWaitEvents, relaxedOrderingDispatch);
@@ -671,7 +674,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendMemoryRangesBar
uint32_t numWaitEvents, uint32_t numWaitEvents,
ze_event_handle_t *phWaitEvents) { ze_event_handle_t *phWaitEvents) {
if (this->isFlushTaskSubmissionEnabled) { if (this->isFlushTaskSubmissionEnabled) {
checkAvailableSpace(numWaitEvents); checkAvailableSpace(numWaitEvents, false);
checkWaitEventsState(numWaitEvents, phWaitEvents); checkWaitEventsState(numWaitEvents, phWaitEvents);
} }
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendMemoryRangesBarrier(numRanges, pRangeSizes, pRanges, hSignalEvent, numWaitEvents, phWaitEvents); auto ret = CommandListCoreFamily<gfxCoreFamily>::appendMemoryRangesBarrier(numRanges, pRangeSizes, pRanges, hSignalEvent, numWaitEvents, phWaitEvents);
@@ -684,13 +687,13 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendLaunchCooperati
ze_event_handle_t hSignalEvent, ze_event_handle_t hSignalEvent,
uint32_t numWaitEvents, uint32_t numWaitEvents,
ze_event_handle_t *waitEventHandles, bool relaxedOrderingDispatch) { ze_event_handle_t *waitEventHandles, bool relaxedOrderingDispatch) {
relaxedOrderingDispatch = isRelaxedOrderingDispatchAllowed(numWaitEvents);
if (this->isFlushTaskSubmissionEnabled) { if (this->isFlushTaskSubmissionEnabled) {
checkAvailableSpace(numWaitEvents); checkAvailableSpace(numWaitEvents, relaxedOrderingDispatch);
checkWaitEventsState(numWaitEvents, waitEventHandles); checkWaitEventsState(numWaitEvents, waitEventHandles);
} }
relaxedOrderingDispatch = isRelaxedOrderingDispatchAllowed(numWaitEvents);
auto ret = CommandListCoreFamily<gfxCoreFamily>::appendLaunchCooperativeKernel(kernelHandle, launchKernelArgs, hSignalEvent, numWaitEvents, waitEventHandles, relaxedOrderingDispatch); auto ret = CommandListCoreFamily<gfxCoreFamily>::appendLaunchCooperativeKernel(kernelHandle, launchKernelArgs, hSignalEvent, numWaitEvents, waitEventHandles, relaxedOrderingDispatch);
return flushImmediate(ret, true, false, relaxedOrderingDispatch, hSignalEvent); return flushImmediate(ret, true, false, relaxedOrderingDispatch, hSignalEvent);
} }

View File

@@ -11,6 +11,7 @@
#include "shared/source/kernel/implicit_args.h" #include "shared/source/kernel/implicit_args.h"
#include "shared/test/common/cmd_parse/gen_cmd_parse.h" #include "shared/test/common/cmd_parse/gen_cmd_parse.h"
#include "shared/test/common/helpers/unit_test_helper.h" #include "shared/test/common/helpers/unit_test_helper.h"
#include "shared/test/common/libult/ult_command_stream_receiver.h"
#include "shared/test/common/test_macros/hw_test.h" #include "shared/test/common/test_macros/hw_test.h"
#include "level_zero/core/source/kernel/kernel_imp.h" #include "level_zero/core/source/kernel/kernel_imp.h"
@@ -813,6 +814,139 @@ HWTEST_F(CommandListCreate, givenFlushTaskFlagEnabledAndAsyncCmdQueueAndCopyOnly
EXPECT_GT(commandContainer.getCommandStream()->getUsed(), used); EXPECT_GT(commandContainer.getCommandStream()->getUsed(), used);
} }
struct CmdContainerMock : public CommandContainer {
using CommandContainer::secondaryCommandStreamForImmediateCmdList;
};
HWTEST_F(CommandListCreate, givenImmediateCopyOnlySingleTileDirectSubmissionCommandListWhenInitializeThenCreateSecondaryCmdBufferInSystemMemory) {
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionFlatRingBuffer.set(-1);
ze_command_queue_desc_t desc = {};
desc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS;
ze_result_t returnValue;
CommandStreamReceiver *csr = nullptr;
device->getCsrForOrdinalAndIndex(&csr, desc.ordinal, desc.index);
reinterpret_cast<UltCommandStreamReceiver<FamilyType> *>(csr)->directSubmissionAvailable = true;
std::unique_ptr<L0::CommandList> commandList(CommandList::createImmediate(productFamily, device, &desc, false, NEO::EngineGroupType::Copy, returnValue));
ASSERT_NE(nullptr, commandList);
auto localMemSupported = device->getHwInfo().featureTable.flags.ftrLocalMemory;
EXPECT_EQ(reinterpret_cast<CmdContainerMock *>(&commandList->commandContainer)->secondaryCommandStreamForImmediateCmdList.get() != nullptr, localMemSupported);
if (localMemSupported) {
EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(reinterpret_cast<CmdContainerMock *>(&commandList->commandContainer)->secondaryCommandStreamForImmediateCmdList->getGraphicsAllocation()->getMemoryPool()));
}
}
HWTEST2_F(CommandListCreate, givenSecondaryCommandStreamForImmediateCmdListWhenCheckAvailableSpaceThenSwapCommandStreams, IsAtLeastSkl) {
if (!device->getHwInfo().featureTable.flags.ftrLocalMemory) {
GTEST_SKIP();
}
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionFlatRingBuffer.set(-1);
static_cast<MockMemoryManager *>(device->getNEODevice()->getMemoryManager())->localMemorySupported[0] = true;
ze_command_queue_desc_t desc = {};
desc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS;
ze_result_t returnValue;
CommandStreamReceiver *csr = nullptr;
device->getCsrForOrdinalAndIndex(&csr, desc.ordinal, desc.index);
reinterpret_cast<UltCommandStreamReceiver<FamilyType> *>(csr)->directSubmissionAvailable = true;
std::unique_ptr<L0::CommandList> commandList(CommandList::createImmediate(productFamily, device, &desc, false, NEO::EngineGroupType::Copy, returnValue));
ASSERT_NE(nullptr, commandList);
EXPECT_NE(reinterpret_cast<CmdContainerMock *>(&commandList->commandContainer)->secondaryCommandStreamForImmediateCmdList.get(), nullptr);
EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(reinterpret_cast<CmdContainerMock *>(&commandList->commandContainer)->secondaryCommandStreamForImmediateCmdList->getGraphicsAllocation()->getMemoryPool()));
auto immediateCmdList = static_cast<CommandListCoreFamilyImmediate<gfxCoreFamily> *>(commandList.get());
auto secondaryCmdStream = reinterpret_cast<CmdContainerMock *>(&commandList->commandContainer)->secondaryCommandStreamForImmediateCmdList.get();
immediateCmdList->checkAvailableSpace(0u, false);
EXPECT_EQ(commandList->commandContainer.getCommandStream(), secondaryCmdStream);
EXPECT_TRUE(MemoryPoolHelper::isSystemMemoryPool(commandList->commandContainer.getCommandStream()->getGraphicsAllocation()->getMemoryPool()));
}
HWTEST2_F(CommandListCreate, givenNoSecondaryCommandStreamForImmediateCmdListWhenCheckAvailableSpaceThenNotSwapCommandStreams, IsAtLeastSkl) {
if (!device->getHwInfo().featureTable.flags.ftrLocalMemory) {
GTEST_SKIP();
}
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionFlatRingBuffer.set(-1);
static_cast<MockMemoryManager *>(device->getNEODevice()->getMemoryManager())->localMemorySupported[0] = true;
ze_command_queue_desc_t desc = {};
desc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS;
ze_result_t returnValue;
std::unique_ptr<L0::CommandList> commandList(CommandList::createImmediate(productFamily, device, &desc, false, NEO::EngineGroupType::Copy, returnValue));
ASSERT_NE(nullptr, commandList);
EXPECT_EQ(reinterpret_cast<CmdContainerMock *>(&commandList->commandContainer)->secondaryCommandStreamForImmediateCmdList.get(), nullptr);
auto immediateCmdList = static_cast<CommandListCoreFamilyImmediate<gfxCoreFamily> *>(commandList.get());
auto cmdStream = commandList->commandContainer.getCommandStream();
immediateCmdList->checkAvailableSpace(0u, false);
EXPECT_EQ(commandList->commandContainer.getCommandStream(), cmdStream);
EXPECT_FALSE(MemoryPoolHelper::isSystemMemoryPool(commandList->commandContainer.getCommandStream()->getGraphicsAllocation()->getMemoryPool()));
}
HWTEST_F(CommandListCreate, givenDirectSubmissionFlatRingBufferFlagDisabledImmediateCopyOnlySingleTileDirectSubmissionCommandListWhenInitializeThenNotCreateSecondaryCmdBufferInSystemMemory) {
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionFlatRingBuffer.set(0u);
ze_command_queue_desc_t desc = {};
desc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS;
ze_result_t returnValue;
CommandStreamReceiver *csr = nullptr;
device->getCsrForOrdinalAndIndex(&csr, desc.ordinal, desc.index);
reinterpret_cast<UltCommandStreamReceiver<FamilyType> *>(csr)->directSubmissionAvailable = true;
std::unique_ptr<L0::CommandList> commandList(CommandList::createImmediate(productFamily, device, &desc, false, NEO::EngineGroupType::Copy, returnValue));
ASSERT_NE(nullptr, commandList);
EXPECT_EQ(reinterpret_cast<CmdContainerMock *>(&commandList->commandContainer)->secondaryCommandStreamForImmediateCmdList.get(), nullptr);
}
HWTEST_F(CommandListCreate, givenImmediateCopyOnlySingleTileCommandListWhenInitializeThenNotCreateSecondaryCmdBufferInSystemMemory) {
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionFlatRingBuffer.set(-1);
ze_command_queue_desc_t desc = {};
desc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS;
ze_result_t returnValue;
std::unique_ptr<L0::CommandList> commandList(CommandList::createImmediate(productFamily, device, &desc, false, NEO::EngineGroupType::Copy, returnValue));
ASSERT_NE(nullptr, commandList);
EXPECT_EQ(reinterpret_cast<CmdContainerMock *>(&commandList->commandContainer)->secondaryCommandStreamForImmediateCmdList.get(), nullptr);
}
using CommandListCreateImplicitScaling = Test<SingleRootMultiSubDeviceFixtureWithImplicitScaling<1u, 1u>>;
HWTEST_F(CommandListCreateImplicitScaling, givenImmediateCopyOnlyDirectSubmissionCommandListWhenInitializeThenNotCreateSecondaryCmdBufferInSystemMemory) {
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionFlatRingBuffer.set(-1);
ze_command_queue_desc_t desc = {};
desc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS;
ze_result_t returnValue;
CommandStreamReceiver *csr = nullptr;
device->getCsrForOrdinalAndIndex(&csr, desc.ordinal, desc.index);
reinterpret_cast<UltCommandStreamReceiver<FamilyType> *>(csr)->directSubmissionAvailable = true;
std::unique_ptr<L0::CommandList> commandList(CommandList::createImmediate(productFamily, device, &desc, false, NEO::EngineGroupType::Copy, returnValue));
ASSERT_NE(nullptr, commandList);
EXPECT_EQ(reinterpret_cast<CmdContainerMock *>(&commandList->commandContainer)->secondaryCommandStreamForImmediateCmdList.get(), nullptr);
}
HWTEST_F(CommandListCreate, givenCopyOnlySingleTileDirectSubmissionCommandListWhenInitializeThenNotCreateSecondaryCmdBufferInSystemMemory) {
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionFlatRingBuffer.set(-1);
ze_result_t returnValue;
CommandStreamReceiver *csr = nullptr;
device->getCsrForOrdinalAndIndex(&csr, 0u, 0u);
reinterpret_cast<UltCommandStreamReceiver<FamilyType> *>(csr)->directSubmissionAvailable = true;
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::Copy, 0u, returnValue));
ASSERT_NE(nullptr, commandList);
EXPECT_EQ(reinterpret_cast<CmdContainerMock *>(&commandList->commandContainer)->secondaryCommandStreamForImmediateCmdList.get(), nullptr);
}
HWTEST_F(CommandListCreate, givenAsyncCmdQueueAndCopyOnlyImmediateCommandListWhenAppendWaitEventsWithSubdeviceScopeThenMiFlushAndSemWaitAreAdded) { HWTEST_F(CommandListCreate, givenAsyncCmdQueueAndCopyOnlyImmediateCommandListWhenAppendWaitEventsWithSubdeviceScopeThenMiFlushAndSemWaitAreAdded) {
using SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT; using SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;

View File

@@ -1894,12 +1894,12 @@ HWTEST2_F(CommandListCreate, givenImmediateCommandListWhenThereIsNoEnoughSpaceFo
commandList->commandContainer.getCommandStream()->getGraphicsAllocation()->updateTaskCount(0u, 0u); commandList->commandContainer.getCommandStream()->getGraphicsAllocation()->updateTaskCount(0u, 0u);
commandList->commandContainer.getCommandStream()->getSpace(useSize); commandList->commandContainer.getCommandStream()->getSpace(useSize);
reinterpret_cast<CommandListCoreFamilyImmediate<gfxCoreFamily> *>(commandList.get())->checkAvailableSpace(0); reinterpret_cast<CommandListCoreFamilyImmediate<gfxCoreFamily> *>(commandList.get())->checkAvailableSpace(0, false);
EXPECT_EQ(1U, commandList->commandContainer.getCmdBufferAllocations().size()); EXPECT_EQ(1U, commandList->commandContainer.getCmdBufferAllocations().size());
commandList->commandContainer.getCommandStream()->getSpace(useSize); commandList->commandContainer.getCommandStream()->getSpace(useSize);
auto latestFlushedTaskCount = commandList->csr->peekLatestFlushedTaskCount(); auto latestFlushedTaskCount = commandList->csr->peekLatestFlushedTaskCount();
reinterpret_cast<CommandListCoreFamilyImmediate<gfxCoreFamily> *>(commandList.get())->checkAvailableSpace(0); reinterpret_cast<CommandListCoreFamilyImmediate<gfxCoreFamily> *>(commandList.get())->checkAvailableSpace(0, false);
EXPECT_EQ(1U, commandList->commandContainer.getCmdBufferAllocations().size()); EXPECT_EQ(1U, commandList->commandContainer.getCmdBufferAllocations().size());
EXPECT_EQ(latestFlushedTaskCount + 1, commandList->csr->peekLatestFlushedTaskCount()); EXPECT_EQ(latestFlushedTaskCount + 1, commandList->csr->peekLatestFlushedTaskCount());
} }
@@ -1920,12 +1920,12 @@ HWTEST2_F(CommandListCreate, givenImmediateCommandListWhenThereIsNoEnoughSpaceFo
commandList->commandContainer.getCommandStream()->getGraphicsAllocation()->updateTaskCount(0u, 0u); commandList->commandContainer.getCommandStream()->getGraphicsAllocation()->updateTaskCount(0u, 0u);
commandList->commandContainer.getCommandStream()->getSpace(useSize); commandList->commandContainer.getCommandStream()->getSpace(useSize);
reinterpret_cast<CommandListCoreFamilyImmediate<gfxCoreFamily> *>(commandList.get())->checkAvailableSpace(numEvents); reinterpret_cast<CommandListCoreFamilyImmediate<gfxCoreFamily> *>(commandList.get())->checkAvailableSpace(numEvents, false);
EXPECT_EQ(1U, commandList->commandContainer.getCmdBufferAllocations().size()); EXPECT_EQ(1U, commandList->commandContainer.getCmdBufferAllocations().size());
commandList->commandContainer.getCommandStream()->getSpace(useSize); commandList->commandContainer.getCommandStream()->getSpace(useSize);
auto latestFlushedTaskCount = commandList->csr->peekLatestFlushedTaskCount(); auto latestFlushedTaskCount = commandList->csr->peekLatestFlushedTaskCount();
reinterpret_cast<CommandListCoreFamilyImmediate<gfxCoreFamily> *>(commandList.get())->checkAvailableSpace(numEvents); reinterpret_cast<CommandListCoreFamilyImmediate<gfxCoreFamily> *>(commandList.get())->checkAvailableSpace(numEvents, false);
EXPECT_EQ(1U, commandList->commandContainer.getCmdBufferAllocations().size()); EXPECT_EQ(1U, commandList->commandContainer.getCmdBufferAllocations().size());
EXPECT_EQ(latestFlushedTaskCount + 1, commandList->csr->peekLatestFlushedTaskCount()); EXPECT_EQ(latestFlushedTaskCount + 1, commandList->csr->peekLatestFlushedTaskCount());
} }

View File

@@ -704,7 +704,7 @@ TEST(SourceLevelDebugger, whenCaptureSBACalledThenNoCommandsAreAddedToStream) {
MockSourceLevelDebugger debugger; MockSourceLevelDebugger debugger;
CommandContainer container; CommandContainer container;
container.initialize(device.get(), nullptr, true); container.initialize(device.get(), nullptr, true, false);
NEO::Debugger::SbaAddresses sbaAddresses = {}; NEO::Debugger::SbaAddresses sbaAddresses = {};
debugger.captureStateBaseAddress(*container.getCommandStream(), sbaAddresses, false); debugger.captureStateBaseAddress(*container.getCommandStream(), sbaAddresses, false);

View File

@@ -65,7 +65,7 @@ CommandContainer::CommandContainer(uint32_t maxNumAggregatedIdds) : CommandConta
numIddsPerBlock = maxNumAggregatedIdds; numIddsPerBlock = maxNumAggregatedIdds;
} }
CommandContainer::ErrorCode CommandContainer::initialize(Device *device, AllocationsList *reusableAllocationList, bool requireHeaps) { CommandContainer::ErrorCode CommandContainer::initialize(Device *device, AllocationsList *reusableAllocationList, bool requireHeaps, bool createSecondaryCmdBufferInHostMem) {
this->device = device; this->device = device;
this->reusableAllocationList = reusableAllocationList; this->reusableAllocationList = reusableAllocationList;
size_t alignedSize = alignUp<size_t>(this->getTotalCmdBufferSize(), MemoryConstants::pageSize64k); size_t alignedSize = alignUp<size_t>(this->getTotalCmdBufferSize(), MemoryConstants::pageSize64k);
@@ -85,6 +85,19 @@ CommandContainer::ErrorCode CommandContainer::initialize(Device *device, Allocat
commandStream->replaceGraphicsAllocation(cmdBufferAllocation); commandStream->replaceGraphicsAllocation(cmdBufferAllocation);
if (createSecondaryCmdBufferInHostMem) {
this->useSecondaryCommandStream = true;
auto cmdBufferAllocationHost = this->obtainNextCommandBufferAllocation(true);
if (!cmdBufferAllocationHost) {
return ErrorCode::OUT_OF_DEVICE_MEMORY;
}
secondaryCommandStreamForImmediateCmdList = std::make_unique<LinearStream>(cmdBufferAllocationHost->getUnderlyingBuffer(),
alignedSize - cmdBufferReservedSize, this, gfxCoreHelper.getBatchBufferEndSize());
secondaryCommandStreamForImmediateCmdList->replaceGraphicsAllocation(cmdBufferAllocationHost);
cmdBufferAllocations.push_back(cmdBufferAllocationHost);
}
if (!getFlushTaskUsedForImmediate()) { if (!getFlushTaskUsedForImmediate()) {
addToResidencyContainer(cmdBufferAllocation); addToResidencyContainer(cmdBufferAllocation);
} }
@@ -139,6 +152,14 @@ void CommandContainer::addToResidencyContainer(GraphicsAllocation *alloc) {
this->residencyContainer.push_back(alloc); this->residencyContainer.push_back(alloc);
} }
bool CommandContainer::swapStreams() {
if (this->useSecondaryCommandStream) {
this->commandStream.swap(this->secondaryCommandStreamForImmediateCmdList);
return true;
}
return false;
}
void CommandContainer::removeDuplicatesFromResidencyContainer() { void CommandContainer::removeDuplicatesFromResidencyContainer() {
std::sort(this->residencyContainer.begin(), this->residencyContainer.end()); std::sort(this->residencyContainer.begin(), this->residencyContainer.end());
this->residencyContainer.erase(std::unique(this->residencyContainer.begin(), this->residencyContainer.end()), this->residencyContainer.end()); this->residencyContainer.erase(std::unique(this->residencyContainer.begin(), this->residencyContainer.end()), this->residencyContainer.end());
@@ -275,14 +296,18 @@ void CommandContainer::handleCmdBufferAllocations(size_t startIndex) {
} }
GraphicsAllocation *CommandContainer::obtainNextCommandBufferAllocation() { GraphicsAllocation *CommandContainer::obtainNextCommandBufferAllocation() {
return this->obtainNextCommandBufferAllocation(false);
}
GraphicsAllocation *CommandContainer::obtainNextCommandBufferAllocation(bool forceHostMemory) {
forceHostMemory &= this->useSecondaryCommandStream;
GraphicsAllocation *cmdBufferAllocation = nullptr; GraphicsAllocation *cmdBufferAllocation = nullptr;
if (this->reusableAllocationList) { if (this->reusableAllocationList) {
size_t alignedSize = alignUp<size_t>(this->getTotalCmdBufferSize(), MemoryConstants::pageSize64k); size_t alignedSize = alignUp<size_t>(this->getTotalCmdBufferSize(), MemoryConstants::pageSize64k);
cmdBufferAllocation = this->reusableAllocationList->detachAllocation(alignedSize, nullptr, nullptr, AllocationType::COMMAND_BUFFER).release(); cmdBufferAllocation = this->reusableAllocationList->detachAllocation(alignedSize, nullptr, forceHostMemory, nullptr, AllocationType::COMMAND_BUFFER).release();
} }
if (!cmdBufferAllocation) { if (!cmdBufferAllocation) {
cmdBufferAllocation = this->allocateCommandBuffer(); cmdBufferAllocation = this->allocateCommandBuffer(forceHostMemory);
} }
return cmdBufferAllocation; return cmdBufferAllocation;
@@ -381,10 +406,15 @@ void CommandContainer::reserveSpaceForDispatch(HeapReserveArguments &sshReserveA
} }
GraphicsAllocation *CommandContainer::reuseExistingCmdBuffer() { GraphicsAllocation *CommandContainer::reuseExistingCmdBuffer() {
return this->reuseExistingCmdBuffer(false);
}
GraphicsAllocation *CommandContainer::reuseExistingCmdBuffer(bool forceHostMemory) {
forceHostMemory &= this->useSecondaryCommandStream;
size_t alignedSize = alignUp<size_t>(this->getTotalCmdBufferSize(), MemoryConstants::pageSize64k); size_t alignedSize = alignUp<size_t>(this->getTotalCmdBufferSize(), MemoryConstants::pageSize64k);
auto cmdBufferAllocation = this->immediateReusableAllocationList->detachAllocation(alignedSize, nullptr, this->immediateCmdListCsr, AllocationType::COMMAND_BUFFER).release(); auto cmdBufferAllocation = this->immediateReusableAllocationList->detachAllocation(alignedSize, nullptr, forceHostMemory, this->immediateCmdListCsr, AllocationType::COMMAND_BUFFER).release();
if (!cmdBufferAllocation) { if (!cmdBufferAllocation) {
this->reusableAllocationList->detachAllocation(alignedSize, nullptr, this->immediateCmdListCsr, AllocationType::COMMAND_BUFFER).release(); this->reusableAllocationList->detachAllocation(alignedSize, nullptr, forceHostMemory, this->immediateCmdListCsr, AllocationType::COMMAND_BUFFER).release();
} }
if (cmdBufferAllocation) { if (cmdBufferAllocation) {
@@ -409,6 +439,10 @@ void CommandContainer::setCmdBuffer(GraphicsAllocation *cmdBuffer) {
} }
GraphicsAllocation *CommandContainer::allocateCommandBuffer() { GraphicsAllocation *CommandContainer::allocateCommandBuffer() {
return this->allocateCommandBuffer(false);
}
GraphicsAllocation *CommandContainer::allocateCommandBuffer(bool forceHostMemory) {
size_t alignedSize = alignUp<size_t>(this->getTotalCmdBufferSize(), MemoryConstants::pageSize64k); size_t alignedSize = alignUp<size_t>(this->getTotalCmdBufferSize(), MemoryConstants::pageSize64k);
AllocationProperties properties{device->getRootDeviceIndex(), AllocationProperties properties{device->getRootDeviceIndex(),
true /* allocateMemory*/, true /* allocateMemory*/,
@@ -417,6 +451,7 @@ GraphicsAllocation *CommandContainer::allocateCommandBuffer() {
(device->getNumGenericSubDevices() > 1u) /* multiOsContextCapable */, (device->getNumGenericSubDevices() > 1u) /* multiOsContextCapable */,
false, false,
device->getDeviceBitfield()}; device->getDeviceBitfield()};
properties.flags.forceSystemMemory = forceHostMemory && this->useSecondaryCommandStream;
return device->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties); return device->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
} }

View File

@@ -97,7 +97,7 @@ class CommandContainer : public NonCopyableOrMovableClass {
void *getHeapSpaceAllowGrow(HeapType heapType, size_t size); void *getHeapSpaceAllowGrow(HeapType heapType, size_t size);
ErrorCode initialize(Device *device, AllocationsList *reusableAllocationList, bool requireHeaps); ErrorCode initialize(Device *device, AllocationsList *reusableAllocationList, bool requireHeaps, bool createSecondaryCmdBufferInHostMem);
void prepareBindfulSsh(); void prepareBindfulSsh();
@@ -111,6 +111,9 @@ class CommandContainer : public NonCopyableOrMovableClass {
void handleCmdBufferAllocations(size_t startIndex); void handleCmdBufferAllocations(size_t startIndex);
GraphicsAllocation *obtainNextCommandBufferAllocation(); GraphicsAllocation *obtainNextCommandBufferAllocation();
GraphicsAllocation *obtainNextCommandBufferAllocation(bool forceHostMemory);
bool swapStreams();
void reset(); void reset();
@@ -139,7 +142,9 @@ class CommandContainer : public NonCopyableOrMovableClass {
void reserveSpaceForDispatch(HeapReserveArguments &sshReserveArg, HeapReserveArguments &dshReserveArg, bool getDsh); void reserveSpaceForDispatch(HeapReserveArguments &sshReserveArg, HeapReserveArguments &dshReserveArg, bool getDsh);
GraphicsAllocation *reuseExistingCmdBuffer(); GraphicsAllocation *reuseExistingCmdBuffer();
GraphicsAllocation *reuseExistingCmdBuffer(bool forceHostMemory);
GraphicsAllocation *allocateCommandBuffer(); GraphicsAllocation *allocateCommandBuffer();
GraphicsAllocation *allocateCommandBuffer(bool forceHostMemory);
void setCmdBuffer(GraphicsAllocation *cmdBuffer); void setCmdBuffer(GraphicsAllocation *cmdBuffer);
void addCurrentCommandBufferToReusableAllocationList(); void addCurrentCommandBufferToReusableAllocationList();
@@ -177,6 +182,8 @@ class CommandContainer : public NonCopyableOrMovableClass {
std::unique_ptr<HeapHelper> heapHelper; std::unique_ptr<HeapHelper> heapHelper;
std::unique_ptr<LinearStream> commandStream; std::unique_ptr<LinearStream> commandStream;
std::unique_ptr<LinearStream> secondaryCommandStreamForImmediateCmdList;
bool useSecondaryCommandStream = false;
uint64_t instructionHeapBaseAddress = 0u; uint64_t instructionHeapBaseAddress = 0u;
uint64_t indirectObjectHeapBaseAddress = 0u; uint64_t indirectObjectHeapBaseAddress = 0u;

View File

@@ -328,6 +328,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionOverrideComputeSupport, -1, "Ove
DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionDisableCacheFlush, -1, "-1: driver default, 0: additional cache flush is present 1: disable dispatching cache flush commands") DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionDisableCacheFlush, -1, "-1: driver default, 0: additional cache flush is present 1: disable dispatching cache flush commands")
DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionNewResourceTlbFlush, -1, "-1: driver default - flush when new resource is bound, 0: disabled, 1: enabled") DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionNewResourceTlbFlush, -1, "-1: driver default - flush when new resource is bound, 0: disabled, 1: enabled")
DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionDisableMonitorFence, -1, "Disable dispatching monitor fence commands") DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionDisableMonitorFence, -1, "Disable dispatching monitor fence commands")
DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionFlatRingBuffer, 0, "-1: default, 0: disable, 1: enable, Copies task command buffer directly into ring, implemented for immediate command lists only")
DECLARE_DEBUG_VARIABLE(int32_t, EnableDirectSubmissionController, -1, "Enable direct submission terminating after given timeout, -1: default, 0: disabled, 1: enabled") DECLARE_DEBUG_VARIABLE(int32_t, EnableDirectSubmissionController, -1, "Enable direct submission terminating after given timeout, -1: default, 0: disabled, 1: enabled")
DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionControllerTimeout, -1, "Set direct submission controller timeout, -1: default 5000 us, >=0: timeout in us") DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionControllerTimeout, -1, "Set direct submission controller timeout, -1: default 5000 us, >=0: timeout in us")
DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionControllerDivisor, -1, "Set direct submission controller timeout divider, -1: default 1, >0: divider value") DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionControllerDivisor, -1, "Set direct submission controller timeout divider, -1: default 1, >0: divider value")

View File

@@ -113,6 +113,7 @@ class DirectSubmissionHw {
virtual uint64_t updateTagValue() = 0; virtual uint64_t updateTagValue() = 0;
virtual void getTagAddressValue(TagData &tagData) = 0; virtual void getTagAddressValue(TagData &tagData) = 0;
void unblockGpu(); void unblockGpu();
bool copyCommandBufferIntoRing(BatchBuffer &batchBuffer);
void cpuCachelineFlush(void *ptr, size_t size); void cpuCachelineFlush(void *ptr, size_t size);

View File

@@ -704,13 +704,22 @@ void *DirectSubmissionHw<GfxFamily, Dispatcher>::dispatchWorkloadSection(BatchBu
relaxedOrderingReturnPtrCmdStream.replaceBuffer(relaxedOrderingReturnPtrCmds, RelaxedOrderingHelper::getSizeReturnPtrRegs<GfxFamily>()); relaxedOrderingReturnPtrCmdStream.replaceBuffer(relaxedOrderingReturnPtrCmds, RelaxedOrderingHelper::getSizeReturnPtrRegs<GfxFamily>());
} }
dispatchStartSection(commandStreamAddress); auto copyCmdBuffer = this->copyCommandBufferIntoRing(batchBuffer);
if (copyCmdBuffer) {
auto cmdStreamTaskPtr = ptrOffset(batchBuffer.stream->getCpuBase(), batchBuffer.startOffset);
auto sizeToCopy = ptrDiff(returnCmd, cmdStreamTaskPtr);
auto ringPtr = ringCommandStream.getSpace(sizeToCopy);
memcpy(ringPtr, cmdStreamTaskPtr, sizeToCopy);
} else {
dispatchStartSection(commandStreamAddress);
}
uint64_t returnGpuPointer = ringCommandStream.getCurrentGpuAddressPosition(); uint64_t returnGpuPointer = ringCommandStream.getCurrentGpuAddressPosition();
if (this->relaxedOrderingEnabled && batchBuffer.hasRelaxedOrderingDependencies) { if (this->relaxedOrderingEnabled && batchBuffer.hasRelaxedOrderingDependencies) {
dispatchRelaxedOrderingReturnPtrRegs(relaxedOrderingReturnPtrCmdStream, returnGpuPointer); dispatchRelaxedOrderingReturnPtrRegs(relaxedOrderingReturnPtrCmdStream, returnGpuPointer);
} else { } else if (!copyCmdBuffer) {
setReturnAddress(returnCmd, returnGpuPointer); setReturnAddress(returnCmd, returnGpuPointer);
} }
} else if (workloadMode == 1) { } else if (workloadMode == 1) {
@@ -880,6 +889,21 @@ void DirectSubmissionHw<GfxFamily, Dispatcher>::dispatchTaskStoreSection(uint64_
memcpy_s(dst, RelaxedOrderingHelper::getSizeTaskStoreSection<GfxFamily>(), preinitializedTaskStoreSection.get(), RelaxedOrderingHelper::getSizeTaskStoreSection<GfxFamily>()); memcpy_s(dst, RelaxedOrderingHelper::getSizeTaskStoreSection<GfxFamily>(), preinitializedTaskStoreSection.get(), RelaxedOrderingHelper::getSizeTaskStoreSection<GfxFamily>());
} }
template <typename GfxFamily, typename Dispatcher>
bool DirectSubmissionHw<GfxFamily, Dispatcher>::copyCommandBufferIntoRing(BatchBuffer &batchBuffer) {
auto ret = this->osContext.getNumSupportedDevices() == 1u &&
!batchBuffer.chainedBatchBuffer &&
batchBuffer.commandBufferAllocation &&
MemoryPoolHelper::isSystemMemoryPool(batchBuffer.commandBufferAllocation->getMemoryPool()) &&
!batchBuffer.hasRelaxedOrderingDependencies;
if (DebugManager.flags.DirectSubmissionFlatRingBuffer.get() != -1) {
ret &= !!DebugManager.flags.DirectSubmissionFlatRingBuffer.get();
}
return ret;
}
template <typename GfxFamily, typename Dispatcher> template <typename GfxFamily, typename Dispatcher>
bool DirectSubmissionHw<GfxFamily, Dispatcher>::dispatchCommandBuffer(BatchBuffer &batchBuffer, FlushStampTracker &flushStamp) { bool DirectSubmissionHw<GfxFamily, Dispatcher>::dispatchCommandBuffer(BatchBuffer &batchBuffer, FlushStampTracker &flushStamp) {
// for now workloads requiring cache coherency are not supported // for now workloads requiring cache coherency are not supported
@@ -894,6 +918,11 @@ bool DirectSubmissionHw<GfxFamily, Dispatcher>::dispatchCommandBuffer(BatchBuffe
bool relaxedOrderingSchedulerWillBeNeeded = (this->relaxedOrderingSchedulerRequired || batchBuffer.hasRelaxedOrderingDependencies); bool relaxedOrderingSchedulerWillBeNeeded = (this->relaxedOrderingSchedulerRequired || batchBuffer.hasRelaxedOrderingDependencies);
size_t dispatchSize = getSizeDispatch(relaxedOrderingSchedulerWillBeNeeded, batchBuffer.hasRelaxedOrderingDependencies); size_t dispatchSize = getSizeDispatch(relaxedOrderingSchedulerWillBeNeeded, batchBuffer.hasRelaxedOrderingDependencies);
if (this->copyCommandBufferIntoRing(batchBuffer)) {
dispatchSize += (batchBuffer.stream->getUsed() - batchBuffer.startOffset) - 2 * getSizeStartSection();
}
size_t cycleSize = getSizeSwitchRingBufferSection(); size_t cycleSize = getSizeSwitchRingBufferSection();
size_t requiredMinimalSize = dispatchSize + cycleSize + getSizeEnd(relaxedOrderingSchedulerWillBeNeeded); size_t requiredMinimalSize = dispatchSize + cycleSize + getSizeEnd(relaxedOrderingSchedulerWillBeNeeded);
if (this->relaxedOrderingEnabled) { if (this->relaxedOrderingEnabled) {

View File

@@ -21,6 +21,7 @@ struct ReusableAllocationRequirements {
uint32_t contextId; uint32_t contextId;
uint32_t activeTileCount; uint32_t activeTileCount;
uint32_t tagOffset; uint32_t tagOffset;
bool forceSystemMemoryFlag;
}; };
bool checkTagAddressReady(ReusableAllocationRequirements *requirements, NEO::GraphicsAllocation *gfxAllocation) { bool checkTagAddressReady(ReusableAllocationRequirements *requirements, NEO::GraphicsAllocation *gfxAllocation) {
@@ -42,6 +43,10 @@ AllocationsList::AllocationsList(AllocationUsage allocationUsage)
: allocationUsage(allocationUsage) {} : allocationUsage(allocationUsage) {}
std::unique_ptr<GraphicsAllocation> AllocationsList::detachAllocation(size_t requiredMinimalSize, const void *requiredPtr, CommandStreamReceiver *commandStreamReceiver, AllocationType allocationType) { std::unique_ptr<GraphicsAllocation> AllocationsList::detachAllocation(size_t requiredMinimalSize, const void *requiredPtr, CommandStreamReceiver *commandStreamReceiver, AllocationType allocationType) {
return this->detachAllocation(requiredMinimalSize, requiredPtr, false, commandStreamReceiver, allocationType);
}
std::unique_ptr<GraphicsAllocation> AllocationsList::detachAllocation(size_t requiredMinimalSize, const void *requiredPtr, bool forceSystemMemoryFlag, CommandStreamReceiver *commandStreamReceiver, AllocationType allocationType) {
ReusableAllocationRequirements req; ReusableAllocationRequirements req;
req.requiredMinimalSize = requiredMinimalSize; req.requiredMinimalSize = requiredMinimalSize;
req.csrTagAddress = (commandStreamReceiver == nullptr) ? nullptr : commandStreamReceiver->getTagAddress(); req.csrTagAddress = (commandStreamReceiver == nullptr) ? nullptr : commandStreamReceiver->getTagAddress();
@@ -50,6 +55,7 @@ std::unique_ptr<GraphicsAllocation> AllocationsList::detachAllocation(size_t req
req.requiredPtr = requiredPtr; req.requiredPtr = requiredPtr;
req.activeTileCount = (commandStreamReceiver == nullptr) ? 1u : commandStreamReceiver->getActivePartitions(); req.activeTileCount = (commandStreamReceiver == nullptr) ? 1u : commandStreamReceiver->getActivePartitions();
req.tagOffset = (commandStreamReceiver == nullptr) ? 0u : commandStreamReceiver->getPostSyncWriteOffset(); req.tagOffset = (commandStreamReceiver == nullptr) ? 0u : commandStreamReceiver->getPostSyncWriteOffset();
req.forceSystemMemoryFlag = forceSystemMemoryFlag;
GraphicsAllocation *a = nullptr; GraphicsAllocation *a = nullptr;
GraphicsAllocation *retAlloc = processLocked<AllocationsList, &AllocationsList::detachAllocationImpl>(a, static_cast<void *>(&req)); GraphicsAllocation *retAlloc = processLocked<AllocationsList, &AllocationsList::detachAllocationImpl>(a, static_cast<void *>(&req));
return std::unique_ptr<GraphicsAllocation>(retAlloc); return std::unique_ptr<GraphicsAllocation>(retAlloc);
@@ -60,7 +66,8 @@ GraphicsAllocation *AllocationsList::detachAllocationImpl(GraphicsAllocation *,
auto *curr = head; auto *curr = head;
while (curr != nullptr) { while (curr != nullptr) {
if ((req->allocationType == curr->getAllocationType()) && if ((req->allocationType == curr->getAllocationType()) &&
(curr->getUnderlyingBufferSize() >= req->requiredMinimalSize)) { (curr->getUnderlyingBufferSize() >= req->requiredMinimalSize) &&
(curr->storageInfo.systemMemoryForced == req->forceSystemMemoryFlag)) {
if (req->csrTagAddress == nullptr) { if (req->csrTagAddress == nullptr) {
return removeOneImpl(curr, nullptr); return removeOneImpl(curr, nullptr);
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018-2022 Intel Corporation * Copyright (C) 2018-2023 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -21,6 +21,7 @@ class AllocationsList : public IDList<GraphicsAllocation, true, true> {
AllocationsList(AllocationUsage allocationUsage); AllocationsList(AllocationUsage allocationUsage);
std::unique_ptr<GraphicsAllocation> detachAllocation(size_t requiredMinimalSize, const void *requiredPtr, CommandStreamReceiver *commandStreamReceiver, AllocationType allocationType); std::unique_ptr<GraphicsAllocation> detachAllocation(size_t requiredMinimalSize, const void *requiredPtr, CommandStreamReceiver *commandStreamReceiver, AllocationType allocationType);
std::unique_ptr<GraphicsAllocation> detachAllocation(size_t requiredMinimalSize, const void *requiredPtr, bool forceSystemMemoryFlag, CommandStreamReceiver *commandStreamReceiver, AllocationType allocationType);
void freeAllGraphicsAllocations(Device *neoDevice); void freeAllGraphicsAllocations(Device *neoDevice);
private: private:

View File

@@ -31,6 +31,7 @@ struct StorageInfo {
bool isLockable = false; bool isLockable = false;
bool localOnlyRequired = false; bool localOnlyRequired = false;
bool systemMemoryPlacement = true; bool systemMemoryPlacement = true;
bool systemMemoryForced = false;
char resourceTag[AppResourceDefines::maxStrLen + 1] = ""; char resourceTag[AppResourceDefines::maxStrLen + 1] = "";
uint32_t getMemoryBanks() const { return static_cast<uint32_t>(memoryBanks.to_ulong()); } uint32_t getMemoryBanks() const { return static_cast<uint32_t>(memoryBanks.to_ulong()); }
uint32_t getTotalBanksCnt() const; uint32_t getTotalBanksCnt() const;

View File

@@ -530,6 +530,7 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
allocationData.flags.isUSMHostAllocation = properties.flags.isUSMHostAllocation; allocationData.flags.isUSMHostAllocation = properties.flags.isUSMHostAllocation;
allocationData.storageInfo.systemMemoryPlacement = allocationData.flags.useSystemMemory; allocationData.storageInfo.systemMemoryPlacement = allocationData.flags.useSystemMemory;
allocationData.storageInfo.systemMemoryForced = properties.flags.forceSystemMemory;
return true; return true;
} }

View File

@@ -2003,6 +2003,7 @@ DrmAllocation *DrmMemoryManager::createAllocWithAlignment(const AllocationData &
bo.release(); bo.release();
allocation->isShareableHostMemory = true; allocation->isShareableHostMemory = true;
allocation->storageInfo = allocationData.storageInfo;
return allocation.release(); return allocation.release();
} else { } else {
return createAllocWithAlignmentFromUserptr(allocationData, size, alignment, alignedSize, gpuAddress); return createAllocWithAlignmentFromUserptr(allocationData, size, alignment, alignedSize, gpuAddress);

View File

@@ -18,6 +18,7 @@ struct MockDirectSubmissionHw : public DirectSubmissionHw<GfxFamily, Dispatcher>
using BaseClass::activeTiles; using BaseClass::activeTiles;
using BaseClass::allocateResources; using BaseClass::allocateResources;
using BaseClass::completionFenceAllocation; using BaseClass::completionFenceAllocation;
using BaseClass::copyCommandBufferIntoRing;
using BaseClass::cpuCachelineFlush; using BaseClass::cpuCachelineFlush;
using BaseClass::currentQueueWorkCount; using BaseClass::currentQueueWorkCount;
using BaseClass::currentRelaxedOrderingQueueSize; using BaseClass::currentRelaxedOrderingQueueSize;

View File

@@ -451,6 +451,7 @@ EnableRingSwitchTagUpdateWa = -1
PlaformSupportEvictIfNecessaryFlag = -1 PlaformSupportEvictIfNecessaryFlag = -1
DirectSubmissionReadBackCommandBuffer = -1 DirectSubmissionReadBackCommandBuffer = -1
DirectSubmissionReadBackRingBuffer = -1 DirectSubmissionReadBackRingBuffer = -1
DirectSubmissionFlatRingBuffer = 0
ReadBackCommandBufferAllocation = -1 ReadBackCommandBufferAllocation = -1
PrintImageBlitBlockCopyCmdDetails = 0 PrintImageBlitBlockCopyCmdDetails = 0
LogGdiCalls = 0 LogGdiCalls = 0

View File

@@ -34,6 +34,7 @@ class MyMockCommandContainer : public CommandContainer {
using CommandContainer::dirtyHeaps; using CommandContainer::dirtyHeaps;
using CommandContainer::getTotalCmdBufferSize; using CommandContainer::getTotalCmdBufferSize;
using CommandContainer::immediateReusableAllocationList; using CommandContainer::immediateReusableAllocationList;
using CommandContainer::secondaryCommandStreamForImmediateCmdList;
}; };
struct CommandContainerHeapStateTests : public ::testing::Test { struct CommandContainerHeapStateTests : public ::testing::Test {
@@ -87,7 +88,7 @@ TEST_F(CommandContainerHeapStateTests, givenDirtyHeapsWhenSettingStateForSingleH
TEST_F(CommandContainerTest, givenCmdContainerWhenCreatingCommandBufferThenCorrectAllocationTypeIsSet) { TEST_F(CommandContainerTest, givenCmdContainerWhenCreatingCommandBufferThenCorrectAllocationTypeIsSet) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
ASSERT_NE(0u, cmdContainer.getCmdBufferAllocations().size()); ASSERT_NE(0u, cmdContainer.getCmdBufferAllocations().size());
EXPECT_EQ(AllocationType::COMMAND_BUFFER, cmdContainer.getCmdBufferAllocations()[0]->getAllocationType()); EXPECT_EQ(AllocationType::COMMAND_BUFFER, cmdContainer.getCmdBufferAllocations()[0]->getAllocationType());
@@ -98,9 +99,37 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenCreatingCommandBufferThenCorre
EXPECT_EQ(AllocationType::COMMAND_BUFFER, cmdContainer.getCmdBufferAllocations()[1]->getAllocationType()); EXPECT_EQ(AllocationType::COMMAND_BUFFER, cmdContainer.getCmdBufferAllocations()[1]->getAllocationType());
} }
TEST_F(CommandContainerTest, givenCreateSecondaryCmdBufferInHostMemWhenInitializeThenCreateAdditionalLinearStream) {
MyMockCommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true, true);
EXPECT_NE(cmdContainer.secondaryCommandStreamForImmediateCmdList.get(), nullptr);
auto secondaryCmdStream = cmdContainer.secondaryCommandStreamForImmediateCmdList.get();
auto cmdStream = cmdContainer.getCommandStream();
EXPECT_TRUE(cmdContainer.swapStreams());
EXPECT_EQ(cmdContainer.getCommandStream(), secondaryCmdStream);
EXPECT_EQ(cmdContainer.secondaryCommandStreamForImmediateCmdList.get(), cmdStream);
}
TEST_F(CommandContainerTest, whenInitializeThenNotCreateAdditionalLinearStream) {
MyMockCommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true, false);
EXPECT_EQ(cmdContainer.secondaryCommandStreamForImmediateCmdList.get(), nullptr);
auto cmdStream = cmdContainer.getCommandStream();
EXPECT_FALSE(cmdContainer.swapStreams());
EXPECT_EQ(cmdContainer.getCommandStream(), cmdStream);
}
TEST_F(CommandContainerTest, givenCmdContainerWhenAllocatingHeapsThenSetCorrectAllocationTypes) { TEST_F(CommandContainerTest, givenCmdContainerWhenAllocatingHeapsThenSetCorrectAllocationTypes) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
for (uint32_t i = 0; i < HeapType::NUM_TYPES; i++) { for (uint32_t i = 0; i < HeapType::NUM_TYPES; i++) {
HeapType heapType = static_cast<HeapType>(i); HeapType heapType = static_cast<HeapType>(i);
@@ -121,7 +150,7 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenAllocatingHeapsThenSetCorrectA
TEST_F(CommandContainerTest, givenCommandContainerWhenInitializeThenEverythingIsInitialized) { TEST_F(CommandContainerTest, givenCommandContainerWhenInitializeThenEverythingIsInitialized) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
auto status = cmdContainer.initialize(pDevice, nullptr, true); auto status = cmdContainer.initialize(pDevice, nullptr, true, false);
EXPECT_EQ(CommandContainer::ErrorCode::SUCCESS, status); EXPECT_EQ(CommandContainer::ErrorCode::SUCCESS, status);
EXPECT_EQ(pDevice, cmdContainer.getDevice()); EXPECT_EQ(pDevice, cmdContainer.getDevice());
@@ -151,7 +180,7 @@ TEST_F(CommandContainerTest, givenCommandContainerWhenInitializeThenEverythingIs
TEST_F(CommandContainerTest, givenCommandContainerWhenHeapNotRequiredThenHeapIsNotInitialized) { TEST_F(CommandContainerTest, givenCommandContainerWhenHeapNotRequiredThenHeapIsNotInitialized) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
auto status = cmdContainer.initialize(pDevice, nullptr, false); auto status = cmdContainer.initialize(pDevice, nullptr, false, false);
EXPECT_EQ(CommandContainer::ErrorCode::SUCCESS, status); EXPECT_EQ(CommandContainer::ErrorCode::SUCCESS, status);
EXPECT_EQ(pDevice, cmdContainer.getDevice()); EXPECT_EQ(pDevice, cmdContainer.getDevice());
@@ -188,7 +217,7 @@ TEST_F(CommandContainerTest, givenEnabledLocalMemoryAndIsaInSystemMemoryWhenCmdC
auto instructionHeapBaseAddress = device->getMemoryManager()->getInternalHeapBaseAddress(0, false); auto instructionHeapBaseAddress = device->getMemoryManager()->getInternalHeapBaseAddress(0, false);
CommandContainer cmdContainer; CommandContainer cmdContainer;
auto status = cmdContainer.initialize(device.get(), nullptr, true); auto status = cmdContainer.initialize(device.get(), nullptr, true, false);
EXPECT_EQ(CommandContainer::ErrorCode::SUCCESS, status); EXPECT_EQ(CommandContainer::ErrorCode::SUCCESS, status);
EXPECT_EQ(instructionHeapBaseAddress, cmdContainer.getInstructionHeapBaseAddress()); EXPECT_EQ(instructionHeapBaseAddress, cmdContainer.getInstructionHeapBaseAddress());
@@ -207,7 +236,7 @@ TEST_F(CommandContainerTest, givenForceDefaultHeapSizeWhenCmdContainerIsInitiali
auto device = std::unique_ptr<MockDevice>(Device::create<MockDevice>(executionEnvironment, 0u)); auto device = std::unique_ptr<MockDevice>(Device::create<MockDevice>(executionEnvironment, 0u));
CommandContainer cmdContainer; CommandContainer cmdContainer;
auto status = cmdContainer.initialize(device.get(), nullptr, true); auto status = cmdContainer.initialize(device.get(), nullptr, true, false);
EXPECT_EQ(CommandContainer::ErrorCode::SUCCESS, status); EXPECT_EQ(CommandContainer::ErrorCode::SUCCESS, status);
auto indirectHeap = cmdContainer.getIndirectHeap(IndirectHeap::Type::INDIRECT_OBJECT); auto indirectHeap = cmdContainer.getIndirectHeap(IndirectHeap::Type::INDIRECT_OBJECT);
@@ -217,14 +246,21 @@ TEST_F(CommandContainerTest, givenForceDefaultHeapSizeWhenCmdContainerIsInitiali
TEST_F(CommandContainerTest, givenCommandContainerDuringInitWhenAllocateGfxMemoryFailsThenErrorIsReturned) { TEST_F(CommandContainerTest, givenCommandContainerDuringInitWhenAllocateGfxMemoryFailsThenErrorIsReturned) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
pDevice->executionEnvironment->memoryManager.reset(new FailMemoryManager(0, *pDevice->executionEnvironment)); pDevice->executionEnvironment->memoryManager.reset(new FailMemoryManager(0, *pDevice->executionEnvironment));
auto status = cmdContainer.initialize(pDevice, nullptr, true); auto status = cmdContainer.initialize(pDevice, nullptr, true, false);
EXPECT_EQ(CommandContainer::ErrorCode::OUT_OF_DEVICE_MEMORY, status);
}
TEST_F(CommandContainerTest, givenCreateSecondaryCmdBufferInHostMemWhenAllocateSecondaryCmdStreamFailsDuringInitializeThenErrorIsReturned) {
CommandContainer cmdContainer;
static_cast<MockMemoryManager *>(pDevice->getMemoryManager())->maxSuccessAllocatedGraphicsMemoryIndex = 7;
auto status = cmdContainer.initialize(pDevice, nullptr, true, true);
EXPECT_EQ(CommandContainer::ErrorCode::OUT_OF_DEVICE_MEMORY, status); EXPECT_EQ(CommandContainer::ErrorCode::OUT_OF_DEVICE_MEMORY, status);
} }
TEST_F(CommandContainerTest, givenCmdContainerWithAllocsListWhenAllocateAndResetThenCmdBufferAllocIsReused) { TEST_F(CommandContainerTest, givenCmdContainerWithAllocsListWhenAllocateAndResetThenCmdBufferAllocIsReused) {
AllocationsList allocList; AllocationsList allocList;
auto cmdContainer = std::make_unique<CommandContainer>(); auto cmdContainer = std::make_unique<CommandContainer>();
cmdContainer->initialize(pDevice, &allocList, true); cmdContainer->initialize(pDevice, &allocList, true, false);
auto &cmdBufferAllocs = cmdContainer->getCmdBufferAllocations(); auto &cmdBufferAllocs = cmdContainer->getCmdBufferAllocations();
auto memoryManager = static_cast<MockMemoryManager *>(pDevice->getMemoryManager()); auto memoryManager = static_cast<MockMemoryManager *>(pDevice->getMemoryManager());
EXPECT_EQ(memoryManager->handleFenceCompletionCalled, 0u); EXPECT_EQ(memoryManager->handleFenceCompletionCalled, 0u);
@@ -261,7 +297,7 @@ TEST_F(CommandContainerTest, givenReusableAllocationsAndRemoveUserFenceInCmdlist
AllocationsList allocList; AllocationsList allocList;
auto cmdContainer = std::make_unique<CommandContainer>(); auto cmdContainer = std::make_unique<CommandContainer>();
cmdContainer->initialize(pDevice, &allocList, true); cmdContainer->initialize(pDevice, &allocList, true, false);
auto &cmdBufferAllocs = cmdContainer->getCmdBufferAllocations(); auto &cmdBufferAllocs = cmdContainer->getCmdBufferAllocations();
auto memoryManager = static_cast<MockMemoryManager *>(pDevice->getMemoryManager()); auto memoryManager = static_cast<MockMemoryManager *>(pDevice->getMemoryManager());
EXPECT_EQ(0u, memoryManager->handleFenceCompletionCalled); EXPECT_EQ(0u, memoryManager->handleFenceCompletionCalled);
@@ -283,7 +319,7 @@ TEST_F(CommandContainerTest, givenCommandContainerDuringInitWhenAllocateHeapMemo
CommandContainer cmdContainer; CommandContainer cmdContainer;
auto tempMemoryManager = pDevice->executionEnvironment->memoryManager.release(); auto tempMemoryManager = pDevice->executionEnvironment->memoryManager.release();
pDevice->executionEnvironment->memoryManager.reset(new FailMemoryManager(1, *pDevice->executionEnvironment)); pDevice->executionEnvironment->memoryManager.reset(new FailMemoryManager(1, *pDevice->executionEnvironment));
auto status = cmdContainer.initialize(pDevice, nullptr, true); auto status = cmdContainer.initialize(pDevice, nullptr, true, false);
EXPECT_EQ(CommandContainer::ErrorCode::OUT_OF_DEVICE_MEMORY, status); EXPECT_EQ(CommandContainer::ErrorCode::OUT_OF_DEVICE_MEMORY, status);
delete tempMemoryManager; delete tempMemoryManager;
} }
@@ -298,10 +334,10 @@ TEST_F(CommandContainerTest, givenCommandContainerWhenSettingIndirectHeapAllocat
TEST_F(CommandContainerTest, givenHeapAllocationsWhenDestroyCommandContainerThenHeapAllocationsAreReused) { TEST_F(CommandContainerTest, givenHeapAllocationsWhenDestroyCommandContainerThenHeapAllocationsAreReused) {
std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer); std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer);
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
auto heapAllocationsAddress = cmdContainer->getIndirectHeapAllocation(HeapType::SURFACE_STATE)->getUnderlyingBuffer(); auto heapAllocationsAddress = cmdContainer->getIndirectHeapAllocation(HeapType::SURFACE_STATE)->getUnderlyingBuffer();
cmdContainer.reset(new CommandContainer); cmdContainer.reset(new CommandContainer);
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
bool status = true; bool status = true;
for (uint32_t i = 0; i < HeapType::NUM_TYPES && !status; i++) { for (uint32_t i = 0; i < HeapType::NUM_TYPES && !status; i++) {
auto heapType = static_cast<HeapType>(i); auto heapType = static_cast<HeapType>(i);
@@ -316,7 +352,7 @@ TEST_F(CommandContainerTest, givenHeapAllocationsWhenDestroyCommandContainerThen
TEST_F(CommandContainerTest, givenCommandContainerWhenResetThenStateIsReset) { TEST_F(CommandContainerTest, givenCommandContainerWhenResetThenStateIsReset) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
LinearStream stream; LinearStream stream;
uint32_t usedSize = 1; uint32_t usedSize = 1;
cmdContainer.getCommandStream()->getSpace(usedSize); cmdContainer.getCommandStream()->getSpace(usedSize);
@@ -330,7 +366,7 @@ TEST_F(CommandContainerTest, givenCommandContainerWhenResetThenStateIsReset) {
TEST_F(CommandContainerTest, givenCommandContainerWhenWantToAddNullPtrToResidencyContainerThenNothingIsAdded) { TEST_F(CommandContainerTest, givenCommandContainerWhenWantToAddNullPtrToResidencyContainerThenNothingIsAdded) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
auto size = cmdContainer.getResidencyContainer().size(); auto size = cmdContainer.getResidencyContainer().size();
cmdContainer.addToResidencyContainer(nullptr); cmdContainer.addToResidencyContainer(nullptr);
EXPECT_EQ(cmdContainer.getResidencyContainer().size(), size); EXPECT_EQ(cmdContainer.getResidencyContainer().size(), size);
@@ -338,7 +374,7 @@ TEST_F(CommandContainerTest, givenCommandContainerWhenWantToAddNullPtrToResidenc
TEST_F(CommandContainerTest, givenCommandContainerWhenWantToAddAlreadyAddedAllocationAndDuplicatesRemovedThenExpectedSizeIsReturned) { TEST_F(CommandContainerTest, givenCommandContainerWhenWantToAddAlreadyAddedAllocationAndDuplicatesRemovedThenExpectedSizeIsReturned) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
MockGraphicsAllocation mockAllocation; MockGraphicsAllocation mockAllocation;
auto sizeBefore = cmdContainer.getResidencyContainer().size(); auto sizeBefore = cmdContainer.getResidencyContainer().size();
@@ -363,7 +399,7 @@ HWTEST_F(CommandContainerTest, givenCmdContainerWhenInitializeCalledThenSSHHeapH
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer); std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer);
cmdContainer->setReservedSshSize(4 * MemoryConstants::pageSize); cmdContainer->setReservedSshSize(4 * MemoryConstants::pageSize);
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
cmdContainer->setDirtyStateForAllHeaps(false); cmdContainer->setDirtyStateForAllHeaps(false);
auto heap = cmdContainer->getIndirectHeap(HeapType::SURFACE_STATE); auto heap = cmdContainer->getIndirectHeap(HeapType::SURFACE_STATE);
@@ -376,7 +412,7 @@ HWTEST_F(CommandContainerTest, givenNotEnoughSpaceInSSHWhenGettingHeapWithRequir
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer); std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer);
cmdContainer->setReservedSshSize(4 * MemoryConstants::pageSize); cmdContainer->setReservedSshSize(4 * MemoryConstants::pageSize);
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
cmdContainer->setDirtyStateForAllHeaps(false); cmdContainer->setDirtyStateForAllHeaps(false);
auto heap = cmdContainer->getIndirectHeap(HeapType::SURFACE_STATE); auto heap = cmdContainer->getIndirectHeap(HeapType::SURFACE_STATE);
@@ -391,7 +427,7 @@ HWTEST_F(CommandContainerTest, givenNotEnoughSpaceInSSHWhenGettingHeapWithRequir
TEST_F(CommandContainerTest, givenAvailableSpaceWhenGetHeapWithRequiredSizeAndAlignmentCalledThenExistingAllocationIsReturned) { TEST_F(CommandContainerTest, givenAvailableSpaceWhenGetHeapWithRequiredSizeAndAlignmentCalledThenExistingAllocationIsReturned) {
std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer); std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer);
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
cmdContainer->setDirtyStateForAllHeaps(false); cmdContainer->setDirtyStateForAllHeaps(false);
HeapType heapTypes[] = {HeapType::SURFACE_STATE, HeapType heapTypes[] = {HeapType::SURFACE_STATE,
HeapType::DYNAMIC_STATE}; HeapType::DYNAMIC_STATE};
@@ -426,7 +462,7 @@ TEST_F(CommandContainerTest, givenAvailableSpaceWhenGetHeapWithRequiredSizeAndAl
TEST_F(CommandContainerTest, givenUnalignedAvailableSpaceWhenGetHeapWithRequiredSizeAndAlignmentCalledThenHeapReturnedIsCorrectlyAligned) { TEST_F(CommandContainerTest, givenUnalignedAvailableSpaceWhenGetHeapWithRequiredSizeAndAlignmentCalledThenHeapReturnedIsCorrectlyAligned) {
std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer); std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer);
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
cmdContainer->setDirtyStateForAllHeaps(false); cmdContainer->setDirtyStateForAllHeaps(false);
auto heapAllocation = cmdContainer->getIndirectHeapAllocation(HeapType::SURFACE_STATE); auto heapAllocation = cmdContainer->getIndirectHeapAllocation(HeapType::SURFACE_STATE);
auto heap = cmdContainer->getIndirectHeap(HeapType::SURFACE_STATE); auto heap = cmdContainer->getIndirectHeap(HeapType::SURFACE_STATE);
@@ -450,7 +486,7 @@ TEST_F(CommandContainerTest, givenUnalignedAvailableSpaceWhenGetHeapWithRequired
TEST_F(CommandContainerTest, givenNoAlignmentAndAvailableSpaceWhenGetHeapWithRequiredSizeAndAlignmentCalledThenHeapReturnedIsNotAligned) { TEST_F(CommandContainerTest, givenNoAlignmentAndAvailableSpaceWhenGetHeapWithRequiredSizeAndAlignmentCalledThenHeapReturnedIsNotAligned) {
std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer); std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer);
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
cmdContainer->setDirtyStateForAllHeaps(false); cmdContainer->setDirtyStateForAllHeaps(false);
auto heapAllocation = cmdContainer->getIndirectHeapAllocation(HeapType::SURFACE_STATE); auto heapAllocation = cmdContainer->getIndirectHeapAllocation(HeapType::SURFACE_STATE);
auto heap = cmdContainer->getIndirectHeap(HeapType::SURFACE_STATE); auto heap = cmdContainer->getIndirectHeap(HeapType::SURFACE_STATE);
@@ -474,7 +510,7 @@ TEST_F(CommandContainerTest, givenNoAlignmentAndAvailableSpaceWhenGetHeapWithReq
TEST_F(CommandContainerTest, givenNotEnoughSpaceWhenGetHeapWithRequiredSizeAndAlignmentCalledThenNewAllocationIsReturned) { TEST_F(CommandContainerTest, givenNotEnoughSpaceWhenGetHeapWithRequiredSizeAndAlignmentCalledThenNewAllocationIsReturned) {
std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer); std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer);
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
cmdContainer->setDirtyStateForAllHeaps(false); cmdContainer->setDirtyStateForAllHeaps(false);
HeapType heapTypes[] = {HeapType::SURFACE_STATE, HeapType heapTypes[] = {HeapType::SURFACE_STATE,
HeapType::DYNAMIC_STATE}; HeapType::DYNAMIC_STATE};
@@ -512,7 +548,7 @@ TEST_F(CommandContainerTest, givenNotEnoughSpaceWhenGetHeapWithRequiredSizeAndAl
TEST_F(CommandContainerTest, givenNotEnoughSpaceWhenCreatedAlocationHaveDifferentBaseThenHeapIsDirty) { TEST_F(CommandContainerTest, givenNotEnoughSpaceWhenCreatedAlocationHaveDifferentBaseThenHeapIsDirty) {
std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer); std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer);
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
cmdContainer->setDirtyStateForAllHeaps(false); cmdContainer->setDirtyStateForAllHeaps(false);
HeapType type = HeapType::INDIRECT_OBJECT; HeapType type = HeapType::INDIRECT_OBJECT;
@@ -544,7 +580,7 @@ TEST_F(CommandContainerTest, givenNotEnoughSpaceWhenCreatedAlocationHaveDifferen
TEST_F(CommandContainerTest, whenAllocateNextCmdBufferIsCalledThenNewAllocationIsCreatedAndCommandStreamReplaced) { TEST_F(CommandContainerTest, whenAllocateNextCmdBufferIsCalledThenNewAllocationIsCreatedAndCommandStreamReplaced) {
std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer); std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer);
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
auto stream = cmdContainer->getCommandStream(); auto stream = cmdContainer->getCommandStream();
ASSERT_NE(nullptr, stream); ASSERT_NE(nullptr, stream);
@@ -572,7 +608,7 @@ TEST_F(CommandContainerTest, whenAllocateNextCmdBufferIsCalledThenNewAllocationI
TEST_F(CommandContainerTest, whenResettingCommandContainerThenStoredCmdBuffersAreFreedAndStreamIsReplacedWithInitialBuffer) { TEST_F(CommandContainerTest, whenResettingCommandContainerThenStoredCmdBuffersAreFreedAndStreamIsReplacedWithInitialBuffer) {
std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer); std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer);
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
cmdContainer->allocateNextCommandBuffer(); cmdContainer->allocateNextCommandBuffer();
cmdContainer->allocateNextCommandBuffer(); cmdContainer->allocateNextCommandBuffer();
@@ -618,7 +654,7 @@ TEST_P(CommandContainerHeaps, givenCommandContainerWhenGetAllowHeapGrowCalledThe
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
if (!pDevice->getHardwareInfo().capabilityTable.supportsImages && HeapType::DYNAMIC_STATE == heapType) { if (!pDevice->getHardwareInfo().capabilityTable.supportsImages && HeapType::DYNAMIC_STATE == heapType) {
EXPECT_EQ(cmdContainer.getIndirectHeap(heapType), nullptr); EXPECT_EQ(cmdContainer.getIndirectHeap(heapType), nullptr);
} else { } else {
@@ -636,7 +672,7 @@ TEST_P(CommandContainerHeaps, givenCommandContainerWhenGetingMoreThanAvailableSi
HeapType heapType = GetParam(); HeapType heapType = GetParam();
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
cmdContainer.setDirtyStateForAllHeaps(false); cmdContainer.setDirtyStateForAllHeaps(false);
auto heap = cmdContainer.getIndirectHeap(heapType); auto heap = cmdContainer.getIndirectHeap(heapType);
if (!pDevice->getHardwareInfo().capabilityTable.supportsImages && HeapType::DYNAMIC_STATE == heapType) { if (!pDevice->getHardwareInfo().capabilityTable.supportsImages && HeapType::DYNAMIC_STATE == heapType) {
@@ -671,10 +707,10 @@ TEST_P(CommandContainerHeaps, givenCommandContainerForDifferentRootDevicesThenHe
auto device1 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(executionEnvironment, 1u)); auto device1 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(executionEnvironment, 1u));
CommandContainer cmdContainer0; CommandContainer cmdContainer0;
cmdContainer0.initialize(device0.get(), nullptr, true); cmdContainer0.initialize(device0.get(), nullptr, true, false);
CommandContainer cmdContainer1; CommandContainer cmdContainer1;
cmdContainer1.initialize(device1.get(), nullptr, true); cmdContainer1.initialize(device1.get(), nullptr, true, false);
if (!pDevice->getHardwareInfo().capabilityTable.supportsImages && HeapType::DYNAMIC_STATE == heapType) { if (!pDevice->getHardwareInfo().capabilityTable.supportsImages && HeapType::DYNAMIC_STATE == heapType) {
EXPECT_EQ(cmdContainer0.getIndirectHeap(heapType), nullptr); EXPECT_EQ(cmdContainer0.getIndirectHeap(heapType), nullptr);
EXPECT_EQ(cmdContainer1.getIndirectHeap(heapType), nullptr); EXPECT_EQ(cmdContainer1.getIndirectHeap(heapType), nullptr);
@@ -701,13 +737,13 @@ TEST_F(CommandContainerHeaps, givenCommandContainerForDifferentRootDevicesThenCm
auto device1 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(executionEnvironment, 1u)); auto device1 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(executionEnvironment, 1u));
CommandContainer cmdContainer0; CommandContainer cmdContainer0;
cmdContainer0.initialize(device0.get(), nullptr, true); cmdContainer0.initialize(device0.get(), nullptr, true, false);
EXPECT_EQ(1u, cmdContainer0.getCmdBufferAllocations().size()); EXPECT_EQ(1u, cmdContainer0.getCmdBufferAllocations().size());
uint32_t cmdBufferAllocationIndex0 = cmdContainer0.getCmdBufferAllocations().front()->getRootDeviceIndex(); uint32_t cmdBufferAllocationIndex0 = cmdContainer0.getCmdBufferAllocations().front()->getRootDeviceIndex();
EXPECT_EQ(device0->getRootDeviceIndex(), cmdBufferAllocationIndex0); EXPECT_EQ(device0->getRootDeviceIndex(), cmdBufferAllocationIndex0);
CommandContainer cmdContainer1; CommandContainer cmdContainer1;
cmdContainer1.initialize(device1.get(), nullptr, true); cmdContainer1.initialize(device1.get(), nullptr, true, false);
EXPECT_EQ(1u, cmdContainer1.getCmdBufferAllocations().size()); EXPECT_EQ(1u, cmdContainer1.getCmdBufferAllocations().size());
uint32_t cmdBufferAllocationIndex1 = cmdContainer1.getCmdBufferAllocations().front()->getRootDeviceIndex(); uint32_t cmdBufferAllocationIndex1 = cmdContainer1.getCmdBufferAllocations().front()->getRootDeviceIndex();
EXPECT_EQ(device1->getRootDeviceIndex(), cmdBufferAllocationIndex1); EXPECT_EQ(device1->getRootDeviceIndex(), cmdBufferAllocationIndex1);
@@ -729,13 +765,13 @@ TEST_F(CommandContainerHeaps, givenCommandContainerForDifferentRootDevicesThenIn
auto &gfxCoreHelper1 = device1->getGfxCoreHelper(); auto &gfxCoreHelper1 = device1->getGfxCoreHelper();
CommandContainer cmdContainer0; CommandContainer cmdContainer0;
cmdContainer0.initialize(device0.get(), nullptr, true); cmdContainer0.initialize(device0.get(), nullptr, true, false);
bool useLocalMemory0 = !gfxCoreHelper0.useSystemMemoryPlacementForISA(device0->getHardwareInfo()); bool useLocalMemory0 = !gfxCoreHelper0.useSystemMemoryPlacementForISA(device0->getHardwareInfo());
uint64_t baseAddressHeapDevice0 = device0->getMemoryManager()->getInternalHeapBaseAddress(device0->getRootDeviceIndex(), useLocalMemory0); uint64_t baseAddressHeapDevice0 = device0->getMemoryManager()->getInternalHeapBaseAddress(device0->getRootDeviceIndex(), useLocalMemory0);
EXPECT_EQ(cmdContainer0.getInstructionHeapBaseAddress(), baseAddressHeapDevice0); EXPECT_EQ(cmdContainer0.getInstructionHeapBaseAddress(), baseAddressHeapDevice0);
CommandContainer cmdContainer1; CommandContainer cmdContainer1;
cmdContainer1.initialize(device1.get(), nullptr, true); cmdContainer1.initialize(device1.get(), nullptr, true, false);
bool useLocalMemory1 = !gfxCoreHelper1.useSystemMemoryPlacementForISA(device0->getHardwareInfo()); bool useLocalMemory1 = !gfxCoreHelper1.useSystemMemoryPlacementForISA(device0->getHardwareInfo());
uint64_t baseAddressHeapDevice1 = device1->getMemoryManager()->getInternalHeapBaseAddress(device1->getRootDeviceIndex(), useLocalMemory1); uint64_t baseAddressHeapDevice1 = device1->getMemoryManager()->getInternalHeapBaseAddress(device1->getRootDeviceIndex(), useLocalMemory1);
EXPECT_EQ(cmdContainer1.getInstructionHeapBaseAddress(), baseAddressHeapDevice1); EXPECT_EQ(cmdContainer1.getInstructionHeapBaseAddress(), baseAddressHeapDevice1);
@@ -746,7 +782,7 @@ TEST_F(CommandContainerTest, givenCommandContainerWhenDestructionThenNonHeapAllo
MockGraphicsAllocation alloc; MockGraphicsAllocation alloc;
size_t size = 0x1000; size_t size = 0x1000;
alloc.setSize(size); alloc.setSize(size);
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
cmdContainer->getDeallocationContainer().push_back(&alloc); cmdContainer->getDeallocationContainer().push_back(&alloc);
cmdContainer.reset(); cmdContainer.reset();
EXPECT_EQ(alloc.getUnderlyingBufferSize(), size); EXPECT_EQ(alloc.getUnderlyingBufferSize(), size);
@@ -754,7 +790,7 @@ TEST_F(CommandContainerTest, givenCommandContainerWhenDestructionThenNonHeapAllo
TEST_F(CommandContainerTest, givenContainerAllocatesNextCommandBufferWhenResetingContainerThenExpectFirstCommandBufferAllocationIsReused) { TEST_F(CommandContainerTest, givenContainerAllocatesNextCommandBufferWhenResetingContainerThenExpectFirstCommandBufferAllocationIsReused) {
auto cmdContainer = std::make_unique<CommandContainer>(); auto cmdContainer = std::make_unique<CommandContainer>();
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
auto stream = cmdContainer->getCommandStream(); auto stream = cmdContainer->getCommandStream();
ASSERT_NE(nullptr, stream); ASSERT_NE(nullptr, stream);
@@ -799,14 +835,14 @@ class MyLinearStreamMock : public LinearStream {
TEST_F(CommandContainerTest, givenCmdContainerWhenContainerIsInitializedThenStreamContainsContainerPtr) { TEST_F(CommandContainerTest, givenCmdContainerWhenContainerIsInitializedThenStreamContainsContainerPtr) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
EXPECT_EQ(reinterpret_cast<MyLinearStreamMock *>(cmdContainer.getCommandStream())->cmdContainer, &cmdContainer); EXPECT_EQ(reinterpret_cast<MyLinearStreamMock *>(cmdContainer.getCommandStream())->cmdContainer, &cmdContainer);
} }
TEST_F(CommandContainerTest, givenCmdContainerWhenContainerIsInitializedThenStreamSizeEqualAlignedTotalCmdBuffSizeDecreasedOfReservedSize) { TEST_F(CommandContainerTest, givenCmdContainerWhenContainerIsInitializedThenStreamSizeEqualAlignedTotalCmdBuffSizeDecreasedOfReservedSize) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
size_t alignedSize = alignUp<size_t>(CommandContainer::totalCmdBufferSize, MemoryConstants::pageSize64k); size_t alignedSize = alignUp<size_t>(CommandContainer::totalCmdBufferSize, MemoryConstants::pageSize64k);
EXPECT_EQ(cmdContainer.getCommandStream()->getMaxAvailableSpace(), alignedSize - CommandContainer::cmdBufferReservedSize); EXPECT_EQ(cmdContainer.getCommandStream()->getMaxAvailableSpace(), alignedSize - CommandContainer::cmdBufferReservedSize);
} }
@@ -816,21 +852,21 @@ TEST_F(CommandContainerTest, GivenCmdContainerAndDebugFlagWhenContainerIsInitial
DebugManager.flags.OverrideCmdListCmdBufferSizeInKb.set(0); DebugManager.flags.OverrideCmdListCmdBufferSizeInKb.set(0);
MyMockCommandContainer cmdContainer; MyMockCommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
size_t alignedSize = alignUp<size_t>(cmdContainer.getTotalCmdBufferSize(), MemoryConstants::pageSize64k); size_t alignedSize = alignUp<size_t>(cmdContainer.getTotalCmdBufferSize(), MemoryConstants::pageSize64k);
EXPECT_EQ(cmdContainer.getCommandStream()->getMaxAvailableSpace(), alignedSize - MyMockCommandContainer::cmdBufferReservedSize); EXPECT_EQ(cmdContainer.getCommandStream()->getMaxAvailableSpace(), alignedSize - MyMockCommandContainer::cmdBufferReservedSize);
auto newSizeInKB = 512; auto newSizeInKB = 512;
DebugManager.flags.OverrideCmdListCmdBufferSizeInKb.set(newSizeInKB); DebugManager.flags.OverrideCmdListCmdBufferSizeInKb.set(newSizeInKB);
MyMockCommandContainer cmdContainer2; MyMockCommandContainer cmdContainer2;
cmdContainer2.initialize(pDevice, nullptr, true); cmdContainer2.initialize(pDevice, nullptr, true, false);
alignedSize = alignUp<size_t>(cmdContainer.getTotalCmdBufferSize(), MemoryConstants::pageSize64k); alignedSize = alignUp<size_t>(cmdContainer.getTotalCmdBufferSize(), MemoryConstants::pageSize64k);
EXPECT_EQ(cmdContainer2.getCommandStream()->getMaxAvailableSpace(), alignedSize - MyMockCommandContainer::cmdBufferReservedSize); EXPECT_EQ(cmdContainer2.getCommandStream()->getMaxAvailableSpace(), alignedSize - MyMockCommandContainer::cmdBufferReservedSize);
} }
TEST_F(CommandContainerTest, givenCmdContainerWhenAlocatingNextCmdBufferThenStreamSizeEqualAlignedTotalCmdBuffSizeDecreasedOfReservedSize) { TEST_F(CommandContainerTest, givenCmdContainerWhenAlocatingNextCmdBufferThenStreamSizeEqualAlignedTotalCmdBuffSizeDecreasedOfReservedSize) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
cmdContainer.allocateNextCommandBuffer(); cmdContainer.allocateNextCommandBuffer();
size_t alignedSize = alignUp<size_t>(CommandContainer::totalCmdBufferSize, MemoryConstants::pageSize64k); size_t alignedSize = alignUp<size_t>(CommandContainer::totalCmdBufferSize, MemoryConstants::pageSize64k);
EXPECT_EQ(cmdContainer.getCommandStream()->getMaxAvailableSpace(), alignedSize - CommandContainer::cmdBufferReservedSize); EXPECT_EQ(cmdContainer.getCommandStream()->getMaxAvailableSpace(), alignedSize - CommandContainer::cmdBufferReservedSize);
@@ -838,7 +874,7 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenAlocatingNextCmdBufferThenStre
TEST_F(CommandContainerTest, givenCmdContainerWhenCloseAndAllocateNextCommandBufferCalledThenBBEndPlacedAtEndOfLinearStream) { TEST_F(CommandContainerTest, givenCmdContainerWhenCloseAndAllocateNextCommandBufferCalledThenBBEndPlacedAtEndOfLinearStream) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
auto &gfxCoreHelper = pDevice->getGfxCoreHelper(); auto &gfxCoreHelper = pDevice->getGfxCoreHelper();
auto ptr = cmdContainer.getCommandStream()->getSpace(0u); auto ptr = cmdContainer.getCommandStream()->getSpace(0u);
cmdContainer.closeAndAllocateNextCommandBuffer(); cmdContainer.closeAndAllocateNextCommandBuffer();
@@ -847,7 +883,7 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenCloseAndAllocateNextCommandBuf
TEST_F(CommandContainerTest, givenCmdContainerWhenCloseAndAllocateNextCommandBufferCalledThenNewCmdBufferAllocationCreated) { TEST_F(CommandContainerTest, givenCmdContainerWhenCloseAndAllocateNextCommandBufferCalledThenNewCmdBufferAllocationCreated) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
EXPECT_EQ(cmdContainer.getCmdBufferAllocations().size(), 1u); EXPECT_EQ(cmdContainer.getCmdBufferAllocations().size(), 1u);
cmdContainer.closeAndAllocateNextCommandBuffer(); cmdContainer.closeAndAllocateNextCommandBuffer();
EXPECT_EQ(cmdContainer.getCmdBufferAllocations().size(), 2u); EXPECT_EQ(cmdContainer.getCmdBufferAllocations().size(), 2u);
@@ -855,7 +891,7 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenCloseAndAllocateNextCommandBuf
TEST_F(CommandContainerTest, givenCmdContainerWhenSetCmdBufferThenCmdBufferSetCorrectly) { TEST_F(CommandContainerTest, givenCmdContainerWhenSetCmdBufferThenCmdBufferSetCorrectly) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
AllocationProperties properties{pDevice->getRootDeviceIndex(), AllocationProperties properties{pDevice->getRootDeviceIndex(),
true /* allocateMemory*/, true /* allocateMemory*/,
@@ -874,7 +910,7 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenSetCmdBufferThenCmdBufferSetCo
TEST_F(CommandContainerTest, givenCmdContainerWhenReuseExistingCmdBufferWithoutAnyAllocationInListThenReturnNullptr) { TEST_F(CommandContainerTest, givenCmdContainerWhenReuseExistingCmdBufferWithoutAnyAllocationInListThenReturnNullptr) {
auto cmdContainer = std::make_unique<MyMockCommandContainer>(); auto cmdContainer = std::make_unique<MyMockCommandContainer>();
AllocationsList allocList; AllocationsList allocList;
cmdContainer->initialize(pDevice, &allocList, false); cmdContainer->initialize(pDevice, &allocList, false, false);
auto csr = pDevice->getDefaultEngine().commandStreamReceiver; auto csr = pDevice->getDefaultEngine().commandStreamReceiver;
cmdContainer->setImmediateCmdListCsr(csr); cmdContainer->setImmediateCmdListCsr(csr);
cmdContainer->immediateReusableAllocationList = std::make_unique<NEO::AllocationsList>(); cmdContainer->immediateReusableAllocationList = std::make_unique<NEO::AllocationsList>();
@@ -891,7 +927,7 @@ HWTEST_F(CommandContainerTest, givenCmdContainerWhenReuseExistingCmdBufferWithAl
*csr.tagAddress = 0u; *csr.tagAddress = 0u;
AllocationsList allocList; AllocationsList allocList;
cmdContainer->initialize(pDevice, &allocList, false); cmdContainer->initialize(pDevice, &allocList, false, false);
cmdContainer->setImmediateCmdListCsr(&csr); cmdContainer->setImmediateCmdListCsr(&csr);
cmdContainer->immediateReusableAllocationList = std::make_unique<NEO::AllocationsList>(); cmdContainer->immediateReusableAllocationList = std::make_unique<NEO::AllocationsList>();
@@ -912,7 +948,7 @@ HWTEST_F(CommandContainerTest, givenCmdContainerWhenReuseExistingCmdBufferWithAl
*csr.tagAddress = 10u; *csr.tagAddress = 10u;
AllocationsList allocList; AllocationsList allocList;
cmdContainer->initialize(pDevice, &allocList, false); cmdContainer->initialize(pDevice, &allocList, false, false);
cmdContainer->setImmediateCmdListCsr(&csr); cmdContainer->setImmediateCmdListCsr(&csr);
cmdContainer->immediateReusableAllocationList = std::make_unique<NEO::AllocationsList>(); cmdContainer->immediateReusableAllocationList = std::make_unique<NEO::AllocationsList>();
@@ -929,7 +965,7 @@ HWTEST_F(CommandContainerTest, givenCmdContainerWhenReuseExistingCmdBufferWithAl
TEST_F(CommandContainerTest, GivenCmdContainerWhenContainerIsInitializedThenSurfaceStateIndirectHeapSizeIsCorrect) { TEST_F(CommandContainerTest, GivenCmdContainerWhenContainerIsInitializedThenSurfaceStateIndirectHeapSizeIsCorrect) {
MyMockCommandContainer cmdContainer; MyMockCommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
auto size = cmdContainer.allocationIndirectHeaps[IndirectHeap::Type::SURFACE_STATE]->getUnderlyingBufferSize(); auto size = cmdContainer.allocationIndirectHeaps[IndirectHeap::Type::SURFACE_STATE]->getUnderlyingBufferSize();
constexpr size_t expectedHeapSize = MemoryConstants::pageSize64k; constexpr size_t expectedHeapSize = MemoryConstants::pageSize64k;
EXPECT_EQ(expectedHeapSize, size); EXPECT_EQ(expectedHeapSize, size);
@@ -962,7 +998,7 @@ HWTEST_F(CommandContainerTest, givenCmdContainerHasImmediateCsrWhenGettingHeapWi
cmdContainer.immediateReusableAllocationList = std::make_unique<NEO::AllocationsList>(); cmdContainer.immediateReusableAllocationList = std::make_unique<NEO::AllocationsList>();
cmdContainer.setNumIddPerBlock(1); cmdContainer.setNumIddPerBlock(1);
auto code = cmdContainer.initialize(pDevice, nullptr, true); auto code = cmdContainer.initialize(pDevice, nullptr, true, false);
EXPECT_EQ(CommandContainer::ErrorCode::SUCCESS, code); EXPECT_EQ(CommandContainer::ErrorCode::SUCCESS, code);
EXPECT_EQ(nullptr, cmdContainer.getIndirectHeap(HeapType::DYNAMIC_STATE)); EXPECT_EQ(nullptr, cmdContainer.getIndirectHeap(HeapType::DYNAMIC_STATE));
@@ -1138,7 +1174,7 @@ HWTEST_F(CommandContainerTest, givenCmdContainerUsedInRegularCmdListWhenGettingH
HeapReserveArguments sshReserveArgs = {sshHeapPtr, 0, sshAlign}; HeapReserveArguments sshReserveArgs = {sshHeapPtr, 0, sshAlign};
HeapReserveArguments dshReserveArgs = {dshHeapPtr, 0, dshAlign}; HeapReserveArguments dshReserveArgs = {dshHeapPtr, 0, dshAlign};
auto code = cmdContainer.initialize(pDevice, nullptr, true); auto code = cmdContainer.initialize(pDevice, nullptr, true, false);
EXPECT_EQ(CommandContainer::ErrorCode::SUCCESS, code); EXPECT_EQ(CommandContainer::ErrorCode::SUCCESS, code);
cmdContainer.reserveSpaceForDispatch(sshReserveArgs, dshReserveArgs, true); cmdContainer.reserveSpaceForDispatch(sshReserveArgs, dshReserveArgs, true);
@@ -1186,7 +1222,7 @@ HWTEST_F(CommandContainerTest, givenCmdContainerUsingPrivateHeapsWhenGettingRese
HeapReserveArguments sshReserveArgs = {sshHeapPtr, 0, sshAlign}; HeapReserveArguments sshReserveArgs = {sshHeapPtr, 0, sshAlign};
HeapReserveArguments dshReserveArgs = {dshHeapPtr, 0, dshAlign}; HeapReserveArguments dshReserveArgs = {dshHeapPtr, 0, dshAlign};
auto code = cmdContainer.initialize(pDevice, nullptr, true); auto code = cmdContainer.initialize(pDevice, nullptr, true, false);
EXPECT_EQ(CommandContainer::ErrorCode::SUCCESS, code); EXPECT_EQ(CommandContainer::ErrorCode::SUCCESS, code);
constexpr size_t nonZeroSshSize = 4 * MemoryConstants::kiloByte; constexpr size_t nonZeroSshSize = 4 * MemoryConstants::kiloByte;
@@ -1229,7 +1265,7 @@ HWTEST_F(CommandContainerTest,
cmdContainer.setNumIddPerBlock(1); cmdContainer.setNumIddPerBlock(1);
auto code = cmdContainer.initialize(pDevice, nullptr, true); auto code = cmdContainer.initialize(pDevice, nullptr, true, false);
EXPECT_EQ(CommandContainer::ErrorCode::SUCCESS, code); EXPECT_EQ(CommandContainer::ErrorCode::SUCCESS, code);
constexpr size_t misalignedSize = 11; constexpr size_t misalignedSize = 11;
@@ -1339,7 +1375,7 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenFillReusableAllocationListsThe
auto csr = pDevice->getDefaultEngine().commandStreamReceiver; auto csr = pDevice->getDefaultEngine().commandStreamReceiver;
AllocationsList allocList; AllocationsList allocList;
cmdContainer->initialize(pDevice, &allocList, true); cmdContainer->initialize(pDevice, &allocList, true, false);
cmdContainer->setImmediateCmdListCsr(csr); cmdContainer->setImmediateCmdListCsr(csr);
auto heapHelper = reinterpret_cast<MockHeapHelper *>(cmdContainer->getHeapHelper()); auto heapHelper = reinterpret_cast<MockHeapHelper *>(cmdContainer->getHeapHelper());
@@ -1366,7 +1402,7 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenFillReusableAllocationListsWit
AllocationsList allocList; AllocationsList allocList;
cmdContainer->enableHeapSharing(); cmdContainer->enableHeapSharing();
cmdContainer->initialize(pDevice, &allocList, true); cmdContainer->initialize(pDevice, &allocList, true, false);
cmdContainer->setImmediateCmdListCsr(csr); cmdContainer->setImmediateCmdListCsr(csr);
auto &reusableHeapsList = reinterpret_cast<MockHeapHelper *>(cmdContainer->getHeapHelper())->storageForReuse->getAllocationsForReuse(); auto &reusableHeapsList = reinterpret_cast<MockHeapHelper *>(cmdContainer->getHeapHelper())->storageForReuse->getAllocationsForReuse();
@@ -1386,7 +1422,7 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenFillReusableAllocationListsWit
auto csr = pDevice->getDefaultEngine().commandStreamReceiver; auto csr = pDevice->getDefaultEngine().commandStreamReceiver;
auto cmdContainer = std::make_unique<CommandContainer>(); auto cmdContainer = std::make_unique<CommandContainer>();
AllocationsList allocList; AllocationsList allocList;
cmdContainer->initialize(pDevice, &allocList, true); cmdContainer->initialize(pDevice, &allocList, true, false);
cmdContainer->setImmediateCmdListCsr(csr); cmdContainer->setImmediateCmdListCsr(csr);
auto &reusableHeapsList = reinterpret_cast<MockHeapHelper *>(cmdContainer->getHeapHelper())->storageForReuse->getAllocationsForReuse(); auto &reusableHeapsList = reinterpret_cast<MockHeapHelper *>(cmdContainer->getHeapHelper())->storageForReuse->getAllocationsForReuse();
@@ -1407,7 +1443,7 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenFillReusableAllocationListsWit
DebugManager.flags.SetAmountOfReusableAllocations.set(1); DebugManager.flags.SetAmountOfReusableAllocations.set(1);
auto cmdContainer = std::make_unique<MyMockCommandContainer>(); auto cmdContainer = std::make_unique<MyMockCommandContainer>();
AllocationsList allocList; AllocationsList allocList;
cmdContainer->initialize(pDevice, &allocList, false); cmdContainer->initialize(pDevice, &allocList, false, false);
EXPECT_EQ(cmdContainer->immediateReusableAllocationList, nullptr); EXPECT_EQ(cmdContainer->immediateReusableAllocationList, nullptr);
cmdContainer->fillReusableAllocationLists(); cmdContainer->fillReusableAllocationLists();
@@ -1422,7 +1458,7 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenFillReusableAllocationListsAnd
DebugManager.flags.SetAmountOfReusableAllocations.set(1); DebugManager.flags.SetAmountOfReusableAllocations.set(1);
auto cmdContainer = std::make_unique<MyMockCommandContainer>(); auto cmdContainer = std::make_unique<MyMockCommandContainer>();
AllocationsList allocList; AllocationsList allocList;
cmdContainer->initialize(pDevice, &allocList, false); cmdContainer->initialize(pDevice, &allocList, false, false);
EXPECT_EQ(cmdContainer->immediateReusableAllocationList, nullptr); EXPECT_EQ(cmdContainer->immediateReusableAllocationList, nullptr);
EXPECT_TRUE(allocList.peekIsEmpty()); EXPECT_TRUE(allocList.peekIsEmpty());
@@ -1443,7 +1479,7 @@ TEST_F(CommandContainerTest, givenCmdContainerWithoutGlobalListWhenFillReusableA
DebugManagerStateRestore dbgRestore; DebugManagerStateRestore dbgRestore;
DebugManager.flags.SetAmountOfReusableAllocations.set(1); DebugManager.flags.SetAmountOfReusableAllocations.set(1);
auto cmdContainer = std::make_unique<MyMockCommandContainer>(); auto cmdContainer = std::make_unique<MyMockCommandContainer>();
cmdContainer->initialize(pDevice, nullptr, false); cmdContainer->initialize(pDevice, nullptr, false, false);
EXPECT_EQ(cmdContainer->immediateReusableAllocationList, nullptr); EXPECT_EQ(cmdContainer->immediateReusableAllocationList, nullptr);
cmdContainer->fillReusableAllocationLists(); cmdContainer->fillReusableAllocationLists();
@@ -1461,7 +1497,7 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenFillReusableAllocationListsWit
auto cmdContainer = std::make_unique<MyMockCommandContainer>(); auto cmdContainer = std::make_unique<MyMockCommandContainer>();
auto csr = pDevice->getDefaultEngine().commandStreamReceiver; auto csr = pDevice->getDefaultEngine().commandStreamReceiver;
AllocationsList allocList; AllocationsList allocList;
cmdContainer->initialize(pDevice, &allocList, false); cmdContainer->initialize(pDevice, &allocList, false, false);
cmdContainer->setImmediateCmdListCsr(csr); cmdContainer->setImmediateCmdListCsr(csr);
EXPECT_EQ(cmdContainer->immediateReusableAllocationList, nullptr); EXPECT_EQ(cmdContainer->immediateReusableAllocationList, nullptr);
@@ -1478,7 +1514,7 @@ TEST_F(CommandContainerTest, givenCmdContainerAndCsrWhenGetHeapWithRequiredSizeA
auto cmdContainer = std::make_unique<CommandContainer>(); auto cmdContainer = std::make_unique<CommandContainer>();
auto csr = pDevice->getDefaultEngine().commandStreamReceiver; auto csr = pDevice->getDefaultEngine().commandStreamReceiver;
AllocationsList allocList; AllocationsList allocList;
cmdContainer->initialize(pDevice, &allocList, true); cmdContainer->initialize(pDevice, &allocList, true, false);
cmdContainer->setImmediateCmdListCsr(csr); cmdContainer->setImmediateCmdListCsr(csr);
cmdContainer->fillReusableAllocationLists(); cmdContainer->fillReusableAllocationLists();
@@ -1502,7 +1538,7 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenFillReusableAllocationListsAnd
auto cmdContainer = std::make_unique<MyMockCommandContainer>(); auto cmdContainer = std::make_unique<MyMockCommandContainer>();
auto csr = pDevice->getDefaultEngine().commandStreamReceiver; auto csr = pDevice->getDefaultEngine().commandStreamReceiver;
AllocationsList allocList; AllocationsList allocList;
cmdContainer->initialize(pDevice, &allocList, false); cmdContainer->initialize(pDevice, &allocList, false, false);
cmdContainer->setImmediateCmdListCsr(csr); cmdContainer->setImmediateCmdListCsr(csr);
cmdContainer->fillReusableAllocationLists(); cmdContainer->fillReusableAllocationLists();

View File

@@ -161,7 +161,7 @@ TEST_F(LinearStreamTest, givenLinearStreamWithoutCmdContainerWhenOneByteLeftInSt
using CommandContainerLinearStreamTest = Test<DeviceFixture>; using CommandContainerLinearStreamTest = Test<DeviceFixture>;
TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenOneByteLeftInStreamThenGetSpaceThrowAbort) { TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenOneByteLeftInStreamThenGetSpaceThrowAbort) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
auto stream = reinterpret_cast<MyLinearStreamMock *>(cmdContainer.getCommandStream()); auto stream = reinterpret_cast<MyLinearStreamMock *>(cmdContainer.getCommandStream());
stream->sizeUsed = stream->getMaxAvailableSpace() - 1; stream->sizeUsed = stream->getMaxAvailableSpace() - 1;
EXPECT_THROW(stream->getSpace(1), std::exception); EXPECT_THROW(stream->getSpace(1), std::exception);
@@ -169,7 +169,7 @@ TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenOn
TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenThereIsNoSpaceForCommandAndBBEndThenNewCmdBufferAllocated) { TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenThereIsNoSpaceForCommandAndBBEndThenNewCmdBufferAllocated) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
auto &gfxCoreHelper = pDevice->getGfxCoreHelper(); auto &gfxCoreHelper = pDevice->getGfxCoreHelper();
auto stream = reinterpret_cast<MyLinearStreamMock *>(cmdContainer.getCommandStream()); auto stream = reinterpret_cast<MyLinearStreamMock *>(cmdContainer.getCommandStream());
size_t dummyCommandSize = 2; size_t dummyCommandSize = 2;
@@ -181,7 +181,7 @@ TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenTh
TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenThereIsNoSpaceForCommandAndBBEndThenLinearStreamHasNewAllocation) { TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenThereIsNoSpaceForCommandAndBBEndThenLinearStreamHasNewAllocation) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
auto &gfxCoreHelper = pDevice->getGfxCoreHelper(); auto &gfxCoreHelper = pDevice->getGfxCoreHelper();
auto stream = reinterpret_cast<MyLinearStreamMock *>(cmdContainer.getCommandStream()); auto stream = reinterpret_cast<MyLinearStreamMock *>(cmdContainer.getCommandStream());
size_t dummyCommandSize = 2; size_t dummyCommandSize = 2;
@@ -194,7 +194,7 @@ TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenTh
TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenThereIsNoSpaceForCommandAndBBEndThenGetSpaceReturnPtrFromNewAllocation) { TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenThereIsNoSpaceForCommandAndBBEndThenGetSpaceReturnPtrFromNewAllocation) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
auto &gfxCoreHelper = pDevice->getGfxCoreHelper(); auto &gfxCoreHelper = pDevice->getGfxCoreHelper();
auto stream = reinterpret_cast<MyLinearStreamMock *>(cmdContainer.getCommandStream()); auto stream = reinterpret_cast<MyLinearStreamMock *>(cmdContainer.getCommandStream());
size_t dummyCommandSize = 2; size_t dummyCommandSize = 2;
@@ -206,7 +206,7 @@ TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenTh
TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenThereIsSpaceForCommandAndBBEndThenNewCmdBufferIsNotAllocated) { TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenThereIsSpaceForCommandAndBBEndThenNewCmdBufferIsNotAllocated) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
auto &gfxCoreHelper = pDevice->getGfxCoreHelper(); auto &gfxCoreHelper = pDevice->getGfxCoreHelper();
auto stream = reinterpret_cast<MyLinearStreamMock *>(cmdContainer.getCommandStream()); auto stream = reinterpret_cast<MyLinearStreamMock *>(cmdContainer.getCommandStream());
size_t dummyCommandSize = 2; size_t dummyCommandSize = 2;
@@ -218,7 +218,7 @@ TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenTh
TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenThereIsNoSpaceForCommandAndBBEndThenBBEndAddedAtEndOfStream) { TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenThereIsNoSpaceForCommandAndBBEndThenBBEndAddedAtEndOfStream) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
auto &gfxCoreHelper = pDevice->getGfxCoreHelper(); auto &gfxCoreHelper = pDevice->getGfxCoreHelper();
auto stream = reinterpret_cast<MyLinearStreamMock *>(cmdContainer.getCommandStream()); auto stream = reinterpret_cast<MyLinearStreamMock *>(cmdContainer.getCommandStream());
size_t dummyCommandSize = 2; size_t dummyCommandSize = 2;

View File

@@ -638,7 +638,7 @@ HWTEST2_P(L0DebuggerSimpleParameterizedTest, givenNotChangedSurfaceStateWhenCapt
debugger->sbaTrackingGpuVa.address = 0x45670000; debugger->sbaTrackingGpuVa.address = 0x45670000;
NEO::CommandContainer container; NEO::CommandContainer container;
container.initialize(pDevice, nullptr, true); container.initialize(pDevice, nullptr, true, false);
NEO::Debugger::SbaAddresses sba = {}; NEO::Debugger::SbaAddresses sba = {};
sba.SurfaceStateBaseAddress = 0x123456000; sba.SurfaceStateBaseAddress = 0x123456000;
@@ -661,7 +661,7 @@ HWTEST2_P(L0DebuggerSimpleParameterizedTest, givenChangedBaseAddressesWhenCaptur
debugger->sbaTrackingGpuVa.address = 0x45670000; debugger->sbaTrackingGpuVa.address = 0x45670000;
{ {
NEO::CommandContainer container; NEO::CommandContainer container;
container.initialize(pDevice, nullptr, true); container.initialize(pDevice, nullptr, true, false);
NEO::Debugger::SbaAddresses sba = {}; NEO::Debugger::SbaAddresses sba = {};
sba.SurfaceStateBaseAddress = 0x123456000; sba.SurfaceStateBaseAddress = 0x123456000;
@@ -674,7 +674,7 @@ HWTEST2_P(L0DebuggerSimpleParameterizedTest, givenChangedBaseAddressesWhenCaptur
{ {
NEO::CommandContainer container; NEO::CommandContainer container;
container.initialize(pDevice, nullptr, true); container.initialize(pDevice, nullptr, true, false);
NEO::Debugger::SbaAddresses sba = {}; NEO::Debugger::SbaAddresses sba = {};
sba.GeneralStateBaseAddress = 0x123456000; sba.GeneralStateBaseAddress = 0x123456000;
@@ -687,7 +687,7 @@ HWTEST2_P(L0DebuggerSimpleParameterizedTest, givenChangedBaseAddressesWhenCaptur
{ {
NEO::CommandContainer container; NEO::CommandContainer container;
container.initialize(pDevice, nullptr, true); container.initialize(pDevice, nullptr, true, false);
NEO::Debugger::SbaAddresses sba = {}; NEO::Debugger::SbaAddresses sba = {};
sba.BindlessSurfaceStateBaseAddress = 0x123456000; sba.BindlessSurfaceStateBaseAddress = 0x123456000;

View File

@@ -15,6 +15,7 @@
#include "shared/source/helpers/flush_stamp.h" #include "shared/source/helpers/flush_stamp.h"
#include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/helpers/gfx_core_helper.h"
#include "shared/source/helpers/register_offsets.h" #include "shared/source/helpers/register_offsets.h"
#include "shared/source/memory_manager/memory_allocation.h"
#include "shared/source/utilities/cpuintrinsics.h" #include "shared/source/utilities/cpuintrinsics.h"
#include "shared/test/common/cmd_parse/hw_parse.h" #include "shared/test/common/cmd_parse/hw_parse.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/debug_manager_state_restore.h"
@@ -251,6 +252,119 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, DirectSubmissionDispatchBufferTest,
EXPECT_TRUE(foundFenceUpdate); EXPECT_TRUE(foundFenceUpdate);
} }
HWTEST_F(DirectSubmissionDispatchBufferTest, givenCopyCommandBufferIntoRingWhenDispatchCommandBufferThenCopyTaskStream) {
using MI_BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START;
using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;
using Dispatcher = RenderDispatcher<FamilyType>;
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionFlatRingBuffer.set(-1);
FlushStampTracker flushStamp(true);
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice->getDefaultEngine().commandStreamReceiver);
EXPECT_TRUE(directSubmission.copyCommandBufferIntoRing(batchBuffer));
bool ret = directSubmission.initialize(true, false);
EXPECT_TRUE(ret);
size_t sizeUsed = directSubmission.ringCommandStream.getUsed();
batchBuffer.endCmdPtr = batchBuffer.stream->getCpuBase();
ret = directSubmission.dispatchCommandBuffer(batchBuffer, flushStamp);
HardwareParse hwParse;
hwParse.parseCommands<FamilyType>(directSubmission.ringCommandStream, sizeUsed);
auto semaphoreIt = find<MI_SEMAPHORE_WAIT *>(hwParse.cmdList.begin(), hwParse.cmdList.end());
MI_BATCH_BUFFER_START *bbStart = hwParse.getCommand<MI_BATCH_BUFFER_START>(hwParse.cmdList.begin(), semaphoreIt);
EXPECT_EQ(nullptr, bbStart);
}
HWTEST_F(DirectSubmissionDispatchBufferTest, givenDefaultDirectSubmissionFlatRingBufferAndSingleTileDirectSubmissionWhenSubmitSystemMemNotChainedBatchBufferWithoutRelaxingDependenciesThenCopyIntoRing) {
using MI_BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START;
using Dispatcher = RenderDispatcher<FamilyType>;
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionFlatRingBuffer.set(-1);
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice->getDefaultEngine().commandStreamReceiver);
EXPECT_TRUE(directSubmission.copyCommandBufferIntoRing(batchBuffer));
}
HWTEST_F(DirectSubmissionDispatchBufferTest, givenDefaultDirectSubmissionFlatRingBufferAndSingleTileDirectSubmissionWhenSubmitSystemMemNotChainedBatchBufferWithoutCommandBufferRelaxingDependenciesThenNotCopyIntoRing) {
using MI_BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START;
using Dispatcher = RenderDispatcher<FamilyType>;
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionFlatRingBuffer.set(-1);
batchBuffer.commandBufferAllocation = nullptr;
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice->getDefaultEngine().commandStreamReceiver);
EXPECT_FALSE(directSubmission.copyCommandBufferIntoRing(batchBuffer));
}
HWTEST_F(DirectSubmissionDispatchBufferTest, givenDisabledDirectSubmissionFlatRingBufferAndSingleTileDirectSubmissionWhenSubmitSystemMemNotChainedBatchBufferWithoutRelaxingDependenciesThenNotCopyIntoRing) {
using Dispatcher = RenderDispatcher<FamilyType>;
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionFlatRingBuffer.set(0);
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice->getDefaultEngine().commandStreamReceiver);
EXPECT_FALSE(directSubmission.copyCommandBufferIntoRing(batchBuffer));
}
HWTEST_F(DirectSubmissionDispatchBufferTest, givenDefaultDirectSubmissionFlatRingBufferAndSingleTileDirectSubmissionWhenSubmitSystemMemNotChainedBatchBufferWithRelaxingDependenciesThenNotCopyIntoRing) {
using Dispatcher = RenderDispatcher<FamilyType>;
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionFlatRingBuffer.set(-1);
batchBuffer.hasRelaxedOrderingDependencies = true;
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice->getDefaultEngine().commandStreamReceiver);
EXPECT_FALSE(directSubmission.copyCommandBufferIntoRing(batchBuffer));
}
HWTEST_F(DirectSubmissionDispatchBufferTest, givenDefaultDirectSubmissionFlatRingBufferAndSingleTileDirectSubmissionWhenSubmitSystemMemChainedBatchBufferWithoutRelaxingDependenciesThenNotCopyIntoRing) {
using Dispatcher = RenderDispatcher<FamilyType>;
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionFlatRingBuffer.set(-1);
batchBuffer.chainedBatchBuffer = reinterpret_cast<GraphicsAllocation *>(0x1234);
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice->getDefaultEngine().commandStreamReceiver);
EXPECT_FALSE(directSubmission.copyCommandBufferIntoRing(batchBuffer));
}
HWTEST_F(DirectSubmissionDispatchBufferTest, givenDefaultDirectSubmissionFlatRingBufferAndSingleTileDirectSubmissionWhenSubmitLocalMemNotChainedBatchBufferWithoutRelaxingDependenciesThenNotCopyIntoRing) {
using Dispatcher = RenderDispatcher<FamilyType>;
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionFlatRingBuffer.set(-1);
static_cast<MemoryAllocation *>(batchBuffer.commandBufferAllocation)->overrideMemoryPool(MemoryPool::LocalMemory);
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice->getDefaultEngine().commandStreamReceiver);
EXPECT_FALSE(directSubmission.copyCommandBufferIntoRing(batchBuffer));
}
HWTEST_F(DirectSubmissionDispatchBufferTest, givenDefaultDirectSubmissionFlatRingBufferAndMultiTileDirectSubmissionWhenSubmitSystemMemNotChainedBatchBufferWithoutRelaxingDependenciesThenNotCopyIntoRing) {
using Dispatcher = RenderDispatcher<FamilyType>;
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionFlatRingBuffer.set(-1);
std::unique_ptr<OsContext> osContext(OsContext::create(pDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->osInterface.get(), pDevice->getRootDeviceIndex(), 0,
EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_CCS, EngineUsage::Regular},
PreemptionMode::ThreadGroup, 0b11)));
pDevice->getDefaultEngine().commandStreamReceiver->setupContext(*osContext.get());
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice->getDefaultEngine().commandStreamReceiver);
EXPECT_FALSE(directSubmission.copyCommandBufferIntoRing(batchBuffer));
}
HWTEST_F(DirectSubmissionDispatchBufferTest, HWTEST_F(DirectSubmissionDispatchBufferTest,
givenDirectSubmissionDisableMonitorFenceWhenDispatchWorkloadCalledThenExpectStartWithoutMonitorFence) { givenDirectSubmissionDisableMonitorFenceWhenDispatchWorkloadCalledThenExpectStartWithoutMonitorFence) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;

View File

@@ -162,7 +162,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPAndLaterCommandEncoderTest, givenOffsetAndValue
GenCmdList commands; GenCmdList commands;
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
constexpr uint32_t regOffset = 0x2000u; constexpr uint32_t regOffset = 0x2000u;
constexpr uint32_t immVal = 0xbaau; constexpr uint32_t immVal = 0xbaau;
constexpr uint64_t dstAddress = 0xDEADCAF0u; constexpr uint64_t dstAddress = 0xDEADCAF0u;

View File

@@ -18,7 +18,7 @@ using EncodeBatchBufferStartOrEndTest = Test<DeviceFixture>;
HWTEST_F(EncodeBatchBufferStartOrEndTest, givenCommandContainerWhenEncodeBBEndThenCommandIsAdded) { HWTEST_F(EncodeBatchBufferStartOrEndTest, givenCommandContainerWhenEncodeBBEndThenCommandIsAdded) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
EncodeBatchBufferStartOrEnd<FamilyType>::programBatchBufferEnd(cmdContainer); EncodeBatchBufferStartOrEnd<FamilyType>::programBatchBufferEnd(cmdContainer);
GenCmdList commands; GenCmdList commands;
@@ -31,7 +31,7 @@ HWTEST_F(EncodeBatchBufferStartOrEndTest, givenCommandContainerWhenEncodeBBEndTh
HWTEST_F(EncodeBatchBufferStartOrEndTest, givenCommandContainerWhenEncodeBBStartThenCommandIsAdded) { HWTEST_F(EncodeBatchBufferStartOrEndTest, givenCommandContainerWhenEncodeBBStartThenCommandIsAdded) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
EncodeBatchBufferStartOrEnd<FamilyType>::programBatchBufferStart(cmdContainer.getCommandStream(), 0, true, false, false); EncodeBatchBufferStartOrEnd<FamilyType>::programBatchBufferStart(cmdContainer.getCommandStream(), 0, true, false, false);
GenCmdList commands; GenCmdList commands;
@@ -44,7 +44,7 @@ HWTEST_F(EncodeBatchBufferStartOrEndTest, givenCommandContainerWhenEncodeBBStart
HWTEST_F(EncodeBatchBufferStartOrEndTest, givenCommandContainerWhenEncodeBBStartWithSecondLevelParameterThenCommandIsProgrammedCorrectly) { HWTEST_F(EncodeBatchBufferStartOrEndTest, givenCommandContainerWhenEncodeBBStartWithSecondLevelParameterThenCommandIsProgrammedCorrectly) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
EncodeBatchBufferStartOrEnd<FamilyType>::programBatchBufferStart(cmdContainer.getCommandStream(), 0, true, false, false); EncodeBatchBufferStartOrEnd<FamilyType>::programBatchBufferStart(cmdContainer.getCommandStream(), 0, true, false, false);
GenCmdList commands; GenCmdList commands;
@@ -61,7 +61,7 @@ HWTEST_F(EncodeBatchBufferStartOrEndTest, givenCommandContainerWhenEncodeBBStart
HWTEST_F(EncodeBatchBufferStartOrEndTest, givenCommandContainerWhenEncodeBBStartWithFirstLevelParameterThenCommandIsProgrammedCorrectly) { HWTEST_F(EncodeBatchBufferStartOrEndTest, givenCommandContainerWhenEncodeBBStartWithFirstLevelParameterThenCommandIsProgrammedCorrectly) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
EncodeBatchBufferStartOrEnd<FamilyType>::programBatchBufferStart(cmdContainer.getCommandStream(), 0, false, false, false); EncodeBatchBufferStartOrEnd<FamilyType>::programBatchBufferStart(cmdContainer.getCommandStream(), 0, false, false, false);
GenCmdList commands; GenCmdList commands;
@@ -78,7 +78,7 @@ HWTEST_F(EncodeBatchBufferStartOrEndTest, givenCommandContainerWhenEncodeBBStart
HWTEST_F(EncodeBatchBufferStartOrEndTest, givenGpuAddressWhenEncodeBBStartThenAddressIsProgrammedCorrectly) { HWTEST_F(EncodeBatchBufferStartOrEndTest, givenGpuAddressWhenEncodeBBStartThenAddressIsProgrammedCorrectly) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
uint64_t gpuAddress = 12 * MemoryConstants::pageSize; uint64_t gpuAddress = 12 * MemoryConstants::pageSize;
EncodeBatchBufferStartOrEnd<FamilyType>::programBatchBufferStart(cmdContainer.getCommandStream(), gpuAddress, false, false, false); EncodeBatchBufferStartOrEnd<FamilyType>::programBatchBufferStart(cmdContainer.getCommandStream(), gpuAddress, false, false, false);
@@ -99,7 +99,7 @@ using EncodeNoopTest = Test<DeviceFixture>;
HWTEST_F(EncodeNoopTest, WhenAligningLinearStreamToCacheLineSizeThenItIsAlignedCorrectly) { HWTEST_F(EncodeNoopTest, WhenAligningLinearStreamToCacheLineSizeThenItIsAlignedCorrectly) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
auto commandStream = cmdContainer.getCommandStream(); auto commandStream = cmdContainer.getCommandStream();
EncodeNoop<FamilyType>::alignToCacheLine(*commandStream); EncodeNoop<FamilyType>::alignToCacheLine(*commandStream);
@@ -112,7 +112,7 @@ HWTEST_F(EncodeNoopTest, WhenAligningLinearStreamToCacheLineSizeThenItIsAlignedC
HWTEST_F(EncodeNoopTest, WhenEmittingNoopsThenExpectCorrectNumberOfBytesNooped) { HWTEST_F(EncodeNoopTest, WhenEmittingNoopsThenExpectCorrectNumberOfBytesNooped) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
auto commandStream = cmdContainer.getCommandStream(); auto commandStream = cmdContainer.getCommandStream();
size_t usedBefore = commandStream->getUsed(); size_t usedBefore = commandStream->getUsed();

View File

@@ -506,7 +506,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandEncodeStatesTest, givenForceBtpPrefetchModeDe
{ {
DebugManager.flags.ForceBtpPrefetchMode.set(-1); DebugManager.flags.ForceBtpPrefetchMode.set(-1);
cmdContainer.reset(new MyMockCommandContainer()); cmdContainer.reset(new MyMockCommandContainer());
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
bool requiresUncachedMocs = false; bool requiresUncachedMocs = false;
EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs); EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs);
@@ -537,7 +537,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandEncodeStatesTest, givenForceBtpPrefetchModeDe
{ {
DebugManager.flags.ForceBtpPrefetchMode.set(0); DebugManager.flags.ForceBtpPrefetchMode.set(0);
cmdContainer.reset(new MyMockCommandContainer()); cmdContainer.reset(new MyMockCommandContainer());
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
bool requiresUncachedMocs = false; bool requiresUncachedMocs = false;
EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs); EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs);
@@ -564,7 +564,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandEncodeStatesTest, givenForceBtpPrefetchModeDe
{ {
DebugManager.flags.ForceBtpPrefetchMode.set(1); DebugManager.flags.ForceBtpPrefetchMode.set(1);
cmdContainer.reset(new MyMockCommandContainer()); cmdContainer.reset(new MyMockCommandContainer());
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
bool requiresUncachedMocs = false; bool requiresUncachedMocs = false;
EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs); EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs);
@@ -1269,7 +1269,7 @@ HWTEST_F(BindlessCommandEncodeStatesContainerTest, givenBindlessKernelAndBindles
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.UseBindlessMode.set(1); DebugManager.flags.UseBindlessMode.set(1);
auto commandContainer = std::make_unique<CommandContainer>(); auto commandContainer = std::make_unique<CommandContainer>();
commandContainer->initialize(pDevice, nullptr, true); commandContainer->initialize(pDevice, nullptr, true, false);
commandContainer->setDirtyStateForAllHeaps(false); commandContainer->setDirtyStateForAllHeaps(false);
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(),
pDevice->getNumGenericSubDevices() > 1, pDevice->getNumGenericSubDevices() > 1,
@@ -1305,7 +1305,7 @@ HWTEST2_F(BindlessCommandEncodeStatesContainerTest, givenBindlessKernelAndBindle
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.UseBindlessMode.set(1); DebugManager.flags.UseBindlessMode.set(1);
auto commandContainer = std::make_unique<CommandContainer>(); auto commandContainer = std::make_unique<CommandContainer>();
commandContainer->initialize(pDevice, nullptr, true); commandContainer->initialize(pDevice, nullptr, true, false);
commandContainer->setDirtyStateForAllHeaps(false); commandContainer->setDirtyStateForAllHeaps(false);
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(),
pDevice->getNumGenericSubDevices() > 1, pDevice->getNumGenericSubDevices() > 1,
@@ -1344,7 +1344,7 @@ HWTEST_F(BindlessCommandEncodeStatesContainerTest, givenBindfulKernelWhenBindles
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.UseBindlessMode.set(1); DebugManager.flags.UseBindlessMode.set(1);
auto commandContainer = std::make_unique<CommandContainer>(); auto commandContainer = std::make_unique<CommandContainer>();
commandContainer->initialize(pDevice, nullptr, true); commandContainer->initialize(pDevice, nullptr, true, false);
commandContainer->setDirtyStateForAllHeaps(false); commandContainer->setDirtyStateForAllHeaps(false);
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(),
pDevice->getNumGenericSubDevices() > 1, pDevice->getNumGenericSubDevices() > 1,
@@ -1380,7 +1380,7 @@ HWTEST_F(BindlessCommandEncodeStatesContainerTest, givenBindlessModeEnabledWhenD
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.UseBindlessMode.set(1); DebugManager.flags.UseBindlessMode.set(1);
auto commandContainer = std::make_unique<CommandContainer>(); auto commandContainer = std::make_unique<CommandContainer>();
commandContainer->initialize(pDevice, nullptr, true); commandContainer->initialize(pDevice, nullptr, true, false);
commandContainer->setDirtyStateForAllHeaps(false); commandContainer->setDirtyStateForAllHeaps(false);
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(),
pDevice->getNumGenericSubDevices() > 1, pDevice->getNumGenericSubDevices() > 1,
@@ -1422,7 +1422,7 @@ HWTEST_F(BindlessCommandEncodeStatesTest, givenGlobalBindlessHeapsWhenDispatchin
DebugManagerStateRestore restorer; DebugManagerStateRestore restorer;
DebugManager.flags.UseBindlessMode.set(1); DebugManager.flags.UseBindlessMode.set(1);
auto cmdContainer = std::make_unique<CommandContainer>(); auto cmdContainer = std::make_unique<CommandContainer>();
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
cmdContainer->setDirtyStateForAllHeaps(false); cmdContainer->setDirtyStateForAllHeaps(false);
using SAMPLER_BORDER_COLOR_STATE = typename FamilyType::SAMPLER_BORDER_COLOR_STATE; using SAMPLER_BORDER_COLOR_STATE = typename FamilyType::SAMPLER_BORDER_COLOR_STATE;
using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA; using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA;
@@ -1474,7 +1474,7 @@ HWTEST_F(BindlessCommandEncodeStatesTest, givenBindlessModeDisabledelWithSampler
DebugManagerStateRestore restorer; DebugManagerStateRestore restorer;
DebugManager.flags.UseBindlessMode.set(0); DebugManager.flags.UseBindlessMode.set(0);
auto cmdContainer = std::make_unique<CommandContainer>(); auto cmdContainer = std::make_unique<CommandContainer>();
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE; using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE;
using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA; using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA;
uint32_t numSamplers = 1; uint32_t numSamplers = 1;

View File

@@ -438,7 +438,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncodeStatesTest, givenForceBtpPrefetchModeD
{ {
DebugManager.flags.ForceBtpPrefetchMode.set(-1); DebugManager.flags.ForceBtpPrefetchMode.set(-1);
cmdContainer.reset(new MyMockCommandContainer()); cmdContainer.reset(new MyMockCommandContainer());
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
bool requiresUncachedMocs = false; bool requiresUncachedMocs = false;
EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs); EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs);
@@ -471,7 +471,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncodeStatesTest, givenForceBtpPrefetchModeD
{ {
DebugManager.flags.ForceBtpPrefetchMode.set(0); DebugManager.flags.ForceBtpPrefetchMode.set(0);
cmdContainer.reset(new MyMockCommandContainer()); cmdContainer.reset(new MyMockCommandContainer());
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
bool requiresUncachedMocs = false; bool requiresUncachedMocs = false;
EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs); EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs);
@@ -495,7 +495,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncodeStatesTest, givenForceBtpPrefetchModeD
{ {
DebugManager.flags.ForceBtpPrefetchMode.set(1); DebugManager.flags.ForceBtpPrefetchMode.set(1);
cmdContainer.reset(new MyMockCommandContainer()); cmdContainer.reset(new MyMockCommandContainer());
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
bool requiresUncachedMocs = false; bool requiresUncachedMocs = false;
EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs); EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs);

View File

@@ -147,7 +147,7 @@ HWTEST_F(CommandEncoderMathTest, WhenReservingCommandThenBitfieldSetCorrectly) {
GenCmdList commands; GenCmdList commands;
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
EncodeMath<FamilyType>::commandReserve(cmdContainer); EncodeMath<FamilyType>::commandReserve(cmdContainer);
@@ -177,7 +177,7 @@ HWTEST_F(CommandEncoderMathTest, givenOffsetAndValueWhenEncodeBitwiseAndValIsCal
GenCmdList commands; GenCmdList commands;
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
constexpr uint32_t regOffset = 0x2000u; constexpr uint32_t regOffset = 0x2000u;
constexpr uint32_t immVal = 0xbaau; constexpr uint32_t immVal = 0xbaau;
constexpr uint64_t dstAddress = 0xDEADCAF0u; constexpr uint64_t dstAddress = 0xDEADCAF0u;
@@ -223,7 +223,7 @@ HWTEST_F(CommandEncoderMathTest, WhenSettingGroupSizeIndirectThenCommandsAreCorr
using MI_STORE_REGISTER_MEM = typename FamilyType::MI_STORE_REGISTER_MEM; using MI_STORE_REGISTER_MEM = typename FamilyType::MI_STORE_REGISTER_MEM;
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
CrossThreadDataOffset offsets[3] = {0, sizeof(uint32_t), 2 * sizeof(uint32_t)}; CrossThreadDataOffset offsets[3] = {0, sizeof(uint32_t), 2 * sizeof(uint32_t)};
uint32_t crossThreadAddress[3] = {}; uint32_t crossThreadAddress[3] = {};
@@ -249,7 +249,7 @@ HWTEST_F(CommandEncoderMathTest, WhenSettingGroupCountIndirectThenCommandsAreCor
using MI_STORE_REGISTER_MEM = typename FamilyType::MI_STORE_REGISTER_MEM; using MI_STORE_REGISTER_MEM = typename FamilyType::MI_STORE_REGISTER_MEM;
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
CrossThreadDataOffset offsets[3] = {0, sizeof(uint32_t), 2 * sizeof(uint32_t)}; CrossThreadDataOffset offsets[3] = {0, sizeof(uint32_t), 2 * sizeof(uint32_t)};
uint32_t crossThreadAddress[3] = {}; uint32_t crossThreadAddress[3] = {};

View File

@@ -24,7 +24,7 @@ HWTEST2_F(XeHPAndLaterCommandEncoderMathTest, WhenAppendsAGreaterThanThenPredica
using MI_MATH_ALU_INST_INLINE = typename FamilyType::MI_MATH_ALU_INST_INLINE; using MI_MATH_ALU_INST_INLINE = typename FamilyType::MI_MATH_ALU_INST_INLINE;
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
EncodeMathMMIO<FamilyType>::encodeGreaterThanPredicate(cmdContainer, 0xDEADBEEFCAF0u, 17u); EncodeMathMMIO<FamilyType>::encodeGreaterThanPredicate(cmdContainer, 0xDEADBEEFCAF0u, 17u);

View File

@@ -18,7 +18,7 @@ class CommandSetMMIOFixture : public DeviceFixture {
void setUp() { void setUp() {
DeviceFixture::setUp(); DeviceFixture::setUp();
cmdContainer = std::make_unique<CommandContainer>(); cmdContainer = std::make_unique<CommandContainer>();
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
} }
void tearDown() { void tearDown() {
cmdContainer.reset(); cmdContainer.reset();

View File

@@ -15,7 +15,7 @@ namespace NEO {
void CommandEncodeStatesFixture::setUp() { void CommandEncodeStatesFixture::setUp() {
DeviceFixture::setUp(); DeviceFixture::setUp();
cmdContainer = std::make_unique<MyMockCommandContainer>(); cmdContainer = std::make_unique<MyMockCommandContainer>();
cmdContainer->initialize(pDevice, nullptr, true); cmdContainer->initialize(pDevice, nullptr, true, false);
cmdContainer->setDirtyStateForAllHeaps(false); cmdContainer->setDirtyStateForAllHeaps(false);
const auto &hwInfo = pDevice->getHardwareInfo(); const auto &hwInfo = pDevice->getHardwareInfo();
auto &productHelper = pDevice->getProductHelper(); auto &productHelper = pDevice->getProductHelper();

View File

@@ -38,16 +38,20 @@ struct DirectSubmissionFixture : public DeviceFixture {
struct DirectSubmissionDispatchBufferFixture : public DirectSubmissionFixture { struct DirectSubmissionDispatchBufferFixture : public DirectSubmissionFixture {
void setUp() { void setUp() {
DebugManager.flags.DirectSubmissionFlatRingBuffer.set(0);
DirectSubmissionFixture::setUp(); DirectSubmissionFixture::setUp();
MemoryManager *memoryManager = pDevice->getExecutionEnvironment()->memoryManager.get(); MemoryManager *memoryManager = pDevice->getExecutionEnvironment()->memoryManager.get();
const AllocationProperties commandBufferProperties{pDevice->getRootDeviceIndex(), 0x1000, const AllocationProperties commandBufferProperties{pDevice->getRootDeviceIndex(), 0x1000,
AllocationType::COMMAND_BUFFER, pDevice->getDeviceBitfield()}; AllocationType::COMMAND_BUFFER, pDevice->getDeviceBitfield()};
commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(commandBufferProperties); commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(commandBufferProperties);
stream = std::make_unique<LinearStream>(commandBuffer);
stream->getSpace(0x40);
batchBuffer.endCmdPtr = &bbStart[0]; batchBuffer.endCmdPtr = &bbStart[0];
batchBuffer.commandBufferAllocation = commandBuffer; batchBuffer.commandBufferAllocation = commandBuffer;
batchBuffer.usedSize = 0x40; batchBuffer.usedSize = 0x40;
batchBuffer.taskStartAddress = 0x881112340000; batchBuffer.taskStartAddress = 0x881112340000;
batchBuffer.stream = stream.get();
} }
void tearDown() { void tearDown() {
@@ -60,4 +64,6 @@ struct DirectSubmissionDispatchBufferFixture : public DirectSubmissionFixture {
BatchBuffer batchBuffer; BatchBuffer batchBuffer;
uint8_t bbStart[64]; uint8_t bbStart[64];
GraphicsAllocation *commandBuffer; GraphicsAllocation *commandBuffer;
DebugManagerStateRestore restorer;
std::unique_ptr<LinearStream> stream;
}; };

View File

@@ -26,7 +26,7 @@ GEN11TEST_F(CommandEncoderMathTestGen11, WhenAppendsAGreaterThanThenPredicateCor
using MI_MATH_ALU_INST_INLINE = typename FamilyType::MI_MATH_ALU_INST_INLINE; using MI_MATH_ALU_INST_INLINE = typename FamilyType::MI_MATH_ALU_INST_INLINE;
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
EncodeMathMMIO<FamilyType>::encodeGreaterThanPredicate(cmdContainer, 0xDEADBEEFCAF0u, 17u); EncodeMathMMIO<FamilyType>::encodeGreaterThanPredicate(cmdContainer, 0xDEADBEEFCAF0u, 17u);

View File

@@ -33,7 +33,7 @@ GEN12LPTEST_F(CommandEncoderTest, WhenAdjustComputeModeIsCalledThenStateComputeM
CommandContainer cmdContainer; CommandContainer cmdContainer;
auto ret = cmdContainer.initialize(pDevice, nullptr, true); auto ret = cmdContainer.initialize(pDevice, nullptr, true, false);
ASSERT_EQ(CommandContainer::ErrorCode::SUCCESS, ret); ASSERT_EQ(CommandContainer::ErrorCode::SUCCESS, ret);
auto usedSpaceBefore = cmdContainer.getCommandStream()->getUsed(); auto usedSpaceBefore = cmdContainer.getCommandStream()->getUsed();
@@ -62,7 +62,7 @@ GEN12LPTEST_F(CommandEncoderTest, WhenAdjustComputeModeIsCalledThenStateComputeM
GEN12LPTEST_F(CommandEncoderTest, givenCommandContainerWhenEncodeL3StateThenDoNotDispatchMMIOCommand) { GEN12LPTEST_F(CommandEncoderTest, givenCommandContainerWhenEncodeL3StateThenDoNotDispatchMMIOCommand) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
EncodeL3State<FamilyType>::encode(cmdContainer, false); EncodeL3State<FamilyType>::encode(cmdContainer, false);
GenCmdList commands; GenCmdList commands;
@@ -84,7 +84,7 @@ GEN12LPTEST_F(CommandEncodeStatesTest, givenVariousEngineTypesWhenEncodeSbaThenA
CommandContainer cmdContainer; CommandContainer cmdContainer;
auto ret = cmdContainer.initialize(pDevice, nullptr, true); auto ret = cmdContainer.initialize(pDevice, nullptr, true, false);
ASSERT_EQ(CommandContainer::ErrorCode::SUCCESS, ret); ASSERT_EQ(CommandContainer::ErrorCode::SUCCESS, ret);
auto gmmHelper = cmdContainer.getDevice()->getRootDeviceEnvironment().getGmmHelper(); auto gmmHelper = cmdContainer.getDevice()->getRootDeviceEnvironment().getGmmHelper();
@@ -127,7 +127,7 @@ GEN12LPTEST_F(CommandEncoderTest, GivenGen12LpWhenProgrammingL3StateOnThenExpect
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM; using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
EncodeL3State<FamilyType>::encode(cmdContainer, true); EncodeL3State<FamilyType>::encode(cmdContainer, true);
@@ -141,7 +141,7 @@ GEN12LPTEST_F(CommandEncoderTest, GivenGen12LpWhenProgrammingL3StateOnThenExpect
GEN12LPTEST_F(CommandEncoderTest, GivenGen12LpWhenProgrammingL3StateOffThenExpectNoCommandsDispatched) { GEN12LPTEST_F(CommandEncoderTest, GivenGen12LpWhenProgrammingL3StateOffThenExpectNoCommandsDispatched) {
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM; using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
EncodeL3State<FamilyType>::encode(cmdContainer, false); EncodeL3State<FamilyType>::encode(cmdContainer, false);

View File

@@ -24,7 +24,7 @@ GEN12LPTEST_F(CommandEncoderMathTestGen12Lp, WhenAppendsAGreaterThanThenPredicat
using MI_MATH_ALU_INST_INLINE = typename FamilyType::MI_MATH_ALU_INST_INLINE; using MI_MATH_ALU_INST_INLINE = typename FamilyType::MI_MATH_ALU_INST_INLINE;
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
EncodeMathMMIO<FamilyType>::encodeGreaterThanPredicate(cmdContainer, 0xDEADBEEFCAF0u, 17u); EncodeMathMMIO<FamilyType>::encodeGreaterThanPredicate(cmdContainer, 0xDEADBEEFCAF0u, 17u);

View File

@@ -26,7 +26,7 @@ GEN8TEST_F(CommandEncoderMathTestGen8, WhenAppendsAGreaterThanThenPredicateCorre
using MI_MATH_ALU_INST_INLINE = typename FamilyType::MI_MATH_ALU_INST_INLINE; using MI_MATH_ALU_INST_INLINE = typename FamilyType::MI_MATH_ALU_INST_INLINE;
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
EncodeMathMMIO<FamilyType>::encodeGreaterThanPredicate(cmdContainer, 0xDEADBEEFCAF0u, 17u); EncodeMathMMIO<FamilyType>::encodeGreaterThanPredicate(cmdContainer, 0xDEADBEEFCAF0u, 17u);

View File

@@ -23,7 +23,7 @@ using CommandEncoderTest = Test<DeviceFixture>;
GEN9TEST_F(CommandEncoderTest, WhenProgrammingThenLoadRegisterImmIsUsed) { GEN9TEST_F(CommandEncoderTest, WhenProgrammingThenLoadRegisterImmIsUsed) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
EncodeL3State<FamilyType>::encode(cmdContainer, false); EncodeL3State<FamilyType>::encode(cmdContainer, false);
GenCmdList commands; GenCmdList commands;
@@ -36,7 +36,7 @@ GEN9TEST_F(CommandEncoderTest, WhenProgrammingThenLoadRegisterImmIsUsed) {
GEN9TEST_F(CommandEncoderTest, givenNoSlmThenCorrectMmioIsSet) { GEN9TEST_F(CommandEncoderTest, givenNoSlmThenCorrectMmioIsSet) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
EncodeL3State<FamilyType>::encode(cmdContainer, false); EncodeL3State<FamilyType>::encode(cmdContainer, false);
GenCmdList commands; GenCmdList commands;
@@ -54,7 +54,7 @@ GEN9TEST_F(CommandEncoderTest, givenNoSlmThenCorrectMmioIsSet) {
GEN9TEST_F(CommandEncoderTest, givenSlmThenCorrectMmioIsSet) { GEN9TEST_F(CommandEncoderTest, givenSlmThenCorrectMmioIsSet) {
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
EncodeL3State<FamilyType>::encode(cmdContainer, true); EncodeL3State<FamilyType>::encode(cmdContainer, true);
GenCmdList commands; GenCmdList commands;

View File

@@ -26,7 +26,7 @@ GEN9TEST_F(CommandEncoderMathTestGen9, WhenAppendsAGreaterThanThenPredicateCorre
using MI_MATH_ALU_INST_INLINE = typename FamilyType::MI_MATH_ALU_INST_INLINE; using MI_MATH_ALU_INST_INLINE = typename FamilyType::MI_MATH_ALU_INST_INLINE;
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true); cmdContainer.initialize(pDevice, nullptr, true, false);
EncodeMathMMIO<FamilyType>::encodeGreaterThanPredicate(cmdContainer, 0xDEADBEEFCAF0u, 17u); EncodeMathMMIO<FamilyType>::encodeGreaterThanPredicate(cmdContainer, 0xDEADBEEFCAF0u, 17u);

View File

@@ -674,6 +674,7 @@ struct DrmCommandStreamDirectSubmissionTest : public DrmCommandStreamEnhancedTes
void setUpT() { void setUpT() {
DebugManager.flags.EnableDirectSubmission.set(1u); DebugManager.flags.EnableDirectSubmission.set(1u);
DebugManager.flags.DirectSubmissionDisableMonitorFence.set(0); DebugManager.flags.DirectSubmissionDisableMonitorFence.set(0);
DebugManager.flags.DirectSubmissionFlatRingBuffer.set(0);
DrmCommandStreamEnhancedTest::setUpT<GfxFamily>(); DrmCommandStreamEnhancedTest::setUpT<GfxFamily>();
auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo(); auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo();
auto engineType = device->getDefaultEngine().osContext->getEngineType(); auto engineType = device->getDefaultEngine().osContext->getEngineType();

View File

@@ -3798,7 +3798,7 @@ TEST(DrmMemoryManager, givenEnabledResourceRegistrationWhenSshIsAllocatedThenItI
auto device = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(executionEnvironment, 0)); auto device = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(executionEnvironment, 0));
CommandContainer cmdContainer; CommandContainer cmdContainer;
cmdContainer.initialize(device.get(), nullptr, true); cmdContainer.initialize(device.get(), nullptr, true, false);
auto *ssh = cmdContainer.getIndirectHeap(NEO::HeapType::SURFACE_STATE); auto *ssh = cmdContainer.getIndirectHeap(NEO::HeapType::SURFACE_STATE);
auto bo = static_cast<DrmAllocation *>(ssh->getGraphicsAllocation())->getBO(); auto bo = static_cast<DrmAllocation *>(ssh->getGraphicsAllocation())->getBO();

View File

@@ -1135,6 +1135,7 @@ HWTEST_TEMPLATED_F(WddmCommandStreamMockGdiTest, givenDirectSubmissionEnabledOnR
auto mockCsr = static_cast<MockWddmCsr<FamilyType> *>(csr); auto mockCsr = static_cast<MockWddmCsr<FamilyType> *>(csr);
DebugManager.flags.EnableDirectSubmission.set(1); DebugManager.flags.EnableDirectSubmission.set(1);
DebugManager.flags.DirectSubmissionFlatRingBuffer.set(0);
auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo(); auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo();
hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_RCS].engineSupported = true; hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_RCS].engineSupported = true;
@@ -1178,6 +1179,7 @@ HWTEST_TEMPLATED_F(WddmCommandStreamMockGdiTest, givenDirectSubmissionEnabledOnB
auto mockCsr = static_cast<MockWddmCsr<FamilyType> *>(csr); auto mockCsr = static_cast<MockWddmCsr<FamilyType> *>(csr);
DebugManager.flags.EnableDirectSubmission.set(1); DebugManager.flags.EnableDirectSubmission.set(1);
DebugManager.flags.DirectSubmissionFlatRingBuffer.set(0);
auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo(); auto hwInfo = device->getRootDeviceEnvironment().getMutableHardwareInfo();
hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_BCS].engineSupported = true; hwInfo->capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_BCS].engineSupported = true;