remove unused system time, add cpu time for windows
This commit is contained in:
@ -44,24 +44,18 @@ static double get_cpu_time()
|
||||
rv += (double) ru.ru_utime.tv_usec * 0.000001;
|
||||
}
|
||||
return rv;
|
||||
#endif
|
||||
#endif
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
static double get_sys_time()
|
||||
{
|
||||
#ifndef _WIN32
|
||||
struct rusage ru;
|
||||
#else /* _WIN32 */
|
||||
// from MSD docs.
|
||||
FILETIME ct,et,kt,ut;
|
||||
double rv = 0.0;
|
||||
if (getrusage(RUSAGE_SELF, &ru) == 0) {
|
||||
rv = (double) ru.ru_stime.tv_sec;
|
||||
rv += (double) ru.ru_stime.tv_usec * 0.000001;
|
||||
if (GetProcessTimes(GetCurrentProcess(),&ct,&et,&kt,&ut)) {
|
||||
rv = (double) dwLowDateTime * 0.0000001;
|
||||
rv += (double) dwHighDateTime *429.4967296;
|
||||
}
|
||||
return rv;
|
||||
);
|
||||
#endif /* _WIN32 */
|
||||
#endif
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -69,7 +63,7 @@ static double get_wall_time()
|
||||
{
|
||||
#ifdef LMP_CLOCK_GETTIME
|
||||
struct timespec tp;
|
||||
clock_gettime(CLOCK_REALTIME_HR,&tp);
|
||||
clock_gettime(CLOCK_REALTIME,&tp);
|
||||
double rv = (double) tp.tv_sec;
|
||||
rv += (double) tp.tv_nsec * 0.0000000001;
|
||||
return rv;
|
||||
@ -83,7 +77,6 @@ static double get_wall_time()
|
||||
Timer::Timer(LAMMPS *lmp) : Pointers(lmp)
|
||||
{
|
||||
memory->create(cpu_array,TIME_N,"timer:cpu_array");
|
||||
memory->create(sys_array,TIME_N,"timer:sys_array");
|
||||
memory->create(wall_array,TIME_N,"timer:wall_array");
|
||||
}
|
||||
|
||||
@ -92,7 +85,6 @@ Timer::Timer(LAMMPS *lmp) : Pointers(lmp)
|
||||
Timer::~Timer()
|
||||
{
|
||||
memory->destroy(cpu_array);
|
||||
memory->destroy(sys_array);
|
||||
memory->destroy(wall_array);
|
||||
}
|
||||
|
||||
@ -101,7 +93,6 @@ Timer::~Timer()
|
||||
void Timer::init()
|
||||
{
|
||||
for (int i = 0; i < TIME_N; i++) cpu_array[i] = 0.0;
|
||||
for (int i = 0; i < TIME_N; i++) sys_array[i] = 0.0;
|
||||
for (int i = 0; i < TIME_N; i++) wall_array[i] = 0.0;
|
||||
}
|
||||
|
||||
@ -112,7 +103,6 @@ void Timer::stamp()
|
||||
// uncomment if want synchronized timing
|
||||
// MPI_Barrier(world);
|
||||
previous_cpu = get_cpu_time();
|
||||
previous_sys = get_sys_time();
|
||||
previous_wall = get_wall_time();
|
||||
}
|
||||
|
||||
@ -123,13 +113,10 @@ void Timer::stamp(enum ttype which)
|
||||
// uncomment if want synchronized timing
|
||||
// MPI_Barrier(world);
|
||||
double current_cpu = get_cpu_time();
|
||||
double current_sys = get_sys_time();
|
||||
double current_wall = get_wall_time();
|
||||
cpu_array[which] += current_cpu - previous_cpu;
|
||||
sys_array[which] += current_sys - previous_sys;
|
||||
wall_array[which] += current_wall - previous_wall;
|
||||
previous_cpu = current_cpu;
|
||||
previous_sys = current_sys;
|
||||
previous_wall = current_wall;
|
||||
}
|
||||
|
||||
@ -139,7 +126,6 @@ void Timer::barrier_start(enum ttype which)
|
||||
{
|
||||
MPI_Barrier(world);
|
||||
cpu_array[which] = get_cpu_time();
|
||||
sys_array[which] = get_sys_time();
|
||||
wall_array[which] = get_wall_time();
|
||||
}
|
||||
|
||||
@ -149,10 +135,8 @@ void Timer::barrier_stop(enum ttype which)
|
||||
{
|
||||
MPI_Barrier(world);
|
||||
double current_cpu = get_cpu_time();
|
||||
double current_sys = get_sys_time();
|
||||
double current_wall = get_wall_time();
|
||||
cpu_array[which] = current_cpu - cpu_array[which];
|
||||
sys_array[which] = current_sys - sys_array[which];
|
||||
wall_array[which] = current_wall - wall_array[which];
|
||||
}
|
||||
|
||||
@ -166,14 +150,6 @@ double Timer::cpu(enum ttype which)
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
double Timer::sys(enum ttype which)
|
||||
{
|
||||
double current_sys = get_sys_time();
|
||||
return (current_sys - sys_array[which]);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
double Timer::elapsed(enum ttype which)
|
||||
{
|
||||
double current_wall = get_wall_time();
|
||||
|
||||
Reference in New Issue
Block a user