Changeset 329 for branches


Ignore:
Timestamp:
Jun 28, 2012 5:16:44 AM (6 years ago)
Author:
kulshres
Message:

Merge branch 'advec' of 'gitclone' into svn branch

the following changeset were committed:

commit 35689c69c49e02fb1b211e4f873851ce734c839e
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri May 4 16:34:49 2012 +0200

add a comment for clarification

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

commit 710b93301d98610239f17dc40ba8cba6651f2ea5
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri May 4 14:21:49 2012 +0200

add copyright notices

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

commit 830f2cc75ba823c2343f4a524eb3e90ab02bc278
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu May 3 13:59:32 2012 +0200

Use the block allocation and don't write all locations to tape

Now that we ensure block structure while allocating an advector
we don't need to write all locations to tape in order to do
subscripting operations. We can use arithmetic.

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

commit 8599c889e5cd684a7066600835df5f0c033eb339
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu May 3 13:57:39 2012 +0200

Allocate advector ensuring contiguous locations

use a dummy blocker to call the function before calling the vector
constructor. Also use the fill constructor since the initialise
constructor is experimental (for some reason) and a fill constructor
is called internally by gcc anyway. This way we won't have to ensure a
n+1 block and get holes.

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

commit d62777e6070cf8b80b7b32616a874186e6463919
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Thu May 3 13:50:48 2012 +0200

Always put the last freed block to the front

This will make it efficienter if a block is deallocated right
one after the other. There will only be a search the first time
and all others will just work with the front of the list.

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

commit 1da1fa5bc7f5b9eada18c25026fd8ff25c8a91bb
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Apr 30 12:17:41 2012 +0200

simply get rid of fmin/fmax for doubles

most modern computers have this now and only cause conflicts

we should concentrate on finding cases where they are not defined
instead of where they are defined.

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

commit 33ae71a35fc04da062c4ba85659cbaf474caf1b8
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Fri Apr 27 17:36:41 2012 +0200

changes in StoreManagemerLocintBlock? to make it work right

add StoreManagerLocintBlock? to be the default StoreManager? in
tape_handling.cpp

All existing ADOL-C programs need to be tested again.

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

commit af30b922ee0a267555fdcdfe66d0823aa98688be
Author: Benjamin Letschert <letschi@…>
Date: Fri Apr 27 13:09:56 2012 +0200

Adding new storem anagement StoreManagerLocintBlock? to storemanager.h
and to tape_handling.cpp

commit 481e48172d773d5eab1c28b5190b4ba56f1c8bfe
Author: kulshres <kulshres@94ac48a7-3327-4b6a-8511-9a4036a20e83>
Date: Tue Apr 10 14:36:19 2012 +0000

regenerate files

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

git-svn-id: https://projects.coin-or.org/svn/ADOL-C/trunk@317 94ac48a7-3327-4b6a-8511-9a4036a20e83

commit c2c0d638dc69335333f35b4a37ce71a2a00037af
Author: kulshres <kulshres@94ac48a7-3327-4b6a-8511-9a4036a20e83>
Date: Tue Apr 10 14:36:09 2012 +0000

tweaks in configure

to check for fmin/fmax and get rid of some redundancies

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

git-svn-id: https://projects.coin-or.org/svn/ADOL-C/trunk@316 94ac48a7-3327-4b6a-8511-9a4036a20e83

commit ac86b35809c07c453aa5e3160a1da6bd63cd8f41
Author: kulshres <kulshres@94ac48a7-3327-4b6a-8511-9a4036a20e83>
Date: Fri Mar 30 12:51:29 2012 +0000

regenerate files

git-svn-id: https://projects.coin-or.org/svn/ADOL-C/trunk@315 94ac48a7-3327-4b6a-8511-9a4036a20e83

commit 96999453f3c1cb11f9543dca419dcd80ceb9ba64
Author: kulshres <kulshres@94ac48a7-3327-4b6a-8511-9a4036a20e83>
Date: Fri Mar 30 12:50:27 2012 +0000

get 'make distcheck' to work again

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

git-svn-id: https://projects.coin-or.org/svn/ADOL-C/trunk@314 94ac48a7-3327-4b6a-8511-9a4036a20e83

