Ignore:
Timestamp:
Sep 21, 2017, 7:12:08 PM (2 years ago)
Author:
matszpk
Message:

CLRadeonExtender: Commenting AmdCL2BinGen and ROCmBinaries.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/amdbin/ROCmBinaries.cpp

    r3396 r3420  
    4444    { } // ignore failed
    4545    uint64_t codeOffset = 0;
     46    // find '.text' section
    4647    if (textIndex!=SHN_UNDEF)
    4748    {
     
    5253    }
    5354   
     55    // counts regions (symbol or kernel)
    5456    regionsNum = 0;
    5557    const size_t symbolsNum = getSymbolsNum();
     
    7274    std::unique_ptr<RegionOffsetEntry[]> symOffsets(new RegionOffsetEntry[regionsNum]);
    7375   
     76    // get regions info
    7477    for (size_t i = 0; i < symbolsNum; i++)
    7578    {
     
    8891        {
    8992            ROCmRegionType type = ROCmRegionType::DATA;
     93            // if kernel
    9094            if (symType==STT_GNU_IFUNC)
    9195                type = ROCmRegionType::KERNEL;
     96            // if function kernel
    9297            else if (symType==STT_FUNC)
    9398                type = ROCmRegionType::FKERNEL;
     
    98103        }
    99104    }
     105    // sort regions by offset
    100106    std::sort(symOffsets.get(), symOffsets.get()+regionsNum,
    101107            [](const RegionOffsetEntry& a, const RegionOffsetEntry& b)
     
    122128        for (size_t i = 0; i < regionsNum; i++)
    123129            regionsMap[i] = std::make_pair(regions[i].regionName, i);
     130        // sort region map
    124131        mapSort(regionsMap.begin(), regionsMap.end());
    125132    }
     
    134141};
    135142
     143// list of AMDGPU arch entries for GPU devices
    136144static const AMDGPUArchValuesEntry amdGpuArchValuesTbl[] =
    137145{
     
    153161
    154162
     163/// determint GPU device from ROCm notes
    155164GPUDeviceType ROCmBinary::determineGPUDeviceType(uint32_t& outArchMinor,
    156165                     uint32_t& outArchStepping) const
     
    188197    // determine device type
    189198    GPUDeviceType deviceType = GPUDeviceType::CAPE_VERDE;
     199    // choose lowest GPU device by archMajor by default
    190200    if (archMajor==0)
    191201        deviceType = GPUDeviceType::CAPE_VERDE;
     
    197207        deviceType = GPUDeviceType::GFX900;
    198208   
     209    // recognize device type by arch major, minor and stepping
    199210    for (cxuint i = 0; i < amdGpuArchValuesNum; i++)
    200211        if (amdGpuArchValuesTbl[i].major==archMajor &&
     
    219230}
    220231
     232// if ROCm binary
    221233bool CLRX::isROCmBinary(size_t binarySize, const cxbyte* binary)
    222234{
     
    276288}
    277289
     290// ELF notes contents
    278291static const cxbyte noteDescType1[8] =
    279292{ 2, 0, 0, 0, 1, 0, 0, 0 };
     
    352365    ElfBinaryGen64 elfBinGen64({ 0U, 0U, 0x40, 0, ET_DYN,
    353366        0xe0, EV_CURRENT, UINT_MAX, 0, 0 }, true, true, true, PHREGION_FILESTART);
    354     // add symbols
     367    // add symbols (kernels, function kernels and data symbols)
    355368    elfBinGen64.addSymbol(ElfSymbol64("_DYNAMIC", 5,
    356369                  ELF64_ST_INFO(STB_LOCAL, STT_NOTYPE), STV_HIDDEN, true, 0, 0));
     
    378391                break;
    379392        }
     393        // add to symbols and dynamic symbols table
    380394        elfBinGen64.addSymbol(elfsym);
    381395        elfBinGen64.addDynSymbol(elfsym);
     
    418432    elfBinGen64.addRegion(ElfRegion64(0, (const cxbyte*)nullptr, 1, ".dynstr", SHT_STRTAB,
    419433                SHF_ALLOC, 0, 0, Elf64Types::nobase));
     434    // '.text' with alignment=4096
    420435    elfBinGen64.addRegion(ElfRegion64(input->codeSize, (const cxbyte*)input->code,
    421436              0x1000, ".text", SHT_PROGBITS, SHF_ALLOC|SHF_EXECINSTR, 0, 0,
Note: See TracChangeset for help on using the changeset viewer.