performance: add scratch space handling to immediate flush task

Related-To: NEO-7808

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2023-06-15 17:54:12 +00:00
committed by Compute-Runtime-Automation
parent e1b429db40
commit 1146f42bcb
4 changed files with 93 additions and 1 deletions

View File

@@ -277,6 +277,28 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushImmediateTask(
flushData.stateComputeModeFullConfigurationNeeded = getStateComputeModeDirty();
flushData.stateBaseAddressFullConfigurationNeeded = getGSBAStateDirty();
if (this->requiredScratchSize > 0 || this->requiredPrivateScratchSize > 0) {
bool checkFeStateDirty = false;
bool checkSbaStateDirty = false;
scratchSpaceController->setRequiredScratchSpace(dispatchFlags.sshCpuBase,
0u,
this->requiredScratchSize,
this->requiredPrivateScratchSize,
this->taskCount,
*this->osContext,
checkSbaStateDirty,
checkFeStateDirty);
flushData.frontEndFullConfigurationNeeded |= checkFeStateDirty;
flushData.stateBaseAddressFullConfigurationNeeded |= checkSbaStateDirty;
if (scratchSpaceController->getScratchSpaceAllocation()) {
makeResident(*scratchSpaceController->getScratchSpaceAllocation());
}
if (scratchSpaceController->getPrivateScratchSpaceAllocation()) {
makeResident(*scratchSpaceController->getPrivateScratchSpaceAllocation());
}
}
handleImmediateFlushPipelineSelectState(dispatchFlags, flushData);
handleImmediateFlushFrontEndState(dispatchFlags, flushData);
handleImmediateFlushStateComputeModeState(dispatchFlags, flushData);

View File

@@ -137,7 +137,8 @@ struct CsrSizeRequestFlags {
};
struct ImmediateDispatchFlags {
StreamProperties *requiredState;
StreamProperties *requiredState = nullptr;
void *sshCpuBase = nullptr;
};
} // namespace NEO

View File

@@ -36,6 +36,7 @@ void CommandStreamReceiverFixture::setUp() {
requiredStreamProperties.initSupport(pDevice->getRootDeviceEnvironment());
immediateFlushTaskFlags.requiredState = &requiredStreamProperties;
immediateFlushTaskFlags.sshCpuBase = sshBuffer;
}
void CommandStreamReceiverFixture::tearDown() {

View File

@@ -3603,3 +3603,71 @@ HWTEST2_F(CommandStreamReceiverHwTest,
bindingTableAddress = hwParserCsr.getCommand<_3DSTATE_BINDING_TABLE_POOL_ALLOC>();
EXPECT_EQ(nullptr, bindingTableAddress);
}
HWTEST2_F(CommandStreamReceiverHwTest,
givenImmediateFlushTaskWhenNextDispatchRequiresScratchSpaceThenFrontEndCommandIsDispatched,
IsAtLeastXeHpCore) {
using CFE_STATE = typename FamilyType::CFE_STATE;
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
commandStreamReceiver.storeMakeResidentAllocations = true;
EXPECT_TRUE(commandStreamReceiver.getMediaVFEStateDirty());
commandStreamReceiver.flushImmediateTask(commandStream, commandStream.getUsed(), immediateFlushTaskFlags, *pDevice);
HardwareParse hwParserCsr;
hwParserCsr.parseCommands<FamilyType>(commandStreamReceiver.commandStream, 0);
auto frontEndCmd = hwParserCsr.getCommand<CFE_STATE>();
ASSERT_NE(nullptr, frontEndCmd);
EXPECT_FALSE(commandStreamReceiver.getMediaVFEStateDirty());
commandStreamReceiver.setRequiredScratchSizes(0x100, 0);
size_t usedSize = commandStreamReceiver.commandStream.getUsed();
commandStreamReceiver.flushImmediateTask(commandStream,
commandStream.getUsed(),
immediateFlushTaskFlags,
*pDevice);
hwParserCsr.tearDown();
hwParserCsr.parseCommands<FamilyType>(commandStreamReceiver.commandStream, usedSize);
frontEndCmd = hwParserCsr.getCommand<CFE_STATE>();
ASSERT_NE(nullptr, frontEndCmd);
EXPECT_TRUE(commandStreamReceiver.isMadeResident(commandStreamReceiver.getScratchSpaceController()->getScratchSpaceAllocation()));
}
HWTEST2_F(CommandStreamReceiverHwTest,
givenImmediateFlushTaskWhenNextDispatchRequiresPrivateScratchSpaceThenFrontEndCommandIsDispatched,
IsAtLeastXeHpCore) {
using CFE_STATE = typename FamilyType::CFE_STATE;
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
commandStreamReceiver.storeMakeResidentAllocations = true;
EXPECT_TRUE(commandStreamReceiver.getMediaVFEStateDirty());
commandStreamReceiver.flushImmediateTask(commandStream, commandStream.getUsed(), immediateFlushTaskFlags, *pDevice);
HardwareParse hwParserCsr;
hwParserCsr.parseCommands<FamilyType>(commandStreamReceiver.commandStream, 0);
auto frontEndCmd = hwParserCsr.getCommand<CFE_STATE>();
ASSERT_NE(nullptr, frontEndCmd);
EXPECT_FALSE(commandStreamReceiver.getMediaVFEStateDirty());
commandStreamReceiver.setRequiredScratchSizes(0, 0x100);
size_t usedSize = commandStreamReceiver.commandStream.getUsed();
commandStreamReceiver.flushImmediateTask(commandStream,
commandStream.getUsed(),
immediateFlushTaskFlags,
*pDevice);
hwParserCsr.tearDown();
hwParserCsr.parseCommands<FamilyType>(commandStreamReceiver.commandStream, usedSize);
frontEndCmd = hwParserCsr.getCommand<CFE_STATE>();
ASSERT_NE(nullptr, frontEndCmd);
EXPECT_TRUE(commandStreamReceiver.isMadeResident(commandStreamReceiver.getScratchSpaceController()->getPrivateScratchSpaceAllocation()));
}