Changeset 6128


Ignore:
Timestamp:
Jul 8, 2018, 10:11:05 PM (4 months ago)
Author:
xwa163
Message:

lzparabix_grep: Improve the performance by merging LineFeed? stream into multiplexing alphabet

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/lzparabix/LZParabixGrepGenerator.cpp

    r6127 r6128  
    2323#include <re/collect_ccs.h>
    2424#include <re/replaceCC.h>
     25#include <re/re_seq.h>
     26#include <re/re_cc.h>
    2527
    2628#include <UCD/resolve_properties.h>
     
    173175    std::set<re::Name *> UnicodeProperties;
    174176
    175     const auto UnicodeSets = re::collectCCs(mREs[0], &cc::Unicode, std::set<re::Name *>({re::makeZeroWidth("\\b{g}")}));
     177    re::CC* linefeedCC = re::makeCC(0x0A);
     178
     179    re::Seq* seq = re::makeSeq();
     180    seq->push_back(mREs[0]);
     181    seq->push_back(std::move(linefeedCC));
     182
     183    const auto UnicodeSets = re::collectCCs(seq, &cc::Unicode, std::set<re::Name *>({re::makeZeroWidth("\\b{g}")}));
    176184    StreamSetBuffer * const MatchResults = mGrepDriver->addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(1, 1), baseBufferSize, 1);
    177 
    178185
    179186    this->generateBlockData(idb);
     
    182189    mpx = make_unique<cc::MultiplexedAlphabet>("mpx", UnicodeSets);
    183190    mREs[0] = transformCCs(mpx.get(), mREs[0]);
     191
    184192    std::vector<re::CC *> mpx_basis = mpx->getMultiplexedCCs();
    185193    auto numOfCharacterClasses = mpx_basis.size();
     
    190198    mGrepDriver->makeKernelCall(ccK, {LiteralBitStream}, {CharClasses});
    191199
    192     StreamSetBuffer * CompressedLineFeedStream = mPxDriver.addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(1, 1), baseBufferSize, 1);
    193     kernel::Kernel * linefeedK = mPxDriver.addKernelInstance<kernel::LineFeedKernelBuilder>(idb, Binding{idb->getStreamSetTy(8), "basis", FixedRate(), Principal()}, cc::BitNumbering::BigEndian);
    194     mPxDriver.makeKernelCall(linefeedK, {LiteralBitStream}, {CompressedLineFeedStream});
    195 
    196     auto ret = this->generateBitStreamDecompression(idb, {CharClasses, CompressedLineFeedStream});
    197 //    auto ret = this->generateAioBitStreamDecompressoin(idb, {CharClasses, CompressedLineFeedStream});
     200//    StreamSetBuffer * CompressedLineFeedStream = mPxDriver.addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(1, 1), baseBufferSize, 1);
     201//    kernel::Kernel * linefeedK = mPxDriver.addKernelInstance<kernel::LineFeedKernelBuilder>(idb, Binding{idb->getStreamSetTy(8), "basis", FixedRate(), Principal()}, cc::BitNumbering::BigEndian);
     202//    mPxDriver.makeKernelCall(linefeedK, {LiteralBitStream}, {CompressedLineFeedStream});
     203
     204//    auto ret = this->generateBitStreamDecompression(idb, {CharClasses, CompressedLineFeedStream});
     205    auto ret = this->generateBitStreamDecompression(idb, {CharClasses});
    198206
    199207    StreamSetBuffer * decompressedCharClasses = ret[0];
    200     StreamSetBuffer * LineBreakStream = ret[1];
     208//    StreamSetBuffer * LineBreakStream = ret[1];
    201209
    202210
     
    208216    mGrepDriver->makeKernelCall(icgrepK, {fakeMatchCopiedBits, decompressedCharClasses}, {MatchResults});
    209217    MatchResultsBufs[0] = MatchResults;
     218
     219    StreamSetBuffer * newLineBreak = mPxDriver.addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(1, 1), this->getInputBufferBlocks(idb));
     220    kernel::Kernel * lineFeedGrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, transformCCs(mpx.get(), linefeedCC), externalStreamNames, std::vector<cc::Alphabet *>{mpx.get()}, cc::BitNumbering::BigEndian, true);
     221    mGrepDriver->makeKernelCall(lineFeedGrepK, {fakeMatchCopiedBits, decompressedCharClasses}, {newLineBreak});
     222
    210223
    211224    StreamSetBuffer * MergedResults = MatchResultsBufs[0];
     
    220233        kernel::Kernel * matchedLinesK = mGrepDriver->addKernelInstance<kernel::MatchedLinesKernel>(idb);
    221234        Matches = mGrepDriver->addBuffer<StaticBuffer>(idb, idb->getStreamSetTy(1, 1), baseBufferSize);
    222         mGrepDriver->makeKernelCall(matchedLinesK, {OriginalMatches, LineBreakStream}, {Matches});
     235        mGrepDriver->makeKernelCall(matchedLinesK, {OriginalMatches, newLineBreak}, {Matches});
    223236    }
    224237
     
    231244    }
    232245
    233     return std::pair<StreamSetBuffer *, StreamSetBuffer *>(LineBreakStream, Matches);
     246    return std::pair<StreamSetBuffer *, StreamSetBuffer *>(newLineBreak, Matches);
    234247};
    235248
Note: See TracChangeset for help on using the changeset viewer.