Ignore:
Timestamp:
Mar 7, 2016, 3:37:30 PM (3 years ago)
Author:
nmedfort
Message:

Initial modifications to Pablo Compiler and Kernel Builder to support circular buffers for Lookahead.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.cpp

    r4954 r4959  
    2020
    2121/** ------------------------------------------------------------------------------------------------------------- *
    22  * @brief doScopeCount
    23  ** ------------------------------------------------------------------------------------------------------------- */
    24 static unsigned doScopeCount(const PabloBlock * const pb) {
    25     unsigned count = 1;
    26     for (const Statement * stmt : *pb) {
    27         if (LLVM_UNLIKELY(isa<If>(stmt))) {
    28             count += doScopeCount(cast<If>(stmt)->getBody());
    29         } else if (LLVM_UNLIKELY(isa<While>(stmt))) {
    30             count += doScopeCount(cast<While>(stmt)->getBody());
    31         }
    32     }
    33     return count;
    34 }
    35 
    36 /** ------------------------------------------------------------------------------------------------------------- *
    3722 * @brief initialize
    3823 ** ------------------------------------------------------------------------------------------------------------- */
    39 void CarryManager::initialize(PabloBlock * pb, KernelBuilder * kBuilder) {
    40     mRootScope = pb;
    41     mCarryInfoVector.resize(doScopeCount(pb));
     24void CarryManager::initialize(PabloFunction * const function, KernelBuilder * const kBuilder) {
     25    mRootScope = function->getEntryBlock();
     26    mCarryInfoVector.resize(mRootScope->enumerateScopes(0) + 1);
    4227    mCarryPackType = mBitBlockType;
    43 
    44     const unsigned totalCarryDataSize = enumerate(pb, 0, 0);
    45 
     28    const unsigned totalCarryDataSize = std::max<unsigned>(enumerate(mRootScope, 0, 0), 1);
    4629    mCarryPackPtr.resize(totalCarryDataSize, nullptr);
    4730    mCarryInPack.resize(totalCarryDataSize, nullptr);
    4831    mCarryOutPack.resize(totalCarryDataSize, nullptr);
    49 
    5032    mTotalCarryDataBitBlocks = totalCarryDataSize;
    51    
    5233    ArrayType* cdArrayTy = ArrayType::get(mBitBlockType, mTotalCarryDataBitBlocks);
    53     mCdArrayIdx = kBuilder->extendKernelInternalStateType(cdArrayTy);
    54    
     34    mCdArrayIdx = kBuilder->addInternalStateType(cdArrayTy);
    5535    if (mPabloCountCount > 0) {
    5636        ArrayType* pcArrayTy = ArrayType::get(iBuilder->getIntNTy(64), mPabloCountCount);
    57         mPcArrayIdx = kBuilder->extendKernelInternalStateType(pcArrayTy);
    58     }
    59  
     37        mPcArrayIdx = kBuilder->addInternalStateType(pcArrayTy);
     38    }
    6039    mCurrentScope = mRootScope;
    6140    mCurrentFrameIndex = 0;
     
    6443}
    6544
     45/** ------------------------------------------------------------------------------------------------------------- *
     46 * @brief initialize_setPtrs
     47 ** ------------------------------------------------------------------------------------------------------------- */
    6648void CarryManager::initialize_setPtrs(KernelBuilder * kBuilder) {
    67 
    68     Value * kernelStuctParam = kBuilder->getKernelStructParam();
    69     Value * cdArrayPtr = kBuilder->getKernelInternalStatePtr(kernelStuctParam, mCdArrayIdx);
    70  
     49    Value * cdArrayPtr = kBuilder->getInternalState(mCdArrayIdx);
    7150    mCarryPackBasePtr = iBuilder->CreateBitCast(cdArrayPtr, PointerType::get(mCarryPackType, 0));
    72     mCarryBitBlockPtr = iBuilder->CreateBitCast(cdArrayPtr, PointerType::get(mBitBlockType, 0));   
    73    
     51    mCarryBitBlockPtr = iBuilder->CreateBitCast(cdArrayPtr, PointerType::get(mBitBlockType, 0));
    7452    if (mPabloCountCount > 0) {
    75         Value * pcArrayPtr = kBuilder->getKernelInternalStatePtr(kernelStuctParam, mPcArrayIdx);
     53        Value * pcArrayPtr = kBuilder->getInternalState(mPcArrayIdx);
    7654        mPopcountBasePtr = iBuilder->CreateBitCast(pcArrayPtr, Type::getInt64PtrTy(iBuilder->getContext()));
    7755    }
    78  
    79     mBlockNo = iBuilder->CreateUDiv(kBuilder->getKernelInternalState(kernelStuctParam, mFilePosIdx), iBuilder->getInt64(mBitBlockWidth));
     56    setBlockNo(kBuilder);
    8057    mCurrentScope = mRootScope;
    8158    mCurrentFrameIndex = 0;
     
    8461}
    8562
    86 void CarryManager::set_BlockNo(KernelBuilder * kBuilder){
    87     Value * kernelStuctParam = kBuilder->getKernelStructParam();
    88     mBlockNo = iBuilder->CreateUDiv(kBuilder->getKernelInternalState(kernelStuctParam, mFilePosIdx), iBuilder->getInt64(mBitBlockWidth));
     63/** ------------------------------------------------------------------------------------------------------------- *
     64 * @brief setBlockNo
     65 ** ------------------------------------------------------------------------------------------------------------- */
     66void CarryManager::setBlockNo(KernelBuilder * kBuilder) {
     67    mBlockNo = iBuilder->CreateUDiv(iBuilder->CreateBlockAlignedLoad(kBuilder->getInternalState(mFilePosIdx)), iBuilder->getInt64(mBitBlockWidth));
    8968}
    9069
Note: See TracChangeset for help on using the changeset viewer.