Changeset 5450


Ignore:
Timestamp:
May 14, 2017, 3:35:16 PM (2 years ago)
Author:
cameron
Message:

Until_N kernel and icgrep -max-count option: initial check-in

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

Legend:

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

    r5449 r5450  
    9494target_link_libraries (RegExpCompiler RegExpADT)
    9595
    96 add_executable(icgrep icgrep.cpp grep_engine.cpp kernels/scanmatchgen.cpp kernels/cc_kernel.cpp kernels/cc_scan_kernel.cpp kernels/linebreak_kernel.cpp kernels/streams_merge.cpp kernels/match_count.cpp kernels/grep_kernel.cpp)
     96add_executable(icgrep icgrep.cpp grep_engine.cpp kernels/scanmatchgen.cpp kernels/cc_kernel.cpp kernels/cc_scan_kernel.cpp kernels/linebreak_kernel.cpp kernels/streams_merge.cpp kernels/match_count.cpp kernels/grep_kernel.cpp kernels/until_n.cpp)
    9797add_executable(u8u16 u8u16.cpp)
    9898add_executable(base64 base64.cpp kernels/radix64.cpp)
  • icGREP/icgrep-devel/icgrep/grep_engine.cpp

    r5440 r5450  
    2222#include <kernels/scanmatchgen.h>
    2323#include <kernels/streamset.h>
     24#include <kernels/until_n.h>
    2425#include <kernels/kernel_builder.h>
    2526#include <pablo/pablo_kernel.h>
     
    5253static cl::alias ShowLineNumbersLong("line-number", cl::desc("Alias for -n"), cl::aliasopt(ShowLineNumbers));
    5354
     55static cl::opt<int> MaxCount("m", cl::desc("Limit the number of matches per file."), cl::cat(bGrepOutputOptions), cl::init((size_t) -1));
     56static cl::alias MaxCountLong("max-count", cl::desc("Alias for -m"), cl::aliasopt(MaxCount));
     57
    5458static re::CC * parsedCodePointSet = nullptr;
    5559
     
    109113    }
    110114    if (ShowLineNumbers) {
    111         resultStrs[fileIdx] << lineNum << ":";
     115        // Internally line numbers are counted from 0.  For display, adjust
     116        // the line number so that lines are numbered from 1.
     117        resultStrs[fileIdx] << lineNum+1 << ":";
    112118    }
    113119
     
    287293        MergedResults = pxDriver.addBuffer(make_unique<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments));
    288294        pxDriver.makeKernelCall(invertK, {OriginalMatches, LineBreakStream}, {MergedResults});
     295    }
     296    if (MaxCount > 0) {
     297        kernel::Kernel * untilK = pxDriver.addKernelInstance(make_unique<kernel::UntilNkernel>(idb));
     298        untilK->setInitialArguments({idb->getSize(MaxCount)});
     299        StreamSetBuffer * AllMatches = MergedResults;
     300        MergedResults = pxDriver.addBuffer(make_unique<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments));
     301        pxDriver.makeKernelCall(untilK, {AllMatches}, {MergedResults});
    289302    }
    290303    if (CountOnly) {
Note: See TracChangeset for help on using the changeset viewer.