Ignore:
Timestamp:
Apr 5, 2017, 11:47:54 AM (2 years ago)
Author:
cameron
Message:

Kernel signatures for object cache

Location:
icGREP/icgrep-devel/icgrep
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/deletion.cpp

    r5376 r5392  
    8282
    8383DeletionKernel::DeletionKernel(IDISA::IDISA_Builder * iBuilder, unsigned fw, unsigned streamCount)
    84 : BlockOrientedKernel(iBuilder, "del",
     84: BlockOrientedKernel(iBuilder, "Parabix:del" + std::to_string(fw) + "_" + std::to_string(streamCount),
    8585              {Binding{iBuilder->getStreamSetTy(streamCount), "inputStreamSet"},
    8686               Binding{iBuilder->getStreamSetTy(), "delMaskSet"}},
     
    225225
    226226DeleteByPEXTkernel::DeleteByPEXTkernel(IDISA::IDISA_Builder * iBuilder, unsigned fw, unsigned streamCount, bool shouldSwizzle)
    227 : BlockOrientedKernel(iBuilder, "PEXTdel",
     227    : BlockOrientedKernel(iBuilder, "Parabix:PEXTdel" + std::to_string(fw) + "_" + std::to_string(streamCount) + (shouldSwizzle ? "swiz" : "noswiz"),
    228228                      {Binding{iBuilder->getStreamSetTy(streamCount), "inputStreamSet"},
    229229                          Binding{iBuilder->getStreamSetTy(), "delMaskSet"}},
     
    265265
    266266SwizzledBitstreamCompressByCount::SwizzledBitstreamCompressByCount(IDISA::IDISA_Builder * iBuilder, unsigned bitStreamCount, unsigned fieldWidth)
    267     : BlockOrientedKernel(iBuilder, "swizzled_compress", {Binding{iBuilder->getStreamSetTy(), "countsPerStride"}}, {}, {}, {}, {})
     267    : BlockOrientedKernel(iBuilder, "Parabix:swizzled_compress" + std::to_string(fieldWidth) + "_" + std::to_string(bitStreamCount),
     268                         {Binding{iBuilder->getStreamSetTy(), "countsPerStride"}}, {}, {}, {}, {})
    268269, mBitStreamCount(bitStreamCount)
    269270    , mFieldWidth(fieldWidth)
  • icGREP/icgrep-devel/icgrep/kernels/deletion.h

    r5362 r5392  
    2727
    2828    DeletionKernel(IDISA::IDISA_Builder * iBuilder, unsigned fw, unsigned streamCount);
    29    
     29    bool moduleIDisSignature() override {return true;}
     30
    3031protected:
    31 
    3232    void generateDoBlockMethod() override;
    3333
     
    4343
    4444    DeleteByPEXTkernel(IDISA::IDISA_Builder * iBuilder, unsigned fw, unsigned streamCount, bool shouldSwizzle);
     45    bool moduleIDisSignature() override {return true;}
    4546   
    4647protected:
    47    
    4848    void generateDoBlockMethod() override;
    4949   
     
    6868   
    6969    SwizzledBitstreamCompressByCount(IDISA::IDISA_Builder * iBuilder, unsigned bitStreamCount, unsigned fieldWidth = 64);
     70    bool moduleIDisSignature() override {return true;}
    7071   
    7172protected:
     73    void generateDoBlockMethod() override;
    7274   
    73     void generateDoBlockMethod() override;
    7475    void generateFinalBlockMethod(llvm::Value * remainingBytes) override;
    7576   
  • icGREP/icgrep-devel/icgrep/kernels/kernel.cpp

    r5391 r5392  
    1313#include <llvm/IR/Module.h>
    1414#include <llvm/Support/raw_ostream.h>
     15#include <llvm/Bitcode/ReaderWriter.h>
    1516#include <llvm/Transforms/Utils/Local.h>
    1617
     
    5960}
    6061
    61 void KernelBuilder::prepareKernelSignature() {
     62void KernelBuilder::prepareStreamSetNameMap() {
    6263    for (unsigned i = 0; i < mStreamSetInputs.size(); i++) {
    6364        mStreamSetNameMap.emplace(mStreamSetInputs[i].name, i);
     
    110111    }
    111112    if (mStreamSetNameMap.empty()) {
    112         prepareKernelSignature();
     113        prepareStreamSetNameMap();
    113114    }
    114115    for (auto binding : mInternalScalars) {
     
    153154   
    154155}   
     156
     157
     158// Default kernel signature: generate the IR and emit as byte code.
     159void KernelBuilder::generateKernelSignature(std::string &signature) {
     160    generateKernel();
     161    raw_string_ostream OS(signature);
     162    WriteBitcodeToFile(iBuilder->getModule(), OS);
     163}
     164
    155165
    156166std::unique_ptr<Module> KernelBuilder::createKernelModule(const std::vector<StreamSetBuffer *> & inputs, const std::vector<StreamSetBuffer *> & outputs) {
  • icGREP/icgrep-devel/icgrep/kernels/kernel.h

    r5391 r5392  
    2828public:
    2929   
     30    // Kernel Signatures and Module IDs
     31    //
     32    // A kernel signature uniquely identifies a kernel and its full functionality.
     33    // In the event that a particular kernel instance is to be generated and compiled
     34    // to produce object code, and we have a cached kernel object code instance with
     35    // the same signature and targetting the same IDISA architecture, then the cached
     36    // object code may safely be used to avoid recompilation.
     37    //
     38    // A kernel signature is a byte string of arbitrary length.
     39    //
     40    // Kernel developers should take responsibility for designing appropriate signature
     41    // mechanisms that are short, inexpensive to compute and guarantee uniqueness
     42    // based on the semantics of the kernel. 
     43    //
     44    // If no other mechanism is available, the default generateKernelSignature() method
     45    // uses the full LLVM IR (before optimization) of the kernel instance.
     46    //
     47    // A kernel Module ID is short string that is used as a name for a particular kernel
     48    // instance.  Kernel Module IDs are used to look up and retrieve cached kernel instances
     49    // and so should be highly likely to uniquely identify a kernel instance.
     50    //
     51    // The ideal case is that a kernel Module ID serves as a full kernel signature thus
     52    // guaranteeing uniqueness.  In this case, the moduleIDisUnique() method
     53    // should return true.
     54    //
     55   
     56    // Can the module ID itself serve as the unique signature?
     57    virtual bool moduleIDisSignature() {/* default */  return false;}
     58   
     59    virtual void generateKernelSignature(std::string & signature);
     60   
    3061    // Create a module stub for the kernel, populated only with its Module ID.     
    3162    //
     
    139170    }
    140171
    141     void prepareKernelSignature();
     172    void prepareStreamSetNameMap();
    142173
    143174    virtual void prepareKernel();
  • icGREP/icgrep-devel/icgrep/kernels/mmap_kernel.h

    r5377 r5392  
    1818public:
    1919    MMapSourceKernel(IDISA::IDISA_Builder * iBuilder, unsigned blocksPerSegment = 1, unsigned codeUnitWidth = 8); 
     20    bool moduleIDisSignature() override {return true;}
    2021private:
    2122    void generateInitMethod() override;
  • icGREP/icgrep-devel/icgrep/kernels/s2p_kernel.h

    r5297 r5392  
    1515public:   
    1616    S2PKernel(IDISA::IDISA_Builder * builder);
     17    bool moduleIDisSignature() override {return true;}
    1718    virtual ~S2PKernel() {}
    18 private:
     19protected:
    1920    void generateDoBlockMethod() override;
    2021    void generateFinalBlockMethod(llvm::Value * remainingBytes) override;
  • icGREP/icgrep-devel/icgrep/kernels/scanmatchgen.h

    r5377 r5392  
    1717public:
    1818    ScanMatchKernel(IDISA::IDISA_Builder * iBuilder, GrepType grepType, unsigned codeUnitWidth);
     19    bool moduleIDisSignature() override {return true;}
    1920protected:
    2021    void generateInitMethod() override;
  • icGREP/icgrep-devel/icgrep/object_cache.cpp

    r5391 r5392  
    88
    99
     10#define OBJECT_CACHE_DEBUG
    1011#ifdef OBJECT_CACHE_DEBUG
    1112#include <iostream>
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.cpp

    r5356 r5392  
    141141, mSymbolTable(new SymbolGenerator(mAllocator))
    142142, mEntryBlock(PabloBlock::Create(this)) {
    143     prepareKernelSignature();
     143    prepareStreamSetNameMap();
    144144    for (const Binding & ss : mStreamSetInputs) {
    145145        Var * param = new (mAllocator) Var(mSymbolTable->makeString(ss.name, iBuilder), ss.type, mAllocator, Var::KernelInputParameter);
Note: See TracChangeset for help on using the changeset viewer.