Program sba for global bindless heaps

Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
Maciej Plewka
2020-12-04 11:28:18 +00:00
committed by Compute-Runtime-Automation
parent b9aee10679
commit 3ca77a6cbe
24 changed files with 570 additions and 86 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -11,6 +11,7 @@
#include "shared/source/command_stream/linear_stream.h"
#include "shared/source/command_stream/preemption.h"
#include "shared/source/device/device.h"
#include "shared/source/helpers/api_specific_config.h"
#include "shared/source/helpers/blit_commands_helper.h"
#include "shared/source/helpers/heap_helper.h"
#include "shared/source/helpers/hw_helper.h"
@@ -70,7 +71,10 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::reset() {
containsStatelessUncachedResource = false;
if (!isCopyOnly()) {
programStateBaseAddress(commandContainer, true);
if (!NEO::ApiSpecificConfig::getBindlessConfiguration()) {
programStateBaseAddress(commandContainer, false);
}
commandContainer.setDirtyStateForAllHeaps(false);
programThreadArbitrationPolicy(device);
}
@@ -89,7 +93,10 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::initialize(Device *device, NEO
ze_result_t returnType = parseErrorCode(returnValue);
if (returnType == ZE_RESULT_SUCCESS) {
if (!isCopyOnly()) {
programStateBaseAddress(commandContainer, false);
if (!NEO::ApiSpecificConfig::getBindlessConfiguration()) {
programStateBaseAddress(commandContainer, false);
}
commandContainer.setDirtyStateForAllHeaps(false);
programThreadArbitrationPolicy(device);
}
}
@@ -1701,7 +1708,6 @@ void CommandListCoreFamily<gfxCoreFamily>::programStateBaseAddress(NEO::CommandC
device->getL0Debugger()->captureStateBaseAddress(commandContainer, sbaAddresses);
}
commandContainer.setDirtyStateForAllHeaps(false);
}
} // namespace L0

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -35,7 +35,7 @@ struct CommandQueueHw : public CommandQueueImp {
void dispatchTaskCountWrite(NEO::LinearStream &commandStream, bool flushDataCache) override;
void programGeneralStateBaseAddress(uint64_t gsba, bool useLocalMemoryForIndirectHeap, NEO::LinearStream &commandStream);
void programStateBaseAddress(uint64_t gsba, bool useLocalMemoryForIndirectHeap, NEO::LinearStream &commandStream);
size_t estimateStateBaseAddressCmdSize();
MOCKABLE_VIRTUAL void programFrontEnd(uint64_t scratchAddress, NEO::LinearStream &commandStream);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -227,7 +227,7 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommandLists(
}
if (gsbaStateDirty) {
auto indirectHeap = CommandList::fromHandle(phCommandLists[0])->commandContainer.getIndirectHeap(NEO::HeapType::INDIRECT_OBJECT);
programGeneralStateBaseAddress(scratchSpaceController->calculateNewGSH(), indirectHeap->getGraphicsAllocation()->isAllocatedInLocalMemoryPool(), child);
programStateBaseAddress(scratchSpaceController->calculateNewGSH(), indirectHeap->getGraphicsAllocation()->isAllocatedInLocalMemoryPool(), child);
}
if (commandQueuePreemptionMode == NEO::PreemptionMode::Initial) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -11,6 +11,7 @@
#include "shared/source/command_stream/csr_definitions.h"
#include "shared/source/command_stream/linear_stream.h"
#include "shared/source/device/device.h"
#include "shared/source/helpers/api_specific_config.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/helpers/interlocked_max.h"
#include "shared/source/helpers/preamble.h"
@@ -28,7 +29,7 @@
namespace L0 {
template <GFXCORE_FAMILY gfxCoreFamily>
void CommandQueueHw<gfxCoreFamily>::programGeneralStateBaseAddress(uint64_t gsba, bool useLocalMemoryForIndirectHeap, NEO::LinearStream &commandStream) {
void CommandQueueHw<gfxCoreFamily>::programStateBaseAddress(uint64_t gsba, bool useLocalMemoryForIndirectHeap, NEO::LinearStream &commandStream) {
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
using STATE_BASE_ADDRESS = typename GfxFamily::STATE_BASE_ADDRESS;
using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL;
@@ -51,6 +52,12 @@ void CommandQueueHw<gfxCoreFamily>::programGeneralStateBaseAddress(uint64_t gsba
auto pSbaCmd = static_cast<STATE_BASE_ADDRESS *>(commandStream.getSpace(sizeof(STATE_BASE_ADDRESS)));
STATE_BASE_ADDRESS sbaCmd;
bool useGlobalSshAndDsh = NEO::ApiSpecificConfig::getBindlessConfiguration();
uint64_t globalHeapsBase = 0;
if (useGlobalSshAndDsh) {
globalHeapsBase = neoDevice->getBindlessHeapsHelper()->getGlobalHeapsBase();
}
NEO::StateBaseAddressHelper<GfxFamily>::programStateBaseAddress(&sbaCmd,
nullptr,
nullptr,
@@ -60,7 +67,9 @@ void CommandQueueHw<gfxCoreFamily>::programGeneralStateBaseAddress(uint64_t gsba
(device->getMOCS(true, false) >> 1),
neoDevice->getMemoryManager()->getInternalHeapBaseAddress(device->getRootDeviceIndex(), useLocalMemoryForIndirectHeap),
neoDevice->getMemoryManager()->getInternalHeapBaseAddress(device->getRootDeviceIndex(), !hwHelper.useSystemMemoryPlacementForISA(hwInfo)),
globalHeapsBase,
true,
useGlobalSshAndDsh,
neoDevice->getGmmHelper(),
false,
NEO::MemoryCompressionState::NotApplicable);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -315,6 +315,8 @@ TEST_F(CommandListCreate, givenInvalidProductFamilyThenReturnsNullPointer) {
}
HWCMDTEST_F(IGFX_GEN8_CORE, CommandListCreate, whenCommandListIsCreatedThenPCAndStateBaseAddressCmdsAreAddedAndCorrectlyProgrammed) {
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.UseBindlessMode.set(0);
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
@@ -368,6 +370,33 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandListCreate, whenCommandListIsCreatedThenPCAnd
EXPECT_EQ(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER), cmdSba->getStatelessDataPortAccessMemoryObjectControlState());
}
HWCMDTEST_F(IGFX_GEN8_CORE, CommandListCreate, whenBindlessModeEnabledWhenCommandListIsCreatedThenStateBaseAddressCmdsIsNotAdded) {
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.UseBindlessMode.set(1);
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
ze_result_t returnValue;
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, returnValue));
auto &commandContainer = commandList->commandContainer;
ASSERT_NE(nullptr, commandContainer.getCommandStream());
auto usedSpaceBefore = commandContainer.getCommandStream()->getUsed();
auto result = commandList->close();
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
auto usedSpaceAfter = commandContainer.getCommandStream()->getUsed();
ASSERT_GT(usedSpaceAfter, usedSpaceBefore);
GenCmdList cmdList;
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
cmdList, ptrOffset(commandContainer.getCommandStream()->getCpuBase(), 0), usedSpaceAfter));
auto itor = find<STATE_BASE_ADDRESS *>(cmdList.begin(), cmdList.end());
ASSERT_EQ(cmdList.end(), itor);
}
HWTEST_F(CommandListCreate, givenCommandListWithCopyOnlyWhenCreatedThenStateBaseAddressCmdIsNotProgrammed) {
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
@@ -411,6 +440,47 @@ HWTEST_F(CommandListCreate, whenCommandListIsResetThenContainsStatelessUncachedR
EXPECT_FALSE(commandList->getContainsStatelessUncachedResource());
}
HWTEST_F(CommandListCreate, givenBindlessModeEnabledWhenCommandListsResetThenSbaNotReloaded) {
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.UseBindlessMode.set(1);
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
ze_result_t returnValue;
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily,
device,
NEO::EngineGroupType::Compute,
returnValue));
EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue);
returnValue = commandList->reset();
auto usedAfter = commandList->commandContainer.getCommandStream()->getUsed();
EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue);
GenCmdList cmdList;
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
cmdList, ptrOffset(commandList->commandContainer.getCommandStream()->getCpuBase(), 0), usedAfter));
auto itor = find<STATE_BASE_ADDRESS *>(cmdList.begin(), cmdList.end());
ASSERT_EQ(cmdList.end(), itor);
}
HWTEST_F(CommandListCreate, givenBindlessModeDisabledWhenCommandListsResetThenSbaReloaded) {
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.UseBindlessMode.set(0);
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
ze_result_t returnValue;
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily,
device,
NEO::EngineGroupType::Compute,
returnValue));
EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue);
returnValue = commandList->reset();
auto usedAfter = commandList->commandContainer.getCommandStream()->getUsed();
EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue);
GenCmdList cmdList;
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
cmdList, ptrOffset(commandList->commandContainer.getCommandStream()->getCpuBase(), 0), usedAfter));
auto itor = find<STATE_BASE_ADDRESS *>(cmdList.begin(), cmdList.end());
ASSERT_NE(cmdList.end(), itor);
}
HWTEST_F(CommandListCreate, givenCommandListWithCopyOnlyWhenResetThenStateBaseAddressNotProgrammed) {
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -10,10 +10,13 @@
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/helpers/state_base_address.h"
#include "shared/source/os_interface/device_factory.h"
#include "shared/test/unit_test/cmd_parse/gen_cmd_parse.h"
#include "shared/test/unit_test/helpers/debug_manager_state_restore.h"
#include "shared/test/unit_test/helpers/default_hw_info.h"
#include "shared/test/unit_test/helpers/variable_backup.h"
#include "shared/test/unit_test/mocks/mock_bindless_heaps_helper.h"
#include "shared/test/unit_test/mocks/mock_command_stream_receiver.h"
#include "shared/test/unit_test/mocks/mock_graphics_allocation.h"
#include "opencl/test/unit_test/libult/ult_command_stream_receiver.h"
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
@@ -301,7 +304,7 @@ HWTEST2_F(CommandQueueProgramSBATest, whenCreatingCommandQueueThenItIsInitialize
.Times(1); // instruction heap
}
commandQueue->programGeneralStateBaseAddress(0u, true, child);
commandQueue->programStateBaseAddress(0u, true, child);
if (isaInLocalMemory) {
EXPECT_CALL(*memoryManager, getInternalHeapBaseAddress(rootDeviceIndex, false))
@@ -317,7 +320,7 @@ HWTEST2_F(CommandQueueProgramSBATest, whenCreatingCommandQueueThenItIsInitialize
.Times(2);
}
commandQueue->programGeneralStateBaseAddress(0u, false, child);
commandQueue->programStateBaseAddress(0u, false, child);
commandQueue->destroy();
}
@@ -333,7 +336,7 @@ HWTEST2_F(CommandQueueProgramSBATest,
uint32_t alignedSize = 4096u;
NEO::LinearStream child(commandQueue->commandStream->getSpace(alignedSize), alignedSize);
commandQueue->programGeneralStateBaseAddress(0u, true, child);
commandQueue->programStateBaseAddress(0u, true, child);
auto pSbaCmd = static_cast<STATE_BASE_ADDRESS *>(commandQueue->commandStream->getSpace(sizeof(STATE_BASE_ADDRESS)));
uint32_t statelessMocsIndex = pSbaCmd->getStatelessDataPortAccessMemoryObjectControlState();
@@ -344,6 +347,82 @@ HWTEST2_F(CommandQueueProgramSBATest,
commandQueue->destroy();
}
using BindlessCommandQueueSBASupport = IsAtLeastProduct<IGFX_SKYLAKE>;
HWTEST2_F(CommandQueueProgramSBATest,
givenBindlessModeEnabledWhenProgrammingStateBaseAddressThenBindlessBaseAddressIsPassed, BindlessCommandQueueSBASupport) {
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.UseBindlessMode.set(1);
auto bindlessHeapsHelper = std::make_unique<MockBindlesHeapsHelper>(neoDevice->getMemoryManager(), neoDevice->getNumAvailableDevices() > 1, neoDevice->getRootDeviceIndex());
MockBindlesHeapsHelper *bindlessHeapsHelperPtr = bindlessHeapsHelper.get();
neoDevice->bindlessHeapHelper.reset(bindlessHeapsHelper.release());
NEO::MockGraphicsAllocation baseAllocation;
bindlessHeapsHelperPtr->surfaceStateHeaps[NEO::BindlessHeapsHelper::GLOBAL_SSH].reset(new IndirectHeap(&baseAllocation, true));
baseAllocation.setGpuBaseAddress(0x123000);
ze_command_queue_desc_t desc = {};
auto csr = std::unique_ptr<NEO::CommandStreamReceiver>(neoDevice->createCommandStreamReceiver());
auto commandQueue = new MockCommandQueueHw<gfxCoreFamily>(device, csr.get(), &desc);
commandQueue->initialize(false, false);
uint32_t alignedSize = 4096u;
NEO::LinearStream child(commandQueue->commandStream->getSpace(alignedSize), alignedSize);
commandQueue->programStateBaseAddress(0u, true, child);
auto usedSpaceAfter = commandQueue->commandStream->getUsed();
GenCmdList cmdList;
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
cmdList, ptrOffset(commandQueue->commandStream->getCpuBase(), 0), usedSpaceAfter));
auto itor = find<STATE_BASE_ADDRESS *>(cmdList.begin(), cmdList.end());
ASSERT_NE(cmdList.end(), itor);
auto cmdSba = genCmdCast<STATE_BASE_ADDRESS *>(*itor);
EXPECT_EQ(cmdSba->getBindlessSurfaceStateBaseAddressModifyEnable(), true);
EXPECT_EQ(cmdSba->getBindlessSurfaceStateBaseAddress(), neoDevice->bindlessHeapHelper->getGlobalHeapsBase());
EXPECT_EQ(cmdSba->getBindlessSurfaceStateSize(), MemoryConstants::sizeOf4GBinPageEntities);
commandQueue->destroy();
}
HWTEST2_F(CommandQueueProgramSBATest,
givenBindlessModeDisabledWhenProgrammingStateBaseAddressThenBindlessBaseAddressNotPassed, CommandQueueSBASupport) {
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.UseBindlessMode.set(0);
auto bindlessHeapsHelper = std::make_unique<MockBindlesHeapsHelper>(neoDevice->getMemoryManager(), neoDevice->getNumAvailableDevices() > 1, neoDevice->getRootDeviceIndex());
MockBindlesHeapsHelper *bindlessHeapsHelperPtr = bindlessHeapsHelper.get();
neoDevice->bindlessHeapHelper.reset(bindlessHeapsHelper.release());
NEO::MockGraphicsAllocation baseAllocation;
bindlessHeapsHelperPtr->surfaceStateHeaps[NEO::BindlessHeapsHelper::GLOBAL_SSH].reset(new IndirectHeap(&baseAllocation, true));
baseAllocation.setGpuBaseAddress(0x123000);
ze_command_queue_desc_t desc = {};
auto csr = std::unique_ptr<NEO::CommandStreamReceiver>(neoDevice->createCommandStreamReceiver());
auto commandQueue = new MockCommandQueueHw<gfxCoreFamily>(device, csr.get(), &desc);
commandQueue->initialize(false, false);
uint32_t alignedSize = 4096u;
NEO::LinearStream child(commandQueue->commandStream->getSpace(alignedSize), alignedSize);
commandQueue->programStateBaseAddress(0u, true, child);
auto usedSpaceAfter = commandQueue->commandStream->getUsed();
GenCmdList cmdList;
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
cmdList, ptrOffset(commandQueue->commandStream->getCpuBase(), 0), usedSpaceAfter));
auto itor = find<STATE_BASE_ADDRESS *>(cmdList.begin(), cmdList.end());
ASSERT_NE(cmdList.end(), itor);
auto cmdSba = genCmdCast<STATE_BASE_ADDRESS *>(*itor);
EXPECT_NE(cmdSba->getBindlessSurfaceStateBaseAddress(), neoDevice->bindlessHeapHelper->getGlobalHeapsBase());
commandQueue->destroy();
}
TEST_F(CommandQueueCreate, givenCmdQueueWithBlitCopyWhenExecutingNonCopyBlitCommandListThenWrongCommandListStatusReturned) {
const ze_command_queue_desc_t desc = {};
ze_result_t returnValue;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -1206,7 +1206,9 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenCsrWhenGen
0,
0,
generalStateBaseAddress,
0,
true,
false,
pDevice->getGmmHelper(),
false,
MemoryCompressionState::NotApplicable);
@@ -1228,7 +1230,9 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenNonZeroGeneralStateBaseAddres
0,
0,
generalStateBaseAddress,
0,
true,
false,
pDevice->getGmmHelper(),
false,
MemoryCompressionState::NotApplicable);
@@ -1252,6 +1256,8 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenNonZeroInternalHeapBaseAddres
0,
internalHeapBaseAddress,
0,
0,
false,
false,
pDevice->getGmmHelper(),
false,
@@ -1281,7 +1287,9 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenSbaProgram
0,
internalHeapBase,
instructionHeapBase,
0,
true,
false,
pDevice->getGmmHelper(),
false,
MemoryCompressionState::NotApplicable);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -11,6 +11,7 @@
#include "shared/source/command_stream/command_stream_receiver.h"
#include "shared/source/command_stream/linear_stream.h"
#include "shared/source/device/device.h"
#include "shared/source/helpers/api_specific_config.h"
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/helpers/heap_helper.h"
#include "shared/source/helpers/hw_helper.h"
@@ -72,6 +73,9 @@ ErrorCode CommandContainer::initialize(Device *device) {
heapHelper = std::unique_ptr<HeapHelper>(new HeapHelper(device->getMemoryManager(), device->getDefaultEngine().commandStreamReceiver->getInternalAllocationStorage(), device->getNumAvailableDevices() > 1u));
for (uint32_t i = 0; i < IndirectHeap::Type::NUM_TYPES; i++) {
if (NEO::ApiSpecificConfig::getBindlessConfiguration() && i != IndirectHeap::INDIRECT_OBJECT) {
continue;
}
allocationIndirectHeaps[i] = heapHelper->getHeapAllocation(i,
heapSize,
alignedSize,
@@ -83,6 +87,9 @@ ErrorCode CommandContainer::initialize(Device *device) {
bool requireInternalHeap = (IndirectHeap::INDIRECT_OBJECT == i);
indirectHeaps[i] = std::make_unique<IndirectHeap>(allocationIndirectHeaps[i], requireInternalHeap);
if (i == IndirectHeap::Type::SURFACE_STATE) {
indirectHeaps[i]->getSpace(reservedSshSize);
}
}
auto &hwHelper = HwHelper::get(getDevice()->getHardwareInfo().platform.eRenderCoreFamily);
@@ -91,8 +98,6 @@ ErrorCode CommandContainer::initialize(Device *device) {
instructionHeapBaseAddress = device->getMemoryManager()->getInternalHeapBaseAddress(device->getRootDeviceIndex(), !hwHelper.useSystemMemoryPlacementForISA(getDevice()->getHardwareInfo()));
indirectHeaps[IndirectHeap::Type::SURFACE_STATE]->getSpace(reservedSshSize);
iddBlock = nullptr;
nextIddInBlock = this->getNumIddPerBlock();
@@ -129,12 +134,15 @@ void CommandContainer::reset() {
addToResidencyContainer(commandStream->getGraphicsAllocation());
for (auto &indirectHeap : indirectHeaps) {
indirectHeap->replaceBuffer(indirectHeap->getCpuBase(),
indirectHeap->getMaxAvailableSpace());
addToResidencyContainer(indirectHeap->getGraphicsAllocation());
if (indirectHeap != nullptr) {
indirectHeap->replaceBuffer(indirectHeap->getCpuBase(),
indirectHeap->getMaxAvailableSpace());
addToResidencyContainer(indirectHeap->getGraphicsAllocation());
}
}
if (indirectHeaps[IndirectHeap::Type::SURFACE_STATE] != nullptr) {
indirectHeaps[IndirectHeap::Type::SURFACE_STATE]->getSpace(reservedSshSize);
}
indirectHeaps[IndirectHeap::Type::SURFACE_STATE]->getSpace(reservedSshSize);
iddBlock = nullptr;
nextIddInBlock = this->getNumIddPerBlock();
@@ -229,4 +237,22 @@ void CommandContainer::allocateNextCommandBuffer() {
addToResidencyContainer(cmdBufferAllocation);
}
void CommandContainer::prepareBindfulSsh() {
if (ApiSpecificConfig::getBindlessConfiguration()) {
if (allocationIndirectHeaps[IndirectHeap::SURFACE_STATE] == nullptr) {
size_t alignedSize = alignUp<size_t>(totalCmdBufferSize, MemoryConstants::pageSize64k);
constexpr size_t heapSize = 65536u;
allocationIndirectHeaps[IndirectHeap::SURFACE_STATE] = heapHelper->getHeapAllocation(IndirectHeap::SURFACE_STATE,
heapSize,
alignedSize,
device->getRootDeviceIndex());
UNRECOVERABLE_IF(!allocationIndirectHeaps[IndirectHeap::SURFACE_STATE]);
residencyContainer.push_back(allocationIndirectHeaps[IndirectHeap::SURFACE_STATE]);
indirectHeaps[IndirectHeap::SURFACE_STATE] = std::make_unique<IndirectHeap>(allocationIndirectHeaps[IndirectHeap::SURFACE_STATE], false);
indirectHeaps[IndirectHeap::SURFACE_STATE]->getSpace(reservedSshSize);
}
setHeapDirty(IndirectHeap::SURFACE_STATE);
}
}
} // namespace NEO

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -79,6 +79,8 @@ class CommandContainer : public NonCopyableOrMovableClass {
ErrorCode initialize(Device *device);
void prepareBindfulSsh();
virtual ~CommandContainer();
uint32_t slmSize = std::numeric_limits<uint32_t>::max();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -429,9 +429,14 @@ template <typename Family>
void *EncodeDispatchKernel<Family>::getInterfaceDescriptor(CommandContainer &container, uint32_t &iddOffset) {
if (container.nextIddInBlock == container.getNumIddPerBlock()) {
container.getIndirectHeap(HeapType::DYNAMIC_STATE)->align(EncodeStates<Family>::alignInterfaceDescriptorData);
container.setIddBlock(container.getHeapSpaceAllowGrow(HeapType::DYNAMIC_STATE,
sizeof(INTERFACE_DESCRIPTOR_DATA) * container.getNumIddPerBlock()));
if (ApiSpecificConfig::getBindlessConfiguration()) {
container.getDevice()->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH)->align(EncodeStates<Family>::alignInterfaceDescriptorData);
container.setIddBlock(container.getDevice()->getBindlessHeapsHelper()->getSpaceInHeap(sizeof(INTERFACE_DESCRIPTOR_DATA) * container.getNumIddPerBlock(), BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH));
} else {
container.getIndirectHeap(HeapType::DYNAMIC_STATE)->align(EncodeStates<Family>::alignInterfaceDescriptorData);
container.setIddBlock(container.getHeapSpaceAllowGrow(HeapType::DYNAMIC_STATE,
sizeof(INTERFACE_DESCRIPTOR_DATA) * container.getNumIddPerBlock()));
}
container.nextIddInBlock = 0;
EncodeMediaInterfaceDescriptorLoad<Family>::encode(container);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -79,7 +79,7 @@ void EncodeDispatchKernel<Family>::encode(CommandContainer &container,
uint32_t bindingTablePointer = 0u;
bool isBindlessKernel = kernelDescriptor.kernelAttributes.bufferAddressingMode == KernelDescriptor::BindlessAndStateless;
if (!isBindlessKernel) {
container.prepareBindfulSsh();
if (bindingTableStateCount > 0u) {
auto ssh = container.getHeapWithRequiredSizeAndAlignment(HeapType::SURFACE_STATE, dispatchInterface->getSurfaceStateHeapDataSize(), BINDING_TABLE_STATE::SURFACESTATEPOINTER_ALIGN_SIZE);
sshOffset = ssh->getUsed();
@@ -89,9 +89,8 @@ void EncodeDispatchKernel<Family>::encode(CommandContainer &container,
dispatchInterface->getSurfaceStateHeapDataSize(), bindingTableStateCount,
kernelDescriptor.payloadMappings.bindingTable.tableOffset));
}
idd.setBindingTablePointer(bindingTablePointer);
}
idd.setBindingTablePointer(bindingTablePointer);
PreemptionHelper::programInterfaceDescriptorDataPreemption<Family>(&idd, preemptionMode);
@@ -114,8 +113,9 @@ void EncodeDispatchKernel<Family>::encode(CommandContainer &container,
}
idd.setSamplerStatePointer(samplerStateOffset);
EncodeDispatchKernel<Family>::adjustBindingTablePrefetch(idd, samplerCount, bindingTableStateCount);
if (!isBindlessKernel) {
EncodeDispatchKernel<Family>::adjustBindingTablePrefetch(idd, samplerCount, bindingTableStateCount);
}
auto numGrfCrossThreadData = static_cast<uint32_t>(sizeCrossThreadData / sizeof(float[8]));
idd.setCrossThreadConstantDataReadLength(numGrfCrossThreadData);
@@ -221,13 +221,18 @@ template <typename Family>
void EncodeMediaInterfaceDescriptorLoad<Family>::encode(CommandContainer &container) {
using MEDIA_STATE_FLUSH = typename Family::MEDIA_STATE_FLUSH;
using MEDIA_INTERFACE_DESCRIPTOR_LOAD = typename Family::MEDIA_INTERFACE_DESCRIPTOR_LOAD;
auto heap = container.getIndirectHeap(HeapType::DYNAMIC_STATE);
auto heapBase = ApiSpecificConfig::getBindlessConfiguration() ? container.getDevice()->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::GLOBAL_DSH)->getGraphicsAllocation()->getUnderlyingBuffer() : container.getIndirectHeap(HeapType::DYNAMIC_STATE)->getCpuBase();
auto mediaStateFlush = container.getCommandStream()->getSpaceForCmd<MEDIA_STATE_FLUSH>();
*mediaStateFlush = Family::cmdInitMediaStateFlush;
auto iddOffset = static_cast<uint32_t>(ptrDiff(container.getIddBlock(), heapBase));
iddOffset += ApiSpecificConfig::getBindlessConfiguration() ? static_cast<uint32_t>(container.getDevice()->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::GLOBAL_DSH)->getGraphicsAllocation()->getGpuAddress() -
container.getDevice()->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::GLOBAL_DSH)->getGraphicsAllocation()->getGpuBaseAddress())
: 0;
MEDIA_INTERFACE_DESCRIPTOR_LOAD cmd = Family::cmdInitMediaInterfaceDescriptorLoad;
cmd.setInterfaceDescriptorDataStartAddress(static_cast<uint32_t>(ptrDiff(container.getIddBlock(), heap->getCpuBase())));
cmd.setInterfaceDescriptorDataStartAddress(iddOffset);
cmd.setInterfaceDescriptorTotalLength(sizeof(INTERFACE_DESCRIPTOR_DATA) * container.getNumIddPerBlock());
auto buffer = container.getCommandStream()->getSpace(sizeof(cmd));
@@ -352,6 +357,8 @@ void EncodeStateBaseAddress<Family>::encode(CommandContainer &container, STATE_B
statelessMocsIndex,
container.getIndirectObjectHeapBaseAddress(),
container.getInstructionHeapBaseAddress(),
0,
false,
false,
gmmHelper,
false,

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -404,7 +404,9 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
mocsIndex,
getMemoryManager()->getInternalHeapBaseAddress(rootDeviceIndex, ioh.getGraphicsAllocation()->isAllocatedInLocalMemoryPool()),
instructionHeapBaseAddress,
0,
true,
false,
device.getGmmHelper(),
isMultiOsContextCapable(),
dispatchFlags.memoryCompressionState);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -10,5 +10,71 @@
#include "shared/source/helpers/state_base_address_bdw_plus.inl"
namespace NEO {
template struct StateBaseAddressHelper<BDWFamily>;
template <>
void StateBaseAddressHelper<BDWFamily>::programStateBaseAddress(
STATE_BASE_ADDRESS *stateBaseAddress,
const IndirectHeap *dsh,
const IndirectHeap *ioh,
const IndirectHeap *ssh,
uint64_t generalStateBase,
bool setGeneralStateBaseAddress,
uint32_t statelessMocsIndex,
uint64_t indirectObjectHeapBaseAddress,
uint64_t instructionHeapBaseAddress,
uint64_t globalHeapsBaseAddress,
bool setInstructionStateBaseAddress,
bool useGlobalHeapsBaseAddress,
GmmHelper *gmmHelper,
bool isMultiOsContextCapable,
MemoryCompressionState memoryCompressionState) {
*stateBaseAddress = BDWFamily::cmdInitStateBaseAddress;
if (dsh) {
stateBaseAddress->setDynamicStateBaseAddressModifyEnable(true);
stateBaseAddress->setDynamicStateBufferSizeModifyEnable(true);
stateBaseAddress->setDynamicStateBaseAddress(dsh->getHeapGpuBase());
stateBaseAddress->setDynamicStateBufferSize(dsh->getHeapSizeInPages());
}
if (ioh) {
stateBaseAddress->setIndirectObjectBaseAddressModifyEnable(true);
stateBaseAddress->setIndirectObjectBufferSizeModifyEnable(true);
stateBaseAddress->setIndirectObjectBaseAddress(ioh->getHeapGpuBase());
stateBaseAddress->setIndirectObjectBufferSize(ioh->getHeapSizeInPages());
}
if (ssh) {
stateBaseAddress->setSurfaceStateBaseAddressModifyEnable(true);
stateBaseAddress->setSurfaceStateBaseAddress(ssh->getHeapGpuBase());
}
if (setInstructionStateBaseAddress) {
stateBaseAddress->setInstructionBaseAddressModifyEnable(true);
stateBaseAddress->setInstructionBaseAddress(instructionHeapBaseAddress);
stateBaseAddress->setInstructionBufferSizeModifyEnable(true);
stateBaseAddress->setInstructionBufferSize(MemoryConstants::sizeOf4GBinPageEntities);
stateBaseAddress->setInstructionMemoryObjectControlState(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER));
}
if (setGeneralStateBaseAddress) {
stateBaseAddress->setGeneralStateBaseAddressModifyEnable(true);
stateBaseAddress->setGeneralStateBufferSizeModifyEnable(true);
// GSH must be set to 0 for stateless
stateBaseAddress->setGeneralStateBaseAddress(GmmHelper::decanonize(generalStateBase));
stateBaseAddress->setGeneralStateBufferSize(0xfffff);
}
if (DebugManager.flags.OverrideStatelessMocsIndex.get() != -1) {
statelessMocsIndex = DebugManager.flags.OverrideStatelessMocsIndex.get();
}
statelessMocsIndex = statelessMocsIndex << 1;
stateBaseAddress->setStatelessDataPortAccessMemoryObjectControlState(statelessMocsIndex);
appendStateBaseAddressParameters(stateBaseAddress, ssh, setGeneralStateBaseAddress, indirectObjectHeapBaseAddress, gmmHelper, isMultiOsContextCapable, memoryCompressionState);
}
template struct StateBaseAddressHelper<BDWFamily>;
} // namespace NEO

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -23,7 +23,7 @@ BindlessHeapsHelper::BindlessHeapsHelper(MemoryManager *memManager, bool isMulti
auto heapAllocation = getHeapAllocation(MemoryConstants::pageSize64k, MemoryConstants::pageSize64k, allocInFrontWindow);
UNRECOVERABLE_IF(heapAllocation == nullptr);
ssHeapsAllocations.push_back(heapAllocation);
surfaceStateHeaps[heapType] = std::make_unique<IndirectHeap>(heapAllocation, false);
surfaceStateHeaps[heapType] = std::make_unique<IndirectHeap>(heapAllocation, true);
}
borderColorStates = getHeapAllocation(MemoryConstants::pageSize, MemoryConstants::pageSize, true);
@@ -60,6 +60,7 @@ SurfaceStateInHeapInfo BindlessHeapsHelper::allocateSSInHeap(size_t ssSize, Grap
}
}
void *ptrInHeap = getSpaceInHeap(ssSize, heapType);
memset(ptrInHeap, 0, ssSize);
auto bindlessOffset = heap->getGraphicsAllocation()->getGpuAddress() - heap->getGraphicsAllocation()->getGpuBaseAddress() + heap->getUsed() - ssSize;
SurfaceStateInHeapInfo bindlesInfo;
if (heapType == BindlesHeapType::GLOBAL_SSH) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -8,6 +8,7 @@
#pragma once
#include "shared/source/aub_mem_dump/aub_mem_dump.h"
#include "shared/source/built_ins/sip.h"
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/command_stream/linear_stream.h"
#include "shared/source/commands/bxml_generator_glue.h"
#include "shared/source/helpers/aux_translation.h"

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -31,7 +31,9 @@ struct StateBaseAddressHelper {
uint32_t statelessMocsIndex,
uint64_t indirectObjectHeapBaseAddress,
uint64_t instructionHeapBaseAddress,
uint64_t globalHeapsBaseAddress,
bool setInstructionStateBaseAddress,
bool useGlobalHeapsBaseAddress,
GmmHelper *gmmHelper,
bool isMultiOsContextCapable,
MemoryCompressionState memoryCompressionState);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -26,30 +26,51 @@ void StateBaseAddressHelper<GfxFamily>::programStateBaseAddress(
uint32_t statelessMocsIndex,
uint64_t indirectObjectHeapBaseAddress,
uint64_t instructionHeapBaseAddress,
uint64_t globalHeapsBaseAddress,
bool setInstructionStateBaseAddress,
bool useGlobalHeapsBaseAddress,
GmmHelper *gmmHelper,
bool isMultiOsContextCapable,
MemoryCompressionState memoryCompressionState) {
*stateBaseAddress = GfxFamily::cmdInitStateBaseAddress;
if (dsh) {
if (useGlobalHeapsBaseAddress) {
stateBaseAddress->setDynamicStateBaseAddressModifyEnable(true);
stateBaseAddress->setDynamicStateBufferSizeModifyEnable(true);
stateBaseAddress->setDynamicStateBaseAddress(dsh->getHeapGpuBase());
stateBaseAddress->setDynamicStateBufferSize(dsh->getHeapSizeInPages());
}
stateBaseAddress->setDynamicStateBaseAddress(globalHeapsBaseAddress);
stateBaseAddress->setDynamicStateBufferSize(MemoryConstants::pageSize64k);
if (ioh) {
stateBaseAddress->setIndirectObjectBaseAddressModifyEnable(true);
stateBaseAddress->setIndirectObjectBufferSizeModifyEnable(true);
stateBaseAddress->setIndirectObjectBaseAddress(ioh->getHeapGpuBase());
stateBaseAddress->setIndirectObjectBufferSize(ioh->getHeapSizeInPages());
}
stateBaseAddress->setIndirectObjectBaseAddress(indirectObjectHeapBaseAddress);
stateBaseAddress->setIndirectObjectBufferSize(MemoryConstants::sizeOf4GBinPageEntities);
if (ssh) {
stateBaseAddress->setSurfaceStateBaseAddressModifyEnable(true);
stateBaseAddress->setSurfaceStateBaseAddress(ssh->getHeapGpuBase());
stateBaseAddress->setSurfaceStateBaseAddress(globalHeapsBaseAddress);
stateBaseAddress->setBindlessSurfaceStateBaseAddressModifyEnable(true);
stateBaseAddress->setBindlessSurfaceStateBaseAddress(globalHeapsBaseAddress);
stateBaseAddress->setBindlessSurfaceStateSize(MemoryConstants::sizeOf4GBinPageEntities);
} else {
if (dsh) {
stateBaseAddress->setDynamicStateBaseAddressModifyEnable(true);
stateBaseAddress->setDynamicStateBufferSizeModifyEnable(true);
stateBaseAddress->setDynamicStateBaseAddress(dsh->getHeapGpuBase());
stateBaseAddress->setDynamicStateBufferSize(dsh->getHeapSizeInPages());
}
if (ioh) {
stateBaseAddress->setIndirectObjectBaseAddressModifyEnable(true);
stateBaseAddress->setIndirectObjectBufferSizeModifyEnable(true);
stateBaseAddress->setIndirectObjectBaseAddress(ioh->getHeapGpuBase());
stateBaseAddress->setIndirectObjectBufferSize(ioh->getHeapSizeInPages());
}
if (ssh) {
stateBaseAddress->setSurfaceStateBaseAddressModifyEnable(true);
stateBaseAddress->setSurfaceStateBaseAddress(ssh->getHeapGpuBase());
}
}
if (setInstructionStateBaseAddress) {

View File

@@ -444,8 +444,6 @@ void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation
residencyController.removeFromTrimCandidateListIfUsed(input, true);
}
executionEnvironment.rootDeviceEnvironments[gfxAllocation->getRootDeviceIndex()]->memoryOperationsInterface->evict(nullptr, *input);
auto defaultGmm = gfxAllocation->getDefaultGmm();
if (defaultGmm) {
auto index = gfxAllocation->getRootDeviceIndex();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -1022,12 +1022,112 @@ HWCMDTEST_F(IGFX_GEN8_CORE, InterfaceDescriptorDataTests, givenVariousValuesWhen
}
using BindlessCommandEncodeStatesTest = Test<MemManagerFixture>;
using BindlessCommandEncodeStatesTesttt = Test<DeviceFixture>;
HWTEST_F(BindlessCommandEncodeStatesTesttt, givenBindlessKernelWhenBindlessModeEnabledThenCmdContainerDoesNotHaveSsh) {
using BINDING_TABLE_STATE = typename FamilyType::BINDING_TABLE_STATE;
using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA;
using WALKER = typename FamilyType::WALKER_TYPE;
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.UseBindlessMode.set(1);
auto commandContainer = std::make_unique<CommandContainer>();
commandContainer->initialize(pDevice);
commandContainer->setDirtyStateForAllHeaps(false);
pDevice->bindlessHeapHelper.reset(new NEO::BindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()));
uint32_t numBindingTable = 1;
BINDING_TABLE_STATE bindingTableState;
bindingTableState.sInit();
uint32_t dims[] = {1, 1, 1};
std::unique_ptr<MockDispatchKernelEncoder> dispatchInterface(new MockDispatchKernelEncoder());
dispatchInterface->kernelDescriptor.payloadMappings.bindingTable.numEntries = numBindingTable;
dispatchInterface->kernelDescriptor.payloadMappings.bindingTable.tableOffset = 0U;
dispatchInterface->kernelDescriptor.kernelAttributes.bufferAddressingMode = KernelDescriptor::BindlessAndStateless;
const uint8_t *sshData = reinterpret_cast<uint8_t *>(&bindingTableState);
EXPECT_CALL(*dispatchInterface.get(), getSurfaceStateHeapData()).WillRepeatedly(::testing::Return(sshData));
EXPECT_CALL(*dispatchInterface.get(), getSurfaceStateHeapDataSize()).WillRepeatedly(::testing::Return(static_cast<uint32_t>(sizeof(BINDING_TABLE_STATE))));
bool requiresUncachedMocs = false;
EXPECT_EQ(commandContainer->getIndirectHeap(HeapType::SURFACE_STATE), nullptr);
EncodeDispatchKernel<FamilyType>::encode(*commandContainer.get(), dims, false, false, dispatchInterface.get(), 0, pDevice, NEO::PreemptionMode::Disabled, requiresUncachedMocs);
EXPECT_EQ(commandContainer->getIndirectHeap(HeapType::SURFACE_STATE), nullptr);
}
HWTEST_F(BindlessCommandEncodeStatesTesttt, givenBindfulKernelWhenBindlessModeEnabledThenCmdContainerHaveSsh) {
using BINDING_TABLE_STATE = typename FamilyType::BINDING_TABLE_STATE;
using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA;
using WALKER = typename FamilyType::WALKER_TYPE;
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.UseBindlessMode.set(1);
auto commandContainer = std::make_unique<CommandContainer>();
commandContainer->initialize(pDevice);
commandContainer->setDirtyStateForAllHeaps(false);
pDevice->bindlessHeapHelper.reset(new NEO::BindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()));
uint32_t numBindingTable = 1;
BINDING_TABLE_STATE bindingTableState;
bindingTableState.sInit();
uint32_t dims[] = {1, 1, 1};
std::unique_ptr<MockDispatchKernelEncoder> dispatchInterface(new MockDispatchKernelEncoder());
dispatchInterface->kernelDescriptor.payloadMappings.bindingTable.numEntries = numBindingTable;
dispatchInterface->kernelDescriptor.payloadMappings.bindingTable.tableOffset = 0U;
dispatchInterface->kernelDescriptor.kernelAttributes.bufferAddressingMode = KernelDescriptor::BindfulAndStateless;
const uint8_t *sshData = reinterpret_cast<uint8_t *>(&bindingTableState);
EXPECT_CALL(*dispatchInterface.get(), getSurfaceStateHeapData()).WillRepeatedly(::testing::Return(sshData));
EXPECT_CALL(*dispatchInterface.get(), getSurfaceStateHeapDataSize()).WillRepeatedly(::testing::Return(static_cast<uint32_t>(sizeof(BINDING_TABLE_STATE))));
bool requiresUncachedMocs = false;
EXPECT_EQ(commandContainer->getIndirectHeap(HeapType::SURFACE_STATE), nullptr);
EncodeDispatchKernel<FamilyType>::encode(*commandContainer.get(), dims, false, false, dispatchInterface.get(), 0, pDevice, NEO::PreemptionMode::Disabled, requiresUncachedMocs);
EXPECT_NE(commandContainer->getIndirectHeap(HeapType::SURFACE_STATE), nullptr);
}
HWTEST_F(BindlessCommandEncodeStatesTesttt, givenBindlessModeEnabledWhenDispatchingTwoBindfulKernelsThenItuseTheSameSsh) {
using BINDING_TABLE_STATE = typename FamilyType::BINDING_TABLE_STATE;
using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA;
using WALKER = typename FamilyType::WALKER_TYPE;
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.UseBindlessMode.set(1);
auto commandContainer = std::make_unique<CommandContainer>();
commandContainer->initialize(pDevice);
commandContainer->setDirtyStateForAllHeaps(false);
pDevice->bindlessHeapHelper.reset(new NEO::BindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex()));
uint32_t numBindingTable = 1;
BINDING_TABLE_STATE bindingTableState;
bindingTableState.sInit();
uint32_t dims[] = {1, 1, 1};
std::unique_ptr<MockDispatchKernelEncoder> dispatchInterface(new MockDispatchKernelEncoder());
dispatchInterface->kernelDescriptor.payloadMappings.bindingTable.numEntries = numBindingTable;
dispatchInterface->kernelDescriptor.payloadMappings.bindingTable.tableOffset = 0U;
dispatchInterface->kernelDescriptor.kernelAttributes.bufferAddressingMode = KernelDescriptor::BindfulAndStateless;
const uint8_t *sshData = reinterpret_cast<uint8_t *>(&bindingTableState);
EXPECT_CALL(*dispatchInterface.get(), getSurfaceStateHeapData()).WillRepeatedly(::testing::Return(sshData));
EXPECT_CALL(*dispatchInterface.get(), getSurfaceStateHeapDataSize()).WillRepeatedly(::testing::Return(static_cast<uint32_t>(sizeof(BINDING_TABLE_STATE))));
bool requiresUncachedMocs = false;
EXPECT_EQ(commandContainer->getIndirectHeap(HeapType::SURFACE_STATE), nullptr);
EncodeDispatchKernel<FamilyType>::encode(*commandContainer.get(), dims, false, false, dispatchInterface.get(), 0, pDevice, NEO::PreemptionMode::Disabled, requiresUncachedMocs);
auto sshBefore = commandContainer->getIndirectHeap(HeapType::SURFACE_STATE);
EncodeDispatchKernel<FamilyType>::encode(*commandContainer.get(), dims, false, false, dispatchInterface.get(), 0, pDevice, NEO::PreemptionMode::Disabled, requiresUncachedMocs);
EncodeDispatchKernel<FamilyType>::encode(*commandContainer.get(), dims, false, false, dispatchInterface.get(), 0, pDevice, NEO::PreemptionMode::Disabled, requiresUncachedMocs);
auto sshAfter = commandContainer->getIndirectHeap(HeapType::SURFACE_STATE);
EncodeDispatchKernel<FamilyType>::encode(*commandContainer.get(), dims, false, false, dispatchInterface.get(), 0, pDevice, NEO::PreemptionMode::Disabled, requiresUncachedMocs);
EXPECT_EQ(sshBefore, sshAfter);
}
HWTEST_F(BindlessCommandEncodeStatesTest, givenGlobalBindlessHeapsWhenDispatchingKernelWithSamplerThenGlobalDshInResidnecyContainer) {
DebugManagerStateRestore restorer;
DebugManager.flags.UseBindlessMode.set(1);
auto cmdContainer = std::make_unique<CommandContainer>();
cmdContainer->initialize(pDevice);
cmdContainer->setDirtyStateForAllHeaps(false);
using SAMPLER_BORDER_COLOR_STATE = typename FamilyType::SAMPLER_BORDER_COLOR_STATE;
using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA;
uint32_t numSamplers = 1;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -24,6 +24,7 @@ class CommandEncodeStatesFixture : public DeviceFixture {
DeviceFixture::SetUp();
cmdContainer = std::make_unique<MyMockCommandContainer>();
cmdContainer->initialize(pDevice);
cmdContainer->setDirtyStateForAllHeaps(false);
}
void TearDown() {
cmdContainer.reset();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -8,6 +8,7 @@
#include "shared/source/helpers/bindless_heaps_helper.h"
#include "shared/test/unit_test/fixtures/front_window_fixture.h"
#include "shared/test/unit_test/helpers/debug_manager_state_restore.h"
#include "shared/test/unit_test/mocks/mock_bindless_heaps_helper.h"
#include "shared/test/unit_test/mocks/mock_device.h"
#include "shared/test/unit_test/mocks/mock_graphics_allocation.h"
#include "shared/test/unit_test/mocks/ult_device_factory.h"
@@ -16,30 +17,6 @@
using namespace NEO;
class MockBindlesHeapsHelper : public BindlessHeapsHelper {
public:
using BaseClass = BindlessHeapsHelper;
MockBindlesHeapsHelper(MemoryManager *memManager, bool isMultiOsContextCapable, const uint32_t rootDeviceIndex) : BaseClass(memManager, isMultiOsContextCapable, rootDeviceIndex) {
globalSsh = surfaceStateHeaps[BindlesHeapType::GLOBAL_SSH].get();
specialSsh = surfaceStateHeaps[BindlesHeapType::SPECIAL_SSH].get();
scratchSsh = surfaceStateHeaps[BindlesHeapType::SPECIAL_SSH].get();
globalDsh = surfaceStateHeaps[BindlesHeapType::SPECIAL_SSH].get();
}
using BindlesHeapType = BindlessHeapsHelper::BindlesHeapType;
using BaseClass::borderColorStates;
using BaseClass::growHeap;
using BaseClass::isMultiOsContextCapable;
using BaseClass::memManager;
using BaseClass::rootDeviceIndex;
using BaseClass::ssHeapsAllocations;
using BaseClass::surfaceStateInHeapAllocationMap;
IndirectHeap *specialSsh;
IndirectHeap *globalSsh;
IndirectHeap *scratchSsh;
IndirectHeap *globalDsh;
};
TEST(BindlessHeapsHelper, givenBindlessModeFlagEnabledWhenCreatingRootDevicesThenBindlesHeapHelperCreated) {
DebugManagerStateRestore dbgRestorer;
DebugManager.flags.UseBindlessMode.set(1);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -57,6 +57,8 @@ HWTEST2_F(SBATest, WhenProgramStateBaseAddressParametersIsCalledThenSBACmdHasBin
0,
0,
0,
0,
false,
false,
pDevice->getGmmHelper(),
true,
@@ -66,3 +68,68 @@ HWTEST2_F(SBATest, WhenProgramStateBaseAddressParametersIsCalledThenSBACmdHasBin
EXPECT_EQ(ssh.getHeapGpuBase(), cmd->getBindlessSurfaceStateBaseAddress());
EXPECT_TRUE(cmd->getBindlessSurfaceStateBaseAddressModifyEnable());
}
using SbaForBindlessTests = Test<DeviceFixture>;
HWTEST2_F(SbaForBindlessTests, givenGlobalBindlessBaseAddressWhenProgramStateBaseAddressThenSbaProgrammedCorrectly, IsSklOrAbove) {
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
EXPECT_NE(IGFX_BROADWELL, ::productFamily);
uint64_t globalBindlessHeapsBaseAddress = 0x12340000;
StackVec<char, 4096> buffer(4096);
NEO::LinearStream cmdStream(buffer.begin(), buffer.size());
STATE_BASE_ADDRESS *cmd = reinterpret_cast<STATE_BASE_ADDRESS *>(cmdStream.getSpace(0));
StateBaseAddressHelper<FamilyType>::programStateBaseAddress(
cmd,
nullptr,
nullptr,
nullptr,
0,
false,
0,
0,
0,
globalBindlessHeapsBaseAddress,
false,
true,
pDevice->getGmmHelper(),
true,
MemoryCompressionState::NotApplicable);
EXPECT_TRUE(cmd->getBindlessSurfaceStateBaseAddressModifyEnable());
EXPECT_EQ(cmd->getBindlessSurfaceStateBaseAddress(), globalBindlessHeapsBaseAddress);
EXPECT_EQ(cmd->getBindlessSurfaceStateSize(), MemoryConstants::sizeOf4GBinPageEntities);
}
HWTEST2_F(SbaForBindlessTests, givenGlobalBindlessBaseAddressWhenPassingIndirectBaseAddressThenIndirectBaseAddressIsSet, IsSklOrAbove) {
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
EXPECT_NE(IGFX_BROADWELL, ::productFamily);
uint64_t globalBindlessHeapsBaseAddress = 0x12340000;
uint64_t indirectObjectBaseAddress = 0x12340000;
StackVec<char, 4096> buffer(4096);
NEO::LinearStream cmdStream(buffer.begin(), buffer.size());
STATE_BASE_ADDRESS *cmd = reinterpret_cast<STATE_BASE_ADDRESS *>(cmdStream.getSpace(0));
StateBaseAddressHelper<FamilyType>::programStateBaseAddress(
cmd,
nullptr,
nullptr,
nullptr,
0,
false,
0,
indirectObjectBaseAddress,
0,
globalBindlessHeapsBaseAddress,
false,
true,
pDevice->getGmmHelper(),
true,
MemoryCompressionState::NotApplicable);
EXPECT_EQ(cmd->getIndirectObjectBaseAddress(), indirectObjectBaseAddress);
}

View File

@@ -1,11 +1,12 @@
#
# Copyright (C) 2020 Intel Corporation
# Copyright (C) 2020-2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(NEO_CORE_tests_mocks
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/mock_bindless_heaps_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_command_stream_receiver.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_command_stream_receiver.h
${CMAKE_CURRENT_SOURCE_DIR}/mock_compiler_interface_spirv.cpp

View File

@@ -0,0 +1,35 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/bindless_heaps_helper.h"
using namespace NEO;
class MockBindlesHeapsHelper : public BindlessHeapsHelper {
public:
using BaseClass = BindlessHeapsHelper;
MockBindlesHeapsHelper(MemoryManager *memManager, bool isMultiOsContextCapable, const uint32_t rootDeviceIndex) : BaseClass(memManager, isMultiOsContextCapable, rootDeviceIndex) {
globalSsh = surfaceStateHeaps[BindlesHeapType::GLOBAL_SSH].get();
specialSsh = surfaceStateHeaps[BindlesHeapType::SPECIAL_SSH].get();
scratchSsh = surfaceStateHeaps[BindlesHeapType::SPECIAL_SSH].get();
globalDsh = surfaceStateHeaps[BindlesHeapType::SPECIAL_SSH].get();
}
using BindlesHeapType = BindlessHeapsHelper::BindlesHeapType;
using BaseClass::borderColorStates;
using BaseClass::growHeap;
using BaseClass::isMultiOsContextCapable;
using BaseClass::memManager;
using BaseClass::rootDeviceIndex;
using BaseClass::ssHeapsAllocations;
using BaseClass::surfaceStateHeaps;
using BaseClass::surfaceStateInHeapAllocationMap;
IndirectHeap *specialSsh;
IndirectHeap *globalSsh;
IndirectHeap *scratchSsh;
IndirectHeap *globalDsh;
};