Changeset 5134 for icGREP


Ignore:
Timestamp:
Aug 26, 2016, 12:48:42 PM (3 years ago)
Author:
cameron
Message:

refine PabloKernel? signature based on CountOnly? parameter

Location:
icGREP/icgrep-devel/icgrep
Files:
5 edited

Legend:

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

    r5133 r5134  
    153153    ExternalUnboundedBuffer ByteStream(iBuilder, StreamSetType(1, i8));
    154154    CircularBuffer BasisBits(iBuilder, StreamSetType(8, i1), segmentSize);
    155     CircularBuffer MatchResults(iBuilder, StreamSetType(2, i1), segmentSize);
    156155
    157156    kernel::s2pKernel  s2pk(iBuilder);
     
    159158
    160159    re_ast = re::regular_expression_passes(encoding, re_ast);   
    161     pablo::PabloFunction * function = re::re2pablo_compiler(encoding, re_ast);
     160    pablo::PabloFunction * function = re::re2pablo_compiler(encoding, re_ast, CountOnly);
    162161    pablo_function_passes(function);
    163     pablo::PabloKernel  icgrepK(iBuilder, "icgrep", function, {"matchedLineCount"});
    164     icgrepK.generateKernel({&BasisBits}, {&MatchResults});
    165 
    166     ByteStream.setStreamSetBuffer(inputStream);
    167     BasisBits.allocateBuffer();
    168     MatchResults.allocateBuffer();
    169    
    170     Value * s2pInstance = s2pk.createInstance({});
    171     Value * icgrepInstance = icgrepK.createInstance({});
    172162   
    173163    if (CountOnly) {
     164        pablo::PabloKernel  icgrepK(iBuilder, "icgrep", function, {"matchedLineCount"});
     165        icgrepK.generateKernel({&BasisBits}, {});
     166
     167        ByteStream.setStreamSetBuffer(inputStream);
     168        BasisBits.allocateBuffer();
     169       
     170        Value * s2pInstance = s2pk.createInstance({});
     171        Value * icgrepInstance = icgrepK.createInstance({});
     172       
    174173        generatePipelineLoop(iBuilder, {&s2pk, &icgrepK}, {s2pInstance, icgrepInstance}, fileSize);
    175174        Value * matchCount = icgrepK.createGetAccumulatorCall(icgrepInstance, "matchedLineCount");
     
    177176    }
    178177    else {
     178        CircularBuffer MatchResults(iBuilder, StreamSetType(2, i1), segmentSize);
     179        pablo::PabloKernel  icgrepK(iBuilder, "icgrep", function, {});
     180        icgrepK.generateKernel({&BasisBits},  {&MatchResults});
     181
     182        ByteStream.setStreamSetBuffer(inputStream);
     183        BasisBits.allocateBuffer();
     184        MatchResults.allocateBuffer();
     185       
     186        Value * s2pInstance = s2pk.createInstance({});
     187        Value * icgrepInstance = icgrepK.createInstance({});
    179188        kernel::scanMatchKernel scanMatchK(iBuilder, mIsNameExpression);
    180189        scanMatchK.generateKernel({&MatchResults}, {});
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r5091 r5134  
    8686    mLineBreak = mPB.createOr(lb, unterminatedLineAtEOF);
    8787    mAny = mPB.createNot(lb, "any");
    88     mFunction.setResult(1, mPB.createAssign("lf", mLineBreak));
     88    if (!mCountOnly) mFunction.setResult(1, mPB.createAssign("lf", mLineBreak));
    8989    return;
    9090}
     
    170170    mLineBreak = mPB.createOr(lb, unterminatedLineAtEOF);
    171171    mAny = mPB.createNot(lb, "any");
    172     mFunction.setResult(1, mPB.createAssign("lf", mLineBreak));
     172    if (!mCountOnly) mFunction.setResult(1, mPB.createAssign("lf", mLineBreak));
    173173}
    174174
     
    212212    }
    213213    Assign * matches = mPB.createAssign("matches", mPB.createAnd(match_follow, mLineBreak));
    214     mFunction.setResultCount(mPB.createCount("matchedLineCount", matches));
    215     mFunction.setResult(0, matches);
     214    if (mCountOnly) {
     215        mFunction.setResultCount(mPB.createCount("matchedLineCount", matches));
     216    }
     217    else {
     218        mFunction.setResult(0, matches);
     219    }
    216220}
    217221
     
    626630}
    627631
    628 RE_Compiler::RE_Compiler(pablo::PabloFunction & function, cc::CC_Compiler & ccCompiler)
    629 : mCCCompiler(ccCompiler)
     632RE_Compiler::RE_Compiler(pablo::PabloFunction & function, cc::CC_Compiler & ccCompiler, bool CountOnly)
     633: mCountOnly(CountOnly)
     634, mCCCompiler(ccCompiler)
    630635, mLineBreak(nullptr)
    631636, mCRLF(nullptr)
  • icGREP/icgrep-devel/icgrep/re/re_compiler.h

    r5091 r5134  
    5252public:
    5353
    54     RE_Compiler(pablo::PabloFunction & function, cc::CC_Compiler & ccCompiler);
     54    RE_Compiler(pablo::PabloFunction & function, cc::CC_Compiler & ccCompiler, bool CountOnly = false);
    5555    void initializeRequiredStreams(Encoding encoding);
    5656    void compileUnicodeNames(RE *& re);
     
    9393private:
    9494
     95    bool                                            mCountOnly;
    9596    cc::CC_Compiler &                               mCCCompiler;
    9697    pablo::PabloAST *                               mLineBreak;
  • icGREP/icgrep-devel/icgrep/re/re_toolchain.cpp

    r5045 r5134  
    8686}
    8787   
    88 PabloFunction * re2pablo_compiler(const Encoding encoding, RE * re_ast) {
    89     PabloFunction * function = PabloFunction::Create("process_block", encoding.getBits(), 2);
     88PabloFunction * re2pablo_compiler(const Encoding encoding, RE * re_ast, bool CountOnly) {
     89    PabloFunction * function = PabloFunction::Create("process_block", encoding.getBits(), CountOnly ? 0 : 2);
    9090    cc::CC_Compiler cc_compiler(*function, encoding);
    91     re::RE_Compiler re_compiler(*function, cc_compiler);
     91    re::RE_Compiler re_compiler(*function, cc_compiler, CountOnly);
    9292    re_compiler.initializeRequiredStreams(encoding);
    9393    re_compiler.compileUnicodeNames(re_ast);
  • icGREP/icgrep-devel/icgrep/re/re_toolchain.h

    r5030 r5134  
    3333RE * regular_expression_passes(const Encoding encoding, RE * re_ast);
    3434
    35 pablo::PabloFunction * re2pablo_compiler(const Encoding encoding, RE * re_ast);
     35pablo::PabloFunction * re2pablo_compiler(const Encoding encoding, RE * re_ast, bool CountOnly = false);
    3636   
    3737}
Note: See TracChangeset for help on using the changeset viewer.