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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.