feature: add new functionality to in order patch helpers

Related-To: NEO-10385

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz 2024-03-11 12:37:03 +00:00 committed by Compute-Runtime-Automation
parent 75ce4dbe3b
commit 3f740f3460
6 changed files with 134 additions and 0 deletions

View File

@ -349,6 +349,10 @@ struct CommandListCoreFamily : public CommandListImp {
bool isSkippingInOrderBarrierAllowed(ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents) const;
void encodeMiFlush(uint64_t immediateDataGpuAddress, uint64_t immediateData, NEO::MiFlushArgs &args);
void updateInOrderExecInfo(size_t inOrderPatchIndex, std::shared_ptr<NEO::InOrderExecInfo> *inOrderExecInfo);
void disablePatching(size_t inOrderPatchIndex);
void enablePatching(size_t inOrderPatchIndex);
NEO::InOrderPatchCommandsContainer<GfxFamily> inOrderPatchCmds;
uint64_t latestHostWaitedInOrderSyncValue = 0;

View File

@ -3817,4 +3817,24 @@ void CommandListCoreFamily<gfxCoreFamily>::encodeMiFlush(uint64_t immediateDataG
commandContainer.addToResidencyContainer(dummyAllocation);
}
}
template <GFXCORE_FAMILY gfxCoreFamily>
void CommandListCoreFamily<gfxCoreFamily>::updateInOrderExecInfo(size_t inOrderPatchIndex, std::shared_ptr<NEO::InOrderExecInfo> *inOrderExecInfo) {
auto &patchCmd = inOrderPatchCmds[inOrderPatchIndex];
patchCmd.updateInOrderExecInfo(inOrderExecInfo);
patchCmd.setSkipPatching(false);
}
template <GFXCORE_FAMILY gfxCoreFamily>
void CommandListCoreFamily<gfxCoreFamily>::disablePatching(size_t inOrderPatchIndex) {
auto &patchCmd = inOrderPatchCmds[inOrderPatchIndex];
patchCmd.setSkipPatching(true);
}
template <GFXCORE_FAMILY gfxCoreFamily>
void CommandListCoreFamily<gfxCoreFamily>::enablePatching(size_t inOrderPatchIndex) {
auto &patchCmd = inOrderPatchCmds[inOrderPatchIndex];
patchCmd.setSkipPatching(false);
}
} // namespace L0

View File

