Changeset 23250
- Timestamp:
- 09/11/18 09:18:59 (7 years ago)
- Location:
- issm/trunk-jpl/src/c/cores
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/cores/ad_core.cpp
r23066 r23250 19 19 /*}}}*/ 20 20 21 #ifdef _HAVE_CODIPACK_ 22 CoDi_global codi_global = {}; 23 #endif 21 24 void ad_core(FemModel* femmodel){ 22 25 … … 41 44 if(isautodiff && !iscontrol){ 42 45 43 #if def _HAVE_ADOLC_46 #if defined(_HAVE_ADOLC_) 44 47 if(VerboseAutodiff())_printf0_(" start ad core\n"); 45 48 … … 318 321 xDelete(axp); 319 322 xDelete(driver); 323 324 #elif defined(_HAVE_CODIPACK_) 325 if(VerboseAutodiff())_printf0_(" start CoDiPack ad core\n"); 326 327 /*First, stop tracing: */ 328 auto& tape_codi = IssmDouble::getGlobalTape(); 329 tape_codi.setPassive(); 330 331 if(VerboseAutodiff()){ /*{{{*/ 332 if(my_rank == 0) { 333 // FIXME codi "just because" for now 334 tape_codi.printStatistics(std::cout); 335 codi_global.print(std::cout); 336 } 337 } 338 339 /*retrieve parameters: */ 340 femmodel->parameters->FindParam(&num_dependents,AutodiffNumDependentsEnum); 341 femmodel->parameters->FindParam(&num_independents,AutodiffNumIndependentsEnum); 342 343 /*if no dependents, no point in running a driver: */ 344 if(!(num_dependents*num_independents)) return; 345 346 /*Branch according to AD driver: */ 347 femmodel->parameters->FindParam(&driver,AutodiffDriverEnum); 348 if(VerboseAutodiff())_printf0_(" driver: " << driver << "\n"); 349 350 if (strcmp(driver,"fos_reverse")==0) { /*{{{*/ 351 if(VerboseAutodiff())_printf0_(" CoDiPack fos_reverse\n"); 352 int aDepIndex=0; 353 double *weightVectorTimesJac=NULL; 354 355 /*retrieve direction index: */ 356 femmodel->parameters->FindParam(&aDepIndex,AutodiffFosReverseIndexEnum); 357 if (my_rank==0) { 358 if (aDepIndex<0 || aDepIndex>=num_dependents 359 || codi_global.output_indices.size() <= aDepIndex){ 360 _error_("index value for AutodiffFosReverseIndexEnum should be in [0,num_dependents-1]"); 361 } 362 tape_codi.setGradient(codi_global.output_indices[aDepIndex], 1.0); 363 } 364 365 tape_codi.evaluate(); 366 367 weightVectorTimesJac=xNew<double>(num_independents); 368 /*call driver: */ 369 auto in_size = codi_global.input_indices.size(); 370 for(size_t i = 0; i < in_size; ++i) { 371 weightVectorTimesJac[i] = tape_codi.getGradient(codi_global.input_indices[i]); 372 } 373 374 /*add to results*/ 375 femmodel->results->AddObject(new GenericExternalResult<IssmPDouble*>(femmodel->results->Size()+1,AutodiffJacobianEnum,weightVectorTimesJac,num_independents,1,0,0.0)); 376 377 /*free resources :*/ 378 xDelete(weightVectorTimesJac); 379 } /*}}}*/ 380 else _error_("driver: " << driver << " not yet supported!"); 381 382 if(VerboseAutodiff())_printf0_(" end CoDiPack ad core\n"); 383 xDelete(driver); 320 384 #else 321 385 _error_("Should not be requesting AD drivers when an AD library is not available!"); -
issm/trunk-jpl/src/c/cores/adgradient_core.cpp
r23066 r23250 48 48 if(isautodiff){ 49 49 50 #if def _HAVE_ADOLC_50 #if defined(_HAVE_ADOLC_) 51 51 if(VerboseAutodiff())_printf0_(" start ad core\n"); 52 52 … … 182 182 xDelete(totalgradient); 183 183 xDelete(axp); /*}}}*/ 184 185 #elif defined(_HAVE_CODIPACK_) 186 fprintf(stderr, "*** Codipack adgradient_core()\n"); 184 187 #else 185 188 _error_("Should not be requesting AD drivers when an AD library is not available!"); -
issm/trunk-jpl/src/c/cores/controladm1qn3_core.cpp
r23240 r23250 168 168 /*Print tape statistics so that user can kill this run if something is off already:*/ 169 169 if(VerboseAutodiff()){ /*{{{*/ 170 171 #ifdef _HAVE_ADOLC_ 170 172 size_t tape_stats[15]; 171 173 tapestats(my_rank,tape_stats); //reading of tape statistics … … 208 210 } 209 211 delete [] sstats; 212 #endif 213 214 #ifdef _HAVE_CODIPACK_ 215 #ifdef _AD_TAPE_ALLOC_ 216 //_printf_("Allocation time P(" << my_rank << "): " << alloc_profiler.DeltaTime(StartInit, FinishInit) << "\n"); 217 #endif 218 std::stringstream out_s; 219 IssmDouble::getGlobalTape().printStatistics(out_s); 220 _printf0_("CoDiPack Profiling::Tape Statistics :\n" << out_s.str()); 221 #endif 210 222 } /*}}}*/ 211 223
Note:
See TracChangeset
for help on using the changeset viewer.