performance: limit number of copies of dirty flags and state values

Related-To: NEO-7828

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2023-04-28 22:31:28 +00:00
committed by Compute-Runtime-Automation
parent 34348874e3
commit 01c20212c3
3 changed files with 39 additions and 38 deletions

View File

@@ -733,39 +733,38 @@ size_t CommandQueueHw<gfxCoreFamily>::estimateLinearStreamSizeComplementary(
ctx.globalInit |= !gpgpuEnabled;
ctx.globalInit |= scmStateDirty;
CommandListRequiredStateChange cmdListState;
for (uint32_t i = 0; i < numCommandLists; i++) {
auto cmdList = CommandList::fromHandle(phCommandLists[i]);
auto &requiredStreamState = cmdList->getRequiredStreamState();
auto &finalStreamState = cmdList->getFinalStreamState();
NEO::StreamProperties stagingState{};
bool propertyFeDirty = false;
bool propertyPsDirty = false;
bool propertySbaDirty = false;
bool propertyScmDirty = false;
bool frontEndReturnPoint = false;
bool propertyPreemptionDirty = false;
linearStreamSizeEstimate += estimateFrontEndCmdSizeForMultipleCommandLists(frontEndStateDirty, ctx.engineInstanced, cmdList,
streamProperties, requiredStreamState, finalStreamState,
stagingState, propertyFeDirty, frontEndReturnPoint);
cmdListState.requiredState,
cmdListState.flags.propertyFeDirty, cmdListState.flags.frontEndReturnPoint);
linearStreamSizeEstimate += estimatePipelineSelectCmdSizeForMultipleCommandLists(streamProperties, requiredStreamState, finalStreamState, gpgpuEnabled,
stagingState, propertyPsDirty);
cmdListState.requiredState, cmdListState.flags.propertyPsDirty);
linearStreamSizeEstimate += estimateScmCmdSizeForMultipleCommandLists(streamProperties, scmStateDirty, requiredStreamState, finalStreamState,
stagingState, propertyScmDirty);
cmdListState.requiredState, cmdListState.flags.propertyScmDirty);
linearStreamSizeEstimate += estimateStateBaseAddressCmdSizeForMultipleCommandLists(baseAdresStateDirty, cmdList->getCmdListHeapAddressModel(), streamProperties, requiredStreamState, finalStreamState,
stagingState, propertySbaDirty);
linearStreamSizeEstimate += computePreemptionSizeForCommandList(ctx, cmdList, propertyPreemptionDirty);
cmdListState.requiredState, cmdListState.flags.propertySbaDirty);
linearStreamSizeEstimate += computePreemptionSizeForCommandList(ctx, cmdList, cmdListState.flags.preemptionDirty);
linearStreamSizeEstimate += estimateCommandListSecondaryStart(cmdList);
ctx.spaceForResidency += estimateCommandListResidencySize(cmdList);
if (propertyScmDirty || propertyFeDirty || propertyPsDirty || propertySbaDirty || frontEndReturnPoint || propertyPreemptionDirty) {
CommandListRequiredStateChange stateChange(stagingState, cmdList, {propertyScmDirty, propertyFeDirty, propertyPsDirty, propertySbaDirty, frontEndReturnPoint, propertyPreemptionDirty}, ctx.statePreemption, i);
this->stateChanges.push_back(stateChange);
if (cmdListState.flags.isAnyDirty()) {
cmdListState.commandList = cmdList;
cmdListState.cmdListIndex = i;
cmdListState.newPreemptionMode = ctx.statePreemption;
this->stateChanges.push_back(cmdListState);
linearStreamSizeEstimate += this->estimateCommandListPrimaryStart(true);
cmdListState.requiredState.resetState();
cmdListState.flags.cleanDirty();
}
}
@@ -935,7 +934,7 @@ void CommandQueueHw<gfxCoreFamily>::updateOneCmdListPreemptionModeAndCtxStatePre
NEO::MemorySynchronizationCommands<GfxFamily>::addSingleBarrier(cmdStream, args);
}
NEO::PreemptionHelper::programCmdStream<GfxFamily>(cmdStream,
cmdListRequired.newMode,
cmdListRequired.newPreemptionMode,
NEO::PreemptionMode::Initial,
this->csr->getPreemptionAllocation());
}

View File

@@ -108,21 +108,25 @@ struct CommandQueueImp : public CommandQueue {
bool propertySbaDirty = false;
bool frontEndReturnPoint = false;
bool preemptionDirty = false;
bool isAnyDirty() const {
return (propertyScmDirty || propertyFeDirty || propertyPsDirty || propertySbaDirty || frontEndReturnPoint || preemptionDirty);
}
void cleanDirty() {
propertyScmDirty = false;
propertyFeDirty = false;
propertyPsDirty = false;
propertySbaDirty = false;
frontEndReturnPoint = false;
preemptionDirty = false;
}
};
struct CommandListRequiredStateChange {
CommandListRequiredStateChange() = default;
CommandListRequiredStateChange(NEO::StreamProperties &requiredState, CommandList *commandList,
CommandListDirtyFlags flags,
NEO::PreemptionMode newMode,
uint32_t cmdListIndex) : requiredState(requiredState),
commandList(commandList),
flags(flags),
newMode(newMode),
cmdListIndex(cmdListIndex) {}
NEO::StreamProperties requiredState{};
CommandList *commandList = nullptr;
CommandListDirtyFlags flags;
NEO::PreemptionMode newMode = NEO::PreemptionMode::Initial;
CommandListDirtyFlags flags{};
NEO::PreemptionMode newPreemptionMode = NEO::PreemptionMode::Initial;
uint32_t cmdListIndex = 0;
};