Refactor state base address programing 4/n

- This change gets level one cache policy from cached values instead
of calling virtual methods

Related-To: NEO-5055

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2023-02-24 16:55:21 +00:00
committed by Compute-Runtime-Automation
parent 57614f9cd4
commit 34064811d2
30 changed files with 283 additions and 94 deletions

View File

@@ -8,6 +8,7 @@
#pragma once
#include "shared/source/command_stream/transfer_direction.h"
#include "shared/source/helpers/cache_policy.h"
#include "shared/source/helpers/hw_mapper.h"
#include "shared/source/helpers/pipe_control_args.h"
#include "shared/source/helpers/vec.h"
@@ -326,6 +327,8 @@ struct CommandListCoreFamily : CommandListImp {
static constexpr bool cmdListDefaultMediaSamplerClockGate = false;
static constexpr bool cmdListDefaultGlobalAtomics = false;
NEO::L1CachePolicy l1CachePolicyData{};
int64_t currentSurfaceStateBaseAddress = NEO::StreamProperty64::initValue;
int64_t currentDynamicStateBaseAddress = NEO::StreamProperty64::initValue;
int64_t currentIndirectObjectBaseAddress = NEO::StreamProperty64::initValue;

View File

@@ -178,6 +178,8 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::initialize(Device *device, NEO
commandContainer.doubleSbaWa = this->doubleSbaWa;
auto gmmHelper = rootDeviceEnvironment.getGmmHelper();
this->defaultMocsIndex = (gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER) >> 1);
this->l1CachePolicyData.init(productHelper);
commandContainer.l1CachePolicyData = &this->l1CachePolicyData;
if (device->isImplicitScalingCapable() && !this->internalUsage && !isCopyOnly()) {
this->partitionCount = static_cast<uint32_t>(this->device->getNEODevice()->getDeviceBitfield().count());
@@ -2381,6 +2383,7 @@ void CommandListCoreFamily<gfxCoreFamily>::updateStreamProperties(Kernel &kernel
updateStreamPropertiesForRegularCommandLists(kernel, isCooperative, threadGroupDimensions, isIndirect);
}
}
template <GFXCORE_FAMILY gfxCoreFamily>
inline bool getFusedEuDisabled(Kernel &kernel, Device *device, const ze_group_count_t *threadGroupDimensions, bool isIndirect) {
auto &kernelAttributes = kernel.getKernelDescriptor().kernelAttributes;
@@ -2621,22 +2624,24 @@ void CommandListCoreFamily<gfxCoreFamily>::programStateBaseAddress(NEO::CommandC
bool isRcs = (this->engineGroupType == NEO::EngineGroupType::RenderCompute);
NEO::EncodeWA<GfxFamily>::addPipeControlBeforeStateBaseAddress(*commandContainer.getCommandStream(), this->device->getNEODevice()->getRootDeviceEnvironment(), isRcs, this->dcFlushSupport);
uint32_t statelessMocsIndex = this->defaultMocsIndex;
NEO::StateBaseAddressProperties *sbaProperties = useSbaProperties ? &this->finalStreamState.stateBaseAddress : nullptr;
STATE_BASE_ADDRESS sba;
NEO::EncodeWA<GfxFamily>::addPipeControlBeforeStateBaseAddress(*commandContainer.getCommandStream(), this->device->getNEODevice()->getRootDeviceEnvironment(), isRcs, this->dcFlushSupport);
NEO::EncodeStateBaseAddressArgs<GfxFamily> encodeStateBaseAddressArgs = {
&commandContainer, // container
sba, // sbaCmd
sbaProperties, // sbaProperties
statelessMocsIndex, // statelessMocsIndex
false, // useGlobalAtomics
this->partitionCount > 1, // multiOsContextCapable
isRcs, // isRcs
this->doubleSbaWa}; // doubleSbaWa
&commandContainer, // container
sba, // sbaCmd
sbaProperties, // sbaProperties
statelessMocsIndex, // statelessMocsIndex
l1CachePolicyData.getL1CacheValue(false), // l1CachePolicy
l1CachePolicyData.getL1CacheValue(true), // l1CachePolicyDebuggerActive
false, // useGlobalAtomics
this->partitionCount > 1, // multiOsContextCapable
isRcs, // isRcs
this->doubleSbaWa}; // doubleSbaWa
NEO::EncodeStateBaseAddress<GfxFamily>::encode(encodeStateBaseAddressArgs);
bool sbaTrackingEnabled = NEO::Debugger::isDebugEnabled(this->internalUsage) && this->device->getL0Debugger();

View File

@@ -70,7 +70,6 @@ struct CommandQueueHw : public CommandQueueImp {
inline bool isNEODebuggerActive(Device *device);
NEO::StreamProperties cmdListBeginState{};
size_t spaceForResidency = 0;
NEO::PreemptionMode preemptionMode{};
NEO::PreemptionMode statePreemption{};

View File

@@ -12,6 +12,7 @@
#include "shared/source/command_stream/linear_stream.h"
#include "shared/source/device/device.h"
#include "shared/source/helpers/api_specific_config.h"
#include "shared/source/helpers/cache_policy.h"
#include "shared/source/helpers/gfx_core_helper.h"
#include "shared/source/helpers/state_base_address.h"
#include "shared/source/helpers/state_base_address_bdw_and_later.inl"
@@ -28,9 +29,10 @@ void CommandQueueHw<gfxCoreFamily>::programStateBaseAddress(uint64_t gsba, bool
using STATE_BASE_ADDRESS = typename GfxFamily::STATE_BASE_ADDRESS;
NEO::Device *neoDevice = device->getNEODevice();
auto csr = this->getCsr();
bool isRcs = csr->isRcs();
auto &rootDeviceEnvironment = neoDevice->getRootDeviceEnvironment();
bool isRcs = this->getCsr()->isRcs();
bool useGlobalSshAndDsh = false;
bool isDebuggerActive = neoDevice->isDebuggerActive() || neoDevice->getDebugger() != nullptr;
@@ -54,8 +56,9 @@ void CommandQueueHw<gfxCoreFamily>::programStateBaseAddress(uint64_t gsba, bool
STATE_BASE_ADDRESS sbaCmd;
NEO::EncodeWA<GfxFamily>::addPipeControlBeforeStateBaseAddress(commandStream, rootDeviceEnvironment, isRcs, this->getCsr()->getDcFlushSupport());
NEO::EncodeWA<GfxFamily>::addPipeControlBeforeStateBaseAddress(commandStream, rootDeviceEnvironment, isRcs, csr->getDcFlushSupport());
NEO::EncodeWA<GfxFamily>::encodeAdditionalPipelineSelect(commandStream, {}, true, rootDeviceEnvironment, isRcs);
auto l1CachePolicyData = csr->getStoredL1CachePolicy();
NEO::StateBaseAddressHelperArgs<GfxFamily> stateBaseAddressHelperArgs = {
gsba, // generalStateBaseAddress
@@ -70,6 +73,8 @@ void CommandQueueHw<gfxCoreFamily>::programStateBaseAddress(uint64_t gsba, bool
nullptr, // ssh
neoDevice->getGmmHelper(), // gmmHelper
(device->getMOCS(cachedMOCSAllowed, false) >> 1), // statelessMocsIndex
l1CachePolicyData->getL1CacheValue(false), // l1CachePolicy
l1CachePolicyData->getL1CacheValue(true), // l1CachePolicyDebuggerActive
NEO::MemoryCompressionState::NotApplicable, // memoryCompressionState
true, // setInstructionStateBaseAddress
true, // setGeneralStateBaseAddress

View File

@@ -9,6 +9,7 @@
#include "shared/source/command_stream/csr_definitions.h"
#include "shared/source/command_stream/scratch_space_controller.h"
#include "shared/source/helpers/api_specific_config.h"
#include "shared/source/helpers/cache_policy.h"
#include "shared/source/helpers/gfx_core_helper.h"
#include "shared/source/helpers/pipe_control_args.h"
#include "shared/source/helpers/state_base_address.h"
@@ -26,9 +27,10 @@ void CommandQueueHw<gfxCoreFamily>::programStateBaseAddress(uint64_t gsba, bool
NEO::Device *neoDevice = device->getNEODevice();
uint32_t rootDeviceIndex = neoDevice->getRootDeviceIndex();
auto csr = this->getCsr();
bool dispatchCommand = false;
bool multiOsContextCapable = device->isImplicitScalingCapable();
bool isRcs = this->getCsr()->isRcs();
bool isRcs = csr->isRcs();
auto isDebuggerActive = neoDevice->isDebuggerActive() || neoDevice->getDebugger() != nullptr;
bool setGeneralStateBaseAddress = false;
bool useGlobalHeapsBaseAddress = false;
@@ -40,6 +42,8 @@ void CommandQueueHw<gfxCoreFamily>::programStateBaseAddress(uint64_t gsba, bool
NEO::StateBaseAddressProperties *sbaProperties = nullptr;
auto l1CachePolicyData = csr->getStoredL1CachePolicy();
if (streamProperties != nullptr) {
dispatchCommand = true;
sbaProperties = &streamProperties->stateBaseAddress;
@@ -56,7 +60,7 @@ void CommandQueueHw<gfxCoreFamily>::programStateBaseAddress(uint64_t gsba, bool
if (dispatchCommand) {
auto gmmHelper = neoDevice->getGmmHelper();
NEO::EncodeWA<GfxFamily>::addPipeControlBeforeStateBaseAddress(commandStream, neoDevice->getRootDeviceEnvironment(), isRcs, this->getCsr()->getDcFlushSupport());
NEO::EncodeWA<GfxFamily>::addPipeControlBeforeStateBaseAddress(commandStream, neoDevice->getRootDeviceEnvironment(), isRcs, csr->getDcFlushSupport());
STATE_BASE_ADDRESS sbaCmd;
NEO::StateBaseAddressHelperArgs<GfxFamily> stateBaseAddressHelperArgs = {
@@ -72,6 +76,8 @@ void CommandQueueHw<gfxCoreFamily>::programStateBaseAddress(uint64_t gsba, bool
nullptr, // ssh
gmmHelper, // gmmHelper
(device->getMOCS(cachedMOCSAllowed, false) >> 1), // statelessMocsIndex
l1CachePolicyData->getL1CacheValue(false), // l1CachePolicy
l1CachePolicyData->getL1CacheValue(true), // l1CachePolicyDebuggerActive
NEO::MemoryCompressionState::NotApplicable, // memoryCompressionState
true, // setInstructionStateBaseAddress
setGeneralStateBaseAddress, // setGeneralStateBaseAddress