From 7982e26ae7eb0067db0ef9b6eba90f8a4ef8c14d Mon Sep 17 00:00:00 2001 From: Krystian Chmielewski Date: Tue, 31 Jan 2023 12:18:49 +0000 Subject: [PATCH] feat(ocloc concat): allow device binary Allow for use of device binary in ocloc concat. Previously only AR files could be concatenated. This feature only works for zebin with AOT Product Config note. Signed-off-by: Krystian Chmielewski --- .../offline_compiler/mock/mock_ocloc_concat.h | 11 +- .../offline_compiler/ocloc_concat_tests.cpp | 100 ++++++++++++++++-- .../offline_compiler/source/ocloc_concat.cpp | 83 ++++++++++++--- shared/offline_compiler/source/ocloc_concat.h | 12 ++- .../device_binary_format/zebin_decoder.cpp | 21 ++-- .../device_binary_format/zebin_decoder.h | 3 + .../test/common/mocks/mock_modules_zebin.cpp | 59 +++++++++++ shared/test/common/mocks/mock_modules_zebin.h | 44 +------- 8 files changed, 253 insertions(+), 80 deletions(-) diff --git a/opencl/test/unit_test/offline_compiler/mock/mock_ocloc_concat.h b/opencl/test/unit_test/offline_compiler/mock/mock_ocloc_concat.h index 19d6e952a2..19e5db0c57 100644 --- a/opencl/test/unit_test/offline_compiler/mock/mock_ocloc_concat.h +++ b/opencl/test/unit_test/offline_compiler/mock/mock_ocloc_concat.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Intel Corporation + * Copyright (C) 2022-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -20,9 +20,12 @@ class MockOclocConcat : public OclocConcat { using OclocConcat::fileNamesToConcat; using OclocConcat::parseArguments; - Ar::Ar decodeAr(const std::vector &arFile, std::string &outErrors, std::string &outWarnings) override { - outErrors.append(decodeArErrorMessage.str()); - return {}; + Ar::Ar decodeAr(ArrayRef arFile, std::string &outErrors, std::string &outWarnings) override { + if (shouldFailDecodingAr) { + outErrors.append(decodeArErrorMessage.str()); + return {}; + } + return OclocConcat::decodeAr(arFile, outErrors, outWarnings); } bool shouldFailDecodingAr = false; diff --git a/opencl/test/unit_test/offline_compiler/ocloc_concat_tests.cpp b/opencl/test/unit_test/offline_compiler/ocloc_concat_tests.cpp index af6a4373a4..e446466247 100644 --- a/opencl/test/unit_test/offline_compiler/ocloc_concat_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/ocloc_concat_tests.cpp @@ -1,15 +1,21 @@ /* - * Copyright (C) 2022 Intel Corporation + * Copyright (C) 2022-2023 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "shared/offline_compiler/source/ocloc_error_code.h" +#include "shared/source/device_binary_format/ar/ar_encoder.h" +#include "shared/source/device_binary_format/elf/elf_encoder.h" +#include "shared/test/common/mocks/mock_modules_zebin.h" #include "gtest/gtest.h" #include "mock/mock_argument_helper.h" #include "mock/mock_ocloc_concat.h" +#include "platforms.h" + +#include namespace NEO { TEST(OclocConcatTest, GivenNoArgumentsWhenInitializingThenErrorIsReturned) { @@ -79,20 +85,96 @@ TEST(OclocConcatTest, GivenMissingOutFileNameAfterOutArgumentWhenInitalizingThen TEST(OclocConcatTest, GivenErrorDuringDecodingArWhenConcatenatingThenErrorIsReturned) { MockOclocArgHelper::FilesMap mockArgHelperFilesMap{ - {"fatBinary1.ar", "fatBinary1Data"}, - {"fatBinary2.ar", "fatBinary2Data"}}; + {"fatBinary1.ar", "!\nInvalidAr"}, + {"fatBinary2.ar", "!\nfatBinary2Data"}}; MockOclocArgHelper mockArgHelper{mockArgHelperFilesMap}; auto oclocConcat = MockOclocConcat(&mockArgHelper); + mockArgHelper.messagePrinter = new MessagePrinter(true); oclocConcat.shouldFailDecodingAr = true; oclocConcat.fileNamesToConcat = {"fatBinary1.ar", "fatBinary2.ar"}; - - ::testing::internal::CaptureStdout(); auto error = oclocConcat.concatenate(); - const auto output = ::testing::internal::GetCapturedStdout(); - + const auto output = mockArgHelper.messagePrinter.getLog().str(); EXPECT_EQ(static_cast(OclocErrorCode::INVALID_FILE), error); - EXPECT_EQ(MockOclocConcat::decodeArErrorMessage.str(), output); + EXPECT_EQ("fatBinary1.ar : Error while decoding AR file\n", output); } -} // namespace NEO \ No newline at end of file +TEST(OclocConcatTest, GivenBinaryFileNonZebinWhenConcatenatingThenErrorIsReturned) { + MockOclocArgHelper::FilesMap mockArgHelperFilesMap{ + {"binary.bin", "NOT Zebin"}}; + MockOclocArgHelper mockArgHelper{mockArgHelperFilesMap}; + auto oclocConcat = MockOclocConcat(&mockArgHelper); + mockArgHelper.messagePrinter = new MessagePrinter(true); + oclocConcat.fileNamesToConcat = {"binary.bin"}; + auto error = oclocConcat.concatenate(); + const auto output = mockArgHelper.messagePrinter.getLog().str(); + EXPECT_EQ(static_cast(OclocErrorCode::INVALID_FILE), error); + EXPECT_EQ("binary.bin : Not a zebin file\n", output); +} + +TEST(OclocConcatTest, GivenZebinWithoutAOTProductConfigWhenConcatenatingThenErrorIsReturned) { + ZebinTestData::ValidEmptyProgram zebin64; + ZebinTestData::ValidEmptyProgram zebin32; + for (auto zebin : {&zebin64.storage, &zebin32.storage}) { + MockOclocArgHelper::FilesMap mockArgHelperFilesMap{ + {"zebin.bin", std::string(reinterpret_cast(zebin->data()), zebin->size())}}; + MockOclocArgHelper mockArgHelper{mockArgHelperFilesMap}; + auto oclocConcat = MockOclocConcat(&mockArgHelper); + mockArgHelper.messagePrinter = new MessagePrinter(true); + oclocConcat.fileNamesToConcat = {"zebin.bin"}; + auto error = oclocConcat.concatenate(); + const auto output = mockArgHelper.messagePrinter.getLog().str(); + EXPECT_EQ(static_cast(OclocErrorCode::INVALID_FILE), error); + EXPECT_EQ("zebin.bin : Couldn't find AOT product configuration in intelGTNotes section.\n", output); + } +} + +TEST(OclocConcatTest, GivenZebinWithAOTNoteAndFatBinaryWhenConcatenatingThenCorrectFatBinaryIsProduced) { + std::vector fatBinary; + { + std::array file{0}; + NEO::Ar::ArEncoder arEncoder(true); + arEncoder.appendFileEntry("10.0.0", ArrayRef::fromAny(file.data(), file.size())); + arEncoder.appendFileEntry("11.0.0", ArrayRef::fromAny(file.data(), file.size())); + fatBinary = arEncoder.encode(); + } + + ZebinTestData::ValidEmptyProgram zebin; + { + AOT::PRODUCT_CONFIG productConfig = AOT::PRODUCT_CONFIG::TGL; // 12.0.0 + zebin.appendSection(Elf::SHT_NOTE, Elf::SectionsNamesZebin::noteIntelGT, + ZebinTestData::createIntelGTNoteSection(versionToString(NEO::zeInfoDecoderVersion), productConfig)); + } + + MockOclocArgHelper::FilesMap mockArgHelperFilesMap{ + {"binary.bin", std::string(reinterpret_cast(zebin.storage.data()), zebin.storage.size())}, + {"fatBinary.ar", std::string(reinterpret_cast(fatBinary.data()), fatBinary.size())}}; + MockOclocArgHelper mockArgHelper{mockArgHelperFilesMap}; + mockArgHelper.interceptOutput = true; + mockArgHelper.messagePrinter = new MessagePrinter(true); + + auto oclocConcat = MockOclocConcat(&mockArgHelper); + oclocConcat.fileNamesToConcat = { + "fatBinary.ar", + "binary.bin", + }; + + auto error = oclocConcat.concatenate(); + const auto output = mockArgHelper.messagePrinter.getLog().str(); + + EXPECT_EQ(static_cast(OclocErrorCode::SUCCESS), error); + EXPECT_TRUE(output.empty()); + EXPECT_EQ(1U, mockArgHelper.interceptedFiles.size()); + + std::string errors, warnings; + auto &concatedFatBinary = mockArgHelper.interceptedFiles["concat.ar"]; + auto concatedAr = NEO::Ar::decodeAr(ArrayRef::fromAny(reinterpret_cast(concatedFatBinary.data()), concatedFatBinary.size()), errors, warnings); + EXPECT_TRUE(errors.empty()); + EXPECT_TRUE(warnings.empty()); + ASSERT_EQ(6U, concatedAr.files.size()); + EXPECT_EQ("10.0.0", concatedAr.files[1].fileName); + EXPECT_EQ("11.0.0", concatedAr.files[3].fileName); + EXPECT_EQ("12.0.0", concatedAr.files[5].fileName); +} + +} // namespace NEO diff --git a/shared/offline_compiler/source/ocloc_concat.cpp b/shared/offline_compiler/source/ocloc_concat.cpp index f28fb10d50..850ec891b5 100644 --- a/shared/offline_compiler/source/ocloc_concat.cpp +++ b/shared/offline_compiler/source/ocloc_concat.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Intel Corporation + * Copyright (C) 2022-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -11,6 +11,7 @@ #include "shared/offline_compiler/source/ocloc_error_code.h" #include "shared/source/device_binary_format/ar/ar_decoder.h" #include "shared/source/device_binary_format/ar/ar_encoder.h" +#include "shared/source/device_binary_format/zebin_decoder.h" namespace NEO { OclocConcat::ErrorCode OclocConcat::initialize(const std::vector &args) { @@ -22,8 +23,8 @@ OclocConcat::ErrorCode OclocConcat::initialize(const std::vector &a return error; } -Ar::Ar OclocConcat::decodeAr(const std::vector &arFile, std::string &outErrors, std::string &outWarnings) { - return NEO::Ar::decodeAr({reinterpret_cast(arFile.data()), arFile.size()}, outErrors, outWarnings); +Ar::Ar OclocConcat::decodeAr(ArrayRef arFile, std::string &outErrors, std::string &outWarnings) { + return NEO::Ar::decodeAr(arFile, outErrors, outWarnings); } OclocConcat::ErrorCode OclocConcat::parseArguments(const std::vector &args) { @@ -59,26 +60,76 @@ OclocConcat::ErrorCode OclocConcat::checkIfFatBinariesExist() { return filesExist ? OclocErrorCode::SUCCESS : OclocErrorCode::INVALID_COMMAND_LINE; } +void OclocConcat::printMsg(ConstStringRef fileName, const std::string &message) { + if (false == message.empty()) { + argHelper->printf(fileName.data()); + argHelper->printf(" : "); + argHelper->printf(message.c_str()); + } +} + +AOT::PRODUCT_CONFIG OclocConcat::getAOTProductConfigFromBinary(ArrayRef binary, std::string &outErrors) { + std::vector intelGTNotes; + if (NEO::isZebin(binary)) { + std::string warnings; + auto elf = Elf::decodeElf(binary, outErrors, warnings); + getIntelGTNotes(elf, intelGTNotes, outErrors, warnings); + } else if (NEO::isZebin(binary)) { + std::string warnings; + auto elf = Elf::decodeElf(binary, outErrors, warnings); + getIntelGTNotes(elf, intelGTNotes, outErrors, warnings); + } else { + outErrors.append("Not a zebin file\n"); + return {}; + } + + AOT::PRODUCT_CONFIG productConfig{}; + bool productConfigFound = false; + for (auto ¬e : intelGTNotes) { + if (note.type == Elf::ProductConfig) { + productConfig = *reinterpret_cast(note.data.begin()); + productConfigFound = true; + break; + } + } + if (false == productConfigFound) { + outErrors.append("Couldn't find AOT product configuration in intelGTNotes section.\n"); + } + return productConfig; +} + OclocConcat::ErrorCode OclocConcat::concatenate() { NEO::Ar::ArEncoder arEncoder(true); for (auto &fileName : fileNamesToConcat) { - auto arFile = argHelper->readBinaryFile(fileName); + auto file = argHelper->readBinaryFile(fileName); + auto fileRef = ArrayRef(reinterpret_cast(file.data()), file.size()); - std::string warnings; - std::string errors; - auto ar = decodeAr(arFile, errors, warnings); - if (false == errors.empty()) { - argHelper->printf(errors.c_str()); - return OclocErrorCode::INVALID_FILE; - } - argHelper->printf(warnings.c_str()); + if (NEO::Ar::isAr(fileRef)) { + std::string warnings; + std::string errors; + auto ar = decodeAr(fileRef, errors, warnings); - for (auto &fileEntry : ar.files) { - if (NEO::ConstStringRef(fileEntry.fileName).startsWith("pad_")) { - continue; + if (false == errors.empty()) { + printMsg(fileName, errors); + return OclocErrorCode::INVALID_FILE; } + printMsg(fileName, warnings); - arEncoder.appendFileEntry(fileEntry.fileName, fileEntry.fileData); + for (auto &fileEntry : ar.files) { + if (NEO::ConstStringRef(fileEntry.fileName).startsWith("pad_")) { + continue; + } + arEncoder.appendFileEntry(fileEntry.fileName, fileEntry.fileData); + } + } else { + std::string errors; + auto productConfig = getAOTProductConfigFromBinary(fileRef, errors); + if (false == errors.empty()) { + printMsg(fileName, errors); + return OclocErrorCode::INVALID_FILE; + } + auto entryName = ProductConfigHelper::parseMajorMinorRevisionValue(productConfig); + arEncoder.appendFileEntry(entryName, fileRef); } } diff --git a/shared/offline_compiler/source/ocloc_concat.h b/shared/offline_compiler/source/ocloc_concat.h index 7e8b318972..c53050b26b 100644 --- a/shared/offline_compiler/source/ocloc_concat.h +++ b/shared/offline_compiler/source/ocloc_concat.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Intel Corporation + * Copyright (C) 2022-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -7,11 +7,15 @@ #pragma once +#include "shared/source/utilities/arrayref.h" #include "shared/source/utilities/const_stringref.h" #include #include +namespace AOT { +enum PRODUCT_CONFIG : uint32_t; +} class OclocArgHelper; namespace NEO { namespace Ar { @@ -38,9 +42,11 @@ Usage: ocloc concat ... [-out &arFile, std::string &outErrors, std::string &outWarnings); - ErrorCode parseArguments(const std::vector &args); ErrorCode checkIfFatBinariesExist(); + MOCKABLE_VIRTUAL Ar::Ar decodeAr(ArrayRef arFile, std::string &outErrors, std::string &outWarnings); + AOT::PRODUCT_CONFIG getAOTProductConfigFromBinary(ArrayRef binary, std::string &outErrors); + ErrorCode parseArguments(const std::vector &args); + void printMsg(ConstStringRef fileName, const std::string &message); OclocArgHelper *argHelper; std::vector fileNamesToConcat; diff --git a/shared/source/device_binary_format/zebin_decoder.cpp b/shared/source/device_binary_format/zebin_decoder.cpp index cdf91aa0be..a5f76a8ea5 100644 --- a/shared/source/device_binary_format/zebin_decoder.cpp +++ b/shared/source/device_binary_format/zebin_decoder.cpp @@ -31,17 +31,20 @@ void setKernelMiscInfoPosition(ConstStringRef metadata, NEO::ProgramInfo &dst) { dst.kernelMiscInfoPos = metadata.str().find(Elf::ZebinKernelMetadata::Tags::kernelMiscInfo.str()); } +template bool isZebin(ArrayRef binary); +template bool isZebin(ArrayRef binary); +template +bool isZebin(ArrayRef binary) { + auto fileHeader = Elf::decodeElfFileHeader(binary); + return fileHeader != nullptr && + (fileHeader->type == NEO::Elf::ET_REL || + fileHeader->type == NEO::Elf::ET_ZEBIN_EXE); +} + template <> bool isDeviceBinaryFormat(const ArrayRef binary) { - auto isValidZebinHeader = [](auto header) { - return header != nullptr && - (header->type == NEO::Elf::ET_REL || - header->type == NEO::Elf::ET_ZEBIN_EXE); - }; - return Elf::isElf(binary) - ? isValidZebinHeader(Elf::decodeElfFileHeader(binary)) - : isValidZebinHeader(Elf::decodeElfFileHeader(binary)); -} + return isZebin(binary) || isZebin(binary); +}; bool validateTargetDevice(const TargetDevice &targetDevice, Elf::ELF_IDENTIFIER_CLASS numBits, PRODUCT_FAMILY productFamily, GFXCORE_FAMILY gfxCore, AOT::PRODUCT_CONFIG productConfig, Elf::ZebinTargetFlags targetMetadata) { if (targetDevice.maxPointerSizeInBytes == 4 && static_cast(numBits == Elf::EI_CLASS_64)) { diff --git a/shared/source/device_binary_format/zebin_decoder.h b/shared/source/device_binary_format/zebin_decoder.h index 53fd11064d..73b4826627 100644 --- a/shared/source/device_binary_format/zebin_decoder.h +++ b/shared/source/device_binary_format/zebin_decoder.h @@ -64,6 +64,9 @@ struct ZeInfoKernelSections { DecodeError validateZeInfoVersion(const Elf::ZebinKernelMetadata::Types::Version &receivedZeInfoVersion, std::string &outErrReason, std::string &outWarning); +template +bool isZebin(ArrayRef binary); + bool validateTargetDevice(const TargetDevice &targetDevice, Elf::ELF_IDENTIFIER_CLASS numBits, PRODUCT_FAMILY productFamily, GFXCORE_FAMILY gfxCore, AOT::PRODUCT_CONFIG productConfig, Elf::ZebinTargetFlags targetMetadata); template diff --git a/shared/test/common/mocks/mock_modules_zebin.cpp b/shared/test/common/mocks/mock_modules_zebin.cpp index 0d50e2a386..de04e561a0 100644 --- a/shared/test/common/mocks/mock_modules_zebin.cpp +++ b/shared/test/common/mocks/mock_modules_zebin.cpp @@ -248,4 +248,63 @@ ZebinCopyBufferSimdModule::ZebinCopyBufferSimdModule(const NEO::Hardwar this->elfHeader = reinterpret_cast *>(storage.data()); } +size_t writeElfNote(ArrayRef dst, ArrayRef desc, NEO::ConstStringRef name, uint32_t type) { + auto noteSize = sizeof(NEO::Elf::ElfNoteSection) + alignUp(desc.size(), 4U) + alignUp(name.size() + 1U, 4U); + UNRECOVERABLE_IF(dst.size() < noteSize) + + memset(dst.begin(), 0, noteSize); + auto note = reinterpret_cast(dst.begin()); + note->descSize = static_cast(desc.size()); + note->nameSize = static_cast(name.size() + 1U); + note->type = type; + auto noteName = ptrOffset(dst.begin(), sizeof(NEO::Elf::ElfNoteSection)); + std::memcpy(noteName, name.begin(), name.size()); + auto noteDesc = ptrOffset(noteName, note->nameSize); + std::memcpy(noteDesc, desc.begin(), desc.size()); + return noteSize; +} + +size_t writeIntelGTNote(ArrayRef dst, NEO::Elf::IntelGTSectionType sectionType, ArrayRef desc) { + return writeElfNote(dst, desc, NEO::Elf::IntelGtNoteOwnerName, static_cast(sectionType)); +} + +size_t writeIntelGTVersionNote(ArrayRef dst, NEO::ConstStringRef version) { + std::vector desc(version.length() + 1U, 0U); + std::memcpy(desc.data(), version.begin(), version.length()); + return writeIntelGTNote(dst, NEO::Elf::ZebinVersion, {desc.data(), desc.size()}); +} + +std::vector createIntelGTNoteSection(NEO::ConstStringRef version, AOT::PRODUCT_CONFIG productConfig) { + const size_t noteSectionSize = sizeof(NEO::Elf::ElfNoteSection) * 2 + 8U * 2 + alignUp(version.length() + 1, 4U) + sizeof(AOT::PRODUCT_CONFIG); + std::vector intelGTNotesSection(noteSectionSize, 0); + size_t noteOffset = 0U; + noteOffset += writeIntelGTVersionNote(ArrayRef(ptrOffset(intelGTNotesSection.data(), noteOffset), intelGTNotesSection.size() - noteOffset), version); + + writeIntelGTNote(ArrayRef(ptrOffset(intelGTNotesSection.data(), noteOffset), intelGTNotesSection.size() - noteOffset), + NEO::Elf::IntelGTSectionType::ProductConfig, + ArrayRef::fromAny(&productConfig, 1U)); + return intelGTNotesSection; +} + +std::vector createIntelGTNoteSection(PRODUCT_FAMILY productFamily, GFXCORE_FAMILY coreFamily, NEO::Elf::ZebinTargetFlags flags, NEO::ConstStringRef version) { + const size_t noteSectionSize = sizeof(NEO::Elf::ElfNoteSection) * 4U + 4U * 8U + 3U * 4U + alignUp(version.length() + 1, 4U); + std::vector intelGTNotes(noteSectionSize, 0); + size_t noteOffset = 0U; + noteOffset += writeIntelGTNote(ArrayRef(ptrOffset(intelGTNotes.data(), noteOffset), intelGTNotes.size() - noteOffset), + NEO::Elf::ProductFamily, + ArrayRef::fromAny(&productFamily, 1U)); + + noteOffset += writeIntelGTNote(ArrayRef(ptrOffset(intelGTNotes.data(), noteOffset), intelGTNotes.size() - noteOffset), + NEO::Elf::GfxCore, + ArrayRef::fromAny(&coreFamily, 1U)); + + noteOffset += writeIntelGTNote(ArrayRef(ptrOffset(intelGTNotes.data(), noteOffset), intelGTNotes.size() - noteOffset), + NEO::Elf::TargetMetadata, + ArrayRef::fromAny(&flags.packed, 1U)); + + writeIntelGTVersionNote(ArrayRef(ptrOffset(intelGTNotes.data(), noteOffset), intelGTNotes.size() - noteOffset), + version); + return intelGTNotes; +} + }; // namespace ZebinTestData diff --git a/shared/test/common/mocks/mock_modules_zebin.h b/shared/test/common/mocks/mock_modules_zebin.h index 876753fe3d..e0ad8261ce 100644 --- a/shared/test/common/mocks/mock_modules_zebin.h +++ b/shared/test/common/mocks/mock_modules_zebin.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2022 Intel Corporation + * Copyright (C) 2020-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -263,44 +263,6 @@ kernels: -)==="; }; -inline std::vector createIntelGTNoteSection(PRODUCT_FAMILY productFamily, GFXCORE_FAMILY coreFamily, NEO::Elf::ZebinTargetFlags flags, NEO::ConstStringRef version) { - std::array notes = {{{8, 4, NEO::Elf::IntelGTSectionType::ProductFamily}, - {8, 4, NEO::Elf::IntelGTSectionType::GfxCore}, - {8, 4, NEO::Elf::IntelGTSectionType::TargetMetadata}, - {8, static_cast(alignUp(version.length(), 4U)), NEO::Elf::IntelGTSectionType::ZebinVersion}}}; - - std::array, 4> descData; - descData[0].resize(4); - std::memcpy(descData[0].data(), &productFamily, 4); - - descData[1].resize(4); - std::memcpy(descData[1].data(), &coreFamily, 4); - - descData[2].resize(4); - std::memcpy(descData[2].data(), &flags.packed, 4); - - descData[3].resize(notes[3].descSize); - std::memcpy(descData[3].data(), version.data(), notes[3].descSize); - - size_t noteSectionSize = 0U; - for (auto ¬e : notes) { - noteSectionSize += sizeof(note) + note.descSize + note.nameSize; - } - - std::vector intelGTNotesSection(noteSectionSize); - auto intelGTNotes = intelGTNotesSection.data(); - for (size_t i = 0; i < 4U; i++) { - auto ¬e = notes[i]; - std::memcpy(intelGTNotes, ¬e, sizeof(NEO::Elf::ElfNoteSection)); - intelGTNotes = ptrOffset(intelGTNotes, sizeof(NEO::Elf::ElfNoteSection)); - std::memcpy(intelGTNotes, NEO::Elf::IntelGtNoteOwnerName.data(), note.nameSize); - intelGTNotes = ptrOffset(intelGTNotes, note.nameSize); - std::memcpy(intelGTNotes, descData[i].data(), note.descSize); - intelGTNotes = ptrOffset(intelGTNotes, note.descSize); - } - return intelGTNotesSection; -} - template struct ZebinCopyBufferSimdModule { ZebinCopyBufferSimdModule(const NEO::HardwareInfo &hwInfo, uint8_t simdSize); @@ -372,4 +334,8 @@ kernels: )==="; }; +size_t writeElfNote(ArrayRef dst, ArrayRef desc, NEO::ConstStringRef name, uint32_t type); +size_t writeIntelGTNote(ArrayRef dst, NEO::Elf::IntelGTSectionType sectionType, ArrayRef desc); +std::vector createIntelGTNoteSection(NEO::ConstStringRef version, AOT::PRODUCT_CONFIG productConfig); +std::vector createIntelGTNoteSection(PRODUCT_FAMILY productFamily, GFXCORE_FAMILY coreFamily, NEO::Elf::ZebinTargetFlags flags, NEO::ConstStringRef version); } // namespace ZebinTestData \ No newline at end of file