enable and apply clang-format

This commit is contained in:
Axel Kohlmeyer
2022-03-18 00:06:28 -04:00
parent 6d38ce5284
commit 32612d3f5b
7 changed files with 631 additions and 647 deletions

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -24,10 +23,10 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
Timer::Timer(LAMMPS *lmp) : Pointers(lmp)
Timer::Timer(LAMMPS *_lmp) : Pointers(_lmp)
{
_level = NORMAL;
_sync = OFF;
_sync = OFF;
_timeout = -1;
_s_timeout = -1;
_checkfreq = 10;
@ -49,7 +48,7 @@ void Timer::init()
void Timer::_stamp(enum ttype which)
{
double current_cpu=0.0, current_wall=0.0;
double current_cpu = 0.0, current_wall = 0.0;
if (_level > NORMAL) current_cpu = platform::cputime();
current_wall = platform::walltime();
@ -58,13 +57,13 @@ void Timer::_stamp(enum ttype which)
const double delta_cpu = current_cpu - previous_cpu;
const double delta_wall = current_wall - previous_wall;
cpu_array[which] += delta_cpu;
cpu_array[which] += delta_cpu;
wall_array[which] += delta_wall;
cpu_array[ALL] += delta_cpu;
wall_array[ALL] += delta_wall;
cpu_array[ALL] += delta_cpu;
wall_array[ALL] += delta_wall;
}
previous_cpu = current_cpu;
previous_cpu = current_cpu;
previous_wall = current_wall;
if (which == RESET) {
@ -78,9 +77,9 @@ void Timer::_stamp(enum ttype which)
if (_level > NORMAL) current_cpu = platform::cputime();
current_wall = platform::walltime();
cpu_array[SYNC] += current_cpu - previous_cpu;
cpu_array[SYNC] += current_cpu - previous_cpu;
wall_array[SYNC] += current_wall - previous_wall;
previous_cpu = current_cpu;
previous_cpu = current_cpu;
previous_wall = current_wall;
}
}
@ -89,7 +88,7 @@ void Timer::_stamp(enum ttype which)
void Timer::barrier_start()
{
double current_cpu=0.0, current_wall=0.0;
double current_cpu = 0.0, current_wall = 0.0;
MPI_Barrier(world);
@ -98,9 +97,9 @@ void Timer::barrier_start()
current_cpu = platform::cputime();
current_wall = platform::walltime();
cpu_array[TOTAL] = current_cpu;
cpu_array[TOTAL] = current_cpu;
wall_array[TOTAL] = current_wall;
previous_cpu = current_cpu;
previous_cpu = current_cpu;
previous_wall = current_wall;
}
@ -108,7 +107,7 @@ void Timer::barrier_start()
void Timer::barrier_stop()
{
double current_cpu=0.0, current_wall=0.0;
double current_cpu = 0.0, current_wall = 0.0;
MPI_Barrier(world);
@ -117,7 +116,7 @@ void Timer::barrier_stop()
current_cpu = platform::cputime();
current_wall = platform::walltime();
cpu_array[TOTAL] = current_cpu - cpu_array[TOTAL];
cpu_array[TOTAL] = current_cpu - cpu_array[TOTAL];
wall_array[TOTAL] = current_wall - wall_array[TOTAL];
}
@ -169,14 +168,13 @@ void Timer::print_timeout(FILE *fp)
// remaining timeout in seconds
int s = _timeout - d;
// remaining 1/100ths of seconds
const int hs = 100*((_timeout - d) - s);
const int hs = 100 * ((_timeout - d) - s);
// breaking s down into second/minutes/hours
const int seconds = s % 60;
s = (s - seconds) / 60;
s = (s - seconds) / 60;
const int minutes = s % 60;
const int hours = (s - minutes) / 60;
fprintf(fp," Walltime left : %d:%02d:%02d.%02d\n",
hours,minutes,seconds,hs);
fprintf(fp, " Walltime left : %d:%02d:%02d.%02d\n", hours, minutes, seconds, hs);
}
}
@ -186,14 +184,13 @@ bool Timer::_check_timeout()
{
double walltime = platform::walltime() - timeout_start;
// broadcast time to insure all ranks act the same.
MPI_Bcast(&walltime,1,MPI_DOUBLE,0,world);
MPI_Bcast(&walltime, 1, MPI_DOUBLE, 0, world);
if (walltime < _timeout) {
_nextcheck += _checkfreq;
return false;
} else {
if (comm->me == 0)
error->warning(FLERR,"Wall time limit reached");
if (comm->me == 0) error->warning(FLERR, "Wall time limit reached");
_timeout = 0.0;
return true;
}
@ -208,38 +205,40 @@ double Timer::get_timeout_remain()
/* ----------------------------------------------------------------------
modify parameters of the Timer class
------------------------------------------------------------------------- */
static const char *timer_style[] = { "off", "loop", "normal", "full" };
static const char *timer_mode[] = { "nosync", "(dummy)", "sync" };
static const char *timer_style[] = {"off", "loop", "normal", "full"};
static const char *timer_mode[] = {"nosync", "(dummy)", "sync"};
void Timer::modify_params(int narg, char **arg)
{
int iarg = 0;
while (iarg < narg) {
if (strcmp(arg[iarg],timer_style[OFF]) == 0) {
if (strcmp(arg[iarg], timer_style[OFF]) == 0) {
_level = OFF;
} else if (strcmp(arg[iarg],timer_style[LOOP]) == 0) {
} else if (strcmp(arg[iarg], timer_style[LOOP]) == 0) {
_level = LOOP;
} else if (strcmp(arg[iarg],timer_style[NORMAL]) == 0) {
} else if (strcmp(arg[iarg], timer_style[NORMAL]) == 0) {
_level = NORMAL;
} else if (strcmp(arg[iarg],timer_style[FULL]) == 0) {
} else if (strcmp(arg[iarg], timer_style[FULL]) == 0) {
_level = FULL;
} else if (strcmp(arg[iarg],timer_mode[OFF]) == 0) {
_sync = OFF;
} else if (strcmp(arg[iarg],timer_mode[NORMAL]) == 0) {
_sync = NORMAL;
} else if (strcmp(arg[iarg],"timeout") == 0) {
} else if (strcmp(arg[iarg], timer_mode[OFF]) == 0) {
_sync = OFF;
} else if (strcmp(arg[iarg], timer_mode[NORMAL]) == 0) {
_sync = NORMAL;
} else if (strcmp(arg[iarg], "timeout") == 0) {
++iarg;
if (iarg < narg) {
_timeout = utils::timespec2seconds(arg[iarg]);
} else error->all(FLERR,"Illegal timer command");
} else if (strcmp(arg[iarg],"every") == 0) {
} else
error->all(FLERR, "Illegal timer command");
} else if (strcmp(arg[iarg], "every") == 0) {
++iarg;
if (iarg < narg) {
_checkfreq = utils::inumeric(FLERR,arg[iarg],false,lmp);
if (_checkfreq <= 0)
error->all(FLERR,"Illegal timer command");
} else error->all(FLERR,"Illegal timer command");
} else error->all(FLERR,"Illegal timer command");
_checkfreq = utils::inumeric(FLERR, arg[iarg], false, lmp);
if (_checkfreq <= 0) error->all(FLERR, "Illegal timer command");
} else
error->all(FLERR, "Illegal timer command");
} else
error->all(FLERR, "Illegal timer command");
++iarg;
}
@ -253,7 +252,7 @@ void Timer::modify_params(int narg, char **arg)
timeout = fmt::format("{:%H:%M:%S}", fmt::gmtime(tv));
}
utils::logmesg(lmp,"New timer settings: style={} mode={} timeout={}\n",
timer_style[_level],timer_mode[_sync],timeout);
utils::logmesg(lmp, "New timer settings: style={} mode={} timeout={}\n", timer_style[_level],
timer_mode[_sync], timeout);
}
}