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/editd/editd_cpu_kernel.cpp

    r5238 r5246  
    1212using namespace llvm;
    1313
    14 void editdCPUKernel::bitblock_advance_ci_co(Value * val, unsigned shift, Value * stideCarryArr, unsigned carryIdx, std::vector<std::vector<Value *>> & adv, std::vector<std::vector<int>> & calculated, int i, int j){   
    15     if(!calculated[i][j]){
     14void editdCPUKernel::bitblock_advance_ci_co(Value * val, unsigned shift, Value * stideCarryArr, unsigned carryIdx, std::vector<std::vector<Value *>> & adv, std::vector<std::vector<int>> & calculated, int i, int j) const {
     15    if (calculated[i][j] == 0) {
    1616        Value * ptr = iBuilder->CreateGEP(stideCarryArr, {iBuilder->getInt32(0), iBuilder->getInt32(carryIdx)});
    1717        Value * ci = iBuilder->CreateLoad(ptr);
     
    2121        calculated[i][j] = 1;
    2222    }
    23     return;
    2423}
    2524
    26 void editdCPUKernel::generateFinalBlockMethod() {
     25void editdCPUKernel::generateFinalBlockMethod() const {
    2726    IDISA::IDISA_Builder::InsertPoint savePoint = iBuilder->saveIP();
    2827    Module * m = iBuilder->getModule();
     
    4241    /* Adjust the produced item count */
    4342    Value * produced = getProducedItemCount(self);
    44     produced = iBuilder->CreateSub(produced, ConstantInt::get(iBuilder->getSizeTy(), iBuilder->getStride()));
     43    produced = iBuilder->CreateSub(produced, iBuilder->getSize(iBuilder->getStride()));
    4544    setProducedItemCount(self, iBuilder->CreateAdd(produced, remaining));
    4645    iBuilder->CreateRetVoid();
     
    4847}
    4948   
    50 void editdCPUKernel::generateDoBlockMethod() {
     49void editdCPUKernel::generateDoBlockMethod() const {
    5150    IDISA::IDISA_Builder::InsertPoint savePoint = iBuilder->saveIP();
    5251    Module * m = iBuilder->getModule(); 
     
    6766    Value * ccStreamPtr = getStreamSetBlockPtr(kernelStuctParam, "CCStream", blockNo);
    6867    Value * resultStreamPtr = getStreamSetBlockPtr(kernelStuctParam, "ResultStream", blockNo);
    69     Value * pattPos = ConstantInt::get(int32ty, 0);
     68
    7069   
    7170    unsigned carryIdx = 0;
     
    7372    std::vector<std::vector<Value *>> e(mPatternLen+1, std::vector<Value *>(mEditDistance+1));
    7473    std::vector<std::vector<Value *>> adv(mPatternLen, std::vector<Value *>(mEditDistance+1));
    75     std::vector<std::vector<int>> calculated(mPatternLen, std::vector<int>(mEditDistance+1));
    76     for(unsigned i=0; i<mPatternLen; i++)
    77         for(unsigned j=0; j<=mEditDistance; j++)
    78             calculated[i][j] = 0;
    79     Value * pattPtr = iBuilder->CreateGEP(pattStartPtr, {pattPos});
     74    std::vector<std::vector<int>> calculated(mPatternLen, std::vector<int>(mEditDistance + 1, 0));
     75    Value * pattPos = iBuilder->getInt32(0);
     76    Value * pattPtr = iBuilder->CreateGEP(pattStartPtr, pattPos);
    8077    Value * pattCh = iBuilder->CreateLoad(pattPtr);
    8178    Value * pattIdx = iBuilder->CreateAnd(iBuilder->CreateLShr(pattCh, 1), ConstantInt::get(int8ty, 3));
     
    9087
    9188    for(unsigned i = 1; i<mPatternLen; i++){     
    92         pattPtr = iBuilder->CreateGEP(pattStartPtr, {pattPos});
     89        pattPtr = iBuilder->CreateGEP(pattStartPtr, pattPos);
    9390        pattCh = iBuilder->CreateLoad(pattPtr);
    9491        pattIdx = iBuilder->CreateAnd(iBuilder->CreateLShr(pattCh, 1), ConstantInt::get(int8ty, 3));
     
    119116
    120117    Value * produced = getProducedItemCount(kernelStuctParam);
    121     produced = iBuilder->CreateAdd(produced, ConstantInt::get(iBuilder->getSizeTy(), iBuilder->getStride()));
     118    produced = iBuilder->CreateAdd(produced, iBuilder->getSize(iBuilder->getStride()));
    122119    setProducedItemCount(kernelStuctParam, produced);
    123120       
Note: See TracChangeset for help on using the changeset viewer.