From f8a26dd158ff5b46b25c251e552524a0cb2beb0b Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 12 Oct 2016 07:26:03 -0400 Subject: [PATCH] update Timer::force_timeout() to trigger at next loop iteration --- src/timer.cpp | 10 ++++++++++ src/timer.h | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/timer.cpp b/src/timer.cpp index 8711231889..583c6a2b3f 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -98,6 +98,7 @@ Timer::Timer(LAMMPS *lmp) : Pointers(lmp) _timeout = -1.0; _checkfreq = 10; _nextcheck = -1; + _laststep = -1; this->_stamp(RESET); } @@ -215,6 +216,7 @@ void Timer::set_wall(enum ttype which, double newtime) void Timer::init_timeout() { + _laststep = -1; if (_timeout < 0) _nextcheck = -1; else @@ -247,6 +249,14 @@ void Timer::print_timeout(FILE *fp) /* ---------------------------------------------------------------------- */ +void Timer::force_timeout() +{ + _timeout = 0.0; + _nextcheck = _laststep + 1; +} + +/* ---------------------------------------------------------------------- */ + bool Timer::_check_timeout() { double walltime = MPI_Wtime() - timeout_start; diff --git a/src/timer.h b/src/timer.h index 903a182128..ff9c66db7c 100644 --- a/src/timer.h +++ b/src/timer.h @@ -64,7 +64,7 @@ class Timer : protected Pointers { void init_timeout(); // trigger enforced timeout - void force_timeout() { _timeout = 0.0; }; + void force_timeout(); // get remaining time in seconds. 0.0 if inactive, negative if expired double get_timeout_remain(); @@ -75,6 +75,7 @@ class Timer : protected Pointers { // check for timeout. inline wrapper around internal // function to reduce overhead in case there is no check. bool check_timeout(int step) { + _laststep = step; if (_nextcheck != step) return false; else return _check_timeout(); } @@ -91,7 +92,8 @@ class Timer : protected Pointers { int _sync; // if nonzero, synchronize tasks before setting the timer int _timeout; // max allowed wall time in seconds. infinity if negative int _checkfreq; // frequency of timeout checking - int _nextcheck; // timestep number of next timeout check + int _nextcheck; // loop number of next timeout check + int _laststep; // loop number of last iteration // update one specific timer array void _stamp(enum ttype);