00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include "Timer_dh.h"
00044 #include "Mem_dh.h"
00045
00046 #undef __FUNC__
00047 #define __FUNC__ "Timer_dhCreate"
00048 void
00049 Timer_dhCreate (Timer_dh * t)
00050 {
00051 START_FUNC_DH
00052 struct _timer_dh *tmp =
00053 (struct _timer_dh *) MALLOC_DH (sizeof (struct _timer_dh));
00054 CHECK_V_ERROR;
00055 *t = tmp;
00056
00057 tmp->isRunning = false;
00058 tmp->begin_wall = 0.0;
00059 tmp->end_wall = 0.0;
00060 #ifdef WIN32
00061 tmp->sc_clk_tck = CLOCKS_PER_SEC;
00062 #else
00063 tmp->sc_clk_tck = sysconf (128);
00064 #endif
00065
00066 #if defined(EUCLID_TIMING)
00067 sprintf (msgBuf_dh, "using EUCLID_TIMING; _SC_CLK_TCK = %i",
00068 (int) tmp->sc_clk_tck);
00069 SET_INFO (msgBuf_dh);
00070 #elif defined(MPI_TIMING)
00071 SET_INFO ("using MPI timing")
00072 #else
00073 SET_INFO ("using JUNK timing")
00074 #endif
00075 END_FUNC_DH}
00076
00077 #undef __FUNC__
00078 #define __FUNC__ "Timer_dhDestroy"
00079 void
00080 Timer_dhDestroy (Timer_dh t)
00081 {
00082 START_FUNC_DH FREE_DH (t);
00083 END_FUNC_DH}
00084
00085
00086
00087
00088
00089
00090 #ifdef EUCLID_TIMING
00091
00092 #undef __FUNC__
00093 #define __FUNC__ "Timer_dhStart"
00094 void
00095 Timer_dhStart (Timer_dh t)
00096 {
00097 START_FUNC_DH t->begin_wall = times (&(t->begin_cpu));
00098 t->isRunning = true;
00099 END_FUNC_DH}
00100
00101 #undef __FUNC__
00102 #define __FUNC__ "Timer_dhStop"
00103 void
00104 Timer_dhStop (Timer_dh t)
00105 {
00106 START_FUNC_DH t->end_wall = times (&(t->end_cpu));
00107 t->isRunning = false;
00108 END_FUNC_DH}
00109
00110 #undef __FUNC__
00111 #define __FUNC__ "Timer_dhReadWall"
00112 double
00113 Timer_dhReadWall (Timer_dh t)
00114 {
00115 START_FUNC_DH double retval = 0.0;
00116 long int sc_clk_tck = t->sc_clk_tck;
00117 if (t->isRunning)
00118 t->end_wall = times (&(t->end_cpu));
00119 retval = (double) (t->end_wall - t->begin_wall) / (double) sc_clk_tck;
00120 END_FUNC_VAL (retval)}
00121
00122 #undef __FUNC__
00123 #define __FUNC__ "Timer_dhReadCPU"
00124 double
00125 Timer_dhReadCPU (Timer_dh t)
00126 {
00127 START_FUNC_DH double retval;
00128 long int sc_clk_tck = t->sc_clk_tck;
00129 if (t->isRunning)
00130 t->end_wall = times (&(t->end_cpu));
00131 retval = (double) (t->end_cpu.tms_utime - t->begin_cpu.tms_utime
00132 + t->end_cpu.tms_stime - t->begin_cpu.tms_stime
00133 + t->end_cpu.tms_cutime - t->begin_cpu.tms_cutime
00134 + t->end_cpu.tms_cstime - t->begin_cpu.tms_cstime)
00135 / (double) sc_clk_tck;
00136 END_FUNC_VAL (retval)}
00137
00138 #undef __FUNC__
00139 #define __FUNC__ "Timer_dhReadUsage"
00140 double
00141 Timer_dhReadUsage (Timer_dh t)
00142 {
00143 START_FUNC_DH double cpu = Timer_dhReadCPU (t);
00144 double wall = Timer_dhReadWall (t);
00145 double retval = 100.0 * cpu / wall;
00146 END_FUNC_VAL (retval);
00147 }
00148
00149
00150
00151
00152
00153
00154 #elif defined(MPI_TIMING)
00155
00156 #undef __FUNC__
00157 #define __FUNC__ "Timer_dhStart"
00158 void
00159 Timer_dhStart (Timer_dh t)
00160 {
00161 START_FUNC_DH t->begin_wall = MPI_Wtime ();
00162 t->isRunning = true;
00163 END_FUNC_DH}
00164
00165 #undef __FUNC__
00166 #define __FUNC__ "Timer_dhStop"
00167 void
00168 Timer_dhStop (Timer_dh t)
00169 {
00170 START_FUNC_DH t->end_wall = MPI_Wtime ();
00171 t->isRunning = false;
00172 END_FUNC_DH}
00173
00174 #undef __FUNC__
00175 #define __FUNC__ "Timer_dhReadWall"
00176 double
00177 Timer_dhReadWall (Timer_dh t)
00178 {
00179 START_FUNC_DH double retval;
00180 if (t->isRunning)
00181 t->end_wall = MPI_Wtime ();
00182 retval = t->end_wall - t->begin_wall;
00183 END_FUNC_VAL (retval)}
00184
00185 #undef __FUNC__
00186 #define __FUNC__ "Timer_dhReadCPU"
00187 double
00188 Timer_dhReadCPU (Timer_dh t)
00189 {
00190 START_FUNC_DH END_FUNC_VAL (-1.0)}
00191
00192 #undef __FUNC__
00193 #define __FUNC__ "Timer_dhReadUsage"
00194 double
00195 Timer_dhReadUsage (Timer_dh t)
00196 {
00197 START_FUNC_DH END_FUNC_VAL (-1.0);
00198 }
00199
00200
00201
00202
00203
00204
00205 #else
00206
00207 #undef __FUNC__
00208 #define __FUNC__ "Timer_dhStart"
00209 void
00210 Timer_dhStart (Timer_dh t)
00211 {
00212 START_FUNC_DH END_FUNC_DH}
00213
00214 #undef __FUNC__
00215 #define __FUNC__ "Timer_dhStop"
00216 void
00217 Timer_dhStop (Timer_dh t)
00218 {
00219 START_FUNC_DH END_FUNC_DH}
00220
00221 #undef __FUNC__
00222 #define __FUNC__ "Timer_dhReadWall"
00223 double
00224 Timer_dhReadWall (Timer_dh t)
00225 {
00226 START_FUNC_DH END_FUNC_VAL (-1.0)}
00227
00228 #undef __FUNC__
00229 #define __FUNC__ "Timer_dhReadCPU"
00230 double
00231 Timer_dhReadCPU (Timer_dh t)
00232 {
00233 START_FUNC_DH END_FUNC_VAL (-1.0)}
00234
00235 #undef __FUNC__
00236 #define __FUNC__ "Timer_dhReadUsage"
00237 double
00238 Timer_dhReadUsage (Timer_dh t)
00239 {
00240 START_FUNC_DH END_FUNC_VAL (-1.0);
00241 }
00242
00243 #endif