Ignore:
Timestamp:
Nov 22, 2012 8:18:52 AM (7 years ago)
Author:
kulshres
Message:

Merge branch '2.3.x_ISSM' into svn

This introduces the new externally differentiated functions API

From: Jean Utke <utke@…>

Please see comments in ADOL-C/include/adolc/externfcts.h for details

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ADOL-C/src/externfcts.cpp

    r342 r370  
    6565  edf->spp_nz=0;
    6666
     67  edf->max_n=0;
     68  edf->max_m=0;
     69
     70  edf->nestedAdolc=true;
     71  edf->dp_x_changes=true;
     72  edf->dp_y_priorRequired=true;
     73
    6774  return edf;
    6875}
     
    7885    ADOLC_OPENMP_GET_THREAD_NUMBER;
    7986
     87    if (xa[n-1].loc()-xa[0].loc()!=n-1 || ya[m-1].loc()-ya[0].loc()!=m-1) fail(ADOLC_EXT_DIFF_LOCATIONGAP);
    8088    if (edfct==NULL) fail(ADOLC_EXT_DIFF_NULLPOINTER_STRUCT);
    8189
     
    93101    } else oldTraceFlag=0;
    94102
    95     numVals = ADOLC_GLOBAL_TAPE_VARS.storeSize;
    96     vals = new double[numVals];
    97     memcpy(vals, ADOLC_GLOBAL_TAPE_VARS.store,
    98             numVals * sizeof(double));
     103    if (edfct->nestedAdolc) {
     104      numVals = ADOLC_GLOBAL_TAPE_VARS.storeSize;
     105      vals = new double[numVals];
     106      memcpy(vals, ADOLC_GLOBAL_TAPE_VARS.store,
     107             numVals * sizeof(double));
     108    }
    99109
    100     for (i=0; i<n; ++i) xp[i]=xa[i].getValue();
    101     for (i=0; i<m; ++i) yp[i]=ya[i].getValue();
    102 
    103     ret=edfct->function(n, xp, m, yp);
    104 
    105     memcpy(ADOLC_GLOBAL_TAPE_VARS.store, vals,
    106             numVals * sizeof(double));
    107     delete[] vals;
     110    edfct->max_n=(edfct->max_n<n)?n:edfct->max_n;
     111    edfct->max_m=(edfct->max_m<m)?m:edfct->max_m;
    108112
    109113    /* update taylor buffer if keep != 0 ; possible double counting as in
     
    111115
    112116    if (oldTraceFlag != 0) {
    113         ADOLC_CURRENT_TAPE_INFOS.numTays_Tape += n;
    114         ADOLC_CURRENT_TAPE_INFOS.numTays_Tape += m;
    115         if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors) {
    116             for (i=0; i<n; ++i) ADOLC_WRITE_SCAYLOR(xa[i].getValue());
    117             for (i=0; i<m; ++i) ADOLC_WRITE_SCAYLOR(ya[i].getValue());
    118         }
     117      if (edfct->dp_x_changes) ADOLC_CURRENT_TAPE_INFOS.numTays_Tape += n;
     118      if (edfct->dp_y_priorRequired) ADOLC_CURRENT_TAPE_INFOS.numTays_Tape += m;
     119      if (ADOLC_CURRENT_TAPE_INFOS.keepTaylors) {
     120        if (edfct->dp_x_changes) for (i=0; i<n; ++i) ADOLC_WRITE_SCAYLOR(xa[i].getValue());
     121        if (edfct->dp_y_priorRequired) for (i=0; i<m; ++i) ADOLC_WRITE_SCAYLOR(ya[i].getValue());
     122      }
    119123    }
     124
     125    for (i=0; i<n; ++i) xp[i]=xa[i].getValue();
     126    if (edfct->dp_y_priorRequired) for (i=0; i<m; ++i) yp[i]=ya[i].getValue();
     127
     128    ret=edfct->function(n, xp, m, yp);
     129
     130    if (edfct->nestedAdolc) {
     131      memcpy(ADOLC_GLOBAL_TAPE_VARS.store, vals,
     132          numVals * sizeof(double));
     133      delete[] vals;
     134    }
     135
    120136    /* write back */
    121     for (i=0; i<n; ++i) xa[i].setValue(xp[i]);
     137    if (edfct->dp_x_changes) for (i=0; i<n; ++i) xa[i].setValue(xp[i]);
    122138    for (i=0; i<m; ++i) ya[i].setValue(yp[i]);
    123139
Note: See TracChangeset for help on using the changeset viewer.