Ignore:
Timestamp:
Jan 5, 2017, 3:54:40 PM (2 years ago)
Author:
nmedfort
Message:

Code clean up to enforce proper calling order of KernelBuilder? methods

File:
1 edited

Legend:

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

    r5238 r5246  
    120120#endif
    121121   
    122 void S2PKernel::generateFinalBlockMethod() {
     122void S2PKernel::generateFinalBlockMethod() const {
    123123    /* Prepare the s2p final block function:
    124124     assumption: if remaining bytes is greater than 0, it is safe to read a full block of bytes.
     
    144144    /* Adjust the produced item count */
    145145    Value * produced = getProducedItemCount(self);
    146     produced = iBuilder->CreateSub(produced, ConstantInt::get(iBuilder->getSizeTy(), iBuilder->getStride()));
     146    produced = iBuilder->CreateSub(produced, iBuilder->getSize(iBuilder->getStride()));
    147147    setProducedItemCount(self, iBuilder->CreateAdd(produced, remainingBytes));
    148148   
     
    161161
    162162   
    163 void S2PKernel::generateDoBlockLogic(Value * self, Value * blockNo) {
     163void S2PKernel::generateDoBlockLogic(Value * self, Value * blockNo) const {
    164164
    165165    Value * byteStream = getStreamSetBlockPtr(self, "byteStream", blockNo);
     
    171171        bytepack[i] = iBuilder->CreateBlockAlignedLoad(ptr);
    172172    }
    173     Value * bitblock[8];
    174     s2p(iBuilder, bytepack, bitblock);
     173    Value * basisbits[8];
     174    s2p(iBuilder, bytepack, basisbits);
    175175    for (unsigned i = 0; i < 8; ++i) {
    176         iBuilder->CreateBlockAlignedStore(bitblock[i], basisBits, {iBuilder->getInt32(0), iBuilder->getInt32(i)});
     176        iBuilder->CreateBlockAlignedStore(basisbits[i], basisBits, {iBuilder->getInt32(0), iBuilder->getInt32(i)});
    177177    }
    178178    Value * produced = getProducedItemCount(self);
    179     produced = iBuilder->CreateAdd(produced, ConstantInt::get(iBuilder->getSizeTy(), iBuilder->getStride()));
     179    produced = iBuilder->CreateAdd(produced, iBuilder->getSize(iBuilder->getStride()));
    180180    setProducedItemCount(self, produced);   
    181181}
    182182   
    183 void S2PKernel::generateDoBlockMethod() {
     183void S2PKernel::generateDoBlockMethod() const {
    184184    auto savePoint = iBuilder->saveIP();
    185185
    186186    Function * doBlockFunction = iBuilder->getModule()->getFunction(mKernelName + doBlock_suffix);
    187187   
    188     iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), "entry", doBlockFunction, 0));
     188    iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), "entry", doBlockFunction));
    189189   
    190190    Value * self = getParameter(doBlockFunction, "self");
     
    196196    iBuilder->restoreIP(savePoint);
    197197}
    198 }
     198
     199S2PKernel::S2PKernel(IDISA::IDISA_Builder * builder)
     200: KernelBuilder(builder, "s2p", {Binding{builder->getStreamSetTy(1, 8), "byteStream"}}, {Binding{builder->getStreamSetTy(8, 1), "basisBits"}}, {}, {}, {}) {
     201
     202}
     203
     204}
Note: See TracChangeset for help on using the changeset viewer.