Changeset 25530


Ignore:
Timestamp:
09/03/20 21:04:49 (5 years ago)
Author:
Mathieu Morlighem
Message:

CHG: putting non template function into CPP file to speed up compilation

Location:
issm/trunk-jpl/src/c
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/Makefile.am

    r25465 r25530  
    147147        ./shared/io/Comm/IssmComm.cpp \
    148148        ./shared/io/Marshalling/IoCodeConversions.cpp \
     149        ./shared/io/Marshalling/Marshalling.cpp \
    149150        ./shared/LatLong/Ll2xyx.cpp \
    150151        ./shared/LatLong/Xy2llx.cpp \
  • issm/trunk-jpl/src/c/shared/io/Marshalling/Marshalling.h

    r25525 r25530  
    4242
    4343        public:
    44                 WriteCheckpointFunctor(char** pmarshalled_data_in) : MarshallHandle(MARSHALLING_WRITE),pmarshalled_data(pmarshalled_data_in){}
    45                 void Echo(void){
    46                         printf("WriteCheckpointFunctor Echo:\n");
    47                         printf("   pmarshalled_data: %p\n",pmarshalled_data);
    48                 }
     44                WriteCheckpointFunctor(char** pmarshalled_data_in);
     45                void Echo(void);
    4946                template<typename T> void call(T & value){
    5047                        memcpy(*pmarshalled_data,&value,sizeof(T));
    5148                        *pmarshalled_data+=sizeof(T);
    5249                }
    53                 void call(char* & value){
    54                         int size = strlen(value)+1;
    55                         this->call(size);
    56                         this->call(value,size);
    57                 };
     50                void call(char* & value);
    5851                template<typename T> void call(T* & value,int size){
    5952                        bool pointer_null = true;
     
    7265
    7366        public:
    74                 LoadCheckpointFunctor(char** pmarshalled_data_in) : MarshallHandle(MARSHALLING_LOAD),pmarshalled_data(pmarshalled_data_in){}
    75                 void Echo(void){
    76                         printf("LoadCheckpointFunctor Echo:\n");
    77                         printf("   pmarshalled_data: %p\n",pmarshalled_data);
    78                 }
     67                LoadCheckpointFunctor(char** pmarshalled_data_in);
     68                void Echo(void);
     69                void call(char* & value);
    7970                template<typename T> void call(T & value){
    8071                        memcpy(&value,*pmarshalled_data,sizeof(T));
    8172                        *pmarshalled_data+=sizeof(T);
    8273                }
    83                 void call(char* & value){
    84                         int size;
    85                         this->call(size);
    86                         this->call(value,size);
    87                 };
    8874                template<typename T> void call(T* & value,int size){
    8975                        bool pointer_null;
     
    10591
    10692        public:
    107                 SizeCheckpointFunctor(void) : MarshallHandle(MARSHALLING_SIZE),marshalled_data_size(0){}
    108                 int MarshalledSize(void){return this->marshalled_data_size;};
    109                 void Echo(void){
    110                         printf("SizeCheckpointFunctor Echo:\n");
    111                         printf("   marshalled_data_size: %i\n",marshalled_data_size);
    112                 }
     93                SizeCheckpointFunctor(void);
     94                int MarshalledSize(void);
     95                void Echo(void);
    11396                template<typename T> void call(T & value){
    11497                        marshalled_data_size+=sizeof(T);
    11598                }
    116                 void call(char* & value){
    117                         int size = strlen(value)+1;
    118                         this->call(size);
    119                         this->call(value,size);
    120                 };
     99                void call(char* & value);
    121100                template<typename T> void call(T* & value,int size){
    122101                        bool pointer_null = true;
     
    135114
    136115        public:
    137                 CountDoublesFunctor(void) : MarshallHandle(AD_COUNTDOUBLES),double_count(0){}
    138                 int DoubleCount(void){return this->double_count;};
    139                 void Echo(void){
    140                         printf("CountDoublesFunctor Echo:\n");
    141                         printf("   double_count: %i\n",double_count);
    142                 }
    143                 template<typename T> void call(T & value){
    144                         /*General case: do nothing*/
    145                 }
    146                 template<typename T> void call(T* & value,int size){
    147                         /*General case: do nothing*/
    148                 }
    149                 void call(IssmDouble value){
    150                         this->double_count++;
    151                 }
    152                 void call(IssmDouble* value,int size){
    153                         if(value) this->double_count+= size;
    154                 }
     116                CountDoublesFunctor(void);
     117                int  DoubleCount(void);
     118                void Echo(void);
     119                template<typename T> void call(T & value){/*General case: do nothing*/}
     120                template<typename T> void call(T* & value,int size){/*General case: do nothing*/}
     121                void call(IssmDouble value);
     122                void call(IssmDouble* value,int size);
    155123}; /*}}}*/
    156124class RegisterInputFunctor:   public MarshallHandle{ /*{{{*/
    157125
    158126        private:
    159                 int   double_count;
    160                 int*  identifiers;
    161                 IssmDouble::TapeType* tape_codi;
    162 
    163         public:
    164                 RegisterInputFunctor(int* identifiers_in) : MarshallHandle(AD_REGISTERINPUT){
    165                         this->double_count = 0;
    166                         this->identifiers  = identifiers_in;
    167                         this->tape_codi    = &(IssmDouble::getGlobalTape());
    168                 }
    169                 void Echo(void){
    170                         printf("RegisterInputFunctor Echo:\n");
    171                         printf("   double_count: %i\n",double_count);
    172                 }
    173                 template<typename T> void call(T & value){
    174                         /*General case: do nothing*/
    175                 }
    176                 template<typename T> void call(T* & value,int size){
    177                         /*General case: do nothing*/
    178                 }
    179                 void call(IssmDouble value){
    180                         this->tape_codi->registerInput(value);
    181                         this->identifiers[this->double_count] = value.getGradientData();
    182                         this->double_count++;
    183                 }
    184                 void call(IssmDouble* value,int size){
    185                         if(value){
    186                                 for(int i=0;i<size;i++){
    187                                         this->tape_codi->registerInput(value[i]);
    188                                         this->identifiers[this->double_count] = value[i].getGradientData();
    189                                         this->double_count++;
    190                                 }
    191                         }
    192                 }
     127                int  double_count;
     128                int *identifiers;
     129                int  size_max;
     130                IssmDouble::TapeType *tape_codi;
     131
     132        public:
     133                RegisterInputFunctor(int* identifiers_in,int size_max_in);
     134                void Echo(void);
     135                template<typename T> void call(T & value){/*General case: do nothing*/}
     136                template<typename T> void call(T* & value,int size){/*General case: do nothing*/}
     137                void call(IssmDouble value);
     138                void call(IssmDouble* value,int size);
    193139}; /*}}}*/
    194140class RegisterOutputFunctor:  public MarshallHandle{ /*{{{*/
     
    199145
    200146        public:
    201                 RegisterOutputFunctor(void) : MarshallHandle(AD_REGISTEROUTPUT){
    202                         this->double_count = 0;
    203                         this->tape_codi    = &(IssmDouble::getGlobalTape());
    204                 }
    205                 void Echo(void){
    206                         printf("RegisterOutputFunctor Echo:\n");
    207                         printf("   double_count: %i\n",double_count);
    208                 }
    209                 template<typename T> void call(T & value){
    210                         /*General case: do nothing*/
    211                 }
    212                 template<typename T> void call(T* & value,int size){
    213                         /*General case: do nothing*/
    214                 }
    215                 void call(IssmDouble value){
    216                         this->tape_codi->registerOutput(value);
    217                         this->double_count++;
    218                 }
    219                 void call(IssmDouble* value,int size){
    220                         if(value){
    221                                 for(int i=0;i<size;i++){
    222                                         this->tape_codi->registerOutput(value[i]);
    223                                         this->double_count++;
    224                                 }
    225                         }
    226                 }
     147                RegisterOutputFunctor(void);
     148                void Echo(void);
     149                template<typename T> void call(T & value){/*General case: do nothing*/}
     150                template<typename T> void call(T* & value,int size){/*General case: do nothing*/}
     151                void call(IssmDouble value);
     152                void call(IssmDouble* value,int size);
    227153}; /*}}}*/
    228154class SetAdjointFunctor:      public MarshallHandle{ /*{{{*/
     
    230156        private:
    231157                int                   double_count;
     158                int                   size_max;
    232159                IssmDouble::TapeType* tape_codi;
    233160                double*               adjoint;
    234161
    235162        public:
    236                 SetAdjointFunctor(double* adjoint_in) : MarshallHandle(AD_SETADJOINT){
    237                         this->double_count = 0;
    238                         this->tape_codi    = &(IssmDouble::getGlobalTape());
    239                         this->adjoint      = adjoint_in;
    240                 }
    241                 void Echo(void){
    242                         printf("SetAdjointFunctor Echo:\n");
    243                         printf("   double_count: %i\n",double_count);
    244                 }
    245                 template<typename T> void call(T & value){
    246                         /*General case: do nothing*/
    247                 }
    248                 template<typename T> void call(T* & value,int size){
    249                         /*General case: do nothing*/
    250                 }
    251                 void call(IssmDouble value){
    252                         value.gradient() = this->adjoint[this->double_count];
    253                         this->double_count++;
    254                 }
    255                 void call(IssmDouble* value,int size){
    256                         if(value){
    257                                 for(int i=0;i<size;i++){
    258                                         value[i].gradient() = this->adjoint[this->double_count];
    259                                         this->double_count++;
    260                                 }
    261                         }
    262                 }
     163                SetAdjointFunctor(double* adjoint_in,int size_max_in);
     164                void Echo(void);
     165                template<typename T> void call(T & value){/*General case: do nothing*/}
     166                template<typename T> void call(T* & value,int size){/*General case: do nothing*/}
     167                void call(IssmDouble value);
     168                void call(IssmDouble* value,int size);
    263169}; /*}}}*/
    264170#endif
     
    293199}
    294200
    295 #endif 
     201#endif
Note: See TracChangeset for help on using the changeset viewer.