Changeset 267


Ignore:
Timestamp:
Aug 9, 2011 7:39:06 AM (9 years ago)
Author:
kulshres
Message:

allow openmp to work with the new memory manager

needs further testing to ensure consistency of derivatives

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

Location:
trunk/ADOL-C
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/ADOL-C/examples/additional_examples/openmp_exam/liborser.cpp

    r42 r267  
    112112  Nmat = 40;
    113113  N = Nmat+40;
    114   npath = 100;
     114  npath = 30;
    115115
    116116  lambda   = new double[N];
     
    140140      for (i=0; i<Nmat; i++)
    141141        {
    142           z[j][i] = 0.2+j*0.00001;
    143           xp[j][N+i]=  0.2+j*0.00001;
     142          z[j][i] = 0.3;
     143          xp[j][N+i]=  0.3;
    144144        }
    145145    }
     
    171171       
    172172      va >>= v[i];
    173     trace_off();
     173    trace_off(1);
    174174
    175175    for(i=0;i<npath;i++)
  • trunk/ADOL-C/src/sparse/sparsedrivers.cpp

    r204 r267  
    650650    TapeInfos *tapeInfos;
    651651
     652    ADOLC_OPENMP_THREAD_NUMBER;
     653    ADOLC_OPENMP_GET_THREAD_NUMBER;
     654
    652655    tapeInfos=getTapeInfos(tag);
    653656    memcpy(&ADOLC_CURRENT_TAPE_INFOS, tapeInfos, sizeof(TapeInfos));
     
    680683    SparseHessInfos sHinfos;
    681684    TapeInfos *tapeInfos;
     685
     686    ADOLC_OPENMP_THREAD_NUMBER;
     687    ADOLC_OPENMP_GET_THREAD_NUMBER;
    682688
    683689    tapeInfos=getTapeInfos(tag);
  • trunk/ADOL-C/src/storemanager.h

    r199 r267  
    9292
    9393  StoreManagerLocint(double * &storePtr, size_t &size, size_t &numlives);
     94  StoreManagerLocint(const StoreManagerLocint *const stm, double * &storePtr, size_t &size, size_t &numLives);
    9495
    9596  virtual ~StoreManagerLocint();
  • trunk/ADOL-C/src/tape_handling.cpp

    r228 r267  
    5353}
    5454
     55const GlobalTapeVarsCL& GlobalTapeVarsCL::operator=(const GlobalTapeVarsCL& gtv) {
     56    storeSize = gtv.storeSize;
     57    numLives = gtv.numLives;
     58    maxLoc = gtv.maxLoc;
     59    operationBufferSize = gtv.operationBufferSize;
     60    locationBufferSize = gtv.locationBufferSize;
     61    valueBufferSize = gtv.valueBufferSize;
     62    taylorBufferSize = gtv.taylorBufferSize;
     63    maxNumberTaylorBuffers = gtv.maxNumberTaylorBuffers;
     64    inParallelRegion = gtv.inParallelRegion;
     65    newTape = gtv.newTape;
     66    branchSwitchWarning = gtv.branchSwitchWarning;
     67    currentTapeInfosPtr = gtv.currentTapeInfosPtr;
     68    store = new double[storeSize];
     69    memcpy(store, gtv.store, storeSize*sizeof(double));
     70    storeManagerPtr = new StoreManagerLocint(dynamic_cast<StoreManagerLocint*>(gtv.storeManagerPtr), store, storeSize, numLives);
     71    return *this;
     72}
     73
    5574StoreManagerLocint::StoreManagerLocint(double * &storePtr, size_t &size, size_t &numlives) :
    5675    storePtr(storePtr),
     
    8099    anzahl = 0;
    81100    head = 0;
     101}
     102
     103StoreManagerLocint::StoreManagerLocint(const StoreManagerLocint *const stm, double * &storePtr, size_t &size, size_t &numlives) :
     104    storePtr(storePtr),
     105    groesse(size), anzahl(numlives)
     106{
     107#ifdef ADOLC_DEBUG
     108    std::cerr << "StoreManagerInteger::StoreManagerInteger()\n";
     109#endif
     110    head = stm->head;
     111    indexFeld = new locint[groesse];
     112    for (int i = 0; i < groesse; i++)
     113        indexFeld[i] = stm->indexFeld[i];
    82114}
    83115
     
    10401072    if (firstParallel) {
    10411073        ADOLC_EXT_DIFF_FCTS_BUFFER.init(init_CpInfos);
    1042         memcpy(&ADOLC_GLOBAL_TAPE_VARS, globalTapeVars_s, sizeof(GlobalTapeVars));
    1043         ADOLC_GLOBAL_TAPE_VARS.store = (double *)
    1044             malloc(sizeof(double) * ADOLC_GLOBAL_TAPE_VARS.storeSize);
    1045         memcpy(ADOLC_GLOBAL_TAPE_VARS.store, globalTapeVars_s->store,
    1046                 ADOLC_GLOBAL_TAPE_VARS.locMinUnused * sizeof(double));
     1074
     1075        /* Use assignment operator instead of open coding
     1076         * this copies the store and the storemanager too
     1077         */
     1078        ADOLC_GLOBAL_TAPE_VARS = *globalTapeVars_s;
     1079
    10471080        ADOLC_GLOBAL_TAPE_VARS.newTape = 0;
    10481081        ADOLC_CURRENT_TAPE_INFOS.tapingComplete = 1;
     
    10501083    } else {
    10511084        if (ADOLC_parallel_doCopy) {
    1052             ADOLC_GLOBAL_TAPE_VARS.locMinUnused = globalTapeVars_s->locMinUnused;
    1053             ADOLC_GLOBAL_TAPE_VARS.numMaxAlive = globalTapeVars_s->numMaxAlive;
    10541085            ADOLC_GLOBAL_TAPE_VARS.storeSize = globalTapeVars_s->storeSize;
    1055             ADOLC_GLOBAL_TAPE_VARS.numToFree = globalTapeVars_s->numToFree;
    1056             ADOLC_GLOBAL_TAPE_VARS.minLocToFree = globalTapeVars_s->minLocToFree;
     1086            ADOLC_GLOBAL_TAPE_VARS.numLives = globalTapeVars_s->numLives;
     1087           
    10571088            ADOLC_GLOBAL_TAPE_VARS.branchSwitchWarning = globalTapeVars_s->branchSwitchWarning;
    1058             free(ADOLC_GLOBAL_TAPE_VARS.store);
    1059             ADOLC_GLOBAL_TAPE_VARS.store = (double *)
    1060                 malloc(sizeof(double) * ADOLC_GLOBAL_TAPE_VARS.storeSize);
     1089
     1090            /* deleting the storemanager deletes the store too */
     1091            delete ADOLC_GLOBAL_TAPE_VARS.storeManagerPtr;
     1092
     1093            ADOLC_GLOBAL_TAPE_VARS.store = new
     1094                double[ADOLC_GLOBAL_TAPE_VARS.storeSize];
    10611095            memcpy(ADOLC_GLOBAL_TAPE_VARS.store, globalTapeVars_s->store,
    1062                     ADOLC_GLOBAL_TAPE_VARS.locMinUnused * sizeof(double));
     1096                    ADOLC_GLOBAL_TAPE_VARS.storeSize * sizeof(double));
     1097            ADOLC_GLOBAL_TAPE_VARS.storeManagerPtr = new StoreManagerLocint(dynamic_cast<StoreManagerLocint*>(globalTapeVars_s->storeManagerPtr), ADOLC_GLOBAL_TAPE_VARS.store, ADOLC_GLOBAL_TAPE_VARS.storeSize, ADOLC_GLOBAL_TAPE_VARS.numLives);
    10631098        }
    10641099    }
  • trunk/ADOL-C/src/taping_p.h

    r262 r267  
    289289    GlobalTapeVarsCL();
    290290    ~GlobalTapeVarsCL();
     291    const GlobalTapeVarsCL& operator=(const GlobalTapeVarsCL&);
    291292#else
    292293    void *storeManagerPtr;
     
    296297
    297298#if defined(_OPENMP)
    298 #error nicht hier
     299
    299300extern int isParallel();
    300301
Note: See TracChangeset for help on using the changeset viewer.