refactor: get ioh alignment from static function

Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
Maciej Plewka 2024-07-24 11:27:35 +00:00 committed by Compute-Runtime-Automation
parent 1d3d3e9a79
commit afee8814ef
22 changed files with 65 additions and 52 deletions

View File

@ -997,11 +997,10 @@ struct CmdlistAppendLaunchKernelWithImplicitArgsTests : CmdlistAppendLaunchKerne
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
const auto &rootDeviceEnvironment = device->getNEODevice()->getRootDeviceEnvironment();
const auto &gfxCoreHelper = device->getNEODevice()->getGfxCoreHelper();
implicitArgsProgrammingSize = ImplicitArgsHelper::getSizeForImplicitArgsPatching(&expectedImplicitArgs, *kernelDescriptor, !kernelRequiresGenerationOfLocalIdsByRuntime, rootDeviceEnvironment);
auto sizeCrossThreadData = kernel->getCrossThreadDataSize();
auto sizePerThreadDataForWholeGroup = kernel->getPerThreadDataSizeForWholeThreadGroup();
EXPECT_EQ(indirectHeap->getUsed(), alignUp(sizeCrossThreadData + sizePerThreadDataForWholeGroup + implicitArgsProgrammingSize, gfxCoreHelper.getIOHAlignment()));
EXPECT_EQ(indirectHeap->getUsed(), alignUp(sizeCrossThreadData + sizePerThreadDataForWholeGroup + implicitArgsProgrammingSize, NEO::EncodeDispatchKernel<FamilyType>::getDefaultIOHAlignment()));
if (FamilyType::supportsCmdSet(IGFX_XE_HP_CORE)) {
expectedImplicitArgs.localIdTablePtr = indirectHeapAllocation->getGpuAddress();

View File

@ -3018,7 +3018,7 @@ HWTEST2_F(CommandListAppendLaunchKernel,
auto ioh = commandContainer.getIndirectHeap(NEO::IndirectHeapType::indirectObject);
size_t totalSize = 1024 + 64;
size_t expectedSize = alignUp(totalSize, device->getGfxCoreHelper().getIOHAlignment());
size_t expectedSize = alignUp(totalSize, NEO::EncodeDispatchKernel<FamilyType>::getDefaultIOHAlignment());
EXPECT_EQ(expectedSize, ioh->getUsed());
}

View File

@ -76,7 +76,7 @@ size_t HardwareCommandsHelper<GfxFamily>::getSizeRequiredIOH(const Kernel &kerne
if (pImplicitArgs) {
size += ImplicitArgsHelper::getSizeForImplicitArgsPatching(pImplicitArgs, kernelDescriptor, isHwLocalIdGeneration, rootDeviceEnvironment);
}
return alignUp(size, rootDeviceEnvironment.getHelper<GfxCoreHelper>().getIOHAlignment());
return alignUp(size, NEO::EncodeDispatchKernel<GfxFamily>::getDefaultIOHAlignment());
}
template <typename GfxFamily>
@ -347,7 +347,7 @@ size_t HardwareCommandsHelper<GfxFamily>::sendIndirectState(
WalkerType::INDIRECTDATASTARTADDRESS_ALIGN_SIZE);
walkerCmd->setIndirectDataLength(indirectDataLength);
ioh.align(kernel.getGfxCoreHelper().getIOHAlignment());
ioh.align(NEO::EncodeDispatchKernel<GfxFamily>::getDefaultIOHAlignment());
}
return offsetCrossThreadData;

View File

@ -1385,7 +1385,7 @@ HWTEST_F(DispatchWalkerTest, WhenKernelRequiresImplicitArgsThenIohRequiresMoreSp
HardwareCommandsHelper<FamilyType>::getPerThreadDataSizeTotal(simdSize, grfSize, numGrf, numChannels, Math::computeTotalElementsCount(workGroupSize), false, rootDeviceEnvironment) +
ImplicitArgsHelper::getSizeForImplicitArgsPatching(kernelWithImplicitArgs.getImplicitArgs(), kernelWithImplicitArgs.getDescriptor(), false, rootDeviceEnvironment);
size = alignUp(size, pClDevice->getGfxCoreHelper().getIOHAlignment());
size = alignUp(size, NEO::EncodeDispatchKernel<FamilyType>::getDefaultIOHAlignment());
EXPECT_EQ(size, iohSizeWithImplicitArgs);
}
}

