+double process::load_balance(double /*my_load*/)
+{
+ if (lb_iter == 1) // warn only once
+ WARN0("process::load_balance() is a no-op!");
+ return 0.0;
+}
+
+void process::compute()
+{
+ if (real_load > 0.0) {
+ double flops = opt::comp_cost(real_load);
+ m_task_t task = MSG_task_create("computation", flops, 0.0, NULL);
+ TRACE_msg_set_task_category(task, TRACE_CAT_COMP);
+ DEBUG2("compute %g flop%s", flops, ESSE(flops));
+ MSG_task_execute(task);
+ comp += flops;
+ MSG_task_destroy(task);
+ } else {
+ DEBUG0("nothing to compute !");
+ }
+}
+
+void process::send1_no_bookkeeping(neighbor& nb)
+{
+ if (real_load != prev_load_broadcast)
+ comm.send(nb.get_ctrl_mbox(), new message(message::INFO, real_load));
+ double load_to_send = nb.get_to_send();
+ if (load_to_send > 0.0) {
+ comm.send(nb.get_data_mbox(), new message(message::LOAD, load_to_send));
+ nb.set_to_send(0.0);
+ }
+}
+
+void process::send1_bookkeeping(neighbor& nb)
+{
+ if (expected_load != prev_load_broadcast)
+ comm.send(nb.get_ctrl_mbox(),
+ new message(message::INFO, expected_load));
+ double load_to_send;
+ double new_debt;
+ double debt_to_send = nb.get_to_send();
+ if (debt_to_send > 0.0) {
+ comm.send(nb.get_ctrl_mbox(),
+ new message(message::CREDIT, debt_to_send));
+ nb.set_to_send(0.0);
+ new_debt = nb.get_debt() + debt_to_send;
+ } else {
+ new_debt = nb.get_debt();
+ }
+ if (real_load <= new_debt) {
+ load_to_send = real_load;
+ nb.set_debt(new_debt - load_to_send);
+ real_load = 0.0;
+ } else {
+ load_to_send = new_debt;
+ nb.set_debt(0.0);
+ real_load -= load_to_send;
+ }
+ if (load_to_send > 0.0)
+ comm.send(nb.get_data_mbox(), new message(message::LOAD, load_to_send));
+}
+
+void process::send_all()
+{
+ using std::tr1::bind;
+ using std::tr1::placeholders::_1;
+
+ if (opt::bookkeeping) {
+ std::for_each(neigh.begin(), neigh.end(),
+ bind(&process::send1_bookkeeping, this, _1));
+ prev_load_broadcast = expected_load;
+ } else {
+ std::for_each(neigh.begin(), neigh.end(),
+ bind(&process::send1_no_bookkeeping, this, _1));
+ prev_load_broadcast = real_load;
+ }
+ comm.flush(false);
+}
+
+void process::receive(double timeout)