Ignore:
Timestamp:
Jul 16, 2016, 6:51:39 PM (3 years ago)
Author:
cameron
Message:

Set names and attributes for doSegment functions

File:
1 edited

Legend:

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

    r5079 r5095  
    2828#include <IDISA/idisa_builder.h>
    2929#include <IDISA/idisa_target.h>
     30#include <kernels/pipeline.h>
    3031#include <kernels/interface.h>
    3132#include <kernels/kernel.h>
     
    225226Function * u8u16Pipeline(Module * mMod, IDISA::IDISA_Builder * iBuilder, pablo::PabloFunction * function) {
    226227    Type * mBitBlockType = iBuilder->getBitBlockType();
    227     unsigned mBlockSize = iBuilder->getBitBlockWidth();
    228228    s2pKernel  s2pk(iBuilder);
    229229    s2pk.generateKernel();
     
    253253    Value * const inputStream = &*(args++);
    254254    inputStream->setName("input");
    255     Value * const bufferSize = &*(args++);
    256     bufferSize->setName("bufferSize");
     255    Value * const fileSize = &*(args++);
     256    fileSize->setName("fileSize");
    257257   
    258258    iBuilder->SetInsertPoint(BasicBlock::Create(mMod->getContext(), "entry", main,0));
    259    
    260     BasicBlock * entryBlock = iBuilder->GetInsertBlock();
    261    
    262     BasicBlock * fullCondBlock = BasicBlock::Create(mMod->getContext(), "fullCond", main, 0);
    263     BasicBlock * fullBodyBlock = BasicBlock::Create(mMod->getContext(), "fullBody", main, 0);
    264     BasicBlock * finalBlock = BasicBlock::Create(mMod->getContext(), "final", main, 0);
    265    
    266     StreamSetBuffer ByteStream(iBuilder, StreamSetType(1, 8), 0);
    267     StreamSetBuffer BasisBits(iBuilder, StreamSetType(8, 1), 1);
    268     StreamSetBuffer U8u16Bits(iBuilder, StreamSetType(18, 1), 1);
    269     StreamSetBuffer U16Bits(iBuilder, StreamSetType(16, 1), 1);
    270     StreamSetBuffer DeletionCounts(iBuilder, StreamSetType(1, 1), 1);
    271     StreamSetBuffer U16out(iBuilder, StreamSetType(1, 16), u16OutputBlocks);
     259       
     260    kernel::StreamSetBuffer ByteStream(iBuilder, StreamSetType(1, 8), 0);
     261    kernel::StreamSetBuffer BasisBits(iBuilder, StreamSetType(8, 1), 1);
     262    kernel::StreamSetBuffer U8u16Bits(iBuilder, StreamSetType(18, 1), 1);
     263    kernel::StreamSetBuffer U16Bits(iBuilder, StreamSetType(16, 1), 1);
     264    kernel::StreamSetBuffer DeletionCounts(iBuilder, StreamSetType(1, 1), 1);
     265    kernel::StreamSetBuffer U16out(iBuilder, StreamSetType(1, 16), u16OutputBlocks);
    272266
    273267    ByteStream.setStreamSetBuffer(inputStream);
    274     Value * basisBits = BasisBits.allocateBuffer();
    275     Value * u8u16Bits = U8u16Bits.allocateBuffer();
    276     Value * u16Bits = U16Bits.allocateBuffer();
    277     Value * delCounts = DeletionCounts.allocateBuffer();
     268    BasisBits.allocateBuffer();
     269    U8u16Bits.allocateBuffer();
     270    U16Bits.allocateBuffer();
     271    DeletionCounts.allocateBuffer();
    278272    Value * u16out = U16out.allocateBuffer();
    279273   
    280     Value * s2pInstance = s2pk.createInstance({});
    281     Value * u8u16Instance = u8u16k.createInstance({});
    282     Value * delInstance = delK.createInstance({});
    283     Value * p2sInstance = p2sk.createInstance({});
    284     Value * stdOutInstance = stdOutK.createInstance({u16out, iBuilder->CreateGEP(u16out, {iBuilder->getInt32(u16OutputBlocks-2)})});
    285    
    286     Value * initialBufferSize = bufferSize;
    287     BasicBlock * initialBlock = entryBlock;
    288     Value * initialBlockNo = iBuilder->getInt64(0);
    289    
    290     iBuilder->CreateBr(fullCondBlock);
    291    
    292    
    293     iBuilder->SetInsertPoint(fullCondBlock);
    294     PHINode * remainingBytes = iBuilder->CreatePHI(int64ty, 2, "remainingBytes");
    295     remainingBytes->addIncoming(initialBufferSize, initialBlock);
    296     PHINode * blockNo = iBuilder->CreatePHI(int64ty, 2, "blockNo");
    297     blockNo->addIncoming(initialBlockNo, initialBlock);
    298     PHINode * outputBuffer = iBuilder->CreatePHI(PointerType::get(U16out.getStreamSetBlockType(), 0), 2, "outputBuffer");
    299     outputBuffer->addIncoming(u16out, initialBlock);
    300    
    301     Constant * const step = ConstantInt::get(int64ty, mBlockSize);
    302     Value * fullCondTest = iBuilder->CreateICmpULT(remainingBytes, step);
    303     iBuilder->CreateCondBr(fullCondTest, finalBlock, fullBodyBlock);
    304    
    305     iBuilder->SetInsertPoint(fullBodyBlock);
    306    
    307     s2pk.createDoBlockCall(s2pInstance, {ByteStream.getBlockPointer(blockNo), basisBits});
    308     u8u16k.createDoBlockCall(u8u16Instance, {basisBits, u8u16Bits});
    309     delK.createDoBlockCall(delInstance, {u8u16Bits, u16Bits, delCounts});
    310     Value * units_generated = p2sk.createDoBlockCall(p2sInstance, {u16Bits, delCounts, outputBuffer});
    311     Value * u16out_next = iBuilder->CreateBitCast(iBuilder->CreateGEP(iBuilder->CreateBitCast(outputBuffer, i16PtrTy), units_generated), outputBuffer->getType());
    312     u16out_next = stdOutK.createDoBlockCall(stdOutInstance, {u16out_next});
    313    
    314     Value * diff = iBuilder->CreateSub(remainingBytes, step);
    315    
    316     remainingBytes->addIncoming(diff, fullBodyBlock);
    317     blockNo->addIncoming(iBuilder->CreateAdd(blockNo, iBuilder->getInt64(1)), fullBodyBlock);
    318     outputBuffer->addIncoming(u16out_next, fullBodyBlock);
    319     iBuilder->CreateBr(fullCondBlock);
    320    
    321     iBuilder->SetInsertPoint(finalBlock);
    322     s2pk.createFinalBlockCall(s2pInstance, remainingBytes, {ByteStream.getBlockPointer(blockNo), basisBits});
    323     u8u16k.createFinalBlockCall(u8u16Instance, remainingBytes, {basisBits, u8u16Bits});
    324     delK.createFinalBlockCall(delInstance, remainingBytes, {u8u16Bits, u16Bits, delCounts});
    325     units_generated = p2sk.createFinalBlockCall(p2sInstance, remainingBytes, {u16Bits, delCounts, outputBuffer});
    326     u16out_next = iBuilder->CreateBitCast(iBuilder->CreateGEP(iBuilder->CreateBitCast(outputBuffer, i16PtrTy), units_generated), outputBuffer->getType());
    327     stdOutK.createFinalBlockCall(stdOutInstance, remainingBytes, {u16out_next});
    328 
     274    Value * s2pInstance = s2pk.createInstance({}, {&ByteStream}, {&BasisBits});
     275    Value * u8u16Instance = u8u16k.createInstance({}, {&BasisBits}, {&U8u16Bits});
     276    Value * delInstance = delK.createInstance({}, {&U8u16Bits}, {&U16Bits, &DeletionCounts});
     277    Value * p2sInstance = p2sk.createInstance({}, {&U16Bits, &DeletionCounts}, {&U16out});
     278    Value * stdOutInstance = stdOutK.createInstance({u16out, iBuilder->CreateGEP(u16out, {iBuilder->getInt32(u16OutputBlocks-2)})}, {&U16out}, {});
     279   
     280    generatePipelineLoop(iBuilder, {&s2pk, &u8u16k, &delK, &p2sk, &stdOutK}, {s2pInstance, u8u16Instance, delInstance, p2sInstance, stdOutInstance}, fileSize);
     281   
    329282    iBuilder->CreateRetVoid();
    330283    return main;
Note: See TracChangeset for help on using the changeset viewer.