source: issm/trunk-jpl/src/c/classes/objects/Profiler.cpp@ 13540

Last change on this file since 13540 was 13540, checked in by Eric.Larour, 12 years ago

CHG: cleanup issm.cpp. Worked on homogeneizing solutioncore
returned by CorePointerFromSolutionEnum. Because we have wrappers (dakota, control),
created new PureCorePointerFromSolutionEnum, which only deals with analyses, not wrappers.
This new PureCorePointerFromSolutionEnum is called in control_core, controltao_core.
Also, CorePointerFromSolutionEnum can take in a nodakota flag, to allow for return of all
solution types except dakota itself. This is called in dakota_core.
Also move the AutodiffDriversx to ad_core.

File size: 3.6 KB
RevLine 
[13534]1/*!\file Profiler.c
2 * \brief: implementation of the Profiler object
3 */
4
5/*Include files: {{{*/
6#ifdef HAVE_CONFIG_H
7 #include <config.h>
8#else
9#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
10#endif
11
12#include "./Profiler.h"
13/*}}}*/
14
15/*Profiler constructors and destructors:*/
16/*FUNCTION Profiler::Profiler() default constructor {{{*/
17Profiler::Profiler(){
[13539]18 this->time=new Parameters();
[13540]19 this->flops=new Parameters();
20 this->memory=new Parameters();
[13534]21}
22/*}}}*/
23/*FUNCTION Profiler::~Profiler(){{{*/
24Profiler::~Profiler(){
[13539]25 delete time;
[13534]26}
27/*}}}*/
28
29/*Object virtual functions definitions:*/
30/*FUNCTION Profiler::Echo{{{*/
31void Profiler::Echo(void){
32
33 _printLine_("Profiler:");
34 _printLine_(" time tags: ");
[13539]35 this->time->Echo();
[13534]36
37}
38/*}}}*/
39/*FUNCTION Profiler::DeepEcho{{{*/
40void Profiler::DeepEcho(void){
41
42 _printLine_("Profiler:");
43 _printLine_(" time tags: ");
[13539]44 this->time->DeepEcho();
[13534]45
46}
47/*}}}*/
48/*FUNCTION Profiler::Id{{{*/
49int Profiler::Id(void){ return -1; }
50/*}}}*/
51/*FUNCTION Profiler::ObjectEnum{{{*/
52int Profiler::ObjectEnum(void){
53
54 return ProfilerEnum;
55
56}
57/*}}}*/
58
59/*Profiler routines:*/
60/*FUNCTION Profiler::Tag {{{*/
61void Profiler::Tag(int tagenum,bool dontmpisync){
62
[13539]63 IssmDouble t;
64 IssmDouble f;
65 IssmDouble m;
[13534]66
67 /*If mpisync requested, make sure all the cpus are at the same point
68 *in the execution: */
69 if(!dontmpisync){
70 #ifdef _HAVE_MPI_
71 MPI_Barrier(MPI_COMM_WORLD);
72 #endif
73 }
74
[13539]75 /*Capture time: */
[13534]76 #ifdef _HAVE_MPI_
[13539]77 t=MPI_Wtime();
[13534]78 #else
[13539]79 t=(IssmPDouble)clock();
[13534]80 #endif
81
[13539]82 /*Capture flops: */
83 #ifdef _HAVE_PETSC_
84 PetscGetFlops(&f);
85 PetscMemoryGetCurrentUsage(&m);
86 #else
87 /*do nothing for now:*/
88 #endif
[13534]89
[13539]90 /*Plug into this->time: */
91 this->time->AddObject(new DoubleParam(tagenum,t));
92 this->flops->AddObject(new DoubleParam(tagenum,f));
93 this->memory->AddObject(new DoubleParam(tagenum,m));
94
[13534]95}
96/*}}}*/
[13539]97/*FUNCTION Profiler::DeltaTime {{{*/
98IssmDouble Profiler::DeltaTime(int inittag, int finaltag){
[13534]99
[13539]100 IssmDouble init, final;
101 this->time->FindParam(&init,inittag);
102 this->time->FindParam(&final,finaltag);
[13534]103
104 #ifdef _HAVE_MPI_
105 return final-init;
106 #else
107 return (final-init)/CLOCKS_PER_SEC;
108 #endif
109}
110/*}}}*/
[13539]111/*FUNCTION Profiler::DeltaFlops {{{*/
112IssmDouble Profiler::DeltaFlops(int inittag, int finaltag){
[13534]113
[13539]114 IssmDouble init, final;
115 this->flops->FindParam(&init,inittag);
116 this->flops->FindParam(&final,finaltag);
[13534]117
[13539]118 return final-init;
119}
120/*}}}*/
121/*FUNCTION Profiler::DeltaTimeModHour {{{*/
122int Profiler::DeltaTimeModHour(int inittag, int finishtag){
123
124 IssmDouble init, finish;
125 this->time->FindParam(&init,inittag);
126 this->time->FindParam(&finish,finishtag);
127
[13534]128 #ifdef _HAVE_MPI_
[13539]129 return int((reCast<int,IssmDouble>(finish-init))/3600);
[13534]130 #else
[13539]131 return int((reCast<int,IssmDouble>(finish-init))/CLOCKS_PER_SEC/3600);
[13534]132 #endif
133
134}
135/*}}}*/
[13539]136/*FUNCTION Profiler::DeltaTimeModMin {{{*/
137int Profiler::DeltaTimeModMin(int inittag, int finishtag){
[13534]138
[13539]139 IssmDouble init, finish;
140 this->time->FindParam(&init,inittag);
141 this->time->FindParam(&finish,finishtag);
[13534]142
143 #ifdef _HAVE_MPI_
[13539]144 return int(int(reCast<int,IssmDouble>(finish-init))%3600/60);
[13534]145 #else
[13539]146 return int(int(reCast<int,IssmDouble>(finish-init))/CLOCKS_PER_SEC%3600/60);
[13534]147 #endif
148}
149/*}}}*/
[13539]150/*FUNCTION Profiler::DeltaTimeModSec {{{*/
151int Profiler::DeltaTimeModSec(int inittag, int finishtag){
[13534]152
[13539]153 IssmDouble init, finish;
154 this->time->FindParam(&init,inittag);
155 this->time->FindParam(&finish,finishtag);
[13534]156
157 #ifdef _HAVE_MPI_
[13539]158 return int(reCast<int,IssmDouble>(finish-init))%60;
[13534]159 #else
[13539]160 return int(reCast<int,IssmDouble>(finish-init))/CLOCKS_PER_SEC%60;
[13534]161 #endif
162}
163/*}}}*/
[13539]164/*FUNCTION Profiler::Memory {{{*/
165IssmDouble Profiler::Memory(int tag){
166
167 IssmDouble m;
168 this->memory->FindParam(&m,tag);
169
170 return m;
171}
172/*}}}*/
Note: See TracBrowser for help on using the repository browser.