diff --git a/src/KSPACE/fix_tune_kspace.cpp b/src/KSPACE/fix_tune_kspace.cpp index 98a5a292a9..44b2bfc551 100644 --- a/src/KSPACE/fix_tune_kspace.cpp +++ b/src/KSPACE/fix_tune_kspace.cpp @@ -159,7 +159,7 @@ void FixTuneKspace::pre_exchange() adjust_rcut(time); } - last_spcpu = timer->elapsed(Timer::LOOP); + last_spcpu = timer->elapsed(Timer::TOTAL); } /* ---------------------------------------------------------------------- @@ -177,7 +177,7 @@ double FixTuneKspace::get_timing_info() dvalue = 0.0; firststep = 1; } else { - new_cpu = timer->elapsed(Timer::LOOP); + new_cpu = timer->elapsed(Timer::TOTAL); double cpu_diff = new_cpu - last_spcpu; int step_diff = new_step - last_step; if (step_diff > 0.0) dvalue = cpu_diff/step_diff; diff --git a/src/REPLICA/neb.cpp b/src/REPLICA/neb.cpp index 3bd5809e2f..f14852875d 100644 --- a/src/REPLICA/neb.cpp +++ b/src/REPLICA/neb.cpp @@ -217,7 +217,7 @@ void NEB::run() // damped dynamic min styles insure all replicas converge together timer->init(); - timer->barrier_start(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); while (update->minimize->niter < n1steps) { update->minimize->run(nevery); @@ -225,7 +225,7 @@ void NEB::run() if (update->minimize->stop_condition) break; } - timer->barrier_stop(Timer::LOOP); + timer->barrier_stop(Timer::TOTAL); update->minimize->cleanup(); @@ -287,7 +287,7 @@ void NEB::run() // damped dynamic min styles insure all replicas converge together timer->init(); - timer->barrier_start(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); while (update->minimize->niter < n2steps) { update->minimize->run(nevery); @@ -295,7 +295,7 @@ void NEB::run() if (update->minimize->stop_condition) break; } - timer->barrier_stop(Timer::LOOP); + timer->barrier_stop(Timer::TOTAL); update->minimize->cleanup(); diff --git a/src/REPLICA/prd.cpp b/src/REPLICA/prd.cpp index 5a434b9499..61f6b8c2e7 100644 --- a/src/REPLICA/prd.cpp +++ b/src/REPLICA/prd.cpp @@ -265,8 +265,8 @@ void PRD::command(int narg, char **arg) share_event(0,0); timer->init(); - timer->barrier_start(Timer::LOOP); - time_start = timer->get_wall(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); + time_start = timer->get_wall(Timer::TOTAL); log_event(); @@ -291,8 +291,8 @@ void PRD::command(int narg, char **arg) nbuild = ndanger = 0; time_dephase = time_dynamics = time_quench = time_comm = time_output = 0.0; - timer->barrier_start(Timer::LOOP); - time_start = timer->get_wall(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); + time_start = timer->get_wall(Timer::TOTAL); while (update->ntimestep < update->endstep) { dephase(); @@ -352,7 +352,7 @@ void PRD::command(int narg, char **arg) lmp->init(); update->integrate->setup(); - timer->barrier_start(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); if (t_corr > 0) replicate(ireplica); if (temp_flag == 0) { @@ -362,23 +362,23 @@ void PRD::command(int narg, char **arg) universe->uworld); } - timer->barrier_stop(Timer::LOOP); - time_comm += timer->get_wall(Timer::LOOP); + timer->barrier_stop(Timer::TOTAL); + time_comm += timer->get_wall(Timer::TOTAL); // write restart file of hot coords if (restart_flag) { - timer->barrier_start(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); output->write_restart(update->ntimestep); - timer->barrier_stop(Timer::LOOP); - time_output += timer->get_wall(Timer::LOOP); + timer->barrier_stop(Timer::TOTAL); + time_output += timer->get_wall(Timer::TOTAL); } } // set total timers and counters so Finish() will process them - timer->set_wall(Timer::LOOP, time_start); - timer->barrier_stop(Timer::LOOP); + timer->set_wall(Timer::TOTAL, time_start); + timer->barrier_stop(Timer::TOTAL); timer->set_wall(Timer::PAIR, time_dephase); timer->set_wall(Timer::BOND, time_dynamics); @@ -394,12 +394,12 @@ void PRD::command(int narg, char **arg) fprintf(universe->uscreen, "Loop time of %g on %d procs for %d steps with " BIGINT_FORMAT " atoms\n", - timer->get_wall(Timer::LOOP),nprocs_universe,nsteps,atom->natoms); + timer->get_wall(Timer::TOTAL),nprocs_universe,nsteps,atom->natoms); if (universe->ulogfile) fprintf(universe->ulogfile, "Loop time of %g on %d procs for %d steps with " BIGINT_FORMAT " atoms\n", - timer->get_wall(Timer::LOOP),nprocs_universe,nsteps,atom->natoms); + timer->get_wall(Timer::TOTAL),nprocs_universe,nsteps,atom->natoms); } finish->end(2); @@ -445,7 +445,7 @@ void PRD::dephase() update->whichflag = 1; update->nsteps = n_dephase*t_dephase; - timer->barrier_start(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); for (int i = 0; i < n_dephase; i++) { int seed = static_cast (random_dephase->uniform() * MAXSMALLINT); @@ -455,8 +455,8 @@ void PRD::dephase() if (temp_flag == 0) temp_dephase = temperature->compute_scalar(); } - timer->barrier_stop(Timer::LOOP); - time_dephase += timer->get_wall(Timer::LOOP); + timer->barrier_stop(Timer::TOTAL); + time_dephase += timer->get_wall(Timer::TOTAL); update->integrate->cleanup(); finish->end(0); @@ -484,10 +484,10 @@ void PRD::dynamics() //modify->addstep_compute_all(update->ntimestep); bigint ncalls = neighbor->ncalls; - timer->barrier_start(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); update->integrate->run(t_event); - timer->barrier_stop(Timer::LOOP); - time_dynamics += timer->get_wall(Timer::LOOP); + timer->barrier_stop(Timer::TOTAL); + time_dynamics += timer->get_wall(Timer::TOTAL); nbuild += neighbor->ncalls - ncalls; ndanger += neighbor->ndanger; @@ -526,10 +526,10 @@ void PRD::quench() int ncalls = neighbor->ncalls; - timer->barrier_start(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); update->minimize->run(maxiter); - timer->barrier_stop(Timer::LOOP); - time_quench += timer->get_wall(Timer::LOOP); + timer->barrier_stop(Timer::TOTAL); + time_quench += timer->get_wall(Timer::TOTAL); if (neighbor->ncalls == ncalls) quench_reneighbor = 0; else quench_reneighbor = 1; @@ -562,7 +562,7 @@ int PRD::check_event(int replica_num) if (compute_event->compute_scalar() > 0.0) worldflag = 1; if (replica_num >= 0 && replica_num != universe->iworld) worldflag = 0; - timer->barrier_start(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); if (me == 0) MPI_Allreduce(&worldflag,&universeflag,1, MPI_INT,MPI_SUM,comm_replica); @@ -598,8 +598,8 @@ int PRD::check_event(int replica_num) MPI_Bcast(&ireplica,1,MPI_INT,0,world); } - timer->barrier_stop(Timer::LOOP); - time_comm += timer->get_wall(Timer::LOOP); + timer->barrier_stop(Timer::TOTAL); + time_comm += timer->get_wall(Timer::TOTAL); return ireplica; } @@ -615,14 +615,14 @@ int PRD::check_event(int replica_num) void PRD::share_event(int ireplica, int flag) { - timer->barrier_start(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); // communicate quenched coords to all replicas and store as event // decrement event counter if flag = 0 since not really an event replicate(ireplica); - timer->barrier_stop(Timer::LOOP); - time_comm += timer->get_wall(Timer::LOOP); + timer->barrier_stop(Timer::TOTAL); + time_comm += timer->get_wall(Timer::TOTAL); // adjust time for last correlated event check (not on first event) @@ -657,21 +657,21 @@ void PRD::share_event(int ireplica, int flag) // addstep_compute_all insures eng/virial are calculated if needed if (output->ndump && universe->iworld == 0) { - timer->barrier_start(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); modify->addstep_compute_all(update->ntimestep); update->integrate->setup_minimal(1); output->write_dump(update->ntimestep); - timer->barrier_stop(Timer::LOOP); - time_output += timer->get_wall(Timer::LOOP); + timer->barrier_stop(Timer::TOTAL); + time_output += timer->get_wall(Timer::TOTAL); } // restore and communicate hot coords to all replicas fix_event->restore_state(); - timer->barrier_start(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); replicate(ireplica); - timer->barrier_stop(Timer::LOOP); - time_comm += timer->get_wall(Timer::LOOP); + timer->barrier_stop(Timer::TOTAL); + time_comm += timer->get_wall(Timer::TOTAL); } /* ---------------------------------------------------------------------- @@ -680,13 +680,13 @@ void PRD::share_event(int ireplica, int flag) void PRD::log_event() { - timer->set_wall(Timer::LOOP, time_start); + timer->set_wall(Timer::TOTAL, time_start); if (universe->me == 0) { if (universe->uscreen) fprintf(universe->uscreen, BIGINT_FORMAT " %.3f %d %d %d %d %d\n", fix_event->event_timestep, - timer->elapsed(Timer::LOOP), + timer->elapsed(Timer::TOTAL), fix_event->clock, fix_event->event_number,fix_event->correlated_event, fix_event->ncoincident, @@ -695,7 +695,7 @@ void PRD::log_event() fprintf(universe->ulogfile, BIGINT_FORMAT " %.3f %d %d %d %d %d\n", fix_event->event_timestep, - timer->elapsed(Timer::LOOP), + timer->elapsed(Timer::TOTAL), fix_event->clock, fix_event->event_number,fix_event->correlated_event, fix_event->ncoincident, diff --git a/src/REPLICA/tad.cpp b/src/REPLICA/tad.cpp index af9d9d91de..a81cd0771e 100644 --- a/src/REPLICA/tad.cpp +++ b/src/REPLICA/tad.cpp @@ -244,8 +244,8 @@ void TAD::command(int narg, char **arg) quench(); timer->init(); - timer->barrier_start(Timer::LOOP); - time_start = timer->get_wall(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); + time_start = timer->get_wall(Timer::TOTAL); fix_event->store_event_tad(update->ntimestep); log_event(0); fix_event->restore_state(); @@ -265,8 +265,8 @@ void TAD::command(int narg, char **arg) nbuild = ndanger = 0; time_neb = time_dynamics = time_quench = time_comm = time_output = 0.0; - timer->barrier_start(Timer::LOOP); - time_start = timer->get_wall(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); + time_start = timer->get_wall(Timer::TOTAL); int confident_flag, event_flag; @@ -337,10 +337,10 @@ void TAD::command(int narg, char **arg) // write restart file of hot coords if (restart_flag) { - timer->barrier_start(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); output->write_restart(update->ntimestep); - timer->barrier_stop(Timer::LOOP); - time_output += timer->get_wall(Timer::LOOP); + timer->barrier_stop(Timer::TOTAL); + time_output += timer->get_wall(Timer::TOTAL); } } @@ -371,8 +371,8 @@ void TAD::command(int narg, char **arg) // set total timers and counters so Finish() will process them - timer->set_wall(Timer::LOOP, time_start); - timer->barrier_stop(Timer::LOOP); + timer->set_wall(Timer::TOTAL, time_start); + timer->barrier_stop(Timer::TOTAL); timer->set_wall(Timer::PAIR, time_neb); timer->set_wall(Timer::BOND, time_dynamics); @@ -388,12 +388,12 @@ void TAD::command(int narg, char **arg) fprintf(universe->uscreen, "Loop time of %g on %d procs for %d steps with " BIGINT_FORMAT " atoms\n", - timer->get_wall(Timer::LOOP),nprocs_universe,nsteps,atom->natoms); + timer->get_wall(Timer::TOTAL),nprocs_universe,nsteps,atom->natoms); if (universe->ulogfile) fprintf(universe->ulogfile, "Loop time of %g on %d procs for %d steps with " BIGINT_FORMAT " atoms\n", - timer->get_wall(Timer::LOOP),nprocs_universe,nsteps,atom->natoms); + timer->get_wall(Timer::TOTAL),nprocs_universe,nsteps,atom->natoms); } if (me_universe == 0) fclose(ulogfile_neb); @@ -436,10 +436,10 @@ void TAD::dynamics() //modify->addstep_compute_all(update->ntimestep); int ncalls = neighbor->ncalls; - timer->barrier_start(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); update->integrate->run(t_event); - timer->barrier_stop(Timer::LOOP); - time_dynamics += timer->get_wall(Timer::LOOP); + timer->barrier_stop(Timer::TOTAL); + time_dynamics += timer->get_wall(Timer::TOTAL); nbuild += neighbor->ncalls - ncalls; ndanger += neighbor->ndanger; @@ -478,10 +478,10 @@ void TAD::quench() int ncalls = neighbor->ncalls; - timer->barrier_start(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); update->minimize->run(maxiter); - timer->barrier_stop(Timer::LOOP); - time_quench += timer->get_wall(Timer::LOOP); + timer->barrier_stop(Timer::TOTAL); + time_quench += timer->get_wall(Timer::TOTAL); if (neighbor->ncalls == ncalls) quench_reneighbor = 0; else quench_reneighbor = 1; @@ -520,14 +520,14 @@ int TAD::check_event() void TAD::log_event(int ievent) { - timer->set_wall(Timer::LOOP, time_start); + timer->set_wall(Timer::TOTAL, time_start); if (universe->me == 0) { double tfrac = 0.0; if (universe->uscreen) fprintf(universe->uscreen, BIGINT_FORMAT " %.3f %d %d %s %.3f %.3f %.3f %.3f\n", fix_event->event_timestep, - timer->elapsed(Timer::LOOP), + timer->elapsed(Timer::TOTAL), fix_event->event_number,ievent, "E ", fix_event->ebarrier,tfrac, @@ -536,7 +536,7 @@ void TAD::log_event(int ievent) fprintf(universe->ulogfile, BIGINT_FORMAT " %.3f %d %d %s %.3f %.3f %.3f %.3f\n", fix_event->event_timestep, - timer->elapsed(Timer::LOOP), + timer->elapsed(Timer::TOTAL), fix_event->event_number,ievent, "E ", fix_event->ebarrier,tfrac, @@ -548,12 +548,12 @@ void TAD::log_event(int ievent) // addstep_compute_all insures eng/virial are calculated if needed if (output->ndump && universe->iworld == 0) { - timer->barrier_start(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); modify->addstep_compute_all(update->ntimestep); update->integrate->setup_minimal(1); output->write_dump(update->ntimestep); - timer->barrier_stop(Timer::LOOP); - time_output += timer->get_wall(Timer::LOOP); + timer->barrier_stop(Timer::TOTAL); + time_output += timer->get_wall(Timer::TOTAL); } } @@ -741,10 +741,10 @@ void TAD::perform_neb(int ievent) // because timer->array is reset // inside neb->run() -// timer->barrier_start(Timer::LOOP); +// timer->barrier_start(Timer::TOTAL); // neb->run(); -// timer->barrier_stop(Timer::LOOP); -// time_neb += timer->get_wall(Timer::LOOP); +// timer->barrier_stop(Timer::TOTAL); +// time_neb += timer->get_wall(Timer::TOTAL); MPI_Barrier(world); double time_tmp = MPI_Wtime(); @@ -960,7 +960,7 @@ void TAD::compute_tlo(int ievent) // first-replica output about each event - timer->set_wall(Timer::LOOP, time_start); + timer->set_wall(Timer::TOTAL, time_start); if (universe->me == 0) { double tfrac = 0.0; if (ievent > 0) tfrac = delthi/deltstop; @@ -969,7 +969,7 @@ void TAD::compute_tlo(int ievent) fprintf(universe->uscreen, BIGINT_FORMAT " %.3f %d %d %s %.3f %.3f %.3f %.3f\n", fix_event_list[ievent]->event_timestep, - timer->elapsed(Timer::LOOP), + timer->elapsed(Timer::TOTAL), fix_event->event_number, ievent,statstr,ebarrier,tfrac, fix_event->tlo,deltlo); @@ -978,7 +978,7 @@ void TAD::compute_tlo(int ievent) fprintf(universe->ulogfile, BIGINT_FORMAT " %.3f %d %d %s %.3f %.3f %.3f %.3f\n", fix_event_list[ievent]->event_timestep, - timer->elapsed(Timer::LOOP), + timer->elapsed(Timer::TOTAL), fix_event->event_number, ievent,statstr,ebarrier,tfrac, fix_event->tlo,deltlo); diff --git a/src/REPLICA/temper.cpp b/src/REPLICA/temper.cpp index d23181dc72..473ab208b8 100644 --- a/src/REPLICA/temper.cpp +++ b/src/REPLICA/temper.cpp @@ -205,7 +205,7 @@ void Temper::command(int narg, char **arg) } timer->init(); - timer->barrier_start(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); for (int iswap = 0; iswap < nswaps; iswap++) { @@ -310,7 +310,7 @@ void Temper::command(int narg, char **arg) if (me_universe == 0) print_status(); } - timer->barrier_stop(Timer::LOOP); + timer->barrier_stop(Timer::TOTAL); update->integrate->cleanup(); diff --git a/src/REPLICA/verlet_split.cpp b/src/REPLICA/verlet_split.cpp index 38245213c0..679f55da5d 100644 --- a/src/REPLICA/verlet_split.cpp +++ b/src/REPLICA/verlet_split.cpp @@ -268,7 +268,7 @@ void VerletSplit::run(int n) MPI_Barrier(universe->uworld); timer->init(); - timer->barrier_start(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); // setup initial Rspace <-> Kspace comm params diff --git a/src/finish.cpp b/src/finish.cpp index bfb67b5fa9..27d6ce8458 100644 --- a/src/finish.cpp +++ b/src/finish.cpp @@ -161,13 +161,13 @@ void Finish::end(int flag) // loop stats if (loopflag) { - time_other = timer->get_wall(Timer::LOOP) - + time_other = timer->get_wall(Timer::TOTAL) - (timer->get_wall(Timer::PAIR) + timer->get_wall(Timer::BOND) + timer->get_wall(Timer::KSPACE) + timer->get_wall(Timer::NEIGHBOR) + timer->get_wall(Timer::COMM) + timer->get_wall(Timer::OUTPUT) + timer->get_wall(Timer::MODIFY)); - time_loop = timer->get_wall(Timer::LOOP); + time_loop = timer->get_wall(Timer::TOTAL); MPI_Allreduce(&time_loop,&tmp,1,MPI_DOUBLE,MPI_SUM,world); time_loop = tmp/nprocs; diff --git a/src/input.cpp b/src/input.cpp index ffc1fb9ab1..8ad312b29e 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -46,6 +46,7 @@ #include "error.h" #include "memory.h" #include "citeme.h" +#include "timer.h" #ifdef _OPENMP #include "omp.h" @@ -585,6 +586,7 @@ int Input::execute_command() else if (!strcmp(command,"thermo_modify")) thermo_modify(); else if (!strcmp(command,"thermo_style")) thermo_style(); else if (!strcmp(command,"timestep")) timestep(); + else if (!strcmp(command,"timers")) timers(); else if (!strcmp(command,"uncompute")) uncompute(); else if (!strcmp(command,"undump")) undump(); else if (!strcmp(command,"unfix")) unfix(); @@ -1523,6 +1525,14 @@ void Input::timestep() /* ---------------------------------------------------------------------- */ +void Input::timers() +{ + if (narg != 1) error->all(FLERR,"Illegal timers command"); + timer->modify_params(narg,arg); +} + +/* ---------------------------------------------------------------------- */ + void Input::uncompute() { if (narg != 1) error->all(FLERR,"Illegal uncompute command"); diff --git a/src/input.h b/src/input.h index ef5c0a98e4..3100f85817 100644 --- a/src/input.h +++ b/src/input.h @@ -123,6 +123,7 @@ class Input : protected Pointers { void thermo_modify(); void thermo_style(); void timestep(); + void timers(); void uncompute(); void undump(); void unfix(); diff --git a/src/minimize.cpp b/src/minimize.cpp index d8a4de831b..64719a5cd5 100644 --- a/src/minimize.cpp +++ b/src/minimize.cpp @@ -54,9 +54,9 @@ void Minimize::command(int narg, char **arg) update->minimize->setup(); timer->init(); - timer->barrier_start(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); update->minimize->run(update->nsteps); - timer->barrier_stop(Timer::LOOP); + timer->barrier_stop(Timer::TOTAL); update->minimize->cleanup(); diff --git a/src/rerun.cpp b/src/rerun.cpp index 6e2c6262e8..f2ab475bb8 100644 --- a/src/rerun.cpp +++ b/src/rerun.cpp @@ -143,7 +143,7 @@ void Rerun::command(int narg, char **arg) lmp->init(); timer->init(); - timer->barrier_start(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); bigint ntimestep = rd->seek(first,0); if (ntimestep < 0) @@ -171,7 +171,7 @@ void Rerun::command(int narg, char **arg) output->next_thermo = update->ntimestep; output->write(update->ntimestep); - timer->barrier_stop(Timer::LOOP); + timer->barrier_stop(Timer::TOTAL); update->integrate->cleanup(); diff --git a/src/run.cpp b/src/run.cpp index b02865d6c1..eb0d5836c0 100644 --- a/src/run.cpp +++ b/src/run.cpp @@ -171,9 +171,9 @@ void Run::command(int narg, char **arg) } else output->setup(0); timer->init(); - timer->barrier_start(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); update->integrate->run(nsteps); - timer->barrier_stop(Timer::LOOP); + timer->barrier_stop(Timer::TOTAL); update->integrate->cleanup(); @@ -209,9 +209,9 @@ void Run::command(int narg, char **arg) } else output->setup(0); timer->init(); - timer->barrier_start(Timer::LOOP); + timer->barrier_start(Timer::TOTAL); update->integrate->run(nsteps); - timer->barrier_stop(Timer::LOOP); + timer->barrier_stop(Timer::TOTAL); update->integrate->cleanup(); diff --git a/src/thermo.cpp b/src/thermo.cpp index ff30ca644b..b98dbfe21e 100644 --- a/src/thermo.cpp +++ b/src/thermo.cpp @@ -328,7 +328,7 @@ void Thermo::compute(int flag) int loc = 0; if (lineflag == MULTILINE) { double cpu; - if (flag) cpu = timer->elapsed(Timer::LOOP); + if (flag) cpu = timer->elapsed(Timer::TOTAL); else cpu = 0.0; loc = sprintf(&line[loc],format_multi,ntimestep,cpu); } @@ -1452,7 +1452,7 @@ void Thermo::compute_time() void Thermo::compute_cpu() { if (firststep == 0) dvalue = 0.0; - else dvalue = timer->elapsed(Timer::LOOP); + else dvalue = timer->elapsed(Timer::TOTAL); } /* ---------------------------------------------------------------------- */ @@ -1466,7 +1466,7 @@ void Thermo::compute_tpcpu() new_cpu = 0.0; dvalue = 0.0; } else { - new_cpu = timer->elapsed(Timer::LOOP); + new_cpu = timer->elapsed(Timer::TOTAL); double cpu_diff = new_cpu - last_tpcpu; double time_diff = new_time - last_time; if (time_diff > 0.0 && cpu_diff > 0.0) dvalue = time_diff/cpu_diff; @@ -1488,7 +1488,7 @@ void Thermo::compute_spcpu() new_cpu = 0.0; dvalue = 0.0; } else { - new_cpu = timer->elapsed(Timer::LOOP); + new_cpu = timer->elapsed(Timer::TOTAL); double cpu_diff = new_cpu - last_spcpu; int step_diff = new_step - last_step; if (cpu_diff > 0.0) dvalue = step_diff/cpu_diff; diff --git a/src/timer.cpp b/src/timer.cpp index d9cdd20a14..b3ee15b553 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -13,8 +13,11 @@ #include "mpi.h" #include "timer.h" +#include "error.h" #include "memory.h" +#include + #ifdef _WIN32 #include #else @@ -55,32 +58,25 @@ static double CPU_Time() Timer::Timer(LAMMPS *lmp) : Pointers(lmp) { - memory->create(cpu_array,TIME_N,"timer:cpu_array"); - memory->create(wall_array,TIME_N,"timer:wall_array"); -} - -/* ---------------------------------------------------------------------- */ - -Timer::~Timer() -{ - memory->destroy(cpu_array); - memory->destroy(wall_array); + _level = NORMAL; + _sync = OFF; } /* ---------------------------------------------------------------------- */ void Timer::init() { - for (int i = 0; i < TIME_N; i++) cpu_array[i] = 0.0; - for (int i = 0; i < TIME_N; i++) wall_array[i] = 0.0; + for (int i = 0; i < NUM_TIMER; i++) { + cpu_array[i] = 0.0; + wall_array[i] = 0.0; + } } /* ---------------------------------------------------------------------- */ void Timer::stamp() { - // uncomment if want synchronized timing - // MPI_Barrier(world); + if (_sync) MPI_Barrier(world); previous_cpu = CPU_Time(); previous_wall = MPI_Wtime(); } @@ -89,8 +85,7 @@ void Timer::stamp() void Timer::stamp(enum ttype which) { - // uncomment if want synchronized timing - // MPI_Barrier(world); + if (_sync) MPI_Barrier(world); double current_cpu = CPU_Time(); double current_wall = MPI_Wtime(); cpu_array[which] += current_cpu - previous_cpu; @@ -142,3 +137,26 @@ void Timer::set_wall(enum ttype which, double newtime) wall_array[which] = newtime; } +/* ---------------------------------------------------------------------- + modify parameters of the Timer class +------------------------------------------------------------------------- */ + +void Timer::modify_params(int narg, char **arg) +{ + int iarg = 0; + while (iarg < narg) { + if (strcmp(arg[iarg],"off") == 0) { + _level = OFF; + } else if (strcmp(arg[iarg],"normal") == 0) { + _level = NORMAL; + } else if (strcmp(arg[iarg],"full") == 0) { + _level = FULL; + } else if (strcmp(arg[iarg],"nosync") == 0) { + _sync = OFF; + } else if (strcmp(arg[iarg],"sync") == 0) { + _sync = NORMAL; + } else error->all(FLERR,"Illegal timers command"); + + ++iarg; + } +} diff --git a/src/timer.h b/src/timer.h index 22bede9c80..671cc25ef0 100644 --- a/src/timer.h +++ b/src/timer.h @@ -21,10 +21,12 @@ namespace LAMMPS_NS { class Timer : protected Pointers { public: - enum ttype {LOOP=0,PAIR,BOND,KSPACE,NEIGHBOR,COMM,MODIFY,OUTPUT,TIME_N}; + + enum ttype {TOTAL=0,PAIR,BOND,KSPACE,NEIGHBOR,COMM,MODIFY,OUTPUT,NUM_TIMER}; + enum tlevel {OFF=0,LOOP,NORMAL,FULL}; Timer(class LAMMPS *); - ~Timer(); + ~Timer() {}; void init(); void stamp(); void stamp(enum ttype); @@ -40,11 +42,16 @@ class Timer : protected Pointers { void set_wall(enum ttype, double); + + void modify_params(int, char **); + private: - double *cpu_array; - double *wall_array; + double cpu_array[NUM_TIMER]; + double wall_array[NUM_TIMER]; double previous_cpu; double previous_wall; + int _level; // level of detail: off=0,loop=1,normal=2,full=3 + int _sync; // if nonzero, synchronize tasks before setting the timer }; }