Ignore:
Timestamp:
Nov 18, 2016, 1:46:55 PM (2 years ago)
Author:
nmedfort
Message:

Merged PabloFunction? and PabloKernel? classes. Updated projects where necessary.

File:
1 edited

Legend:

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

    r5202 r5217  
    6767}
    6868       
    69    
    70 void p2sKernel_withCompressedOutput::prepareKernel() {
    71     KernelBuilder::prepareKernel();
    72 }
    73 
    7469void p2sKernel_withCompressedOutput::generateDoBlockMethod() {
    7570    auto savePoint = iBuilder->saveIP();
     
    109104    iBuilder->restoreIP(savePoint);
    110105}
    111    
    112    
     106
    113107void p2s_16Kernel::generateDoBlockMethod() {
    114108    auto savePoint = iBuilder->saveIP();
     
    140134        Value * merge0 = iBuilder->bitCast(iBuilder->esimd_mergel(8, hi_bytes[j], lo_bytes[j]));
    141135        Value * merge1 = iBuilder->bitCast(iBuilder->esimd_mergeh(8, hi_bytes[j], lo_bytes[j]));
    142         iBuilder->CreateBlockAlignedStore(merge0, i16StreamBlock_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(0), iBuilder->getInt32(2*j)});
    143         iBuilder->CreateBlockAlignedStore(merge1, i16StreamBlock_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(0), iBuilder->getInt32(2*j+1)});
    144     }
    145     iBuilder->CreateRetVoid();
    146     iBuilder->restoreIP(savePoint);
    147 }
    148        
    149 
    150 void p2s_16Kernel_withCompressedOutput::prepareKernel() {
    151     KernelBuilder::prepareKernel();
    152 }
    153    
     136        // iBuilder->getInt32(0),
     137        iBuilder->CreateBlockAlignedStore(merge0, i16StreamBlock_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(2*j)});
     138        iBuilder->CreateBlockAlignedStore(merge1, i16StreamBlock_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(2*j+1)});
     139    }
     140    iBuilder->CreateRetVoid();
     141    iBuilder->restoreIP(savePoint);
     142}
    154143
    155144void p2s_16Kernel_withCompressedOutput::generateDoBlockMethod() {
    156145    auto savePoint = iBuilder->saveIP();
    157146    Module * m = iBuilder->getModule();
    158     Type * i32 = iBuilder->getIntNTy(32); 
    159     Type * bitBlockPtrTy = llvm::PointerType::get(iBuilder->getBitBlockType(), 0); 
    160 
    161     Function * doBlockFunction = m->getFunction(mKernelName + doBlock_suffix);
    162    
     147    Type * i32 = iBuilder->getIntNTy(32);
     148    Type * bitBlockPtrTy = llvm::PointerType::get(iBuilder->getBitBlockType(), 0);
     149
     150    Function * doBlockFunction = m->getFunction(mKernelName + doBlock_suffix);
     151
    163152    iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), "entry", doBlockFunction, 0));
    164153    Constant * stride = ConstantInt::get(iBuilder->getSizeTy(), iBuilder->getStride());
     
    170159    Value * i16UnitsGenerated = getProducedItemCount(self); // units generated to buffer
    171160    Value * i16BlockNo = iBuilder->CreateUDiv(i16UnitsGenerated, stride);
    172    
     161
    173162    Value * i16StreamBase_ptr = iBuilder->CreateBitCast(getStreamSetBlockPtr(self, "i16Stream", i16BlockNo), PointerType::get(iBuilder->getInt16Ty(), 0));
    174    
     163
    175164    Value * u16_output_ptr = iBuilder->CreateGEP(i16StreamBase_ptr, iBuilder->CreateURem(i16UnitsGenerated, stride));
    176165
    177    
     166
    178167    Value * hi_input[8];
    179168    for (unsigned j = 0; j < 8; ++j) {
     
    182171    Value * hi_bytes[8];
    183172    p2s(iBuilder, hi_input, hi_bytes);
    184    
     173
    185174    Value * lo_input[8];
    186175    for (unsigned j = 0; j < 8; ++j) {
     
    189178    Value * lo_bytes[8];
    190179    p2s(iBuilder, lo_input, lo_bytes);
    191    
    192     unsigned UTF_16_units_per_register = iBuilder->getBitBlockWidth()/16;
    193    
     180
     181    const auto UTF_16_units_per_register = iBuilder->getBitBlockWidth() / 16;
     182
    194183    Value * unit_counts = iBuilder->fwCast(UTF_16_units_per_register, iBuilder->CreateBlockAlignedLoad(delCountBlock_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(0)}));
    195    
     184
    196185    Value * offset = ConstantInt::get(i32, 0);
    197    
     186
    198187    for (unsigned j = 0; j < 8; ++j) {
    199188        Value * merge0 = iBuilder->bitCast(iBuilder->esimd_mergel(8, hi_bytes[j], lo_bytes[j]));
    200189        Value * merge1 = iBuilder->bitCast(iBuilder->esimd_mergeh(8, hi_bytes[j], lo_bytes[j]));
    201         //iBuilder->CallPrintRegister("merge0", merge0);
    202190        iBuilder->CreateAlignedStore(merge0, iBuilder->CreateBitCast(iBuilder->CreateGEP(u16_output_ptr, offset), bitBlockPtrTy), 1);
    203191        offset = iBuilder->CreateZExt(iBuilder->CreateExtractElement(unit_counts, iBuilder->getInt32(2*j)), i32);
    204         //iBuilder->CallPrintInt("offset", offset);
    205192        iBuilder->CreateAlignedStore(merge1, iBuilder->CreateBitCast(iBuilder->CreateGEP(u16_output_ptr, offset), bitBlockPtrTy), 1);
    206         //iBuilder->CallPrintRegister("merge1", merge1);
    207193        offset = iBuilder->CreateZExt(iBuilder->CreateExtractElement(unit_counts, iBuilder->getInt32(2*j+1)), i32);
    208         //iBuilder->CallPrintInt("offset", offset);
    209     }
    210    
     194    }
     195
    211196    i16UnitsGenerated = iBuilder->CreateAdd(i16UnitsGenerated, iBuilder->CreateZExt(offset, iBuilder->getSizeTy()));
    212197    setProducedItemCount(self, i16UnitsGenerated);
Note: See TracChangeset for help on using the changeset viewer.