Ignore:
Timestamp:
Jun 27, 2016, 9:43:17 AM (3 years ago)
Author:
cameron
Message:

Updates for kernels with variable output length; stdout kernel

File:
1 edited

Legend:

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

    r5074 r5076  
    3333#include <kernels/p2s_kernel.h>
    3434#include <kernels/deletion.h>
     35#include <kernels/stdout_kernel.h>
    3536
    3637#include <utf_encoding.h>
     
    220221using namespace kernel;
    221222
     223const unsigned u16OutputBlocks = 16;
    222224
    223225Function * u8u16Pipeline(Module * mMod, IDISA::IDISA_Builder * iBuilder, pablo::PabloFunction * function) {
     
    237239    p2sk.generateKernel();
    238240   
     241    stdOutKernel stdOutK(iBuilder, 16);
     242    stdOutK.generateKernel();
     243   
    239244    Type * const int64ty = iBuilder->getInt64Ty();
     245    Type * i16PtrTy = PointerType::get(iBuilder->getInt16Ty(), 0);
    240246    Type * const voidTy = Type::getVoidTy(mMod->getContext());
    241247    Type * const inputType = PointerType::get(ArrayType::get(ArrayType::get(mBitBlockType, 8), 1), 0);
     
    263269    StreamSetBuffer U16Bits(iBuilder, StreamSetType(16, 1), 1);
    264270    StreamSetBuffer DeletionCounts(iBuilder, StreamSetType(1, 1), 1);
    265     StreamSetBuffer U16out(iBuilder, StreamSetType(1, 16), 1);
     271    StreamSetBuffer U16out(iBuilder, StreamSetType(1, 16), u16OutputBlocks);
    266272
    267273    ByteStream.setStreamSetBuffer(inputStream);
     
    276282    Value * delInstance = delK.createInstance({});
    277283    Value * p2sInstance = p2sk.createInstance({});
     284    Value * stdOutInstance = stdOutK.createInstance({u16out, iBuilder->CreateGEP(u16out, {iBuilder->getInt32(u16OutputBlocks-2)})});
    278285   
    279286    Value * initialBufferSize = bufferSize;
     
    289296    PHINode * blockNo = iBuilder->CreatePHI(int64ty, 2, "blockNo");
    290297    blockNo->addIncoming(initialBlockNo, initialBlock);
     298    PHINode * outputBuffer = iBuilder->CreatePHI(PointerType::get(U16out.getStreamSetBlockType(), 0), 2, "outputBuffer");
     299    outputBuffer->addIncoming(u16out, initialBlock);
    291300   
    292301    Constant * const step = ConstantInt::get(int64ty, mBlockSize);
     
    299308    u8u16k.createDoBlockCall(u8u16Instance, {basisBits, u8u16Bits});
    300309    delK.createDoBlockCall(delInstance, {u8u16Bits, u16Bits, delCounts});
    301     p2sk.createDoBlockCall(p2sInstance, {u16Bits, delCounts, u16out});
     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});
    302313   
    303314    Value * diff = iBuilder->CreateSub(remainingBytes, step);
     
    305316    remainingBytes->addIncoming(diff, fullBodyBlock);
    306317    blockNo->addIncoming(iBuilder->CreateAdd(blockNo, iBuilder->getInt64(1)), fullBodyBlock);
     318    outputBuffer->addIncoming(u16out_next, fullBodyBlock);
    307319    iBuilder->CreateBr(fullCondBlock);
    308320   
     
    311323    u8u16k.createFinalBlockCall(u8u16Instance, remainingBytes, {basisBits, u8u16Bits});
    312324    delK.createFinalBlockCall(delInstance, remainingBytes, {u8u16Bits, u16Bits, delCounts});
    313     p2sk.createFinalBlockCall(p2sInstance, remainingBytes, {u16Bits, delCounts, u16out});
    314    
    315    
     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
    316329    iBuilder->CreateRetVoid();
    317330    return main;
Note: See TracChangeset for help on using the changeset viewer.