Changeset 2519 in CLRX


Ignore:
Timestamp:
Nov 1, 2016, 2:41:13 PM (4 years ago)
Author:
matszpk
Message:

CLRadeonExtender: Update.

Location:
CLRadeonExtender/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/CLRX/amdasm/Disassembler.h

    r2517 r2519  
    258258};
    259259
    260 struct ROCmDisasmRegion
    261 {
    262     size_t size;
    263     size_t offset;
    264     size_t kernelIndex;
     260/// disasm ROCm region
     261struct ROCmDisasmRegionInput
     262{
     263    CString regionName; ///< region name
     264    size_t size;    ///< region size
     265    size_t offset;  ///< region offset in code
     266    bool isKernel;  ///< true if kernel
    265267};
    266268
     
    270272    uint32_t archMinor;     ///< GPU arch minor
    271273    uint32_t archStepping;     ///< GPU arch stepping
    272     std::vector<ROCmDisasmKernelInput> kernels;    ///< kernel inputs
    273     std::vector<ROCmDisasmRegion> regions;  ///< regions
     274    std::vector<ROCmDisasmRegionInput> regions;  ///< regions
    274275    size_t codeSize;    ///< code size
    275276    const cxbyte* code; ///< code
  • CLRadeonExtender/trunk/amdasm/DisasmROCm.cpp

    r2517 r2519  
    1919
    2020#include <CLRX/Config.h>
     21#include <iostream>
    2122#include <cstdint>
    2223#include <cstdio>
     
    7172    std::unique_ptr<ROCmDisasmInput> input(new ROCmDisasmInput);
    7273    uint32_t archMajor = 0;
    73     const uint16_t textIndex = binary.getSectionIndex(".text");
    7474   
    7575    {
     
    9898    }
    9999    // determine device type
     100    std::cout << "archmajor: " << archMajor << ", archminor: " << input->archMinor <<
     101            ", archstepping: " << input->archStepping << "\n";
    100102    cxuint deviceNumber = 0;
    101103    for (deviceNumber = 0; deviceNumber <= cxuint(GPUDeviceType::GPUDEVICE_MAX);
     
    109111    input->deviceType = GPUDeviceType(deviceNumber);
    110112   
    111     input->code = binary.getSectionContent(textIndex);
    112     input->codeSize = ULEV(binary.getSectionHeader(textIndex).sh_size);
     113    const size_t regionsNum = binary.getRegionsNum();
     114    input->regions.resize(regionsNum);
     115    size_t codeOffset = binary.getCode()-binary.getBinaryCode();
     116    for (size_t i = 0; i < regionsNum; i++)
     117    {
     118        const ROCmRegion& region = binary.getRegion(i);
     119        input->regions[i] = { region.regionName, region.size,
     120            region.offset - codeOffset, region.isKernel };
     121    }
     122   
     123    input->code = binary.getCode();
     124    input->codeSize = binary.getCodeSize();
    113125    return input.release();
    114126}
     
    117129           ISADisassembler* isaDisassembler, size_t& sectionCount, Flags flags)
    118130{
     131    const bool doDumpData = ((flags & DISASM_DUMPDATA) != 0);
     132    const bool doMetadata = ((flags & (DISASM_METADATA|DISASM_CONFIG)) != 0);
     133    const bool doDumpCode = ((flags & DISASM_DUMPCODE) != 0);
     134    const bool doDumpConfig = ((flags & DISASM_CONFIG) != 0);
     135   
     136    const GPUArchitecture arch = getGPUArchitectureFromDeviceType(rocmInput->deviceType);
     137    const cxuint maxSgprsNum = getGPUMaxRegistersNum(arch, REGTYPE_SGPR, 0);
     138   
     139    for (cxuint i = 0; i < rocmInput->regions.size(); i++)
     140    {
     141        const ROCmDisasmRegionInput& rinput = rocmInput->regions[i];
     142        if (rinput.isKernel)
     143        {
     144            output.write(".kernel ", 8);
     145            output.write(rinput.regionName.c_str(), rinput.regionName.size());
     146            output.put('\n');
     147        }
     148    }
     149    if (doDumpCode && rocmInput->code != nullptr && rocmInput->codeSize != 0)
     150    {
     151    }
    119152}
  • CLRadeonExtender/trunk/amdbin/ROCmBinaries.cpp

    r2518 r2519  
    5252        const Elf64_Sym& sym = getSymbol(i);
    5353        const cxbyte symType = ELF64_ST_TYPE(sym.st_info);
    54         if (sym.st_shndx==textIndex &&
     54        if (sym.st_shndx==textIndex && ELF64_ST_BIND(sym.st_info)==STB_GLOBAL &&
    5555            (symType==STT_GNU_IFUNC || symType==STT_OBJECT))
    5656            regionsNum++;
     
    7474       
    7575        const cxbyte symType = ELF64_ST_TYPE(sym.st_info);
    76         const bool isKernel = (symType==STT_GNU_IFUNC);
    77         if (symType==STT_GNU_IFUNC || symType==STT_OBJECT)
     76        if (ELF64_ST_BIND(sym.st_info)==STB_GLOBAL &&
     77            (symType==STT_GNU_IFUNC || symType==STT_OBJECT))
     78        {
     79            const bool isKernel = (symType==STT_GNU_IFUNC);
    7880            symOffsets[j] = std::make_pair(value, j);
    79        
    80         if (isKernel && value+0x100 > codeOffset+codeSize)
    81             throw Exception("Kernel offset is too big!");
    82         regions[j++] = { getSymbolName(i), size, value, isKernel };
     81            if (isKernel && value+0x100 > codeOffset+codeSize)
     82                throw Exception("Kernel offset is too big!");
     83            regions[j++] = { getSymbolName(i), size, value, isKernel };
     84        }
    8385    }
    8486    std::sort(symOffsets.get(), symOffsets.get()+regionsNum,
  • CLRadeonExtender/trunk/programs/clrxdisasm.cpp

    r2498 r2519  
    2424#include <CLRX/utils/CLIParser.h>
    2525#include <CLRX/amdbin/AmdBinaries.h>
     26#include <CLRX/amdbin/AmdCL2Binaries.h>
     27#include <CLRX/amdbin/ROCmBinaries.h>
    2628#include <CLRX/amdbin/GalliumBinaries.h>
    2729#include <CLRX/amdasm/Disassembler.h>
     
    138140                    disasm.disassemble();
    139141                }
     142                else if (isROCmBinary(binaryData.size(), binaryData.data()))
     143                {   // ROCm binary
     144                    binFlags |= ROCMBIN_CREATE_REGIONMAP;
     145                    ROCmBinary rocmBin(binaryData.size(), binaryData.data(), binFlags);
     146                    Disassembler disasm(rocmBin, std::cout, disasmFlags);
     147                    disasm.disassemble();
     148                }
    140149                else // if gallium binary
    141150                {
Note: See TracChangeset for help on using the changeset viewer.