Changeset 199


Ignore:
Timestamp:
Feb 22, 2011 8:25:56 AM (8 years ago)
Author:
kulshres
Message:

don't save the whole store on tape unconditionally in take/keep_stock

we need to save the store only if there are live adoubles at the time
of take/keep_stock call.

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

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

Legend:

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

    r198 r199  
    8686  locint head;
    8787  size_t &groesse;
    88   size_t anzahl;
     88  size_t &anzahl;
    8989private:
    9090  void grow();
    9191public:
    9292
    93   StoreManagerLocint(double * &storePtr, size_t &size);
     93  StoreManagerLocint(double * &storePtr, size_t &size, size_t &numlives);
    9494
    9595  virtual ~StoreManagerLocint();
  • trunk/ADOL-C/src/tape_handling.cpp

    r198 r199  
    4242  store = 0;
    4343  storeSize = 0;
    44   storeManagerPtr = new StoreManagerLocint(store, storeSize);
     44  numLives = 0;
     45  storeManagerPtr = new StoreManagerLocint(store, storeSize, numLives);
    4546}
    4647
     
    5253}
    5354
    54 StoreManagerLocint::StoreManagerLocint(double * &storePtr, size_t &size) :
     55StoreManagerLocint::StoreManagerLocint(double * &storePtr, size_t &size, size_t &numlives) :
    5556    storePtr(storePtr),
    5657    indexFeld(0),
    5758    head(0),
    58     groesse(size), anzahl(0)
     59    groesse(size), anzahl(numlives)
    5960{
    6061#ifdef ADOLC_DEBUG
    6162    std::cerr << "StoreManagerInteger::StoreManagerInteger()\n";
    6263#endif
    63     groesse = initialeGroesse;
    6464}
    6565
     
    9797
    9898void StoreManagerLocint::free_loc(locint loc) {
    99     assert(loc < groesse);
     99    assert(0 < loc && loc < groesse);
    100100    indexFeld[loc] = head;
    101101    head = loc;
    102102    --anzahl;
     103    storePtr[loc] = 0.0;
    103104#ifdef ADOLC_DEBUG
    104105    std::cerr << "free_loc: " << loc << " fill: " << size() << "max: " << maxSize() << endl;
     
    107108
    108109void StoreManagerLocint::grow() {
     110    if (groesse == 0) groesse += initialGroesse;
    109111    size_t const alteGroesse = groesse;
    110112    groesse *= 2;
     
    134136    storePtr = new double[groesse];
    135137    indexFeld = new locint[groesse];
    136 
     138    memset(storePtr, 0, groesse*sizeof(double));
    137139    // we use index 0 as end-of-list marker
    138140    size_t i = 1;
  • trunk/ADOL-C/src/taping.c

    r198 r199  
    555555 * - intended to be used in start_trace only */
    556556void take_stock() {
    557     locint space_left, vals_left, loc = 0;
     557    locint space_left, loc = 0;
    558558    double *vals;
     559    size_t vals_left;
    559560    ADOLC_OPENMP_THREAD_NUMBER;
    560561
     
    563564    vals_left = ADOLC_GLOBAL_TAPE_VARS.storeSize;
    564565    vals      = ADOLC_GLOBAL_TAPE_VARS.store;
    565 
     566   
     567    /* if we have adoubles in use */
     568    if (ADOLC_GLOBAL_TAPE_VARS.numLives > 0) {
    566569    /* fill the current values (real) tape buffer and write it to disk
    567570     * - do this as long as buffer can be fully filled */
     
    584587        put_vals_notWriteBlock(vals, vals_left);
    585588    }
     589    }
    586590    ADOLC_CURRENT_TAPE_INFOS.traceFlag = 1;
    587591}
     
    596600    ADOLC_OPENMP_GET_THREAD_NUMBER;
    597601    /* if we have adoubles in use */
    598     if (ADOLC_GLOBAL_TAPE_VARS.storeSize > 0) {
     602    if (ADOLC_GLOBAL_TAPE_VARS.numLives > 0) {
    599603        locint loc2 = ADOLC_GLOBAL_TAPE_VARS.storeSize - 1;
    600604
     
    602606         * value stack -> special handling at the beginning of reverse */
    603607        put_op(death_not);
    604         ADOLC_PUT_LOCINT(0);    /* lowest loc */
     608        ADOLC_PUT_LOCINT(1);    /* lowest loc */
    605609        ADOLC_PUT_LOCINT(loc2); /* highest loc */
    606610
    607         ADOLC_CURRENT_TAPE_INFOS.numTays_Tape += ADOLC_GLOBAL_TAPE_VARS.storeSize;
     611        ADOLC_CURRENT_TAPE_INFOS.numTays_Tape += ADOLC_GLOBAL_TAPE_VARS.storeSize - 1;
    608612        /* now really do it if keepTaylors ist set */
    609613        if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors) {
    610614            do {
    611615                ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[loc2]);
    612             } while (loc2-- > 0);
     616            } while (--loc2 > 0);
    613617        }
    614618    }
  • trunk/ADOL-C/src/taping_p.h

    r198 r199  
    271271    double* store;              /* double store for calc. while taping */
    272272    size_t storeSize;
     273    size_t numLives;
    273274    locint maxLoc;
    274275
     
    284285    TapeInfos *currentTapeInfosPtr;
    285286#ifdef __cplusplus
     287    StoreManager *storeManagerPtr;
    286288    GlobalTapeVarsCL();
    287289    ~GlobalTapeVarsCL();
    288     StoreManager *storeManagerPtr;
    289290#else
    290291    void *storeManagerPtr;
Note: See TracChangeset for help on using the changeset viewer.