Ignore:
Timestamp:
Oct 25, 2017, 4:57:58 PM (19 months ago)
Author:
nmedfort
Message:

First stage of MultiBlockKernel? and pipeline restructuring

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/p2s_kernel.cpp

    r5440 r5706  
    11#include "p2s_kernel.h"
    2 //#include "llvm/IR/Constant.h"      // for Constant
    3 //#include "llvm/IR/Constants.h"     // for ConstantInt
    4 //#include "llvm/IR/DerivedTypes.h"  // for PointerType, VectorType
    5 //#include "llvm/IR/Function.h"      // for Function, Function::arg_iterator
    6 //#include <llvm/IR/Module.h>
    72#include <kernels/streamset.h>
    83#include <kernels/kernel_builder.h>
     
    107102    PointerType * int16PtrTy = iBuilder->getInt16Ty()->getPointerTo();
    108103    PointerType * bitBlockPtrTy = iBuilder->getBitBlockType()->getPointerTo();
    109     ConstantInt * stride = iBuilder->getSize(iBuilder->getStride());
     104    ConstantInt * blockMask = iBuilder->getSize(iBuilder->getBitBlockWidth() - 1);
    110105
    111106    Value * hi_input[8];
     
    123118    p2s(iBuilder, lo_input, lo_bytes);
    124119
    125     Value * delCountBlock_ptr = iBuilder->getInputStreamBlockPtr("deletionCounts", iBuilder->getInt32(0));
    126     Value * unit_counts = iBuilder->fwCast(iBuilder->getBitBlockWidth() / 16, iBuilder->CreateBlockAlignedLoad(delCountBlock_ptr));
    127 
    128 
    129     Value * u16_output_ptr = iBuilder->getOutputStreamBlockPtr("i16Stream", iBuilder->getInt32(0));
    130     u16_output_ptr = iBuilder->CreatePointerCast(u16_output_ptr, int16PtrTy);
     120    Value * delCount = iBuilder->loadInputStreamBlock("deletionCounts", iBuilder->getInt32(0));
     121    Value * unitCounts = iBuilder->fwCast(iBuilder->getBitBlockWidth() / 16, delCount);
     122    Value * outputPtr = iBuilder->getOutputStreamBlockPtr("i16Stream", iBuilder->getInt32(0));
     123    outputPtr = iBuilder->CreatePointerCast(outputPtr, int16PtrTy);
    131124    Value * i16UnitsGenerated = iBuilder->getProducedItemCount("i16Stream"); // units generated to buffer
    132     u16_output_ptr = iBuilder->CreateGEP(u16_output_ptr, iBuilder->CreateURem(i16UnitsGenerated, stride));
     125    outputPtr = iBuilder->CreateGEP(outputPtr, iBuilder->CreateAnd(i16UnitsGenerated, blockMask));
    133126
    134127    Value * offset = ConstantInt::get(i32Ty, 0);
     
    136129    for (unsigned j = 0; j < 8; ++j) {
    137130        Value * merge0 = iBuilder->bitCast(iBuilder->esimd_mergel(8, hi_bytes[j], lo_bytes[j]));
    138         iBuilder->CreateAlignedStore(merge0, iBuilder->CreateBitCast(iBuilder->CreateGEP(u16_output_ptr, offset), bitBlockPtrTy), 1);
    139         offset = iBuilder->CreateZExt(iBuilder->CreateExtractElement(unit_counts, iBuilder->getInt32(2 * j)), i32Ty);
     131        iBuilder->CreateAlignedStore(merge0, iBuilder->CreateBitCast(iBuilder->CreateGEP(outputPtr, offset), bitBlockPtrTy), 1);
     132        offset = iBuilder->CreateZExt(iBuilder->CreateExtractElement(unitCounts, iBuilder->getInt32(2 * j)), i32Ty);
    140133
    141134        Value * merge1 = iBuilder->bitCast(iBuilder->esimd_mergeh(8, hi_bytes[j], lo_bytes[j]));
    142         iBuilder->CreateAlignedStore(merge1, iBuilder->CreateBitCast(iBuilder->CreateGEP(u16_output_ptr, offset), bitBlockPtrTy), 1);
    143         offset = iBuilder->CreateZExt(iBuilder->CreateExtractElement(unit_counts, iBuilder->getInt32(2 * j + 1)), i32Ty);
    144     }   
     135        iBuilder->CreateAlignedStore(merge1, iBuilder->CreateBitCast(iBuilder->CreateGEP(outputPtr, offset), bitBlockPtrTy), 1);
     136        offset = iBuilder->CreateZExt(iBuilder->CreateExtractElement(unitCounts, iBuilder->getInt32(2 * j + 1)), i32Ty);
     137    }
     138
    145139    Value * i16UnitsFinal = iBuilder->CreateAdd(i16UnitsGenerated, iBuilder->CreateZExt(offset, iBuilder->getSizeTy()));
    146140    iBuilder->setProducedItemCount("i16Stream", i16UnitsFinal);
     
    157151: BlockOrientedKernel("p2s_compress",
    158152              {Binding{iBuilder->getStreamSetTy(8, 1), "basisBits"}, Binding{iBuilder->getStreamSetTy(1, 1), "deletionCounts"}},
    159                       {Binding{iBuilder->getStreamSetTy(1, 8), "byteStream", MaxRatio(1)}},
     153              {Binding{iBuilder->getStreamSetTy(1, 8), "byteStream", BoundedRate(0, 1)}},
    160154              {}, {}, {}) {
    161155}
     
    172166: BlockOrientedKernel("p2s_16_compress",
    173167              {Binding{b->getStreamSetTy(16, 1), "basisBits"}, Binding{b->getStreamSetTy(1, 1), "deletionCounts"}},
    174               {Binding{b->getStreamSetTy(1, 16), "i16Stream", MaxRatio(1)}},
     168              {Binding{b->getStreamSetTy(1, 16), "i16Stream", BoundedRate(0, 1)}},
    175169              {},
    176170              {},
Note: See TracChangeset for help on using the changeset viewer.