Changeset 3724 in CLRX


Ignore:
Timestamp:
Feb 6, 2018, 7:02:59 AM (15 months ago)
Author:
matszpk
Message:

CLRadeonExtender: ROCmBinGen: Integrate ROCm metadata generator (untested) with ROCmBinGenerator.

Location:
CLRadeonExtender/trunk
Files:
3 edited

Legend:

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

    r3715 r3724  
    369369    size_t metadataSize;    ///< metadata size
    370370    const char* metadata;   ///< metadata
     371    bool useMetadataInfo;   ///< use metadatainfo instead same metadata
     372    ROCmMetadata metadataInfo; ///< metadata info
    371373    std::vector<BinSection> extraSections;  ///< extra sections
    372374    std::vector<BinSymbol> extraSymbols;    ///< extra symbols
  • CLRadeonExtender/trunk/amdbin/ROCmBinaries.cpp

    r3723 r3724  
    19721972    if (!target.empty())
    19731973        elfBinGen64.addNote({"AMD", target.size(), (const cxbyte*)target.c_str(), 0xbU});
    1974     if (input->metadataSize != 0)
    1975         elfBinGen64.addNote({"AMD", input->metadataSize,
    1976                 (const cxbyte*)input->metadata, 0xaU});
     1974   
     1975    size_t metadataSize = input->metadataSize;
     1976    const char* metadata = input->metadata;
     1977    std::string metadataStr;
     1978    if (input->useMetadataInfo)
     1979    {
     1980        // generate ROCm metadata
     1981        std::vector<std::pair<CString, size_t> > symbolIndices(input->symbols.size());
     1982        // create sorted indices of symbols by its name
     1983        for (size_t k = 0; k < input->symbols.size(); k++)
     1984            symbolIndices[k] = std::make_pair(input->symbols[k].symbolName, k);
     1985        mapSort(symbolIndices.begin(), symbolIndices.end());
     1986       
     1987        const size_t mdKernelsNum = input->metadataInfo.kernels.size();
     1988        std::unique_ptr<const ROCmKernelConfig*[]> kernelConfigPtrs(
     1989                new const ROCmKernelConfig*[mdKernelsNum]);
     1990        for (size_t k = 0; k < mdKernelsNum; k++)
     1991        {
     1992            auto it = binaryMapFind(symbolIndices.begin(), symbolIndices.end(),
     1993                        input->metadataInfo.kernels[k].name);
     1994            if (it == symbolIndices.end())
     1995                throw BinGenException("Kernel in metadata doesn't exists in code");
     1996            kernelConfigPtrs[k] = reinterpret_cast<const ROCmKernelConfig*>(
     1997                        input->code + input->symbols[it->second].offset);
     1998        }
     1999       
     2000        //generateROCmMetadata(input->metadataInfo, metadataStr);
     2001        metadataSize = metadataStr.size();
     2002        metadata = metadataStr.c_str();
     2003    }
     2004   
     2005    if (metadataSize != 0)
     2006        elfBinGen64.addNote({"AMD", metadataSize, (const cxbyte*)metadata, 0xaU});
    19772007   
    19782008    /// region and sections
  • CLRadeonExtender/trunk/tests/amdbin/ROCmBinGen.cpp

    r3674 r3724  
    5959    rocmInput.globalDataSize = binary.getGlobalDataSize();
    6060    rocmInput.globalData = binary.getGlobalData();
     61    rocmInput.useMetadataInfo = false;
    6162   
    6263    {
Note: See TracChangeset for help on using the changeset viewer.