From 91b26277a4b02368294a1e13fb835d398e33dcad Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Thu, 27 Jul 2023 09:38:15 +0000 Subject: [PATCH] feature: add method to adjust hw info for igc Related-To: NEO-8203 Signed-off-by: Mateusz Jablonski --- manifests/manifest.yml | 2 +- opencl/test/unit_test/program/program_tests.cpp | 5 ++++- .../offline_compiler/source/ocloc_igc_facade.cpp | 15 ++++++++++----- .../device_binary_formats.cpp | 4 +++- shared/source/helpers/compiler_product_helper.h | 2 ++ .../helpers/compiler_product_helper_base.inl | 4 ++++ .../device_binary_format/elf/elf_tests_data.h | 7 +++++-- .../device_binary_format/patchtokens_tests.h | 5 ++++- .../patchtokens_dumper_tests.cpp | 15 ++++++++++++--- .../device_binary_format/zebin_decoder_tests.cpp | 2 ++ 10 files changed, 47 insertions(+), 14 deletions(-) diff --git a/manifests/manifest.yml b/manifests/manifest.yml index 38597297e3..80c009cf56 100644 --- a/manifests/manifest.yml +++ b/manifests/manifest.yml @@ -42,7 +42,7 @@ components: dest_dir: kernels_bin type: git branch: kernels_bin - revision: 2079-811 + revision: 2079-814 kmdaf: branch: kmdaf dest_dir: kmdaf diff --git a/opencl/test/unit_test/program/program_tests.cpp b/opencl/test/unit_test/program/program_tests.cpp index 48408c9f1f..73e52993c2 100644 --- a/opencl/test/unit_test/program/program_tests.cpp +++ b/opencl/test/unit_test/program/program_tests.cpp @@ -110,7 +110,10 @@ class PatchtokensProgramWithDebugData : public MockProgram { PatchtokensProgramWithDebugData(ClDevice &device) : MockProgram(toClDeviceVector(device)) { auto rootDeviceIdx = device.getRootDeviceIndex(); - const auto &hwInfo = device.getHardwareInfo(); + auto hwInfo = device.getHardwareInfo(); + + auto &compilerProductHelper = device.getCompilerProductHelper(); + compilerProductHelper.adjustHwInfoForIgc(hwInfo); this->buildInfos.resize(rootDeviceIdx + 1); auto &buildInfo = this->buildInfos[rootDeviceIdx]; diff --git a/shared/offline_compiler/source/ocloc_igc_facade.cpp b/shared/offline_compiler/source/ocloc_igc_facade.cpp index 84f7e8cf6c..e42d8d62e3 100644 --- a/shared/offline_compiler/source/ocloc_igc_facade.cpp +++ b/shared/offline_compiler/source/ocloc_igc_facade.cpp @@ -96,12 +96,17 @@ int OclocIgcFacade::initialize(const HardwareInfo &hwInfo) { argHelper->printf("Error! IGC device context has not been properly created!\n"); return OclocErrorCode::OUT_OF_HOST_MEMORY; } - - populateIgcPlatform(*igcPlatform, hwInfo); - IGC::GtSysInfoHelper::PopulateInterfaceWith(*igcGtSystemInfo.get(), hwInfo.gtSystemInfo); - auto compilerProductHelper = NEO::CompilerProductHelper::create(hwInfo.platform.eProductFamily); - populateWithFeatures(igcFtrWa.get(), hwInfo, compilerProductHelper.get()); + + auto copyHwInfo = hwInfo; + if (compilerProductHelper) { + compilerProductHelper->adjustHwInfoForIgc(copyHwInfo); + } + + populateIgcPlatform(*igcPlatform, copyHwInfo); + IGC::GtSysInfoHelper::PopulateInterfaceWith(*igcGtSystemInfo.get(), copyHwInfo.gtSystemInfo); + + populateWithFeatures(igcFtrWa.get(), copyHwInfo, compilerProductHelper.get()); initialized = true; return OclocErrorCode::SUCCESS; diff --git a/shared/source/device_binary_format/device_binary_formats.cpp b/shared/source/device_binary_format/device_binary_formats.cpp index 9daf3976a2..0847b65371 100644 --- a/shared/source/device_binary_format/device_binary_formats.cpp +++ b/shared/source/device_binary_format/device_binary_formats.cpp @@ -22,10 +22,12 @@ std::vector packDeviceBinary(const SingleDeviceBinary binary, std::stri } TargetDevice getTargetDevice(const RootDeviceEnvironment &rootDeviceEnvironment) { - auto hwInfo = *rootDeviceEnvironment.getHardwareInfo(); + auto initialHwInfo = *rootDeviceEnvironment.getHardwareInfo(); auto &compilerProductHelper = rootDeviceEnvironment.getHelper(); auto &gfxCoreHelper = rootDeviceEnvironment.getHelper(); TargetDevice targetDevice = {}; + auto hwInfo = initialHwInfo; + compilerProductHelper.adjustHwInfoForIgc(hwInfo); targetDevice.coreFamily = hwInfo.platform.eRenderCoreFamily; targetDevice.productFamily = hwInfo.platform.eProductFamily; diff --git a/shared/source/helpers/compiler_product_helper.h b/shared/source/helpers/compiler_product_helper.h index d0c4dc0cc3..48271736f2 100644 --- a/shared/source/helpers/compiler_product_helper.h +++ b/shared/source/helpers/compiler_product_helper.h @@ -55,6 +55,7 @@ class CompilerProductHelper { virtual uint32_t getNumThreadsPerEu() const = 0; virtual uint32_t matchRevisionIdWithProductConfig(HardwareIpVersion ipVersion, uint32_t revisionID) const = 0; virtual std::string getDeviceExtensions(const HardwareInfo &hwInfo, const ReleaseHelper *releaseHelper) const = 0; + virtual void adjustHwInfoForIgc(HardwareInfo &hwInfo) const = 0; virtual ~CompilerProductHelper() = default; uint32_t getHwIpVersion(const HardwareInfo &hwInfo) const; @@ -93,6 +94,7 @@ class CompilerProductHelperHw : public CompilerProductHelper { uint32_t getNumThreadsPerEu() const override; uint32_t matchRevisionIdWithProductConfig(HardwareIpVersion ipVersion, uint32_t revisionID) const override; std::string getDeviceExtensions(const HardwareInfo &hwInfo, const ReleaseHelper *releaseHelper) const override; + void adjustHwInfoForIgc(HardwareInfo &hwInfo) const override; ~CompilerProductHelperHw() override = default; diff --git a/shared/source/helpers/compiler_product_helper_base.inl b/shared/source/helpers/compiler_product_helper_base.inl index 0d42518c5a..a3853d455e 100644 --- a/shared/source/helpers/compiler_product_helper_base.inl +++ b/shared/source/helpers/compiler_product_helper_base.inl @@ -227,4 +227,8 @@ bool CompilerProductHelperHw::isBFloat16ConversionSupported(const Re } return false; } + +template +void CompilerProductHelperHw::adjustHwInfoForIgc(HardwareInfo &hwInfo) const { +} } // namespace NEO diff --git a/shared/test/common/device_binary_format/elf/elf_tests_data.h b/shared/test/common/device_binary_format/elf/elf_tests_data.h index bb8202c835..d07facdd12 100644 --- a/shared/test/common/device_binary_format/elf/elf_tests_data.h +++ b/shared/test/common/device_binary_format/elf/elf_tests_data.h @@ -27,7 +27,10 @@ enum class enabledIrFormat { template struct MockElfBinaryPatchtokens { MockElfBinaryPatchtokens(const HardwareInfo &hwInfo) : MockElfBinaryPatchtokens(std::string{}, hwInfo){}; - MockElfBinaryPatchtokens(const std::string &buildOptions, const HardwareInfo &hwInfo) { + MockElfBinaryPatchtokens(const std::string &buildOptions, const HardwareInfo &inputHwInfo) { + auto hwInfo = inputHwInfo; + auto compilerProductHelper = NEO::CompilerProductHelper::create(hwInfo.platform.eProductFamily); + compilerProductHelper->adjustHwInfoForIgc(hwInfo); mockDevBinaryHeader.Device = hwInfo.platform.eRenderCoreFamily; mockDevBinaryHeader.GPUPointerSizeInBytes = sizeof(void *); mockDevBinaryHeader.Version = iOpenCL::CURRENT_ICBE_VERSION; @@ -62,4 +65,4 @@ struct MockElfBinaryPatchtokens { static constexpr size_t mockDataSize = 0x10; iOpenCL::SProgramBinaryHeader mockDevBinaryHeader = iOpenCL::SProgramBinaryHeader{iOpenCL::MAGIC_CL, 0, 0, 0, 0, 0, 0}; std::vector storage; -}; \ No newline at end of file +}; diff --git a/shared/test/common/device_binary_format/patchtokens_tests.h b/shared/test/common/device_binary_format/patchtokens_tests.h index 65a2baa62b..7832fc8838 100644 --- a/shared/test/common/device_binary_format/patchtokens_tests.h +++ b/shared/test/common/device_binary_format/patchtokens_tests.h @@ -84,10 +84,13 @@ inline uint32_t pushBackArgInfoToken(std::vector &outStream, struct ValidEmptyProgram : NEO::PatchTokenBinary::ProgramFromPatchtokens { ValidEmptyProgram() { + auto hwInfo = *NEO::defaultHwInfo; + auto compilerProductHelper = NEO::CompilerProductHelper::create(hwInfo.platform.eProductFamily); + compilerProductHelper->adjustHwInfoForIgc(hwInfo); iOpenCL::SProgramBinaryHeader headerTok = {}; headerTok.Magic = iOpenCL::MAGIC_CL; headerTok.Version = iOpenCL::CURRENT_ICBE_VERSION; - headerTok.Device = NEO::defaultHwInfo->platform.eRenderCoreFamily; + headerTok.Device = hwInfo.platform.eRenderCoreFamily; headerTok.GPUPointerSizeInBytes = sizeof(uintptr_t); this->decodeStatus = NEO::DecodeError::Success; diff --git a/shared/test/unit_test/device_binary_format/patchtokens_dumper_tests.cpp b/shared/test/unit_test/device_binary_format/patchtokens_dumper_tests.cpp index 3650091504..700b0e8cd7 100644 --- a/shared/test/unit_test/device_binary_format/patchtokens_dumper_tests.cpp +++ b/shared/test/unit_test/device_binary_format/patchtokens_dumper_tests.cpp @@ -88,6 +88,9 @@ TEST(KernelArgDumper, givenEmptyKernelArgThenProperlyCreatesDump) { } TEST(ProgramDumper, givenProgramWithPatchtokensThenProperlyCreatesDump) { + auto hwInfo = *NEO::defaultHwInfo; + auto compilerProductHelper = NEO::CompilerProductHelper::create(hwInfo.platform.eProductFamily); + compilerProductHelper->adjustHwInfoForIgc(hwInfo); using namespace iOpenCL; PatchTokensTestData::ValidProgramWithConstantSurfaceAndPointer progWithConst = {}; PatchTokensTestData::ValidProgramWithGlobalSurfaceAndPointer progWithGlobal = {}; @@ -136,7 +139,7 @@ struct SProgramBinaryHeader { << CURRENT_ICBE_VERSION << R"===( uint32_t Device; // = )===" - << NEO::defaultHwInfo->platform.eRenderCoreFamily << R"===( + << hwInfo.platform.eRenderCoreFamily << R"===( uint32_t GPUPointerSizeInBytes; // = )===" << progWithConst.header->GPUPointerSizeInBytes << R"===( @@ -264,6 +267,9 @@ Kernels section size : 0 } TEST(ProgramDumper, givenProgramWithKernelThenProperlyCreatesDump) { + auto hwInfo = *NEO::defaultHwInfo; + auto compilerProductHelper = NEO::CompilerProductHelper::create(hwInfo.platform.eProductFamily); + compilerProductHelper->adjustHwInfoForIgc(hwInfo); PatchTokensTestData::ValidProgramWithKernelUsingSlm program; std::string generated = NEO::PatchTokenBinary::asString(program); std::stringstream expected; @@ -275,7 +281,7 @@ struct SProgramBinaryHeader { << iOpenCL::CURRENT_ICBE_VERSION << R"===( uint32_t Device; // = )===" - << NEO::defaultHwInfo->platform.eRenderCoreFamily << R"===( + << hwInfo.platform.eRenderCoreFamily << R"===( uint32_t GPUPointerSizeInBytes; // = )===" << program.header->GPUPointerSizeInBytes << R"===( @@ -341,6 +347,9 @@ Kernel-scope tokens section size : )===" } TEST(ProgramDumper, givenProgramWithMultipleKerneslThenProperlyCreatesDump) { + auto hwInfo = *NEO::defaultHwInfo; + auto compilerProductHelper = NEO::CompilerProductHelper::create(hwInfo.platform.eProductFamily); + compilerProductHelper->adjustHwInfoForIgc(hwInfo); PatchTokensTestData::ValidProgramWithKernelUsingSlm program; program.kernels.push_back(program.kernels[0]); program.kernels[1].tokens.allocateLocalSurface = nullptr; @@ -358,7 +367,7 @@ struct SProgramBinaryHeader { << iOpenCL::CURRENT_ICBE_VERSION << R"===( uint32_t Device; // = )===" - << NEO::defaultHwInfo->platform.eRenderCoreFamily << R"===( + << hwInfo.platform.eRenderCoreFamily << R"===( uint32_t GPUPointerSizeInBytes; // = )===" << program.header->GPUPointerSizeInBytes << R"===( diff --git a/shared/test/unit_test/device_binary_format/zebin_decoder_tests.cpp b/shared/test/unit_test/device_binary_format/zebin_decoder_tests.cpp index a7f631570c..f46ffd56e1 100644 --- a/shared/test/unit_test/device_binary_format/zebin_decoder_tests.cpp +++ b/shared/test/unit_test/device_binary_format/zebin_decoder_tests.cpp @@ -71,6 +71,8 @@ TEST(ZebinValidateTargetTest, givenTargetDeviceCreatedUsingHelperFunctionWhenVal auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0]; auto hwInfo = *rootDeviceEnvironment.getHardwareInfo(); auto targetDevice = getTargetDevice(rootDeviceEnvironment); + auto &compilerProductHelper = rootDeviceEnvironment.getHelper(); + compilerProductHelper.adjustHwInfoForIgc(hwInfo); EXPECT_TRUE(validateTargetDevice(targetDevice, NEO::Elf::EI_CLASS_32, hwInfo.platform.eProductFamily, hwInfo.platform.eRenderCoreFamily, AOT::UNKNOWN_ISA, {})); }