Changeset 5410


Ignore:
Timestamp:
Apr 18, 2017, 9:53:43 AM (22 months ago)
Author:
cameron
Message:

icgrep refactoring progress; icgrep kernel signatures currently must include -v flag

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

Legend:

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

    r5408 r5410  
    160160
    161161#ifdef CUDA_ENABLED
    162 Function * generateGPUKernel(ParabixDriver & nvptxDriver, bool CountOnly){
     162Function * generateGPUKernel(NVPTXDriver & nvptxDriver, bool CountOnly){
    163163    IDISA::IDISA_Builder * iBuilder = nvptxDriver.getIDISA_Builder();
    164164    Module * m = iBuilder->getModule();
     
    251251    mmapK0.setName("mmap0");
    252252    mmapK0.setInitialArguments({fileSize});
    253     pxDriver.addKernelCall(mmapK0, {}, {&InputStream});
     253    pxDriver.addKernelCall(mmapK0, {}, {InputStream});
    254254
    255255
     
    257257    mmapK1.setName("mmap1");
    258258    mmapK1.setInitialArguments({fileSize});
    259     pxDriver.addKernelCall(mmapK1, {}, {&MatchResults});
     259    pxDriver.addKernelCall(mmapK1, {}, {MatchResults});
    260260
    261261    ExternalFileBuffer LineBreak(iBuilder, iBuilder->getStreamSetTy(1, 1));
     
    265265    mmapK2.setName("mmap2");
    266266    mmapK2.setInitialArguments({fileSize});
    267     pxDriver.addKernelCall(mmapK2, {}, {&LineBreak});
     267    pxDriver.addKernelCall(mmapK2, {}, {LineBreak});
    268268
    269269    kernel::ScanMatchKernel scanMatchK(iBuilder, grepType, 8);
    270270    scanMatchK.setInitialArguments({fileIdx});
    271     pxDriver.addKernelCall(scanMatchK, {&InputStream, &MatchResults, &LineBreak}, {});
     271    pxDriver.addKernelCall(scanMatchK, {InputStream, MatchResults, LineBreak}, {});
    272272    pxDriver.generatePipelineIR();
    273273    iBuilder->CreateRetVoid();
     
    443443    ParabixDriver pxDriver(iBuilder);
    444444
    445     // segment size made availabe for each call to the mmap source kernel
     445    // segment size made available for each call to the mmap source kernel
    446446    const unsigned segmentSize = codegen::SegmentSize;
    447447    const unsigned bufferSegments = codegen::BufferSegments * codegen::ThreadNum;
     
    502502    }
    503503
    504     StreamSetBuffer * byteStream = nullptr;
     504    StreamSetBuffer * ByteStream = nullptr;
    505505    kernel::KernelBuilder * sourceK = nullptr;
    506506    if (usingStdIn) {
    507507        // TODO: use fstat(STDIN_FILENO) to see if we can mmap the stdin safely and avoid the calls to read
    508         byteStream = new ExtensibleBuffer(iBuilder, iBuilder->getStreamSetTy(1, 8), segmentSize);
     508        ByteStream = pxDriver.addBuffer(make_unique<ExtensibleBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 8), segmentSize));
    509509        sourceK = new kernel::StdInKernel(iBuilder, segmentSize);
    510510    } else {
    511         byteStream = new SourceFileBuffer(iBuilder, iBuilder->getStreamSetTy(1, 8));
     511        ByteStream = pxDriver.addBuffer(make_unique<SourceFileBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 8)));
    512512        sourceK = new kernel::FileSourceKernel(iBuilder, inputStream->getType(), segmentSize);
    513513        sourceK->setInitialArguments({inputStream, fileSize});
    514514    }
    515     byteStream->allocateBuffer();
    516     pxDriver.addKernelCall(*sourceK, {}, {byteStream});
    517 
    518     CircularBuffer BasisBits(iBuilder, iBuilder->getStreamSetTy(8), segmentSize * bufferSegments);
    519     BasisBits.allocateBuffer();
     515    pxDriver.addKernelCall(*sourceK, {}, {ByteStream});
     516   
     517    StreamSetBuffer * BasisBits = pxDriver.addBuffer(make_unique<CircularBuffer>(iBuilder, iBuilder->getStreamSetTy(8, 1), segmentSize * bufferSegments));
    520518
    521519    kernel::S2PKernel s2pk(iBuilder);
    522     pxDriver.addKernelCall(s2pk, {byteStream}, {&BasisBits});
     520    pxDriver.addKernelCall(s2pk, {ByteStream}, {BasisBits});
    523521
    524522    kernel::LineBreakKernelBuilder linebreakK(iBuilder, encodingBits);
    525     CircularBuffer LineBreakStream(iBuilder, iBuilder->getStreamSetTy(1, 1), segmentSize * bufferSegments);
    526     LineBreakStream.allocateBuffer();
    527 
    528     pxDriver.addKernelCall(linebreakK, {&BasisBits}, {&LineBreakStream});
     523    StreamSetBuffer * LineBreakStream = pxDriver.addBuffer(make_unique<CircularBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 1), segmentSize * bufferSegments));
     524    pxDriver.addKernelCall(linebreakK, {BasisBits}, {LineBreakStream});
    529525   
    530526    kernel::ICgrepKernelBuilder icgrepK(iBuilder, re_ast, CountOnly);
     
    532528    if (CountOnly) {
    533529       
    534         pxDriver.addKernelCall(icgrepK, {&BasisBits, &LineBreakStream}, {});
     530        pxDriver.addKernelCall(icgrepK, {BasisBits, LineBreakStream}, {});
    535531
    536532        pxDriver.generatePipelineIR();
     
    544540        #ifdef CUDA_ENABLED
    545541        if (codegen::NVPTX){
    546             ExternalFileBuffer MatchResults(iBuilder, iBuilder->getStreamSetTy(1, 1), addrSpace);
    547             MatchResults.setStreamSetBuffer(outputStream);
    548 
    549             pxDriver.addKernelCall(icgrepK, {&BasisBits, &LineBreakStream}, {&MatchResults});
     542            ExternalFileBuffer * MatchResults = pxDriver.addExternalBuffer(make_unique<ExternalFileBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 1), addrSpace), outputStream);
     543
     544            pxDriver.addKernelCall(icgrepK, {BasisBits, LineBreakStream}, {MatchResults});
    550545
    551546            pxDriver.generatePipelineIR();
     
    559554        if (CPU_Only) {
    560555
    561             CircularBuffer MatchResults(iBuilder, iBuilder->getStreamSetTy(1, 1), segmentSize * bufferSegments);
    562             MatchResults.allocateBuffer();
    563 
    564             pxDriver.addKernelCall(icgrepK, {&BasisBits, &LineBreakStream}, {&MatchResults});
     556            StreamSetBuffer * MatchResults = pxDriver.addBuffer(make_unique<CircularBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 1), segmentSize * bufferSegments));
     557
     558            pxDriver.addKernelCall(icgrepK, {BasisBits, LineBreakStream}, {MatchResults});
    565559
    566560            kernel::ScanMatchKernel scanMatchK(iBuilder, grepType, encodingBits);
    567561            scanMatchK.setInitialArguments({fileIdx});
    568562
    569             pxDriver.addKernelCall(scanMatchK, {&MatchResults, &LineBreakStream, byteStream}, {});
     563            pxDriver.addKernelCall(scanMatchK, {MatchResults, LineBreakStream, ByteStream}, {});
    570564
    571565            linkGrepFunction(pxDriver, grepType, UTF_16, scanMatchK);
     
    581575    #ifdef CUDA_ENABLED
    582576    if(codegen::NVPTX){
    583         ParabixDriver nvptxDriver(iBuilder);
     577        NVPTXDriver nvptxDriver(iBuilder);
    584578        Function * kernelFunction = generateGPUKernel(nvptxDriver, CountOnly);
    585579       
     
    603597    delete iBuilder;
    604598    delete sourceK;
    605     delete byteStream;
    606599
    607600    if (CountOnly) {
     
    642635    fileIdx->setName("fileIdx");
    643636
    644     StreamSetBuffer * byteStream = nullptr;
     637    StreamSetBuffer * ByteStream = nullptr;
    645638    kernel::KernelBuilder * sourceK = nullptr;
    646639    if (usingStdIn) {
    647640        // TODO: use fstat(STDIN_FILENO) to see if we can mmap the stdin safely and avoid the calls to read
    648         byteStream = new ExtensibleBuffer(iBuilder, iBuilder->getStreamSetTy(1, 8), segmentSize);
     641        ByteStream = pxDriver.addBuffer(make_unique<ExtensibleBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 8), segmentSize));
    649642        sourceK = new kernel::StdInKernel(iBuilder, segmentSize);
    650643    } else {
    651         byteStream = new SourceFileBuffer(iBuilder, iBuilder->getStreamSetTy(1, 8));
    652         sourceK = new kernel::FileSourceKernel(iBuilder, inputStream->getType(), segmentSize);
    653         sourceK->setInitialArguments({inputStream, fileSize});
    654     }
    655     byteStream->allocateBuffer();
    656     pxDriver.addKernelCall(*sourceK, {}, {byteStream});
    657 
    658     CircularBuffer BasisBits(iBuilder, iBuilder->getStreamSetTy(8), segmentSize * bufferSegments);
    659     BasisBits.allocateBuffer();
     644        ByteStream = pxDriver.addExternalBuffer(make_unique<ExternalFileBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 8)), inputStream);
     645        sourceK = new kernel::MMapSourceKernel(iBuilder, segmentSize);
     646        sourceK->setInitialArguments({fileSize});
     647    }
     648    pxDriver.addKernelCall(*sourceK, {}, {ByteStream});
     649
     650    StreamSetBuffer * BasisBits = pxDriver.addBuffer(make_unique<CircularBuffer>(iBuilder, iBuilder->getStreamSetTy(8, 1), segmentSize * bufferSegments));
    660651
    661652    kernel::S2PKernel s2pk(iBuilder);
    662     pxDriver.addKernelCall(s2pk, {byteStream}, {&BasisBits});
     653    pxDriver.addKernelCall(s2pk, {ByteStream}, {BasisBits});
    663654
    664655    kernel::LineBreakKernelBuilder linebreakK(iBuilder, encodingBits);
    665     CircularBuffer LineBreakStream(iBuilder, iBuilder->getStreamSetTy(1, 1), segmentSize * bufferSegments);
    666     LineBreakStream.allocateBuffer();
    667     pxDriver.addKernelCall(linebreakK, {&BasisBits}, {&LineBreakStream});
    668 
     656    StreamSetBuffer * LineBreakStream = pxDriver.addBuffer(make_unique<CircularBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 1), segmentSize * bufferSegments));
     657    pxDriver.addKernelCall(linebreakK, {BasisBits}, {LineBreakStream});
     658   
    669659    std::vector<pablo::PabloKernel *> icgrepKs;
    670660    std::vector<StreamSetBuffer *> MatchResultsBufs;
    671661
    672662    for(unsigned i = 0; i < REs.size(); ++i){
    673         pablo::PabloKernel * const icgrepK = new kernel::ICgrepKernelBuilder(iBuilder, REs[i], false);
    674         CircularBuffer * const matchResults = new CircularBuffer(iBuilder, iBuilder->getStreamSetTy(1, 1), segmentSize * bufferSegments);
    675         matchResults->allocateBuffer();
    676 
    677         pxDriver.addKernelCall(*icgrepK, {&BasisBits, &LineBreakStream}, {matchResults});
     663        pablo::PabloKernel * const icgrepK = new kernel::ICgrepKernelBuilder(iBuilder, REs[i]);
     664        StreamSetBuffer * MatchResults = pxDriver.addBuffer(make_unique<CircularBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 1), segmentSize * bufferSegments));
     665        pxDriver.addKernelCall(*icgrepK, {BasisBits, LineBreakStream}, {MatchResults});
    678666        icgrepKs.push_back(icgrepK);
    679         MatchResultsBufs.push_back(matchResults);
    680     }
    681 
    682     CircularBuffer mergedResults(iBuilder, iBuilder->getStreamSetTy(1, 1), segmentSize * bufferSegments);
    683     mergedResults.allocateBuffer();
     667        MatchResultsBufs.push_back(MatchResults);
     668    }
     669
     670    StreamSetBuffer * MergedResults = pxDriver.addBuffer(make_unique<CircularBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 1), segmentSize * bufferSegments));
    684671
    685672    kernel::StreamsMerge streamsMergeK(iBuilder, 1, REs.size());
    686     pxDriver.addKernelCall(streamsMergeK, MatchResultsBufs, {&mergedResults});
     673    pxDriver.addKernelCall(streamsMergeK, MatchResultsBufs, {MergedResults});
    687674
    688675    if (CountOnly) {
    689676        kernel::MatchCount matchCountK(iBuilder);
    690         pxDriver.addKernelCall(matchCountK, {&mergedResults}, {});
     677        pxDriver.addKernelCall(matchCountK, {MergedResults}, {});
    691678        pxDriver.generatePipelineIR();
    692679        iBuilder->CreateRet(matchCountK.getScalarField("matchedLineCount"));
     
    695682        kernel::ScanMatchKernel scanMatchK(iBuilder, grepType, encodingBits);
    696683        scanMatchK.setInitialArguments({fileIdx});
    697         pxDriver.addKernelCall(scanMatchK, {&mergedResults, &LineBreakStream, byteStream}, {});
     684        pxDriver.addKernelCall(scanMatchK, {MergedResults, LineBreakStream, ByteStream}, {});
    698685        linkGrepFunction(pxDriver, grepType, UTF_16, scanMatchK);
    699686        pxDriver.generatePipelineIR();
     
    704691    delete iBuilder;
    705692    delete sourceK;
    706     delete byteStream;
    707     for (StreamSetBuffer * buf : MatchResultsBufs) {
    708         delete buf;
    709     }
    710693
    711694    if (CountOnly) {
  • icGREP/icgrep-devel/icgrep/kernels/grep_kernel.cpp

    r5408 r5410  
    3131        signature += "-c";
    3232    }
     33    if (AlgorithmOptionIsSet(InvertMatches)) {
     34        signature += "-v";
     35    }
    3336    return signature;
    3437}
Note: See TracChangeset for help on using the changeset viewer.