Changeset 12988


Ignore:
Timestamp:
08/10/12 17:09:30 (13 years ago)
Author:
Eric.Larour
Message:

NEW: created wrapper to SolverxSeq solver, so that when running with Adolc support,
we can go from solving for a IssmDouble* vector solution to solving a double* vector
solution, and come back to an IssmDouble* vector.

In addition, added tape start phase and tape statistics at the beginning and end of issm.cpp
respectively.

Also fixed a bug (reCast type) in PddSurfaceMassBalance.

Fixed a bug in solve.m, where cluster.np was set to 1 too late for Adolc
runs.

config-macosx64-larour-ad.sh now defaults to using adolc.

Location:
issm/trunk-jpl
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/configs/config-macosx64-larour-ad.sh

    r12689 r12988  
    1717        --without-groundingline \
    1818        --without-kriging  \
    19         --with-gsl-dir=$ISSM_DIR/externalpackages/gsl/install
    20         #--with-adolc-dir=$ISSM_DIR/externalpackages/adolc/install\
     19        --with-gsl-dir=$ISSM_DIR/externalpackages/gsl/install \
     20        --with-adolc-dir=$ISSM_DIR/externalpackages/adolc/install
  • issm/trunk-jpl/src/c/classes/objects/Params/TransientParam.cpp

    r12832 r12988  
    9999void  TransientParam::GetParameterValue(IssmDouble* pdouble,IssmDouble time){
    100100
    101         double output;
     101        IssmDouble output;
    102102        bool   found;
    103103
  • issm/trunk-jpl/src/c/modules/Solverx/Solverx.h

    r12850 r12988  
    2525void SolverxSeq(SeqVec** puf,SeqMat* Kff, SeqVec* pf);
    2626void SolverxSeq(IssmDouble** pX,IssmDouble* A,IssmDouble* B,int n);
     27void SolverxSeq(double** pX,double* A,double* B,int n);
    2728
    2829#endif  /* _SOLVERX_H */
  • issm/trunk-jpl/src/c/modules/Solverx/SolverxSeq.cpp

    r12850 r12988  
    4444
    4545}/*}}}*/
    46 void SolverxSeq(IssmDouble** pX,IssmDouble* A,IssmDouble* B,int n){/*{{{*/
     46#ifdef _HAVE_ADOLC_
     47void SolverxSeq(IssmDouble** pX,IssmDouble* A,IssmDouble* B,int n){//{{{
     48        /* if we use Adol-C then the IssmDouble will be an adouble
     49           and the calls to gsl_... will not work.
     50           We therefore call a wrapped solver instead.
     51        */
    4752
     53        /*Output: */
     54        IssmDouble* X=NULL;
     55
     56        /*Intermediary: */
     57        int     i;
     58        double* doubleA=NULL;
     59        double* doubleB=NULL;
     60        double* doubleX=NULL;
     61
     62        /*First, transfer from IssmDouble to double all our matrices and vectors: */
     63        doubleA=xNew<double>(n*n);
     64        doubleB=xNew<double>(n);
     65        for(i=0;i<n*n;i++)A[i]>>=doubleA[i];
     66        for(i=0;i<n;i++)B[i]>>=doubleB[i];
     67       
     68        /*Call wrapped solver: */
     69        SolverxSeq(&doubleX,doubleA, doubleB, n);
     70
     71        /*Transfer solution vector from double to IssmDouble: */
     72        X = xNew<IssmDouble>(n);
     73        for(i=0;i<n;i++)X[i]<<=doubleX[i];
     74
     75        /*Free ressources:*/
     76        xDelete<double>(doubleA);
     77        xDelete<double>(doubleB);
     78
     79        /*Assign output pointers: */
     80        *pX=X;
     81}
     82/*}}}*/
     83#endif
     84//void SolverxSeq(double** pX,double* A,double* B,int n){ //{{{
     85#ifdef _HAVE_ADOLC_
     86void SolverxSeq(double** pX,double* A,double* B,int n){
     87#else
     88void SolverxSeq(IssmDouble** pX,IssmDouble* A,IssmDouble* B,int n){
     89#endif
    4890        #ifdef _HAVE_GSL_
    49                 /*GSL Matrices and vectors: */
    50                 int              s;
    51                 gsl_matrix_view  a;
    52                 gsl_vector_view  b;
    53                 gsl_vector      *x = NULL;
    54                 gsl_permutation *p = NULL;
    55                 #ifdef _HAVE_ADOLC_
    56                         // if we use Adol-C then the IssmDouble will be an adouble
    57                         // and the calls to gsl_... will not work
    58                         // and we should call  a suitable wrapped solve instead
    59                         _error2_("SolverxSeq: should not be here with Adol-C");
    60                 #else
    61                         /*A will be modified by LU decomposition. Use copy*/
    62                         IssmDouble* Acopy = xNew<IssmDouble>(n*n);
    63                         xMemCpy<IssmDouble>(Acopy,A,n*n);
     91        /*GSL Matrices and vectors: */
     92        int              s;
     93        gsl_matrix_view  a;
     94        gsl_vector_view  b;
     95        gsl_vector      *x = NULL;
     96        gsl_permutation *p = NULL;
     97        /*A will be modified by LU decomposition. Use copy*/
     98        double* Acopy = xNew<double>(n*n);
     99        xMemCpy<double>(Acopy,A,n*n);
    64100
    65                         /*Initialize gsl matrices and vectors: */
    66                         a = gsl_matrix_view_array (Acopy,n,n);
    67                         b = gsl_vector_view_array (B,n);
    68                         x = gsl_vector_alloc (n);
     101        /*Initialize gsl matrices and vectors: */
     102        a = gsl_matrix_view_array (Acopy,n,n);
     103        b = gsl_vector_view_array (B,n);
     104        x = gsl_vector_alloc (n);
    69105
    70                         /*Run LU and solve: */
    71                         p = gsl_permutation_alloc (n);
    72                         gsl_linalg_LU_decomp (&a.matrix, p, &s);
    73                         gsl_linalg_LU_solve (&a.matrix, p, &b.vector, x);
     106        /*Run LU and solve: */
     107        p = gsl_permutation_alloc (n);
     108        gsl_linalg_LU_decomp (&a.matrix, p, &s);
     109        gsl_linalg_LU_solve (&a.matrix, p, &b.vector, x);
    74110
    75                         //printf ("x = \n");
    76                         //gsl_vector_fprintf (stdout, x, "%g");
     111        //printf ("x = \n");
     112        //gsl_vector_fprintf (stdout, x, "%g");
    77113
    78                         /*Copy result*/
    79                         IssmDouble* X = xNew<IssmDouble>(n);
    80                         memcpy(X,gsl_vector_ptr(x,0),n*sizeof(IssmDouble));
     114        /*Copy result*/
     115        double* X = xNew<double>(n);
     116        memcpy(X,gsl_vector_ptr(x,0),n*sizeof(double));
    81117
    82                         /*Clean up and assign output pointer*/
    83                         xDelete<IssmDouble>(Acopy);
    84                         gsl_permutation_free(p);
    85                         gsl_vector_free(x);
    86                         *pX=X;
    87                 #endif
     118        /*Clean up and assign output pointer*/
     119        xDelete<double>(Acopy);
     120        gsl_permutation_free(p);
     121        gsl_vector_free(x);
     122        *pX=X;
    88123        #endif
    89 }/*}}}*/
     124}
     125/*}}}*/
  • issm/trunk-jpl/src/c/shared/Elements/PddSurfaceMassBalance.cpp

    r12867 r12988  
    8080      if (tstar < PDup){
    8181        pd = 1.;
    82         if (tstar >= -siglimc){ pd = pds[int(tstar/DT + siglim0c)];}}
     82        if (tstar >= -siglimc){ pd = pds[reCast<int,IssmDouble>(tstar/DT + siglim0c)];}}
    8383      else {
    8484        pd = 0.;}
     
    100100      if (tstar >= siglim) {pdd = pdd + tstar*deltm;}
    101101      else if (tstar> -siglim){
    102         pddsig=pdds[int(tstar/DT + siglim0)];
     102        pddsig=pdds[reCast<int,IssmDouble>(tstar/DT + siglim0)];
    103103        pdd = pdd + pddsig*deltm;
    104104        frzndd = frzndd - (tstar-pddsig)*deltm;}
  • issm/trunk-jpl/src/c/solutions/issm.cpp

    r12696 r12988  
    1414        bool  dakota_analysis,control_analysis,tao_analysis;
    1515
     16        /*AD: */
     17        int   tape_stats[11];
     18
    1619        /*FemModel: */
    1720        FemModel *femmodel = NULL;
     
    4144
    4245        ISSMBOOT();
     46
     47        /*If running AD, then initialize the tape: */
     48        #ifdef _HAVE_ADOLC_
     49        trace_on(1);
     50        #endif
    4351
    4452        /*Initialize environments: Petsc, MPI, etc...: */
     
    200208        #endif
    201209        #endif
     210
     211        /*If running AD, close our tape, print statistics: */
     212        #ifdef _HAVE_ADOLC_
     213        trace_off();
     214        tapestats(1,tape_stats); //reading of tape statistics
     215        _pprintLine_("   ADOLC statistics: ");
     216        _pprintLine_("   "<<setw(45)<<left<<"Number of independents: " <<tape_stats[0]);
     217        _pprintLine_("   "<<setw(45)<<left<<"Number of dependents: " <<tape_stats[1]);
     218        _pprintLine_("   "<<setw(45)<<left<<"Maximal number of live active variables: " <<tape_stats[2]);
     219        _pprintLine_("   "<<setw(45)<<left<<"Size of value stack (number of overwrites): " <<tape_stats[3]);
     220        _pprintLine_("   "<<setw(45)<<left<<"Buffer size (a multiple of eight): " <<tape_stats[4]);
     221        _pprintLine_("   "<<setw(45)<<left<<"Total number of operations recorded: " <<tape_stats[5]);
     222        #endif
    202223       
    203224        /*end module: */
  • issm/trunk-jpl/src/m/model/solve.m

    r12845 r12988  
    6868end
    6969
     70%we need to make sure we have PETSC support, otherwise, we run with only one cpu:
     71if ~ispetsc,
     72        disp('PETSC support not included, running on 1 cpu only!');
     73        cluster.np=1;
     74end
     75
     76
    7077%Wite all input files
    7178marshall(md);                                          % bin file
     
    7380BuildQueueScript(cluster,md.private.runtimename,md.miscellaneous.name,md.private.solution,md.settings.io_gather,md.debug.valgrind,md.debug.gprof); % queue file
    7481
    75 %we need to make sure we have PETSC support, otherwise, we run with only one cpu:
    76 if ~ispetsc,
    77         disp('PETSC support not included, running on 1 cpu only!');
    78         cluster.np=1;
    79 end
    8082
    8183%Stop here if batch mode
Note: See TracChangeset for help on using the changeset viewer.