Do not allocate dynamic state heap if not needed

Dynamic state heap is only used for sampler data.

Related-To: NEO-6821

Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
Dominik Dabek
2022-03-28 12:55:12 +00:00
committed by Compute-Runtime-Automation
parent afd71beee9
commit 308f9ccfff
49 changed files with 639 additions and 530 deletions

View File

@@ -87,6 +87,9 @@ ErrorCode CommandContainer::initialize(Device *device, AllocationsList *reusable
if (NEO::ApiSpecificConfig::getBindlessConfiguration() && i != IndirectHeap::Type::INDIRECT_OBJECT) {
continue;
}
if (!hardwareInfo.capabilityTable.supportsImages && IndirectHeap::Type::DYNAMIC_STATE == i) {
continue;
}
allocationIndirectHeaps[i] = heapHelper->getHeapAllocation(i,
heapSize,
alignedSize,

View File

@@ -121,29 +121,30 @@ void EncodeDispatchKernel<Family>::encode(CommandContainer &container,
PreemptionHelper::programInterfaceDescriptorDataPreemption<Family>(&idd, args.preemptionMode);
auto heap = ApiSpecificConfig::getBindlessConfiguration() ? args.device->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::GLOBAL_DSH) : container.getIndirectHeap(HeapType::DYNAMIC_STATE);
UNRECOVERABLE_IF(!heap);
uint32_t samplerStateOffset = 0;
uint32_t samplerCount = 0;
if (kernelDescriptor.payloadMappings.samplerTable.numSamplers > 0) {
samplerCount = kernelDescriptor.payloadMappings.samplerTable.numSamplers;
samplerStateOffset = EncodeStates<Family>::copySamplerState(
heap, kernelDescriptor.payloadMappings.samplerTable.tableOffset,
kernelDescriptor.payloadMappings.samplerTable.numSamplers, kernelDescriptor.payloadMappings.samplerTable.borderColor,
args.dispatchInterface->getDynamicStateHeapData(),
args.device->getBindlessHeapsHelper(), hwInfo);
if (ApiSpecificConfig::getBindlessConfiguration()) {
container.getResidencyContainer().push_back(args.device->getBindlessHeapsHelper()->getHeap(NEO::BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH)->getGraphicsAllocation());
}
}
if constexpr (Family::supportsSampler) {
idd.setSamplerStatePointer(samplerStateOffset);
}
auto heap = ApiSpecificConfig::getBindlessConfiguration() ? args.device->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::GLOBAL_DSH) : container.getIndirectHeap(HeapType::DYNAMIC_STATE);
UNRECOVERABLE_IF(!heap);
EncodeDispatchKernel<Family>::adjustBindingTablePrefetch(idd, samplerCount, bindingTableStateCount);
uint32_t samplerStateOffset = 0;
uint32_t samplerCount = 0;
if (kernelDescriptor.payloadMappings.samplerTable.numSamplers > 0) {
samplerCount = kernelDescriptor.payloadMappings.samplerTable.numSamplers;
samplerStateOffset = EncodeStates<Family>::copySamplerState(
heap, kernelDescriptor.payloadMappings.samplerTable.tableOffset,
kernelDescriptor.payloadMappings.samplerTable.numSamplers, kernelDescriptor.payloadMappings.samplerTable.borderColor,
args.dispatchInterface->getDynamicStateHeapData(),
args.device->getBindlessHeapsHelper(), hwInfo);
if (ApiSpecificConfig::getBindlessConfiguration()) {
container.getResidencyContainer().push_back(args.device->getBindlessHeapsHelper()->getHeap(NEO::BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH)->getGraphicsAllocation());
}
}
idd.setSamplerStatePointer(samplerStateOffset);
EncodeDispatchKernel<Family>::adjustBindingTablePrefetch(idd, samplerCount, bindingTableStateCount);
} else {
EncodeDispatchKernel<Family>::adjustBindingTablePrefetch(idd, 0u, bindingTableStateCount);
}
uint64_t offsetThreadData = 0u;
const uint32_t inlineDataSize = sizeof(INLINE_DATA);

View File

@@ -82,7 +82,7 @@ class CommandStreamReceiver {
virtual SubmissionStatus flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) = 0;
virtual CompletionStamp flushTask(LinearStream &commandStream, size_t commandStreamStart,
const IndirectHeap &dsh, const IndirectHeap &ioh, const IndirectHeap &ssh,
const IndirectHeap *dsh, const IndirectHeap *ioh, const IndirectHeap *ssh,
uint32_t taskLevel, DispatchFlags &dispatchFlags, Device &device) = 0;
virtual bool flushBatchedSubmissions() = 0;

View File

