+ int result;
+ process* proc;
+ try {
+ proc = opt::loba_algorithms.new_instance(opt::loba_algo, argc, argv);
+
+ proc_mutex->acquire();
+ ++proc_counter;
+ proc_mutex->release();
+
+ result = proc->run();
+
+ proc_mutex->acquire();
+ loads.push(proc->get_real_load());
+ comps.push(proc->get_comp_amount());
+ comp_iterations.push(proc->get_comp_iter());
+ all_comp_iterations.push(proc->get_all_comp_iter());
+ data_send_amount.push(proc->get_data_send_amount());
+ data_recv_amount.push(proc->get_data_recv_amount());
+ data_send_count.push(proc->get_data_send_count());
+ data_recv_count.push(proc->get_data_recv_count());
+ ctrl_send_amount.push(proc->get_ctrl_send_amount());
+ ctrl_recv_amount.push(proc->get_ctrl_recv_amount());
+ ctrl_send_count.push(proc->get_ctrl_send_count());
+ ctrl_recv_count.push(proc->get_ctrl_recv_count());
+
+ // Synchronization barrier...
+ // The goal is to circumvent a limitation in SimGrid (at least
+ // in version 3.5): a process must be alive when another one
+ // destroys a communication they had together.
+
+ --proc_counter;
+ proc_cond->broadcast();
+ while (proc_counter > 0)
+ proc_cond->wait(*proc_mutex);
+ proc_mutex->release();
+
+ delete proc;
+ }
+ catch (const std::invalid_argument& e) {
+ THROWF(arg_error, 0, "%s", e.what());
+ }
+ catch (const std::exception& e) {
+ THROWF(0, 0, "%s", e.what());
+ }
+ return result;
+}
+
+static bool check_for_lost_load()
+{
+ bool res = true;
+ double total_init = process::get_total_load_init();
+ double total_exit = process::get_total_load_exit();
+ double lost = total_init - total_exit;
+ double lost_ratio = 100.0 * lost / total_init;
+ if (lost_ratio < -opt::load_ratio_threshold) {
+ XBT_ERROR("Gained load at exit! %g (%g%%) <============",
+ -lost, -lost_ratio);
+ res = false;
+ } else if (lost_ratio > opt::load_ratio_threshold) {
+ XBT_ERROR("Lost load at exit! %g (%g%%) <============",
+ lost, lost_ratio);
+ res = false;
+ } else
+ XBT_VERB("Total load at exit looks good: %g (%g%%)", lost, lost_ratio);
+
+ double total_running = process::get_total_load_running();
+ double running_ratio = 100.0 * total_running / total_init;
+ if (running_ratio < -opt::load_ratio_threshold) {
+ XBT_ERROR("Negative running load at exit! %g (%g%%) <============",
+ total_running, running_ratio);
+ res = false;
+ } else if (running_ratio > opt::load_ratio_threshold) {
+ XBT_ERROR("Remaining running load at exit! %g (%g%%) <============",
+ total_running, running_ratio);
+ res = false;
+ } else
+ XBT_VERB("Running load at exit looks good: %g (%g%%)",
+ total_running, running_ratio);
+ return res;
+}
+
+static void signal_handler(int /*sig*/)
+{
+ if (!opt::exit_request) {
+ XBT_CRITICAL(">>>>>>>>>>"
+ " caught CTRL-C: global exit requested "
+ "<<<<<<<<<<");
+ opt::exit_request = 1;
+ } else {
+ XBT_CRITICAL(">>>>>>>>>>"
+ " caught CTRL-C for the 2nd time: exit immediately "
+ "<<<<<<<<<<");
+ exit(EXIT_FAILURE_INTR);
+ }