mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 23:56:39 +08:00
refactor(zebin): move files to seperate directory
* Moved zebin related files to zebin directory. * Moved zebin related code to Zebin namespace. * Separated zeInfo from zebin elf. * Seperated zeInfo decoding from zebin decoder. * Refactored populateKernelPayloadArgument function. Signed-off-by: Krystian Chmielewski <krystian.chmielewski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
210b4cfeea
commit
58d3f892a9
@@ -14,11 +14,11 @@
|
||||
#include "shared/source/compiler_interface/linker.h"
|
||||
#include "shared/source/debugger/debugger_l0.h"
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/device_binary_format/debug_zebin.h"
|
||||
#include "shared/source/device_binary_format/device_binary_formats.h"
|
||||
#include "shared/source/device_binary_format/elf/elf.h"
|
||||
#include "shared/source/device_binary_format/elf/elf_encoder.h"
|
||||
#include "shared/source/device_binary_format/elf/ocl_elf.h"
|
||||
#include "shared/source/device_binary_format/zebin/debug_zebin.h"
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/helpers/addressing_mode_helper.h"
|
||||
@@ -481,13 +481,13 @@ ModuleImp::~ModuleImp() {
|
||||
kernelImmDatas.clear();
|
||||
}
|
||||
|
||||
NEO::Debug::Segments ModuleImp::getZebinSegments() {
|
||||
NEO::Zebin::Debug::Segments ModuleImp::getZebinSegments() {
|
||||
std::vector<std::pair<std::string_view, NEO::GraphicsAllocation *>> kernels;
|
||||
for (const auto &kernelImmData : kernelImmDatas)
|
||||
kernels.push_back({kernelImmData->getDescriptor().kernelMetadata.kernelName, kernelImmData->getIsaGraphicsAllocation()});
|
||||
ArrayRef<const uint8_t> strings = {reinterpret_cast<const uint8_t *>(translationUnit->programInfo.globalStrings.initData),
|
||||
translationUnit->programInfo.globalStrings.size};
|
||||
return NEO::Debug::Segments(translationUnit->globalVarBuffer, translationUnit->globalConstBuffer, strings, kernels);
|
||||
return NEO::Zebin::Debug::Segments(translationUnit->globalVarBuffer, translationUnit->globalConstBuffer, strings, kernels);
|
||||
}
|
||||
|
||||
ze_result_t ModuleImp::initialize(const ze_module_desc_t *desc, NEO::Device *neoDevice) {
|
||||
@@ -665,7 +665,7 @@ ze_result_t ModuleImp::initialize(const ze_module_desc_t *desc, NEO::Device *neo
|
||||
void ModuleImp::createDebugZebin() {
|
||||
auto refBin = ArrayRef<const uint8_t>::fromAny(translationUnit->unpackedDeviceBinary.get(), translationUnit->unpackedDeviceBinarySize);
|
||||
auto segments = getZebinSegments();
|
||||
auto debugZebin = NEO::Debug::createDebugZebin(refBin, segments);
|
||||
auto debugZebin = NEO::Zebin::Debug::createDebugZebin(refBin, segments);
|
||||
|
||||
translationUnit->debugDataSize = debugZebin.size();
|
||||
translationUnit->debugData.reset(new char[translationUnit->debugDataSize]);
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
namespace NEO {
|
||||
struct KernelDescriptor;
|
||||
|
||||
namespace Debug {
|
||||
namespace Zebin::Debug {
|
||||
struct Segments;
|
||||
} // namespace Debug
|
||||
} // namespace Zebin::Debug
|
||||
} // namespace NEO
|
||||
namespace L0 {
|
||||
|
||||
@@ -149,7 +149,7 @@ struct ModuleImp : public Module {
|
||||
void copyPatchedSegments(const NEO::Linker::PatchableSegments &isaSegmentsForPatching);
|
||||
void verifyDebugCapabilities();
|
||||
void checkIfPrivateMemoryPerDispatchIsNeeded() override;
|
||||
NEO::Debug::Segments getZebinSegments();
|
||||
NEO::Zebin::Debug::Segments getZebinSegments();
|
||||
void passDebugData();
|
||||
void createDebugZebin();
|
||||
void registerElfInDebuggerL0();
|
||||
|
||||
@@ -615,7 +615,7 @@ HWTEST_F(ModuleWithDebuggerL0Test, GivenDebugDataWithoutRelocationsWhenInitializ
|
||||
data.resize(4);
|
||||
NEO::Elf::ElfEncoder<> elfEncoder;
|
||||
elfEncoder.getElfFileHeader().type = NEO::Elf::SHT_PROGBITS;
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Elf::SectionsNamesZebin::textPrefix, data);
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Zebin::Elf::SectionNames::textPrefix, data);
|
||||
auto elfBinary = elfEncoder.encode();
|
||||
|
||||
kernelInfo->kernelDescriptor.external.debugData->vIsaSize = static_cast<uint32_t>(elfBinary.size());
|
||||
@@ -815,7 +815,7 @@ HWTEST_F(ModuleWithDebuggerL0Test, GivenNonZebinBinaryWhenDestroyModuleThenModul
|
||||
data.resize(4);
|
||||
NEO::Elf::ElfEncoder<> elfEncoder;
|
||||
elfEncoder.getElfFileHeader().type = NEO::Elf::SHT_PROGBITS;
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Elf::SectionsNamesZebin::textPrefix, data);
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Zebin::Elf::SectionNames::textPrefix, data);
|
||||
auto elfBinary = elfEncoder.encode();
|
||||
|
||||
kernelInfo->kernelDescriptor.external.debugData->vIsaSize = static_cast<uint32_t>(elfBinary.size());
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "shared/source/compiler_interface/compiler_warnings/compiler_warnings.h"
|
||||
#include "shared/source/compiler_interface/external_functions.h"
|
||||
#include "shared/source/device_binary_format/ar/ar_encoder.h"
|
||||
#include "shared/source/device_binary_format/debug_zebin.h"
|
||||
#include "shared/source/device_binary_format/zebin/debug_zebin.h"
|
||||
#include "shared/source/gmm_helper/gmm_helper.h"
|
||||
#include "shared/source/helpers/addressing_mode_helper.h"
|
||||
#include "shared/source/helpers/blit_helper.h"
|
||||
@@ -2340,7 +2340,7 @@ HWTEST_F(ModuleTranslationUnitTest, WhenCreatingFromZebinThenAppendAllowZebinFla
|
||||
}
|
||||
|
||||
HWTEST2_F(ModuleTranslationUnitTest, givenLargeGrfAndSimd16WhenProcessingBinaryThenKernelGroupSizeReducedToFitWithinSubslice, IsWithinXeGfxFamily) {
|
||||
std::string validZeInfo = std::string("version :\'") + versionToString(zeInfoDecoderVersion) + R"===('
|
||||
std::string validZeInfo = std::string("version :\'") + versionToString(NEO::Zebin::ZeInfo::zeInfoDecoderVersion) + R"===('
|
||||
kernels:
|
||||
- name : kernel_with_default_maxWGS
|
||||
execution_env :
|
||||
@@ -2355,10 +2355,10 @@ kernels:
|
||||
|
||||
uint8_t kernelIsa[8]{0U};
|
||||
ZebinTestData::ValidEmptyProgram zebin;
|
||||
zebin.removeSection(NEO::Elf::SHT_ZEBIN::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo);
|
||||
zebin.appendSection(NEO::Elf::SHT_ZEBIN::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo, ArrayRef<const uint8_t>::fromAny(validZeInfo.data(), validZeInfo.size()));
|
||||
zebin.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Elf::SectionsNamesZebin::textPrefix.str() + "kernel_with_default_maxWGS", {kernelIsa, sizeof(kernelIsa)});
|
||||
zebin.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Elf::SectionsNamesZebin::textPrefix.str() + "kernel_with_reduced_maxWGS", {kernelIsa, sizeof(kernelIsa)});
|
||||
zebin.removeSection(NEO::Zebin::Elf::SHT_ZEBIN::SHT_ZEBIN_ZEINFO, NEO::Zebin::Elf::SectionNames::zeInfo);
|
||||
zebin.appendSection(NEO::Zebin::Elf::SHT_ZEBIN::SHT_ZEBIN_ZEINFO, NEO::Zebin::Elf::SectionNames::zeInfo, ArrayRef<const uint8_t>::fromAny(validZeInfo.data(), validZeInfo.size()));
|
||||
zebin.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Zebin::Elf::SectionNames::textPrefix.str() + "kernel_with_default_maxWGS", {kernelIsa, sizeof(kernelIsa)});
|
||||
zebin.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Zebin::Elf::SectionNames::textPrefix.str() + "kernel_with_reduced_maxWGS", {kernelIsa, sizeof(kernelIsa)});
|
||||
zebin.elfHeader->machine = this->device->getNEODevice()->getHardwareInfo().platform.eProductFamily;
|
||||
|
||||
MockModule mockModule{this->device, nullptr, ModuleType::User};
|
||||
@@ -2387,7 +2387,7 @@ kernels:
|
||||
}
|
||||
|
||||
HWTEST2_F(ModuleTranslationUnitTest, givenLargeGrfAndSimd16WhenProcessingBinaryThenSuggestedKernelGroupSizeFitsWithinSubslice, IsWithinXeGfxFamily) {
|
||||
std::string validZeInfo = std::string("version :\'") + versionToString(zeInfoDecoderVersion) + R"===('
|
||||
std::string validZeInfo = std::string("version :\'") + versionToString(NEO::Zebin::ZeInfo::zeInfoDecoderVersion) + R"===('
|
||||
kernels:
|
||||
- name : kernel_with_default_maxWGS
|
||||
execution_env :
|
||||
@@ -2402,10 +2402,10 @@ kernels:
|
||||
|
||||
uint8_t kernelIsa[8]{0U};
|
||||
ZebinTestData::ValidEmptyProgram zebin;
|
||||
zebin.removeSection(NEO::Elf::SHT_ZEBIN::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo);
|
||||
zebin.appendSection(NEO::Elf::SHT_ZEBIN::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo, ArrayRef<const uint8_t>::fromAny(validZeInfo.data(), validZeInfo.size()));
|
||||
zebin.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Elf::SectionsNamesZebin::textPrefix.str() + "kernel_with_default_maxWGS", {kernelIsa, sizeof(kernelIsa)});
|
||||
zebin.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Elf::SectionsNamesZebin::textPrefix.str() + "kernel_with_reduced_maxWGS", {kernelIsa, sizeof(kernelIsa)});
|
||||
zebin.removeSection(NEO::Zebin::Elf::SHT_ZEBIN::SHT_ZEBIN_ZEINFO, NEO::Zebin::Elf::SectionNames::zeInfo);
|
||||
zebin.appendSection(NEO::Zebin::Elf::SHT_ZEBIN::SHT_ZEBIN_ZEINFO, NEO::Zebin::Elf::SectionNames::zeInfo, ArrayRef<const uint8_t>::fromAny(validZeInfo.data(), validZeInfo.size()));
|
||||
zebin.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Zebin::Elf::SectionNames::textPrefix.str() + "kernel_with_default_maxWGS", {kernelIsa, sizeof(kernelIsa)});
|
||||
zebin.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Zebin::Elf::SectionNames::textPrefix.str() + "kernel_with_reduced_maxWGS", {kernelIsa, sizeof(kernelIsa)});
|
||||
zebin.elfHeader->machine = this->device->getNEODevice()->getHardwareInfo().platform.eProductFamily;
|
||||
|
||||
MockModule mockModule{this->device, nullptr, ModuleType::User};
|
||||
@@ -2447,18 +2447,18 @@ kernels:
|
||||
}
|
||||
|
||||
TEST_F(ModuleTranslationUnitTest, WhenCreatingFromZeBinaryAndGlobalsAreExportedThenTheirAllocationTypeIsUSMDevice) {
|
||||
std::string zeInfo = std::string("version :\'") + versionToString(zeInfoDecoderVersion) + R"===('
|
||||
std::string zeInfo = std::string("version :\'") + versionToString(NEO::Zebin::ZeInfo::zeInfoDecoderVersion) + R"===('
|
||||
kernels:
|
||||
- name : kernel
|
||||
execution_env :
|
||||
simd_size : 8
|
||||
)===";
|
||||
MockElfEncoder<> elfEncoder;
|
||||
elfEncoder.getElfFileHeader().type = NEO::Elf::ET_ZEBIN_EXE;
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Elf::SectionsNamesZebin::textPrefix.str() + "kernel", std::string{});
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Elf::SectionsNamesZebin::dataConst, std::string{"12345678"});
|
||||
elfEncoder.getElfFileHeader().type = NEO::Zebin::Elf::ET_ZEBIN_EXE;
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Zebin::Elf::SectionNames::textPrefix.str() + "kernel", std::string{});
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Zebin::Elf::SectionNames::dataConst, std::string{"12345678"});
|
||||
auto dataConstSectionIndex = elfEncoder.getLastSectionHeaderIndex();
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Elf::SectionsNamesZebin::dataGlobal, std::string{"12345678"});
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Zebin::Elf::SectionNames::dataGlobal, std::string{"12345678"});
|
||||
auto dataGlobalSectionIndex = elfEncoder.getLastSectionHeaderIndex();
|
||||
|
||||
NEO::Elf::ElfSymbolEntry<NEO::Elf::ELF_IDENTIFIER_CLASS::EI_CLASS_64> symbolTable[2] = {};
|
||||
@@ -2473,9 +2473,9 @@ kernels:
|
||||
symbolTable[1].shndx = decltype(symbolTable[1].shndx)(dataGlobalSectionIndex);
|
||||
symbolTable[1].size = 4;
|
||||
symbolTable[1].value = 0;
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_SYMTAB, NEO::Elf::SectionsNamesZebin::symtab,
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_SYMTAB, NEO::Zebin::Elf::SectionNames::symtab,
|
||||
ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(symbolTable), sizeof(symbolTable)));
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo, zeInfo);
|
||||
elfEncoder.appendSection(NEO::Zebin::Elf::SHT_ZEBIN_ZEINFO, NEO::Zebin::Elf::SectionNames::zeInfo, zeInfo);
|
||||
auto zebin = elfEncoder.encode();
|
||||
|
||||
L0::ModuleTranslationUnit moduleTu(this->device);
|
||||
@@ -3717,7 +3717,7 @@ TEST_F(ModuleWithZebinTest, givenZebinSegmentsThenSegmentsArePopulated) {
|
||||
module->addSegments();
|
||||
auto segments = module->getZebinSegments();
|
||||
|
||||
auto checkGPUSeg = [](NEO::GraphicsAllocation *alloc, NEO::Debug::Segments::Segment segment) {
|
||||
auto checkGPUSeg = [](NEO::GraphicsAllocation *alloc, NEO::Zebin::Debug::Segments::Segment segment) {
|
||||
EXPECT_EQ(alloc->getGpuAddress(), segment.address);
|
||||
EXPECT_EQ(alloc->getUnderlyingBufferSize(), segment.size);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user