Changeset 25530
- Timestamp:
- 09/03/20 21:04:49 (5 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/Makefile.am
r25465 r25530 147 147 ./shared/io/Comm/IssmComm.cpp \ 148 148 ./shared/io/Marshalling/IoCodeConversions.cpp \ 149 ./shared/io/Marshalling/Marshalling.cpp \ 149 150 ./shared/LatLong/Ll2xyx.cpp \ 150 151 ./shared/LatLong/Xy2llx.cpp \ -
issm/trunk-jpl/src/c/shared/io/Marshalling/Marshalling.h
r25525 r25530 42 42 43 43 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); 49 46 template<typename T> void call(T & value){ 50 47 memcpy(*pmarshalled_data,&value,sizeof(T)); 51 48 *pmarshalled_data+=sizeof(T); 52 49 } 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); 58 51 template<typename T> void call(T* & value,int size){ 59 52 bool pointer_null = true; … … 72 65 73 66 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); 79 70 template<typename T> void call(T & value){ 80 71 memcpy(&value,*pmarshalled_data,sizeof(T)); 81 72 *pmarshalled_data+=sizeof(T); 82 73 } 83 void call(char* & value){84 int size;85 this->call(size);86 this->call(value,size);87 };88 74 template<typename T> void call(T* & value,int size){ 89 75 bool pointer_null; … … 105 91 106 92 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); 113 96 template<typename T> void call(T & value){ 114 97 marshalled_data_size+=sizeof(T); 115 98 } 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); 121 100 template<typename T> void call(T* & value,int size){ 122 101 bool pointer_null = true; … … 135 114 136 115 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); 155 123 }; /*}}}*/ 156 124 class RegisterInputFunctor: public MarshallHandle{ /*{{{*/ 157 125 158 126 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); 193 139 }; /*}}}*/ 194 140 class RegisterOutputFunctor: public MarshallHandle{ /*{{{*/ … … 199 145 200 146 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); 227 153 }; /*}}}*/ 228 154 class SetAdjointFunctor: public MarshallHandle{ /*{{{*/ … … 230 156 private: 231 157 int double_count; 158 int size_max; 232 159 IssmDouble::TapeType* tape_codi; 233 160 double* adjoint; 234 161 235 162 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); 263 169 }; /*}}}*/ 264 170 #endif … … 293 199 } 294 200 295 #endif 201 #endif
Note:
See TracChangeset
for help on using the changeset viewer.