Ignore:
Timestamp:
Jan 14, 2017, 3:49:56 PM (3 years ago)
Author:
nmedfort
Message:

Changes working towards simplifying accessing stream elements + some modifications to simplify include / forward declarations within the CodeGen? library.

Location:
icGREP/icgrep-devel/icgrep/editd
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/editd/editd.cpp

    r5257 r5260  
    6868using namespace kernel;
    6969using namespace pablo;
    70 
    71 std::string IRFilename = "editd.ll";
    72 std::string PTXFilename = "editd.ptx";
     70using namespace parabix;
     71
     72const static std::string IRFilename = "editd.ll";
     73const static std::string PTXFilename = "editd.ptx";
    7374
    7475struct matchPosition
  • icGREP/icgrep-devel/icgrep/editd/editd_cpu_kernel.cpp

    r5247 r5260  
    66#include <kernels/kernel.h>
    77#include <IR_Gen/idisa_builder.h>
     8#include <llvm/IR/Module.h>
    89#include <llvm/Support/raw_ostream.h>
    910#include <iostream>
    1011
     12using namespace llvm;
     13
    1114namespace kernel {
    12 using namespace llvm;
    1315
    1416void 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 {
     
    6466    Value * stideCarryArr = getScalarField(kernelStuctParam, "srideCarry");
    6567    Value * blockNo = getScalarField(kernelStuctParam, blockNoScalar);
    66     Value * ccStreamPtr = getStreamSetBlockPtr(kernelStuctParam, "CCStream", blockNo);
    67     Value * resultStreamPtr = getStreamSetBlockPtr(kernelStuctParam, "ResultStream", blockNo);
    68 
    6968   
    7069    unsigned carryIdx = 0;
     
    7776    Value * pattCh = iBuilder->CreateLoad(pattPtr);
    7877    Value * pattIdx = iBuilder->CreateAnd(iBuilder->CreateLShr(pattCh, 1), ConstantInt::get(int8ty, 3));
    79     Value * pattStreamPtr = iBuilder->CreateGEP(ccStreamPtr, {iBuilder->getInt32(0), iBuilder->CreateZExt(pattIdx, int32ty)});
     78    Value * pattStreamPtr = getStream(kernelStuctParam, "CCStream", blockNo, iBuilder->CreateZExt(pattIdx, int32ty));
    8079    Value * pattStream = iBuilder->CreateLoad(pattStreamPtr);
    8180    pattPos = iBuilder->CreateAdd(pattPos, ConstantInt::get(int32ty, 1));
     
    8685    }
    8786
    88     for(unsigned i = 1; i<mPatternLen; i++){     
     87    for(unsigned i = 1; i < mPatternLen; i++){
    8988        pattPtr = iBuilder->CreateGEP(pattStartPtr, pattPos);
    9089        pattCh = iBuilder->CreateLoad(pattPtr);
    9190        pattIdx = iBuilder->CreateAnd(iBuilder->CreateLShr(pattCh, 1), ConstantInt::get(int8ty, 3));
    92         pattStreamPtr = iBuilder->CreateGEP(ccStreamPtr, {iBuilder->getInt32(0), iBuilder->CreateZExt(pattIdx, int32ty)});
     91        pattStreamPtr = getStream(kernelStuctParam, "CCStream", blockNo, iBuilder->CreateZExt(pattIdx, int32ty));
    9392        pattStream = iBuilder->CreateLoad(pattStreamPtr);
    9493
     
    108107    }
    109108   
    110     Value * ptr = iBuilder->CreateGEP(resultStreamPtr, {iBuilder->getInt32(0), iBuilder->getInt32(0)});
    111     iBuilder->CreateStore(e[mPatternLen-1][0], ptr);
     109    Value * ptr = getStream(kernelStuctParam, "ResultStream", blockNo, iBuilder->getInt32(0));
     110    iBuilder->CreateStore(e[mPatternLen - 1][0], ptr);
    112111    for(unsigned j = 1; j<= mEditDistance; j++){
    113         ptr = iBuilder->CreateGEP(resultStreamPtr, {iBuilder->getInt32(0), iBuilder->getInt32(j)});
     112        ptr = getStream(kernelStuctParam, "ResultStream", blockNo, iBuilder->getInt32(j));
    114113        iBuilder->CreateStore(iBuilder->CreateAnd(e[mPatternLen-1][j], iBuilder->CreateNot(e[mPatternLen-1][j-1])), ptr);
    115114    }
     
    123122}
    124123
     124editdCPUKernel::editdCPUKernel(IDISA::IDISA_Builder * b, unsigned dist, unsigned pattLen) :
     125KernelBuilder(b, "editd_cpu",
     126             {Binding{b->getStreamSetTy(4), "CCStream"}},
     127             {Binding{b->getStreamSetTy(dist + 1), "ResultStream"}},
     128             {Binding{PointerType::get(b->getInt8Ty(), 1), "pattStream"},
     129             Binding{PointerType::get(ArrayType::get(b->getBitBlockType(), pattLen * (dist + 1) * 4), 0), "srideCarry"}},
     130             {},
     131             {Binding{b->getBitBlockType(), "EOFmask"}}),
     132mEditDistance(dist),
     133mPatternLen(pattLen){
     134
     135}
     136
    125137}
    126138
  • icGREP/icgrep-devel/icgrep/editd/editd_cpu_kernel.h

    r5246 r5260  
    1919public:
    2020   
    21     editdCPUKernel(IDISA::IDISA_Builder * b, unsigned dist, unsigned pattLen) :
    22     KernelBuilder(b, "editd_cpu",
    23                   {Binding{b->getStreamSetTy(4), "CCStream"}},
    24                   {Binding{b->getStreamSetTy(dist + 1), "ResultStream"}},
    25                   {Binding{PointerType::get(b->getInt8Ty(), 1), "pattStream"},
    26                   Binding{PointerType::get(ArrayType::get(b->getBitBlockType(), pattLen * (dist + 1) * 4), 0), "srideCarry"}},
    27                   {},
    28                   {Binding{b->getBitBlockType(), "EOFmask"}}),
    29     mEditDistance(dist),
    30     mPatternLen(pattLen){}
     21    editdCPUKernel(IDISA::IDISA_Builder * b, unsigned dist, unsigned pattLen);
    3122   
    3223   
     
    3425    void generateDoBlockMethod() const override;
    3526    void generateFinalBlockMethod() const 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) const;
     27    void bitblock_advance_ci_co(llvm::Value * val, unsigned shift, llvm::Value * stideCarryArr, unsigned carryIdx, std::vector<std::vector<llvm::Value *>> & adv, std::vector<std::vector<int>> & calculated, int i, int j) const;
    3728    unsigned mEditDistance;
    3829    unsigned mPatternLen;
  • icGREP/icgrep-devel/icgrep/editd/editd_gpu_kernel.cpp

    r5247 r5260  
    66#include <kernels/kernel.h>
    77#include <IR_Gen/idisa_builder.h>
     8#include <llvm/IR/Module.h>
    89#include <llvm/Support/raw_ostream.h>
    910#include <iostream>
    1011
    11 namespace kernel {
    1212using namespace llvm;
    1313
     14namespace kernel {
    1415
    1516void bitblock_advance_ci_co(IDISA::IDISA_Builder * iBuilder, Value * val, unsigned shift, Value * stideCarryArr, unsigned carryIdx, std::vector<std::vector<Value *>> & adv, std::vector<std::vector<int>> & calculated, int i, int j){   
     
    6667    Value * stideCarryArr = getScalarField(kernelStuctParam, "srideCarry");
    6768    Value * blockNo = getScalarField(kernelStuctParam, blockNoScalar);
    68     Value * ccStreamPtr = getStreamSetBlockPtr(kernelStuctParam, "CCStream", blockNo);
    69     Value * resultStreamPtr = getStreamSetBlockPtr(kernelStuctParam, "ResultStream", blockNo);
    7069    Value * pattLen = ConstantInt::get(int32ty, mPatternLen+1);
    7170    Value * pattPos = ConstantInt::get(int32ty, 0);
     
    7372    unsigned carryIdx = 0;
    7473
    75     std::vector<std::vector<Value *>> e(mPatternLen, std::vector<Value *>(mEditDistance+1));
    76     std::vector<std::vector<Value *>> adv(mPatternLen, std::vector<Value *>(mEditDistance+1));
    77     std::vector<std::vector<int>> calculated(mPatternLen, std::vector<int>(mEditDistance+1));
    78     for(unsigned i=0; i<mPatternLen; i++)
    79         for(unsigned j=0; j<=mEditDistance; j++)
    80             calculated[i][j] = 0;
     74    std::vector<std::vector<Value *>> e(mPatternLen, std::vector<Value *>(mEditDistance + 1));
     75    std::vector<std::vector<Value *>> adv(mPatternLen, std::vector<Value *>(mEditDistance + 1));
     76    std::vector<std::vector<int>> calculated(mPatternLen, std::vector<int>(mEditDistance + 1, 0));
     77
    8178    Function * bidFunc = cast<Function>(m->getOrInsertFunction("llvm.nvvm.read.ptx.sreg.ctaid.x", int32ty, nullptr));
    8279    Value * bid = iBuilder->CreateCall(bidFunc);
     
    8582    Value * pattCh = iBuilder->CreateLoad(pattPtr);
    8683    Value * pattIdx = iBuilder->CreateAnd(iBuilder->CreateLShr(pattCh, 1), ConstantInt::get(int8ty, 3));
    87     Value * pattStreamPtr = iBuilder->CreateGEP(ccStreamPtr, {iBuilder->getInt32(0), iBuilder->CreateZExt(pattIdx, int32ty)});
     84    Value * pattStreamPtr = getStream(kernelStuctParam, "CCStream", blockNo, iBuilder->CreateZExt(pattIdx, int32ty));
    8885    Value * pattStream = iBuilder->CreateLoad(pattStreamPtr);
    8986    pattPos = iBuilder->CreateAdd(pattPos, ConstantInt::get(int32ty, 1));
     
    9895        pattCh = iBuilder->CreateLoad(pattPtr);
    9996        pattIdx = iBuilder->CreateAnd(iBuilder->CreateLShr(pattCh, 1), ConstantInt::get(int8ty, 3));
    100         pattStreamPtr = iBuilder->CreateGEP(ccStreamPtr, {iBuilder->getInt32(0), iBuilder->CreateZExt(pattIdx, int32ty)});
     97        pattStreamPtr = getStream(kernelStuctParam, "CCStream", blockNo, iBuilder->CreateZExt(pattIdx, int32ty));
    10198        pattStream = iBuilder->CreateLoad(pattStreamPtr);
    10299
     
    116113    }
    117114
    118     Value * ptr = iBuilder->CreateGEP(resultStreamPtr, {iBuilder->getInt32(0), iBuilder->getInt32(0)});
     115    Value * ptr = getStream(kernelStuctParam, "ResultStream", blockNo, iBuilder->getInt32(0));
    119116    iBuilder->CreateStore(e[mPatternLen-1][0], ptr);
    120117    for(unsigned j = 1; j<= mEditDistance; j++){
    121         ptr = iBuilder->CreateGEP(resultStreamPtr, {iBuilder->getInt32(0), iBuilder->getInt32(j)});
    122         iBuilder->CreateStore(iBuilder->CreateAnd(e[mPatternLen-1][j], iBuilder->CreateNot(e[mPatternLen-1][j-1])), ptr);
     118        ptr = getStream(kernelStuctParam, "ResultStream", blockNo, iBuilder->getInt32(j));
     119        iBuilder->CreateStore(iBuilder->CreateAnd(e[mPatternLen - 1][j], iBuilder->CreateNot(e[mPatternLen - 1][j - 1])), ptr);
    123120    }
    124121
     
    131128}
    132129
     130editdGPUKernel::editdGPUKernel(IDISA::IDISA_Builder * b, unsigned dist, unsigned pattLen) :
     131KernelBuilder(b, "editd_gpu",
     132              {Binding{b->getStreamSetTy(4), "CCStream"}},
     133              {Binding{b->getStreamSetTy(dist + 1), "ResultStream"}},
     134              {Binding{PointerType::get(b->getInt8Ty(), 1), "pattStream"},
     135              Binding{PointerType::get(ArrayType::get(b->getBitBlockType(), pattLen * (dist + 1) * 4), 0), "srideCarry"}},
     136              {},
     137              {Binding{b->getBitBlockType(), "EOFmask"}}),
     138mEditDistance(dist),
     139mPatternLen(pattLen) {
     140
     141}
     142
    133143}
    134144
  • icGREP/icgrep-devel/icgrep/editd/editd_gpu_kernel.h

    r5246 r5260  
    1919public:
    2020   
    21     editdGPUKernel(IDISA::IDISA_Builder * b, unsigned dist, unsigned pattLen) :
    22     KernelBuilder(b, "editd_gpu",
    23                   {Binding{b->getStreamSetTy(4), "CCStream"}},
    24                   {Binding{b->getStreamSetTy(dist + 1), "ResultStream"}},
    25                   {Binding{PointerType::get(b->getInt8Ty(), 1), "pattStream"},
    26                   Binding{PointerType::get(ArrayType::get(b->getBitBlockType(), pattLen * (dist + 1) * 4), 0), "srideCarry"}},
    27                   {},
    28                   {Binding{b->getBitBlockType(), "EOFmask"}}),
    29     mEditDistance(dist),
    30     mPatternLen(pattLen){}
     21    editdGPUKernel(IDISA::IDISA_Builder * b, unsigned dist, unsigned pattLen);
    3122   
    3223   
  • icGREP/icgrep-devel/icgrep/editd/editdscan_kernel.cpp

    r5246 r5260  
    88#include <llvm/IR/Intrinsics.h>
    99#include <IR_Gen/idisa_builder.h>
     10#include <llvm/IR/Module.h>
    1011#include <llvm/Support/raw_os_ostream.h>
    1112#include <iostream>
     
    3536    Value * scanwordPos = iBuilder->CreateMul(blockNo, ConstantInt::get(blockNo->getType(), iBuilder->getBitBlockWidth()));
    3637   
    37     Value * matchResultsPtr = getStreamSetBlockPtr(kernelStuctParam, "matchResults", blockNo);
    38 
    3938    std::vector<Value * > matchWordVectors;
    4039    for(unsigned d = 0; d <= mEditDistance; d++){
    41         Value * matches = iBuilder->CreateBlockAlignedLoad(matchResultsPtr, {iBuilder->getInt32(0), iBuilder->getInt32(d)});
     40        Value * ptr = getStream(kernelStuctParam, "matchResults", blockNo, iBuilder->getInt32(d));
     41        Value * matches = iBuilder->CreateBlockAlignedLoad(ptr);
    4242        matchWordVectors.push_back(iBuilder->CreateBitCast(matches, scanwordVectorType));
    4343    }
     
    101101}
    102102
     103editdScanKernel::editdScanKernel(IDISA::IDISA_Builder * iBuilder, unsigned dist) :
     104KernelBuilder(iBuilder, "scanMatch",
     105              {Binding{iBuilder->getStreamSetTy(dist + 1), "matchResults"}},
     106              {}, {}, {}, {}),
     107mEditDistance(dist),
     108mScanwordBitWidth(iBuilder->getSizeTy()->getBitWidth()) {
     109
    103110}
     111
     112}
  • icGREP/icgrep-devel/icgrep/editd/editdscan_kernel.h

    r5246 r5260  
    1919class editdScanKernel : public KernelBuilder {
    2020public:
    21     editdScanKernel(IDISA::IDISA_Builder * iBuilder, unsigned dist) :
    22     KernelBuilder(iBuilder, "scanMatch",
    23                   {Binding{iBuilder->getStreamSetTy(dist + 1), "matchResults"}},
    24                   {}, {}, {}, {}),
    25     mEditDistance(dist),
    26     mScanwordBitWidth(iBuilder->getSizeTy()->getBitWidth()) {}
     21    editdScanKernel(IDISA::IDISA_Builder * iBuilder, unsigned dist);
    2722       
    2823private:
Note: See TracChangeset for help on using the changeset viewer.