refactor: don't use global GfxCoreHelper getter 2/n

Related-To: NEO-6853
Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
This commit is contained in:
Kamil Kopryk
2023-01-09 15:56:36 +00:00
committed by Compute-Runtime-Automation
parent bd81b5546d
commit f2bbb56d29
20 changed files with 115 additions and 93 deletions

View File

@@ -148,7 +148,7 @@ size_t HardwareCommandsHelper<GfxFamily>::sendInterfaceDescriptorData(
productHelper.updateIddCommand(&interfaceDescriptor, kernelDescriptor.kernelAttributes.numGrfRequired,
kernelDescriptor.kernelAttributes.threadArbitrationPolicy);
EncodeDispatchKernel<GfxFamily>::appendAdditionalIDDFields(&interfaceDescriptor, hardwareInfo, threadsPerThreadGroup,
EncodeDispatchKernel<GfxFamily>::appendAdditionalIDDFields(&interfaceDescriptor, device.getRootDeviceEnvironment(), threadsPerThreadGroup,
slmTotalSize, SlmPolicy::SlmPolicyNone);
interfaceDescriptor.setBindingTablePointer(static_cast<uint32_t>(bindingTablePointer));
@@ -161,8 +161,9 @@ size_t HardwareCommandsHelper<GfxFamily>::sendInterfaceDescriptorData(
EncodeDispatchKernel<GfxFamily>::adjustBindingTablePrefetch(interfaceDescriptor, numSamplers, bindingTablePrefetchSize);
auto &gfxCoreHelper = device.getGfxCoreHelper();
auto programmableIDSLMSize =
static_cast<SHARED_LOCAL_MEMORY_SIZE>(GfxCoreHelperHw<GfxFamily>::get().computeSlmValues(hardwareInfo, slmTotalSize));
static_cast<SHARED_LOCAL_MEMORY_SIZE>(gfxCoreHelper.computeSlmValues(hardwareInfo, slmTotalSize));
if (DebugManager.flags.OverrideSlmAllocationSize.get() != -1) {
programmableIDSLMSize = static_cast<SHARED_LOCAL_MEMORY_SIZE>(DebugManager.flags.OverrideSlmAllocationSize.get());

View File

@@ -87,7 +87,7 @@ struct EncodeDispatchKernel {
static void encodeAdditionalWalkerFields(const HardwareInfo &hwInfo, WALKER_TYPE &walkerCmd, const EncodeWalkerArgs &walkerArgs);
static void appendAdditionalIDDFields(INTERFACE_DESCRIPTOR_DATA *pInterfaceDescriptor, const HardwareInfo &hwInfo,
static void appendAdditionalIDDFields(INTERFACE_DESCRIPTOR_DATA *pInterfaceDescriptor, const RootDeviceEnvironment &rootDeviceEnvironment,
const uint32_t threadsPerThreadGroup, uint32_t slmTotalSize, SlmPolicy slmPolicy);
static void setGrfInfo(INTERFACE_DESCRIPTOR_DATA *pInterfaceDescriptor, uint32_t numGrf, const size_t &sizeCrossThreadData,

View File

@@ -56,6 +56,7 @@ void EncodeDispatchKernel<Family>::encode(CommandContainer &container, EncodeDis
auto pImplicitArgs = args.dispatchInterface->getImplicitArgs();
const HardwareInfo &hwInfo = args.device->getHardwareInfo();
auto &gfxCoreHelper = args.device->getGfxCoreHelper();
LinearStream *listCmdBufferStream = container.getCommandStream();
@@ -84,7 +85,7 @@ void EncodeDispatchKernel<Family>::encode(CommandContainer &container, EncodeDis
kernelDescriptor.kernelAttributes.barrierCount,
hwInfo);
auto slmSize = static_cast<typename INTERFACE_DESCRIPTOR_DATA::SHARED_LOCAL_MEMORY_SIZE>(
GfxCoreHelperHw<Family>::get().computeSlmValues(hwInfo, args.dispatchInterface->getSlmTotalSize()));
gfxCoreHelper.computeSlmValues(hwInfo, args.dispatchInterface->getSlmTotalSize()));
idd.setSharedLocalMemorySize(slmSize);
uint32_t bindingTableStateCount = kernelDescriptor.payloadMappings.bindingTable.numEntries;
@@ -375,7 +376,7 @@ template <typename Family>
inline void EncodeDispatchKernel<Family>::encodeAdditionalWalkerFields(const HardwareInfo &hwInfo, WALKER_TYPE &walkerCmd, const EncodeWalkerArgs &walkerArgs) {}
template <typename Family>
void EncodeDispatchKernel<Family>::appendAdditionalIDDFields(INTERFACE_DESCRIPTOR_DATA *pInterfaceDescriptor, const HardwareInfo &hwInfo, const uint32_t threadsPerThreadGroup, uint32_t slmTotalSize, SlmPolicy slmPolicy) {}
void EncodeDispatchKernel<Family>::appendAdditionalIDDFields(INTERFACE_DESCRIPTOR_DATA *pInterfaceDescriptor, const RootDeviceEnvironment &rootDeviceEnvironment, const uint32_t threadsPerThreadGroup, uint32_t slmTotalSize, SlmPolicy slmPolicy) {}
template <typename Family>
inline void EncodeComputeMode<Family>::adjustPipelineSelect(CommandContainer &container, const NEO::KernelDescriptor &kernelDescriptor) {

View File

@@ -102,8 +102,10 @@ void EncodeDispatchKernel<Family>::encode(CommandContainer &container, EncodeDis
kernelDescriptor.kernelAttributes.barrierCount,
hwInfo);
auto &gfxCoreHelper = args.device->getGfxCoreHelper();
auto slmSize = static_cast<SHARED_LOCAL_MEMORY_SIZE>(
GfxCoreHelperHw<Family>::get().computeSlmValues(hwInfo, args.dispatchInterface->getSlmTotalSize()));
gfxCoreHelper.computeSlmValues(hwInfo, args.dispatchInterface->getSlmTotalSize()));
if (DebugManager.flags.OverrideSlmAllocationSize.get() != -1) {
slmSize = static_cast<SHARED_LOCAL_MEMORY_SIZE>(DebugManager.flags.OverrideSlmAllocationSize.get());
@@ -291,7 +293,7 @@ void EncodeDispatchKernel<Family>::encode(CommandContainer &container, EncodeDis
auto threadGroupCount = walkerCmd.getThreadGroupIdXDimension() * walkerCmd.getThreadGroupIdYDimension() * walkerCmd.getThreadGroupIdZDimension();
EncodeDispatchKernel<Family>::adjustInterfaceDescriptorData(idd, *args.device, hwInfo, threadGroupCount, kernelDescriptor.kernelAttributes.numGrfRequired);
EncodeDispatchKernel<Family>::appendAdditionalIDDFields(&idd, hwInfo, threadsPerThreadGroup,
EncodeDispatchKernel<Family>::appendAdditionalIDDFields(&idd, args.device->getRootDeviceEnvironment(), threadsPerThreadGroup,
args.dispatchInterface->getSlmTotalSize(),
args.dispatchInterface->getSlmPolicy());

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2022 Intel Corporation
* Copyright (C) 2018-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -20,7 +20,7 @@ typedef Gen8Family Family;
static uint32_t slmSizeId[] = {0, 1, 2, 4, 4, 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 16};
template <>
uint32_t GfxCoreHelperHw<Family>::alignSlmSize(uint32_t slmSize) {
uint32_t GfxCoreHelperHw<Family>::alignSlmSize(uint32_t slmSize) const {
if (slmSize == 0u) {
return 0u;
}
@@ -30,7 +30,7 @@ uint32_t GfxCoreHelperHw<Family>::alignSlmSize(uint32_t slmSize) {
}
template <>
uint32_t GfxCoreHelperHw<Family>::computeSlmValues(const HardwareInfo &hwInfo, uint32_t slmSize) {
uint32_t GfxCoreHelperHw<Family>::computeSlmValues(const HardwareInfo &hwInfo, uint32_t slmSize) const {
slmSize += (4 * KB - 1);
slmSize = slmSize >> 12;
slmSize = std::min(slmSize, 15u);

View File

@@ -91,8 +91,8 @@ class GfxCoreHelper {
virtual bool isLinearStoragePreferred(bool isSharedContext, bool isImage1d, bool forceLinearStorage) const = 0;
virtual uint8_t getBarriersCountFromHasBarriers(uint8_t hasBarriers) const = 0;
virtual uint32_t calculateAvailableThreadCount(const HardwareInfo &hwInfo, uint32_t grfCount) const = 0;
virtual uint32_t alignSlmSize(uint32_t slmSize) = 0;
virtual uint32_t computeSlmValues(const HardwareInfo &hwInfo, uint32_t slmSize) = 0;
virtual uint32_t alignSlmSize(uint32_t slmSize) const = 0;
virtual uint32_t computeSlmValues(const HardwareInfo &hwInfo, uint32_t slmSize) const = 0;
virtual bool isWaDisableRccRhwoOptimizationRequired() const = 0;
virtual bool isAdditionalFeatureFlagRequired(const FeatureTable *featureTable) const = 0;
@@ -270,9 +270,9 @@ class GfxCoreHelperHw : public GfxCoreHelper {
uint32_t calculateAvailableThreadCount(const HardwareInfo &hwInfo, uint32_t grfCount) const override;
uint32_t alignSlmSize(uint32_t slmSize) override;
uint32_t alignSlmSize(uint32_t slmSize) const override;
uint32_t computeSlmValues(const HardwareInfo &hwInfo, uint32_t slmSize) override;
uint32_t computeSlmValues(const HardwareInfo &hwInfo, uint32_t slmSize) const override;
static AuxTranslationMode getAuxTranslationMode(const HardwareInfo &hwInfo);

View File

@@ -418,7 +418,7 @@ bool GfxCoreHelperHw<GfxFamily>::isLinearStoragePreferred(bool isSharedContext,
}
template <typename GfxFamily>
uint32_t GfxCoreHelperHw<GfxFamily>::alignSlmSize(uint32_t slmSize) {
uint32_t GfxCoreHelperHw<GfxFamily>::alignSlmSize(uint32_t slmSize) const {
if (slmSize == 0u) {
return 0u;
}
@@ -429,7 +429,7 @@ uint32_t GfxCoreHelperHw<GfxFamily>::alignSlmSize(uint32_t slmSize) {
}
template <typename GfxFamily>
uint32_t GfxCoreHelperHw<GfxFamily>::computeSlmValues(const HardwareInfo &hwInfo, uint32_t slmSize) {
uint32_t GfxCoreHelperHw<GfxFamily>::computeSlmValues(const HardwareInfo &hwInfo, uint32_t slmSize) const {
auto value = std::max(slmSize, 1024u);
value = Math::nextPowerOfTwo(value);
value = Math::getMinLsbSet(value);

View File

@@ -251,12 +251,15 @@ void EncodeDispatchKernel<Family>::encodeAdditionalWalkerFields(const HardwareIn
}
template <>
void EncodeDispatchKernel<Family>::appendAdditionalIDDFields(INTERFACE_DESCRIPTOR_DATA *pInterfaceDescriptor, const HardwareInfo &hwInfo, const uint32_t threadsPerThreadGroup, uint32_t slmTotalSize, SlmPolicy slmPolicy) {
void EncodeDispatchKernel<Family>::appendAdditionalIDDFields(INTERFACE_DESCRIPTOR_DATA *pInterfaceDescriptor, const RootDeviceEnvironment &rootDeviceEnvironment, const uint32_t threadsPerThreadGroup, uint32_t slmTotalSize, SlmPolicy slmPolicy) {
using PREFERRED_SLM_ALLOCATION_SIZE = typename Family::INTERFACE_DESCRIPTOR_DATA::PREFERRED_SLM_ALLOCATION_SIZE;
auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo();
const uint32_t threadsPerDssCount = hwInfo.gtSystemInfo.ThreadCount / hwInfo.gtSystemInfo.DualSubSliceCount;
const uint32_t workGroupCountPerDss = static_cast<uint32_t>(Math::divideAndRoundUp(threadsPerDssCount, threadsPerThreadGroup));
const uint32_t workgroupSlmSize = GfxCoreHelperHw<Family>::get().alignSlmSize(slmTotalSize);
auto &gfxCoreHelper = rootDeviceEnvironment.getHelper<GfxCoreHelper>();
const uint32_t workgroupSlmSize = gfxCoreHelper.alignSlmSize(slmTotalSize);
uint32_t slmSize = 0u;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2022 Intel Corporation
* Copyright (C) 2021-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -283,7 +283,7 @@ std::string GfxCoreHelperHw<Family>::getExtensions(const HardwareInfo &hwInfo) c
}
template <>
uint32_t GfxCoreHelperHw<Family>::alignSlmSize(uint32_t slmSize) {
uint32_t GfxCoreHelperHw<Family>::alignSlmSize(uint32_t slmSize) const {
const uint32_t alignedSlmSizes[] = {
0u,
1u * KB,
@@ -310,7 +310,7 @@ uint32_t GfxCoreHelperHw<Family>::alignSlmSize(uint32_t slmSize) {
}
template <>
uint32_t GfxCoreHelperHw<Family>::computeSlmValues(const HardwareInfo &hwInfo, uint32_t slmSize) {
uint32_t GfxCoreHelperHw<Family>::computeSlmValues(const HardwareInfo &hwInfo, uint32_t slmSize) const {
using SHARED_LOCAL_MEMORY_SIZE = typename Family::INTERFACE_DESCRIPTOR_DATA::SHARED_LOCAL_MEMORY_SIZE;
if (slmSize == 0u) {
return SHARED_LOCAL_MEMORY_SIZE::SHARED_LOCAL_MEMORY_SIZE_ENCODES_0K;

View File

@@ -32,12 +32,13 @@ void EncodeDispatchKernel<Family>::adjustTimestampPacket(WALKER_TYPE &walkerCmd,
}
template <>
void EncodeDispatchKernel<Family>::appendAdditionalIDDFields(INTERFACE_DESCRIPTOR_DATA *pInterfaceDescriptor, const HardwareInfo &hwInfo, const uint32_t threadsPerThreadGroup, uint32_t slmTotalSize, SlmPolicy slmPolicy) {
void EncodeDispatchKernel<Family>::appendAdditionalIDDFields(INTERFACE_DESCRIPTOR_DATA *pInterfaceDescriptor, const RootDeviceEnvironment &rootDeviceEnvironment, const uint32_t threadsPerThreadGroup, uint32_t slmTotalSize, SlmPolicy slmPolicy) {
using PREFERRED_SLM_ALLOCATION_SIZE = typename Family::INTERFACE_DESCRIPTOR_DATA::PREFERRED_SLM_ALLOCATION_SIZE;
auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo();
const uint32_t threadsPerDssCount = hwInfo.gtSystemInfo.ThreadCount / hwInfo.gtSystemInfo.DualSubSliceCount;
const uint32_t workGroupCountPerDss = threadsPerDssCount / threadsPerThreadGroup;
const uint32_t workgroupSlmSize = GfxCoreHelperHw<Family>::get().alignSlmSize(slmTotalSize);
auto &gfxCoreHelper = rootDeviceEnvironment.getHelper<GfxCoreHelper>();
const uint32_t workgroupSlmSize = gfxCoreHelper.alignSlmSize(slmTotalSize);
uint32_t slmSize = 0u;

View File

@@ -126,7 +126,7 @@ bool GfxCoreHelperHw<Family>::isBufferSizeSuitableForCompression(const size_t si
}
template <>
uint32_t GfxCoreHelperHw<Family>::computeSlmValues(const HardwareInfo &hwInfo, uint32_t slmSize) {
uint32_t GfxCoreHelperHw<Family>::computeSlmValues(const HardwareInfo &hwInfo, uint32_t slmSize) const {
using SHARED_LOCAL_MEMORY_SIZE = typename Family::INTERFACE_DESCRIPTOR_DATA::SHARED_LOCAL_MEMORY_SIZE;
auto slmValue = std::max(slmSize, 1024u);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2022 Intel Corporation
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -250,9 +250,9 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandEncodeStatesTest, givenSlmTotalSizeGraterThan
EncodeDispatchKernel<FamilyType>::encode(*cmdContainer.get(), dispatchArgs, nullptr);
auto interfaceDescriptorData = static_cast<INTERFACE_DESCRIPTOR_DATA *>(cmdContainer->getIddBlock());
auto &gfxcoreHelper = this->getHelper<GfxCoreHelper>();
uint32_t expectedValue = static_cast<typename INTERFACE_DESCRIPTOR_DATA::SHARED_LOCAL_MEMORY_SIZE>(
GfxCoreHelperHw<FamilyType>::get().computeSlmValues(pDevice->getHardwareInfo(), slmTotalSize));
gfxcoreHelper.computeSlmValues(pDevice->getHardwareInfo(), slmTotalSize));
EXPECT_EQ(expectedValue, interfaceDescriptorData->getSharedLocalMemorySize());
}

View File

@@ -97,9 +97,9 @@ HWTEST2_F(CommandEncodeStatesTestDg2AndLater, GivenVariousSlmTotalSizesAndSettin
for (auto rev : revs) {
hwInfo.platform.usRevId = ProductHelper::get(productFamily)->getHwRevIdFromStepping(rev, hwInfo);
if ((hwInfo.platform.eProductFamily == IGFX_DG2) && (rev == REVISION_A0)) {
verifyPreferredSlmValues<FamilyType>(valuesToTestForDg2AStep, hwInfo);
verifyPreferredSlmValues<FamilyType>(valuesToTestForDg2AStep, pDevice->getRootDeviceEnvironment());
} else {
verifyPreferredSlmValues<FamilyType>(valuesToTest, hwInfo);
verifyPreferredSlmValues<FamilyType>(valuesToTest, pDevice->getRootDeviceEnvironment());
}
}
}
@@ -119,7 +119,7 @@ HWTEST2_F(CommandEncodeStatesTestDg2AndLater, GivenDebugOverrideWhenSetAdditiona
{32 * KB, debugOverrideValue},
{64 * KB, debugOverrideValue},
};
verifyPreferredSlmValues<FamilyType>(valuesToTest, hardwareInfo);
verifyPreferredSlmValues<FamilyType>(valuesToTest, pDevice->getRootDeviceEnvironment());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2022 Intel Corporation
* Copyright (C) 2021-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -8,6 +8,7 @@
#pragma once
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/kernel/dispatch_kernel_encoder_interface.h"
#include "shared/test/common/test_macros/test.h"
@@ -19,10 +20,11 @@ struct PreferredSlmTestValues {
};
template <typename FamilyType>
void verifyPreferredSlmValues(std::vector<PreferredSlmTestValues<FamilyType>> valuesToTest, NEO::HardwareInfo &hwInfo) {
void verifyPreferredSlmValues(std::vector<PreferredSlmTestValues<FamilyType>> valuesToTest, const NEO::RootDeviceEnvironment &rootDeviceEnvironment) {
using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA;
using PREFERRED_SLM_ALLOCATION_SIZE = typename INTERFACE_DESCRIPTOR_DATA::PREFERRED_SLM_ALLOCATION_SIZE;
auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo();
auto threadsPerDssCount = hwInfo.gtSystemInfo.ThreadCount / hwInfo.gtSystemInfo.SubSliceCount;
uint32_t localWorkGroupsPerDssCounts[] = {1, 2, 4};
@@ -43,7 +45,7 @@ void verifyPreferredSlmValues(std::vector<PreferredSlmTestValues<FamilyType>> va
: valueToTest.preferredSlmAllocationSizePerDss / localWorkGroupsPerDssCount;
NEO::EncodeDispatchKernel<FamilyType>::appendAdditionalIDDFields(&idd,
hwInfo,
rootDeviceEnvironment,
threadsPerThreadGroup,
slmTotalSize,
slmPolicy);

View File

@@ -124,9 +124,9 @@ HWTEST2_F(CommandEncodeStatesTestHpc, GivenVariousSlmTotalSizesAndSettingRevIDTo
for (auto rev : revs) {
hwInfo.platform.usRevId = ProductHelper::get(productFamily)->getHwRevIdFromStepping(rev, hwInfo);
if ((hwInfo.platform.eProductFamily == IGFX_PVC) && (rev == REVISION_A0)) {
verifyPreferredSlmValues<FamilyType>(valuesToTestForPvcAStep, hwInfo);
verifyPreferredSlmValues<FamilyType>(valuesToTestForPvcAStep, pDevice->getRootDeviceEnvironment());
} else {
verifyPreferredSlmValues<FamilyType>(valuesToTest, hwInfo);
verifyPreferredSlmValues<FamilyType>(valuesToTest, pDevice->getRootDeviceEnvironment());
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2022 Intel Corporation
* Copyright (C) 2021-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -52,9 +52,10 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncodeStatesTest, givenSlmTotalSizeGraterTha
auto cmd = genCmdCast<WALKER_TYPE *>(*itor);
auto &idd = cmd->getInterfaceDescriptor();
auto &gfxcoreHelper = this->getHelper<GfxCoreHelper>();
uint32_t expectedValue = static_cast<typename INTERFACE_DESCRIPTOR_DATA::SHARED_LOCAL_MEMORY_SIZE>(
GfxCoreHelperHw<FamilyType>::get().computeSlmValues(pDevice->getHardwareInfo(), slmTotalSize));
gfxcoreHelper.computeSlmValues(pDevice->getHardwareInfo(), slmTotalSize));
EXPECT_EQ(expectedValue, idd.getSharedLocalMemorySize());
}

View File

@@ -1076,51 +1076,51 @@ HWCMDTEST_F(IGFX_GEN8_CORE, GfxCoreHelperTest, GivenVariousValuesWhenAlignSlmSiz
HWCMDTEST_F(IGFX_GEN8_CORE, GfxCoreHelperTest, GivenVariousValuesWhenComputeSlmSizeIsCalledThenCorrectValueIsReturned) {
auto hwInfo = *defaultHwInfo;
auto &gfxCoreHelper = getHelper<GfxCoreHelper>();
if (::renderCoreFamily == IGFX_GEN8_CORE) {
EXPECT_EQ(0u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 0));
EXPECT_EQ(1u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 1));
EXPECT_EQ(1u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 1024));
EXPECT_EQ(1u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 1025));
EXPECT_EQ(1u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 2048));
EXPECT_EQ(1u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 2049));
EXPECT_EQ(1u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 4096));
EXPECT_EQ(2u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 4097));
EXPECT_EQ(2u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 8192));
EXPECT_EQ(4u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 8193));
EXPECT_EQ(4u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 12288));
EXPECT_EQ(4u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 16384));
EXPECT_EQ(8u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 16385));
EXPECT_EQ(8u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 24576));
EXPECT_EQ(8u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 32768));
EXPECT_EQ(16u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 32769));
EXPECT_EQ(16u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 49152));
EXPECT_EQ(16u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 65535));
EXPECT_EQ(16u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 65536));
EXPECT_EQ(0u, gfxCoreHelper.computeSlmValues(hwInfo, 0));
EXPECT_EQ(1u, gfxCoreHelper.computeSlmValues(hwInfo, 1));
EXPECT_EQ(1u, gfxCoreHelper.computeSlmValues(hwInfo, 1024));
EXPECT_EQ(1u, gfxCoreHelper.computeSlmValues(hwInfo, 1025));
EXPECT_EQ(1u, gfxCoreHelper.computeSlmValues(hwInfo, 2048));
EXPECT_EQ(1u, gfxCoreHelper.computeSlmValues(hwInfo, 2049));
EXPECT_EQ(1u, gfxCoreHelper.computeSlmValues(hwInfo, 4096));
EXPECT_EQ(2u, gfxCoreHelper.computeSlmValues(hwInfo, 4097));
EXPECT_EQ(2u, gfxCoreHelper.computeSlmValues(hwInfo, 8192));
EXPECT_EQ(4u, gfxCoreHelper.computeSlmValues(hwInfo, 8193));
EXPECT_EQ(4u, gfxCoreHelper.computeSlmValues(hwInfo, 12288));
EXPECT_EQ(4u, gfxCoreHelper.computeSlmValues(hwInfo, 16384));
EXPECT_EQ(8u, gfxCoreHelper.computeSlmValues(hwInfo, 16385));
EXPECT_EQ(8u, gfxCoreHelper.computeSlmValues(hwInfo, 24576));
EXPECT_EQ(8u, gfxCoreHelper.computeSlmValues(hwInfo, 32768));
EXPECT_EQ(16u, gfxCoreHelper.computeSlmValues(hwInfo, 32769));
EXPECT_EQ(16u, gfxCoreHelper.computeSlmValues(hwInfo, 49152));
EXPECT_EQ(16u, gfxCoreHelper.computeSlmValues(hwInfo, 65535));
EXPECT_EQ(16u, gfxCoreHelper.computeSlmValues(hwInfo, 65536));
} else {
EXPECT_EQ(0u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 0));
EXPECT_EQ(1u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 1));
EXPECT_EQ(1u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 1024));
EXPECT_EQ(2u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 1025));
EXPECT_EQ(2u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 2048));
EXPECT_EQ(3u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 2049));
EXPECT_EQ(3u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 4096));
EXPECT_EQ(4u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 4097));
EXPECT_EQ(4u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 8192));
EXPECT_EQ(5u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 8193));
EXPECT_EQ(5u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 16384));
EXPECT_EQ(6u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 16385));
EXPECT_EQ(6u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 32768));
EXPECT_EQ(7u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 32769));
EXPECT_EQ(7u, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 65536));
EXPECT_EQ(0u, gfxCoreHelper.computeSlmValues(hwInfo, 0));
EXPECT_EQ(1u, gfxCoreHelper.computeSlmValues(hwInfo, 1));
EXPECT_EQ(1u, gfxCoreHelper.computeSlmValues(hwInfo, 1024));
EXPECT_EQ(2u, gfxCoreHelper.computeSlmValues(hwInfo, 1025));
EXPECT_EQ(2u, gfxCoreHelper.computeSlmValues(hwInfo, 2048));
EXPECT_EQ(3u, gfxCoreHelper.computeSlmValues(hwInfo, 2049));
EXPECT_EQ(3u, gfxCoreHelper.computeSlmValues(hwInfo, 4096));
EXPECT_EQ(4u, gfxCoreHelper.computeSlmValues(hwInfo, 4097));
EXPECT_EQ(4u, gfxCoreHelper.computeSlmValues(hwInfo, 8192));
EXPECT_EQ(5u, gfxCoreHelper.computeSlmValues(hwInfo, 8193));
EXPECT_EQ(5u, gfxCoreHelper.computeSlmValues(hwInfo, 16384));
EXPECT_EQ(6u, gfxCoreHelper.computeSlmValues(hwInfo, 16385));
EXPECT_EQ(6u, gfxCoreHelper.computeSlmValues(hwInfo, 32768));
EXPECT_EQ(7u, gfxCoreHelper.computeSlmValues(hwInfo, 32769));
EXPECT_EQ(7u, gfxCoreHelper.computeSlmValues(hwInfo, 65536));
}
}
HWTEST_F(GfxCoreHelperTest, GivenZeroSlmSizeWhenComputeSlmSizeIsCalledThenCorrectValueIsReturned) {
using SHARED_LOCAL_MEMORY_SIZE = typename FamilyType::INTERFACE_DESCRIPTOR_DATA::SHARED_LOCAL_MEMORY_SIZE;
auto hwInfo = *defaultHwInfo;
auto receivedSlmSize = static_cast<SHARED_LOCAL_MEMORY_SIZE>(GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hwInfo, 0));
auto &gfxCoreHelper = getHelper<GfxCoreHelper>();
auto receivedSlmSize = static_cast<SHARED_LOCAL_MEMORY_SIZE>(gfxCoreHelper.computeSlmValues(hwInfo, 0));
EXPECT_EQ(SHARED_LOCAL_MEMORY_SIZE::SHARED_LOCAL_MEMORY_SIZE_ENCODES_0K, receivedSlmSize);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2022 Intel Corporation
* Copyright (C) 2021-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -9,6 +9,7 @@
#include "shared/source/xe_hpc_core/hw_cmds_pvc.h"
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
#include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/test_macros/test.h"
#include "shared/test/unit_test/fixtures/command_container_fixture.h"
#include "shared/test/unit_test/mocks/mock_dispatch_kernel_encoder_interface.h"
@@ -21,7 +22,9 @@ PVCTEST_F(CommandEncodeStatesPvcTest, GivenSmallSlmTotalSizesWhenSetAdditionalIn
using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA;
using PREFERRED_SLM_ALLOCATION_SIZE = typename INTERFACE_DESCRIPTOR_DATA::PREFERRED_SLM_ALLOCATION_SIZE;
HardwareInfo hwInfo = *defaultHwInfo;
MockExecutionEnvironment mockExecutionEnvironment{};
auto &rootDeviceEnvironment = *mockExecutionEnvironment.rootDeviceEnvironments[0];
auto &hwInfo = *rootDeviceEnvironment.getMutableHardwareInfo();
uint32_t threadsCount = 1;
uint32_t slmTotalSize = 0;
@@ -42,7 +45,7 @@ PVCTEST_F(CommandEncodeStatesPvcTest, GivenSmallSlmTotalSizesWhenSetAdditionalIn
hwInfo.platform.usDeviceID = deviceId;
hwInfo.platform.usRevId = revisionToTest.revisionId;
INTERFACE_DESCRIPTOR_DATA idd = FamilyType::cmdInitInterfaceDescriptorData;
EncodeDispatchKernel<FamilyType>::appendAdditionalIDDFields(&idd, hwInfo, threadsCount, slmTotalSize, SlmPolicy::SlmPolicyNone);
EncodeDispatchKernel<FamilyType>::appendAdditionalIDDFields(&idd, rootDeviceEnvironment, threadsCount, slmTotalSize, SlmPolicy::SlmPolicyNone);
if (revisionToTest.isWaRequired) {
EXPECT_EQ(PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_16K, idd.getPreferredSlmAllocationSize());
} else {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2022 Intel Corporation
* Copyright (C) 2021-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -12,6 +12,7 @@
#include "shared/source/xe_hpg_core/hw_cmds_dg2.h"
#include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/test_macros/header/per_product_test_definitions.h"
#include "shared/test/common/test_macros/test.h"
@@ -22,21 +23,24 @@ using CommandEncodeStatesDg2Test = ::testing::Test;
DG2TEST_F(CommandEncodeStatesDg2Test, GivenSmallSlmTotalSizesWhenSetAdditionalInfoIsCalledThenCorrectValuesAreSet) {
using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA;
using PREFERRED_SLM_ALLOCATION_SIZE = typename INTERFACE_DESCRIPTOR_DATA::PREFERRED_SLM_ALLOCATION_SIZE;
MockExecutionEnvironment mockExecutionEnvironment{};
auto &rootDeviceEnvironment = mockExecutionEnvironment.rootDeviceEnvironments[0];
VariableBackup<unsigned short> revisionId(&defaultHwInfo->platform.usRevId);
auto hwInfo = rootDeviceEnvironment->getMutableHardwareInfo();
auto &revisionId = hwInfo->platform.usRevId;
uint32_t threadsCount = 1;
uint32_t slmTotalSize = 0;
{
revisionId = ProductHelper::get(productFamily)->getHwRevIdFromStepping(REVISION_A0, *defaultHwInfo);
revisionId = ProductHelper::get(productFamily)->getHwRevIdFromStepping(REVISION_A0, *hwInfo);
INTERFACE_DESCRIPTOR_DATA idd = FamilyType::cmdInitInterfaceDescriptorData;
EncodeDispatchKernel<FamilyType>::appendAdditionalIDDFields(&idd, *defaultHwInfo, threadsCount, slmTotalSize, SlmPolicy::SlmPolicyNone);
EncodeDispatchKernel<FamilyType>::appendAdditionalIDDFields(&idd, *rootDeviceEnvironment, threadsCount, slmTotalSize, SlmPolicy::SlmPolicyNone);
EXPECT_EQ(PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_128K, idd.getPreferredSlmAllocationSize());
}
{
revisionId = ProductHelper::get(productFamily)->getHwRevIdFromStepping(REVISION_B, *defaultHwInfo);
revisionId = ProductHelper::get(productFamily)->getHwRevIdFromStepping(REVISION_B, *hwInfo);
INTERFACE_DESCRIPTOR_DATA idd = FamilyType::cmdInitInterfaceDescriptorData;
EncodeDispatchKernel<FamilyType>::appendAdditionalIDDFields(&idd, *defaultHwInfo, threadsCount, slmTotalSize, SlmPolicy::SlmPolicyNone);
EncodeDispatchKernel<FamilyType>::appendAdditionalIDDFields(&idd, *rootDeviceEnvironment, threadsCount, slmTotalSize, SlmPolicy::SlmPolicyNone);
EXPECT_EQ(PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_0K, idd.getPreferredSlmAllocationSize());
}
}
@@ -45,8 +49,12 @@ DG2TEST_F(CommandEncodeStatesDg2Test, givenNoWorkaroundNeededWhenSelectingPrefer
using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA;
using PREFERRED_SLM_ALLOCATION_SIZE = typename INTERFACE_DESCRIPTOR_DATA::PREFERRED_SLM_ALLOCATION_SIZE;
HardwareInfo hwInfo = *defaultHwInfo;
hwInfo.platform.usRevId = ProductHelper::get(productFamily)->getHwRevIdFromStepping(REVISION_B, *defaultHwInfo);
MockExecutionEnvironment mockExecutionEnvironment{};
auto &rootDeviceEnvironment = mockExecutionEnvironment.rootDeviceEnvironments[0];
auto &hwInfo = *rootDeviceEnvironment->getMutableHardwareInfo();
hwInfo.platform.usRevId = ProductHelper::get(productFamily)->getHwRevIdFromStepping(REVISION_B, hwInfo);
hwInfo.gtSystemInfo.ThreadCount = 1024;
hwInfo.gtSystemInfo.DualSubSliceCount = 8;
hwInfo.gtSystemInfo.SubSliceCount = 2 * hwInfo.gtSystemInfo.DualSubSliceCount;
@@ -55,28 +63,28 @@ DG2TEST_F(CommandEncodeStatesDg2Test, givenNoWorkaroundNeededWhenSelectingPrefer
const uint32_t threadsPerThreadGroup = 7; // 18 groups will fit in one DSS
const uint32_t slmSizePerThreadGroup = 2 * MemoryConstants::kiloByte;
INTERFACE_DESCRIPTOR_DATA idd = FamilyType::cmdInitInterfaceDescriptorData;
EncodeDispatchKernel<FamilyType>::appendAdditionalIDDFields(&idd, hwInfo, threadsPerThreadGroup, slmSizePerThreadGroup, SlmPolicy::SlmPolicyLargeSlm);
EncodeDispatchKernel<FamilyType>::appendAdditionalIDDFields(&idd, *rootDeviceEnvironment, threadsPerThreadGroup, slmSizePerThreadGroup, SlmPolicy::SlmPolicyLargeSlm);
EXPECT_EQ(PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_64K, idd.getPreferredSlmAllocationSize());
}
{
const uint32_t threadsPerThreadGroup = 8; // 16 groups will fit in one DSS
const uint32_t slmSizePerThreadGroup = 2 * MemoryConstants::kiloByte;
INTERFACE_DESCRIPTOR_DATA idd = FamilyType::cmdInitInterfaceDescriptorData;
EncodeDispatchKernel<FamilyType>::appendAdditionalIDDFields(&idd, hwInfo, threadsPerThreadGroup, slmSizePerThreadGroup, SlmPolicy::SlmPolicyLargeSlm);
EncodeDispatchKernel<FamilyType>::appendAdditionalIDDFields(&idd, *rootDeviceEnvironment, threadsPerThreadGroup, slmSizePerThreadGroup, SlmPolicy::SlmPolicyLargeSlm);
EXPECT_EQ(PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_32K, idd.getPreferredSlmAllocationSize());
}
{
const uint32_t threadsPerThreadGroup = 9; // 14 groups will fit in one DSS
const uint32_t slmSizePerThreadGroup = 2 * MemoryConstants::kiloByte;
INTERFACE_DESCRIPTOR_DATA idd = FamilyType::cmdInitInterfaceDescriptorData;
EncodeDispatchKernel<FamilyType>::appendAdditionalIDDFields(&idd, hwInfo, threadsPerThreadGroup, slmSizePerThreadGroup, SlmPolicy::SlmPolicyLargeSlm);
EncodeDispatchKernel<FamilyType>::appendAdditionalIDDFields(&idd, *rootDeviceEnvironment, threadsPerThreadGroup, slmSizePerThreadGroup, SlmPolicy::SlmPolicyLargeSlm);
EXPECT_EQ(PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_32K, idd.getPreferredSlmAllocationSize());
}
{
const uint32_t threadsPerThreadGroup = 50; // 2 groups will fit in one DSS
const uint32_t slmSizePerThreadGroup = 16 * MemoryConstants::kiloByte;
INTERFACE_DESCRIPTOR_DATA idd = FamilyType::cmdInitInterfaceDescriptorData;
EncodeDispatchKernel<FamilyType>::appendAdditionalIDDFields(&idd, hwInfo, threadsPerThreadGroup, slmSizePerThreadGroup, SlmPolicy::SlmPolicyLargeSlm);
EncodeDispatchKernel<FamilyType>::appendAdditionalIDDFields(&idd, *rootDeviceEnvironment, threadsPerThreadGroup, slmSizePerThreadGroup, SlmPolicy::SlmPolicyLargeSlm);
EXPECT_EQ(PREFERRED_SLM_ALLOCATION_SIZE::PREFERRED_SLM_ALLOCATION_SIZE_32K, idd.getPreferredSlmAllocationSize());
}
}

View File

@@ -144,8 +144,8 @@ MTLTEST_F(GfxCoreHelperTestMtl, givenMtlWhenSetForceNonCoherentThenNothingChange
MTLTEST_F(GfxCoreHelperTestMtl, GivenVariousValuesWhenComputeSlmSizeIsCalledThenCorrectValueIsReturned) {
auto hardwareInfo = *defaultHwInfo;
auto &gfxCoreHelper = getHelper<GfxCoreHelper>();
for (auto &testInput : computeSlmValuesXeHPAndLaterTestsInput) {
EXPECT_EQ(testInput.expected, GfxCoreHelperHw<FamilyType>::get().computeSlmValues(hardwareInfo, testInput.slmSize));
EXPECT_EQ(testInput.expected, gfxCoreHelper.computeSlmValues(hardwareInfo, testInput.slmSize));
}
}