Ignore:
Timestamp:
Mar 29, 2018, 11:24:15 AM (13 months ago)
Author:
cameron
Message:

Multithreaded simple RE mode initial check-in

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/grep/grep_engine.cpp

    r5932 r5934  
    2424#include <kernels/kernel_builder.h>
    2525#include <pablo/pablo_kernel.h>
     26#include <cc/alphabet.h>
    2627#include <re/re_cc.h>
    2728#include <re/re_name.h>
     
    3435#include <re/re_name_resolve.h>
    3536#include <re/re_name_gather.h>
    36 #include <re/re_collect_unicodesets.h>
     37#include <re/collect_ccs.h>
     38#include <re/replaceCC.h>
    3739#include <re/re_multiplex.h>
    3840#include <re/grapheme_clusters.h>
     
    6163static cl::opt<bool> CC_Multiplexing("CC-multiplexing", cl::desc("Enable CC multiplexing."), cl::init(false));
    6264static cl::opt<bool> PropertyKernels("enable-property-kernels", cl::desc("Enable Unicode property kernels."), cl::init(false));
    63 
     65static cl::opt<bool> MultithreadedSimpleRE("enable-simple-RE-kernels", cl::desc("Enable individual CC kernels for simple REs."), cl::init(false));
    6466const unsigned DefaultByteCClimit = 6;
    6567
     
    267269    }
    268270    if (isSimple && byteTestsWithinLimit(mREs[0], ByteCClimit)) {
     271        std::vector<std::string> externalStreamNames;
     272        std::vector<StreamSetBuffer *> icgrepInputSets = {ByteStream};
     273        if (MultithreadedSimpleRE) {
     274            auto CCs = re::collectCCs(mREs[0], &cc::Byte);
     275            for (auto cc : CCs) {
     276                auto ccName = makeName(cc);
     277                mREs[0] = re::replaceCC(mREs[0], cc, ccName);
     278                std::string ccNameStr = ccName->getFullName();
     279                errs () << "Replacing: " << ccNameStr << "\n";
     280                StreamSetBuffer * ccStream = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), baseBufferSize);
     281                kernel::Kernel * ccK = mGrepDriver->addKernelInstance<kernel::DirectCharacterClassKernelBuilder>(idb, ccNameStr, std::vector<re::CC *>{cc}, 1);
     282                mGrepDriver->makeKernelCall(ccK, {ByteStream}, {ccStream});
     283                externalStreamNames.push_back(ccNameStr);
     284                icgrepInputSets.push_back(ccStream);
     285            }
     286        }
    269287        StreamSetBuffer * MatchResults = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), baseBufferSize);
    270         kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ByteGrepKernel>(idb, mREs[0]);
    271         mGrepDriver->makeKernelCall(icgrepK, {ByteStream}, {MatchResults});
     288        kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ByteGrepKernel>(idb, mREs[0], externalStreamNames);
     289        mGrepDriver->makeKernelCall(icgrepK, icgrepInputSets, {MatchResults});
    272290        MatchResultsBufs[0] = MatchResults;
    273291        kernel::Kernel * breakK = mGrepDriver->addKernelInstance<kernel::DirectCharacterClassKernelBuilder>(idb, "breakCC", std::vector<re::CC *>{mBreakCC}, 1);
     
    353371            }
    354372            if (CC_Multiplexing) {
    355                 const auto UnicodeSets = re::collectUnicodeSets(mREs[i], std::set<re::Name *>({re::makeZeroWidth("\\b{g}")}));
     373                const auto UnicodeSets = re::collectCCs(mREs[i], &cc::Unicode, std::set<re::Name *>({re::makeZeroWidth("\\b{g}")}));
    356374                StreamSetBuffer * const MatchResults = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), baseBufferSize);
    357375                if (UnicodeSets.size() <= 1) {
Note: See TracChangeset for help on using the changeset viewer.