Ignore:
Timestamp:
Dec 13, 2016, 2:40:30 PM (3 years ago)
Author:
lindanl
Message:

Some fixes.

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/CMakeLists.txt

    r5218 r5223  
    214214  COMMAND ./run_all ${CMAKE_BINARY_DIR}/u8u16)
    215215
     216add_custom_target (editd_test
     217  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
     218  COMMAND python run_all.py)
     219
    216220add_custom_target (abc_test
    217221  COMMAND python2 abc_testgen.py
  • icGREP/icgrep-devel/icgrep/editd/editd.cpp

    r5221 r5223  
    6161static cl::opt<int> stepSize("step-size", cl::desc("Step Size"), cl::init(3));
    6262static cl::opt<int> prefixLen("prefix", cl::desc("Prefix length"), cl::init(4));
     63static cl::opt<bool> ShowPositions("display", cl::desc("Display the match positions."), cl::init(false));
    6364
    6465using namespace kernel;
     
    110111    }
    111112
    112     std::cerr << "pattern_segs = " << pattern_segs << ", total_len = " << total_len << std::endl;
     113    std::cout << "pattern_segs = " << pattern_segs << ", total_len = " << total_len << std::endl;
    113114
    114115    int v = pattern_segs * (editDistance+1) - total_len * errRate;
     
    131132        }
    132133    }
    133     std::cout << "matching value is " << v << std::endl;
     134
    134135    std::cout << "total candidate from the first filter is " << matchList.size() << std::endl;
    135136    std::cout << "total candidate from the second filter is " << count << std::endl;
     
    142143        curMatch.dist = dist;
    143144        matchList.push_back(curMatch);
    144         // std::cout << "pos: " << match_pos << ", dist:" << dist << "\n";
     145        if(ShowPositions)
     146            std::cout << "pos: " << match_pos << ", dist:" << dist << "\n";
    145147    }
    146148
     
    602604    MatchResults.setStreamSetBuffer(inputStream, fileSize);
    603605   
    604     generatePipelineLoop(iBuilder, {&editdScanK}, fileSize);
     606    generatePipelineLoop(iBuilder, {&editdScanK});
    605607       
    606608    iBuilder->CreateRetVoid();
  • icGREP/icgrep-devel/icgrep/editd/editd_cpu_kernel.cpp

    r5212 r5223  
    1212using namespace llvm;
    1313
    14 Value * bitblock_advance_ci_co_cpu(IDISA::IDISA_Builder * iBuilder, Value * val, unsigned shift, Value * stideCarryArr, unsigned carryIdx){   
    15     Value * ptr = iBuilder->CreateGEP(stideCarryArr, {iBuilder->getInt32(0), iBuilder->getInt32(carryIdx)});
    16     Value * ci = iBuilder->CreateLoad(ptr);
    17     std::pair<Value *, Value *> rslt = iBuilder->bitblock_advance(val, ci, shift);
    18     iBuilder->CreateStore(std::get<0>(rslt), ptr);
    19     return std::get<1>(rslt);
     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){   
     15    if(!calculated[i][j]){
     16        Value * ptr = iBuilder->CreateGEP(stideCarryArr, {iBuilder->getInt32(0), iBuilder->getInt32(carryIdx)});
     17        Value * ci = iBuilder->CreateLoad(ptr);
     18        std::pair<Value *, Value *> rslt = iBuilder->bitblock_advance(val, ci, shift);
     19        iBuilder->CreateStore(std::get<0>(rslt), ptr);
     20        adv[i][j] = std::get<1>(rslt);
     21        calculated[i][j] = 1;
     22    }
     23    return;
    2024}
    2125
     
    6872
    6973    std::vector<std::vector<Value *>> e(mPatternLen+1, std::vector<Value *>(mEditDistance+1));
     74    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;
    7079    Value * pattPtr = iBuilder->CreateGEP(pattStartPtr, {pattPos});
    7180    Value * pattCh = iBuilder->CreateLoad(pattPtr);
     
    8796        pattStream = iBuilder->CreateLoad(pattStreamPtr);
    8897
    89         Value * adv = bitblock_advance_ci_co_cpu(iBuilder, e[i-1][0], 1, stideCarryArr, carryIdx++);
    90         e[i][0] = iBuilder->CreateAnd(adv, pattStream);
     98        bitblock_advance_ci_co(e[i-1][0], 1, stideCarryArr, carryIdx++, adv, calculated, i-1, 0);
     99        e[i][0] = iBuilder->CreateAnd(adv[i-1][0], pattStream);
    91100        for(unsigned j = 1; j<= mEditDistance; j++){
    92             Value * adv0 = bitblock_advance_ci_co_cpu(iBuilder, e[i-1][j], 1, stideCarryArr, carryIdx++);
    93             Value * adv1 = bitblock_advance_ci_co_cpu(iBuilder, e[i-1][j-1], 1, stideCarryArr, carryIdx++);
    94             Value * adv2 = bitblock_advance_ci_co_cpu(iBuilder, e[i][j-1], 1, stideCarryArr, carryIdx++);
    95             Value * tmp1 = iBuilder->CreateAnd(adv0, pattStream);
    96             Value * tmp2 = iBuilder->CreateAnd(adv1, iBuilder->CreateNot(pattStream));
    97             Value * tmp3 = iBuilder->CreateOr(adv2, e[i-1][j-1]);
     101            bitblock_advance_ci_co(e[i-1][j], 1, stideCarryArr, carryIdx++, adv, calculated, i-1, j);
     102            bitblock_advance_ci_co(e[i-1][j-1], 1, stideCarryArr, carryIdx++, adv, calculated, i-1, j-1);
     103            bitblock_advance_ci_co(e[i][j-1], 1, stideCarryArr, carryIdx++, adv, calculated, i, j-1);
     104            Value * tmp1 = iBuilder->CreateAnd(adv[i-1][j], pattStream);
     105            Value * tmp2 = iBuilder->CreateAnd(adv[i-1][j-1], iBuilder->CreateNot(pattStream));
     106            Value * tmp3 = iBuilder->CreateOr(adv[i][j-1], e[i-1][j-1]);
    98107            e[i][j] = iBuilder->CreateOr(iBuilder->CreateOr(tmp1, tmp2), tmp3);
    99108
     
    101110        pattPos = iBuilder->CreateAdd(pattPos, ConstantInt::get(int32ty, 1));
    102111    }
    103 
     112   
    104113    Value * ptr = iBuilder->CreateGEP(resultStreamPtr, {iBuilder->getInt32(0), iBuilder->getInt32(0)});
    105114    iBuilder->CreateStore(e[mPatternLen-1][0], ptr);
  • icGREP/icgrep-devel/icgrep/editd/editd_cpu_kernel.h

    r5217 r5223  
    3434    void generateDoBlockMethod() override;
    3535    void generateFinalBlockMethod() override;
     36    void 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);
    3637    unsigned mEditDistance;
    3738    unsigned mPatternLen;
Note: See TracChangeset for help on using the changeset viewer.