@@ -43,7 +43,7 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
SubmissionStatus flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
CompletionStamp flushTask(LinearStream &commandStream, size_t commandStreamStart,
const IndirectHeap &dsh, const IndirectHeap &ioh, const IndirectHeap &ssh,
const IndirectHeap *dsh, const IndirectHeap *ioh, const IndirectHeap *ssh,
uint32_t taskLevel, DispatchFlags &dispatchFlags, Device &device) override;
void forcePipeControl(NEO::LinearStream &commandStreamCSR);
@@ -83,9 +83,9 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
void collectStateBaseAddresPatchInfo(
uint64_t commandBufferAddress,
uint64_t commandOffset,
const LinearStream &dsh,
const LinearStream &ioh,
const LinearStream &ssh,
const LinearStream *dsh,
const LinearStream *ioh,
const LinearStream *ssh,
uint64_t generalStateBase);
void collectStateBaseAddresIohPatchInfo(uint64_t commandBufferAddress, uint64_t commandOffset, const LinearStream &ioh);

View File

@@ -157,9 +157,9 @@ template <typename GfxFamily>
CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
LinearStream &commandStreamTask,
size_t commandStreamStartTask,
const IndirectHeap &dsh,
const IndirectHeap &ioh,
const IndirectHeap &ssh,
const IndirectHeap *dsh,
const IndirectHeap *ioh,
const IndirectHeap *ssh,
uint32_t taskLevel,
DispatchFlags &dispatchFlags,
Device &device) {
@@ -272,7 +272,7 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
bool checkVfeStateDirty = false;
if (requiredScratchSize || requiredPrivateScratchSize) {
scratchSpaceController->setRequiredScratchSpace(ssh.getCpuBase(),
scratchSpaceController->setRequiredScratchSpace(ssh->getCpuBase(),
0u,
requiredScratchSize,
requiredPrivateScratchSize,
@@ -337,10 +337,10 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
if (stallingCommandsOnNextFlushRequired) {
programStallingCommandsForBarrier(commandStreamCSR, dispatchFlags);
}
bool dshDirty = dshState.updateAndCheck(&dsh);
bool iohDirty = iohState.updateAndCheck(&ioh);
bool sshDirty = sshState.updateAndCheck(&ssh);
const bool hasDsh = hwInfo.capabilityTable.supportsImages;
bool dshDirty = hasDsh ? dshState.updateAndCheck(dsh) : false;
bool iohDirty = iohState.updateAndCheck(ioh);
bool sshDirty = sshState.updateAndCheck(ssh);
auto isStateBaseAddressDirty = dshDirty || iohDirty || sshDirty || stateBaseAddressDirty;
@@ -394,13 +394,13 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
auto instructionHeapBaseAddress = getMemoryManager()->getInternalHeapBaseAddress(rootDeviceIndex, getMemoryManager()->isLocalMemoryUsedForIsa(rootDeviceIndex));
StateBaseAddressHelper<GfxFamily>::programStateBaseAddress(
&cmd,
&dsh,
&ioh,
&ssh,
dsh,
ioh,
ssh,
newGSHbase,
true,
mocsIndex,
getMemoryManager()->getInternalHeapBaseAddress(rootDeviceIndex, ioh.getGraphicsAllocation()->isAllocatedInLocalMemoryPool()),
getMemoryManager()->getInternalHeapBaseAddress(rootDeviceIndex, ioh->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()),
instructionHeapBaseAddress,
0,
true,
@@ -419,7 +419,7 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
}
if (bindingTableBaseAddressRequired) {
StateBaseAddressHelper<GfxFamily>::programBindingTableBaseAddress(commandStreamCSR, ssh, device.getGmmHelper());
StateBaseAddressHelper<GfxFamily>::programBindingTableBaseAddress(commandStreamCSR, *ssh, device.getGmmHelper());
bindingTableBaseAddressRequired = false;
}
@@ -478,13 +478,14 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
if (DebugManager.flags.ForcePipeControlPriorToWalker.get()) {
forcePipeControl(commandStreamCSR);
}
if (hasDsh) {
auto dshAllocation = dsh->getGraphicsAllocation();
this->makeResident(*dshAllocation);
dshAllocation->setEvictable(false);
}
auto iohAllocation = ioh->getGraphicsAllocation();
auto sshAllocation = ssh->getGraphicsAllocation();
auto dshAllocation = dsh.getGraphicsAllocation();
auto iohAllocation = ioh.getGraphicsAllocation();
auto sshAllocation = ssh.getGraphicsAllocation();
this->makeResident(*dshAllocation);
dshAllocation->setEvictable(false);
this->makeResident(*iohAllocation);
this->makeResident(*sshAllocation);
iohAllocation->setEvictable(false);
@@ -952,21 +953,22 @@ template <typename GfxFamily>
void CommandStreamReceiverHw<GfxFamily>::collectStateBaseAddresPatchInfo(
uint64_t baseAddress,
uint64_t commandOffset,
const LinearStream &dsh,
const LinearStream &ioh,
const LinearStream &ssh,
const LinearStream *dsh,
const LinearStream *ioh,
const LinearStream *ssh,
uint64_t generalStateBase) {
typedef typename GfxFamily::STATE_BASE_ADDRESS STATE_BASE_ADDRESS;
PatchInfoData dynamicStatePatchInfo = {dsh.getGraphicsAllocation()->getGpuAddress(), 0u, PatchInfoAllocationType::DynamicStateHeap, baseAddress, commandOffset + STATE_BASE_ADDRESS::PATCH_CONSTANTS::DYNAMICSTATEBASEADDRESS_BYTEOFFSET, PatchInfoAllocationType::Default};
if constexpr (GfxFamily::supportsSampler) {
PatchInfoData dynamicStatePatchInfo = {dsh->getGraphicsAllocation()->getGpuAddress(), 0u, PatchInfoAllocationType::DynamicStateHeap, baseAddress, commandOffset + STATE_BASE_ADDRESS::PATCH_CONSTANTS::DYNAMICSTATEBASEADDRESS_BYTEOFFSET, PatchInfoAllocationType::Default};
flatBatchBufferHelper->setPatchInfoData(dynamicStatePatchInfo);
}
PatchInfoData generalStatePatchInfo = {generalStateBase, 0u, PatchInfoAllocationType::GeneralStateHeap, baseAddress, commandOffset + STATE_BASE_ADDRESS::PATCH_CONSTANTS::GENERALSTATEBASEADDRESS_BYTEOFFSET, PatchInfoAllocationType::Default};
PatchInfoData surfaceStatePatchInfo = {ssh.getGraphicsAllocation()->getGpuAddress(), 0u, PatchInfoAllocationType::SurfaceStateHeap, baseAddress, commandOffset + STATE_BASE_ADDRESS::PATCH_CONSTANTS::SURFACESTATEBASEADDRESS_BYTEOFFSET, PatchInfoAllocationType::Default};
PatchInfoData surfaceStatePatchInfo = {ssh->getGraphicsAllocation()->getGpuAddress(), 0u, PatchInfoAllocationType::SurfaceStateHeap, baseAddress, commandOffset + STATE_BASE_ADDRESS::PATCH_CONSTANTS::SURFACESTATEBASEADDRESS_BYTEOFFSET, PatchInfoAllocationType::Default};
flatBatchBufferHelper->setPatchInfoData(dynamicStatePatchInfo);
flatBatchBufferHelper->setPatchInfoData(generalStatePatchInfo);
flatBatchBufferHelper->setPatchInfoData(surfaceStatePatchInfo);
collectStateBaseAddresIohPatchInfo(baseAddress, commandOffset, ioh);
collectStateBaseAddresIohPatchInfo(baseAddress, commandOffset, *ioh);
}
template <typename GfxFamily>

View File

@@ -161,7 +161,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
}
CompletionStamp flushTask(LinearStream &commandStream, size_t commandStreamStart,
const IndirectHeap &dsh, const IndirectHeap &ioh, const IndirectHeap &ssh,
const IndirectHeap *dsh, const IndirectHeap *ioh, const IndirectHeap *ssh,
uint32_t taskLevel, DispatchFlags &dispatchFlags, Device &device) override {
recordedDispatchFlags = dispatchFlags;
this->lastFlushedCommandStream = &commandStream;

View File

@@ -62,7 +62,7 @@ struct MockAubCsr : public AUBCommandStreamReceiverHw<GfxFamily> {
using AUBCommandStreamReceiverHw<GfxFamily>::AUBCommandStreamReceiverHw;
CompletionStamp flushTask(LinearStream &commandStream, size_t commandStreamStart,
const IndirectHeap &dsh, const IndirectHeap &ioh, const IndirectHeap &ssh,
const IndirectHeap *dsh, const IndirectHeap *ioh, const IndirectHeap *ssh,
uint32_t taskLevel, DispatchFlags &dispatchFlags, Device &device) override {
recordedDispatchFlags = dispatchFlags;

View File

@@ -16,9 +16,9 @@ SubmissionStatus MockCommandStreamReceiver::flush(BatchBuffer &batchBuffer, Resi
CompletionStamp MockCommandStreamReceiver::flushTask(
LinearStream &commandStream,
size_t commandStreamStart,
const IndirectHeap &dsh,
const IndirectHeap &ioh,
const IndirectHeap &ssh,
const IndirectHeap *dsh,
const IndirectHeap *ioh,
const IndirectHeap *ssh,
uint32_t taskLevel,
DispatchFlags &dispatchFlags,
Device &device) {

View File

@@ -90,9 +90,9 @@ class MockCommandStreamReceiver : public CommandStreamReceiver {
CompletionStamp flushTask(
LinearStream &commandStream,
size_t commandStreamStart,
const IndirectHeap &dsh,
const IndirectHeap &ioh,
const IndirectHeap &ssh,
const IndirectHeap *dsh,
const IndirectHeap *ioh,
const IndirectHeap *ssh,
uint32_t taskLevel,
DispatchFlags &dispatchFlags,
Device &device) override;
@@ -251,8 +251,8 @@ class MockCsrHw2 : public CommandStreamReceiverHw<GfxFamily> {
}
CompletionStamp flushTask(LinearStream &commandStream, size_t commandStreamStart,
const IndirectHeap &dsh, const IndirectHeap &ioh,
const IndirectHeap &ssh, uint32_t taskLevel, DispatchFlags &dispatchFlags, Device &device) override {
const IndirectHeap *dsh, const IndirectHeap *ioh,
const IndirectHeap *ssh, uint32_t taskLevel, DispatchFlags &dispatchFlags, Device &device) override {
passedDispatchFlags = dispatchFlags;
recordedCommandBuffer = std::unique_ptr<CommandBuffer>(new CommandBuffer(device));

View File

@@ -116,9 +116,9 @@ class MockCsr : public MockCsrBase<GfxFamily> {
CompletionStamp flushTask(
LinearStream &commandStream,
size_t commandStreamStart,
const IndirectHeap &dsh,
const IndirectHeap &ioh,
const IndirectHeap &ssh,
const IndirectHeap *dsh,
const IndirectHeap *ioh,
const IndirectHeap *ssh,
uint32_t taskLevel,
DispatchFlags &dispatchFlags,
Device &device) override {

View File

@@ -106,13 +106,16 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenAllocatingHeapsThenSetCorrectA
for (uint32_t i = 0; i < HeapType::NUM_TYPES; i++) {
HeapType heapType = static_cast<HeapType>(i);
auto heap = cmdContainer.getIndirectHeap(heapType);
if (HeapType::INDIRECT_OBJECT == heapType) {
EXPECT_EQ(AllocationType::INTERNAL_HEAP, heap->getGraphicsAllocation()->getAllocationType());
EXPECT_NE(0u, heap->getHeapGpuStartOffset());
if (!pDevice->getHardwareInfo().capabilityTable.supportsImages && HeapType::DYNAMIC_STATE == heapType) {
EXPECT_EQ(heap, nullptr);
} else {
EXPECT_EQ(AllocationType::LINEAR_STREAM, heap->getGraphicsAllocation()->getAllocationType());
EXPECT_EQ(0u, heap->getHeapGpuStartOffset());
if (HeapType::INDIRECT_OBJECT == heapType) {
EXPECT_EQ(AllocationType::INTERNAL_HEAP, heap->getGraphicsAllocation()->getAllocationType());
EXPECT_NE(0u, heap->getHeapGpuStartOffset());
} else {
EXPECT_EQ(AllocationType::LINEAR_STREAM, heap->getGraphicsAllocation()->getAllocationType());
EXPECT_EQ(0u, heap->getHeapGpuStartOffset());
}
}
}
}
@@ -128,9 +131,14 @@ TEST_F(CommandContainerTest, givenCommandContainerWhenInitializeThenEverythingIs
EXPECT_NE(cmdContainer.getCommandStream(), nullptr);
for (uint32_t i = 0; i < HeapType::NUM_TYPES; i++) {
auto indirectHeap = cmdContainer.getIndirectHeap(static_cast<HeapType>(i));
auto heapAllocation = cmdContainer.getIndirectHeapAllocation(static_cast<HeapType>(i));
EXPECT_EQ(indirectHeap->getGraphicsAllocation(), heapAllocation);
auto heapType = static_cast<HeapType>(i);
auto indirectHeap = cmdContainer.getIndirectHeap(heapType);
if (!pDevice->getHardwareInfo().capabilityTable.supportsImages && HeapType::DYNAMIC_STATE == heapType) {
EXPECT_EQ(indirectHeap, nullptr);
} else {
auto heapAllocation = cmdContainer.getIndirectHeapAllocation(heapType);
EXPECT_EQ(indirectHeap->getGraphicsAllocation(), heapAllocation);
}
}
EXPECT_EQ(cmdContainer.getIddBlock(), nullptr);
@@ -247,12 +255,17 @@ TEST_F(CommandContainerTest, givenCommandContainerWhenSettingIndirectHeapAllocat
TEST_F(CommandContainerTest, givenHeapAllocationsWhenDestroyCommandContainerThenHeapAllocationsAreReused) {
std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer);
cmdContainer->initialize(pDevice, nullptr, true);
auto heapAllocationsAddress = cmdContainer->getIndirectHeapAllocation(HeapType::DYNAMIC_STATE)->getUnderlyingBuffer();
auto heapAllocationsAddress = cmdContainer->getIndirectHeapAllocation(HeapType::SURFACE_STATE)->getUnderlyingBuffer();
cmdContainer.reset(new CommandContainer);
cmdContainer->initialize(pDevice, nullptr, true);
bool status = false;
bool status = true;
for (uint32_t i = 0; i < HeapType::NUM_TYPES && !status; i++) {
status = cmdContainer->getIndirectHeapAllocation(static_cast<HeapType>(i))->getUnderlyingBuffer() == heapAllocationsAddress;
auto heapType = static_cast<HeapType>(i);
if (!pDevice->getHardwareInfo().capabilityTable.supportsImages && HeapType::DYNAMIC_STATE == heapType) {
status = status && cmdContainer->getIndirectHeapAllocation(heapType) == nullptr;
} else {
status = status && cmdContainer->getIndirectHeapAllocation(heapType)->getUnderlyingBuffer() == heapAllocationsAddress;
}
}
EXPECT_TRUE(status);
}
@@ -336,30 +349,34 @@ TEST_F(CommandContainerTest, givenAvailableSpaceWhenGetHeapWithRequiredSizeAndAl
std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer);
cmdContainer->initialize(pDevice, nullptr, true);
cmdContainer->setDirtyStateForAllHeaps(false);
HeapType types[] = {HeapType::SURFACE_STATE,
HeapType::DYNAMIC_STATE};
HeapType heapTypes[] = {HeapType::SURFACE_STATE,
HeapType::DYNAMIC_STATE};
for (auto type : types) {
auto heapAllocation = cmdContainer->getIndirectHeapAllocation(type);
auto heap = cmdContainer->getIndirectHeap(type);
for (auto heapType : heapTypes) {
auto heapAllocation = cmdContainer->getIndirectHeapAllocation(heapType);
auto heap = cmdContainer->getIndirectHeap(heapType);
const size_t sizeRequested = 32;
const size_t alignment = 32;
if (!pDevice->getHardwareInfo().capabilityTable.supportsImages && HeapType::DYNAMIC_STATE == heapType) {
EXPECT_EQ(heap, nullptr);
} else {
const size_t sizeRequested = 32;
const size_t alignment = 32;
EXPECT_GE(heap->getAvailableSpace(), sizeRequested + alignment);
auto sizeBefore = heap->getUsed();
EXPECT_GE(heap->getAvailableSpace(), sizeRequested + alignment);
auto sizeBefore = heap->getUsed();
auto heapRequested = cmdContainer->getHeapWithRequiredSizeAndAlignment(type, sizeRequested, alignment);
auto newAllocation = heapRequested->getGraphicsAllocation();
auto heapRequested = cmdContainer->getHeapWithRequiredSizeAndAlignment(heapType, sizeRequested, alignment);
auto newAllocation = heapRequested->getGraphicsAllocation();
EXPECT_EQ(heap, heapRequested);
EXPECT_EQ(heapAllocation, newAllocation);
EXPECT_EQ(heap, heapRequested);
EXPECT_EQ(heapAllocation, newAllocation);
EXPECT_TRUE((reinterpret_cast<size_t>(heapRequested->getSpace(0)) & (alignment - 1)) == 0);
EXPECT_FALSE(cmdContainer->isHeapDirty(type));
EXPECT_TRUE((reinterpret_cast<size_t>(heapRequested->getSpace(0)) & (alignment - 1)) == 0);
EXPECT_FALSE(cmdContainer->isHeapDirty(heapType));
auto sizeAfter = heapRequested->getUsed();
EXPECT_EQ(sizeBefore, sizeAfter);
auto sizeAfter = heapRequested->getUsed();
EXPECT_EQ(sizeBefore, sizeAfter);
}
}
}
@@ -415,29 +432,33 @@ TEST_F(CommandContainerTest, givenNotEnoughSpaceWhenGetHeapWithRequiredSizeAndAl
std::unique_ptr<CommandContainer> cmdContainer(new CommandContainer);
cmdContainer->initialize(pDevice, nullptr, true);
cmdContainer->setDirtyStateForAllHeaps(false);
HeapType types[] = {HeapType::SURFACE_STATE,
HeapType::DYNAMIC_STATE};
HeapType heapTypes[] = {HeapType::SURFACE_STATE,
HeapType::DYNAMIC_STATE};
for (auto type : types) {
auto heapAllocation = cmdContainer->getIndirectHeapAllocation(type);
auto heap = cmdContainer->getIndirectHeap(type);
for (auto heapType : heapTypes) {
auto heapAllocation = cmdContainer->getIndirectHeapAllocation(heapType);
auto heap = cmdContainer->getIndirectHeap(heapType);
const size_t sizeRequested = 32;
const size_t alignment = 32;
size_t availableSize = heap->getAvailableSpace();
if (!pDevice->getHardwareInfo().capabilityTable.supportsImages && HeapType::DYNAMIC_STATE == heapType) {
EXPECT_EQ(heap, nullptr);
} else {
const size_t sizeRequested = 32;
const size_t alignment = 32;
size_t availableSize = heap->getAvailableSpace();
heap->getSpace(availableSize - sizeRequested / 2);
heap->getSpace(availableSize - sizeRequested / 2);
EXPECT_LT(heap->getAvailableSpace(), sizeRequested + alignment);
EXPECT_LT(heap->getAvailableSpace(), sizeRequested + alignment);
auto heapRequested = cmdContainer->getHeapWithRequiredSizeAndAlignment(type, sizeRequested, alignment);
auto newAllocation = heapRequested->getGraphicsAllocation();
auto heapRequested = cmdContainer->getHeapWithRequiredSizeAndAlignment(heapType, sizeRequested, alignment);
auto newAllocation = heapRequested->getGraphicsAllocation();
EXPECT_EQ(heap, heapRequested);
EXPECT_NE(heapAllocation, newAllocation);
EXPECT_EQ(heap, heapRequested);
EXPECT_NE(heapAllocation, newAllocation);
EXPECT_TRUE((reinterpret_cast<size_t>(heapRequested->getSpace(0)) & (alignment - 1)) == 0);
EXPECT_TRUE(cmdContainer->isHeapDirty(type));
EXPECT_TRUE((reinterpret_cast<size_t>(heapRequested->getSpace(0)) & (alignment - 1)) == 0);
EXPECT_TRUE(cmdContainer->isHeapDirty(heapType));
}
}
for (auto deallocation : cmdContainer->getDeallocationContainer()) {
cmdContainer->getDevice()->getMemoryManager()->freeGraphicsMemory(deallocation);
@@ -549,40 +570,49 @@ INSTANTIATE_TEST_CASE_P(
IndirectHeap::Type::SURFACE_STATE));
TEST_P(CommandContainerHeaps, givenCommandContainerWhenGetAllowHeapGrowCalledThenHeapIsReturned) {
HeapType heap = GetParam();
HeapType heapType = GetParam();
CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true);
auto usedSpaceBefore = cmdContainer.getIndirectHeap(heap)->getUsed();
size_t size = 5000;
void *ptr = cmdContainer.getHeapSpaceAllowGrow(heap, size);
ASSERT_NE(nullptr, ptr);
auto usedSpaceAfter = cmdContainer.getIndirectHeap(heap)->getUsed();
ASSERT_EQ(usedSpaceBefore + size, usedSpaceAfter);
cmdContainer.initialize(pDevice, nullptr, true);
if (!pDevice->getHardwareInfo().capabilityTable.supportsImages && HeapType::DYNAMIC_STATE == heapType) {
EXPECT_EQ(cmdContainer.getIndirectHeap(heapType), nullptr);
} else {
auto usedSpaceBefore = cmdContainer.getIndirectHeap(heapType)->getUsed();
size_t size = 5000;
void *ptr = cmdContainer.getHeapSpaceAllowGrow(heapType, size);
ASSERT_NE(nullptr, ptr);
auto usedSpaceAfter = cmdContainer.getIndirectHeap(heapType)->getUsed();
ASSERT_EQ(usedSpaceBefore + size, usedSpaceAfter);
}
}
TEST_P(CommandContainerHeaps, givenCommandContainerWhenGetingMoreThanAvailableSizeThenBiggerHeapIsReturned) {
HeapType heap = GetParam();
HeapType heapType = GetParam();
CommandContainer cmdContainer;
cmdContainer.initialize(pDevice, nullptr, true);
cmdContainer.setDirtyStateForAllHeaps(false);
auto heap = cmdContainer.getIndirectHeap(heapType);
if (!pDevice->getHardwareInfo().capabilityTable.supportsImages && HeapType::DYNAMIC_STATE == heapType) {
EXPECT_EQ(heap, nullptr);
} else {
auto usedSpaceBefore = heap->getUsed();
auto availableSizeBefore = heap->getAvailableSpace();
auto usedSpaceBefore = cmdContainer.getIndirectHeap(heap)->getUsed();
auto availableSizeBefore = cmdContainer.getIndirectHeap(heap)->getAvailableSpace();
void *ptr = cmdContainer.getHeapSpaceAllowGrow(heapType, availableSizeBefore + 1);
ASSERT_NE(nullptr, ptr);
void *ptr = cmdContainer.getHeapSpaceAllowGrow(heap, availableSizeBefore + 1);
ASSERT_NE(nullptr, ptr);
auto usedSpaceAfter = cmdContainer.getIndirectHeap(heap)->getUsed();
auto availableSizeAfter = cmdContainer.getIndirectHeap(heap)->getAvailableSpace();
EXPECT_GT(usedSpaceAfter + availableSizeAfter, usedSpaceBefore + availableSizeBefore);
EXPECT_EQ(!cmdContainer.isHeapDirty(heap), heap == IndirectHeap::Type::INDIRECT_OBJECT);
auto usedSpaceAfter = heap->getUsed();
auto availableSizeAfter = heap->getAvailableSpace();
EXPECT_GT(usedSpaceAfter + availableSizeAfter, usedSpaceBefore + availableSizeBefore);
EXPECT_EQ(!cmdContainer.isHeapDirty(heapType), heapType == IndirectHeap::Type::INDIRECT_OBJECT);
}
}
TEST_P(CommandContainerHeaps, givenCommandContainerForDifferentRootDevicesThenHeapsAreCreatedWithCorrectRootDeviceIndex) {
HeapType heap = GetParam();
HeapType heapType = GetParam();
auto executionEnvironment = new NEO::ExecutionEnvironment();
const size_t numDevices = 2;
@@ -595,13 +625,19 @@ TEST_P(CommandContainerHeaps, givenCommandContainerForDifferentRootDevicesThenHe
CommandContainer cmdContainer0;
cmdContainer0.initialize(device0.get(), nullptr, true);
uint32_t heapRootDeviceIndex0 = cmdContainer0.getIndirectHeap(heap)->getGraphicsAllocation()->getRootDeviceIndex();
EXPECT_EQ(device0->getRootDeviceIndex(), heapRootDeviceIndex0);
CommandContainer cmdContainer1;
cmdContainer1.initialize(device1.get(), nullptr, true);
uint32_t heapRootDeviceIndex1 = cmdContainer1.getIndirectHeap(heap)->getGraphicsAllocation()->getRootDeviceIndex();
EXPECT_EQ(device1->getRootDeviceIndex(), heapRootDeviceIndex1);
if (!pDevice->getHardwareInfo().capabilityTable.supportsImages && HeapType::DYNAMIC_STATE == heapType) {
EXPECT_EQ(cmdContainer0.getIndirectHeap(heapType), nullptr);
EXPECT_EQ(cmdContainer1.getIndirectHeap(heapType), nullptr);
} else {
uint32_t heapRootDeviceIndex0 = cmdContainer0.getIndirectHeap(heapType)->getGraphicsAllocation()->getRootDeviceIndex();
EXPECT_EQ(device0->getRootDeviceIndex(), heapRootDeviceIndex0);
uint32_t heapRootDeviceIndex1 = cmdContainer1.getIndirectHeap(heapType)->getGraphicsAllocation()->getRootDeviceIndex();
EXPECT_EQ(device1->getRootDeviceIndex(), heapRootDeviceIndex1);
}
}
TEST_F(CommandContainerHeaps, givenCommandContainerForDifferentRootDevicesThenCmdBufferAllocationIsCreatedWithCorrectRootDeviceIndex) {

View File

@@ -215,7 +215,7 @@ HWTEST2_F(ComputeModeRequirements, givenCoherencyRequirementWithoutSharedHandles
auto flushTask = [&](bool coherencyRequired) {
flags.requiresCoherency = coherencyRequired;
startOffset = getCsrHw<FamilyType>()->commandStream.getUsed();
csr->flushTask(stream, 0, stream, stream, stream, 0, flags, *device);
csr->flushTask(stream, 0, &stream, &stream, &stream, 0, flags, *device);
};
auto findCmd = [&](bool expectToBeProgrammed, bool expectCoherent) {
@@ -274,7 +274,7 @@ HWTEST2_F(ComputeModeRequirements, givenCoherencyRequirementWithSharedHandlesWhe
makeResidentSharedAlloc();
startOffset = getCsrHw<FamilyType>()->commandStream.getUsed();
csr->flushTask(stream, 0, stream, stream, stream, 0, flags, *device);
csr->flushTask(stream, 0, &stream, &stream, &stream, 0, flags, *device);
};
auto flushTaskAndFindCmds = [&](bool expectCoherent, bool areCommandsProgrammed) {
@@ -319,11 +319,11 @@ HWTEST2_F(ComputeModeRequirements, givenFlushWithoutSharedHandlesWhenPreviouslyU
IndirectHeap stream(graphicAlloc);
makeResidentSharedAlloc();
csr->flushTask(stream, 0, stream, stream, stream, 0, flags, *device);
csr->flushTask(stream, 0, &stream, &stream, &stream, 0, flags, *device);
EXPECT_TRUE(getCsrHw<FamilyType>()->getCsrRequestFlags()->hasSharedHandles);
auto startOffset = getCsrHw<FamilyType>()->commandStream.getUsed();
csr->flushTask(stream, 0, stream, stream, stream, 0, flags, *device);
csr->flushTask(stream, 0, &stream, &stream, &stream, 0, flags, *device);
EXPECT_TRUE(getCsrHw<FamilyType>()->getCsrRequestFlags()->hasSharedHandles);
HardwareParse hwParser;

View File

@@ -1190,7 +1190,11 @@ HWTEST_F(BindlessCommandEncodeStatesContainerTest, givenBindlessModeEnabledWhenD
EXPECT_EQ(sshBefore, sshAfter);
}
HWTEST_F(BindlessCommandEncodeStatesTest, givenGlobalBindlessHeapsWhenDispatchingKernelWithSamplerThenGlobalDshInResidnecyContainer) {
HWTEST_F(BindlessCommandEncodeStatesTest, givenGlobalBindlessHeapsWhenDispatchingKernelWithSamplerThenGlobalDshInResidencyContainer) {
bool deviceUsesDsh = pDevice->getHardwareInfo().capabilityTable.supportsImages;
if (!deviceUsesDsh) {
GTEST_SKIP();
}
DebugManagerStateRestore restorer;
DebugManager.flags.UseBindlessMode.set(1);
auto cmdContainer = std::make_unique<CommandContainer>();

View File

@@ -24,6 +24,10 @@ using namespace NEO;
using CommandEncodeStatesTest = Test<CommandEncodeStatesFixture>;
HWTEST_F(CommandEncodeStatesTest, GivenCommandStreamWhenEncodeCopySamplerStateThenIndirectStatePointerIsCorrect) {
bool deviceUsesDsh = pDevice->getHardwareInfo().capabilityTable.supportsImages;
if (!deviceUsesDsh) {
GTEST_SKIP();
}
using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE;
uint32_t numSamplers = 1;
SAMPLER_STATE samplerState;
@@ -37,6 +41,10 @@ HWTEST_F(CommandEncodeStatesTest, GivenCommandStreamWhenEncodeCopySamplerStateTh
}
HWTEST2_F(CommandEncodeStatesTest, givenDebugVariableSetWhenCopyingSamplerStateThenSetLowQualityFilterMode, IsAtLeastGen12lp) {
bool deviceUsesDsh = pDevice->getHardwareInfo().capabilityTable.supportsImages;
if (!deviceUsesDsh) {
GTEST_SKIP();
}
using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE;
DebugManagerStateRestore restore;
@@ -301,7 +309,11 @@ HWTEST2_F(CommandEncodeStatesTest, givenCommandContainerWithDirtyHeapsWhenSetSta
auto itorCmd = find<STATE_BASE_ADDRESS *>(commands.begin(), commands.end());
auto pCmd = genCmdCast<STATE_BASE_ADDRESS *>(*itorCmd);
EXPECT_EQ(dsh->getHeapGpuBase(), pCmd->getDynamicStateBaseAddress());
if constexpr (FamilyType::supportsSampler) {
EXPECT_EQ(dsh->getHeapGpuBase(), pCmd->getDynamicStateBaseAddress());
} else {
EXPECT_EQ(dsh, nullptr);
}
EXPECT_EQ(ssh->getHeapGpuBase(), pCmd->getSurfaceStateBaseAddress());
EXPECT_EQ(sba.getDynamicStateBaseAddress(), pCmd->getDynamicStateBaseAddress());
@@ -332,8 +344,11 @@ HWTEST_F(CommandEncodeStatesTest, givenCommandContainerWhenSetStateBaseAddressCa
ASSERT_NE(itorCmd, commands.end());
auto cmd = genCmdCast<STATE_BASE_ADDRESS *>(*itorCmd);
EXPECT_NE(dsh->getHeapGpuBase(), cmd->getDynamicStateBaseAddress());
if constexpr (FamilyType::supportsSampler) {
EXPECT_NE(dsh->getHeapGpuBase(), cmd->getDynamicStateBaseAddress());
} else {
EXPECT_EQ(dsh, nullptr);
}
EXPECT_NE(ssh->getHeapGpuBase(), cmd->getSurfaceStateBaseAddress());
}

View File

@@ -326,9 +326,9 @@ HWCMDTEST_F(IGFX_GEN8_CORE, MidThreadPreemptionTests, givenDirtyCsrStateWhenStat
csr.flushTask(commandStream,
0,
*heap.get(),
*heap.get(),
*heap.get(),
heap.get(),
heap.get(),
heap.get(),
0,
dispatchFlags,
*mockDevice);
@@ -376,9 +376,9 @@ HWCMDTEST_F(IGFX_GEN8_CORE, MidThreadPreemptionTests, WhenProgrammingPreemptionT
csr.flushTask(commandStream,
0,
*heap.get(),
*heap.get(),
*heap.get(),
heap.get(),
heap.get(),
heap.get(),
0,
dispatchFlags,
*mockDevice);

View File

@@ -165,7 +165,7 @@ HWTEST2_F(XeHpcComputeModeRequirements, giventhreadArbitrationPolicyWithoutShare
getCsrHw<FamilyType>()->streamProperties.stateComputeMode.threadArbitrationPolicy.value = -1;
}
startOffset = getCsrHw<FamilyType>()->commandStream.getUsed();
csr->flushTask(stream, 0, stream, stream, stream, 0, flags, *device);
csr->flushTask(stream, 0, &stream, &stream, &stream, 0, flags, *device);
};
auto findCmd = [&](bool expectToBeProgrammed) {