Ignore:
Timestamp:
Sep 24, 2012 8:40:20 AM (7 years ago)
Author:
kulshres
Message:

Rewrite of the StoreManagerLocintBlock? class

From: Jean Utke <utke@…>

and change in variable names as suggested to do away with mixing
english and german names.

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

This also combines the following commits on Jean's branch:

commit 79f770c3d2ab865a38301d1f86fa7c5b1b5d8dcf
Author: Jean Utke <utke@…>
Date: Sat Sep 22 01:15:58 2012 -0500

the previous fix was still insufficient because it inadvertently left
0 size blocks in the front of the list and the comment that the
newly allocated blocks should be pushed to the end apparently applied
only to the grow routine but not to next_loc so I went and did a more
wholesale change of what I think might work and what incidentally also
seems a little more straitghtforward. This is still a limited change
and I am still dubious about the constructor when non-zero values for
anxahl and groesse are passed
And ALSO these variable names OUGHT to be changed to something reasonable. :-)

commit f463cfcef971df5354709f430083a651ee543713
Author: Jean Utke <utke@…>
Date: Fri Sep 21 18:25:21 2012 -0500

fixing up earlier change in 3e9a21e76d1cb2ee10c220fa7a2f4d0dc8ae8e09
this earlier change was wrong too because while it expanded to
indexFeld with maximal location it still was wrong because
locations with bigger values could already be handed out.
So we restore part of the older code BUT then track if
we actually updated any existing IndexFeld? instance and if not
make a new one.

commit c7892ac99dea373e3eb7d5b7812230b18cf76ce3
Author: Jean Utke <utke@…>
Date: Fri Sep 21 17:32:37 2012 -0500

it is more efficient to use empty instead of size in these conditions

commit 3e9a21e76d1cb2ee10c220fa7a2f4d0dc8ae8e09
Author: Jean Utke <utke@…>
Date: Fri Sep 21 17:23:34 2012 -0500

fixed the behavior where the condition essentially makes the assumption
that the INDEXFELD must include the tail of the handed out locints as
if the locints were allocated in freed in LIFO fashion similar to the old
allocation scheme that this trying to avoid... details are below quoted from an e-mail
also changed some debug messages
================= Details =============

Below you see how the remaining open locations are tracked in just one remaining "IndexFeld?"
instance in the list where size counts down as locations are handed out in next_loc.

INDEXFELD ( 41772 , 3)
next_loc() , anzahl= 65534, groesse= 65536
next_loc: 41772 fill: 65534 max: 65536
INDEXFELD ( 41773 , 2)
next_loc() , anzahl= 65535, groesse= 65536
next_loc: 41773 fill: 65535 max: 65536
INDEXFELD ( 41774 , 1)
next_loc() , anzahl= 65536, groesse= 65536
next_loc: 41774 fill: 65536 max: 65536
INDEXFELD ( 41775 , 0)

Here we are now at the point where - after handing out location 41775
we have to grow so grow() is called:

StoreManagerIntegerBlock::grow(): increase size from 65536 to 131072 entries (currently 65536 entries used)
StoreManagerInteger::grow(): allocate 1048576 B doubles and 2097152 B LinkBlocks?
StoreManagerInteger::grow(): copy values
StoreManagerInteger::grow(): free 524288 + 1048576 B

Unfortunately the logic that should now modify the one remaining INDEXFELD mistakenly
assumes that there has to be an INDEXFELD satisfying something very much like
having locints (de)allocated in LIFO fashion as in the old ADOLC:

"iter->next + iter->size == alteGroesse"

but as you can see the one remaining one doesn't so
then this iter->size is *NOT updated*:
but we continue anyway:
Growing:
INDEXFELD ( 41775 , 0)

and now the next time we call next_loc we happily find the one IndexFeld? instance whose size is 0 and do:

indexFeld.front().size--;

and we get *... DRUMROLL ...* the wraparound for size:

INDEXFELD ( 41776 , 18446744073709551615)

and from there on things go downhill....

File:
1 edited

Legend:

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

    r337 r352  
    6969class StoreManager {
    7070protected:
    71   static size_t const initialeGroesse = 4;
     71  static size_t const initialSize = 4;
    7272public:
    7373  virtual ~StoreManager() {}
     
    8989protected:
    9090  double * &storePtr;
    91   locint * indexFeld;
     91  locint * indexFree;
    9292  locint head;
    93   size_t &groesse;
    94   size_t &anzahl;
     93  size_t &maxsize;
     94  size_t &currentfill;
    9595private:
    9696  void grow();
     
    101101
    102102  virtual ~StoreManagerLocint();
    103   virtual inline size_t size() const { return anzahl; }
    104 
    105   virtual inline size_t maxSize() const { return groesse; }
     103  virtual inline size_t size() const { return currentfill; }
     104
     105  virtual inline size_t maxSize() const { return maxsize; }
    106106
    107107  virtual inline bool realloc_on_next_loc() const {
     
    117117protected:
    118118    double * &storePtr;
    119     struct FeldBlock {
     119    struct FreeBlock {
    120120        locint next; // next location
    121121        size_t size; // number of following free locations
    122         FeldBlock(): next(0), size(0) {}
    123         FeldBlock(const struct FeldBlock &block) :
     122        FreeBlock(): next(0), size(0) {}
     123        FreeBlock(const struct FreeBlock &block) :
    124124            next(block.next),size(block.size) {}
    125125    };
    126126
    127     list<struct FeldBlock> indexFeld;
    128     size_t &groesse;
    129     size_t &anzahl;
     127    list<struct FreeBlock> indexFree;
     128    size_t &maxsize;
     129    size_t &currentfill;
    130130private:
    131     void grow( );
     131    /**
     132     * when minGrow is specified we asssume that we have already
     133     * search the blocks and found no block with minGrow locations in it
     134     */
     135    void grow(size_t minGrow=0 );
    132136public:
    133137    StoreManagerLocintBlock(double * &storePtr, size_t &size, size_t &numlives);
     
    135139
    136140    virtual ~StoreManagerLocintBlock();
    137     virtual inline size_t size() const { return anzahl; }
    138 
    139     virtual inline size_t maxSize() const { return groesse; }
     141    virtual inline size_t size() const { return currentfill; }
     142
     143    virtual inline size_t maxSize() const { return maxsize; }
    140144
    141145    virtual locint next_loc();
Note: See TracChangeset for help on using the changeset viewer.