View File

@ -200,6 +200,7 @@ struct EncodeDispatchKernel {
return BINDING_TABLE_STATE::SURFACESTATEPOINTER_ALIGN_SIZE;
}
static size_t getDefaultIOHAlignment();
template <bool isHeapless>
static void setScratchAddress(uint64_t &scratchAddress, uint32_t requiredScratchSlot0Size, uint32_t requiredScratchSlot1Size, IndirectHeap *ssh, CommandStreamReceiver &csr);
template <bool isHeapless>

View File

@ -0,0 +1,13 @@
/*
* Copyright (C) 2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
namespace NEO {
template <typename Family>
size_t EncodeDispatchKernel<Family>::getDefaultIOHAlignment() {
return 1;
}
} // namespace NEO

View File

@ -6,7 +6,13 @@
*/
namespace NEO {
template <>
void EncodeSurfaceState<Family>::setCoherencyType(Family::RENDER_SURFACE_STATE *surfaceState, Family::RENDER_SURFACE_STATE::COHERENCY_TYPE coherencyType) {
template <typename Family>
size_t EncodeDispatchKernel<Family>::getDefaultIOHAlignment() {
size_t alignment = Family::cacheLineSize;
if (NEO::debugManager.flags.ForceIOHAlignment.get() != -1) {
alignment = static_cast<size_t>(debugManager.flags.ForceIOHAlignment.get());
}
return alignment;
}
} // namespace NEO

View File

@ -329,7 +329,7 @@ void EncodeDispatchKernel<Family>::encode(CommandContainer &container, EncodeDis
walkerCmd.setIndirectDataStartAddress(static_cast<uint32_t>(offsetThreadData));
walkerCmd.setIndirectDataLength(sizeThreadData);
container.getIndirectHeap(HeapType::indirectObject)->align(rootDeviceEnvironment.getHelper<GfxCoreHelper>().getIOHAlignment());
container.getIndirectHeap(HeapType::indirectObject)->align(NEO::EncodeDispatchKernel<Family>::getDefaultIOHAlignment());
}
EncodeDispatchKernel<Family>::encodeThreadData(walkerCmd,

View File

@ -6,14 +6,15 @@
*/
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/command_container/command_encoder.inl"
#include "shared/source/command_container/command_encoder_bdw_and_later.inl"
#include "shared/source/command_container/command_encoder_pre_xe2_hpg_core.inl"
#include "shared/source/gen11/hw_cmds_base.h"
#include "shared/source/gen11/reg_configs.h"
#include "shared/source/gen_common/reg_configs_common.h"
using Family = NEO::Gen11Family;
#include "shared/source/command_container/command_encoder.inl"
#include "shared/source/command_container/command_encoder_bdw_and_later.inl"
#include "shared/source/command_container/command_encoder_heap_addressing.inl"
#include "shared/source/command_container/encode_compute_mode_bdw_and_later.inl"
#include "shared/source/command_container/image_surface_state/compression_params_bdw_and_later.inl"

View File

@ -6,6 +6,9 @@
*/
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/command_container/command_encoder.inl"
#include "shared/source/command_container/command_encoder_bdw_and_later.inl"
#include "shared/source/command_container/command_encoder_pre_xe2_hpg_core.inl"
#include "shared/source/command_stream/stream_properties.h"
#include "shared/source/gen12lp/hw_cmds_base.h"
#include "shared/source/gen12lp/reg_configs.h"
@ -17,8 +20,6 @@
using Family = NEO::Gen12LpFamily;
#include "shared/source/command_container/command_encoder.inl"
#include "shared/source/command_container/command_encoder_bdw_and_later.inl"
#include "shared/source/command_container/command_encoder_heap_addressing.inl"
#include "shared/source/command_container/command_encoder_tgllp_and_later.inl"
#include "shared/source/command_container/encode_compute_mode_tgllp_and_later.inl"

View File

@ -6,13 +6,14 @@
*/
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/command_container/command_encoder.inl"
#include "shared/source/command_container/command_encoder_bdw_and_later.inl"
#include "shared/source/command_container/command_encoder_pre_xe2_hpg_core.inl"
#include "shared/source/gen8/hw_cmds_base.h"
#include "shared/source/gen8/reg_configs.h"
using Family = NEO::Gen8Family;
#include "shared/source/command_container/command_encoder.inl"
#include "shared/source/command_container/command_encoder_bdw_and_later.inl"
#include "shared/source/command_container/command_encoder_heap_addressing.inl"
#include "shared/source/command_container/encode_compute_mode_bdw_and_later.inl"
#include "shared/source/command_container/image_surface_state/compression_params_bdw_and_later.inl"

View File

@ -6,13 +6,14 @@
*/
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/command_container/command_encoder.inl"
#include "shared/source/command_container/command_encoder_bdw_and_later.inl"
#include "shared/source/command_container/command_encoder_pre_xe2_hpg_core.inl"
#include "shared/source/gen9/hw_cmds_base.h"
#include "shared/source/gen9/reg_configs.h"
using Family = NEO::Gen9Family;
#include "shared/source/command_container/command_encoder.inl"
#include "shared/source/command_container/command_encoder_bdw_and_later.inl"
#include "shared/source/command_container/command_encoder_heap_addressing.inl"
#include "shared/source/command_container/encode_compute_mode_bdw_and_later.inl"
#include "shared/source/command_container/image_surface_state/compression_params_bdw_and_later.inl"

View File

@ -160,7 +160,6 @@ class GfxCoreHelper {
virtual size_t getMax3dImageWidthOrHeight() const = 0;
virtual uint64_t getMaxMemAllocSize() const = 0;
virtual uint64_t getPatIndex(CacheRegion cacheRegion, CachePolicy cachePolicy) const = 0;
virtual size_t getIOHAlignment() const = 0;
virtual bool isStatelessToStatefulWithOffsetSupported() const = 0;
virtual void encodeBufferSurfaceState(EncodeSurfaceStateArgs &args) const = 0;
virtual bool platformSupportsImplicitScaling(const NEO::RootDeviceEnvironment &rootDeviceEnvironment) const = 0;
@ -399,7 +398,6 @@ class GfxCoreHelperHw : public GfxCoreHelper {
size_t getMax3dImageWidthOrHeight() const override;
uint64_t getMaxMemAllocSize() const override;
uint64_t getPatIndex(CacheRegion cacheRegion, CachePolicy cachePolicy) const override;
size_t getIOHAlignment() const override;
bool isStatelessToStatefulWithOffsetSupported() const override;
void encodeBufferSurfaceState(EncodeSurfaceStateArgs &args) const override;
bool platformSupportsImplicitScaling(const NEO::RootDeviceEnvironment &rootDeviceEnvironment) const override;

View File

@ -670,11 +670,6 @@ uint64_t GfxCoreHelperHw<GfxFamily>::getPatIndex(CacheRegion cacheRegion, CacheP
return -1;
}
template <typename GfxFamily>
size_t GfxCoreHelperHw<GfxFamily>::getIOHAlignment() const {
return 1;
}
template <typename GfxFamily>
bool GfxCoreHelperHw<GfxFamily>::copyThroughLockedPtrEnabled(const HardwareInfo &hwInfo, const ProductHelper &productHelper) const {
if (debugManager.flags.ExperimentalCopyThroughLock.get() != -1) {

View File

@ -22,15 +22,6 @@ void GfxCoreHelperHw<Family>::applyAdditionalCompressionSettings(Gmm &gmm, bool
}
}
template <>
size_t GfxCoreHelperHw<Family>::getIOHAlignment() const {
size_t alignment = 256;
if (debugManager.flags.ForceIOHAlignment.get() != -1) {
alignment = static_cast<size_t>(debugManager.flags.ForceIOHAlignment.get());
}
return alignment;
}
template <>
void GfxCoreHelperHw<Family>::applyRenderCompressionFlag(Gmm &gmm, uint32_t isCompressed) const {}

View File

@ -8,6 +8,7 @@
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/command_container/command_encoder.inl"
#include "shared/source/command_container/command_encoder_heap_addressing.inl"
#include "shared/source/command_container/command_encoder_xe2_hpg_core_and_later.inl"
#include "shared/source/command_container/command_encoder_xehp_and_later.inl"
#include "shared/source/command_container/encode_compute_mode_tgllp_and_later.inl"
#include "shared/source/command_stream/stream_properties.h"
@ -20,7 +21,6 @@
using Family = NEO::Xe2HpgCoreFamily;
#include "shared/source/command_container/command_encoder_tgllp_and_later.inl"
#include "shared/source/command_container/command_encoder_xe2_hpg_core_and_later.inl"
#include "shared/source/command_container/command_encoder_xe_hpc_core_and_later.inl"
#include "shared/source/command_container/command_encoder_xe_hpg_core_and_later.inl"
#include "shared/source/command_container/image_surface_state/compression_params_xehp_and_later.inl"
@ -333,6 +333,10 @@ void EncodeDispatchKernel<Family>::adjustWalkOrder(WalkerType &walkerCmd, uint32
}
}
template <>
void EncodeSurfaceState<Family>::setCoherencyType(Family::RENDER_SURFACE_STATE *surfaceState, Family::RENDER_SURFACE_STATE::COHERENCY_TYPE coherencyType) {
}
} // namespace NEO
#include "shared/source/command_container/command_encoder_enablers.inl"

View File

@ -7,6 +7,7 @@
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/command_container/command_encoder.inl"
#include "shared/source/command_container/command_encoder_pre_xe2_hpg_core.inl"
#include "shared/source/command_container/command_encoder_xehp_and_later.inl"
#include "shared/source/command_container/encode_compute_mode_tgllp_and_later.inl"
#include "shared/source/command_stream/stream_properties.h"

View File

@ -7,6 +7,7 @@
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/command_container/command_encoder.inl"
#include "shared/source/command_container/command_encoder_pre_xe2_hpg_core.inl"
#include "shared/source/command_container/command_encoder_xehp_and_later.inl"
#include "shared/source/command_container/encode_compute_mode_tgllp_and_later.inl"
#include "shared/source/command_stream/stream_properties.h"

View File

@ -90,6 +90,7 @@ using IsAtMostPVC = IsAtMostProduct<IGFX_PVC>;
using IsNotPVC = IsNotWithinProducts<IGFX_PVC, IGFX_PVC>;
using IsNotPvcOrDg2 = IsNotWithinProducts<IGFX_DG2, IGFX_PVC>;
using IsAtMostArl = IsAtMostProduct<IGFX_ARROWLAKE>;
using IsAtLeastBmg = IsAtLeastProduct<IGFX_BMG>;
using HasStatefulSupport = IsNotAnyGfxCores<IGFX_XE_HPC_CORE>;

View File

@ -1629,3 +1629,17 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandEncodeStatesTest, givenEncodeDispatchKernelWh
EXPECT_EQ(0u, EncodeDispatchKernel<FamilyType>::getInlineDataOffset(dispatchArgs));
}
HWTEST2_F(CommandEncodeStatesTest, givenEncodeDispatchKernelWhenGetIohAlignemntThenOneReturned, IsAtMostArl) {
EXPECT_EQ(NEO::EncodeDispatchKernel<FamilyType>::getDefaultIOHAlignment(), 1u);
}
HWTEST2_F(CommandEncodeStatesTest, givenEncodeDispatchKernelWhenGetIohAlignemntThenCacheLineSizeReturned, IsAtLeastBmg) {
EXPECT_EQ(NEO::EncodeDispatchKernel<FamilyType>::getDefaultIOHAlignment(), FamilyType::cacheLineSize);
}
HWTEST2_F(CommandEncodeStatesTest, givenEncodeDispatchKernelWhenForcingDifferentIohAlignemntThenExpectedAlignmentReturned, IsAtLeastBmg) {
DebugManagerStateRestore restorer;
auto expectedAlignemnt = 1024u;
debugManager.flags.ForceIOHAlignment.set(expectedAlignemnt);
EXPECT_EQ(NEO::EncodeDispatchKernel<FamilyType>::getDefaultIOHAlignment(), expectedAlignemnt);
}

View File

@ -595,7 +595,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncodeStatesTest, givenInlineDataRequiredWhe
size_t expectedSizeIOH = alignUp(dispatchInterface->getCrossThreadDataSize() +
dispatchInterface->getPerThreadDataSizeForWholeThreadGroup() -
inlineDataSize,
this->getHelper<GfxCoreHelper>().getIOHAlignment());
NEO::EncodeDispatchKernel<FamilyType>::getDefaultIOHAlignment());
auto heap = cmdContainer->getIndirectHeap(HeapType::indirectObject);
EXPECT_EQ(expectedSizeIOH, heap->getUsed());
}
@ -622,7 +622,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncodeStatesTest, givenInlineDataRequiredIsF
size_t expectedSizeIOH = alignUp(dispatchInterface->getCrossThreadDataSize() +
dispatchInterface->getPerThreadDataSizeForWholeThreadGroup(),
this->getHelper<GfxCoreHelper>().getIOHAlignment());
NEO::EncodeDispatchKernel<FamilyType>::getDefaultIOHAlignment());
auto heap = cmdContainer->getIndirectHeap(HeapType::indirectObject);
EXPECT_EQ(expectedSizeIOH, heap->getUsed());
}
@ -1613,6 +1613,6 @@ HWTEST2_F(CommandEncodeStatesTest, givenEncodeDispatchKernelWhenRequestingExtraP
auto heap = cmdContainer->getIndirectHeap(HeapType::indirectObject);
size_t expectedConsumedSize = 64 + 1024;
expectedConsumedSize = alignUp(expectedConsumedSize, pDevice->getGfxCoreHelper().getIOHAlignment());
expectedConsumedSize = alignUp(expectedConsumedSize, NEO::EncodeDispatchKernel<FamilyType>::getDefaultIOHAlignment());
EXPECT_EQ(expectedConsumedSize, heap->getUsed());
}

