Changeset 5937 for icGREP


Ignore:
Timestamp:
Mar 30, 2018, 1:44:36 PM (12 months ago)
Author:
cameron
Message:

Simple-RE-kernel optimizations

File:
1 edited

Legend:

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

    r5935 r5937  
    271271        std::vector<std::string> externalStreamNames;
    272272        std::vector<StreamSetBuffer *> icgrepInputSets = {ByteStream};
    273         if (MultithreadedSimpleRE) {
    274             auto CCs = re::collectCCs(mREs[0], &cc::Byte);
     273        if (MultithreadedSimpleRE && hasTriCCwithinLimit(mREs[0], ByteCClimit, prefixRE, suffixRE)) {
     274            auto CCs = re::collectCCs(prefixRE, &cc::Byte);
    275275            for (auto cc : CCs) {
    276276                auto ccName = makeName(cc);
     
    291291        mGrepDriver->makeKernelCall(breakK, {ByteStream}, {LineBreakStream});
    292292    } else if (isSimple && hasTriCCwithinLimit(mREs[0], ByteCClimit, prefixRE, suffixRE)) {
     293        std::vector<std::string> externalStreamNames;
     294        std::vector<StreamSetBuffer *> icgrepInputSets = {ByteStream};
     295        if (MultithreadedSimpleRE) {
     296            auto CCs = re::collectCCs(prefixRE, &cc::Byte);
     297            for (auto cc : CCs) {
     298                auto ccName = makeName(cc);
     299                mREs[0] = re::replaceCC(mREs[0], cc, ccName);
     300                std::string ccNameStr = ccName->getFullName();
     301                StreamSetBuffer * ccStream = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), baseBufferSize);
     302                kernel::Kernel * ccK = mGrepDriver->addKernelInstance<kernel::DirectCharacterClassKernelBuilder>(idb, ccNameStr, std::vector<re::CC *>{cc});
     303                mGrepDriver->makeKernelCall(ccK, {ByteStream}, {ccStream});
     304                externalStreamNames.push_back(ccNameStr);
     305                icgrepInputSets.push_back(ccStream);
     306            }
     307        }
    293308        StreamSetBuffer * MatchResults = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), baseBufferSize);
    294         kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ByteBitGrepKernel>(idb, prefixRE, suffixRE);
    295         mGrepDriver->makeKernelCall(icgrepK, {ByteStream}, {MatchResults});
     309        kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ByteBitGrepKernel>(idb, prefixRE, suffixRE, externalStreamNames);
     310        mGrepDriver->makeKernelCall(icgrepK, icgrepInputSets, {MatchResults});
    296311        MatchResultsBufs[0] = MatchResults;
    297312        kernel::Kernel * breakK = mGrepDriver->addKernelInstance<kernel::DirectCharacterClassKernelBuilder>(idb, "breakCC", std::vector<re::CC *>{mBreakCC});
Note: See TracChangeset for help on using the changeset viewer.