Ignore:
Timestamp:
Dec 31, 2017, 7:22:14 PM (13 months ago)
Author:
cameron
Message:

Supporting multiple alphabets in RE compilation - initial check-in

File:
1 edited

Legend:

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

    r5812 r5816  
    128128        REs[i] = resolveModesAndExternalSymbols(REs[i]);
    129129        REs[i] = excludeUnicodeLineBreak(REs[i]);
    130 #define USE_MULTIPLEX_CC
     130//#define USE_MULTIPLEX_CC
    131131#ifdef USE_MULTIPLEX_CC
    132        
    133132        REs[i] = multiplexing_prepasses(REs[i]);
    134133        const std::vector<const re::CC *> UnicodeSets = re::collectUnicodeSets(REs[i]);
    135         mpx = make_unique<MultiplexedAlphabet>("mpx", UnicodeSets);
    136         REs[i] = transformCCs(mpx.get(), REs[i]);
    137         //llvm::errs() << Printer_RE::PrintRE(REs[i]) << '\n';
    138         std::vector<re::CC *> mpx_basis = mpx->getMultiplexedCCs();
    139         auto numOfCharacterClasses = mpx_basis.size();
    140         StreamSetBuffer * CharClasses = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(numOfCharacterClasses), segmentSize * bufferSegments);
    141         kernel::Kernel * ccK = mGrepDriver->addKernelInstance<kernel::CharClassesKernel>(idb, std::move(mpx_basis));
    142         mGrepDriver->makeKernelCall(ccK, {BasisBits}, {CharClasses});
    143         StreamSetBuffer * MatchResults = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments);
    144         kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, REs[i], numOfCharacterClasses);
    145         mGrepDriver->makeKernelCall(icgrepK, {CharClasses, LineBreakStream, CRLFStream, RequiredStreams}, {MatchResults});
     134        if (UnicodeSets.size() <= 1) {
     135            StreamSetBuffer * MatchResults = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments);
     136            kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, REs[i]);
     137            mGrepDriver->makeKernelCall(icgrepK, {BasisBits, LineBreakStream, CRLFStream, RequiredStreams}, {MatchResults});
     138            MatchResultsBufs[i] = MatchResults;
     139        }
     140        else {
     141            mpx = make_unique<MultiplexedAlphabet>("mpx", UnicodeSets);
     142            REs[i] = transformCCs(mpx.get(), REs[i]);
     143            std::vector<re::CC *> mpx_basis = mpx->getMultiplexedCCs();
     144            auto numOfCharacterClasses = mpx_basis.size();
     145            StreamSetBuffer * CharClasses = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(numOfCharacterClasses), segmentSize * bufferSegments);
     146            kernel::Kernel * ccK = mGrepDriver->addKernelInstance<kernel::CharClassesKernel>(idb, std::move(mpx_basis));
     147            mGrepDriver->makeKernelCall(ccK, {BasisBits}, {CharClasses});
     148            StreamSetBuffer * MatchResults = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments);
     149            kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, REs[i], std::vector<cc::Alphabet *>{mpx.get()});
     150            mGrepDriver->makeKernelCall(icgrepK, {BasisBits, LineBreakStream, CRLFStream, RequiredStreams, CharClasses}, {MatchResults});
     151            MatchResultsBufs[i] = MatchResults;
     152        }
    146153#else
    147154        REs[i] = regular_expression_passes(REs[i]);
     
    149156        kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, REs[i]);
    150157        mGrepDriver->makeKernelCall(icgrepK, {BasisBits, LineBreakStream, CRLFStream, RequiredStreams}, {MatchResults});
     158        MatchResultsBufs[i] = MatchResults;
    151159#endif
    152         MatchResultsBufs[i] = MatchResults;
    153160    }
    154161    StreamSetBuffer * MergedResults = MatchResultsBufs[0];
Note: See TracChangeset for help on using the changeset viewer.