Changeset 5343 for icGREP/icgrep-devel


Ignore:
Timestamp:
Feb 23, 2017, 2:44:49 PM (2 years ago)
Author:
lindanl
Message:

Add count only option for separate compilation of multiple kernels.

Location:
icGREP/icgrep-devel/icgrep
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/CMakeLists.txt

    r5338 r5343  
    7676target_link_libraries (RegExpCompiler RegExpADT)
    7777
    78 add_executable(icgrep icgrep.cpp toolchain.cpp grep_engine.cpp kernels/scanmatchgen.cpp kernels/cc_kernel.cpp kernels/cc_scan_kernel.cpp kernels/unicode_linebreak_kernel.cpp kernels/streams_merge.cpp)
     78add_executable(icgrep icgrep.cpp toolchain.cpp grep_engine.cpp kernels/scanmatchgen.cpp kernels/cc_kernel.cpp kernels/cc_scan_kernel.cpp kernels/unicode_linebreak_kernel.cpp kernels/streams_merge.cpp kernels/match_count.cpp)
    7979add_executable(u8u16 u8u16.cpp toolchain.cpp)
    8080add_executable(base64 base64.cpp kernels/radix64.cpp toolchain.cpp)
  • icGREP/icgrep-devel/icgrep/grep_engine.cpp

    r5341 r5343  
    1919#include <kernels/unicode_linebreak_kernel.h>
    2020#include <kernels/streams_merge.h>
     21#include <kernels/match_count.h>
    2122#include <kernels/pipeline.h>
    2223#include <kernels/mmap_kernel.h>
     
    300301    kernel::ParabixCharacterClassKernelBuilder linefeedK(iBuilder, "linefeed", LF, encodingBits);
    301302
    302     pablo::PabloKernel *linebreakK = UNICODE_LINE_BREAK ? &cast<pablo::PabloKernel>(unicodelbK) :  &cast<pablo::PabloKernel>(linefeedK);
    303     CircularBuffer LineBreakStream(iBuilder, iBuilder->getStreamSetTy(1, 1), segmentSize * bufferSegments);
    304     LineBreakStream.allocateBuffer();
    305     linebreakK->generateKernel({&BasisBits}, {&LineBreakStream});
    306 
    307303    std::vector<pablo::PabloKernel *> icgrepKs;
    308304    std::vector<StreamSetBuffer *> MatchResultsBufs;
     
    310306    for(unsigned i=0; i<REs.size(); i++){   
    311307        pablo::PabloKernel * icgrepK = new pablo::PabloKernel(iBuilder, "icgrep"+std::to_string(i), {Binding{iBuilder->getStreamSetTy(8), "basis"}});
    312         re::re2pablo_compiler(icgrepK, re::regular_expression_passes(REs[i]), CountOnly);
     308        re::re2pablo_compiler(icgrepK, re::regular_expression_passes(REs[i]), false);
    313309        pablo_function_passes(icgrepK);
    314310        icgrepKs.push_back(icgrepK);
     
    320316    std::vector<kernel::KernelBuilder *> KernelList;
    321317    KernelList.push_back(&mmapK);
    322     KernelList.push_back(&s2pk);   
    323     KernelList.push_back(linebreakK);
     318    KernelList.push_back(&s2pk);
    324319
    325320    CircularBuffer mergedResults(iBuilder, iBuilder->getStreamSetTy(1, 1), segmentSize * bufferSegments);
     
    328323    kernel::StreamsMerge streamsMergeK(iBuilder, 1, REs.size());
    329324    streamsMergeK.generateKernel(MatchResultsBufs, {&mergedResults});
    330 
    331     kernel::ScanMatchKernel scanMatchK(iBuilder, mGrepType);
    332     scanMatchK.generateKernel({&mergedResults, &LineBreakStream}, {});               
    333     scanMatchK.setInitialArguments({iBuilder->CreateBitCast(inputStream, int8PtrTy), fileSize, fileIdx});
    334325
    335326    for(unsigned i=0; i<REs.size(); i++){
     
    338329    }
    339330    KernelList.push_back(&streamsMergeK);
    340     KernelList.push_back(&scanMatchK);
    341    
    342     if (pipelineParallel){
    343         generatePipelineParallel(iBuilder, KernelList);
    344     } else if (segmentPipelineParallel){
    345         generateSegmentParallelPipeline(iBuilder, KernelList);
    346     }  else{
    347         generatePipelineLoop(iBuilder, KernelList);
    348     }
    349    
    350     iBuilder->CreateRetVoid();
     331
     332    if (CountOnly) {
     333        kernel::MatchCount matchCountK(iBuilder);
     334        matchCountK.generateKernel({&mergedResults}, {}); 
     335
     336        KernelList.push_back(&matchCountK); 
     337
     338        if (pipelineParallel){
     339            generatePipelineParallel(iBuilder, KernelList);
     340        } else if (segmentPipelineParallel){
     341            generateSegmentParallelPipeline(iBuilder, KernelList);
     342        }  else{
     343            generatePipelineLoop(iBuilder, KernelList);
     344        }
     345        iBuilder->CreateRet(matchCountK.getScalarField(matchCountK.getInstance(), "matchedLineCount"));
     346
     347    }
     348    else{
     349        pablo::PabloKernel *linebreakK = UNICODE_LINE_BREAK ? &cast<pablo::PabloKernel>(unicodelbK) :  &cast<pablo::PabloKernel>(linefeedK);
     350        CircularBuffer LineBreakStream(iBuilder, iBuilder->getStreamSetTy(1, 1), segmentSize * bufferSegments);
     351        LineBreakStream.allocateBuffer();
     352        linebreakK->generateKernel({&BasisBits}, {&LineBreakStream});
     353
     354        kernel::ScanMatchKernel scanMatchK(iBuilder, mGrepType);
     355        scanMatchK.generateKernel({&mergedResults, &LineBreakStream}, {});               
     356        scanMatchK.setInitialArguments({iBuilder->CreateBitCast(inputStream, int8PtrTy), fileSize, fileIdx});
     357
     358        KernelList.push_back(linebreakK);
     359        KernelList.push_back(&scanMatchK);
     360
     361        if (pipelineParallel){
     362            generatePipelineParallel(iBuilder, KernelList);
     363        } else if (segmentPipelineParallel){
     364            generateSegmentParallelPipeline(iBuilder, KernelList);
     365        }  else{
     366            generatePipelineLoop(iBuilder, KernelList);
     367        }
     368       
     369        iBuilder->CreateRetVoid();
     370    }
    351371   
    352372    mEngine = JIT_to_ExecutionEngine(M);
     
    361381    delete iBuilder;
    362382   
    363     mGrepFunction = reinterpret_cast<GrepFunctionType>(mEngine->getPointerToFunction(mainFn));
     383    if (CountOnly) {
     384        mGrepFunction_CountOnly = reinterpret_cast<GrepFunctionType_CountOnly>(mEngine->getPointerToFunction(mainFn));
     385    } else {
     386        mGrepFunction = reinterpret_cast<GrepFunctionType>(mEngine->getPointerToFunction(mainFn));
     387    }
    364388
    365389}
Note: See TracChangeset for help on using the changeset viewer.