Ignore:
Timestamp:
Jul 17, 2015, 1:41:26 PM (4 years ago)
Author:
cameron
Message:

Carry Manager progress and bug fix

File:
1 edited

Legend:

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

    r4678 r4682  
    6464    /* Methods for getting and setting individual carry values. */
    6565   
     66//#define LOAD_STORE_ON_BLOCK_ENTRY_EXIT   
    6667Value * CarryManager::getCarryOpCarryIn(int localIndex) {
    6768    unsigned cd_index = mCurrentScopeIndex + mCarryInfo->carryOpCarryDataOffset(localIndex);
     69#ifndef LOAD_STORE_ON_BLOCK_ENTRY_EXIT
    6870    if (mCarryInfo->getWhileDepth() == 0) {
    6971       Value * packPtr = mBuilder->CreateGEP(mCarryDataPtr, mBuilder->getInt64(cd_index));
    7072       mCarryInVector[cd_index] = mBuilder->CreateAlignedLoad(packPtr, BLOCK_SIZE/8);
    7173    }
     74#endif
    7275    return mCarryInVector[cd_index];
    7376}
     
    7679    unsigned cd_index = mCurrentScopeIndex + mCarryInfo->carryOpCarryDataOffset(localIndex);
    7780    mCarryOutVector[cd_index] = carry_out;
     81#ifndef LOAD_STORE_ON_BLOCK_ENTRY_EXIT
    7882    if (mCarryInfo->getWhileDepth() == 0) {
    7983       Value * packPtr = mBuilder->CreateGEP(mCarryDataPtr, mBuilder->getInt64(cd_index));
    8084       mBuilder->CreateAlignedStore(carry_out, packPtr, BLOCK_SIZE/8);
    8185    }
     86#endif
    8287}
    8388
     
    98103    unsigned carryDataIndex = mCurrentScopeIndex + mCarryInfo->unitAdvanceCarryDataOffset(localIndex);
    99104    mCarryOutVector[carryDataIndex] = strm;
     105#ifndef LOAD_STORE_ON_BLOCK_ENTRY_EXIT
    100106    if (mCarryInfo->getWhileDepth() == 0) {
    101107        Value * packPtr = mBuilder->CreateGEP(mCarryDataPtr, mBuilder->getInt64(carryDataIndex));
     
    103109        mBuilder->CreateAlignedStore(strm, packPtr, BLOCK_SIZE/8);
    104110    }
     111#endif
    105112    Value * carry_in = mCarryInVector[carryDataIndex];
    106113    Value* result_value;
     
    122129    unsigned carryDataIndex = mCurrentScopeIndex + mCarryInfo->shortAdvanceCarryDataOffset(localIndex);
    123130    mCarryOutVector[carryDataIndex] = strm;
     131#ifndef LOAD_STORE_ON_BLOCK_ENTRY_EXIT
    124132    if (mCarryInfo->getWhileDepth() == 0) {
    125133        Value * packPtr = mBuilder->CreateGEP(mCarryDataPtr, mBuilder->getInt64(carryDataIndex));
     
    127135        mBuilder->CreateAlignedStore(strm, packPtr, BLOCK_SIZE/8);
    128136    }
     137#endif
    129138    Value * carry_in = mCarryInVector[carryDataIndex];
    130139    Value* advanceq_longint = mBuilder->CreateBitCast(carry_in, mBuilder->getIntNTy(BLOCK_SIZE));
     
    237246    }
    238247    else {
     248        auto localCarryIndex = mCurrentScopeIndex + mCarryInfo->getLocalCarryPackIndex();
    239249        auto localCarryPacks = mCarryInfo->getLocalCarryDataSize();
    240250        if (localCarryPacks > 0) {
    241             carry_summary = mCarryOutVector[mCurrentScopeIndex];
     251            carry_summary = mCarryOutVector[localCarryIndex];
    242252            for (auto i = 1; i < localCarryPacks; i++) {
    243253                //carry_summary = mBuilder->CreateOr(carry_summary, mPabloBlock->mCarryOutPack[i]);           
    244                 carry_summary = mBuilder->CreateOr(carry_summary, mCarryOutVector[mCurrentScopeIndex+i]);
     254                carry_summary = mBuilder->CreateOr(carry_summary, mCarryOutVector[localCarryIndex+i]);
    245255            }
    246256        }
     
    273283
    274284void CarryManager::ensureCarriesLoadedLocal() {
    275 #if 0
     285#ifdef LOAD_STORE_ON_BLOCK_ENTRY_EXIT
    276286    if ((mCarryInfo->getScopeCarryDataSize() == 0 ) || (mCarryInfo->getWhileDepth() > 0)) return;
    277     if (mCarryInfo->explicitSummaryRequired()) {
    278         auto localCarryIndex = mCurrentScopeIndex + mCarryInfo->getLocalCarryDataOffset();
     287    if ((mCarryInfo->getIfDepth() == 0) || mCarryInfo->explicitSummaryRequired()) {
     288        auto localCarryIndex = mCurrentScopeIndex + mCarryInfo->getLocalCarryPackIndex();
    279289        auto localCarryPacks = mCarryInfo->getLocalCarryDataSize();
    280         for (auto i = 0; i < localCarryPacks; i++) {       
     290        //std::cerr << "ensureCarriesLoadedLocal: localCarryIndex =  " << localCarryIndex << "localCarryPacks =  " << localCarryPacks << std::endl;
     291        for (auto i = localCarryIndex; i < localCarryIndex + localCarryPacks; i++) {       
    281292            mCarryInVector[i] = mBuilder->CreateAlignedLoad(mBuilder->CreateGEP(mCarryDataPtr, mBuilder->getInt64(i)), BLOCK_SIZE/8, false);
    282293        }
     
    286297
    287298void CarryManager::ensureCarriesStoredLocal() {
    288 #if 0
     299#ifdef LOAD_STORE_ON_BLOCK_ENTRY_EXIT
    289300    if ((mCarryInfo->getScopeCarryDataSize() == 0 ) || (mCarryInfo->getWhileDepth() > 0)) return;
    290     auto localCarryIndex = mCurrentScopeIndex + mCarryInfo->getLocalCarryDataOffset();
     301    auto localCarryIndex = mCurrentScopeIndex + mCarryInfo->getLocalCarryPackIndex();
    291302    auto localCarryPacks = mCarryInfo->getLocalCarryDataSize();
    292     for (auto i = 0; i < localCarryPacks; i++) {       
     303    //std::cerr << "ensureCarriesStoredLocal: localCarryIndex =  " << localCarryIndex << "localCarryPacks =  " << localCarryPacks << std::endl;
     304    for (auto i = localCarryIndex; i < localCarryIndex + localCarryPacks; i++) {       
    293305        Value * storePtr = mBuilder->CreateGEP(mCarryDataPtr, mBuilder->getInt64(i));
    294306        mBuilder->CreateAlignedStore(mCarryOutVector[i], storePtr, BLOCK_SIZE/8, false);
    295     }
    296     if (mCarryInfo->getScopeCarryDataSize() > 1) {
    297         const unsigned carrySummaryIndex = mCurrentScopeIndex + mCarryInfo->summaryCarryDataIndex();
    298         Value * summaryPtr = mBuilder->CreateGEP(mCarryDataPtr, mBuilder->getInt64(carrySummaryIndex));
    299         mBuilder->CreateAlignedStore(mCarryOutVector[carrySummaryIndex], summaryPtr, BLOCK_SIZE/8, false);
    300307    }
    301308#endif
Note: See TracChangeset for help on using the changeset viewer.