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

Fix summary pack index calculation, ensureCarriesStoredLocal

File:
1 edited

Legend:

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

    r4709 r4710  
    160160
    161161void CarryManager::leaveScope() {
    162 #ifdef PACKING
    163     if ((mCurrentFrameIndex % PACK_SIZE) == 0) {
    164         // Write out all local packs.
    165         auto localCarryIndex = localBasePack();
    166         auto localCarryPacks = mCarryInfo->getLocalCarryPackCount();
    167         for (auto i = localCarryIndex; i < localCarryIndex + localCarryPacks; i++) {
    168             storeCarryPack(i);
    169         }
    170     }
    171 #endif
    172162    mCurrentFrameIndex -= mCarryInfo->getFrameIndex();
    173163    if (mCurrentScope != mPabloRoot) {
     
    230220}
    231221
     222
     223unsigned CarryManager::summaryPackIndex() {
     224#ifdef PACKING
     225    return summaryPosition()/PACK_SIZE;
     226#else
     227    return summaryPosition();
     228#endif
     229}
     230
    232231unsigned CarryManager::summaryBits() {
    233232#ifdef PACKING
     
    245244    if (mCarryInPack[packIndex] == nullptr) {
    246245        Value * packPtr = mBuilder->CreateGEP(mCarryPackBasePtr, mBuilder->getInt64(packIndex));
     246        // Save the computed pointer - so that it can be used in storeCarryPack.
    247247        mCarryPackPtr[packIndex] = packPtr;
    248248        mCarryInPack[packIndex] = mBuilder->CreateAlignedLoad(packPtr, PACK_SIZE/8);
     
    252252
    253253void CarryManager::storeCarryPack(unsigned packIndex) {
    254     //std::cerr << "storeCarryPack , pack = " << packIndex << std::endl;
    255254    mBuilder->CreateAlignedStore(mCarryOutPack[packIndex], mCarryPackPtr[packIndex], PACK_SIZE/8);
    256255}
     
    487486
    488487Value * CarryManager::getCarrySummaryExpr() {
    489     unsigned summary_posn = summaryPosition();
    490 #ifdef PACKING
    491     Value * pack = getCarryPack(summary_posn/PACK_SIZE);
    492     Value * summary_bits = maskSelectBitRange(pack, summary_posn % PACK_SIZE, summaryBits());
     488    unsigned summary_index = summaryPackIndex();
     489#ifdef PACKING
     490    Value * pack = getCarryPack(summary_index);
     491    Value * summary_bits = maskSelectBitRange(pack, summaryPosition() % PACK_SIZE, summaryBits());
    493492    return mBuilder->CreateBitCast(mBuilder->CreateZExt(summary_bits, mBuilder->getIntNTy(BLOCK_SIZE)), mBitBlockType);
    494493#else
    495     return getCarryPack(summary_posn);
     494    return getCarryPack(summary_index);
    496495#endif
    497496}
     
    523522#endif
    524523    if (mCarryInfo->getIfDepth() > 1) {
    525         const unsigned summaryPackIndex = summaryPosition();
     524        const unsigned summaryIndex = summaryPackIndex();
    526525        PHINode * summary_phi = mBuilder->CreatePHI(mCarryPackType, 2, "summary");
    527526        summary_phi->addIncoming(mZeroInitializer, ifEntryBlock);
    528         summary_phi->addIncoming(mCarryOutPack[summaryPackIndex], ifBodyFinalBlock);
    529         mCarryOutPack[summaryPackIndex] = summary_phi;
     527        summary_phi->addIncoming(mCarryOutPack[summaryIndex], ifBodyFinalBlock);
     528        mCarryOutPack[summaryIndex] = summary_phi;
    530529    }
    531530}
     
    537536        return;
    538537    }
    539     const unsigned carrySummaryIndex = summaryPosition();
     538    const unsigned carrySummaryIndex = summaryPackIndex();
    540539    PHINode * summary_phi = mBuilder->CreatePHI(mCarryPackType, 2, "summary");
    541540    summary_phi->addIncoming(mZeroInitializer, ifEntryBlock);
     
    553552    }
    554553   
    555     const unsigned carrySummaryIndex = summaryPosition();
     554    const unsigned carrySummaryIndex = summaryPackIndex();
    556555   
    557556    Value * carry_summary = mZeroInitializer;
     
    574573                enterScope(inner_blk);
    575574                if (blockHasCarries()) {
    576                   carry_summary = mBuilder->CreateOr(carry_summary, mCarryOutPack[summaryPosition()]);
     575                  carry_summary = mBuilder->CreateOr(carry_summary, mCarryOutPack[summaryPackIndex()]);
    577576                }
    578577                leaveScope();
     
    582581                enterScope(inner_blk);
    583582                if (blockHasCarries()) {
    584                     carry_summary = mBuilder->CreateOr(carry_summary, mCarryOutPack[summaryPosition()]);
     583                    carry_summary = mBuilder->CreateOr(carry_summary, mCarryOutPack[summaryPackIndex()]);
    585584                }
    586585                leaveScope();
     
    649648}
    650649
    651 }
    652 
     650/* Store all the full carry packs generated locally in this scope. */
     651void CarryManager::ensureCarriesStoredLocal() {
     652#ifdef PACKING
     653    if ((mCurrentFrameIndex % PACK_SIZE) == 0) {
     654        // Write out all local packs.
     655        auto localCarryIndex = localBasePack();
     656        auto localCarryPacks = mCarryInfo->getLocalCarryPackCount();
     657        for (auto i = localCarryIndex; i < localCarryIndex + localCarryPacks; i++) {
     658            storeCarryPack(i);
     659        }
     660    }
     661#endif
     662}
     663
     664}
     665
Note: See TracChangeset for help on using the changeset viewer.