View File

@ -25,21 +25,6 @@ HWTEST2_F(GfxCoreHelperXe2AndLaterTests, givenAtLeastXe2HpgWhenCallIsTimestampSh
EXPECT_FALSE(gfxCoreHelper.isTimestampShiftRequired());
}
HWTEST2_F(GfxCoreHelperXe2AndLaterTests, givenAtLeastXe2HpgWhenGetIOHAlignmentThenReturnsCorrectValue, IsAtLeastXe2HpgCore) {
MockExecutionEnvironment mockExecutionEnvironment{};
auto &gfxCoreHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper<GfxCoreHelper>();
EXPECT_EQ(gfxCoreHelper.getIOHAlignment(), 256u);
}
HWTEST2_F(GfxCoreHelperXe2AndLaterTests, givenAtLeastXe2HpgAndForceIOHAlignmentFlagWhenGetIOHAlignmentThenReturnsCorrectValue, IsAtLeastXe2HpgCore) {
DebugManagerStateRestore restorer;
debugManager.flags.ForceIOHAlignment.set(1024);
MockExecutionEnvironment mockExecutionEnvironment{};
auto &gfxCoreHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper<GfxCoreHelper>();
EXPECT_EQ(gfxCoreHelper.getIOHAlignment(), 1024u);
}
HWTEST2_F(GfxCoreHelperXe2AndLaterTests, givenDebugFlagWhenCheckingIsResolveDependenciesByPipeControlsSupportedThenCorrectValueIsReturned, IsLNL) {
DebugManagerStateRestore restorer;