Changeset 5104


Ignore:
Timestamp:
Jul 21, 2016, 6:55:10 AM (3 years ago)
Author:
cameron
Message:

getStreamSetBlockPtr

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

Legend:

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

    r5097 r5104  
    5858   
    5959    Value * self = getParameter(doBlockFunction, "self");
    60    
    6160    Value * blockNo = getScalarField(self, blockNoScalar);
    62     Value * inputStreamBlock = getCircularBufferBlockPointer(self, "inputStreamSet", blockNo);
    63     Value * outputStreamBlock = getCircularBufferBlockPointer(self, "outputStreamSet", blockNo);
    64     Value * delCountBlock = getCircularBufferBlockPointer(self, "deletionCounts", blockNo);
    65    
     61    Value * inputStreamBlock = getStreamSetBlockPtr(self, "inputStreamSet", blockNo);
     62    Value * outputStreamBlock = getStreamSetBlockPtr(self, "outputStreamSet", blockNo);
     63    Value * delCountBlock = getStreamSetBlockPtr(self, "deletionCounts", blockNo);
     64
    6665    Value * del_mask = iBuilder->CreateBlockAlignedLoad(inputStreamBlock, {iBuilder->getInt32(0), iBuilder->getInt32(mStreamCount)});
    6766   
     
    9291    Value * self = getParameter(doBlockFunction, "self");
    9392    Value * blockNo = getScalarField(self, blockNoScalar);
    94     Value * inputStreamBlock = getCircularBufferBlockPointer(self, "inputStreamSet", blockNo);
     93    Value * inputStreamBlock = getStreamSetBlockPtr(self, "inputStreamSet", blockNo);
    9594    Value * remaining = iBuilder->CreateZExt(remainingBytes, iBuilder->getIntNTy(blockSize));
    9695    Value * EOF_del = iBuilder->bitCast(iBuilder->CreateShl(Constant::getAllOnesValue(iBuilder->getIntNTy(blockSize)), remaining));
  • icGREP/icgrep-devel/icgrep/kernels/kernel.cpp

    r5103 r5104  
    2828    unsigned index = mKernelFields.size();
    2929    mKernelFields.push_back(t);
    30     mInternalStateNameMap.emplace(scalarName, iBuilder->getInt32(index));
     30    mInternalStateNameMap.emplace(scalarName, index);
    3131}
    3232
     
    3838    if (!mDoBlockReturnType) mDoBlockReturnType = iBuilder->getVoidTy();
    3939    addScalar(iBuilder->getInt64Ty(), blockNoScalar);
     40    int streamSetNo = 0;
    4041    for (auto sSet : mStreamSetInputs) {
    4142        mScalarInputs.push_back(ScalarBinding{PointerType::get(sSet.ssType.getStreamSetBlockType(), 0), sSet.ssName + basePtrSuffix});
     43        mStreamSetNameMap.emplace(sSet.ssName, streamSetNo);
     44        streamSetNo++;
    4245    }
    4346    for (auto sSet : mStreamSetOutputs) {
    4447        mScalarInputs.push_back(ScalarBinding{PointerType::get(sSet.ssType.getStreamSetBlockType(), 0), sSet.ssName + basePtrSuffix});
     48        mStreamSetNameMap.emplace(sSet.ssName, streamSetNo);
     49        streamSetNo++;
    4550    }
    4651    for (auto binding : mScalarInputs) {
     
    193198        throw std::runtime_error("Kernel does not contain internal state: " + fieldName);
    194199    }
    195     return f->second;
     200    return iBuilder->getInt32(f->second);
    196201}
    197202
     
    215220}
    216221
    217 
     222unsigned KernelBuilder::getStreamSetIndex(std::string ssName) {
     223    const auto f = mStreamSetNameMap.find(ssName);
     224    if (LLVM_UNLIKELY(f == mStreamSetNameMap.end())) {
     225        throw std::runtime_error("Kernel does not contain stream set: " + ssName);
     226    }
     227    return f->second;
     228}
     229
     230Value * KernelBuilder::getStreamSetBasePtr(Value * self, std::string ssName) {
     231    return getScalarField(self, ssName + basePtrSuffix);
     232}
     233
     234Value * KernelBuilder::getStreamSetBlockPtr(Value * self, std::string ssName, Value * blockNo) {
     235    Value * basePtr = getStreamSetBasePtr(self, ssName);
     236    unsigned ssIndex = getStreamSetIndex(ssName);
     237    if (ssIndex < mStreamSetInputs.size()) {
     238        return mStreamSetInputs[ssIndex].ssType.getStreamSetBlockPointer(basePtr, blockNo);
     239    }
     240    else {
     241        return mStreamSetOutputs[ssIndex - mStreamSetInputs.size()].ssType.getStreamSetBlockPointer(basePtr, blockNo);
     242    }
     243}
     244
     245
     246
     247
  • icGREP/icgrep-devel/icgrep/kernels/kernel.h

    r5103 r5104  
    2222   
    2323class KernelBuilder : public KernelInterface {
    24     using NameMap = boost::container::flat_map<std::string, llvm::ConstantInt *>;
     24    using NameMap = boost::container::flat_map<std::string, unsigned>;
    2525
    2626public:
     
    9292    // Get a parameter by name.
    9393    llvm::Value * getParameter(llvm::Function * f, std::string paramName);
    94 
     94   
     95    // Stream set helpers.
     96    unsigned getStreamSetIndex(std::string ssName);
     97   
     98    llvm::Value * getStreamSetBasePtr(Value * self, std::string ssName);
     99   
     100    llvm::Value * getStreamSetBlockPtr(Value * self, std::string ssName, Value * blockNo);
     101       
    95102protected:
    96103
    97104    std::vector<llvm::Type *>  mKernelFields;
    98105    NameMap                    mInternalStateNameMap;
     106    NameMap                    mStreamSetNameMap;
    99107};
    100108}
  • icGREP/icgrep-devel/icgrep/kernels/p2s_kernel.cpp

    r5097 r5104  
    5151    Value * self = getParameter(doBlockFunction, "self");
    5252    Value * blockNo = getScalarField(self, blockNoScalar);
    53     Value * basisBitsBlock_ptr = getCircularBufferBlockPointer(self, "basisBits", blockNo);
    54     Value * byteStreamBlock_ptr = getCircularBufferBlockPointer(self, "byteStream", blockNo);
     53    Value * basisBitsBlock_ptr = getStreamSetBlockPtr(self, "basisBits", blockNo);
     54    Value * byteStreamBlock_ptr = getStreamSetBlockPtr(self, "byteStream", blockNo);
    5555
    5656    Value * p_bitblock[8];
     
    8383   
    8484    iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), "entry", doBlockFunction, 0));
    85    
    86    
    87     Value * self = getParameter(doBlockFunction, "self");
    88     Value * blockNo = getScalarField(self, blockNoScalar);
    89     Value * basisBitsBlock_ptr = getCircularBufferBlockPointer(self, "basisBits", blockNo);
    90     Value * delCountBlock_ptr = getCircularBufferBlockPointer(self, "deletionCounts", blockNo);
    91     Value * byteStreamBlock_ptr = getCircularBufferBlockPointer(self, "byteStream", blockNo);
    92 
     85    Value * self = getParameter(doBlockFunction, "self");
     86    Value * blockNo = getScalarField(self, blockNoScalar);
     87    Value * basisBitsBlock_ptr = getStreamSetBlockPtr(self, "basisBits", blockNo);
     88    Value * delCountBlock_ptr = getStreamSetBlockPtr(self, "deletionCounts", blockNo);
     89    Value * byteStreamBlock_ptr = getStreamSetBlockPtr(self, "byteStream", blockNo);
     90   
    9391    Value * p_bitblock[8];
    9492    for (unsigned i = 0; i < 8; i++) {
     
    121119   
    122120    iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), "entry", doBlockFunction, 0));
    123    
    124     Value * self = getParameter(doBlockFunction, "self");
    125     Value * blockNo = getScalarField(self, blockNoScalar);
    126     Value * basisBitsBlock_ptr = getCircularBufferBlockPointer(self, "basisBits", blockNo);
    127     Value * i16StreamBlock_ptr = getCircularBufferBlockPointer(self, "i16Stream", blockNo);
     121    Value * self = getParameter(doBlockFunction, "self");
     122    Value * blockNo = getScalarField(self, blockNoScalar);
     123    Value * basisBitsBlock_ptr = getStreamSetBlockPtr(self, "basisBits", blockNo);
     124    Value * i16StreamBlock_ptr = getStreamSetBlockPtr(self, "i16Stream", blockNo);
    128125   
    129126    Value * hi_input[8];
     
    166163   
    167164    iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), "entry", doBlockFunction, 0));
    168    
    169     Value * self = getParameter(doBlockFunction, "self");
    170     Value * blockNo = getScalarField(self, blockNoScalar);
    171     Value * basisBitsBlock_ptr = getCircularBufferBlockPointer(self, "basisBits", blockNo);
    172     Value * delCountBlock_ptr = getCircularBufferBlockPointer(self, "deletionCounts", blockNo);
    173     Value * i16StreamBlock_ptr = getCircularBufferBlockPointer(self, "i16Stream", blockNo);
    174 
     165    Value * self = getParameter(doBlockFunction, "self");
     166    Value * blockNo = getScalarField(self, blockNoScalar);
     167    Value * basisBitsBlock_ptr = getStreamSetBlockPtr(self, "basisBits", blockNo);
     168    Value * delCountBlock_ptr = getStreamSetBlockPtr(self, "deletionCounts", blockNo);
     169    Value * i16StreamBlock_ptr = getStreamSetBlockPtr(self, "i16Stream", blockNo);
     170   
    175171    Value * hi_input[8];
    176172    for (unsigned j = 0; j < 8; ++j) {
  • icGREP/icgrep-devel/icgrep/kernels/s2p_kernel.cpp

    r5103 r5104  
    147147    iBuilder->SetInsertPoint(finalEmptyBlock);
    148148    Value * blockNo = getScalarField(self, blockNoScalar);
    149     Value * basisBitsBase_ptr = getScalarField(self, mStreamSetOutputs[0].ssName + basePtrSuffix);
    150     Value * basisBitsBlock_ptr = mStreamSetOutputs[0].ssType.getStreamSetBlockPointer(basisBitsBase_ptr, blockNo);
     149    Value * basisBitsBlock_ptr = getStreamSetBlockPtr(self, "basisBits", blockNo);
    151150    iBuilder->CreateStore(Constant::getNullValue(basisBitsBlock_ptr->getType()->getPointerElementType()), basisBitsBlock_ptr);
    152151    iBuilder->CreateBr(exitBlock);
     
    167166   
    168167    Value * self = getParameter(doBlockFunction, "self");
    169     Value * byteStreamBase_ptr = getScalarField(self, mStreamSetInputs[0].ssName + basePtrSuffix);
    170     Value * basisBitsBase_ptr = getScalarField(self, mStreamSetOutputs[0].ssName + basePtrSuffix);
    171168    Value * blockNo = getScalarField(self, blockNoScalar);
    172    
    173    
    174     Value * byteStreamBlock_ptr = mStreamSetInputs[0].ssType.getStreamSetBlockPointer(byteStreamBase_ptr, blockNo);
    175     Value * basisBitsBlock_ptr = mStreamSetOutputs[0].ssType.getStreamSetBlockPointer(basisBitsBase_ptr, blockNo);
     169    Value * byteStreamBlock_ptr = getStreamSetBlockPtr(self, "byteStream", blockNo);
     170    Value * basisBitsBlock_ptr = getStreamSetBlockPtr(self, "basisBits", blockNo);
    176171   
    177172    Value * s_bytepack[8];
  • icGREP/icgrep-devel/icgrep/kernels/scanmatchgen.cpp

    r5103 r5104  
    5757    Value * recordStart = getScalarField(kernelStuctParam, "LineStart");
    5858    Value * recordNum = getScalarField(kernelStuctParam, "LineNum");
    59     Value * matchResultsBase_ptr = getScalarField(kernelStuctParam, "matchResults" + basePtrSuffix);
    60     Value * matchResultsPtr = mStreamSetInputs[0].ssType.getStreamSetBlockPointer(matchResultsBase_ptr, blockNo);   
     59    Value * matchResultsPtr = getStreamSetBlockPtr(kernelStuctParam, "matchResults", blockNo);   
    6160    Value * matches = iBuilder->CreateBlockAlignedLoad(matchResultsPtr, {iBuilder->getInt32(0), iBuilder->getInt32(0)});
    6261    Value * linebreaks = iBuilder->CreateBlockAlignedLoad(matchResultsPtr, {iBuilder->getInt32(0), iBuilder->getInt32(1)});
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r5102 r5104  
    6464     
    6565    Value * blockNo = mKernelBuilder->getScalarField(mSelf, blockNoScalar);
    66     Value * inputBase_ptr = mKernelBuilder->getScalarField(mSelf, mKernelBuilder->mStreamSetInputs[0].ssName + basePtrSuffix);
    67     Value * inputSet_ptr  = mKernelBuilder->mStreamSetInputs[0].ssType.getStreamSetBlockPointer(inputBase_ptr, blockNo);
     66    std::string inputName = mKernelBuilder->mStreamSetInputs[0].ssName;
     67    Value * inputSet_ptr  = mKernelBuilder->getStreamSetBlockPtr(mSelf, inputName, blockNo);
    6868
    6969    Value * outputSet_ptr = nullptr;
    7070    if (mPabloFunction->getNumOfResults() > 0) {
    71         Value * outputBase_ptr = mKernelBuilder->getScalarField(mSelf, mKernelBuilder->mStreamSetOutputs[0].ssName + basePtrSuffix);
    72         outputSet_ptr = mKernelBuilder->mStreamSetOutputs[0].ssType.getStreamSetBlockPointer(outputBase_ptr, blockNo);
     71        std::string outputName = mKernelBuilder->mStreamSetOutputs[0].ssName;
     72        outputSet_ptr = mKernelBuilder->getStreamSetBlockPtr(mSelf, outputName, blockNo);
    7373    }
    7474    for (unsigned j = 0; j < mPabloFunction->getNumOfParameters(); ++j) {
Note: See TracChangeset for help on using the changeset viewer.