Changeset 5854 for icGREP


Ignore:
Timestamp:
Jan 30, 2018, 2:27:53 PM (13 months ago)
Author:
cameron
Message:

UseDirectCC option for charclasses kernel

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/cc/cc_compiler.h

    r5847 r5854  
    2828   
    2929    virtual pablo::PabloAST * compileCC(const std::string & canonicalName, const re::CC *cc, pablo::PabloBuilder & builder) = 0;
     30   
     31    virtual ~CC_Compiler(){}
    3032
    3133protected:
     
    4951
    5052    pablo::PabloAST * compileCC(const std::string & name, const re::CC *cc, pablo::PabloBuilder & builder) override;
     53   
     54    ~Parabix_CC_Compiler() {}
    5155
    5256private:
     
    100104   
    101105    pablo::PabloAST * compileCC(const std::string & name, const re::CC *cc, pablo::PabloBuilder & builder) override;
    102        
     106   
     107    ~Direct_CC_Compiler() {}
     108   
    103109private:
    104110    pablo::PabloAST *               mCodeUnitStream;
  • icGREP/icgrep-devel/icgrep/kernels/charclasses.cpp

    r5847 r5854  
    5252}
    5353
    54 CharClassesSignature::CharClassesSignature(const std::vector<CC *> &ccs)
    55 : mSignature(signature(ccs)) {
    56 
     54CharClassesSignature::CharClassesSignature(const std::vector<CC *> &ccs, bool useDirectCC)
     55: mUseDirectCC(useDirectCC), mSignature((useDirectCC ? "d" : "p") + signature(ccs)) {
    5756}
    5857
    5958
    60 CharClassesKernel::CharClassesKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, std::vector<CC *> && ccs)
    61 : CharClassesSignature(ccs)
     59CharClassesKernel::CharClassesKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, std::vector<CC *> && ccs, bool useDirectCC)
     60: CharClassesSignature(ccs, useDirectCC)
    6261, PabloKernel(iBuilder,
    6362              "cc" + sha1sum(mSignature),
    64               {Binding{iBuilder->getStreamSetTy(8), "basis"}},
     63              {},
    6564              {Binding{iBuilder->getStreamSetTy(ccs.size(), 1), "charclasses"}})
    6665, mCCs(std::move(ccs)) {
    67 
     66    if (useDirectCC) {
     67        mStreamSetInputs.push_back({Binding{iBuilder->getStreamSetTy(1, 8), "byteData"}});
     68    }
     69    else {
     70        mStreamSetInputs.push_back({Binding{iBuilder->getStreamSetTy(8), "basis"}});
     71    }
    6872}
    6973
     
    7478void CharClassesKernel::generatePabloMethod() {
    7579    PabloBuilder pb(getEntryScope());
     80    CC_Compiler * ccc;
     81    if (mUseDirectCC) {
     82        ccc = new Direct_CC_Compiler(this, pb.createExtract(getInputStreamVar("byteData"), pb.getInteger(0)));
     83    }
     84    else {
     85        ccc = new Parabix_CC_Compiler(this, getInputStreamSet("basis"));
     86    }
    7687
    77     Parabix_CC_Compiler ccc(this, getInputStreamSet("basis"));
    7888    unsigned n = mCCs.size();
    7989
     
    8696    }
    8797
    88     UCD::UCDCompiler ucdCompiler(ccc);
     98    UCD::UCDCompiler ucdCompiler(*ccc);
    8999    if (LLVM_UNLIKELY(AlgorithmOptionIsSet(DisableIfHierarchy))) {
    90100        ucdCompiler.generateWithoutIfHierarchy(nameMap, pb);
     
    104114        }
    105115    }
     116    delete ccc;
    106117}
    107118
  • icGREP/icgrep-devel/icgrep/kernels/charclasses.h

    r5748 r5854  
    1414
    1515struct CharClassesSignature {
    16     CharClassesSignature(const std::vector<re::CC *> & ccs);
     16    CharClassesSignature(const std::vector<re::CC *> & ccs, bool useDirectCC);
    1717protected:
     18    const bool mUseDirectCC;
    1819    const std::string mSignature;
    1920};
     
    2122class CharClassesKernel : public CharClassesSignature, public pablo::PabloKernel {
    2223public:
    23     CharClassesKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, std::vector<re::CC *> && ccs);
     24    CharClassesKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, std::vector<re::CC *> && ccs, bool useDirectCC = false);
    2425    bool hasSignature() const override { return true; }
    2526    std::string makeSignature(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
     
    2930protected:
    3031    std::vector<re::CC *> mCCs;
     32   
    3133};
    3234
Note: See TracChangeset for help on using the changeset viewer.