performance: add one time context init preemption mode 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-07-04 16:42:23 +00:00 committed by Compute-Runtime-Automation
parent e70f441f52
commit 69d80ee5bc
2 changed files with 58 additions and 0 deletions

View File

@ -2037,6 +2037,11 @@ void CommandStreamReceiverHw<GfxFamily>::handleImmediateFlushOneTimeContextInitS
flushData.contextOneTimeInit = true;
flushData.estimatedSize += this->getCmdSizeForPerDssBackedBuffer(peekHwInfo());
}
if (this->getPreemptionMode() == PreemptionMode::Initial) {
flushData.contextOneTimeInit = true;
flushData.estimatedSize += PreemptionHelper::getRequiredCmdStreamSize<GfxFamily>(device.getPreemptionMode(), this->getPreemptionMode());
}
}
template <typename GfxFamily>
@ -2051,6 +2056,11 @@ void CommandStreamReceiverHw<GfxFamily>::dispatchImmediateFlushOneTimeContextIni
if (this->isRayTracingStateProgramingNeeded(device)) {
this->dispatchRayTracingStateCommand(csrStream, device);
}
if (this->getPreemptionMode() == PreemptionMode::Initial) {
PreemptionHelper::programCmdStream<GfxFamily>(csrStream, device.getPreemptionMode(), this->getPreemptionMode(), this->getPreemptionAllocation());
this->setPreemptionMode(device.getPreemptionMode());
}
}
}

View File

@ -7,6 +7,7 @@
#include "shared/source/command_container/implicit_scaling.h"
#include "shared/source/command_stream/command_stream_receiver_simulated_hw.h"
#include "shared/source/command_stream/preemption.h"
#include "shared/source/command_stream/scratch_space_controller_base.h"
#include "shared/source/command_stream/tag_allocation_layout.h"
#include "shared/source/command_stream/wait_status.h"
@ -44,6 +45,7 @@
#include "shared/test/common/test_macros/hw_test.h"
#include "shared/test/common/test_macros/test_checks_shared.h"
#include "shared/test/unit_test/direct_submission/direct_submission_controller_mock.h"
#include "shared/test/unit_test/fixtures/preemption_fixture.h"
#include "gtest/gtest.h"
@ -4038,3 +4040,49 @@ HWTEST2_F(CommandStreamReceiverHwTest,
EXPECT_FALSE(commandStreamReceiver.isMadeResident(immediateListCmdBufferAllocation, currentTaskCountType));
}
HWTEST2_F(CommandStreamReceiverHwTest,
givenImmediateFlushTaskWhenPreemptionModeProgrammingNeededThenOneTimePreemptionModeDispatchedOnSupportingPlatform,
IsAtLeastXeHpCore) {
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
bool preemptionModeProgramming = NEO::PreemptionHelper::getRequiredCmdStreamSize<FamilyType>(pDevice->getPreemptionMode(), commandStreamReceiver.getPreemptionMode()) > 0;
auto preemptionDetails = getPreemptionTestHwDetails<FamilyType>();
EXPECT_EQ(NEO::PreemptionMode::Initial, commandStreamReceiver.getPreemptionMode());
commandStreamReceiver.flushImmediateTask(commandStream, commandStream.getUsed(), immediateFlushTaskFlags, *pDevice);
EXPECT_EQ(pDevice->getPreemptionMode(), commandStreamReceiver.getPreemptionMode());
HardwareParse hwParserCsr;
hwParserCsr.parseCommands<FamilyType>(commandStreamReceiver.commandStream, 0);
auto loadRegisterImmList = hwParserCsr.getCommandsList<MI_LOAD_REGISTER_IMM>();
bool foundPreemptionMode = false;
for (const auto &it : loadRegisterImmList) {
auto loadRegisterImmCmd = reinterpret_cast<MI_LOAD_REGISTER_IMM *>(it);
if (loadRegisterImmCmd->getRegisterOffset() == preemptionDetails.regAddress) {
foundPreemptionMode = true;
}
}
EXPECT_EQ(preemptionModeProgramming, foundPreemptionMode);
size_t usedSize = commandStreamReceiver.commandStream.getUsed();
commandStreamReceiver.flushImmediateTask(commandStream,
commandStream.getUsed(),
immediateFlushTaskFlags,
*pDevice);
hwParserCsr.tearDown();
hwParserCsr.parseCommands<FamilyType>(commandStreamReceiver.commandStream, usedSize);
loadRegisterImmList = hwParserCsr.getCommandsList<MI_LOAD_REGISTER_IMM>();
foundPreemptionMode = false;
for (const auto &it : loadRegisterImmList) {
auto loadRegisterImmCmd = reinterpret_cast<MI_LOAD_REGISTER_IMM *>(it);
if (loadRegisterImmCmd->getRegisterOffset() == preemptionDetails.regAddress) {
foundPreemptionMode = true;
}
}
EXPECT_EQ(false, foundPreemptionMode);
}