Changeset 2504 in CLRX


Ignore:
Timestamp:
Oct 30, 2016, 7:04:40 AM (4 years ago)
Author:
matszpk
Message:

CLRadeonExtender: ROCm: add codeSize field to ROCmKernel. Checking and setting kernel sizes.

Location:
CLRadeonExtender/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/CLRX/amdbin/ROCmBinaries.h

    r2502 r2504  
    5050    CString kernelName; ///< kernel name
    5151    cxbyte* setup;      ///< setup data
    52     cxbyte* code;     ///< data
     52    size_t codeSize;    ///< code size
     53    cxbyte* code;     ///< code
    5354};
    5455
  • CLRadeonExtender/trunk/amdbin/ROCmBinaries.cpp

    r2503 r2504  
    6060    kernels.reset(new ROCmKernel[kernelsNum]);
    6161    size_t j = 0;
    62     std::unique_ptr<uint64_t[]> kernelOffsets(new uint64_t[kernelsNum]);
     62   
     63    typedef std::pair<uint64_t, size_t> KernelOffsetEntry;
     64    std::unique_ptr<KernelOffsetEntry[]> kernelOffsets(new KernelOffsetEntry[kernelsNum]);
    6365    for (size_t i = 0; i < symbolsNum; i++)
    6466    {
     
    6769            continue;
    6870        const size_t value = ULEV(sym.st_value);
     71        const size_t size = ULEV(sym.st_size);
    6972        if (value+0x100 > codeSize)
    7073            throw Exception("Kernel offset is too big!");
    71         kernelOffsets[j] = value;
    72         kernels[j++] = { getSymbolName(i), code+value, code+value+0x100 };
     74        kernelOffsets[j] = std::make_pair(value, j);
     75        kernels[j++] = { getSymbolName(i), code+value, size, code+value+0x100 };
    7376    }
    74     std::sort(kernelOffsets.get(), kernelOffsets.get()+kernelsNum);
     77    std::sort(kernelOffsets.get(), kernelOffsets.get()+kernelsNum,
     78            [](const KernelOffsetEntry& a, const KernelOffsetEntry& b)
     79            { return a.first < b.first; });
    7580    // checking distance between kernels
    7681    for (size_t i = 1; i < kernelsNum; i++)
    77         if (kernelOffsets[i-1]+0x100 > kernelOffsets[i])
     82    {
     83        if (kernelOffsets[i-1].first+0x100 > kernelOffsets[i].first)
    7884            throw Exception("Kernel size is too small!");
     85        ROCmKernel& kernel = kernels[kernelOffsets[i-1].second];
     86        uint64_t kcodeSize = kernelOffsets[i].first - (kernelOffsets[i-1].first+0x100);
     87        if (kernel.codeSize==0 && kcodeSize>0)
     88            kernel.codeSize = kcodeSize;
     89        if (kernel.codeSize > kcodeSize)
     90            throw Exception("Kernel code size out of range");
     91    }
     92    {   // last kernel in position
     93        if (kernelOffsets[kernelsNum-1].first+0x100 > codeSize)
     94            throw Exception("Kernel size is too small!");
     95        ROCmKernel& kernel = kernels[kernelOffsets[kernelsNum-1].second];
     96        uint64_t kcodeSize = codeSize - (kernelOffsets[kernelsNum-1].first+0x100);
     97        if (kernel.codeSize==0 && kcodeSize>0)
     98            kernel.codeSize = kcodeSize;
     99        if (kernel.codeSize > kcodeSize)
     100            throw Exception("Kernel code size out of range");
     101    }
    79102   
    80103    if (hasKernelMap())
Note: See TracChangeset for help on using the changeset viewer.