Ignore:
Timestamp:
Jul 15, 2016, 10:06:31 PM (3 years ago)
Author:
cameron
Message:

wc using doSegment; pipeline generation

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

Legend:

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

    r5083 r5088  
    113113
    114114add_executable(icgrep icgrep.cpp toolchain.cpp grep_engine.cpp kernels/pipeline.cpp kernels/scanmatchgen.cpp ${PRECOMPILED_FILES})
    115 add_executable(u8u16 u8u16.cpp toolchain.cpp kernels/p2s_kernel.cpp kernels/deletion.cpp kernels/stdout_kernel.cpp)
     115add_executable(u8u16 u8u16.cpp toolchain.cpp kernels/p2s_kernel.cpp kernels/pipeline.cpp kernels/deletion.cpp kernels/stdout_kernel.cpp)
    116116#add_executable(symtbl symboltable.cpp toolchain.cpp kernels/symboltablepipeline.cpp kernels/stdout_kernel.cpp grep_engine.cpp kernels/pipeline.cpp kernels/scanmatchgen.cpp ${PRECOMPILED_FILES})
    117 add_executable(wc wc.cpp toolchain.cpp)
     117add_executable(wc wc.cpp toolchain.cpp kernels/pipeline.cpp)
    118118
    119119IF(ENABLE_PREGENERATED_UCD_FUNCTIONS)
  • icGREP/icgrep-devel/icgrep/wc.cpp

    r5074 r5088  
    3333#include <kernels/kernel.h>
    3434#include <kernels/s2p_kernel.h>
     35#include <kernels/pipeline.h>
    3536
    3637#include <pablo/pablo_compiler.h>
     
    141142Function * wcPipeline(Module * mMod, IDISA::IDISA_Builder * iBuilder, pablo::PabloFunction * function) {
    142143    Type * mBitBlockType = iBuilder->getBitBlockType();
    143     unsigned mBlockSize = iBuilder->getBitBlockWidth();
     144   
    144145    s2pKernel  s2pk(iBuilder);
    145146    std::unique_ptr<Module> s2pM = s2pk.createKernelModule();
     
    163164    Value * const inputStream = &*(args++);
    164165    inputStream->setName("input");
    165     Value * const bufferSize = &*(args++);
    166     bufferSize->setName("bufferSize");
     166    Value * const fileSize = &*(args++);
     167    fileSize->setName("fileSize");
    167168    Value * const fileIdx = &*(args++);
    168169    fileIdx->setName("fileIdx");
    169170   
    170171    iBuilder->SetInsertPoint(BasicBlock::Create(mMod->getContext(), "entry", main,0));
    171    
    172     BasicBlock * entryBlock = iBuilder->GetInsertBlock();
    173 
    174     BasicBlock * fullCondBlock = BasicBlock::Create(mMod->getContext(), "fullCond", main, 0);
    175     BasicBlock * fullBodyBlock = BasicBlock::Create(mMod->getContext(), "fullBody", main, 0);
    176     BasicBlock * finalBlock = BasicBlock::Create(mMod->getContext(), "final", main, 0);
    177 
    178     StreamSetBuffer ByteStream(iBuilder, StreamSetType(1, 8), 0);
    179     StreamSetBuffer BasisBits(iBuilder, StreamSetType(8, 1), 1);
     172    kernel::StreamSetBuffer ByteStream(iBuilder, kernel::StreamSetType(1, 8), 0);
     173    kernel::StreamSetBuffer BasisBits(iBuilder, kernel::StreamSetType(8, 1), codegen::SegmentSize);
     174
    180175    ByteStream.setStreamSetBuffer(inputStream);
    181     Value * basisBits = BasisBits.allocateBuffer();
    182 
    183     Value * s2pInstance = s2pk.createInstance({});
    184     Value * wcInstance = wck.createInstance({});
    185    
    186     Value * initialBufferSize = bufferSize;
    187     BasicBlock * initialBlock = entryBlock;
    188     Value * initialBlockNo = iBuilder->getInt64(0);
    189 
    190     iBuilder->CreateBr(fullCondBlock);
    191 
    192    
    193     iBuilder->SetInsertPoint(fullCondBlock);
    194     PHINode * remainingBytes = iBuilder->CreatePHI(int64ty, 2, "remainingBytes");
    195     remainingBytes->addIncoming(initialBufferSize, initialBlock);
    196     PHINode * blockNo = iBuilder->CreatePHI(int64ty, 2, "blockNo");
    197     blockNo->addIncoming(initialBlockNo, initialBlock);
    198 
    199     Constant * const step = ConstantInt::get(int64ty, mBlockSize);
    200     Value * fullCondTest = iBuilder->CreateICmpULT(remainingBytes, step);
    201     iBuilder->CreateCondBr(fullCondTest, finalBlock, fullBodyBlock);
    202    
    203     iBuilder->SetInsertPoint(fullBodyBlock);
    204 
    205     s2pk.createDoBlockCall(s2pInstance, {ByteStream.getBlockPointer(blockNo), basisBits});
    206     wck.createDoBlockCall(wcInstance, {basisBits});
    207 
    208     Value * diff = iBuilder->CreateSub(remainingBytes, step);
    209 
    210     remainingBytes->addIncoming(diff, fullBodyBlock);
    211     blockNo->addIncoming(iBuilder->CreateAdd(blockNo, iBuilder->getInt64(1)), fullBodyBlock);
    212     iBuilder->CreateBr(fullCondBlock);
    213    
    214     iBuilder->SetInsertPoint(finalBlock);
    215     s2pk.createFinalBlockCall(s2pInstance, remainingBytes, {ByteStream.getBlockPointer(blockNo), basisBits});
    216     wck.createFinalBlockCall(wcInstance, remainingBytes, {basisBits});
     176    BasisBits.allocateBuffer();
     177   
     178    Value * s2pInstance = s2pk.createInstance({}, {&ByteStream}, {&BasisBits});;
     179    Value * wcInstance = wck.createInstance({}, {&BasisBits}, {});
     180   
     181    generatePipelineLoop(iBuilder, {&s2pk, &wck}, {s2pInstance, wcInstance}, fileSize);
    217182   
    218183    Value * lineCount = wck.createGetAccumulatorCall(wcInstance, "lineCount");
     
    220185    Value * charCount = wck.createGetAccumulatorCall(wcInstance, "charCount");;
    221186
    222     iBuilder->CreateCall(record_counts_routine, std::vector<Value *>({lineCount, wordCount, charCount, bufferSize, fileIdx}));
     187    iBuilder->CreateCall(record_counts_routine, std::vector<Value *>({lineCount, wordCount, charCount, fileSize, fileIdx}));
    223188   
    224189    iBuilder->CreateRetVoid();
Note: See TracChangeset for help on using the changeset viewer.