| 1 |
/* |
| 2 |
* Copyright (C) 2022-2024 Intel Corporation |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: MIT |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
#include "shared/source/gen12lp/hw_cmds_tgllp.h" |
| 9 |
#include "shared/source/gen12lp/hw_info_gen12lp.h" |
| 10 |
#include "shared/source/helpers/compiler_product_helper.h" |
| 11 |
#include "shared/source/os_interface/device_factory.h" |
| 12 |
#include "shared/source/os_interface/product_helper.h" |
| 13 |
#include "shared/test/common/helpers/debug_manager_state_restore.h" |
| 14 |
#include "shared/test/common/helpers/default_hw_info.h" |
| 15 |
#include "shared/test/common/mocks/mock_aub_center.h" |
| 16 |
#include "shared/test/common/mocks/mock_aub_manager.h" |
| 17 |
#include "shared/test/common/mocks/mock_execution_environment.h" |
| 18 |
#include "shared/test/common/test_macros/header/per_product_test_definitions.h" |
| 19 |
#include "shared/test/common/test_macros/test.h" |
| 20 |
#include "shared/test/unit_test/os_interface/product_helper_tests.h" |
| 21 |
|
| 22 |
#include "aubstream/product_family.h" |
| 23 |
#include "platforms.h" |
| 24 |
|
| 25 |
using namespace NEO; |
| 26 |
|
| 27 |
using TgllpHwInfo = ::testing::Test; |
| 28 |
|
| 29 |
TGLLPTEST_F(TgllpHwInfo, givenHwInfoErrorneousConfigStringThenThrow) { |
| 30 |
HardwareInfo hwInfo = *defaultHwInfo; |
| 31 |
GT_SYSTEM_INFO >SystemInfo = hwInfo.gtSystemInfo; |
| 32 |
|
| 33 |
uint64_t config = 0xdeadbeef; |
| 34 |
gtSystemInfo = {0}; |
| 35 |
EXPECT_ANY_THROW(hardwareInfoSetup[productFamily](&hwInfo, false, config, nullptr)); |
| 36 |
EXPECT_EQ(0u, gtSystemInfo.SliceCount); |
| 37 |
EXPECT_EQ(0u, gtSystemInfo.SubSliceCount); |
| 38 |
EXPECT_EQ(0u, gtSystemInfo.DualSubSliceCount); |
| 39 |
EXPECT_EQ(0u, gtSystemInfo.EUCount); |
| 40 |
} |
| 41 |
|
| 42 |
TGLLPTEST_F(TgllpHwInfo, whenUsingCorrectConfigValueThenCorrectHwInfoIsReturned) { |
| 43 |
HardwareInfo hwInfo = *defaultHwInfo; |
| 44 |
GT_SYSTEM_INFO >SystemInfo = hwInfo.gtSystemInfo; |
| 45 |
|
| 46 |
uint64_t config = 0x100060010; |
| 47 |
|
| 48 |
gtSystemInfo = {0}; |
| 49 |
hardwareInfoSetup[productFamily](&hwInfo, false, config, nullptr); |
| 50 |
EXPECT_EQ(1u, gtSystemInfo.SliceCount); |
| 51 |
EXPECT_EQ(6u, gtSystemInfo.DualSubSliceCount); |
| 52 |
|
| 53 |
config = 0x100020010; |
| 54 |
|
| 55 |
gtSystemInfo = {0}; |
| 56 |
hardwareInfoSetup[productFamily](&hwInfo, false, config, nullptr); |
| 57 |
EXPECT_EQ(1u, gtSystemInfo.SliceCount); |
| 58 |
EXPECT_EQ(2u, gtSystemInfo.DualSubSliceCount); |
| 59 |
} |
| 60 |
|
| 61 |
TGLLPTEST_F(TgllpHwInfo, givenBoolWhenCallTgllpHardwareInfoSetupThenFeatureTableAndWorkaroundTableAreSetCorrect) { |
| 62 |
static bool boolValue[]{ |
| 63 |
true, false}; |
| 64 |
HardwareInfo hwInfo = *defaultHwInfo; |
| 65 |
GT_SYSTEM_INFO >SystemInfo = hwInfo.gtSystemInfo; |
| 66 |
FeatureTable &featureTable = hwInfo.featureTable; |
| 67 |
WorkaroundTable &workaroundTable = hwInfo.workaroundTable; |
| 68 |
|
| 69 |
uint64_t configs[] = { |
| 70 |
0x100060010, |
| 71 |
0x100020010}; |
| 72 |
|
| 73 |
for (auto &config : configs) { |
| 74 |
for (auto setParamBool : boolValue) { |
| 75 |
|
| 76 |
gtSystemInfo = {0}; |
| 77 |
featureTable = {}; |
| 78 |
workaroundTable = {}; |
| 79 |
hardwareInfoSetup[productFamily](&hwInfo, setParamBool, config, nullptr); |
| 80 |
|
| 81 |
EXPECT_EQ(setParamBool, featureTable.flags.ftrL3IACoherency); |
| 82 |
EXPECT_EQ(setParamBool, featureTable.flags.ftrPPGTT); |
| 83 |
EXPECT_EQ(setParamBool, featureTable.flags.ftrSVM); |
| 84 |
EXPECT_EQ(setParamBool, featureTable.flags.ftrIA32eGfxPTEs); |
| 85 |
EXPECT_EQ(setParamBool, featureTable.flags.ftrStandardMipTailFormat); |
| 86 |
EXPECT_EQ(setParamBool, featureTable.flags.ftrTranslationTable); |
| 87 |
EXPECT_EQ(setParamBool, featureTable.flags.ftrUserModeTranslationTable); |
| 88 |
EXPECT_EQ(setParamBool, featureTable.flags.ftrTileMappedResource); |
| 89 |
EXPECT_EQ(setParamBool, featureTable.flags.ftrFbc); |
| 90 |
EXPECT_EQ(setParamBool, featureTable.flags.ftrTileY); |
| 91 |
EXPECT_EQ(setParamBool, featureTable.flags.ftrAstcHdr2D); |
| 92 |
EXPECT_EQ(setParamBool, featureTable.flags.ftrAstcLdr2D); |
| 93 |
EXPECT_EQ(setParamBool, featureTable.flags.ftrGpGpuMidBatchPreempt); |
| 94 |
EXPECT_EQ(setParamBool, featureTable.flags.ftrGpGpuThreadGroupLevelPreempt); |
| 95 |
|
| 96 |
EXPECT_EQ(setParamBool, workaroundTable.flags.wa4kAlignUVOffsetNV12LinearSurface); |
| 97 |
EXPECT_EQ(setParamBool, workaroundTable.flags.waUntypedBufferCompression); |
| 98 |
} |
| 99 |
} |
| 100 |
} |
| 101 |
|
| 102 |
TGLLPTEST_F(TgllpHwInfo, givenSetCommandStreamReceiverInAubModeForTgllpProductFamilyWhenPrepareDeviceEnvironmentsForProductFamilyOverrideIsCalledThenAubCenterIsInitializedCorrectly) { |
| 103 |
DebugManagerStateRestore stateRestore; |
| 104 |
debugManager.flags.SetCommandStreamReceiver.set(1); |
| 105 |
debugManager.flags.ProductFamilyOverride.set("tgllp"); |
| 106 |
|
| 107 |
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get()); |
| 108 |
|
| 109 |
bool success = DeviceFactory::prepareDeviceEnvironmentsForProductFamilyOverride(executionEnvironment); |
| 110 |
ASSERT_TRUE(success); |
| 111 |
|
| 112 |
auto rootDeviceEnvironment = static_cast<MockRootDeviceEnvironment *>(executionEnvironment.rootDeviceEnvironments[0].get()); |
| 113 |
|
| 114 |
EXPECT_TRUE(rootDeviceEnvironment->initAubCenterCalled); |
| 115 |
EXPECT_FALSE(rootDeviceEnvironment->localMemoryEnabledReceived); |
| 116 |
} |
| 117 |
|
| 118 |
TGLLPTEST_F(TgllpHwInfo, givenProductHelperStringThenAfterSetupResultingVmeIsDisabled) { |
| 119 |
HardwareInfo hwInfo = *defaultHwInfo; |
| 120 |
|
| 121 |
uint64_t config = 0x100060010; |
| 122 |
hardwareInfoSetup[productFamily](&hwInfo, false, config, nullptr); |
| 123 |
EXPECT_FALSE(hwInfo.capabilityTable.ftrSupportsVmeAvcTextureSampler); |
| 124 |
EXPECT_FALSE(hwInfo.capabilityTable.ftrSupportsVmeAvcPreemption); |
| 125 |
EXPECT_FALSE(hwInfo.capabilityTable.supportsVme); |
| 126 |
} |
| 127 |
|
| 128 |
TGLLPTEST_F(TgllpHwInfo, givenSetCommandStreamReceiverInAubModeWithOverrideGpuAddressSpaceWhenPrepareDeviceEnvironmentsForProductFamilyOverrideIsCalledThenAubManagerIsInitializedWithCorrectGpuAddressSpace) { |
| 129 |
DebugManagerStateRestore stateRestore; |
| 130 |
debugManager.flags.UseAubStream.set(1); |
| 131 |
debugManager.flags.SetCommandStreamReceiver.set(1); |
| 132 |
debugManager.flags.ProductFamilyOverride.set("tgllp"); |
| 133 |
debugManager.flags.OverrideGpuAddressSpace.set(48); |
| 134 |
|
| 135 |
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get()); |
| 136 |
|
| 137 |
bool success = DeviceFactory::prepareDeviceEnvironmentsForProductFamilyOverride(executionEnvironment); |
| 138 |
ASSERT_TRUE(success); |
| 139 |
|
| 140 |
auto rootDeviceEnvironment = static_cast<MockRootDeviceEnvironment *>(executionEnvironment.rootDeviceEnvironments[0].get()); |
| 141 |
|
| 142 |
auto mockAubManager = static_cast<MockAubManager *>(rootDeviceEnvironment->aubCenter->getAubManager()); |
| 143 |
EXPECT_EQ(MemoryConstants::max48BitAddress, mockAubManager->options.gpuAddressSpace); |
| 144 |
} |
| 145 |
|
| 146 |
TGLLPTEST_F(TgllpHwInfo, givenSetCommandStreamReceiverInAubModeWhenPrepareDeviceEnvironmentsForProductFamilyOverrideIsCalledThenAllRootDeviceEnvironmentMembersAreInitialized) { |
| 147 |
DebugManagerStateRestore stateRestore; |
| 148 |
auto requiredDeviceCount = 2u; |
| 149 |
debugManager.flags.CreateMultipleRootDevices.set(requiredDeviceCount); |
| 150 |
debugManager.flags.SetCommandStreamReceiver.set(1); |
| 151 |
debugManager.flags.ProductFamilyOverride.set("tgllp"); |
| 152 |
|
| 153 |
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get(), true, requiredDeviceCount); |
| 154 |
|
| 155 |
bool success = DeviceFactory::prepareDeviceEnvironmentsForProductFamilyOverride(executionEnvironment); |
| 156 |
ASSERT_TRUE(success); |
| 157 |
|
| 158 |
std::set<MemoryOperationsHandler *> memoryOperationHandlers; |
| 159 |
for (auto rootDeviceIndex = 0u; rootDeviceIndex < requiredDeviceCount; rootDeviceIndex++) { |
| 160 |
auto rootDeviceEnvironment = static_cast<MockRootDeviceEnvironment *>(executionEnvironment.rootDeviceEnvironments[rootDeviceIndex].get()); |
| 161 |
EXPECT_TRUE(rootDeviceEnvironment->initAubCenterCalled); |
| 162 |
EXPECT_FALSE(rootDeviceEnvironment->localMemoryEnabledReceived); |
| 163 |
|
| 164 |
auto memoryOperationInterface = rootDeviceEnvironment->memoryOperationsInterface.get(); |
| 165 |
EXPECT_NE(nullptr, memoryOperationInterface); |
| 166 |
EXPECT_EQ(memoryOperationHandlers.end(), memoryOperationHandlers.find(memoryOperationInterface)); |
| 167 |
memoryOperationHandlers.insert(memoryOperationInterface); |
| 168 |
} |
| 169 |
} |
| 170 |
|
| 171 |
using TgllpProductHelper = ProductHelperTest; |
| 172 |
|
| 173 |
TGLLPTEST_F(TgllpProductHelper, whenGettingAubstreamProductFamilyThenProperEnumValueIsReturned) { |
| 174 |
EXPECT_EQ(aub_stream::ProductFamily::Tgllp, productHelper->getAubStreamProductFamily()); |
| 175 |
} |
| 176 |
|
| 177 |
TGLLPTEST_F(TgllpProductHelper, givenProductHelperWhenGettingEvictIfNecessaryFlagSupportedThenExpectTrue) { |
| 178 |
|
| 179 |
EXPECT_TRUE(productHelper->isEvictionIfNecessaryFlagSupported()); |
| 180 |
} |
| 181 |
|
| 182 |
TGLLPTEST_F(TgllpProductHelper, givenProductHelperWhenGetCommandsStreamPropertiesSupportThenExpectCorrectValues) { |
| 183 |
|
| 184 |
EXPECT_FALSE(productHelper->getScmPropertyThreadArbitrationPolicySupport()); |
| 185 |
EXPECT_TRUE(productHelper->getScmPropertyCoherencyRequiredSupport()); |
| 186 |
EXPECT_FALSE(productHelper->getScmPropertyZPassAsyncComputeThreadLimitSupport()); |
| 187 |
EXPECT_FALSE(productHelper->getScmPropertyPixelAsyncComputeThreadLimitSupport()); |
| 188 |
EXPECT_FALSE(productHelper->getScmPropertyLargeGrfModeSupport()); |
| 189 |
EXPECT_FALSE(productHelper->getScmPropertyDevicePreemptionModeSupport()); |
| 190 |
|
| 191 |
EXPECT_FALSE(productHelper->getStateBaseAddressPropertyBindingTablePoolBaseAddressSupport()); |
| 192 |
|
| 193 |
EXPECT_TRUE(productHelper->getFrontEndPropertyScratchSizeSupport()); |
| 194 |
EXPECT_FALSE(productHelper->getFrontEndPropertyPrivateScratchSizeSupport()); |
| 195 |
|
| 196 |
EXPECT_TRUE(productHelper->getPreemptionDbgPropertyPreemptionModeSupport()); |
| 197 |
EXPECT_TRUE(productHelper->getPreemptionDbgPropertyStateSipSupport()); |
| 198 |
EXPECT_TRUE(productHelper->getPreemptionDbgPropertyCsrSurfaceSupport()); |
| 199 |
|
| 200 |
EXPECT_FALSE(productHelper->getFrontEndPropertyComputeDispatchAllWalkerSupport()); |
| 201 |
EXPECT_TRUE(productHelper->getFrontEndPropertyDisableEuFusionSupport()); |
| 202 |
EXPECT_FALSE(productHelper->getFrontEndPropertyDisableOverDispatchSupport()); |
| 203 |
EXPECT_FALSE(productHelper->getFrontEndPropertySingleSliceDispatchCcsModeSupport()); |
| 204 |
|
| 205 |
EXPECT_TRUE(productHelper->getPipelineSelectPropertyMediaSamplerDopClockGateSupport()); |
| 206 |
EXPECT_FALSE(productHelper->getPipelineSelectPropertySystolicModeSupport()); |
| 207 |
} |
| 208 |
|
| 209 |
TGLLPTEST_F(TgllpProductHelper, givenA0SteppingAndTgllpPlatformWhenAskingIfWAIsRequiredThenReturnTrue) { |
| 210 |
std::array<std::pair<uint32_t, bool>, 3> revisions = { |
| 211 |
{{REVISION_A0, true}, |
| 212 |
{REVISION_B, false}, |
| 213 |
{REVISION_C, false}}}; |
| 214 |
|
| 215 |
for (const auto &[revision, paramBool] : revisions) { |
| 216 |
auto hwInfo = *defaultHwInfo; |
| 217 |
hwInfo.platform.usRevId = productHelper->getHwRevIdFromStepping(revision, hwInfo); |
| 218 |
productHelper->configureHardwareCustom(&hwInfo, nullptr); |
| 219 |
|
| 220 |
EXPECT_EQ(paramBool, productHelper->pipeControlWARequired(hwInfo)); |
| 221 |
EXPECT_EQ(paramBool, productHelper->imagePitchAlignmentWARequired(hwInfo)); |
| 222 |
EXPECT_EQ(paramBool, productHelper->isForceEmuInt32DivRemSPWARequired(hwInfo)); |
| 223 |
} |
| 224 |
} |
| 225 |
|
| 226 |
TGLLPTEST_F(TgllpProductHelper, givenProductHelperWhenAskedIf3DPipelineSelectWAIsRequiredThenTrueIsReturned) { |
| 227 |
EXPECT_TRUE(productHelper->is3DPipelineSelectWARequired()); |
| 228 |
} |
| 229 |
|
| 230 |
TGLLPTEST_F(TgllpProductHelper, givenTgllpWhenObtainingBlitterPreferenceThenReturnFalse) { |
| 231 |
EXPECT_FALSE(productHelper->obtainBlitterPreference(pInHwInfo)); |
| 232 |
} |
| 233 |
|
| 234 |
TGLLPTEST_F(TgllpProductHelper, givenCompilerProductHelperWhenGetProductConfigThenCorrectMatchIsFound) { |
| 235 |
EXPECT_EQ(compilerProductHelper->getHwIpVersion(pInHwInfo), AOT::TGL); |
| 236 |
} |
| 237 |
|
| 238 |
TGLLPTEST_F(TgllpProductHelper, givenCompilerProductHelperWhenGettingOclocEnforceZebinFormatThenExpectTrue) { |
| 239 |
EXPECT_TRUE(compilerProductHelper->oclocEnforceZebinFormat()); |
| 240 |
} |