@ -30,6 +30,7 @@ struct WhiteBox<::L0::CommandListCoreFamily<gfxCoreFamily>>
: public ::L0::CommandListCoreFamily<gfxCoreFamily> {
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
using BaseClass = ::L0::CommandListCoreFamily<gfxCoreFamily>;
using BaseClass::addCmdForPatching;
using BaseClass::addFlushRequiredCommand;
using BaseClass::allocateOrReuseKernelPrivateMemoryIfNeeded;
using BaseClass::appendBlitFill;
@ -63,8 +64,10 @@ struct WhiteBox<::L0::CommandListCoreFamily<gfxCoreFamily>>
using BaseClass::currentSurfaceStateBaseAddress;
using BaseClass::dcFlushSupport;
using BaseClass::device;
using BaseClass::disablePatching;
using BaseClass::dispatchCmdListBatchBufferAsPrimary;
using BaseClass::doubleSbaWa;
using BaseClass::enablePatching;
using BaseClass::engineGroupType;
using BaseClass::estimateBufferSizeMultiTileBarrier;
using BaseClass::eventSignalPipeControl;
@ -103,6 +106,7 @@ struct WhiteBox<::L0::CommandListCoreFamily<gfxCoreFamily>>
using BaseClass::stateBaseAddressTracking;
using BaseClass::stateComputeModeTracking;
using BaseClass::unifiedMemoryControls;
using BaseClass::updateInOrderExecInfo;
using BaseClass::updateStreamProperties;
using BaseClass::updateStreamPropertiesForFlushTaskDispatchFlags;
using BaseClass::updateStreamPropertiesForRegularCommandLists;
@ -163,6 +167,7 @@ struct WhiteBox<L0::CommandListCoreFamilyImmediate<gfxCoreFamily>>
: public L0::CommandListCoreFamilyImmediate<gfxCoreFamily> {
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
using BaseClass = L0::CommandListCoreFamilyImmediate<gfxCoreFamily>;
using BaseClass::addCmdForPatching;
using BaseClass::appendBlitFill;
using BaseClass::appendLaunchKernelWithParams;
using BaseClass::appendMemoryCopyBlitRegion;
@ -177,7 +182,9 @@ struct WhiteBox<L0::CommandListCoreFamilyImmediate<gfxCoreFamily>>
using BaseClass::csr;
using BaseClass::dcFlushSupport;
using BaseClass::device;
using BaseClass::disablePatching;
using BaseClass::doubleSbaWa;
using BaseClass::enablePatching;
using BaseClass::engineGroupType;
using BaseClass::eventSignalPipeControl;
using BaseClass::finalStreamState;
@ -207,6 +214,7 @@ struct WhiteBox<L0::CommandListCoreFamilyImmediate<gfxCoreFamily>>
using BaseClass::stateBaseAddressTracking;
using BaseClass::stateComputeModeTracking;
using BaseClass::synchronizeInOrderExecution;
using BaseClass::updateInOrderExecInfo;
WhiteBox() : BaseClass(BaseClass::defaultNumIddsPerBlock) {}

View File

@ -5732,5 +5732,35 @@ HWTEST2_F(InOrderRegularCmdListTests, givenNonInOrderRegularCmdListWhenPassingCo
verifyPatching(2);
}
HWTEST2_F(InOrderRegularCmdListTests, givenAddedCmdForPatchWhenUpdateNewInOrderInfoThenNewInfoIsSet, IsAtLeastXeHpCore) {
auto semaphoreCmd = FamilyType::cmdInitMiSemaphoreWait;
auto inOrderRegularCmdList = createRegularCmdList<gfxCoreFamily>(false);
auto &inOrderExecInfo = inOrderRegularCmdList->inOrderExecInfo;
inOrderExecInfo->addRegularCmdListSubmissionCounter(4);
inOrderExecInfo->addCounterValue(1);
auto inOrderRegularCmdList2 = createRegularCmdList<gfxCoreFamily>(false);
auto &inOrderExecInfo2 = inOrderRegularCmdList2->inOrderExecInfo;
inOrderExecInfo2->addRegularCmdListSubmissionCounter(6);
inOrderExecInfo2->addCounterValue(1);
inOrderRegularCmdList->addCmdForPatching(&inOrderExecInfo, &semaphoreCmd, nullptr, 1, NEO::InOrderPatchCommandHelpers::PatchCmdType::semaphore);
ASSERT_EQ(1u, inOrderRegularCmdList->inOrderPatchCmds.size());
inOrderRegularCmdList->disablePatching(0);
inOrderRegularCmdList->inOrderPatchCmds[0].patch(3);
EXPECT_EQ(0u, semaphoreCmd.getSemaphoreDataDword());
inOrderRegularCmdList->enablePatching(0);
inOrderRegularCmdList->inOrderPatchCmds[0].patch(3);
EXPECT_EQ(4u, semaphoreCmd.getSemaphoreDataDword());
inOrderRegularCmdList->updateInOrderExecInfo(0, &inOrderExecInfo2);
inOrderRegularCmdList->inOrderPatchCmds[0].patch(3);
EXPECT_EQ(6u, semaphoreCmd.getSemaphoreDataDword());
}
} // namespace ult
} // namespace L0

View File

