Changeset 6127


Ignore:
Timestamp:
Jul 7, 2018, 10:21:29 PM (4 months ago)
Author:
xwa163
Message:
  1. Improve RE_Compiler for multiplexing
  2. Use faster approach for LineBreakStream? generating in LZParabix_grep
Location:
icGREP/icgrep-devel/icgrep
Files:
8 edited

Legend:

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

    r6089 r6127  
    2727    }
    2828
    29 Parabix_CC_Compiler::Parabix_CC_Compiler(pablo::PabloBlock * scope, std::vector<pablo::PabloAST *> basisBitSet, cc::BitNumbering basisSetNumbering)
     29Parabix_CC_Compiler::Parabix_CC_Compiler(pablo::PabloBlock * scope, std::vector<pablo::PabloAST *> basisBitSet, cc::BitNumbering basisSetNumbering, bool fakeBasisBits)
    3030: CC_Compiler(scope)
    3131, mEncodingBits(basisBitSet.size())
    3232, mBasisSetNumbering(basisSetNumbering)
    33 , mBasisBit(basisBitSet) {
     33, mBasisBit(basisBitSet)
     34, mFakeBasisBits(fakeBasisBits) {
    3435    mEncodingMask = (static_cast<unsigned>(1) << mEncodingBits) - static_cast<unsigned>(1);
    3536}
     
    7879                hi |= (mEncodingMask ^ (mEncodingMask - 1));
    7980                PabloAST * expr = make_range(lo, hi, pb);
    80                 PabloAST * bit0 = getBasisVar(0);
     81                PabloAST * bit0 = getBasisVar(0, pb);
    8182                if ((lo & 1) == 0) {
    8283                    bit0 = pb.createNot(bit0);
     
    105106            PabloAST * term = pb.createOnes();
    106107            if (selected_bits & test_bit) {
    107                 term = getBasisVar(i);
     108                term = getBasisVar(i, pb);
    108109                if ((pattern & test_bit) == 0) {
    109110                    term = pb.createNot(term);
     
    162163    PabloAST* hi_test = LE_Range(diff_count - 1, n2 & mask1, pb);
    163164
    164     return pb.createAnd(common, pb.createSel(getBasisVar(diff_count - 1), hi_test, lo_test));
     165    return pb.createAnd(common, pb.createSel(getBasisVar(diff_count - 1, pb), hi_test, lo_test));
    165166}
    166167
     
    171172    }
    172173    else if (((N % 2) == 0) && ((n >> (N - 2)) == 0)) {
    173         return pb.createOr(pb.createOr(getBasisVar(N - 1), getBasisVar(N - 2)), GE_Range(N - 2, n, pb));
     174        return pb.createOr(pb.createOr(getBasisVar(N - 1, pb), getBasisVar(N - 2, pb)), GE_Range(N - 2, n, pb));
    174175    }
    175176    else if (((N % 2) == 0) && ((n >> (N - 2)) == 3)) {
    176         return pb.createAnd(pb.createAnd(getBasisVar(N - 1), getBasisVar(N - 2)), GE_Range(N - 2, n - (3 << (N - 2)), pb));
     177        return pb.createAnd(pb.createAnd(getBasisVar(N - 1, pb), getBasisVar(N - 2, pb)), GE_Range(N - 2, n - (3 << (N - 2)), pb));
    177178    }
    178179    else if (N >= 1)
     
    188189              the value of GE_range(N-1), lo_range) is required.
    189190            */
    190             return pb.createOr(getBasisVar(N - 1), lo_range);
     191            return pb.createOr(getBasisVar(N - 1, pb), lo_range);
    191192        }
    192193        else
     
    196197              in the target for >= and GE_range(N-1, lo_bits) must also be true.
    197198            */
    198             return pb.createAnd(getBasisVar(N - 1), lo_range);
     199            return pb.createAnd(getBasisVar(N - 1, pb), lo_range);
    199200        }
    200201    }
     
    225226}
    226227
    227 inline PabloAST * Parabix_CC_Compiler::getBasisVar(const unsigned i) const {
    228     assert (i < mEncodingBits);
    229     if (mBasisSetNumbering == cc::BitNumbering::BigEndian)
    230         return mBasisBit[mEncodingBits - i - 1];
    231     else return mBasisBit[i];
     228template<typename PabloBlockOrBuilder>
     229inline PabloAST * Parabix_CC_Compiler::getBasisVar(const unsigned i, PabloBlockOrBuilder & pb) const {
     230    if (mFakeBasisBits) {
     231        return pb.createZeroes();
     232    } else {
     233        assert (i < mEncodingBits);
     234        if (mBasisSetNumbering == cc::BitNumbering::BigEndian)
     235            return mBasisBit[mEncodingBits - i - 1];
     236        else return mBasisBit[i];
     237    }
    232238}
    233239
  • icGREP/icgrep-devel/icgrep/cc/cc_compiler.h

    r6089 r6127  
    4141public:
    4242   
    43     Parabix_CC_Compiler(pablo::PabloBlock * scope, std::vector<pablo::PabloAST *> basisBitSet, cc::BitNumbering b = BitNumbering::LittleEndian);
     43    Parabix_CC_Compiler(pablo::PabloBlock * scope, std::vector<pablo::PabloAST *> basisBitSet, cc::BitNumbering b = BitNumbering::LittleEndian, bool fakeBasisBits = false);
    4444   
    4545    pablo::PabloAST * compileCC(const re::CC *cc) override;
     
    5656
    5757private:
    58     pablo::PabloAST * getBasisVar(const unsigned n) const;
     58    template<typename PabloBlockOrBuilder>
     59    pablo::PabloAST * getBasisVar(const unsigned n, PabloBlockOrBuilder & pb) const;
    5960    template<typename PabloBlockOrBuilder>
    6061    pablo::PabloAST * bit_pattern_expr(const unsigned pattern, unsigned selected_bits, PabloBlockOrBuilder & pb);
     
    7677    std::vector<pablo::PabloAST *>  mBasisBit;
    7778    unsigned                        mEncodingMask;
     79    bool mFakeBasisBits;
    7880};
    7981
  • icGREP/icgrep-devel/icgrep/grep/grep_engine.cpp

    r6047 r6127  
    414414    //                kernel::Kernel * ccK = mGrepDriver->addKernelInstance<kernel::CharClassesKernel>(idb, std::move(mpx_basis), true);
    415415    //                mGrepDriver->makeKernelCall(ccK, {ByteStream}, {CharClasses});
    416                     kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, mREs[i], externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()});
     416                    kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, mREs[i], externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()}, cc::BitNumbering::LittleEndian, true);
    417417                    icgrepInputSets.push_back(CharClasses);
    418418                    mGrepDriver->makeKernelCall(icgrepK, icgrepInputSets, {MatchResults});
  • icGREP/icgrep-devel/icgrep/kernels/grep_kernel.cpp

    r6119 r6127  
    250250}
    251251
    252 ICGrepKernel::ICGrepKernel(const std::unique_ptr<kernel::KernelBuilder> & b, RE * const re, std::vector<std::string> externals, std::vector<cc::Alphabet *> alphabets, cc::BitNumbering basisSetNumbering)
     252ICGrepKernel::ICGrepKernel(const std::unique_ptr<kernel::KernelBuilder> & b, RE * const re, std::vector<std::string> externals, std::vector<cc::Alphabet *> alphabets, cc::BitNumbering basisSetNumbering, bool fakeBasisBits)
    253253: ICGrepSignature(re)
    254254, PabloKernel(b, "ic" + sha1sum(mSignature),
     
    259259, mExternals(externals)
    260260, mAlphabets(alphabets)
    261 , mBasisSetNumbering(basisSetNumbering){
     261, mBasisSetNumbering(basisSetNumbering)
     262, mFakeBasisBits(fakeBasisBits){
    262263}
    263264
     
    268269void ICGrepKernel::generatePabloMethod() {
    269270    PabloBuilder pb(getEntryScope());
    270     cc::Parabix_CC_Compiler ccc(getEntryScope(), getInputStreamSet("basis"), mBasisSetNumbering);
    271     RE_Compiler re_compiler(getEntryScope(), ccc, mBasisSetNumbering);
     271    cc::Parabix_CC_Compiler ccc(getEntryScope(), getInputStreamSet("basis"), mBasisSetNumbering, mFakeBasisBits);
     272    RE_Compiler re_compiler(getEntryScope(), ccc, mBasisSetNumbering, mFakeBasisBits);
    272273    for (auto & e : mExternals) {
    273274        re_compiler.addPrecompiled(e, pb.createExtract(getInputStreamVar(e), pb.getInteger(0)));
  • icGREP/icgrep-devel/icgrep/kernels/grep_kernel.h

    r6119 r6127  
    6262class ICGrepKernel : public ICGrepSignature, public pablo::PabloKernel {
    6363public:
    64     ICGrepKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, re::RE * const re_ast, std::vector<std::string> externals, std::vector<cc::Alphabet *> alphabets = {}, cc::BitNumbering basisSetNumbering = cc::BitNumbering::LittleEndian);
     64    ICGrepKernel(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, re::RE * const re_ast, std::vector<std::string> externals, std::vector<cc::Alphabet *> alphabets = {}, cc::BitNumbering basisSetNumbering = cc::BitNumbering::LittleEndian, bool fakeBasisBits = false);
    6565    std::string makeSignature(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) override;
    6666    bool isCachable() const override { return true; }
     
    7070    std::vector<cc::Alphabet *> mAlphabets;
    7171    cc::BitNumbering mBasisSetNumbering;
     72    bool mFakeBasisBits;
    7273};
    7374
  • icGREP/icgrep-devel/icgrep/lzparabix/LZParabixGrepGenerator.cpp

    r6124 r6127  
    205205    mPxDriver.makeKernelCall(fakeStreamGeneratorK, {decompressedCharClasses}, {fakeMatchCopiedBits});
    206206
    207     kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, mREs[0], externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()}, cc::BitNumbering::BigEndian);
     207    kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, mREs[0], externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()}, cc::BitNumbering::BigEndian, true);
    208208    mGrepDriver->makeKernelCall(icgrepK, {fakeMatchCopiedBits, decompressedCharClasses}, {MatchResults});
    209209    MatchResultsBufs[0] = MatchResults;
     
    254254    this->generateBlockData(idb);
    255255    StreamSetBuffer * const LiteralBitStream = this->extractLiteralBitStream(idb);
    256     auto compressedLineBreakStream = this->linefeedStreamFromDecompressedBits(LiteralBitStream);
    257 
    258 
    259     auto ret = this->generateBitStreamDecompression(idb, {LiteralBitStream, compressedLineBreakStream});
     256//    auto compressedLineBreakStream = this->linefeedStreamFromDecompressedBits(LiteralBitStream);
     257
     258
     259    auto ret = this->generateBitStreamDecompression(idb, {LiteralBitStream/*, compressedLineBreakStream*/});
    260260    StreamSetBuffer * decompressedBasisBits = ret[0];
    261     StreamSetBuffer * LineBreakStream = ret[1];
     261//    StreamSetBuffer * LineBreakStream = ret[1];
    262262
    263263//    StreamSetBuffer * decompressedBasisBits = this->generateAioBitStreamDecompressoin(idb, {mCompressedBasisBits})[0];
    264 //    StreamSetBuffer * LineBreakStream = this->linefeedStreamFromDecompressedBits(decompressedBasisBits);
     264    StreamSetBuffer * LineBreakStream = this->linefeedStreamFromDecompressedBits(decompressedBasisBits);
    265265
    266266    std::map<std::string, StreamSetBuffer *> propertyStream;
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r6119 r6127  
    4949void RE_Compiler::addAlphabet(cc::Alphabet * a, std::vector<pablo::PabloAST *> basis_set) {
    5050    mAlphabets.push_back(a);
    51     mAlphabetCompilers.push_back(make_unique<cc::Parabix_CC_Compiler>(mEntryScope, basis_set, mBasisSetNumbering));
     51    mAlphabetCompilers.push_back(make_unique<cc::Parabix_CC_Compiler>(mEntryScope, basis_set, mBasisSetNumbering, false));
    5252}
    5353
     
    628628}
    629629
    630 RE_Compiler::RE_Compiler(PabloBlock * scope, cc::CC_Compiler & ccCompiler, cc::BitNumbering basisSetNumbering)
     630RE_Compiler::RE_Compiler(PabloBlock * scope, cc::CC_Compiler & ccCompiler, cc::BitNumbering basisSetNumbering, bool fakeBasisBits)
    631631: mEntryScope(scope)
    632632, mCCCompiler(ccCompiler)
     
    635635, mStarDepth(0)
    636636, mCompiledName(&mBaseMap)
    637 , mBasisSetNumbering(basisSetNumbering){
     637, mBasisSetNumbering(basisSetNumbering)
     638, mFakeBasisBits(fakeBasisBits) {
    638639    PabloBuilder pb(mEntryScope);
    639640    mLineBreak = pb.createZeroes();  // default so "^/$" matches start/end of text only
  • icGREP/icgrep-devel/icgrep/re/re_compiler.h

    r6119 r6127  
    5252    };
    5353
    54     RE_Compiler(pablo::PabloBlock * scope, cc::CC_Compiler & ccCompiler, cc::BitNumbering basisSetNumbering = cc::BitNumbering::LittleEndian);
     54    RE_Compiler(pablo::PabloBlock * scope, cc::CC_Compiler & ccCompiler, cc::BitNumbering basisSetNumbering = cc::BitNumbering::LittleEndian, bool mFakeBasisBits = false);
    5555   
    5656    //
     
    149149    std::map<std::string, pablo::PabloAST *>        mExternalNameMap;
    150150    cc::BitNumbering mBasisSetNumbering;
     151    bool mFakeBasisBits;
    151152};
    152153
Note: See TracChangeset for help on using the changeset viewer.