Changeset 2516 in CLRX


Ignore:
Timestamp:
Nov 1, 2016, 10:49:52 AM (3 years ago)
Author:
matszpk
Message:

CLRadeonExtender: Small fixes in ROCmBinaries. remove obsolete flags arguments from getGalliumDisasmInputFromBinary.
First code in DisasmROCm. Add ROCm to binary type list.

Location:
CLRadeonExtender/trunk
Files:
8 edited

Legend:

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

    r2386 r2516  
    3636    GALLIUM,     ///< GalliumCompute format
    3737    RAWCODE,     ///< raw code format
    38     AMDCL2      ///< AMD OpenCL 2.0 format
     38    AMDCL2,      ///< AMD OpenCL 2.0 format
     39    ROCM         ///< ROCm (RadeonOpenCompute) format
    3940};
    4041
  • CLRadeonExtender/trunk/CLRX/amdasm/Disassembler.h

    r2515 r2516  
    254254    const cxbyte* setup;
    255255    size_t codeSize;
    256     const cxbyte* code;
     256    size_t offset;
    257257};
    258258
     
    262262    uint32_t archMinor;     ///< GPU arch minor
    263263    uint32_t archStepping;     ///< GPU arch stepping
    264    
    265264    std::vector<ROCmDisasmKernelInput> kernels;    ///< kernel inputs
    266265};
  • CLRadeonExtender/trunk/amdasm/DisasmGallium.cpp

    r2377 r2516  
    3737template<typename GalliumElfBinary>
    3838static void getGalliumDisasmInputFromBinaryBase(const GalliumBinary& binary,
    39             const GalliumElfBinary& elfBin, Flags flags, GalliumDisasmInput* input)
     39            const GalliumElfBinary& elfBin, GalliumDisasmInput* input)
    4040{
    4141    uint16_t rodataIndex = SHN_UNDEF;
     
    7777
    7878GalliumDisasmInput* CLRX::getGalliumDisasmInputFromBinary(GPUDeviceType deviceType,
    79            const GalliumBinary& binary, Flags flags)
     79           const GalliumBinary& binary)
    8080{
    8181    std::unique_ptr<GalliumDisasmInput> input(new GalliumDisasmInput);
     
    8484    {
    8585        input->is64BitMode = false;
    86         getGalliumDisasmInputFromBinaryBase(binary, binary.getElfBinary32(),
    87                                 flags, input.get());
     86        getGalliumDisasmInputFromBinaryBase(binary, binary.getElfBinary32(), input.get());
    8887    }
    8988    else // 64-bit
    9089    {
    9190        input->is64BitMode = true;
    92         getGalliumDisasmInputFromBinaryBase(binary, binary.getElfBinary64(),
    93                                 flags, input.get());
     91        getGalliumDisasmInputFromBinaryBase(binary, binary.getElfBinary64(), input.get());
    9492    }
    9593    return input.release();
  • CLRadeonExtender/trunk/amdasm/DisasmInternals.h

    r2511 r2516  
    7474
    7575extern CLRX_INTERNAL GalliumDisasmInput* getGalliumDisasmInputFromBinary(
    76             GPUDeviceType deviceType, const GalliumBinary& binary, Flags flags);
     76            GPUDeviceType deviceType, const GalliumBinary& binary);
    7777
    7878extern CLRX_INTERNAL const std::pair<const char*, KernelArgType> disasmArgTypeNameMap[74];
  • CLRadeonExtender/trunk/amdasm/DisasmROCm.cpp

    r2511 r2516  
    3535using namespace CLRX;
    3636
     37struct AMDGPUArchValues
     38{
     39    uint32_t major;
     40    uint32_t minor;
     41    uint32_t stepping;
     42};
     43
     44static const AMDGPUArchValues amdGpuArchValuesTbl[] =
     45{
     46    { 0, 0, 0 }, // GPUDeviceType::CAPE_VERDE
     47    { 0, 0, 0 }, // GPUDeviceType::PITCAIRN
     48    { 0, 0, 0 }, // GPUDeviceType::TAHITI
     49    { 0, 0, 0 }, // GPUDeviceType::OLAND
     50    { 7, 0, 0 }, // GPUDeviceType::BONAIRE
     51    { 7, 0, 0 }, // GPUDeviceType::SPECTRE
     52    { 7, 0, 0 }, // GPUDeviceType::SPOOKY
     53    { 7, 0, 0 }, // GPUDeviceType::KALINDI
     54    { 0, 0, 0 }, // GPUDeviceType::HAINAN
     55    { 7, 0, 1 }, // GPUDeviceType::HAWAII
     56    { 8, 0, 0 }, // GPUDeviceType::ICELAND
     57    { 8, 0, 0 }, // GPUDeviceType::TONGA
     58    { 7, 0, 0 }, // GPUDeviceType::MULLINS
     59    { 8, 0, 4 }, // GPUDeviceType::FIJI
     60    { 8, 0, 1 }, // GPUDeviceType::CARRIZO
     61    { 0, 0, 0 }, // GPUDeviceType::DUMMY
     62    { 0, 0, 0 }, // GPUDeviceType::GOOSE
     63    { 0, 0, 0 }, // GPUDeviceType::HORSE
     64    { 8, 1, 0 }, // GPUDeviceType::STONEY
     65    { 8, 0, 4 }, // GPUDeviceType::ELLESMERE
     66    { 8, 0, 4 } // GPUDeviceType::BAFFIN
     67};
     68
     69ROCmDisasmInput* CLRX::getROCmDisasmInputFromBinary(GPUDeviceType deviceType,
     70           const ROCmBinary& binary, Flags flags)
     71{
     72    std::unique_ptr<ROCmDisasmInput> input(new ROCmDisasmInput);
     73    uint32_t archMajor = 0;
     74    {
     75        const cxbyte* noteContent = binary.getSectionContent(".note");
     76        size_t notesSize = binary.getSectionHeader(".note").sh_size;
     77        // find note about AMDGPU
     78        for (size_t offset = 0; offset < notesSize; )
     79        {
     80            const Elf64_Nhdr* nhdr = (const Elf64_Nhdr*)(noteContent + offset);
     81            size_t namesz = ULEV(nhdr->n_namesz);
     82            size_t descsz = ULEV(nhdr->n_descsz);
     83            if (usumGt(offset, namesz+descsz, notesSize))
     84                throw Exception("Note offset+size out of range");
     85            if (ULEV(nhdr->n_type) == 0x3 && namesz==4 && descsz>=0x1a &&
     86                ::strcmp((const char*)noteContent+offset+sizeof(Elf64_Nhdr), "AMD")==0)
     87            {    // AMDGPU type
     88                const uint32_t* content = (const uint32_t*)
     89                        (noteContent+offset+sizeof(Elf64_Nhdr) + 4);
     90                archMajor = ULEV(content[1]);
     91                input->archMinor = ULEV(content[2]);
     92                input->archStepping = ULEV(content[3]);
     93            }
     94            size_t align = (((namesz+descsz)&3)!=0) ? 4-((namesz+descsz)&3) : 0;
     95            offset += sizeof(Elf64_Nhdr) + namesz + descsz + align;
     96        }
     97    }
     98    // determine device type
     99    cxuint deviceNumber = 0;
     100    for (deviceNumber = 0; deviceNumber <= cxuint(GPUDeviceType::GPUDEVICE_MAX);
     101                 deviceNumber++)
     102        if (amdGpuArchValuesTbl[deviceNumber].major==archMajor &&
     103            amdGpuArchValuesTbl[deviceNumber].minor==input->archMinor &&
     104            amdGpuArchValuesTbl[deviceNumber].stepping==input->archStepping)
     105            break;
     106    if (deviceNumber > cxuint(GPUDeviceType::GPUDEVICE_MAX))
     107        throw Exception("Can't determine device type from arch values!");
     108    input->deviceType = GPUDeviceType(deviceNumber);
     109    return input.release();
     110}
     111
    37112void CLRX::disassembleROCm(std::ostream& output, const ROCmDisasmInput* rocmInput,
    38113           ISADisassembler* isaDisassembler, size_t& sectionCount, Flags flags)
    39114{
    40115}
    41 
    42 ROCmDisasmInput* CLRX::getROCmDisasmInputFromBinary(GPUDeviceType deviceType,
    43            const ROCmBinary& binary, Flags flags)
    44 {
    45     return nullptr;
    46 }
  • CLRadeonExtender/trunk/amdasm/Disassembler.cpp

    r2343 r2516  
    288288{
    289289    isaDisassembler.reset(new GCNDisassembler(*this));
    290     galliumInput = getGalliumDisasmInputFromBinary(deviceType, binary, flags);
     290    galliumInput = getGalliumDisasmInputFromBinary(deviceType, binary);
    291291}
    292292
  • CLRadeonExtender/trunk/amdbin/AmdCL2BinGen.cpp

    r2513 r2516  
    16811681};
    16821682
    1683 
    16841683static const AMDGPUArchValues amdGpuArchValuesTbl[] =
    16851684{
  • CLRadeonExtender/trunk/amdbin/ROCmBinaries.cpp

    r2514 r2516  
    5454        if (sym.st_shndx==textIndex)
    5555        {
    56             if (ELF64_ST_TYPE(sym.st_info)==10)
     56            if (ELF64_ST_TYPE(sym.st_info)==STT_GNU_IFUNC)
    5757                kernelsNum++;
    5858            symsNum++;
     
    7575            throw Exception("Kernel offset is too small!");
    7676        const size_t size = ULEV(sym.st_size);
    77         if (ELF64_ST_TYPE(sym.st_info)!=10)
     77        if (ELF64_ST_TYPE(sym.st_info)!=STT_GNU_IFUNC)
    7878        {
    7979            symOffsets[k++] = std::make_pair(value, SIZE_MAX);
Note: See TracChangeset for help on using the changeset viewer.