unsigned lb_maxiter = 0;
unsigned comp_maxiter = 0;
double time_limit = 0;
+ bool exit_on_convergence = false;
bool exit_on_close = true;
// Named parameters lists
opterr = 0;
while ((c = getopt(*argc, argv,
"%:"
- "a:bc:C:d:D:eEhi:I:k:l:L:m:M:N:r:Rs:S:t:T:vVx:X:Z"))
+ "a:bc:C:d:D:eEGhi:I:k:l:L:m:M:N:r:Rs:S:t:T:vVx:X:Z"))
!= -1) {
switch (c) {
case '%':
case 'E':
opt::egocentric = !opt::egocentric;
break;
+ case 'G':
+ opt::exit_on_convergence = !opt::exit_on_convergence;
+ break;
case 'h':
opt::help_requested++;
break;
h.val_or_string(comp_maxiter, "no limit"));
DESCR("convergence is assumed within (\%)", "%g", opt::avg_load_ratio);
DESCR("time limit", "%s", h.val_or_string(time_limit, "no limit"));
+ DESCR("exit on convergence", "%s", h.on_off(exit_on_convergence));
DESCR("exit on close", "%s", h.on_off(exit_on_close));
XBT_INFO("`----");
std::clog << o("-% value")
<< "percent of the load average to assume the convergence"
<< " [" << opt::avg_load_ratio << "]\n";
+ std::clog << o("-G") << "toggle exit on detection of convergence"
+ << " [" << opt_helper::on_off(opt::exit_on_convergence) << "]\n";
std::clog << o("-t value")
<< "time limit (simulated time), 0 for no limit"
<< " [" << opt::time_limit << "]\n";
extern unsigned lb_maxiter;
extern unsigned comp_maxiter;
extern double time_limit;
+ extern bool exit_on_convergence;
extern bool exit_on_close;
// Named parameters lists
double process::total_load_average;
double process::load_diff_threshold;
+std::atomic<int> process::convergence_counter(0);
+
namespace {
void sleep_until_date(double& date, double duration)
proc_mutex->acquire();
process_counter++;
+ convergence_counter++;
total_load_init += real_load;
total_load_running += real_load;
total_load_average = total_load_running / process_counter;
XBT_VERB("current load has diverged: %g (%.4g%%)",
real_load, 100.0 * load_diff / average);
convergence = -1.0;
+ convergence_counter++;
}
} else {
if (converged) {
XBT_VERB("current load has converged: %g (%.4g%%)",
real_load, 100.0 * load_diff / average);
convergence = MSG_get_clock();
+ convergence_counter--;
}
}
}
XBT_VERB("Reached comp_maxiter: %d/%d", comp_iter, opt::comp_maxiter);
last_status = false;
+ } else if (opt::exit_on_convergence && convergence_counter == 0) {
+ XBT_VERB("Global convergence detected");
+ last_status = false;
+
} else if (opt::exit_on_close && close_received) {
XBT_VERB("Close received");
last_status = false;
#include <vector>
#include <msg/msg.h>
#include <xbt/log.h>
+#include "atomic_compat.h"
#include "communicator.h"
#include "misc.h"
#include "msg_thread.h"
static double total_load_average;
static double load_diff_threshold;
+ static std::atomic<int> convergence_counter;
+
typedef MAP_TEMPLATE<m_host_t, neighbor*> rev_neigh_type;
neigh_type neigh; // list of neighbors (do not alter
// after construction!)