Changeset 13539
- Timestamp:
- 10/04/12 16:49:33 (12 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 2 added
- 6 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/Makefile.am
r13537 r13539 221 221 ./shared/Elements/ComputeDelta18oTemperaturePrecipitation.cpp\ 222 222 ./shared/String/sharedstring.h\ 223 ./shared/String/DescriptorIndex.cpp\ 223 224 ./shared/Wrapper/wrappershared.h\ 224 225 ./shared/Wrapper/ModuleBoot.cpp\ … … 373 374 ./modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp\ 374 375 ./modules/AverageOntoPartitionx/AverageOntoPartitionx.h\ 375 ./modules/Dakotax/Dakotax.h\376 ./modules/Dakotax/Dakotax.cpp\377 ./modules/Dakotax/DakotaMPI_Bcast.cpp\378 ./modules/Dakotax/DakotaFree.cpp\379 ./modules/Dakotax/SpawnCore.cpp\380 ./modules/Dakotax/DescriptorIndex.cpp\381 376 ./modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp\ 382 ./modules/Dakotax/SpawnCoreParallel.cpp 377 ./solutions/dakota_core.cpp\ 378 ./solutions/DakotaSpawnCore.cpp 383 379 #}}} 384 380 #Transient sources {{{ -
issm/trunk-jpl/src/c/classes/dakota/DakotaPlugin.cpp
r12837 r13539 88 88 89 89 /*run core solution: */ 90 SpawnCore(responses,numFns, variables,variable_descriptors,numACV,femmodel,counter);90 DakotaSpawnCore(responses,numFns, variables,variable_descriptors,numACV,femmodel,counter); 91 91 92 92 /*populate responses: */ -
issm/trunk-jpl/src/c/classes/objects/Profiler.cpp
r13534 r13539 16 16 /*FUNCTION Profiler::Profiler() default constructor {{{*/ 17 17 Profiler::Profiler(){ 18 this->time tags=new Parameters();18 this->time=new Parameters(); 19 19 } 20 20 /*}}}*/ 21 21 /*FUNCTION Profiler::~Profiler(){{{*/ 22 22 Profiler::~Profiler(){ 23 delete time tags;23 delete time; 24 24 } 25 25 /*}}}*/ … … 31 31 _printLine_("Profiler:"); 32 32 _printLine_(" time tags: "); 33 this->time tags->Echo();33 this->time->Echo(); 34 34 35 35 } … … 40 40 _printLine_("Profiler:"); 41 41 _printLine_(" time tags: "); 42 this->time tags->DeepEcho();42 this->time->DeepEcho(); 43 43 44 44 } … … 59 59 void Profiler::Tag(int tagenum,bool dontmpisync){ 60 60 61 double time; 61 IssmDouble t; 62 IssmDouble f; 63 IssmDouble m; 62 64 63 65 /*If mpisync requested, make sure all the cpus are at the same point … … 69 71 } 70 72 71 /* Now capture time: */73 /*Capture time: */ 72 74 #ifdef _HAVE_MPI_ 73 t ime=MPI_Wtime();75 t=MPI_Wtime(); 74 76 #else 75 t ime=(IssmPDouble)clock();77 t=(IssmPDouble)clock(); 76 78 #endif 77 79 78 /*Plug into this->timetags: */ 79 this->timetags->AddObject(new DoubleParam(tagenum,time)); 80 /*Capture flops: */ 81 #ifdef _HAVE_PETSC_ 82 PetscGetFlops(&f); 83 PetscMemoryGetCurrentUsage(&m); 84 #else 85 /*do nothing for now:*/ 86 #endif 87 88 /*Plug into this->time: */ 89 this->time->AddObject(new DoubleParam(tagenum,t)); 90 this->flops->AddObject(new DoubleParam(tagenum,f)); 91 this->memory->AddObject(new DoubleParam(tagenum,m)); 80 92 81 93 } 82 94 /*}}}*/ 83 /*FUNCTION Profiler::Delta {{{*/84 double Profiler::Delta(int inittag, int finaltag){95 /*FUNCTION Profiler::DeltaTime {{{*/ 96 IssmDouble Profiler::DeltaTime(int inittag, int finaltag){ 85 97 86 double init, final;87 this->time tags->FindParam(&init,inittag);88 this->time tags->FindParam(&final,finaltag);98 IssmDouble init, final; 99 this->time->FindParam(&init,inittag); 100 this->time->FindParam(&final,finaltag); 89 101 90 102 #ifdef _HAVE_MPI_ … … 95 107 } 96 108 /*}}}*/ 97 /*FUNCTION Profiler::Delta ModHour{{{*/98 int Profiler::DeltaModHour(int inittag, int finishtag){109 /*FUNCTION Profiler::DeltaFlops {{{*/ 110 IssmDouble Profiler::DeltaFlops(int inittag, int finaltag){ 99 111 100 double init, finish; 101 this->timetags->FindParam(&init,inittag); 102 this->timetags->FindParam(&finish,finishtag); 112 IssmDouble init, final; 113 this->flops->FindParam(&init,inittag); 114 this->flops->FindParam(&final,finaltag); 115 116 return final-init; 117 } 118 /*}}}*/ 119 /*FUNCTION Profiler::DeltaTimeModHour {{{*/ 120 int Profiler::DeltaTimeModHour(int inittag, int finishtag){ 121 122 IssmDouble init, finish; 123 this->time->FindParam(&init,inittag); 124 this->time->FindParam(&finish,finishtag); 103 125 104 126 #ifdef _HAVE_MPI_ 105 return int(( finish-init)/3600);127 return int((reCast<int,IssmDouble>(finish-init))/3600); 106 128 #else 107 return int(( finish-init)/CLOCKS_PER_SEC/3600);129 return int((reCast<int,IssmDouble>(finish-init))/CLOCKS_PER_SEC/3600); 108 130 #endif 109 131 110 132 } 111 133 /*}}}*/ 112 /*FUNCTION Profiler::Delta ModMin {{{*/113 int Profiler::Delta ModMin(int inittag, int finishtag){134 /*FUNCTION Profiler::DeltaTimeModMin {{{*/ 135 int Profiler::DeltaTimeModMin(int inittag, int finishtag){ 114 136 115 double init, finish;116 this->time tags->FindParam(&init,inittag);117 this->time tags->FindParam(&finish,finishtag);137 IssmDouble init, finish; 138 this->time->FindParam(&init,inittag); 139 this->time->FindParam(&finish,finishtag); 118 140 119 141 #ifdef _HAVE_MPI_ 120 return int(int( finish-init)%3600/60);142 return int(int(reCast<int,IssmDouble>(finish-init))%3600/60); 121 143 #else 122 return int(int( finish-init)/CLOCKS_PER_SEC%3600/60);144 return int(int(reCast<int,IssmDouble>(finish-init))/CLOCKS_PER_SEC%3600/60); 123 145 #endif 124 146 } 125 147 /*}}}*/ 126 /*FUNCTION Profiler::Delta ModSec {{{*/127 int Profiler::Delta ModSec(int inittag, int finishtag){148 /*FUNCTION Profiler::DeltaTimeModSec {{{*/ 149 int Profiler::DeltaTimeModSec(int inittag, int finishtag){ 128 150 129 double init, finish;130 this->time tags->FindParam(&init,inittag);131 this->time tags->FindParam(&finish,finishtag);151 IssmDouble init, finish; 152 this->time->FindParam(&init,inittag); 153 this->time->FindParam(&finish,finishtag); 132 154 133 155 #ifdef _HAVE_MPI_ 134 return int( finish-init)%60;156 return int(reCast<int,IssmDouble>(finish-init))%60; 135 157 #else 136 return int( finish-init)/CLOCKS_PER_SEC%60;158 return int(reCast<int,IssmDouble>(finish-init))/CLOCKS_PER_SEC%60; 137 159 #endif 138 160 } 139 161 /*}}}*/ 162 /*FUNCTION Profiler::Memory {{{*/ 163 IssmDouble Profiler::Memory(int tag){ 164 165 IssmDouble m; 166 this->memory->FindParam(&m,tag); 167 168 return m; 169 } 170 /*}}}*/ -
issm/trunk-jpl/src/c/classes/objects/Profiler.h
r13534 r13539 28 28 29 29 public: 30 Parameters* timetags; 30 Parameters* time; 31 Parameters* flops; 32 Parameters* memory; 31 33 32 34 /*Profiler constructors, destructors {{{*/ … … 43 45 /*Profiler routines {{{*/ 44 46 void Tag(int tagenum,bool dontmpisync=false); 45 double Delta(int inittag, int finaltag); 46 int DeltaModHour(int inittag, int finaltag); 47 int DeltaModMin(int inittag, int finaltag); 48 int DeltaModSec(int inittag, int finaltag); 47 IssmDouble Memory(int tag); 48 IssmDouble DeltaTime(int inittag, int finaltag); 49 IssmDouble DeltaFlops(int inittag, int finaltag); 50 int DeltaTimeModHour(int inittag, int finaltag); 51 int DeltaTimeModMin(int inittag, int finaltag); 52 int DeltaTimeModSec(int inittag, int finaltag); 49 53 /*}}}*/ 50 54 }; -
issm/trunk-jpl/src/c/modules/Dakotax/Dakotax.h
r12832 r13539 10 10 11 11 /* local prototypes: */ 12 int SpawnCore(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, void* femmodel,int counter);13 int DescriptorIndex(char* root, int* pindex,char* descriptor);14 15 12 void Dakotax(FemModel* femmodel); 16 void SpawnCoreParallel(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, FemModel* femmodel,int counter); 17 void DakotaResponses(double* responses,char** responses_descriptors,int numresponses,FemModel* femmodel); 18 void DakotaMPI_Bcast(double** pvariables, char*** pvariables_descriptors,int* pnumvariables, int* pnumresponses); 19 void DakotaFree(double** pvariables,char*** pvariables_descriptors,char*** presponses_descriptors,int numvariables,int numresponses); 13 int DakotaSpawnCore(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, void* femmodel,int counter); 20 14 21 15 #endif /* _DAKOTAX_H */ -
issm/trunk-jpl/src/c/shared/String/sharedstring.h
r5469 r13539 8 8 int DescriptorIndex(char* root, int* pindex,char* descriptor); 9 9 10 #ifndef WIN32 11 int stricmp(const char* a,const char* b); 12 #endif 13 10 14 #endif //ifndef _SHAREDSTRING_H_ 11 15 -
issm/trunk-jpl/src/c/shared/shared.h
r13538 r13539 16 16 #include "Numerics/numerics.h" 17 17 #include "Sorting/sorting.h" 18 #include "String/sharedstring.h" 18 19 #include "Threads/issm_threads.h" 19 20 #include "TriMesh/trimesh.h" -
issm/trunk-jpl/src/c/solutions/issm.cpp
r13534 r13539 7 7 8 8 void ProfilerEcho(Profiler* profiler); 9 void ProfilerEnd(Profiler* profiler, Results* results, Parameters* parameters); 9 10 10 11 int main(int argc,char **argv){ … … 38 39 /*profiling*/ 39 40 Profiler* profiler=NULL; 40 bool profiling = false;41 IssmPDouble Time_start, Flops_start;42 IssmPDouble Solution_time, Memory_use, Current_flops;43 41 44 42 /*Initialize exception trapping: */ … … 48 46 EnvironmentInit(argc,argv); 49 47 50 /*Some profiling: */ 51 profiler=new Profiler(); profiler->Tag(Start); 48 /*Start profiler: */ 49 profiler=new Profiler(); 50 profiler->Tag(Start); 52 51 53 52 /*First process inputs*/ … … 83 82 femmodel->parameters->FindParam(&control_analysis,InversionIscontrolEnum); 84 83 femmodel->parameters->FindParam(&tao_analysis,InversionTaoEnum); 85 femmodel->parameters->FindParam(&profiling,DebugProfilingEnum);86 84 femmodel->parameters->FindParam(&autodiff,AutodiffIsautodiffEnum); 87 85 … … 106 104 107 105 _pprintLine_("call computational core:"); 106 107 108 108 profiler->Tag(StartCore); 109 110 if(profiling)ProfilingStart(&Time_start,&Flops_start);111 112 109 if(dakota_analysis){ 113 110 #ifdef _HAVE_DAKOTA_ 114 Dakotax(femmodel);111 dakota_core(femmodel); 115 112 #else 116 113 _error_("ISSM was not compiled with dakota support, cannot carry out dakota analysis!"); … … 119 116 else if(control_analysis){ 120 117 #ifdef _HAVE_CONTROL_ 121 if(tao_analysis) 122 controltao_core(femmodel); 123 else 124 control_core(femmodel); 118 if(tao_analysis) controltao_core(femmodel); 119 else control_core(femmodel); 125 120 #else 126 _error_("ISSM was not compiled with control support, cannot carry out dakotaanalysis!");121 _error_("ISSM was not compiled with control support, cannot carry out control analysis!"); 127 122 #endif 128 123 } 129 124 else{ 130 125 solutioncore(femmodel); 131 }132 133 if(profiling){134 ProfilingEnd(&Solution_time,&Memory_use,&Current_flops,Time_start,Flops_start);135 femmodel->results->AddObject(new GenericExternalResult<double>(femmodel->results->Size()+1, ProfilingSolutionTimeEnum, Solution_time, 1, 0));136 femmodel->results->AddObject(new GenericExternalResult<double>(femmodel->results->Size()+1, ProfilingCurrentMemEnum, Memory_use, 1, 0));137 femmodel->results->AddObject(new GenericExternalResult<double>(femmodel->results->Size()+1, ProfilingCurrentFlopsEnum, Current_flops, 1, 0));138 126 } 139 127 … … 144 132 } 145 133 #endif 146 147 134 profiler->Tag(FinishCore); 148 135 149 136 ProfilerEnd(profiler,femmodel->results,femmodel->parameters); 137 150 138 _pprintLine_("write results to disk:"); 151 139 OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results); … … 183 171 delete femmodel; 184 172 185 /*Get finish time and close*/ 186 profiler->Tag(Finish); ProfilerEcho(profiler); 173 /*Profiling at the end: */ 174 profiler->Tag(Finish); 175 ProfilerEcho(profiler); 187 176 188 177 /*Finalize environment:*/ … … 196 185 } 197 186 198 199 200 void ProfilerEcho(Profiler* profiler){ 201 202 _pprintLine_(""); 203 _pprintLine_(" "<<setw(40)<<left<<"FemModel initialization elapsed time:"<<profiler->Delta(StartInit,FinishInit)); 204 _pprintLine_(" "<<setw(40)<<left<<"Core solution elapsed time:"<<profiler->Delta(StartCore,FinishCore)); 187 void ProfilerEcho(Profiler* profiler){ /*{{{*/ 188 189 _pprintLine_(""); 190 _pprintLine_(" "<<setw(40)<<left<<"FemModel initialization elapsed time:"<<profiler->DeltaTime(StartInit,FinishInit)); 191 _pprintLine_(" "<<setw(40)<<left<<"Core solution elapsed time:"<<profiler->DeltaTime(StartCore,FinishCore)); 205 192 _pprintLine_(""); 206 193 _pprintLine_(" Total elapsed time:" 207 <<profiler->Delta ModHour(Start,Finish)<<" hrs "208 <<profiler->Delta ModMin(Start,Finish)<<" min "209 <<profiler->Delta ModSec(Start,Finish)<<" sec"194 <<profiler->DeltaTimeModHour(Start,Finish)<<" hrs " 195 <<profiler->DeltaTimeModMin(Start,Finish)<<" min " 196 <<profiler->DeltaTimeModSec(Start,Finish)<<" sec" 210 197 ); 211 198 _pprintLine_(""); 212 199 213 } 214 200 } /*}}}*/ 201 void ProfilerEnd(Profiler* profiler, Results* results, Parameters* parameters){ /*{{{*/ 202 203 bool profiling = false; 204 205 IssmDouble solution_time; 206 IssmDouble solution_flops; 207 IssmDouble solution_memory; 208 209 parameters->FindParam(&profiling,DebugProfilingEnum); 210 211 if(profiling){ 212 213 solution_time=profiler->DeltaTime(StartCore,FinishCore); 214 solution_flops=profiler->DeltaFlops(StartCore,FinishCore); 215 solution_memory=profiler->Memory(FinishCore); 216 217 _pprintLine_("Solution elapsed time : " << solution_time << " Seconds"); 218 _pprintLine_("Solution elapsed flops : " << solution_flops << " Flops"); 219 _pprintLine_("Solution memory used : " << solution_memory << " Bytes"); 220 221 /*Add to results: */ 222 results->AddObject(new GenericExternalResult<double>(results->Size()+1, ProfilingSolutionTimeEnum, solution_time, 1, 0)); 223 results->AddObject(new GenericExternalResult<double>(results->Size()+1, ProfilingCurrentMemEnum, solution_memory, 1, 0)); 224 results->AddObject(new GenericExternalResult<double>(results->Size()+1, ProfilingCurrentFlopsEnum, solution_flops, 1, 0)); 225 } 226 227 } /*}}}*/ -
issm/trunk-jpl/src/c/solutions/solutions.h
r13534 r13539 30 30 void steadystate_core(FemModel* femmodel); 31 31 void transient_core(FemModel* femmodel); 32 void dakota_core(FemModel* femmodel); 32 33 IssmDouble objectivefunction(IssmDouble search_scalar,OptArgs* optargs); 33 34 … … 47 48 void EnvironmentInit(int argc,char** argv); 48 49 void EnvironmentFinalize(void); 50 int DakotaSpawnCore(double* responses, int numresponses, double* variables, char** variables_descriptors,int numvariables, void* femmodel,int counter); 49 51 50 52 //solution configuration … … 53 55 void AdjointCorePointerFromSolutionEnum(void (**padjointcore)(FemModel*),int solutiontype); 54 56 57 55 58 #endif
Note:
See TracChangeset
for help on using the changeset viewer.