@ -123,6 +123,9 @@ struct PatchCmd {
}
void patch(uint64_t appendCounterValue) {
if (skipPatching) {
return;
}
switch (patchCmdType) {
case PatchCmdType::sdi:
patchSdi(appendCounterValue);
@ -142,6 +145,14 @@ struct PatchCmd {
}
}
void updateInOrderExecInfo(std::shared_ptr<InOrderExecInfo> *inOrderExecInfo) {
this->inOrderExecInfo = *inOrderExecInfo;
}
void setSkipPatching(bool value) {
skipPatching = value;
}
bool isExternalDependency() const { return inOrderExecInfo.get(); }
std::shared_ptr<InOrderExecInfo> inOrderExecInfo;
@ -151,6 +162,7 @@ struct PatchCmd {
const PatchCmdType patchCmdType = PatchCmdType::none;
bool deviceAtomicSignaling = false;
bool duplicatedHostStorage = false;
bool skipPatching = false;
protected:
void patchSdi(uint64_t appendCounterValue) {

View File

@ -271,6 +271,66 @@ HWTEST_F(CommandEncoderTests, givenInOrderExecInfoWhenPatchingWalkerThenSetCorre
}
}
HWTEST_F(CommandEncoderTests, givenInOrderExecInfoWhenPatchingDisabledThenNoCmdBufferUpdated) {
MockDevice mockDevice;
MockExecutionEnvironment mockExecutionEnvironment{};
MockMemoryManager memoryManager(mockExecutionEnvironment);
MockTagAllocator<DeviceAllocNodeType<true>> tagAllocator(0, mockDevice.getMemoryManager());
auto node = tagAllocator.getTag();
auto inOrderExecInfo = std::make_shared<InOrderExecInfo>(node, nullptr, memoryManager, 1, 0, true, false);
inOrderExecInfo->addRegularCmdListSubmissionCounter(4);
inOrderExecInfo->addCounterValue(1);
auto cmd = FamilyType::cmdInitMiSemaphoreWait;
cmd.setSemaphoreDataDword(1);
constexpr uint64_t baseCounterValue = 1;
InOrderPatchCommandHelpers::PatchCmd<FamilyType> patchCmd(&inOrderExecInfo, &cmd, nullptr, baseCounterValue, InOrderPatchCommandHelpers::PatchCmdType::semaphore, false, false);
patchCmd.setSkipPatching(true);
patchCmd.patch(2);
EXPECT_EQ(1u, cmd.getSemaphoreDataDword());
patchCmd.setSkipPatching(false);
patchCmd.patch(2);
EXPECT_EQ(4u, cmd.getSemaphoreDataDword());
}
HWTEST_F(CommandEncoderTests, givenNewInOrderExecInfoWhenChangingInOrderExecInfoThenNewValuePatched) {
MockDevice mockDevice;
MockExecutionEnvironment mockExecutionEnvironment{};
MockMemoryManager memoryManager(mockExecutionEnvironment);
MockTagAllocator<DeviceAllocNodeType<true>> tagAllocator(0, mockDevice.getMemoryManager());
auto node = tagAllocator.getTag();
auto inOrderExecInfo = std::make_shared<InOrderExecInfo>(node, nullptr, memoryManager, 1, 0, true, false);
inOrderExecInfo->addRegularCmdListSubmissionCounter(4);
inOrderExecInfo->addCounterValue(1);
auto cmd = FamilyType::cmdInitMiSemaphoreWait;
cmd.setSemaphoreDataDword(1);
constexpr uint64_t baseCounterValue = 1;
InOrderPatchCommandHelpers::PatchCmd<FamilyType> patchCmd(&inOrderExecInfo, &cmd, nullptr, baseCounterValue, InOrderPatchCommandHelpers::PatchCmdType::semaphore, false, false);
patchCmd.patch(2);
EXPECT_EQ(4u, cmd.getSemaphoreDataDword());
auto node2 = tagAllocator.getTag();
auto inOrderExecInfo2 = std::make_shared<InOrderExecInfo>(node2, nullptr, memoryManager, 1, 0, true, false);
inOrderExecInfo2->addRegularCmdListSubmissionCounter(6);
inOrderExecInfo2->addCounterValue(1);
patchCmd.updateInOrderExecInfo(&inOrderExecInfo2);
patchCmd.patch(2);
EXPECT_EQ(6u, cmd.getSemaphoreDataDword());
}
HWTEST_F(CommandEncoderTests, givenImmDataWriteWhenProgrammingMiFlushDwThenSetAllRequiredFields) {
using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW;
uint8_t buffer[2 * sizeof(MI_FLUSH_DW)] = {};