Ignore:
Timestamp:
Oct 29, 2016, 10:12:54 PM (4 years ago)
Author:
matszpk
Message:

CLRadeonExtender: Add function to checking whether binary is ROCm binary.

File:
1 edited

Legend:

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

    r2500 r2501  
    3333using namespace CLRX;
    3434
    35 ROCmBinary::ROCmBinary(size_t binaryCodeSize, cxbyte* binaryCode,
    36             Flags creationFlags)
     35ROCmBinary::ROCmBinary(size_t binaryCodeSize, cxbyte* binaryCode, Flags creationFlags)
     36        : ElfBinary64(binaryCodeSize, binaryCode, creationFlags)
    3737{
    3838}
     
    4040const ROCmKernel& ROCmBinary::getKernel(const char* name) const
    4141{
    42     throw Exception("aaaa");
     42    KernelMap::const_iterator it = binaryMapFind(kernelsMap.begin(),
     43                             kernelsMap.end(), name);
     44    if (it == kernelsMap.end())
     45        throw Exception("Can't find kernel name");
     46    return kernels[it->second];
    4347}
     48
     49bool CLRX::isROCmBinary(size_t binarySize, const cxbyte* binary)
     50{
     51    if (!isElfBinary(binarySize, binary))
     52        return false;
     53    if (binary[EI_CLASS] != ELFCLASS64)
     54        return false;
     55    const Elf64_Ehdr* ehdr = reinterpret_cast<const Elf64_Ehdr*>(binary);
     56    if (ULEV(ehdr->e_machine) != 0xe0 || ULEV(ehdr->e_flags)!=0)
     57        return false;
     58    return true;
     59}
Note: See TracChangeset for help on using the changeset viewer.