Changeset 5079 for icGREP


Ignore:
Timestamp:
Jun 30, 2016, 2:29:44 PM (3 years ago)
Author:
cameron
Message:

Minor u8u16 updates, 8-bit p2sKernel with compressed output

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

Legend:

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

    r5076 r5079  
    6464}
    6565       
     66   
     67void p2sKernel_withCompressedOutput::prepareKernel() {
     68    setDoBlockReturnType(iBuilder->getInt32Ty());
     69    KernelBuilder::prepareKernel();
     70}
     71
     72void p2sKernel_withCompressedOutput::generateDoBlockMethod() {
     73    IDISA::IDISA_Builder::InsertPoint savePoint = iBuilder->saveIP();
     74    Module * m = iBuilder->getModule();
     75    Type * i8PtrTy = iBuilder->getInt8PtrTy();
     76    Type * i32 = iBuilder->getIntNTy(32);
     77    Type * bitBlockPtrTy = llvm::PointerType::get(iBuilder->getBitBlockType(), 0);
     78   
     79    Function * doBlockFunction = m->getFunction(mKernelName + doBlock_suffix);
     80   
     81    iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), "entry", doBlockFunction, 0));
     82   
     83    Value * basisBitsBlock_ptr = getParameter(doBlockFunction, "basisBits");  // input
     84    Value * delCountBlock_ptr = getParameter(doBlockFunction, "deletionCounts");
     85    Value * byteStreamBlock_ptr = getParameter(doBlockFunction, "byteStream"); // output
     86   
     87    Value * p_bitblock[8];
     88    for (unsigned i = 0; i < 8; i++) {
     89        p_bitblock[i] = iBuilder->CreateBlockAlignedLoad(basisBitsBlock_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(i)});
     90    }
     91    Value * s_bytepack[8];
     92    p2s(iBuilder, p_bitblock, s_bytepack);
     93   
     94    unsigned units_per_register = iBuilder->getBitBlockWidth()/8;
     95   
     96    Value * unit_counts = iBuilder->fwCast(units_per_register, iBuilder->CreateBlockAlignedLoad(delCountBlock_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(0)}));
     97   
     98    Value * output_ptr = iBuilder->CreateBitCast(byteStreamBlock_ptr, i8PtrTy);
     99    Value * offset = ConstantInt::get(i32, 0);
     100   
     101    for (unsigned j = 0; j < 8; ++j) {
     102        iBuilder->CreateAlignedStore(s_bytepack[j], iBuilder->CreateBitCast(iBuilder->CreateGEP(output_ptr, offset), bitBlockPtrTy), 1);
     103        offset = iBuilder->CreateZExt(iBuilder->CreateExtractElement(unit_counts, iBuilder->getInt32(j)), i32);
     104    }
     105    iBuilder->CreateRet(offset);
     106    iBuilder->restoreIP(savePoint);
     107}
     108   
     109   
    66110void p2s_16Kernel::generateDoBlockMethod() {
    67111    IDISA::IDISA_Builder::InsertPoint savePoint = iBuilder->saveIP();
     
    99143}
    100144       
    101    
    102 void p2s_16Kernel_withCompressedOutputKernel::prepareKernel() {
     145
     146void p2s_16Kernel_withCompressedOutput::prepareKernel() {
    103147    setDoBlockReturnType(iBuilder->getInt32Ty());
    104148    KernelBuilder::prepareKernel();
    105149}
    106150   
    107 void p2s_16Kernel_withCompressedOutputKernel::generateDoBlockMethod() {
    108     IDISA::IDISA_Builder::InsertPoint savePoint = iBuilder->saveIP();
    109     Module * m = iBuilder->getModule();
    110     Type * i8PtrTy = iBuilder->getInt8PtrTy();
     151void p2s_16Kernel_withCompressedOutput::generateDoBlockMethod() {
     152    IDISA::IDISA_Builder::InsertPoint savePoint = iBuilder->saveIP();
     153    Module * m = iBuilder->getModule();
    111154    Type * i32 = iBuilder->getIntNTy(32);
    112155    Type * bitBlockPtrTy = llvm::PointerType::get(iBuilder->getBitBlockType(), 0);
  • icGREP/icgrep-devel/icgrep/kernels/p2s_kernel.h

    r5076 r5079  
    3737};
    3838
     39class p2sKernel_withCompressedOutput : public KernelBuilder {
     40public:
     41    p2sKernel_withCompressedOutput(IDISA::IDISA_Builder * iBuilder) :
     42    KernelBuilder(iBuilder, "p2s_compress",
     43                  {StreamSetBinding{StreamSetType(8, 1), "basisBits"}, StreamSetBinding{StreamSetType(1, 1), "deletionCounts"}},
     44                  {StreamSetBinding{StreamSetType(1, 8), "byteStream"}},
     45                  {}, {}, {}) {}
     46   
     47private:
     48    void prepareKernel() override;
     49    void generateDoBlockMethod() override;
     50};
     51   
     52
    3953class p2s_16Kernel : public KernelBuilder {
    4054public:
     
    5165
    5266   
    53 class p2s_16Kernel_withCompressedOutputKernel : public KernelBuilder {
     67class p2s_16Kernel_withCompressedOutput : public KernelBuilder {
    5468public:
    55     p2s_16Kernel_withCompressedOutputKernel(IDISA::IDISA_Builder * iBuilder) :
     69    p2s_16Kernel_withCompressedOutput(IDISA::IDISA_Builder * iBuilder) :
    5670    KernelBuilder(iBuilder, "p2s_16_compress",
    5771                  {StreamSetBinding{StreamSetType(16, 1), "basisBits"}, StreamSetBinding{StreamSetType(1, 1), "deletionCounts"}},
  • icGREP/icgrep-devel/icgrep/u8u16.cpp

    r5078 r5079  
    221221using namespace kernel;
    222222
    223 const unsigned u16OutputBlocks = 256;
     223const unsigned u16OutputBlocks = 64;
    224224
    225225Function * u8u16Pipeline(Module * mMod, IDISA::IDISA_Builder * iBuilder, pablo::PabloFunction * function) {
     
    236236    delK.generateKernel();
    237237   
    238     p2s_16Kernel_withCompressedOutputKernel p2sk(iBuilder);   
     238    p2s_16Kernel_withCompressedOutput p2sk(iBuilder);   
    239239    p2sk.generateKernel();
    240240   
     
    247247    Type * const inputType = PointerType::get(ArrayType::get(ArrayType::get(mBitBlockType, 8), 1), 0);
    248248   
    249     Function * const main = cast<Function>(mMod->getOrInsertFunction("Main", Type::getVoidTy(mMod->getContext()), inputType, int64ty, nullptr));
     249    Function * const main = cast<Function>(mMod->getOrInsertFunction("Main", voidTy, inputType, int64ty, nullptr));
    250250    main->setCallingConv(CallingConv::C);
    251251    Function::arg_iterator args = main->arg_begin();
Note: See TracChangeset for help on using the changeset viewer.