Ignore:
Timestamp:
Jul 24, 2015, 5:04:53 PM (4 years ago)
Author:
cameron
Message:

Carry manager check in

Location:
icGREP/icgrep-devel/icgrep/pablo
Files:
2 edited

Legend:

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

    r4697 r4698  
    3333unsigned CarryManager::initialize(PabloBlock * pb, Value * carryPtr) {
    3434    mPabloRoot = pb;
    35     mCarryDataPtr = carryPtr;
     35#ifdef PACKING
     36    mCarryPackBasePtr = mBuilder->CreateBitCast(carryPtr, Type::getInt64PtrTy(mBuilder->getContext()));
     37    mCarryBitBlockPtr = carryPtr;
     38#else
     39    mCarryPackBasePtr = carryPtr;
     40#define mCarryBitBlockPtr mCarryPackBasePtr
     41#endif
    3642    unsigned scopeCount = doScopeCount(pb);
    3743    mCarryInfoVector.resize(scopeCount);
     
    4147    mTotalCarryDataBitBlocks = (totalCarryDataBits + BLOCK_SIZE - 1)/BLOCK_SIZE;
    4248    // Carry Data area will have one extra bit block to store the block number.
    43     mBlockNoPtr = mBuilder->CreateBitCast(mBuilder->CreateGEP(mCarryDataPtr, mBuilder->getInt64(mTotalCarryDataBitBlocks)), Type::getInt64PtrTy(mBuilder->getContext()));
     49    mBlockNoPtr = mBuilder->CreateBitCast(mBuilder->CreateGEP(carryPtr, mBuilder->getInt64(mTotalCarryDataBitBlocks)), Type::getInt64PtrTy(mBuilder->getContext()));
    4450    mBlockNo = mBuilder->CreateLoad(mBlockNoPtr);
    4551    mCarryPackPtr.resize(mTotalCarryDataBitBlocks);
     
    167173}
    168174
    169 unsigned CarryManager::longAdvancePosition(unsigned localIndex) {
    170     return absPosition(mCarryInfo->longAdvance.frameOffsetinBits, localIndex);
     175unsigned CarryManager::longAdvanceBitBlockPosition(unsigned localIndex) {
     176#ifdef PACKING
     177    return (mCurrentFrameIndex + mCarryInfo->longAdvance.frameOffsetinBits) / BLOCK_SIZE + localIndex;
     178#else
     179    return mCurrentFrameIndex + (mCarryInfo->longAdvance.frameOffsetinBits / BLOCK_SIZE) + localIndex;
     180#endif
    171181}
    172182
     
    183193Value * CarryManager::getCarryPack(unsigned packIndex) {
    184194    if (mCarryInPack[packIndex] == nullptr) {
    185         Value * packPtr = mBuilder->CreateGEP(mCarryDataPtr, mBuilder->getInt64(packIndex));
     195        Value * packPtr = mBuilder->CreateGEP(mCarryPackBasePtr, mBuilder->getInt64(packIndex));
    186196        mCarryPackPtr[packIndex] = packPtr;
    187197        mCarryInPack[packIndex] = mBuilder->CreateAlignedLoad(packPtr, PACK_SIZE/8);
     
    358368   
    359369Value * CarryManager::longAdvanceCarryInCarryOut(int localIndex, int shift_amount, Value * carry_out) {
    360     unsigned carryDataIndex = longAdvancePosition(localIndex);
     370    unsigned carryDataIndex = longAdvanceBitBlockPosition(localIndex);
    361371    Value * advBaseIndex = mBuilder->getInt64(carryDataIndex);
    362372    if (shift_amount <= BLOCK_SIZE) {
    363373        // special case using a single buffer entry and the carry_out value.
    364         Value * advanceDataPtr = mBuilder->CreateGEP(mCarryDataPtr, advBaseIndex);
     374        Value * advanceDataPtr = mBuilder->CreateGEP(mCarryBitBlockPtr, advBaseIndex);
    365375        Value * carry_block0 = mBuilder->CreateAlignedLoad(advanceDataPtr, BLOCK_SIZE/8);
    366376        mBuilder->CreateAlignedStore(carry_out, advanceDataPtr, BLOCK_SIZE/8);
     
    378388    Value * loadIndex0 = mBuilder->CreateAdd(mBuilder->CreateAnd(mBuilder->CreateSub(mBlockNo, mBuilder->getInt64(advanceEntries)), indexMask), advBaseIndex);
    379389    Value * storeIndex = mBuilder->CreateAdd(mBuilder->CreateAnd(mBlockNo, indexMask), advBaseIndex);
    380     Value * carry_block0 = mBuilder->CreateAlignedLoad(mBuilder->CreateGEP(mCarryDataPtr, loadIndex0), BLOCK_SIZE/8);
     390    Value * carry_block0 = mBuilder->CreateAlignedLoad(mBuilder->CreateGEP(mCarryBitBlockPtr, loadIndex0), BLOCK_SIZE/8);
    381391    // If the long advance is an exact multiple of BLOCK_SIZE, we simply return the oldest
    382392    // block in the long advance carry data area. 
    383393    if (block_shift == 0) {
    384         mBuilder->CreateAlignedStore(carry_out, mBuilder->CreateGEP(mCarryDataPtr, storeIndex), BLOCK_SIZE/8);
     394        mBuilder->CreateAlignedStore(carry_out, mBuilder->CreateGEP(mCarryBitBlockPtr, storeIndex), BLOCK_SIZE/8);
    385395        return carry_block0;
    386396    }
    387397    // Otherwise we need to combine data from the two oldest blocks.
    388398    Value * loadIndex1 = mBuilder->CreateAdd(mBuilder->CreateAnd(mBuilder->CreateSub(mBlockNo, mBuilder->getInt64(advanceEntries-1)), indexMask), advBaseIndex);
    389     Value * carry_block1 = mBuilder->CreateAlignedLoad(mBuilder->CreateGEP(mCarryDataPtr, loadIndex1), BLOCK_SIZE/8);
     399    Value * carry_block1 = mBuilder->CreateAlignedLoad(mBuilder->CreateGEP(mCarryBitBlockPtr, loadIndex1), BLOCK_SIZE/8);
    390400    Value* block0_shr = mBuilder->CreateLShr(mBuilder->CreateBitCast(carry_block0, mBuilder->getIntNTy(BLOCK_SIZE)), BLOCK_SIZE - block_shift);
    391401    Value* block1_shl = mBuilder->CreateShl(mBuilder->CreateBitCast(carry_block1, mBuilder->getIntNTy(BLOCK_SIZE)), block_shift);
    392     mBuilder->CreateAlignedStore(carry_out, mBuilder->CreateGEP(mCarryDataPtr, storeIndex), BLOCK_SIZE/8);
     402    mBuilder->CreateAlignedStore(carry_out, mBuilder->CreateGEP(mCarryBitBlockPtr, storeIndex), BLOCK_SIZE/8);
    393403    return mBuilder->CreateBitCast(mBuilder->CreateOr(block1_shl, block0_shr), mBitBlockType);
    394404}
     
    438448   
    439449    if (mCarryInfo->blockHasLongAdvances()) { // Force if entry
     450#ifdef PACKING
     451        carry_summary = mBuilder->getInt64(-1);
     452#else
    440453        carry_summary = mOneInitializer;
     454#endif
    441455    }
    442456    else {
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.h

    r4697 r4698  
    3838    : mBuilder(b)
    3939    , mBitBlockType(bitBlockType)
    40 #ifdef PACKING
    41     , mPackType(b->getIntNTy(PACK_SIZE))
    42 #endif
    4340    , mZeroInitializer(zero)
    4441    , mOneInitializer(one)
     
    4845    , mCarryInfo(nullptr)
    4946    , mCurrentFrameIndex(0)
    50     , mCarryDataPtr(nullptr)
     47    , mCarryPackBasePtr(nullptr)
     48#ifdef PACKING
     49    , mCarryBitBlockPtr(nullptr)
     50#endif
    5151    , mBlockNoPtr(nullptr)
    5252    , mBlockNo(nullptr)
     
    9999    IRBuilder <> * mBuilder;
    100100    VectorType * mBitBlockType;
    101 #ifdef PACKING
    102     Type * mPackType;
    103 #endif
    104101    ConstantAggregateZero * mZeroInitializer;
    105102    Constant * mOneInitializer;
     
    109106    PabloBlockCarryData * mCarryInfo;
    110107    unsigned mCurrentFrameIndex;
    111     Value * mCarryDataPtr;
     108    Value * mCarryPackBasePtr;
     109#ifdef PACKING
     110    Value * mCarryBitBlockPtr;
     111#endif
    112112    Value * mBlockNoPtr;
    113113    Value * mBlockNo;
     
    140140    unsigned advance1Position(unsigned localIndex);
    141141    unsigned shortAdvancePosition(unsigned localIndex);
    142     unsigned longAdvancePosition(unsigned localIndex);
     142    unsigned longAdvanceBitBlockPosition(unsigned localIndex);
    143143    unsigned summaryPosition();
    144144    unsigned summaryBits();
Note: See TracChangeset for help on using the changeset viewer.