Changeset 4700 for icGREP


Ignore:
Timestamp:
Jul 25, 2015, 12:51:19 PM (4 years ago)
Author:
cameron
Message:

Bit pack carry manager progress

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

Legend:

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

    r4687 r4700  
    1515
    1616   
    17 unsigned alignCeiling(unsigned toAlign, unsigned alignment) {
    18     return ((toAlign - 1) | (alignment - 1)) + 1;
    19 }
    20 
    21 void EnsurePackHasSpace(unsigned & packedTotalBits, unsigned addedBits) {
    22     unsigned bitsInCurrentPack = packedTotalBits % PACK_SIZE;
    23     if ((bitsInCurrentPack > 0) && (bitsInCurrentPack + addedBits > PACK_SIZE)) {
    24       packedTotalBits = alignCeiling(packedTotalBits, PACK_SIZE);
    25     }
    26 }
    2717
    2818void PabloBlockCarryData::enumerateLocal() {
  • icGREP/icgrep-devel/icgrep/pablo/carry_data.h

    r4697 r4700  
    2424unsigned const LongAdvanceBase = 64;
    2525
     26//#define PACKING
     27
    2628#ifdef PACKING
    2729const unsigned PACK_SIZE = 64;
     
    4446    return alignCeiling(bits, block_size) / block_size;
    4547}
     48
     49static void EnsurePackHasSpace(unsigned & packedTotalBits, unsigned addedBits) {
     50    unsigned bitsInCurrentPack = packedTotalBits % PACK_SIZE;
     51    if ((bitsInCurrentPack > 0) && (bitsInCurrentPack + addedBits > PACK_SIZE)) {
     52        packedTotalBits = alignCeiling(packedTotalBits, PACK_SIZE);
     53    }
     54}
     55
    4656
    4757namespace pablo {
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.cpp

    r4698 r4700  
    3434    mPabloRoot = pb;
    3535#ifdef PACKING
     36    mCarryPackType = mBuilder->getIntNTy(PACK_SIZE);
    3637    mCarryPackBasePtr = mBuilder->CreateBitCast(carryPtr, Type::getInt64PtrTy(mBuilder->getContext()));
    3738    mCarryBitBlockPtr = carryPtr;
    38 #else
     39    mZeroInitializer = mBuilder->getInt64(0);
     40    mOneInitializer = mBuilder->getInt64(-1);
     41#else
     42#define mCarryPackType mBitBlockType
    3943    mCarryPackBasePtr = carryPtr;
    4044#define mCarryBitBlockPtr mCarryPackBasePtr
     
    180184#endif
    181185}
     186   
     187unsigned CarryManager::localBasePack() {
     188#ifdef PACKING
     189    return (mCurrentFrameIndex + mCarryInfo->shortAdvance.frameOffsetinBits) / PACK_SIZE;
     190#else
     191    return mCurrentFrameIndex + (mCarryInfo->shortAdvance.frameOffsetinBits / PACK_SIZE);
     192#endif
     193}
     194   
     195unsigned CarryManager::scopeBasePack() {
     196#ifdef PACKING
     197    return mCurrentFrameIndex / PACK_SIZE;
     198#else
     199    return mCurrentFrameIndex;
     200#endif
     201}
     202   
     203
    182204
    183205unsigned CarryManager::summaryPosition() {
     
    293315    Value* strm_longint = mBuilder->CreateBitCast(strm, mBuilder->getIntNTy(BLOCK_SIZE));
    294316    Value* adv_longint = mBuilder->CreateOr(mBuilder->CreateShl(strm_longint, 1), carry_longint);
    295     result_value = mBuilder->CreateBitCast(adv_longint, mBitBlockType);
     317    Value* result_value = mBuilder->CreateBitCast(adv_longint, mBitBlockType);
    296318    return result_value;
    297319#else
     
    333355    Value* strm_longint = mBuilder->CreateBitCast(strm, mBuilder->getIntNTy(BLOCK_SIZE));
    334356    Value* adv_longint = mBuilder->CreateOr(mBuilder->CreateShl(strm_longint, 1), carry_longint);
    335     result_value = mBuilder->CreateBitCast(adv_longint, mBitBlockType);
     357    Value* result_value = mBuilder->CreateBitCast(adv_longint, mBitBlockType);
    336358    return result_value;
    337359#else
     
    415437    unsigned summary_posn = summaryPosition();
    416438#ifdef PACKING
    417     return getCarryRange(summary_posn, getSummaryBits());
     439    return getCarryRange(summary_posn, summaryBits());
    418440#else
    419441    return getCarryPack(summary_posn);
     
    428450    }
    429451    const unsigned carrySummaryIndex = summaryPosition();
    430     PHINode * summary_phi = mBuilder->CreatePHI(mBitBlockType, 2, "summary");
     452    PHINode * summary_phi = mBuilder->CreatePHI(mCarryPackType, 2, "summary");
    431453    summary_phi->addIncoming(mZeroInitializer, ifEntryBlock);
    432454    summary_phi->addIncoming(mCarryOutPack[carrySummaryIndex], ifBodyFinalBlock);
     
    446468   
    447469    Value * carry_summary = mZeroInitializer;
    448    
    449470    if (mCarryInfo->blockHasLongAdvances()) { // Force if entry
    450 #ifdef PACKING
    451         carry_summary = mBuilder->getInt64(-1);
    452 #else
    453471        carry_summary = mOneInitializer;
    454 #endif
    455472    }
    456473    else {
    457         auto localCarryIndex = mCurrentFrameIndex + mCarryInfo->getLocalCarryPackIndex();
     474        auto localCarryIndex = localBasePack();
    458475        auto localCarryPacks = mCarryInfo->getLocalCarryPackCount();
    459476        if (localCarryPacks > 0) {
     
    493510void CarryManager::ensureCarriesLoadedRecursive() {
    494511    const unsigned scopeCarryPacks = mCarryInfo->getScopeCarryPackCount();
     512    const unsigned currentScopeBase = scopeBasePack();
    495513    if (mCarryInfo->getWhileDepth() == 1) {
    496         for (auto i = mCurrentFrameIndex; i < mCurrentFrameIndex + scopeCarryPacks; ++i) {
     514        for (auto i = currentScopeBase; i < currentScopeBase + scopeCarryPacks; ++i) {
    497515            getCarryPack(i);
    498516        }
     
    505523    mCarryOutAccumPhis.resize(scopeCarryPacks);
    506524#ifdef SET_WHILE_CARRY_IN_TO_ZERO_AFTER_FIRST_ITERATION
     525    const unsigned currentScopeBase = scopeBasePack();
    507526    mCarryInPhis.resize(scopeCarryPacks);
    508527#endif
    509528    for (unsigned index = 0; index < scopeCarryPacks; ++index) {
    510529#ifdef SET_WHILE_CARRY_IN_TO_ZERO_AFTER_FIRST_ITERATION
    511         PHINode * phi_in = mBuilder->CreatePHI(mBitBlockType, 2);
    512         phi_in->addIncoming(mCarryInPack[mCurrentFrameIndex+index], whileEntryBlock);
     530        PHINode * phi_in = mBuilder->CreatePHI(mCarryPackType, 2);
     531        phi_in->addIncoming(mCarryInPack[currentScopeBase+index], whileEntryBlock);
    513532        mCarryInPhis[index] = phi_in;
    514533#endif
    515         PHINode * phi_out = mBuilder->CreatePHI(mBitBlockType, 2);
     534        PHINode * phi_out = mBuilder->CreatePHI(mCarryPackType, 2);
    516535        phi_out->addIncoming(mZeroInitializer, whileEntryBlock);
    517536        mCarryOutAccumPhis[index] = phi_out;
     
    522541void CarryManager::extendCarryDataPhisAtWhileBodyFinalBlock(BasicBlock * whileBodyFinalBlock) {
    523542    const unsigned scopeCarryPacks = mCarryInfo->getScopeCarryPackCount();
     543    const unsigned currentScopeBase = scopeBasePack();
    524544    for (unsigned index = 0; index < scopeCarryPacks; ++index) {
    525545#ifdef SET_WHILE_CARRY_IN_TO_ZERO_AFTER_FIRST_ITERATION
     
    527547#endif
    528548        PHINode * phi = mCarryOutAccumPhis[index];
    529         Value * carryOut = mBuilder->CreateOr(phi, mCarryOutPack[mCurrentFrameIndex+index]);
     549        Value * carryOut = mBuilder->CreateOr(phi, mCarryOutPack[currentScopeBase+index]);
    530550        phi->addIncoming(carryOut, whileBodyFinalBlock);
    531         mCarryOutPack[mCurrentFrameIndex+index] = carryOut;
     551        mCarryOutPack[currentScopeBase+index] = carryOut;
    532552    }
    533553}
     
    535555void CarryManager::ensureCarriesStoredRecursive() {
    536556    const unsigned scopeCarryPacks = mCarryInfo->getScopeCarryPackCount();
     557    const unsigned currentScopeBase = scopeBasePack();
    537558    if (mCarryInfo->getWhileDepth() == 1) {
    538         for (auto i = mCurrentFrameIndex; i < mCurrentFrameIndex + scopeCarryPacks; ++i) {
     559        for (auto i = currentScopeBase; i < currentScopeBase + scopeCarryPacks; ++i) {
    539560            storeCarryPack(i);
    540561        }
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.h

    r4698 r4700  
    9999    IRBuilder <> * mBuilder;
    100100    VectorType * mBitBlockType;
    101     ConstantAggregateZero * mZeroInitializer;
     101    Constant * mZeroInitializer;
    102102    Constant * mOneInitializer;
    103103    IDISA::IDISA_Builder * iBuilder;
     
    108108    Value * mCarryPackBasePtr;
    109109#ifdef PACKING
     110    Type * mCarryPackType;
    110111    Value * mCarryBitBlockPtr;
    111112#endif
     
    141142    unsigned shortAdvancePosition(unsigned localIndex);
    142143    unsigned longAdvanceBitBlockPosition(unsigned localIndex);
     144    unsigned localBasePack();
     145    unsigned scopeBasePack();
    143146    unsigned summaryPosition();
    144147    unsigned summaryBits();
Note: See TracChangeset for help on using the changeset viewer.