final changes to fix halt

This commit is contained in:
Steve Plimpton
2016-10-18 11:16:28 -06:00
parent 1f1c87235a
commit 003581c6a8
3 changed files with 17 additions and 11 deletions

View File

@ -162,8 +162,7 @@ void FixHalt::end_of_step()
} }
// hard halt -> exit LAMMPS // hard halt -> exit LAMMPS
// soft halt -> trigger timer to break from run loop // soft/continue halt -> trigger timer to break from run loop
// continue halt -> trigger time to exit only this run loop
// print message with ID of fix halt in case multiple instances // print message with ID of fix halt in case multiple instances
char str[128]; char str[128];
@ -183,6 +182,8 @@ void FixHalt::end_of_step()
void FixHalt::post_run() void FixHalt::post_run()
{ {
// continue halt -> subsequent runs are allowd
if (eflag == CONTINUE) timer->reset_timeout(); if (eflag == CONTINUE) timer->reset_timeout();
} }

View File

@ -95,10 +95,10 @@ Timer::Timer(LAMMPS *lmp) : Pointers(lmp)
{ {
_level = NORMAL; _level = NORMAL;
_sync = OFF; _sync = OFF;
_timeout = -1; _timeout = -1.0;
_s_timeout = -1;
_checkfreq = 10; _checkfreq = 10;
_nextcheck = -1; _nextcheck = -1;
_laststep = -1;
this->_stamp(RESET); this->_stamp(RESET);
} }
@ -216,7 +216,7 @@ void Timer::set_wall(enum ttype which, double newtime)
void Timer::init_timeout() void Timer::init_timeout()
{ {
_s_timeout = _timeout; _laststep = -1;
if (_timeout < 0) if (_timeout < 0)
_nextcheck = -1; _nextcheck = -1;
else else
@ -249,6 +249,14 @@ void Timer::print_timeout(FILE *fp)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void Timer::force_timeout()
{
_timeout = 0.0;
_nextcheck = _laststep + 1;
}
/* ---------------------------------------------------------------------- */
bool Timer::_check_timeout() bool Timer::_check_timeout()
{ {
double walltime = MPI_Wtime() - timeout_start; double walltime = MPI_Wtime() - timeout_start;

View File

@ -64,10 +64,7 @@ class Timer : protected Pointers {
void init_timeout(); void init_timeout();
// trigger enforced timeout // trigger enforced timeout
void force_timeout() { _timeout = 0.0; } void force_timeout();
// restore original timeout setting after enforce timeout
void reset_timeout() { _timeout = _s_timeout; }
// get remaining time in seconds. 0.0 if inactive, negative if expired // get remaining time in seconds. 0.0 if inactive, negative if expired
double get_timeout_remain(); double get_timeout_remain();
@ -78,7 +75,7 @@ class Timer : protected Pointers {
// check for timeout. inline wrapper around internal // check for timeout. inline wrapper around internal
// function to reduce overhead in case there is no check. // function to reduce overhead in case there is no check.
bool check_timeout(int step) { bool check_timeout(int step) {
if (_timeout == 0.0) return true; _laststep = step;
if (_nextcheck != step) return false; if (_nextcheck != step) return false;
else return _check_timeout(); else return _check_timeout();
} }
@ -94,9 +91,9 @@ class Timer : protected Pointers {
int _level; // level of detail: off=0,loop=1,normal=2,full=3 int _level; // level of detail: off=0,loop=1,normal=2,full=3
int _sync; // if nonzero, synchronize tasks before setting the timer int _sync; // if nonzero, synchronize tasks before setting the timer
int _timeout; // max allowed wall time in seconds. infinity if negative int _timeout; // max allowed wall time in seconds. infinity if negative
int _s_timeout; // copy of timeout for restoring after a forced timeout
int _checkfreq; // frequency of timeout checking int _checkfreq; // frequency of timeout checking
int _nextcheck; // loop 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 // update one specific timer array
void _stamp(enum ttype); void _stamp(enum ttype);