+void process::convergence_check()
+{
+ double average = total_load_average; // fixme: get locked?
+ double load_diff = std::fabs(real_load - average);
+ bool converged = load_diff <= load_diff_threshold;
+
+ if (converged) {
+ if (convergence < 0) {
+ XBT_VERB("current load has converged: %g (%.4g%%)",
+ real_load, 100.0 * load_diff / average);
+ convergence = MSG_get_clock();
+ local_convergence_counter = opt::exit_on_convergence;
+ }
+ if (local_convergence_counter > 0 && --local_convergence_counter == 0)
+ --convergence_counter;
+ } else {
+ if (convergence >= 0.0) {
+ XBT_VERB("current load has diverged: %g (%.4g%%)",
+ real_load, 100.0 * load_diff / average);
+ convergence = -1.0;
+ if (local_convergence_counter == 0)
+ ++convergence_counter;
+ }
+ }
+}
+