Allow to create command container with custom maxNumAggregateIdds

Allows flexibility to create command containers that do not
require the functionality to aggregate IDDs

Change-Id: I1d01a8280665acb45ddad87c97d48231db87281a
Signed-off-by: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@intel.com>
This commit is contained in:
Aravind Gopalakrishnan 2020-02-04 14:03:48 -08:00 committed by sys_ocldev
parent 17ccb796df
commit 2b0d85d0cd
5 changed files with 26 additions and 9 deletions

View File

@ -38,8 +38,6 @@ CommandContainer::~CommandContainer() {
getHeapHelper()->storeHeapAllocation(deallocation);
}
}
residencyContainer.clear();
deallocationContainer.clear();
}
bool CommandContainer::initialize(Device *device) {
@ -84,7 +82,7 @@ bool CommandContainer::initialize(Device *device) {
instructionHeapBaseAddress = device->getMemoryManager()->getInternalHeapBaseAddress(0);
iddBlock = nullptr;
nextIddInBlock = numIddsPerBlock;
nextIddInBlock = this->getNumIddPerBlock();
return true;
}

View File

@ -43,6 +43,10 @@ class CommandContainer : public NonCopyableOrMovableClass {
}
}
CommandContainer(uint32_t maxNumAggregatedIdds) : CommandContainer() {
numIddsPerBlock = maxNumAggregatedIdds;
}
CmdBufferContainer &getCmdBufferAllocations() { return cmdBufferAllocations; }
ResidencyContainer &getResidencyContainer() { return residencyContainer; }
@ -70,7 +74,6 @@ class CommandContainer : public NonCopyableOrMovableClass {
virtual ~CommandContainer();
uint32_t slmSize = std::numeric_limits<uint32_t>::max();
static const uint32_t numIddsPerBlock = 64;
uint32_t nextIddInBlock = 0;
uint32_t lastSentNumGrfRequired = 0;
@ -87,6 +90,7 @@ class CommandContainer : public NonCopyableOrMovableClass {
void setDirtyStateForAllHeaps(bool dirty) { dirtyHeaps = dirty ? std::numeric_limits<uint32_t>::max() : 0; }
void setIddBlock(void *iddBlock) { this->iddBlock = iddBlock; }
void *getIddBlock() { return iddBlock; }
uint32_t getNumIddPerBlock() { return numIddsPerBlock; }
protected:
void *iddBlock = nullptr;
@ -97,6 +101,7 @@ class CommandContainer : public NonCopyableOrMovableClass {
GraphicsAllocation *allocationIndirectHeaps[HeapType::NUM_TYPES] = {};
uint64_t instructionHeapBaseAddress = 0u;
uint32_t dirtyHeaps = std::numeric_limits<uint32_t>::max();
uint32_t numIddsPerBlock = 64;
std::unique_ptr<LinearStream> commandStream;
std::unique_ptr<IndirectHeap> indirectHeaps[HeapType::NUM_TYPES];

View File

@ -255,10 +255,10 @@ void EncodeStates<Family>::adjustStateComputeMode(CommandContainer &container) {
template <typename Family>
void *EncodeDispatchKernel<Family>::getInterfaceDescriptor(CommandContainer &container, uint32_t &iddOffset) {
if (container.nextIddInBlock == container.numIddsPerBlock) {
if (container.nextIddInBlock == container.getNumIddPerBlock()) {
container.getIndirectHeap(HeapType::DYNAMIC_STATE)->align(HardwareCommandsHelper<Family>::alignInterfaceDescriptorData);
container.setIddBlock(container.getHeapSpaceAllowGrow(HeapType::DYNAMIC_STATE,
sizeof(INTERFACE_DESCRIPTOR_DATA) * container.numIddsPerBlock));
sizeof(INTERFACE_DESCRIPTOR_DATA) * container.getNumIddPerBlock()));
container.nextIddInBlock = 0;
EncodeMediaInterfaceDescriptorLoad<Family>::encode(container);

View File

@ -150,7 +150,7 @@ void EncodeDispatchKernel<Family>::encode(CommandContainer &container,
EncodeL3State<Family>::encode(container, slmSizeNew != 0u);
container.slmSize = slmSizeNew;
if (container.nextIddInBlock != container.numIddsPerBlock) {
if (container.nextIddInBlock != container.getNumIddPerBlock()) {
EncodeMediaInterfaceDescriptorLoad<Family>::encode(container);
}
}
@ -213,7 +213,7 @@ void EncodeMediaInterfaceDescriptorLoad<Family>::encode(CommandContainer &contai
MEDIA_INTERFACE_DESCRIPTOR_LOAD cmd = Family::cmdInitMediaInterfaceDescriptorLoad;
cmd.setInterfaceDescriptorDataStartAddress(static_cast<uint32_t>(ptrDiff(container.getIddBlock(), heap->getCpuBase())));
cmd.setInterfaceDescriptorTotalLength(sizeof(INTERFACE_DESCRIPTOR_DATA) * container.numIddsPerBlock);
cmd.setInterfaceDescriptorTotalLength(sizeof(INTERFACE_DESCRIPTOR_DATA) * container.getNumIddPerBlock());
auto buffer = container.getCommandStream()->getSpace(sizeof(cmd));
*(decltype(cmd) *)buffer = cmd;

View File

@ -15,6 +15,20 @@ using namespace NEO;
using CommandEncodeStatesTest = Test<CommandEncodeStatesFixture>;
TEST_F(CommandEncodeStatesTest, givenDefaultCommandConatinerGetNumIddsInBlock) {
auto numIdds = cmdContainer->getNumIddPerBlock();
EXPECT_EQ(64u, numIdds);
}
TEST_F(CommandEncodeStatesTest, givenCommandConatinerCreatedWithMaxNumAggregateIddThenVerifyGetNumIddsInBlockIsCorrect) {
auto cmdContainer = new CommandContainer(1);
auto numIdds = cmdContainer->getNumIddPerBlock();
EXPECT_EQ(1u, numIdds);
delete cmdContainer;
}
HWTEST_F(CommandEncodeStatesTest, givenenDispatchInterfaceWhenDispatchKernelThenWalkerCommandProgrammed) {
uint32_t dims[] = {2, 1, 1};
std::unique_ptr<MockDispatchKernelEncoder> dispatchInterface(new MockDispatchKernelEncoder());
@ -295,7 +309,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandEncodeStatesTest, giveNextIddInBlockZeorWhenD
std::unique_ptr<MockDispatchKernelEncoder> dispatchInterface(new MockDispatchKernelEncoder());
cmdContainer->getIndirectHeap(HeapType::DYNAMIC_STATE)->align(HardwareCommandsHelper<FamilyType>::alignInterfaceDescriptorData);
cmdContainer->setIddBlock(cmdContainer->getHeapSpaceAllowGrow(HeapType::DYNAMIC_STATE, sizeof(INTERFACE_DESCRIPTOR_DATA) * cmdContainer->numIddsPerBlock));
cmdContainer->setIddBlock(cmdContainer->getHeapSpaceAllowGrow(HeapType::DYNAMIC_STATE, sizeof(INTERFACE_DESCRIPTOR_DATA) * cmdContainer->getNumIddPerBlock()));
cmdContainer->nextIddInBlock = 0;
EncodeDispatchKernel<FamilyType>::encode(*cmdContainer.get(), dims, false, false, dispatchInterface.get(), 0, pDevice, NEO::PreemptionMode::Disabled);