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

Add mmap kernel to all pipelines

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.