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

Minor u8u16 updates, 8-bit p2sKernel with compressed output

File:
1 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);
Note: See TracChangeset for help on using the changeset viewer.