cache spcpu and tpcpu values so these thermo keywords can be used multiple times
This commit is contained in:
@ -1835,9 +1835,13 @@ void Thermo::compute_tpcpu()
|
||||
if (firststep == 0) {
|
||||
new_cpu = 0.0;
|
||||
dvalue = 0.0;
|
||||
// if evaluated on the same step already used cached value
|
||||
} else if (last_time == new_time) {
|
||||
dvalue = last_tpcpu;
|
||||
return;
|
||||
} else {
|
||||
new_cpu = timer->elapsed(Timer::TOTAL);
|
||||
double cpu_diff = new_cpu - last_tpcpu;
|
||||
double cpu_diff = new_cpu - last_cpu1;
|
||||
double time_diff = new_time - last_time;
|
||||
if (time_diff > 0.0 && cpu_diff > 0.0)
|
||||
dvalue = time_diff / cpu_diff;
|
||||
@ -1846,7 +1850,8 @@ void Thermo::compute_tpcpu()
|
||||
}
|
||||
|
||||
last_time = new_time;
|
||||
last_tpcpu = new_cpu;
|
||||
last_cpu1 = new_cpu;
|
||||
last_tpcpu = dvalue;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -1859,9 +1864,13 @@ void Thermo::compute_spcpu()
|
||||
if (firststep == 0) {
|
||||
new_cpu = 0.0;
|
||||
dvalue = 0.0;
|
||||
// if evaluated on the same step already used cached value
|
||||
} else if (last_step == new_step) {
|
||||
dvalue = last_spcpu;
|
||||
return;
|
||||
} else {
|
||||
new_cpu = timer->elapsed(Timer::TOTAL);
|
||||
double cpu_diff = new_cpu - last_spcpu;
|
||||
double cpu_diff = new_cpu - last_cpu2;
|
||||
auto step_diff = double(new_step - last_step);
|
||||
if (cpu_diff > 0.0)
|
||||
dvalue = step_diff / cpu_diff;
|
||||
@ -1869,8 +1878,9 @@ void Thermo::compute_spcpu()
|
||||
dvalue = 0.0;
|
||||
}
|
||||
|
||||
last_cpu2 = new_cpu;
|
||||
last_step = new_step;
|
||||
last_spcpu = new_cpu;
|
||||
last_spcpu = dvalue;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -80,7 +80,7 @@ class Thermo : protected Pointers {
|
||||
int flushflag, lineflag;
|
||||
|
||||
double last_tpcpu, last_spcpu;
|
||||
double last_time;
|
||||
double last_time, last_cpu1, last_cpu2;
|
||||
bigint last_step;
|
||||
|
||||
bigint natoms;
|
||||
|
||||
Reference in New Issue
Block a user