From 8fffdcc1111dba58ed2b16678a7d7251b79becde Mon Sep 17 00:00:00 2001 From: Kamil Kopryk Date: Thu, 13 Aug 2020 14:09:05 +0200 Subject: [PATCH] Add adjustPlatformCoreFamilyForIgc helper Change-Id: Ic372e76c1024ca9e585bef15fab29827d33122f3 Signed-off-by: Kamil Kopryk Related-To: NEO-4865 --- level_zero/core/source/module/module_imp.cpp | 9 +++++++-- opencl/source/program/program.cpp | 9 +++++++-- .../unit_test/program/process_elf_binary_tests.cpp | 3 ++- opencl/test/unit_test/program/program_tests.cpp | 7 ++++--- shared/offline_compiler/source/extra_settings.cpp | 3 +++ shared/offline_compiler/source/offline_compiler.cpp | 8 ++++++-- shared/offline_compiler/source/offline_compiler.h | 1 + .../source/compiler_interface/compiler_interface.cpp | 11 ++++++++--- shared/source/helpers/hw_helper.h | 3 +++ shared/source/helpers/hw_helper_base.inl | 4 ++++ .../compiler_interface/compiler_interface_tests.cpp | 3 ++- 11 files changed, 47 insertions(+), 14 deletions(-) diff --git a/level_zero/core/source/module/module_imp.cpp b/level_zero/core/source/module/module_imp.cpp index 350abd10c2..58fe1f2231 100644 --- a/level_zero/core/source/module/module_imp.cpp +++ b/level_zero/core/source/module/module_imp.cpp @@ -115,8 +115,13 @@ bool ModuleTranslationUnit::createFromNativeBinary(const char *input, size_t inp auto productAbbreviation = NEO::hardwarePrefix[device->getNEODevice()->getHardwareInfo().platform.eProductFamily]; NEO::TargetDevice targetDevice = {}; - targetDevice.coreFamily = device->getNEODevice()->getHardwareInfo().platform.eRenderCoreFamily; - targetDevice.stepping = device->getNEODevice()->getHardwareInfo().platform.usRevId; + + auto copyHwInfo = device->getNEODevice()->getHardwareInfo(); + auto &hwHelper = NEO::HwHelper::get(copyHwInfo.platform.eRenderCoreFamily); + hwHelper.adjustPlatformCoreFamilyForIgc(copyHwInfo); + + targetDevice.coreFamily = copyHwInfo.platform.eRenderCoreFamily; + targetDevice.stepping = copyHwInfo.platform.usRevId; targetDevice.maxPointerSizeInBytes = sizeof(uintptr_t); std::string decodeErrors; std::string decodeWarnings; diff --git a/opencl/source/program/program.cpp b/opencl/source/program/program.cpp index 23a815f654..50542b2da9 100644 --- a/opencl/source/program/program.cpp +++ b/opencl/source/program/program.cpp @@ -168,8 +168,13 @@ cl_int Program::createProgramFromBinary( auto productAbbreviation = hardwarePrefix[pDevice->getHardwareInfo().platform.eProductFamily]; TargetDevice targetDevice = {}; - targetDevice.coreFamily = pDevice->getHardwareInfo().platform.eRenderCoreFamily; - targetDevice.stepping = pDevice->getHardwareInfo().platform.usRevId; + + auto copyHwInfo = pDevice->getHardwareInfo(); + auto &hwHelper = HwHelper::get(copyHwInfo.platform.eRenderCoreFamily); + hwHelper.adjustPlatformCoreFamilyForIgc(copyHwInfo); + targetDevice.coreFamily = copyHwInfo.platform.eRenderCoreFamily; + + targetDevice.stepping = copyHwInfo.platform.usRevId; targetDevice.maxPointerSizeInBytes = sizeof(uintptr_t); std::string decodeErrors; std::string decodeWarnings; diff --git a/opencl/test/unit_test/program/process_elf_binary_tests.cpp b/opencl/test/unit_test/program/process_elf_binary_tests.cpp index ddeafafc9c..10d1c86bd2 100644 --- a/opencl/test/unit_test/program/process_elf_binary_tests.cpp +++ b/opencl/test/unit_test/program/process_elf_binary_tests.cpp @@ -17,6 +17,7 @@ #include "opencl/test/unit_test/mocks/mock_cl_device.h" #include "opencl/test/unit_test/mocks/mock_program.h" +#include "test.h" #include "compiler_options.h" #include "gtest/gtest.h" @@ -235,7 +236,7 @@ TEST_F(ProcessElfBinaryTests, GivenNonEmptyBuildOptionsWhenCreatingProgramFromBi EXPECT_STREQ(buildOptionsNotEmpty.c_str(), options.c_str()); } -TEST_F(ProcessElfBinaryTests, GivenBinaryWhenIncompatiblePatchtokenVerionThenProramCreationFails) { +HWTEST_F(ProcessElfBinaryTests, GivenBinaryWhenIncompatiblePatchtokenVerionThenProramCreationFails) { PatchTokensTestData::ValidEmptyProgram programTokens; { NEO::Elf::ElfEncoder<> elfEncoder; diff --git a/opencl/test/unit_test/program/program_tests.cpp b/opencl/test/unit_test/program/program_tests.cpp index 72c399eda7..4dda757792 100644 --- a/opencl/test/unit_test/program/program_tests.cpp +++ b/opencl/test/unit_test/program/program_tests.cpp @@ -2721,8 +2721,9 @@ TEST_F(ProgramTests, WhenProgramIsCreatedThenItsDeviceIsProperlySet) { MockProgram programWithDeviceWithValidSpecializedDevice{executionEnvironment, nullptr, false, &validClDevice.getDevice()}; EXPECT_TRUE(wasValidClDeviceUsed(programWithDeviceWithValidSpecializedDevice)); } +using CreateProgramFromBinaryTests2 = ::testing::Test; -TEST(CreateProgramFromBinaryTests, givenBinaryProgramWhenKernelRebulildIsForcedThenDeviceBinaryIsNotUsed) { +HWTEST_F(CreateProgramFromBinaryTests2, givenBinaryProgramWhenKernelRebulildIsForcedThenDeviceBinaryIsNotUsed) { DebugManagerStateRestore dbgRestorer; DebugManager.flags.RebuildPrecompiledKernels.set(true); cl_int retVal = CL_INVALID_BINARY; @@ -2743,7 +2744,7 @@ TEST(CreateProgramFromBinaryTests, givenBinaryProgramWhenKernelRebulildIsForcedT EXPECT_EQ(0U, pProgram->packedDeviceBinarySize); } -TEST(CreateProgramFromBinaryTests, givenBinaryProgramWhenKernelRebulildIsNotForcedThenDeviceBinaryIsUsed) { +HWTEST_F(CreateProgramFromBinaryTests2, givenBinaryProgramWhenKernelRebulildIsNotForcedThenDeviceBinaryIsUsed) { cl_int retVal = CL_INVALID_BINARY; PatchTokensTestData::ValidEmptyProgram programTokens; @@ -3058,4 +3059,4 @@ TEST(ProgramReplaceDeviceBinary, GivenBinaryZebinThenUseAsBothPackedAndUnpackedB ASSERT_NE(nullptr, program.unpackedDeviceBinary); EXPECT_EQ(0, memcmp(program.packedDeviceBinary.get(), zebin.storage.data(), program.packedDeviceBinarySize)); EXPECT_EQ(0, memcmp(program.unpackedDeviceBinary.get(), zebin.storage.data(), program.unpackedDeviceBinarySize)); -} \ No newline at end of file +} diff --git a/shared/offline_compiler/source/extra_settings.cpp b/shared/offline_compiler/source/extra_settings.cpp index 50dda69bb2..4aaf1e26d1 100644 --- a/shared/offline_compiler/source/extra_settings.cpp +++ b/shared/offline_compiler/source/extra_settings.cpp @@ -16,4 +16,7 @@ void OfflineCompiler::resolveExtraSettings() { CompilerOptions::concatenateAppend(internalOptions, CompilerOptions::forceEmuInt32DivRemSP); } } + +void OfflineCompiler::adjustExtraSettings(HardwareInfo &hwInfo) { +} } // namespace NEO diff --git a/shared/offline_compiler/source/offline_compiler.cpp b/shared/offline_compiler/source/offline_compiler.cpp index 2740f0b0a7..86b584aa44 100644 --- a/shared/offline_compiler/source/offline_compiler.cpp +++ b/shared/offline_compiler/source/offline_compiler.cpp @@ -425,8 +425,12 @@ int OfflineCompiler::initialize(size_t numArgs, const std::vector & if ((igcPlatform == nullptr) || (igcGtSystemInfo == nullptr) || (igcFeWa == nullptr)) { return OUT_OF_HOST_MEMORY; } - IGC::PlatformHelper::PopulateInterfaceWith(*igcPlatform.get(), hwInfo.platform); - IGC::GtSysInfoHelper::PopulateInterfaceWith(*igcGtSystemInfo.get(), hwInfo.gtSystemInfo); + + auto copyHwInfo = hwInfo; + adjustExtraSettings(copyHwInfo); + + IGC::PlatformHelper::PopulateInterfaceWith(*igcPlatform.get(), copyHwInfo.platform); + IGC::GtSysInfoHelper::PopulateInterfaceWith(*igcGtSystemInfo.get(), copyHwInfo.gtSystemInfo); // populate with features igcFeWa.get()->SetFtrDesktop(hwInfo.featureTable.ftrDesktop); igcFeWa.get()->SetFtrChannelSwizzlingXOREnabled(hwInfo.featureTable.ftrChannelSwizzlingXOREnabled); diff --git a/shared/offline_compiler/source/offline_compiler.h b/shared/offline_compiler/source/offline_compiler.h index dfea6c3457..7347f82f7d 100644 --- a/shared/offline_compiler/source/offline_compiler.h +++ b/shared/offline_compiler/source/offline_compiler.h @@ -83,6 +83,7 @@ class OfflineCompiler { int parseCommandLine(size_t numArgs, const std::vector &allArgs); void setStatelessToStatefullBufferOffsetFlag(); void resolveExtraSettings(); + void adjustExtraSettings(HardwareInfo &hwInfo); void parseDebugSettings(); void storeBinary(char *&pDst, size_t &dstSize, const void *pSrc, const size_t srcSize); MOCKABLE_VIRTUAL int buildSourceCode(); diff --git a/shared/source/compiler_interface/compiler_interface.cpp b/shared/source/compiler_interface/compiler_interface.cpp index 0e34bcd9d6..3077ca7db5 100644 --- a/shared/source/compiler_interface/compiler_interface.cpp +++ b/shared/source/compiler_interface/compiler_interface.cpp @@ -11,6 +11,7 @@ #include "shared/source/compiler_interface/compiler_interface.inl" #include "shared/source/debug_settings/debug_settings_manager.h" #include "shared/source/device/device.h" +#include "shared/source/helpers/hw_helper.h" #include "shared/source/helpers/hw_info.h" #include "opencl/source/os_interface/os_inc_base.h" @@ -330,7 +331,6 @@ TranslationOutput::ErrorCode CompilerInterface::getSipKernelBinary(NEO::Device & bool CompilerInterface::loadFcl() { return NEO::loadCompiler(Os::frontEndDllName, fclLib, fclMain); - ; } bool CompilerInterface::loadIgc() { @@ -400,8 +400,13 @@ IGC::IgcOclDeviceCtxTagOCL *CompilerInterface::getIgcDeviceCtx(const Device &dev if (productFamily != "unk") { getHwInfoForPlatformString(productFamily, hwInfo); } - IGC::PlatformHelper::PopulateInterfaceWith(*igcPlatform, hwInfo->platform); - IGC::GtSysInfoHelper::PopulateInterfaceWith(*igcGtSystemInfo, hwInfo->gtSystemInfo); + + auto &hwHelper = NEO::HwHelper::get(hwInfo->platform.eRenderCoreFamily); + auto copyHwInfo = *hwInfo; + hwHelper.adjustPlatformCoreFamilyForIgc(copyHwInfo); + + IGC::PlatformHelper::PopulateInterfaceWith(*igcPlatform, copyHwInfo.platform); + IGC::GtSysInfoHelper::PopulateInterfaceWith(*igcGtSystemInfo, copyHwInfo.gtSystemInfo); igcFeWa.get()->SetFtrDesktop(device.getHardwareInfo().featureTable.ftrDesktop); igcFeWa.get()->SetFtrChannelSwizzlingXOREnabled(device.getHardwareInfo().featureTable.ftrChannelSwizzlingXOREnabled); diff --git a/shared/source/helpers/hw_helper.h b/shared/source/helpers/hw_helper.h index 81a3a49f2d..81ab33f40c 100644 --- a/shared/source/helpers/hw_helper.h +++ b/shared/source/helpers/hw_helper.h @@ -123,6 +123,7 @@ class HwHelper { virtual bool isSpecialWorkgroupSizeRequired(const HardwareInfo &hwInfo, bool isSimulation) const = 0; virtual uint32_t getGlobalTimeStampBits() const = 0; virtual uint32_t getDefaultThreadArbitrationPolicy() const = 0; + virtual void adjustPlatformCoreFamilyForIgc(HardwareInfo &hwInfo) = 0; static uint32_t getSubDevicesCount(const HardwareInfo *pHwInfo); static uint32_t getEnginesCount(const HardwareInfo &hwInfo); @@ -311,6 +312,8 @@ class HwHelperHw : public HwHelper { uint32_t getDefaultThreadArbitrationPolicy() const override; + void adjustPlatformCoreFamilyForIgc(HardwareInfo &hwInfo) override; + protected: LocalMemoryAccessMode getDefaultLocalMemoryAccessMode(const HardwareInfo &hwInfo) const override; diff --git a/shared/source/helpers/hw_helper_base.inl b/shared/source/helpers/hw_helper_base.inl index dee8648910..6c26de39a9 100644 --- a/shared/source/helpers/hw_helper_base.inl +++ b/shared/source/helpers/hw_helper_base.inl @@ -179,6 +179,10 @@ bool HwHelperHw::getEnableLocalMemory(const HardwareInfo &hwInfo) const return OSInterface::osEnableLocalMemory && isLocalMemoryEnabled(hwInfo); } +template +void HwHelperHw::adjustPlatformCoreFamilyForIgc(HardwareInfo &hwInfo) { +} + template AuxTranslationMode HwHelperHw::getAuxTranslationMode() { if (DebugManager.flags.ForceAuxTranslationMode.get() != -1) { diff --git a/shared/test/unit_test/compiler_interface/compiler_interface_tests.cpp b/shared/test/unit_test/compiler_interface/compiler_interface_tests.cpp index 0ce78058f5..467f02eddd 100644 --- a/shared/test/unit_test/compiler_interface/compiler_interface_tests.cpp +++ b/shared/test/unit_test/compiler_interface/compiler_interface_tests.cpp @@ -17,6 +17,7 @@ #include "opencl/test/unit_test/global_environment.h" #include "opencl/test/unit_test/mocks/mock_cif.h" #include "opencl/test/unit_test/mocks/mock_compilers.h" +#include "test.h" #include "gmock/gmock.h" #include "hw_cmds.h" @@ -902,7 +903,7 @@ TEST_F(CompilerInterfaceTest, GivenRequestForNewIgcTranslationCtxWhenCouldNotPop setIgcDebugVars(prevDebugVars); } -TEST_F(CompilerInterfaceTest, givenNoDbgKeyForceUseDifferentPlatformWhenRequestForNewTranslationCtxThenUseDefaultPlatform) { +HWTEST_F(CompilerInterfaceTest, givenNoDbgKeyForceUseDifferentPlatformWhenRequestForNewTranslationCtxThenUseDefaultPlatform) { auto device = this->pDevice; auto retIgc = pCompilerInterface->createIgcTranslationCtx(*device, IGC::CodeType::spirV, IGC::CodeType::oclGenBin); EXPECT_NE(nullptr, retIgc);