43 #include "TimeLog_dh.h"
47 #define MAX_TIME_MARKS 100
48 #define MAX_DESC_LENGTH 60
54 double time[MAX_TIME_MARKS];
55 char desc[MAX_TIME_MARKS][MAX_DESC_LENGTH];
60 #define __FUNC__ "TimeLog_dhCreate"
69 tmp->first = tmp->last = 0;
70 Timer_dhCreate (&tmp->timer);
71 for (i = 0; i < MAX_TIME_MARKS; ++i)
72 strcpy (tmp->desc[i],
"X");
76 #define __FUNC__ "TimeLog_dhDestroy"
80 START_FUNC_DH Timer_dhDestroy (t->timer);
86 #define __FUNC__ "TimeLog_dhStart"
90 START_FUNC_DH Timer_dhStart (t->timer);
94 #define __FUNC__ "TimeLog_dhStop"
98 START_FUNC_DH Timer_dhStop (t->timer);
102 #define __FUNC__ "TimeLog_dhMark"
106 START_FUNC_DH
if (t->last < MAX_TIME_MARKS - 3)
109 Timer_dhStop (t->timer);
110 t->time[t->last] = Timer_dhReadWall (t->timer);
111 Timer_dhStart (t->timer);
112 sprintf (t->desc[t->last], desc);
118 #define __FUNC__ "TimeLog_dhReset"
122 START_FUNC_DH
if (t->last < MAX_TIME_MARKS - 2)
125 int i, first = t->first, last = t->last;
126 for (i = first; i < last; ++i)
128 t->time[last] = total;
129 sprintf (t->desc[last],
"========== totals, and reset ==========\n");
132 Timer_dhStart (t->timer);
138 #define __FUNC__ "TimeLog_dhPrint"
140 TimeLog_dhPrint (
TimeLog_dh t, FILE * fp,
bool allPrint)
144 double timeMax[MAX_TIME_MARKS];
145 double timeMin[MAX_TIME_MARKS];
146 static bool wasSummed =
false;
151 for (i = t->first; i < t->last; ++i)
153 t->time[t->last] = total;
154 sprintf (t->desc[t->last],
"========== totals, and reset ==========\n");
157 MPI_Allreduce (t->time, timeMax, t->last, MPI_DOUBLE, MPI_MAX, comm_dh);
158 MPI_Allreduce (t->time, timeMin, t->last, MPI_DOUBLE, MPI_MIN, comm_dh);
164 if (myid_dh == 0 || allPrint)
167 "\n----------------------------------------- timing report\n");
168 fprintf (fp,
"\n self max min\n");
169 for (i = 0; i < t->last; ++i)
171 fprintf (fp,
"%7.3f %7.3f %7.3f #%s\n", t->time[i],
172 timeMax[i], timeMin[i], t->desc[i]);