Changeset 26432


Ignore:
Timestamp:
09/04/21 18:06:05 (4 years ago)
Author:
Mathieu Morlighem
Message:

CHG: working on integrating CoDiPack 2.0, still not working

Location:
issm/trunk-jpl/src/c
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk-jpl/src/c/classes/FemModel.cpp

    r26165 r26432  
    23072307
    23082308                        #if defined(_HAVE_CODIPACK_)
    2309                         auto& tape_codi = IssmDouble::getGlobalTape();
     2309                        auto& tape_codi = IssmDouble::getTape();
    23102310                        #endif
    23112311
     
    23192319                                                tape_codi.registerOutput(output_value);
    23202320                                                dependents[i] = output_value.getValue();
    2321                                                 codi_global.output_indices.push_back(output_value.getGradientData());
     2321                                                codi_global.output_indices.push_back(output_value.getIdentifier());
    23222322                                        #else
    23232323                                                output_value>>=dependents[i];
  • TabularUnified issm/trunk-jpl/src/c/classes/IoModel.cpp

    r26253 r26432  
    20652065                                scalar=pscalar;
    20662066                        }
    2067                         auto& tape_codi = IssmDouble::getGlobalTape();
     2067                        auto& tape_codi = IssmDouble::getTape();
    20682068                        tape_codi.registerInput(scalar);
    2069                         codi_global.input_indices.push_back(scalar.getGradientData());
     2069                        codi_global.input_indices.push_back(scalar.getIdentifier());
    20702070                #else
    20712071                        if(X){
     
    21382138                        #if defined(_HAVE_CODIPACK_)
    21392139                                // FIXME codi here we just assign instead of using "operator <<="
    2140                                 auto& tape_codi = IssmDouble::getGlobalTape();
     2140                                auto& tape_codi = IssmDouble::getTape();
    21412141                                if(X){
    21422142                                        for (int i=0;i<M*N;i++) {
    21432143                                                matrix[i]=X[Xcount+i];
    21442144                                                tape_codi.registerInput(matrix[i]);
    2145                                                 codi_global.input_indices.push_back(matrix[i].getGradientData());
     2145                                                codi_global.input_indices.push_back(matrix[i].getIdentifier());
    21462146                                        }
    21472147                                }
     
    21502150                                                matrix[i]=buffer[i];
    21512151                                                tape_codi.registerInput(matrix[i]);
    2152                                                 codi_global.input_indices.push_back(matrix[i].getGradientData());
     2152                                                codi_global.input_indices.push_back(matrix[i].getIdentifier());
    21532153                                        }
    21542154                                }
     
    29632963                 * -> These parameters are not read for the CoDiPack ISSM version!
    29642964                 */
    2965                 auto& tape_codi = IssmDouble::getGlobalTape();
     2965                auto& tape_codi = IssmDouble::getTape();
    29662966                tape_codi.setActive();
    29672967                #if _AD_TAPE_ALLOC_
     
    29762976                /*
    29772977                std::stringstream out_s;
    2978                 IssmDouble::getGlobalTape().printStatistics(out_s);
     2978                IssmDouble::getTape().printStatistics(out_s);
    29792979                _printf0_("StartTrace::Tape Statistics     : TapeAlloc count=[" << codi_allocn << "]\n" << out_s.str());
    29802980                */
  • TabularUnified issm/trunk-jpl/src/c/cores/ad_core.cpp

    r23250 r26432  
    326326
    327327                        /*First, stop tracing: */
    328                         auto& tape_codi = IssmDouble::getGlobalTape();
     328                        auto& tape_codi = IssmDouble::getTape();
    329329                        tape_codi.setPassive();
    330330
  • TabularUnified issm/trunk-jpl/src/c/cores/controladm1qn3_core.cpp

    r25793 r26432  
    7575                 * -> These parameters are not read for the CoDiPack ISSM version!
    7676                 */
    77                 auto& tape_codi = IssmDouble::getGlobalTape();
     77                auto& tape_codi = IssmDouble::getTape();
    7878                tape_codi.setActive();
    7979                #if _AD_TAPE_ALLOC_
     
    8888                /*
    8989                std::stringstream out_s;
    90                 IssmDouble::getGlobalTape().printStatistics(out_s);
     90                IssmDouble::getTape().printStatistics(out_s);
    9191                _printf0_("StartTrace::Tape Statistics     : TapeAlloc count=[" << codi_allocn << "]\n" << out_s.str());
    9292                */
     
    153153                #endif
    154154                std::stringstream out_s;
    155                 IssmDouble::getGlobalTape().printStatistics(out_s);
     155                IssmDouble::getTape().printStatistics(out_s);
    156156                _printf0_("CoDiPack Profiling::Tape Statistics :\n" << out_s.str());
    157157                #endif
     
    159159
    160160        #elif defined(_HAVE_CODIPACK_)
    161         auto& tape_codi = IssmDouble::getGlobalTape();
     161        auto& tape_codi = IssmDouble::getTape();
    162162        tape_codi.setPassive();
    163163        if(VerboseAutodiff()){
     
    239239        }
    240240        #elif defined(_HAVE_CODIPACK_)
    241         auto& tape_codi = IssmDouble::getGlobalTape();
     241        auto& tape_codi = IssmDouble::getTape();
    242242        codi_global.input_indices.clear();
    243243        if(my_rank==0){
     
    245245                        aX[i]=X[i];
    246246                        tape_codi.registerInput(aX[i]);
    247                         codi_global.input_indices.push_back(aX[i].getGradientData());
     247                        codi_global.input_indices.push_back(aX[i].getIdentifier());
    248248                }
    249249        }
     
    285285                        tape_codi.registerOutput(output_value);
    286286                        dependents[i] = output_value.getValue();
    287                         codi_global.output_indices.push_back(output_value.getGradientData());
     287                        codi_global.output_indices.push_back(output_value.getIdentifier());
    288288
    289289                        #elif defined(_HAVE_ADOLC_)
  • TabularUnified issm/trunk-jpl/src/c/cores/controlvalidation_core.cpp

    r25578 r26432  
    5050                 * -> These parameters are not read for the CoDiPack ISSM version!
    5151                 */
    52                 auto& tape_codi = IssmDouble::getGlobalTape();
     52                auto& tape_codi = IssmDouble::getTape();
    5353                tape_codi.setActive();
    5454                #if _AD_TAPE_ALLOC_
     
    6363                /*
    6464                std::stringstream out_s;
    65                 IssmDouble::getGlobalTape().printStatistics(out_s);
     65                IssmDouble::getTape().printStatistics(out_s);
    6666                _printf0_("StartTrace::Tape Statistics     : TapeAlloc count=[" << codi_allocn << "]\n" << out_s.str());
    6767                */
     
    127127                #endif
    128128                std::stringstream out_s;
    129                 IssmDouble::getGlobalTape().printStatistics(out_s);
     129                IssmDouble::getTape().printStatistics(out_s);
    130130                _printf0_("CoDiPack Profiling::Tape Statistics :\n" << out_s.str());
    131131                #endif
     
    133133
    134134        #elif defined(_HAVE_CODIPACK_)
    135         auto& tape_codi = IssmDouble::getGlobalTape();
     135        auto& tape_codi = IssmDouble::getTape();
    136136        tape_codi.setPassive();
    137137        if(VerboseAutodiff()){
     
    190190        simul_starttrace2(femmodel);
    191191        IssmDouble* aX=xNew<IssmDouble>(n);
    192         auto& tape_codi = IssmDouble::getGlobalTape();
     192        auto& tape_codi = IssmDouble::getTape();
    193193        codi_global.input_indices.clear();
    194194        if(my_rank==0){
     
    196196                        aX[i]=X0[i];
    197197                        tape_codi.registerInput(aX[i]);
    198                         codi_global.input_indices.push_back(aX[i].getGradientData());
     198                        codi_global.input_indices.push_back(aX[i].getIdentifier());
    199199                }
    200200        }
     
    230230                        tape_codi.registerOutput(output_value);
    231231                        dependents[i] = output_value.getValue();
    232                         codi_global.output_indices.push_back(output_value.getGradientData());
     232                        codi_global.output_indices.push_back(output_value.getIdentifier());
    233233                        J+=output_value;
    234234                }
  • TabularUnified issm/trunk-jpl/src/c/cores/transient_core.cpp

    r26224 r26432  
    374374
    375375        /*Start tracing*/
    376         auto& tape_codi = IssmDouble::getGlobalTape();
     376        auto& tape_codi = IssmDouble::getTape();
    377377        tape_codi.setActive();
    378378
  • TabularUnified issm/trunk-jpl/src/c/shared/io/Marshalling/Marshalling.cpp

    r25543 r26432  
    7575        this->identifiers  = identifiers_in;
    7676        this->size_max         = size_max_in;
    77         this->tape_codi    = &(IssmDouble::getGlobalTape());
     77        this->tape_codi    = &(IssmDouble::getTape());
    7878}/*}}}*/
    7979void RegisterInputFunctor::Echo(void){/*{{{*/
     
    8484        _assert_(this->double_count<size_max);
    8585        this->tape_codi->registerInput(value);
    86         this->identifiers[this->double_count] = value.getGradientData();
     86        this->identifiers[this->double_count] = value.getIdentifier();
    8787        this->double_count++;
    8888}/*}}}*/
     
    9292                        _assert_(this->double_count<size_max);
    9393                        this->tape_codi->registerInput(value[i]);
    94                         this->identifiers[this->double_count] = value[i].getGradientData();
     94                        this->identifiers[this->double_count] = value[i].getIdentifier();
    9595                        this->double_count++;
    9696                }
     
    100100RegisterOutputFunctor::RegisterOutputFunctor(void) : MarshallHandle(AD_REGISTEROUTPUT){/*{{{*/
    101101        this->double_count = 0;
    102         this->tape_codi    = &(IssmDouble::getGlobalTape());
     102        this->tape_codi    = &(IssmDouble::getTape());
    103103}/*}}}*/
    104104void RegisterOutputFunctor::Echo(void){/*{{{*/
     
    121121SetAdjointFunctor::SetAdjointFunctor(double* adjoint_in,int size_max_in) : MarshallHandle(AD_SETADJOINT){/*{{{*/
    122122        this->double_count = 0;
    123         this->tape_codi    = &(IssmDouble::getGlobalTape());
     123        this->tape_codi    = &(IssmDouble::getTape());
    124124        this->adjoint      = adjoint_in;
    125125        this->size_max     = size_max_in;
  • TabularUnified issm/trunk-jpl/src/c/shared/io/Marshalling/Marshalling.h

    r25543 r26432  
    128128                int *identifiers;
    129129                int  size_max;
    130                 IssmDouble::TapeType *tape_codi;
     130                IssmDouble::Tape *tape_codi;
    131131
    132132        public:
     
    142142        private:
    143143                int   double_count;
    144                 IssmDouble::TapeType* tape_codi;
     144                IssmDouble::Tape* tape_codi;
    145145
    146146        public:
     
    157157                int                   double_count;
    158158                int                   size_max;
    159                 IssmDouble::TapeType* tape_codi;
     159                IssmDouble::Tape* tape_codi;
    160160                double*               adjoint;
    161161
  • TabularUnified issm/trunk-jpl/src/c/toolkits/codipack/CoDiPackCommon.hpp

    r23241 r26432  
    3535inline void getVectorGradData(const Real* vec, Data* dataVec, int n) {
    3636  for(int i = 0; i < n; ++i) {
    37     dataVec[i]=vec[i].getGradientData();
     37    dataVec[i]=vec[i].getIdentifier();
    3838  }
    3939}
     
    4343  for(int i = 0; i < n; ++i) {
    4444    pasVec[i]=vec[i].getValue();
    45     dataVec[i]=vec[i].getGradientData();
     45    dataVec[i]=vec[i].getIdentifier();
    4646  }
    4747}
     
    5050inline void getPrimalAndGradData(const Real& value, Passive& pas, Data& data) {
    5151  pas=value.getValue();
    52   data=value.getGradientData();
     52  data=value.getIdentifier();
    5353}
    5454
    5555template<typename Real, typename Data>
    5656inline void registerVector(Real* vec, Data* dataVec, int n) {
    57   typename Real::TapeType& tape = Real::getGlobalTape();
     57  typename Real::TapeType& tape = Real::getTape();
    5858
    5959  for(int i = 0; i < n; ++i) {
    6060    tape.registerInput(vec[i]);
    61     dataVec[i]=vec[i].getGradientData();
     61    dataVec[i]=vec[i].getIdentifier();
    6262  }
    6363}
  • TabularUnified issm/trunk-jpl/src/c/toolkits/gsl/DenseGslSolve.cpp

    r25336 r26432  
    258258        /*recast data_in and tape*/
    259259        codi::DataStore* data = (codi::DataStore*)data_in;
    260         //IssmDouble::TapeType& tape = (IssmDouble::TapeType&)tape_in;
    261         IssmDouble::TapeType& tape = IssmDouble::getGlobalTape();
     260        //IssmDouble::Tape& tape = (IssmDouble::Tape&)tape_in;
     261        IssmDouble::Tape& tape = IssmDouble::getTape();
    262262
    263263  IssmDouble::Real* valueATrans;
     
    277277
    278278  // create the adjoint vector for x and reset the adjoint values on the tape
    279   IssmDouble::GradientValue* adjX = xNew<IssmDouble::GradientValue>(n);
     279  IssmDouble::Gradient* adjX = xNew<IssmDouble::Gradient>(n);
    280280  getVectorAdjoint(tape, indexX, adjX, n);
    281281
    282   IssmDouble::GradientValue* sol  = xNew<IssmDouble::GradientValue>(n);
     282  IssmDouble::Gradient* sol  = xNew<IssmDouble::Gradient>(n);
    283283  SolverxSeq(sol, valueATrans, adjX, n);
    284284
     
    324324/*}}}*/
    325325void SolverxSeq(IssmDouble *X,IssmDouble *A,IssmDouble *B,int n, Parameters* parameters){/*{{{*/
    326   IssmDouble::TapeType& tape = IssmDouble::getGlobalTape();
     326  IssmDouble::Tape& tape = IssmDouble::getTape();
    327327  codi::DataStore* dataHandler = NULL;
    328328
  • TabularUnified issm/trunk-jpl/src/c/toolkits/mpi/issmmpi.h

    r24768 r26432  
    3131                        //#define AMPI_ADOUBLE TOOL::MPI_TYPE
    3232                        //
     33                        //#include <codi/externals/codiMpiTypes.hpp>
     34                        //using MpiTypes = CoDiMpiTypes<IssmDouble>;
    3335                        /*New implementation*/
    34                         #include <codi/externals/codiMpiTypes.hpp>
    35                         using MpiTypes = CoDiMpiTypes<IssmDouble>;
     36                        #include <codi/tools/mpi/codiMpiTypes.hpp>
     37         using MpiTypes = codi::CoDiMpiTypes<IssmDouble>;
    3638                        extern MpiTypes* mpiTypes;
    3739                        #define AMPI_ADOUBLE mpiTypes->MPI_TYPE
  • TabularUnified issm/trunk-jpl/src/c/toolkits/mumps/MumpsSolve.cpp

    r25336 r26432  
    489489        /*recast data_in and tape*/
    490490  codi::DataStore* data = (codi::DataStore*)data_in;
    491   //IssmDouble::TapeType& tape = (IssmDouble::TapeType&)tape_in;
    492   IssmDouble::TapeType& tape = IssmDouble::getGlobalTape();
     491  //IssmDouble::Tape& tape = (IssmDouble::Tape&)tape_in;
     492  IssmDouble::Tape& tape = IssmDouble::getTape();
    493493
    494494
     
    518518
    519519  // create the adjoint vector for x and reset the adjoint values on the tape
    520   IssmDouble::GradientValue* adjX = xNew<IssmDouble::GradientValue>(n);
     520  IssmDouble::Gradient* adjX = xNew<IssmDouble::Gradient>(n);
    521521  getVectorAdjoint(tape, indexX, adjX, n);
    522522
     
    581581/*}}}*/
    582582void MumpsSolve(int n,int nnz,int local_nnz,int* irn_loc,int* jcn_loc,IssmDouble *a_loc,IssmDouble *rhs,Parameters* parameters){/*{{{*/
    583   IssmDouble::TapeType& tape = IssmDouble::getGlobalTape();
     583  IssmDouble::Tape& tape = IssmDouble::getTape();
    584584  codi::DataStore* dataHandler = NULL;
    585585
Note: See TracChangeset for help on using the changeset viewer.