Changeset 435 for trunk


Ignore:
Timestamp:
Jul 4, 2013 7:34:52 AM (7 years ago)
Author:
kulshres
Message:

less work in free_loc() for StoreManagerLocintBlock?

but work still needs to be done in ensure_block()

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

Location:
trunk/ADOL-C/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ADOL-C/src/storemanager.h

    r427 r435  
    123123        FreeBlock(const struct FreeBlock &block) :
    124124            next(block.next),size(block.size) {}
     125        bool operator<(const struct FreeBlock& b) const {
     126            return (next < b.next);
     127        }
    125128    };
    126129
     
    128131    size_t &maxsize;
    129132    size_t &currentfill;
     133
     134    void consolidateBlocks();
    130135private:
    131136    /**
  • trunk/ADOL-C/src/tape_handling.cpp

    r434 r435  
    12341234#ifdef ADOLC_LOCDEBUG
    12351235    std::cerr << "StoreManagerLocintBlock::next_loc: result: " << result << " fill: " << size() << "max: " << maxSize() << endl;
     1236    std::cerr << "Size(INDEXFELD) = " << indexFree.size() << "\n";
    12361237    list<struct FreeBlock>::iterator iter = indexFree.begin();
    12371238    for( ; iter != indexFree.end(); iter++ )
     
    12561257    std::cerr << "searching for big enough block " << endl;
    12571258#endif
     1259    consolidateBlocks();
    12581260    list<struct FreeBlock>::iterator iter = indexFree.begin();
    12591261    for (; iter != indexFree.end() ; iter++ ) {
     
    12771279#ifdef ADOLC_LOCDEBUG
    12781280    std::cerr << "StoreManagerLocintBlock::ensure_Block: " << " fill: " << size() << "max: " << maxSize() <<  " ensure_Block (" << n << ")" << endl;
     1281    std::cerr << "Size(INDEXFELD) = " << indexFree.size() << "\n";
    12791282    iter = indexFree.begin();
    12801283    for( ; iter != indexFree.end(); iter++ )
     
    13641367#ifdef ADOLC_LOCDEBUG
    13651368    std::cerr << "Growing:" << endl;
     1369    std::cerr << "Size(INDEXFELD) = " << indexFree.size() << "\n";
    13661370    iter = indexFree.begin();
    13671371    for( ; iter != indexFree.end(); iter++ )
     
    13741378
    13751379    list<struct FreeBlock>::iterator iter = indexFree.begin();
    1376     for (; iter != indexFree.end() ; iter++ ) {
    1377          if (loc+1 == iter->next || iter->next + iter->size == loc) {
    1378               iter->size++;
    1379               if (loc + 1 == iter->next)
    1380                    iter->next = loc;
    1381     // bringing the matched element to the front maybe a good idea
    1382     // in case several contiguous adouble are deallcated right after
    1383     // one another, e.g. advector
    1384               if (iter != indexFree.begin()) {
    1385                   struct FreeBlock tmp(*iter);
    1386                   iter = indexFree.erase(iter);
    1387                   indexFree.push_front(tmp);
    1388                   iter = indexFree.begin();
    1389               }
    1390               break;
    1391          }
    1392     }
    1393     if (iter == indexFree.end()) {
     1380    if (loc+1 == iter->next || iter->next + iter->size == loc) {
     1381        iter->size++;
     1382        if (loc + 1 == iter->next)
     1383            iter->next = loc;
     1384    }
     1385    else {
    13941386         struct FreeBlock tmp;
    13951387         tmp.next = loc;
     
    14011393#ifdef ADOLC_LOCDEBUG
    14021394    std::cerr << "free_loc: " << loc << " fill: " << size() << "max: " << maxSize() << endl;
    1403 
     1395    std::cerr << "Size(INDEXFELD) = " << indexFree.size() << "\n";
    14041396    iter = indexFree.begin();
    14051397    for( ; iter != indexFree.end(); iter++ )
     
    14131405    ADOLC_GLOBAL_TAPE_VARS.storeManagerPtr->ensure_block(n);
    14141406}
     1407
     1408void StoreManagerLocintBlock::consolidateBlocks() {
     1409    indexFree.sort();
     1410    list<struct FreeBlock>::iterator iter = indexFree.begin(), niter = iter++;
     1411    while (iter != indexFree.end()) {
     1412        if (niter->next + niter->size == iter->next) {
     1413            niter->size += iter->size;
     1414            indexFree.erase(iter);
     1415            iter = niter;
     1416            iter++;
     1417        } else {
     1418            niter = iter;
     1419            iter++;
     1420        }
     1421    }
     1422#ifdef ADOLC_LOCDEBUG
     1423    std::cerr << "StoreManagerLocintBlock::consolidateBlocks: " << " fill: " << size() << "max: " << maxSize() << endl;
     1424    std::cerr << "Size(INDEXFELD) = " << indexFree.size() << "\n";
     1425    iter = indexFree.begin();
     1426    for( ; iter != indexFree.end(); iter++ )
     1427        std::cerr << "INDEXFELD ( " << iter->next << " , " << iter->size << ")" << endl;
     1428#endif
     1429}
Note: See TracChangeset for help on using the changeset viewer.