diff --git a/level_zero/core/source/cmdqueue/cmdqueue_hw.inl b/level_zero/core/source/cmdqueue/cmdqueue_hw.inl index facb092740..56ea245410 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue_hw.inl +++ b/level_zero/core/source/cmdqueue/cmdqueue_hw.inl @@ -733,39 +733,38 @@ size_t CommandQueueHw::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::updateOneCmdListPreemptionModeAndCtxStatePre NEO::MemorySynchronizationCommands::addSingleBarrier(cmdStream, args); } NEO::PreemptionHelper::programCmdStream(cmdStream, - cmdListRequired.newMode, + cmdListRequired.newPreemptionMode, NEO::PreemptionMode::Initial, this->csr->getPreemptionAllocation()); } diff --git a/level_zero/core/source/cmdqueue/cmdqueue_imp.h b/level_zero/core/source/cmdqueue/cmdqueue_imp.h index fce1a934d2..7288e03d34 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue_imp.h +++ b/level_zero/core/source/cmdqueue/cmdqueue_imp.h @@ -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; }; diff --git a/shared/source/command_stream/stream_properties.cpp b/shared/source/command_stream/stream_properties.cpp index 8d9379b6a3..f25946ce21 100644 --- a/shared/source/command_stream/stream_properties.cpp +++ b/shared/source/command_stream/stream_properties.cpp @@ -379,17 +379,17 @@ void StateBaseAddressProperties::resetState() { this->statelessMocs.value = StreamProperty::initValue; this->globalAtomics.value = StreamProperty::initValue; - this->bindingTablePoolBaseAddress.value = StreamProperty::initValue; - this->bindingTablePoolSize.value = StreamProperty::initValue; + this->bindingTablePoolBaseAddress.value = StreamProperty64::initValue; + this->bindingTablePoolSize.value = StreamPropertySizeT::initValue; - this->surfaceStateBaseAddress.value = StreamProperty::initValue; - this->surfaceStateSize.value = StreamProperty::initValue; + this->surfaceStateBaseAddress.value = StreamProperty64::initValue; + this->surfaceStateSize.value = StreamPropertySizeT::initValue; - this->indirectObjectBaseAddress.value = StreamProperty::initValue; - this->indirectObjectSize.value = StreamProperty::initValue; + this->indirectObjectBaseAddress.value = StreamProperty64::initValue; + this->indirectObjectSize.value = StreamPropertySizeT::initValue; - this->dynamicStateBaseAddress.value = StreamProperty::initValue; - this->dynamicStateSize.value = StreamProperty::initValue; + this->dynamicStateBaseAddress.value = StreamProperty64::initValue; + this->dynamicStateSize.value = StreamPropertySizeT::initValue; } void StateBaseAddressProperties::setPropertiesBindingTableSurfaceState(int64_t bindingTablePoolBaseAddress, size_t bindingTablePoolSize, @@ -408,8 +408,6 @@ void StateBaseAddressProperties::setPropertiesBindingTableSurfaceState(int64_t b } void StateBaseAddressProperties::setPropertiesSurfaceState(int64_t surfaceStateBaseAddress, size_t surfaceStateSize) { - DEBUG_BREAK_IF(!this->propertiesSupportLoaded); - this->surfaceStateBaseAddress.isDirty = false; this->surfaceStateBaseAddress.set(surfaceStateBaseAddress);