Location:
branches/advector
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • branches/advector/ADOL-C/src/adouble.cpp

    r284 r329  
    1313 
    1414 Copyright (c) Andrea Walther, Andreas Griewank, Andreas Kowarz,
    15                Hristo Mitev, Sebastian Schlenkrich, Jean Utke, Olaf Vogel
     15               Hristo Mitev, Sebastian Schlenkrich, Jean Utke, Olaf Vogel,
     16               Kshitij Kulshreshtha
    1617 
    1718 This file is part of ADOL-C. This software is provided as open source.
     
    4142    res = cond > 0 ? arg : res;
    4243}
    43 
    44 #if !defined(_ISOC99_SOURCE) && !defined(__USE_ISOC99)
    45 /*--------------------------------------------------------------------------*/
    46 double fmax( const double &x, const double &y ) {
    47     if (y > x)
    48         return y;
    49     else
    50         return x;
    51 }
    52 
    53 /*--------------------------------------------------------------------------*/
    54 double fmin( const double &x, const double &y ) {
    55     if (y < x)
    56         return y;
    57     else
    58         return x;
    59 }
    60 #endif
    6144
    6245/*--------------------------------------------------------------------------*/
  • branches/advector/ADOL-C/src/adouble.h

    r284 r329  
    1010
    1111 Copyright (c) Andrea Walther, Andreas Griewank, Andreas Kowarz,
    12                Hristo Mitev, Sebastian Schlenkrich, Jean Utke, Olaf Vogel
     12               Hristo Mitev, Sebastian Schlenkrich, Jean Utke, Olaf Vogel,
     13               Kshitij Kulshreshtha
    1314 
    1415 This file is part of ADOL-C. This software is provided as open source.
     
    6667void ADOLC_DLL_EXPORT condassign( double &res, const double &cond,
    6768                                  const double &arg );
    68 
    69 #if !defined(_ISOC99_SOURCE) && !defined(__USE_ISOC99) && !defined(__APPLE_CC__)
    70 double ADOLC_DLL_EXPORT fmin( const double &x, const double &y );
    71 double ADOLC_DLL_EXPORT fmax( const double &x, const double &y );
    72 #endif
    7369
    7470
  • branches/advector/ADOL-C/src/advector.cpp

    r284 r329  
    397397}
    398398
     399advector::blocker::blocker(size_t n) {
     400    dflt = new adouble;
     401    ensureContiguousLocations(n);
     402}
     403
    399404bool advector::nondecreasing() const {
    400405    bool ret = true;
     
    416421    static size_t callcounter  = 0;
    417422    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
    418         if (ADOLC_CURRENT_TAPE_INFOS.stats[LOC_BUFFER_SIZE] <= n+2) {
    419             fprintf( DIAG_OUT, "ADOL-C error: LBUFSIZE=%d is too small for operating on advector of size=%d, need > size+2",ADOLC_CURRENT_TAPE_INFOS.stats[LOC_BUFFER_SIZE],n);
    420             exit(-2);
    421         }
    422         if (ADOLC_CURRENT_TAPE_INFOS.currLoc + n + 2> ADOLC_CURRENT_TAPE_INFOS.lastLocP1) {
    423             *(ADOLC_CURRENT_TAPE_INFOS.lastLocP1 - 1) = ADOLC_CURRENT_TAPE_INFOS.lastLocP1 - ADOLC_CURRENT_TAPE_INFOS.currLoc;
    424             put_loc_block(ADOLC_CURRENT_TAPE_INFOS.lastLocP1);
    425             put_op(end_of_int);
    426         }
    427423        put_op(subscript);
    428424        ADOLC_PUT_LOCINT(index.loc());
    429425        ADOLC_PUT_LOCINT(locat);
    430426        ADOLC_PUT_VAL(n);
    431         for (int i = 0; i < n; i++)
    432             ADOLC_PUT_LOCINT(data[i].loc());
     427        ADOLC_PUT_LOCINT(data[0].loc());
    433428
    434429        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
     
    436431            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
    437432    }
     433
     434    if (idx >= n)
     435        fprintf(DIAG_OUT, "ADOL-C warning: index out of bounds while subscripting n=%z, idx=%z\n", n, idx);
     436
    438437    ADOLC_GLOBAL_TAPE_VARS.store[locat] = ADOLC_GLOBAL_TAPE_VARS.store[data[idx].loc()];
    439438    return locat;
     
    447446    size_t n = data.size();
    448447    if (ADOLC_CURRENT_TAPE_INFOS.traceFlag) {
    449         if (ADOLC_CURRENT_TAPE_INFOS.stats[LOC_BUFFER_SIZE] <= n+2) {
    450             fprintf( DIAG_OUT, "ADOL-C error: LBUFSIZE=%d is too small for operating on advector of size=%d, need > size+2",ADOLC_CURRENT_TAPE_INFOS.stats[LOC_BUFFER_SIZE],n);
    451             exit(-2);
    452         }
    453         if (ADOLC_CURRENT_TAPE_INFOS.currLoc + n + 2 > ADOLC_CURRENT_TAPE_INFOS.lastLocP1) {
    454             *(ADOLC_CURRENT_TAPE_INFOS.lastLocP1 - 1) = ADOLC_CURRENT_TAPE_INFOS.lastLocP1 - ADOLC_CURRENT_TAPE_INFOS.currLoc;
    455             put_loc_block(ADOLC_CURRENT_TAPE_INFOS.lastLocP1);
    456             put_op(end_of_int);
    457         }
    458448        put_op(subscript_ref);
    459449        ADOLC_PUT_LOCINT(index.loc());
    460450        ADOLC_PUT_LOCINT(locat);
    461451        ADOLC_PUT_VAL(n);
    462         for (int i = 0; i < n; i++)
    463             ADOLC_PUT_LOCINT(data[i].loc());
     452        ADOLC_PUT_LOCINT(data[0].loc());
    464453
    465454        ++ADOLC_CURRENT_TAPE_INFOS.numTays_Tape;
     
    467456            ADOLC_WRITE_SCAYLOR(ADOLC_GLOBAL_TAPE_VARS.store[locat]);
    468457    }
     458
     459    if (idx >= n)
     460        fprintf(DIAG_OUT, "ADOL-C warning: index out of bounds while subscripting (ref) n=%z, idx=%z\n", n, idx);
     461
    469462    ADOLC_GLOBAL_TAPE_VARS.store[locat] = data[idx].loc();
    470463    return adubref(locat,data[idx].loc());
  • branches/advector/ADOL-C/src/advector.h

    r284 r329  
    100100class ADOLC_DLL_EXPORT advector {
    101101private:
     102    struct blocker {
     103        adouble *dflt;
     104        blocker() {}
     105        blocker(size_t n);
     106        ~blocker() {}
     107    } blk;
    102108    std::vector<adouble> data;
    103109    bool nondecreasing() const;
    104110public:
    105     advector() : data() {}
    106     explicit advector(size_t n) : data(n) {}
     111    advector() : blk(), data() {}
     112    explicit advector(size_t n) : blk(n), data(n, *blk.dflt) { delete blk.dflt; }
    107113    ~advector() {}
    108     advector(const advector& x) : data(x.data) {}
    109     advector(const vector<adouble>& v) : data(v) {}
     114    advector(const advector& x) : blk(x.data.size()), data(x.data) { delete blk.dflt; }
     115    advector(const vector<adouble>& v) : blk(v.size()), data(v) { delete blk.dflt; }
    110116    size_t size() const { return data.size(); }
    111117    operator const vector<adouble>&() const { return data; }
  • branches/advector/ADOL-C/src/fo_rev.c

    r312 r329  
    16711671                    double val = get_val_r();
    16721672                    size_t cnt, idx, numval = (size_t)trunc(fabs(val));
    1673                     if (ADOLC_CURRENT_TAPE_INFOS.stats[LOC_BUFFER_SIZE] <= numval + 2) {
    1674                         fprintf( DIAG_OUT, "ADOL-C error: LBUFSIZE=%d is too small for operating on advector of size=%d, need > size+2",ADOLC_CURRENT_TAPE_INFOS.stats[LOC_BUFFER_SIZE],numval);
    1675                         exit(-2);
    1676                     }
    1677                     locint vectorloc[numval];
    1678                     for (cnt = 1; cnt <= numval; cnt++)
    1679                         vectorloc[numval - cnt] = get_locint_r();
     1673                    locint vectorloc;
     1674                    vectorloc = get_locint_r();
    16801675                    res = get_locint_r();
    16811676                    arg = get_locint_r();
    16821677#if !defined(_NTIGHT_)
    16831678                    idx = (size_t)trunc(fabs(TARG));
    1684                     arg1 = vectorloc[idx];
     1679                    if (idx >= numval)
     1680                        fprintf(DIAG_OUT, "ADOL-C warning: index out of bounds while subscripting n=%z, idx=%z\n", numval, idx);
     1681                    arg1 = vectorloc+idx;
    16851682                    ASSIGN_A( Aarg1, ADJOINT_BUFFER[arg1])
    16861683                    ASSIGN_A( Ares, ADJOINT_BUFFER[res])
     
    17071704                    double val = get_val_r();
    17081705                    size_t cnt, idx, numval = (size_t)trunc(fabs(val));
    1709                     if (ADOLC_CURRENT_TAPE_INFOS.stats[LOC_BUFFER_SIZE] <= numval + 2) {
    1710                         fprintf( DIAG_OUT, "ADOL-C error: LBUFSIZE=%d is too small for operating on advector of size=%d, need > size+2",ADOLC_CURRENT_TAPE_INFOS.stats[LOC_BUFFER_SIZE],numval);
    1711                         exit(-2);
    1712                     }
    1713                     locint vectorloc[numval];
    1714                     for (cnt = 1; cnt <= numval; cnt++)
    1715                         vectorloc[numval - cnt] = get_locint_r();
     1706                    locint vectorloc;
     1707                    vectorloc = get_locint_r();
    17161708                    res = get_locint_r();
    17171709                    arg = get_locint_r();
    17181710#if !defined(_NTIGHT_)
    17191711                    idx = (size_t)trunc(fabs(TARG));
     1712                    if (idx >= numval)
     1713                        fprintf(DIAG_OUT, "ADOL-C warning: index out of bounds while subscripting (ref) n=%z, idx=%z\n", numval, idx);
    17201714                    arg1 = (size_t)trunc(fabs(TRES));
    17211715                    // This is actually NOP
    1722                     // basically all we need is that arg1 == vectorloc[idx]
     1716                    // basically all we need is that arg1 == vectorloc+idx
    17231717                    // so doing a check here is probably good
    1724                     if (arg1 != vectorloc[idx]) {
    1725                         fprintf(DIAG_OUT, "ADOL-C error: indexed active position does not match referenced position\nindexed = %d, referenced = %d\n", vectorloc[idx], arg1);
     1718                    if (arg1 != vectorloc+idx) {
     1719                        fprintf(DIAG_OUT, "ADOL-C error: indexed active position does not match referenced position\nindexed = %d, referenced = %d\n", vectorloc+idx, arg1);
    17261720                        exit(-2);
    17271721                    }
  • branches/advector/ADOL-C/src/ho_rev.c

    r284 r329  
    20442044            case subscript:
    20452045                coval = get_val_r();
    2046                 if (ADOLC_CURRENT_TAPE_INFOS.stats[LOC_BUFFER_SIZE] <= coval + 2) {
    2047                     fprintf( DIAG_OUT, "ADOL-C error: LBUFSIZE=%d is too small for operating on advector of size=%d, need > size+2",ADOLC_CURRENT_TAPE_INFOS.stats[LOC_BUFFER_SIZE],coval);
    2048                         exit(-2);
    2049                     }
    20502046                {
    20512047                    size_t cnt, idx, numval = (size_t)trunc(fabs(coval));
    2052                     locint vectorloc[numval];
    2053                     for (cnt = 1; cnt <= numval; cnt++)
    2054                         vectorloc[numval - cnt] = get_locint_r();
     2048                    locint vectorloc;
     2049                    vectorloc = get_locint_r();
    20552050                    res = get_locint_r();
    20562051                    arg = get_locint_r();
    20572052                    ASSIGN_T(Targ, rpp_T[arg])
    20582053                    idx = (size_t)trunc(fabs(TARG));
    2059                     arg1 = vectorloc[idx];
     2054                    if (idx >= numval)
     2055                        fprintf(DIAG_OUT, "ADOL-C warning: index out of bounds while subscripting n=%z, idx=%z\n", numval, idx);
     2056                    arg1 = vectorloc+idx;
    20602057                    ASSIGN_A(Aarg1, rpp_A[arg1])
    20612058                    ASSIGN_A(Ares, rpp_A[res])
     
    20812078            case subscript_ref:
    20822079                coval = get_val_r();
    2083                 if (ADOLC_CURRENT_TAPE_INFOS.stats[LOC_BUFFER_SIZE] <= coval + 2) {
    2084                     fprintf( DIAG_OUT, "ADOL-C error: LBUFSIZE=%d is too small for operating on advector of size=%d, need > size+2",ADOLC_CURRENT_TAPE_INFOS.stats[LOC_BUFFER_SIZE],coval);
    2085                     exit(-2);
    2086                 }
    20872080                {
    20882081                    size_t cnt, idx, numval = (size_t)trunc(fabs(coval));
    2089                     locint vectorloc[numval];
    2090                     for (cnt = 1; cnt <= numval; cnt++)
    2091                         vectorloc[numval - cnt] = get_locint_r();
     2082                    locint vectorloc;
     2083                    vectorloc = get_locint_r();
    20922084                    res = get_locint_r();
    20932085                    arg = get_locint_r();
     
    20952087                    ASSIGN_T(Tres, rpp_T[res])
    20962088                    idx = (size_t)trunc(fabs(TARG));
     2089                    if (idx >= numval)
     2090                        fprintf(DIAG_OUT, "ADOL-C warning: index out of bounds while subscripting (ref) n=%z, idx=%z\n", numval, idx);
    20972091                    arg1 = (size_t)trunc(fabs(TRES));
    20982092                    // This is actually NOP
  • branches/advector/ADOL-C/src/storemanager.h

    r267 r329  
    99
    1010 Copyright (c) 2006 Johannes Willkomm <johannes.willkomm@rwth-aachen.de>
    11  Written by Johannes Willkomm <johannes.willkomm@rwth-aachen.de>
    12  
     11               2011-2012 Kshitij Kulshreshtha <kshitij@math.upb.de>
     12               2012 Benjamin Letschert <letschi@mail.upb.de>
     13
    1314 This file is part of ADOL-C.
    1415
     
    3536
    3637
     38 3) Have a look a class StoreManagerLocintBlock. This class uses a list of
     39    of free blocks of different sizes instead of free locations.
    3740
    3841 class StoreManagerInSitu
     
    5255
    5356 History:
     57          20120427 bl:     add blocking store management
    5458          20110208 kk:     incorporated in ADOL-C; moved some code arround
    5559          20060507 jw:     begin
     
    6165
    6266#include <adolc/common.h>
     67#include <list>
    6368
    6469class StoreManager {
     
    7075  virtual locint next_loc() = 0;
    7176  virtual void free_loc(locint) = 0;
     77  virtual void ensure_block(size_t n) = 0;
    7278
    7379//   // effectively the current size of the store array
     
    105111  virtual locint next_loc();
    106112  virtual void free_loc(locint loc);
     113  virtual void ensure_block(size_t n) {}
     114};
     115
     116class StoreManagerLocintBlock : public StoreManager {
     117protected:
     118    double * &storePtr;
     119    struct FeldBlock {
     120        locint next; // next location
     121        size_t size; // number of following free locations
     122        FeldBlock(): next(0), size(0) {}
     123        FeldBlock(const struct FeldBlock &block) :
     124            next(block.next),size(block.size) {}
     125    };
     126
     127    list<struct FeldBlock> indexFeld;
     128    size_t &groesse;
     129    size_t &anzahl;
     130private:
     131    void grow( );
     132public:
     133    StoreManagerLocintBlock(double * &storePtr, size_t &size, size_t &numlives);
     134    StoreManagerLocintBlock(const StoreManagerLocintBlock *const stm, double * &storePtr, size_t &size, size_t &numLives);
     135
     136    virtual ~StoreManagerLocintBlock();
     137    virtual inline size_t size() const { return anzahl; }
     138
     139    virtual inline size_t maxSize() const { return groesse; }
     140
     141    virtual locint next_loc();
     142    virtual void free_loc(locint loc);
     143    virtual void ensure_block(size_t n);
    107144};
    108145
  • branches/advector/ADOL-C/src/tape_handling.cpp

    r312 r329  
    55 Contents: management of tape infos
    66
    7  Copyright (c) Andreas Kowarz, Andrea Walther
    8  
     7 Copyright (c) Andreas Kowarz, Andrea Walther, Kshitij Kulshreshtha,
     8               Benjamin Letschert
     9
    910 This file is part of ADOL-C. This software is provided as open source.
    1011 Any use, reproduction, or distribution of the software constitutes
     
    4344  storeSize = 0;
    4445  numLives = 1;
    45   storeManagerPtr = new StoreManagerLocint(store, storeSize, numLives);
     46  storeManagerPtr = new StoreManagerLocintBlock(store, storeSize, numLives);
    4647}
    4748
     
    6970    memcpy(store, gtv.store, storeSize*sizeof(double));
    7071    storeManagerPtr = new
    71         StoreManagerLocint(
    72             dynamic_cast<StoreManagerLocint*>(gtv.storeManagerPtr),
     72        StoreManagerLocintBlock(
     73            dynamic_cast<StoreManagerLocintBlock*>(gtv.storeManagerPtr),
    7374            store, storeSize, numLives);
    7475    return *this;
     
    10991100                    ADOLC_GLOBAL_TAPE_VARS.storeSize * sizeof(double));
    11001101            ADOLC_GLOBAL_TAPE_VARS.storeManagerPtr = new
    1101                 StoreManagerLocint(
    1102                     dynamic_cast<StoreManagerLocint*>(globalTapeVars_s->storeManagerPtr),
     1102                StoreManagerLocintBlock(
     1103                    dynamic_cast<StoreManagerLocintBlock*>(globalTapeVars_s->storeManagerPtr),
    11031104                    ADOLC_GLOBAL_TAPE_VARS.store,
    11041105                    ADOLC_GLOBAL_TAPE_VARS.storeSize,
     
    11791180}
    11801181
     1182StoreManagerLocintBlock::StoreManagerLocintBlock(double * &storePtr, size_t &size, size_t &numlives) :
     1183    storePtr(storePtr),
     1184    groesse(size), anzahl(numlives)
     1185{
     1186    indexFeld.clear();
     1187#ifdef ADOLC_DEBUG
     1188    std::cerr << "StoreManagerIntegerBlock::StoreManagerIntegerBlock()\n";
     1189#endif
     1190}
     1191
     1192StoreManagerLocintBlock::~StoreManagerLocintBlock()
     1193{
     1194#ifdef ADOLC_DEBUG
     1195    std::cerr << "StoreManagerIntegerBlock::~StoreManagerIntegerBlock()\n";
     1196#endif
     1197    if (storePtr) {
     1198     delete[] storePtr;
     1199     storePtr = 0;
     1200    }
     1201    if (indexFeld.size() ) {
     1202        indexFeld.clear();
     1203    }
     1204    groesse = 0;
     1205    anzahl = 0;
     1206}
     1207
     1208StoreManagerLocintBlock::StoreManagerLocintBlock(
     1209    const StoreManagerLocintBlock *const stm,
     1210    double * &storePtr, size_t &size, size_t &numlives) :
     1211    storePtr(storePtr),
     1212    groesse(size), anzahl(numlives)
     1213{
     1214#ifdef ADOLC_DEBUG
     1215    std::cerr << "StoreManagerInteger::StoreManagerInteger()\n";
     1216#endif
     1217    indexFeld.clear();
     1218    list<struct FeldBlock>::const_iterator iter = stm->indexFeld.begin();
     1219    for (; iter != stm->indexFeld.end(); iter++)
     1220        indexFeld.push_back( *iter );
     1221}
     1222
     1223
     1224locint StoreManagerLocintBlock::next_loc() {
     1225    if ( indexFeld.size()==0 )
     1226        grow();
     1227
     1228    locint const result = indexFeld.front().next;
     1229    indexFeld.front().next++;
     1230    indexFeld.front().size--;
     1231
     1232    if (indexFeld.front().size == 0)
     1233          indexFeld.pop_front();
     1234
     1235    ++anzahl;
     1236
     1237#ifdef ADOLC_DEBUG
     1238     std::cerr  << "next_loc() , anzahl= " <<anzahl << ", groesse= "<< groesse << endl;
     1239    list<struct FeldBlock>::iterator iter = indexFeld.begin();
     1240    for( ; iter != indexFeld.end(); iter++ )
     1241       std::cerr << "INDEXFELD ( " << iter->next << " , " << iter->size << ")" << endl;
     1242    std::cerr << "next_loc: " << result << " fill: " << size() << "max: " << maxSize() << endl;
     1243#endif
     1244    return result;
     1245}
     1246
     1247void StoreManagerLocintBlock::ensure_block(size_t n) {
     1248    bool grown = false;
     1249
     1250    if ( indexFeld.size()==0 ) {
     1251#ifdef ADOLC_DEBUG
     1252        std::cerr << "no free blocks...growing " << endl;
     1253#endif
     1254        grow();
     1255        grown = true;
     1256    }
     1257
     1258    while (indexFeld.front().size < n) {
     1259        if (grown && indexFeld.back().size >= n) {
     1260#ifdef ADOLC_DEBUG
     1261            std::cerr << "bringing back to front " << endl;
     1262#endif
     1263            struct FeldBlock tmp(indexFeld.back());
     1264            indexFeld.pop_back();
     1265            indexFeld.push_front(tmp);
     1266        }
     1267        else if (grown && indexFeld.back().size < n) {
     1268#ifdef ADOLC_DEBUG
     1269            std::cerr << "still not enough...growing " << endl;
     1270#endif
     1271            grow();
     1272        }
     1273        else {
     1274#ifdef ADOLC_DEBUG
     1275            std::cerr << "searching for big enough block " << endl;
     1276#endif
     1277            bool found = false;
     1278            list<struct FeldBlock>::iterator iter = indexFeld.begin();
     1279            for (; iter != indexFeld.end() ; iter++ ) {
     1280                if ( iter->size >= n) {
     1281                    if (iter != indexFeld.begin() ) {
     1282                        struct FeldBlock tmp(*iter);
     1283                        iter = indexFeld.erase(iter);
     1284                        indexFeld.push_front(tmp);
     1285                    }
     1286                    found = true;
     1287                    break;
     1288                }
     1289            }
     1290            if (!found) {
     1291#ifdef ADOLC_DEBUG
     1292                std::cerr << "no big enough block...growing " << endl;
     1293#endif
     1294                grow();
     1295                grown = true;
     1296            }
     1297        }
     1298    }
     1299
     1300#ifdef ADOLC_DEBUG
     1301    std::cerr << "ensure_Block: " << " fill: " << size() << "max: " << maxSize() << endl;
     1302    std::cerr << "ensure_Block (" << n << ")" << endl;
     1303    list<struct FeldBlock>::iterator iter = indexFeld.begin();
     1304    for( ; iter != indexFeld.end(); iter++ )
     1305       std::cerr << "INDEXFELD ( " << iter->next << " , " << iter->size << ")" << endl;
     1306#endif
     1307}
     1308
     1309void StoreManagerLocintBlock::grow() {
     1310    if (groesse == 0){
     1311        groesse += initialeGroesse;
     1312        struct FeldBlock tmp;
     1313        tmp.next = 0;
     1314        tmp.size = groesse;
     1315        indexFeld.push_back(tmp);
     1316    }
     1317
     1318    size_t const alteGroesse = groesse;
     1319    groesse *= 2;
     1320
     1321    if (groesse > std::numeric_limits<locint>::max()) {
     1322      // encapsulate this error message
     1323      fprintf(DIAG_OUT,"\nADOL-C error:\n");
     1324      fprintf(DIAG_OUT,"maximal number (%d) of live active variables exceeded\n\n",
     1325           std::numeric_limits<locint>::max());
     1326      exit(-3);
     1327    }
     1328
     1329#ifdef ADOLC_DEBUG
     1330    // index 0 is not used, means one slot less
     1331    std::cerr << "StoreManagerIntegerBlock::grow(): increase size from " << alteGroesse
     1332      << " to " << groesse << " entries (currently " << size() << " entries used)\n";
     1333#endif
     1334
     1335    double *const oldStore = storePtr;
     1336
     1337#if defined(ADOLC_DEBUG)
     1338    std::cerr << "StoreManagerInteger::grow(): allocate " << groesse * sizeof(double) << " B doubles "
     1339      << "and " << groesse * sizeof(struct FeldBlock) << " B LinkBlocks\n";
     1340#endif
     1341    storePtr = new double[groesse];
     1342    memset(storePtr, 0, groesse*sizeof(double));
     1343    size_t i = 0;
     1344
     1345    if (alteGroesse != initialeGroesse) { // not the first time
     1346#if defined(ADOLC_DEBUG)
     1347      std::cerr << "StoreManagerInteger::grow(): copy values\n";
     1348#endif
     1349      for (size_t j = i; j < alteGroesse; ++j) {
     1350          storePtr[j] = oldStore[j];
     1351      }
     1352
     1353#if defined(ADOLC_DEBUG)
     1354      std::cerr << "StoreManagerInteger::grow(): free " << alteGroesse * sizeof(double)
     1355          << " + " << alteGroesse * sizeof(struct FeldBlock) << " B\n";
     1356#endif
     1357      delete [] oldStore;
     1358    }
     1359    list<struct FeldBlock>::iterator iter = indexFeld.begin();
     1360    for (; iter != indexFeld.end() ; iter++ ) {
     1361         if (iter->next + iter->size == alteGroesse ) {
     1362              iter->size += alteGroesse;
     1363              // move the block to the end of the list because that is where
     1364              // other functions expect the newly grown block to be
     1365              struct FeldBlock tmp(*iter);
     1366              iter = indexFeld.erase(iter);
     1367              indexFeld.push_back(tmp);
     1368              break;
     1369         }
     1370    }
     1371    if (iter == indexFeld.end()) {
     1372         struct FeldBlock tmp;
     1373         tmp.next = alteGroesse;
     1374         tmp.size = alteGroesse;
     1375         indexFeld.push_back(tmp);
     1376    }
     1377#ifdef ADOLC_DEBUG
     1378    std::cerr << "Growing:" << endl;
     1379    iter = indexFeld.begin();
     1380    for( ; iter != indexFeld.end(); iter++ )
     1381       std::cerr << "INDEXFELD ( " << iter->next << " , " << iter->size << ")" << endl;
     1382#endif
     1383}
     1384
     1385void StoreManagerLocintBlock::free_loc(locint loc) {
     1386    assert( loc < groesse);
     1387
     1388    list<struct FeldBlock>::iterator iter = indexFeld.begin();
     1389    for (; iter != indexFeld.end() ; iter++ ) {
     1390         if (loc+1 == iter->next || iter->next + iter->size == loc) {
     1391              iter->size++;
     1392              if (loc + 1 == iter->next)
     1393                   iter->next = loc;
     1394    // bringing the matched element to the front maybe a good idea
     1395    // in case several contiguous adouble are deallcated right after
     1396    // one another, e.g. advector
     1397              struct FeldBlock tmp(*iter);
     1398              iter = indexFeld.erase(iter);
     1399              indexFeld.push_front(tmp);
     1400              iter = indexFeld.begin();
     1401              break;
     1402         }
     1403    }
     1404    if (iter == indexFeld.end()) {
     1405         struct FeldBlock tmp;
     1406         tmp.next = loc;
     1407         tmp.size = 1;
     1408         indexFeld.push_front(tmp);
     1409    }
     1410
     1411    --anzahl;
     1412#ifdef ADOLC_DEBUG
     1413    std::cerr << "free_loc: " << loc << " fill: " << size() << "max: " << maxSize() << endl;
     1414
     1415    iter = indexFeld.begin();
     1416    for( ; iter != indexFeld.end(); iter++ )
     1417       std::cerr << "INDEXFELD ( " << iter->next << " , " << iter->size << ")" << endl;
     1418#endif
     1419}
     1420
     1421void ensureContiguousLocations(size_t n) {
     1422    ADOLC_OPENMP_THREAD_NUMBER;
     1423    ADOLC_OPENMP_GET_THREAD_NUMBER;
     1424    ADOLC_GLOBAL_TAPE_VARS.storeManagerPtr->ensure_block(n);
     1425}
  • branches/advector/ADOL-C/src/taping.c

    r312 r329  
    77
    88 Copyright (c) Andrea Walther, Andreas Griewank, Andreas Kowarz,
    9                Hristo Mitev, Sebastian Schlenkrich, Jean Utke, Olaf Vogel
     9               Hristo Mitev, Sebastian Schlenkrich, Jean Utke, Olaf Vogel,
     10               Kshitij Kulshreshtha
    1011 
    1112 This file is part of ADOL-C. This software is provided as open source.
  • branches/advector/ADOL-C/src/taping.h

    r312 r329  
    5757ADOLC_DLL_EXPORT void disableBranchSwitchWarnings();
    5858
     59ADOLC_DLL_EXPORT void ensureContiguousLocations(size_t n);
     60
    5961END_C_DECLS
    6062
  • branches/advector/ADOL-C/src/uni5_for.c

    r312 r329  
    35233523            case subscript:
    35243524                coval = get_val_f();
    3525                 if (ADOLC_CURRENT_TAPE_INFOS.stats[LOC_BUFFER_SIZE] <= coval + 2) {
    3526                     fprintf( DIAG_OUT, "ADOL-C error: LBUFSIZE=%d is too small for operating on advector of size=%d, need > size+2",ADOLC_CURRENT_TAPE_INFOS.stats[LOC_BUFFER_SIZE],coval);
    3527                     exit(-2);
    3528                 }
    35293525                arg = get_locint_f();
    35303526                res = get_locint_f();
    35313527                {
    35323528                    size_t cnt, idx, numvar = (size_t)trunc(fabs(coval));
    3533                     locint vectorloc[numvar];
    3534                     for (cnt = 0; cnt < numvar; cnt++)
    3535                         vectorloc[cnt] = get_locint_f();
     3529                    locint vectorloc;
     3530                    vectorloc = get_locint_f();
    35363531#if !defined(_NTIGHT_)
    35373532                    idx = (size_t)trunc(fabs(dp_T0[arg]));
    3538                     arg1 = vectorloc[idx];
     3533                    if (idx >= numvar)
     3534                        fprintf(DIAG_OUT, "ADOL-C warning: index out of bounds while subscripting n=%z, idx=%z\n", numvar, idx);
     3535                    arg1 = vectorloc+idx;
    35393536                    IF_KEEP_WRITE_TAYLOR(res,keep,k,p);
    35403537                    dp_T0[res] = dp_T0[arg1];
     
    35593556            case subscript_ref:
    35603557                coval = get_val_f();
    3561                 if (ADOLC_CURRENT_TAPE_INFOS.stats[LOC_BUFFER_SIZE] <= coval + 2) {
    3562                     fprintf( DIAG_OUT, "ADOL-C error: LBUFSIZE=%d is too small for operating on advector of size=%d, need > size+2",ADOLC_CURRENT_TAPE_INFOS.stats[LOC_BUFFER_SIZE],coval);
    3563                     exit(-2);
    3564                 }
    35653558                arg = get_locint_f();
    35663559                res = get_locint_f();
    35673560                {
    35683561                    size_t cnt, idx, numvar = (size_t)trunc(fabs(coval));
    3569                     locint vectorloc[numvar];
    3570                     for (cnt = 0; cnt < numvar; cnt++)
    3571                         vectorloc[cnt] = get_locint_f();
     3562                    locint vectorloc;
     3563                    vectorloc = get_locint_f();
    35723564#if !defined(_NTIGHT_)
    35733565                    idx = (size_t)trunc(fabs(dp_T0[arg]));
    3574                     arg1 = vectorloc[idx];
     3566                    if (idx >= numvar)
     3567                        fprintf(DIAG_OUT, "ADOL-C warning: index out of bounds while subscripting (ref) n=%z, idx=%z\n", numvar, idx);
     3568                    arg1 = vectorloc+idx;
    35753569                    IF_KEEP_WRITE_TAYLOR(res,keep,k,p);
    35763570                    dp_T0[res] = arg1;
  • branches/advector/MSVisualStudio/v10/nosparse/config.h

    r312 r329  
    3232#define HAVE_FLOOR 1
    3333
     34/* Define to 1 if you have the `fmax' function. */
     35#define HAVE_FMAX 1
     36
     37/* Define to 1 if you have the `fmin' function. */
     38#define HAVE_FMIN 1
     39
    3440/* Define to 1 if you have the `ftime' function. */
    3541#define HAVE_FTIME 1
     
    4046/* Define 1 if ColPack is available */
    4147/* #undef HAVE_LIBCOLPACK */
    42 
    43 /* Define to 1 if you have the `m' library (-lm). */
    44 #define HAVE_LIBM 1
    4548
    4649/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
     
    9699/* Define to 1 if you have the <sys/types.h> header file. */
    97100#define HAVE_SYS_TYPES_H 1
     101
     102/* Define to 1 if you have the `trunc' function. */
     103#define HAVE_TRUNC 1
    98104
    99105/* Define to 1 if you have the <unistd.h> header file. */
  • branches/advector/MSVisualStudio/v10/nosparse/config.h.in

    r210 r329  
    3232#define HAVE_FLOOR 1
    3333
     34/* Define to 1 if you have the `fmax' function. */
     35#define HAVE_FMAX 1
     36
     37/* Define to 1 if you have the `fmin' function. */
     38#define HAVE_FMIN 1
     39
    3440/* Define to 1 if you have the `ftime' function. */
    3541#define HAVE_FTIME 1
     
    4046/* Define 1 if ColPack is available */
    4147/* #undef HAVE_LIBCOLPACK */
    42 
    43 /* Define to 1 if you have the `m' library (-lm). */
    44 #define HAVE_LIBM 1
    4548
    4649/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
     
    9699/* Define to 1 if you have the <sys/types.h> header file. */
    97100#define HAVE_SYS_TYPES_H 1
     101
     102/* Define to 1 if you have the `trunc' function. */
     103#define HAVE_TRUNC 1
    98104
    99105/* Define to 1 if you have the <unistd.h> header file. */
  • branches/advector/MSVisualStudio/v10/sparse/config.h

    r312 r329  
    3232#define HAVE_FLOOR 1
    3333
     34/* Define to 1 if you have the `fmax' function. */
     35#define HAVE_FMAX 1
     36
     37/* Define to 1 if you have the `fmin' function. */
     38#define HAVE_FMIN 1
     39
    3440/* Define to 1 if you have the `ftime' function. */
    3541#define HAVE_FTIME 1
     
    4046/* Define 1 if ColPack is available */
    4147#define HAVE_LIBCOLPACK 1
    42 
    43 /* Define to 1 if you have the `m' library (-lm). */
    44 #define HAVE_LIBM 1
    4548
    4649/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
     
    9699/* Define to 1 if you have the <sys/types.h> header file. */
    97100#define HAVE_SYS_TYPES_H 1
     101
     102/* Define to 1 if you have the `trunc' function. */
     103#define HAVE_TRUNC 1
    98104
    99105/* Define to 1 if you have the <unistd.h> header file. */
  • branches/advector/MSVisualStudio/v10/sparse/config.h.in

    r210 r329  
    3232#define HAVE_FLOOR 1
    3333
     34/* Define to 1 if you have the `fmax' function. */
     35#define HAVE_FMAX 1
     36
     37/* Define to 1 if you have the `fmin' function. */
     38#define HAVE_FMIN 1
     39
    3440/* Define to 1 if you have the `ftime' function. */
    3541#define HAVE_FTIME 1
     
    4046/* Define 1 if ColPack is available */
    4147#define HAVE_LIBCOLPACK 1
    42 
    43 /* Define to 1 if you have the `m' library (-lm). */
    44 #define HAVE_LIBM 1
    4548
    4649/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
     
    9699/* Define to 1 if you have the <sys/types.h> header file. */
    97100#define HAVE_SYS_TYPES_H 1
     101
     102/* Define to 1 if you have the `trunc' function. */
     103#define HAVE_TRUNC 1
    98104
    99105/* Define to 1 if you have the <unistd.h> header file. */
  • branches/advector/MSVisualStudio/v10/x64/nosparse/config.h

    r312 r329  
    3232#define HAVE_FLOOR 1
    3333
     34/* Define to 1 if you have the `fmax' function. */
     35#define HAVE_FMAX 1
     36
     37/* Define to 1 if you have the `fmin' function. */
     38#define HAVE_FMIN 1
     39
    3440/* Define to 1 if you have the `ftime' function. */
    3541#define HAVE_FTIME 1
     
    4046/* Define 1 if ColPack is available */
    4147/* #undef HAVE_LIBCOLPACK */
    42 
    43 /* Define to 1 if you have the `m' library (-lm). */
    44 #define HAVE_LIBM 1
    4548
    4649/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
     
    9699/* Define to 1 if you have the <sys/types.h> header file. */
    97100#define HAVE_SYS_TYPES_H 1
     101
     102/* Define to 1 if you have the `trunc' function. */
     103#define HAVE_TRUNC 1
    98104
    99105/* Define to 1 if you have the <unistd.h> header file. */
  • branches/advector/MSVisualStudio/v10/x64/nosparse/config.h.in

    r210 r329  
    3232#define HAVE_FLOOR 1
    3333
     34/* Define to 1 if you have the `fmax' function. */
     35#define HAVE_FMAX 1
     36
     37/* Define to 1 if you have the `fmin' function. */
     38#define HAVE_FMIN 1
     39
    3440/* Define to 1 if you have the `ftime' function. */
    3541#define HAVE_FTIME 1
     
    4046/* Define 1 if ColPack is available */
    4147/* #undef HAVE_LIBCOLPACK */
    42 
    43 /* Define to 1 if you have the `m' library (-lm). */
    44 #define HAVE_LIBM 1
    4548
    4649/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
     
    9699/* Define to 1 if you have the <sys/types.h> header file. */
    97100#define HAVE_SYS_TYPES_H 1
     101
     102/* Define to 1 if you have the `trunc' function. */
     103#define HAVE_TRUNC 1
    98104
    99105/* Define to 1 if you have the <unistd.h> header file. */
  • branches/advector/MSVisualStudio/v10/x64/sparse/config.h

    r312 r329  
    3232#define HAVE_FLOOR 1
    3333
     34/* Define to 1 if you have the `fmax' function. */
     35#define HAVE_FMAX 1
     36
     37/* Define to 1 if you have the `fmin' function. */
     38#define HAVE_FMIN 1
     39
    3440/* Define to 1 if you have the `ftime' function. */
    3541#define HAVE_FTIME 1
     
    4046/* Define 1 if ColPack is available */
    4147#define HAVE_LIBCOLPACK 1
    42 
    43 /* Define to 1 if you have the `m' library (-lm). */
    44 #define HAVE_LIBM 1
    4548
    4649/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
     
    9699/* Define to 1 if you have the <sys/types.h> header file. */
    97100#define HAVE_SYS_TYPES_H 1
     101
     102/* Define to 1 if you have the `trunc' function. */
     103#define HAVE_TRUNC 1
    98104
    99105/* Define to 1 if you have the <unistd.h> header file. */
  • branches/advector/MSVisualStudio/v10/x64/sparse/config.h.in

    r210 r329  
    3232#define HAVE_FLOOR 1
    3333
     34/* Define to 1 if you have the `fmax' function. */
     35#define HAVE_FMAX 1
     36
     37/* Define to 1 if you have the `fmin' function. */
     38#define HAVE_FMIN 1
     39
    3440/* Define to 1 if you have the `ftime' function. */
    3541#define HAVE_FTIME 1
     
    4046/* Define 1 if ColPack is available */
    4147#define HAVE_LIBCOLPACK 1
    42 
    43 /* Define to 1 if you have the `m' library (-lm). */
    44 #define HAVE_LIBM 1
    4548
    4649/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
     
    9699/* Define to 1 if you have the <sys/types.h> header file. */
    97100#define HAVE_SYS_TYPES_H 1
     101
     102/* Define to 1 if you have the `trunc' function. */
     103#define HAVE_TRUNC 1
    98104
    99105/* Define to 1 if you have the <unistd.h> header file. */
  • branches/advector/Makefile.am

    r226 r329  
    2222                       ADOL-C/doc/tapebasic.pdf ADOL-C/doc/tapebasic.eps \
    2323                       ADOL-C/doc/tap_point.pdf ADOL-C/doc/tap_point.eps \
    24                        autoconf/shave.in autoconf/shave-libtool.in \
    25                        autoconf/dolt.m4 autoconf/shave.m4 \
    2624                       MSVisualStudio/v10/adolc.sln MSVisualStudio/v10/adolc.vcxproj \
     25                       MSVisualStudio/v10/ColPack_Readme_VC++.txt \
     26                       MSVisualStudio/v10/ColPack.vcxproj \
    2727                       MSVisualStudio/v10/sparse/config.h.in MSVisualStudio/v10/nosparse/config.h.in \
    2828                       MSVisualStudio/v10/x64/sparse/config.h.in MSVisualStudio/v10/x64/nosparse/config.h.in \
     
    3232                       MSVisualStudio/v10/installer.sh \
    3333                       adolc.spec.in adolc.spec \
    34                        update_versions.sh \
    35                        ThirdParty/ColPack/ColPack.vcxproj \
    36                        ThirdParty/ColPack/Readme_VC++.txt
     34                       update_versions.sh
    3735
    3836SUBDIRS              = ADOL-C
    39 
    40 MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure ADOL-C/src/config.h.in \
    41                        ADOL-C/src/stamp-h.in *~ *.orig
    42 
    43 DISTCLEANFILES = doltcompile doltlibtool
    4437
    4538test: all
  • branches/advector/configure.ac

    r312 r329  
    5151   _lib=lib
    5252fi
    53 libdir='${prefix}/${_lib}'
     53libdir='${exec_prefix}/${_lib}'
    5454AC_SUBST(_lib)
    5555AC_SUBST(libdir)
     
    7070AC_FUNC_MALLOC
    7171AC_FUNC_REALLOC
    72 AC_CHECK_FUNCS([floor ftime pow sqrt strchr strtol])
     72
     73# Checks for libraries and fuctions
     74AC_SEARCH_LIBS([pow], [m])
     75AC_CHECK_FUNCS([floor fmax fmin ftime pow sqrt strchr strtol trunc])
    7376
    7477# substitutions
    7578AC_SUBST(ac_aux_dir)
    76 
    77 # Checks for libraries
    78 AC_CHECK_LIB([m], [pow])
    7979
    8080# ADOL-C configuration
     
    164164             AC_MSG_RESULT(no)])
    165165
    166 test "x${ac_pwd}" = x && ac_pwd=`pwd`
    167 abs_srcdir=`readlink -f ${ac_pwd}/${srcdir}`
    168166AC_ARG_WITH(colpack,
    169167        [
    170168AS_HELP_STRING([--with-colpack=DIR],[path to the colpack library and headers [default=${srcdir}/ThirdParty/ColPack]])],
    171                 [
     169[
    172170colpack=$withval
    173171COLPACK_CFLAGS="$ac_adolc_openmpflag -I$colpack/include"
Note: See TracChangeset for help on using the changeset viewer.