Changeset 5254


Ignore:
Timestamp:
Jan 10, 2017, 5:43:35 PM (8 months ago)
Author:
cameron
Message:

Add mmap kernel to all pipelines

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/array-test.cpp

    r5245 r5254  
    2929#include <kernels/interface.h>
    3030#include <kernels/kernel.h>
     31#include <kernels/mmap_kernel.h>
    3132#include <kernels/pipeline.h>
    3233#include <pablo/builder.hpp>
     
    106107    Type * byteStreamTy = iBuilder->getStreamSetTy(1, 8);
    107108
     109    Module * const mod = iBuilder->getModule();
     110   
     111    Function * const main = cast<Function>(mod->getOrInsertFunction("Main", iBuilder->getVoidTy(), byteStreamTy->getPointerTo(), iBuilder->getSizeTy(), nullptr));
     112    main->setCallingConv(CallingConv::C);
     113    Function::arg_iterator args = main->arg_begin();
     114   
     115    Value * const inputStream = &*(args++);
     116    inputStream->setName("input");
     117    Value * const fileSize = &*(args++);
     118    fileSize->setName("fileSize");
     119   
    108120    ExternalFileBuffer ByteStream(iBuilder, byteStreamTy);
    109121    SingleBlockBuffer BasisBits(iBuilder, iBuilder->getStreamSetTy(8, 1));
    110122    SingleBlockBuffer matches(iBuilder, iBuilder->getStreamSetTy(count, 1));
    111123
     124    MMapSourceKernel mmapK(iBuilder, iBuilder->getStride());
     125    mmapK.generateKernel({}, {&ByteStream});
     126    mmapK.setInitialArguments({fileSize});
     127   
    112128    S2PKernel  s2pk(iBuilder);
    113129    s2pk.generateKernel({&ByteStream}, {&BasisBits});
     
    118134    bm.generateKernel({&BasisBits}, {&matches});
    119135
    120     Module * const mod = iBuilder->getModule();
    121 
    122     Function * const main = cast<Function>(mod->getOrInsertFunction("Main", iBuilder->getVoidTy(), byteStreamTy->getPointerTo(), iBuilder->getSizeTy(), nullptr));
    123     main->setCallingConv(CallingConv::C);
    124     Function::arg_iterator args = main->arg_begin();
    125 
    126     Value * const inputStream = &*(args++);
    127     inputStream->setName("input");
    128     Value * const fileSize = &*(args++);
    129     fileSize->setName("fileSize");
    130 
    131136    iBuilder->SetInsertPoint(BasicBlock::Create(mod->getContext(), "entry", main, 0));
    132137
     
    135140    matches.allocateBuffer();
    136141
    137     generatePipelineLoop(iBuilder, {&s2pk, &bm});
     142    generatePipelineLoop(iBuilder, {&mmapK, &s2pk, &bm});
    138143    iBuilder->CreateRetVoid();
    139144
  • icGREP/icgrep-devel/icgrep/base64.cpp

    r5242 r5254  
    2525#include <IR_Gen/idisa_target.h>
    2626#include <kernels/pipeline.h>
     27#include <kernels/mmap_kernel.h>
    2728#include <kernels/interface.h>
    2829#include <kernels/kernel.h>
     
    5354    Type * mBitBlockType = iBuilder->getBitBlockType();
    5455
    55     //Round up to a multiple of 4.
    56     const unsigned segmentSize = ((codegen::SegmentSize + 3)/4) * 4;
    57    
    58     const unsigned bufferSegments = codegen::BufferSegments;
    59    
    60     ExternalFileBuffer ByteStream(iBuilder, iBuilder->getStreamSetTy(1, 8));
    61 
    62     CircularBuffer Expanded3_4Out(iBuilder, iBuilder->getStreamSetTy(1, 8), segmentSize * bufferSegments * 16);
    63     CircularBuffer Radix64out(iBuilder, iBuilder->getStreamSetTy(1, 8), segmentSize * bufferSegments * 16);
    64     LinearCopybackBuffer Base64out(iBuilder, iBuilder->getStreamSetTy(1, 8), segmentSize * bufferSegments * 16 + 2);
    65 
    66     expand3_4Kernel expandK(iBuilder);
    67     expandK.generateKernel({&ByteStream}, {&Expanded3_4Out});
    68 
    69     radix64Kernel radix64K(iBuilder);
    70     radix64K.generateKernel({&Expanded3_4Out}, {&Radix64out});
    71 
    72     base64Kernel base64K(iBuilder);
    73     base64K.generateKernel({&Radix64out}, {&Base64out});
    74    
    75     StdOutKernel stdoutK(iBuilder, 8);
    76     stdoutK.generateKernel({&Base64out}, {});
    77 
    7856    Type * const size_ty = iBuilder->getSizeTy();
    7957    Type * const voidTy = Type::getVoidTy(mMod->getContext());
    8058    Type * const inputType = PointerType::get(ArrayType::get(ArrayType::get(mBitBlockType, 8), 1), 0);
    8159    Type * const outputType = PointerType::get(ArrayType::get(ArrayType::get(mBitBlockType, 8), 1), 0);
    82 
     60   
    8361   
    8462    Function * const main = cast<Function>(mMod->getOrInsertFunction("Main", voidTy, inputType, outputType, size_ty, nullptr));
     
    9270    Value * const fileSize = &*(args++);
    9371    fileSize->setName("fileSize");
     72
     73    //Round up to a multiple of 4.
     74    const unsigned segmentSize = ((codegen::SegmentSize + 3)/4) * 4;
     75   
     76    const unsigned bufferSegments = codegen::BufferSegments;
     77   
     78    ExternalFileBuffer ByteStream(iBuilder, iBuilder->getStreamSetTy(1, 8));
     79
     80    CircularBuffer Expanded3_4Out(iBuilder, iBuilder->getStreamSetTy(1, 8), segmentSize * bufferSegments * 16);
     81    CircularBuffer Radix64out(iBuilder, iBuilder->getStreamSetTy(1, 8), segmentSize * bufferSegments * 16);
     82    LinearCopybackBuffer Base64out(iBuilder, iBuilder->getStreamSetTy(1, 8), segmentSize * bufferSegments * 16 + 2);
     83   
     84    MMapSourceKernel mmapK(iBuilder, iBuilder->getStride());
     85    mmapK.generateKernel({}, {&ByteStream});
     86    mmapK.setInitialArguments({fileSize});
     87       
     88    expand3_4Kernel expandK(iBuilder);
     89    expandK.generateKernel({&ByteStream}, {&Expanded3_4Out});
     90
     91    radix64Kernel radix64K(iBuilder);
     92    radix64K.generateKernel({&Expanded3_4Out}, {&Radix64out});
     93
     94    base64Kernel base64K(iBuilder);
     95    base64K.generateKernel({&Radix64out}, {&Base64out});
     96   
     97    StdOutKernel stdoutK(iBuilder, 8);
     98    stdoutK.generateKernel({&Base64out}, {});
     99
    94100   
    95101    iBuilder->SetInsertPoint(BasicBlock::Create(mMod->getContext(), "entry", main,0));
     
    97103    ByteStream.setStreamSetBuffer(inputStream, fileSize);
    98104//    Radix64out.setEmptyBuffer(iBuilder->CreatePointerCast(outputStream, outputType));
    99     mMod->dump();
    100105    Expanded3_4Out.allocateBuffer();
    101106    Radix64out.allocateBuffer();
     
    104109
    105110    if (segmentPipelineParallel){
    106         generateSegmentParallelPipeline(iBuilder, {&expandK, &radix64K, &base64K, &stdoutK});
     111        generateSegmentParallelPipeline(iBuilder, {&mmapK, &expandK, &radix64K, &base64K, &stdoutK});
    107112    }
    108113    else{
    109         generatePipelineLoop(iBuilder, {&expandK, &radix64K, &base64K, &stdoutK});
     114        generatePipelineLoop(iBuilder, {&mmapK, &expandK, &radix64K, &base64K, &stdoutK});
    110115    }
    111116
  • icGREP/icgrep-devel/icgrep/editd/editd.cpp

    r5244 r5254  
    3232#include <kernels/interface.h>
    3333#include <kernels/kernel.h>
     34#include <kernels/mmap_kernel.h>
    3435#include <kernels/s2p_kernel.h>
    3536#include <editd/editdscan_kernel.h>
     
    287288    Type * mBitBlockType = iBuilder->getBitBlockType();
    288289   
    289     ExternalFileBuffer ByteStream(iBuilder, iBuilder->getStreamSetTy(1, 8));
    290     SingleBlockBuffer BasisBits(iBuilder, iBuilder->getStreamSetTy(8));
    291     ExternalFileBuffer CCResults(iBuilder, iBuilder->getStreamSetTy(4));
    292 
    293     S2PKernel  s2pk(iBuilder);
    294     std::unique_ptr<Module> s2pM = s2pk.createKernelModule({&ByteStream}, {&BasisBits});
    295 
    296     PabloKernel  ccck(iBuilder, "ccc");
    297 
    298     buildPreprocessKernel(ccck, iBuilder);
    299    
    300     std::unique_ptr<Module> cccM = ccck.createKernelModule({&BasisBits}, {&CCResults});
    301    
    302     s2pk.addKernelDeclarations(mMod);
    303     ccck.addKernelDeclarations(mMod);
    304 
    305290    Type * const size_ty = iBuilder->getSizeTy();
    306291    Type * const voidTy = iBuilder->getVoidTy();
     
    319304    outputStream->setName("output");
    320305   
     306    ExternalFileBuffer ByteStream(iBuilder, iBuilder->getStreamSetTy(1, 8));
     307    SingleBlockBuffer BasisBits(iBuilder, iBuilder->getStreamSetTy(8));
     308    ExternalFileBuffer CCResults(iBuilder, iBuilder->getStreamSetTy(4));
     309
     310    MMapSourceKernel mmapK(iBuilder, iBuilder->getStride());
     311    std::unique_ptr<Module> mmapM = mmapK.createKernelModule({}, {&ByteStream});
     312    mmapK.setInitialArguments({fileSize});
     313   
     314    S2PKernel  s2pk(iBuilder);
     315    std::unique_ptr<Module> s2pM = s2pk.createKernelModule({&ByteStream}, {&BasisBits});
     316
     317    PabloKernel  ccck(iBuilder, "ccc");
     318
     319    buildPreprocessKernel(ccck, iBuilder);
     320   
     321    std::unique_ptr<Module> cccM = ccck.createKernelModule({&BasisBits}, {&CCResults});
     322   
     323    mmapK.addKernelDeclarations(mMod);
     324    s2pk.addKernelDeclarations(mMod);
     325    ccck.addKernelDeclarations(mMod);
     326   
    321327    iBuilder->SetInsertPoint(BasicBlock::Create(mMod->getContext(), "entry", main,0));
    322328
     
    325331    CCResults.setStreamSetBuffer(outputStream, fileSize);
    326332   
    327     generatePipelineLoop(iBuilder, {&s2pk, &ccck});
     333    generatePipelineLoop(iBuilder, {&mmapK, &s2pk, &ccck});
    328334       
    329335    iBuilder->CreateRetVoid();
    330336   
    331337    Linker L(*mMod);
     338    L.linkInModule(std::move(mmapM));
    332339    L.linkInModule(std::move(s2pM));
    333340    L.linkInModule(std::move(cccM));
  • icGREP/icgrep-devel/icgrep/grep_engine.cpp

    r5246 r5254  
    2020#include <kernels/kernel.h>
    2121#include <kernels/pipeline.h>
    22 #include <kernels/pipeline.h>
     22#include <kernels/mmap_kernel.h>
    2323#include <kernels/s2p_kernel.h>
    2424#include <kernels/scanmatchgen.h>
     
    291291       
    292292    ExternalFileBuffer ByteStream(iBuilder, iBuilder->getStreamSetTy(1, 8));
     293   
     294    kernel::MMapSourceKernel mmapK(iBuilder, iBuilder->getStride());
     295    mmapK.generateKernel({}, {&ByteStream});
     296    mmapK.setInitialArguments({fileSize});
     297   
    293298    CircularBuffer BasisBits(iBuilder, iBuilder->getStreamSetTy(8, 1), segmentSize * bufferSegments);
    294299
     
    308313        icgrepK.generateKernel({&BasisBits}, {});       
    309314        if (pipelineParallel){
    310             generatePipelineParallel(iBuilder, {&s2pk, &icgrepK});
     315            generatePipelineParallel(iBuilder, {&mmapK, &s2pk, &icgrepK});
    311316        } else if (segmentPipelineParallel){
    312             generateSegmentParallelPipeline(iBuilder, {&s2pk, &icgrepK});
     317            generateSegmentParallelPipeline(iBuilder, {&mmapK, &s2pk, &icgrepK});
    313318        } else {
    314             generatePipelineLoop(iBuilder, {&s2pk, &icgrepK});
     319            generatePipelineLoop(iBuilder, {&mmapK, &s2pk, &icgrepK});
    315320        }
    316321
     
    326331
    327332            icgrepK.generateKernel({&BasisBits},  {&MatchResults});
    328             generatePipelineLoop(iBuilder, {&s2pk, &icgrepK});
     333            generatePipelineLoop(iBuilder, {&mmapK, &s2pk, &icgrepK});
    329334
    330335        }
     
    341346
    342347            if (pipelineParallel){
    343                 generatePipelineParallel(iBuilder, {&s2pk, &icgrepK, &scanMatchK});
     348                generatePipelineParallel(iBuilder, {&mmapK, &s2pk, &icgrepK, &scanMatchK});
    344349            } else if (segmentPipelineParallel){
    345                 generateSegmentParallelPipeline(iBuilder, {&s2pk, &icgrepK, &scanMatchK});
     350                generateSegmentParallelPipeline(iBuilder, {&mmapK, &s2pk, &icgrepK, &scanMatchK});
    346351            }  else{
    347                 generatePipelineLoop(iBuilder, {&s2pk, &icgrepK, &scanMatchK});
     352                generatePipelineLoop(iBuilder, {&mmapK, &s2pk, &icgrepK, &scanMatchK});
    348353            }
    349354        }
  • icGREP/icgrep-devel/icgrep/u8u16.cpp

    r5243 r5254  
    2929#include <IR_Gen/idisa_target.h>
    3030#include <kernels/pipeline.h>
     31#include <kernels/mmap_kernel.h>
    3132#include <kernels/interface.h>
    3233#include <kernels/kernel.h>
     
    262263    assert (iBuilder);
    263264
     265    Type * const size_ty = iBuilder->getSizeTy();
     266    Type * const voidTy = iBuilder->getVoidTy();
     267    Type * const bitBlockType = iBuilder->getBitBlockType();
     268    Type * const inputType = ArrayType::get(ArrayType::get(bitBlockType, 8), 1)->getPointerTo();
     269    Type * const outputType = ArrayType::get(ArrayType::get(bitBlockType, 16), 1)->getPointerTo();
     270   
     271    Function * const main = cast<Function>(mod->getOrInsertFunction("Main", voidTy, inputType, outputType, size_ty, nullptr));
     272    main->setCallingConv(CallingConv::C);
     273    Function::arg_iterator args = main->arg_begin();
     274   
     275    Value * const inputStream = &*(args++);
     276    inputStream->setName("inputStream");
     277    Value * const outputStream = &*(args++);
     278    outputStream->setName("outputStream");
     279    Value * const fileSize = &*(args++);
     280    fileSize->setName("fileSize");
     281
    264282    ExternalFileBuffer ByteStream(iBuilder, iBuilder->getStreamSetTy(1, 8));
    265283
     
    278296    LinearCopybackBuffer U16out(iBuilder, iBuilder->getStreamSetTy(16, 16), segmentSize * bufferSegments + 2);
    279297
     298    MMapSourceKernel mmapK(iBuilder, iBuilder->getStride());
     299    mmapK.generateKernel({}, {&ByteStream});
     300    mmapK.setInitialArguments({fileSize});
     301   
    280302    S2PKernel s2pk(iBuilder);
    281303
     
    303325    }
    304326
    305     Type * const size_ty = iBuilder->getSizeTy();
    306     Type * const voidTy = iBuilder->getVoidTy();
    307     Type * const bitBlockType = iBuilder->getBitBlockType();
    308     Type * const inputType = ArrayType::get(ArrayType::get(bitBlockType, 8), 1)->getPointerTo();
    309     Type * const outputType = ArrayType::get(ArrayType::get(bitBlockType, 16), 1)->getPointerTo();
    310    
    311     Function * const main = cast<Function>(mod->getOrInsertFunction("Main", voidTy, inputType, outputType, size_ty, nullptr));
    312     main->setCallingConv(CallingConv::C);
    313     Function::arg_iterator args = main->arg_begin();
    314 
    315     Value * const inputStream = &*(args++);
    316     inputStream->setName("inputStream");
    317     Value * const outputStream = &*(args++);
    318     outputStream->setName("outputStream");
    319     Value * const fileSize = &*(args++);
    320     fileSize->setName("fileSize");
    321327
    322328    iBuilder->SetInsertPoint(BasicBlock::Create(mod->getContext(), "entry", main,0));
     
    336342
    337343    if (segmentPipelineParallel){
    338         generateSegmentParallelPipeline(iBuilder, {&s2pk, &u8u16k, &delK, &p2sk, &stdoutK});
     344        generateSegmentParallelPipeline(iBuilder, {&mmapK, &s2pk, &u8u16k, &delK, &p2sk, &stdoutK});
    339345    } else {
    340         generatePipelineLoop(iBuilder, {&s2pk, &u8u16k, &delK, &p2sk, &stdoutK});
     346        generatePipelineLoop(iBuilder, {&mmapK, &s2pk, &u8u16k, &delK, &p2sk, &stdoutK});
    341347    }
    342348
Note: See TracChangeset for help on using the changeset viewer.