From 0e50c3f7bb9bad2bcb21895004dbb77dd6d96184 Mon Sep 17 00:00:00 2001 From: Pawel Wilma Date: Thu, 3 Sep 2020 12:24:03 +0200 Subject: [PATCH] WA for integer divide emulation on DG1 Resolves: NEO-5003 Change-Id: I2f0d6730cab53335f34ebd8e335a9517030d6441 Signed-off-by: Pawel Wilma --- .../gen12lp/dg1/hw_helper_tests_dg1.cpp | 15 +++++++++ .../offline_compiler_tests.cpp | 31 +++++++++++++++++++ .../source/extra_settings.cpp | 2 +- shared/source/gen12lp/helpers_gen12lp_dg1.cpp | 1 + 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/opencl/test/unit_test/gen12lp/dg1/hw_helper_tests_dg1.cpp b/opencl/test/unit_test/gen12lp/dg1/hw_helper_tests_dg1.cpp index 819eeb300b..4008e4acf0 100644 --- a/opencl/test/unit_test/gen12lp/dg1/hw_helper_tests_dg1.cpp +++ b/opencl/test/unit_test/gen12lp/dg1/hw_helper_tests_dg1.cpp @@ -96,3 +96,18 @@ DG1TEST_F(HwHelperTestDg1, givenDg1WhenPatchingCPUInaccessibleGlobalBuffersThenU HwHelper &hwHelper = HwHelper::get(hardwareInfo.platform.eRenderCoreFamily); EXPECT_TRUE(hwHelper.forceBlitterUseForGlobalBuffers(hardwareInfo, &mockAllocation)); } + +DG1TEST_F(HwHelperTestDg1, givenDg1WhenSteppingA0ThenIntegerDivisionEmulationIsEnabled) { + HwHelper &hwHelper = HwHelper::get(hardwareInfo.platform.eRenderCoreFamily); + uint32_t stepping = REVISION_A0; + hardwareInfo.platform.usRevId = hwHelper.getHwRevIdFromStepping(stepping, hardwareInfo); + auto &helper = HwHelper::get(renderCoreFamily); + EXPECT_TRUE(helper.isForceEmuInt32DivRemSPWARequired(hardwareInfo)); +} + +DG1TEST_F(HwHelperTestDg1, givenDg1WhenSteppingB0ThenIntegerDivisionEmulationIsNotEnabled) { + HwHelper &hwHelper = HwHelper::get(hardwareInfo.platform.eRenderCoreFamily); + hardwareInfo.platform.usRevId = hwHelper.getHwRevIdFromStepping(REVISION_B, hardwareInfo); + auto &helper = HwHelper::get(renderCoreFamily); + EXPECT_FALSE(helper.isForceEmuInt32DivRemSPWARequired(hardwareInfo)); +} diff --git a/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp b/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp index de067aba2f..efbeb89795 100644 --- a/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp @@ -1226,4 +1226,35 @@ TEST(OfflineCompilerTest, givenNoRevisionIdWhenCompilerIsInitializedThenHwInfoHa EXPECT_EQ(SUCCESS, retVal); EXPECT_EQ(mockOfflineCompiler->hwInfo.platform.usRevId, revId); } + +struct WorkaroundApplicableForDevice { + const char *deviceName; + bool applicable; +}; + +using OfflineCompilerTestWithParams = testing::TestWithParam; + +TEST_P(OfflineCompilerTestWithParams, givenRklWhenExtraSettingsResolvedThenForceEmuInt32DivRemSPIsApplied) { + WorkaroundApplicableForDevice params = GetParam(); + MockOfflineCompiler mockOfflineCompiler; + mockOfflineCompiler.deviceName = params.deviceName; + + mockOfflineCompiler.parseDebugSettings(); + + std::string internalOptions = mockOfflineCompiler.internalOptions; + size_t found = internalOptions.find(NEO::CompilerOptions::forceEmuInt32DivRemSP.data()); + if (params.applicable) { + EXPECT_NE(std::string::npos, found); + } else { + EXPECT_EQ(std::string::npos, found); + } +} + +WorkaroundApplicableForDevice workaroundApplicableForDeviceArray[] = {{"rkl", true}, {"dg1", false}, {"tgllp", false}}; + +INSTANTIATE_TEST_CASE_P( + WorkaroundApplicable, + OfflineCompilerTestWithParams, + testing::ValuesIn(workaroundApplicableForDeviceArray)); + } // namespace NEO diff --git a/shared/offline_compiler/source/extra_settings.cpp b/shared/offline_compiler/source/extra_settings.cpp index dd9081b73b..5d11a0f667 100644 --- a/shared/offline_compiler/source/extra_settings.cpp +++ b/shared/offline_compiler/source/extra_settings.cpp @@ -12,7 +12,7 @@ namespace NEO { void OfflineCompiler::resolveExtraSettings() { - if (deviceName == "tgllp" || deviceName == "rkl") { + if (deviceName == "rkl") { CompilerOptions::concatenateAppend(internalOptions, CompilerOptions::forceEmuInt32DivRemSP); } } diff --git a/shared/source/gen12lp/helpers_gen12lp_dg1.cpp b/shared/source/gen12lp/helpers_gen12lp_dg1.cpp index 734099eba0..0ef7eb76c0 100644 --- a/shared/source/gen12lp/helpers_gen12lp_dg1.cpp +++ b/shared/source/gen12lp/helpers_gen12lp_dg1.cpp @@ -82,6 +82,7 @@ bool isOffsetToSkipSetFFIDGPWARequired(const HardwareInfo &hwInfo) { bool isForceEmuInt32DivRemSPWARequired(const HardwareInfo &hwInfo) { HwHelper &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily); return (((hwInfo.platform.eProductFamily == IGFX_TIGERLAKE_LP) & (hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_B, hwInfo))) || + ((hwInfo.platform.eProductFamily == IGFX_DG1) & (hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_B, hwInfo))) || ((hwInfo.platform.eProductFamily == IGFX_ROCKETLAKE) & (hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_C, hwInfo)))); }