Ignore:
Timestamp:
Mar 7, 2017, 2:09:25 PM (2 years ago)
Author:
xuedongx
Message:

delete the linebreak computation in icgrep

File:
1 edited

Legend:

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

    r5353 r5357  
    1717#include <UCD/resolve_properties.h>
    1818#include <kernels/cc_kernel.h>
    19 #include <kernels/unicode_linebreak_kernel.h>
     19#include <kernels/linebreak_kernel.h>
    2020#include <kernels/streams_merge.h>
    2121#include <kernels/match_count.h>
     
    4040#include <util/aligned_allocator.h>
    4141
    42 #define UNICODE_LINE_BREAK (!re::AlgorithmOptionIsSet(re::DisableUnicodeLineBreak))
    4342
    4443using namespace parabix;
     
    295294    kernel::S2PKernel  s2pk(iBuilder);
    296295    s2pk.generateKernel({&ByteStream}, {&BasisBits});
    297 
    298     std::vector<re::CC *> LF;
    299     LF.push_back(re::makeCC(0x0A));
    300    
    301     kernel::UnicodeLineBreakKernelBuilder unicodelbK(iBuilder, "unicodelinebreak", encodingBits);
    302     kernel::ParabixCharacterClassKernelBuilder linefeedK(iBuilder, "linefeed", LF, encodingBits);
    303 
     296   
    304297    std::vector<pablo::PabloKernel *> icgrepKs;
    305298    std::vector<StreamSetBuffer *> MatchResultsBufs;
    306299
    307300    for(unsigned i=0; i<REs.size(); i++){   
    308         pablo::PabloKernel * icgrepK = new pablo::PabloKernel(iBuilder, "icgrep"+std::to_string(i), {Binding{iBuilder->getStreamSetTy(8), "basis"}});
     301        pablo::PabloKernel * icgrepK = new pablo::PabloKernel(iBuilder, "icgrep"+std::to_string(i), {Binding{iBuilder->getStreamSetTy(8), "basis"}, Binding{iBuilder->getStreamSetTy(1, 1), "linebreak"}});
    309302        re::re2pablo_compiler(icgrepK, re::regular_expression_passes(REs[i]), false);
    310303        pablo_function_passes(icgrepK);
     
    325318    streamsMergeK.generateKernel(MatchResultsBufs, {&mergedResults});
    326319
     320    kernel::LineBreakKernelBuilder linebreakK(iBuilder, "lb", encodingBits);
     321    CircularBuffer LineBreakStream(iBuilder, iBuilder->getStreamSetTy(1, 1), segmentSize * bufferSegments);
     322    LineBreakStream.allocateBuffer();
     323    linebreakK.generateKernel({&BasisBits}, {&LineBreakStream});
     324   
     325    KernelList.push_back(&linebreakK);
    327326    for(unsigned i=0; i<REs.size(); i++){
    328         icgrepKs[i]->generateKernel({&BasisBits}, {MatchResultsBufs[i]});
     327        icgrepKs[i]->generateKernel({&BasisBits, &LineBreakStream}, {MatchResultsBufs[i]});
    329328        KernelList.push_back(icgrepKs[i]);
    330329    }
     
    348347    }
    349348    else{
    350         pablo::PabloKernel *linebreakK = UNICODE_LINE_BREAK ? &cast<pablo::PabloKernel>(unicodelbK) :  &cast<pablo::PabloKernel>(linefeedK);
    351         CircularBuffer LineBreakStream(iBuilder, iBuilder->getStreamSetTy(1, 1), segmentSize * bufferSegments);
    352         LineBreakStream.allocateBuffer();
    353         linebreakK->generateKernel({&BasisBits}, {&LineBreakStream});
    354 
    355349        kernel::ScanMatchKernel scanMatchK(iBuilder, mGrepType);
    356350        scanMatchK.generateKernel({&mergedResults, &LineBreakStream}, {});               
    357351        scanMatchK.setInitialArguments({iBuilder->CreateBitCast(inputStream, int8PtrTy), fileSize, fileIdx});
    358352
    359         KernelList.push_back(linebreakK);
    360353        KernelList.push_back(&scanMatchK);
    361354
     
    491484    s2pk.generateKernel({&ByteStream}, {&BasisBits});
    492485   
    493     std::vector<re::CC *> LF;
    494     LF.push_back(re::makeCC(0x0A));
    495    
    496     kernel::UnicodeLineBreakKernelBuilder unicodelbK(iBuilder, "unicodelinebreak", encodingBits);
    497     kernel::ParabixCharacterClassKernelBuilder linefeedK(iBuilder, "linefeed", LF, encodingBits);
    498 
    499     pablo::PabloKernel *linebreakK = UNICODE_LINE_BREAK ? &cast<pablo::PabloKernel>(unicodelbK) :  &cast<pablo::PabloKernel>(linefeedK);
     486    kernel::LineBreakKernelBuilder linebreakK(iBuilder, "lb", encodingBits);
    500487    CircularBuffer LineBreakStream(iBuilder, iBuilder->getStreamSetTy(1, 1), segmentSize * bufferSegments);
     488
     489    linebreakK.generateKernel({&BasisBits}, {&LineBreakStream});
    501490    LineBreakStream.allocateBuffer();
    502     linebreakK->generateKernel({&BasisBits}, {&LineBreakStream});
    503 
    504     pablo::PabloKernel icgrepK(iBuilder, "icgrep", {Binding{iBuilder->getStreamSetTy(8), "basis"}});
     491
     492    pablo::PabloKernel icgrepK(iBuilder, "icgrep", {Binding{iBuilder->getStreamSetTy(8), "basis"}, Binding{iBuilder->getStreamSetTy(1, 1), "linebreak"}});
    505493    re::re2pablo_compiler(&icgrepK, re::regular_expression_passes(re_ast), CountOnly);
    506494    pablo_function_passes(&icgrepK);
     
    510498
    511499    if (CountOnly) {
    512         icgrepK.generateKernel({&BasisBits}, {});
     500        icgrepK.generateKernel({&BasisBits, &LineBreakStream}, {});
    513501        if (pipelineParallel) {
    514             generatePipelineParallel(iBuilder, {&mmapK, &s2pk, &icgrepK});
     502            generatePipelineParallel(iBuilder, {&mmapK, &s2pk, &linebreakK, &icgrepK});
    515503        } else if (segmentPipelineParallel) {
    516             generateSegmentParallelPipeline(iBuilder, {&mmapK, &s2pk, &icgrepK});
     504            generateSegmentParallelPipeline(iBuilder, {&mmapK, &s2pk, &linebreakK, &icgrepK});
    517505        } else {
    518             generatePipelineLoop(iBuilder, {&mmapK, &s2pk, &icgrepK});
     506            generatePipelineLoop(iBuilder, {&mmapK, &s2pk, &linebreakK, &icgrepK});
    519507        }
    520508        iBuilder->CreateRet(icgrepK.createGetAccumulatorCall(icgrepK.getInstance(), "matchedLineCount"));
     
    525513            MatchResults.setStreamSetBuffer(outputStream, fileSize);
    526514
    527             icgrepK.generateKernel({&BasisBits},  {&MatchResults});
    528             generatePipelineLoop(iBuilder, {&mmapK, &s2pk, &icgrepK});
     515            icgrepK.generateKernel({&BasisBits, &LineBreakStream},  {&MatchResults});
     516            generatePipelineLoop(iBuilder, {&mmapK, &s2pk, &linebreakK, &icgrepK});
    529517
    530518        }
     
    534522            MatchResults.allocateBuffer();
    535523
    536             icgrepK.generateKernel({&BasisBits}, {&MatchResults});
     524            icgrepK.generateKernel({&BasisBits, &LineBreakStream}, {&MatchResults});
    537525
    538526            kernel::ScanMatchKernel scanMatchK(iBuilder, mGrepType);
     
    541529           
    542530            if (pipelineParallel) {
    543                 generatePipelineParallel(iBuilder, {&mmapK, &s2pk, &icgrepK, linebreakK, &scanMatchK});
     531                generatePipelineParallel(iBuilder, {&mmapK, &s2pk, &linebreakK, &icgrepK, &scanMatchK});
    544532            } else if (segmentPipelineParallel) {
    545                 generateSegmentParallelPipeline(iBuilder, {&mmapK, &s2pk, &icgrepK, linebreakK, &scanMatchK});
     533                generateSegmentParallelPipeline(iBuilder, {&mmapK, &s2pk, &linebreakK, &icgrepK, &scanMatchK});
    546534            } else {
    547                 generatePipelineLoop(iBuilder, {&mmapK, &s2pk, &icgrepK, linebreakK, &scanMatchK});
     535                generatePipelineLoop(iBuilder, {&mmapK, &s2pk, &linebreakK, &icgrepK, &scanMatchK});
    548536            }
    549537        }
Note: See TracChangeset for help on using the changeset viewer.