+void process::load_balance()
+{
+ if (lb_iter == 1) // warn only once
+ XBT_WARN("process::load_balance() is a no-op!");
+}
+
+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);
+ XBT_DEBUG("compute %g flop%s", flops, ESSE(flops));
+ MSG_task_execute(task);
+ comp += flops;
+ MSG_task_destroy(task);
+ } else {
+ XBT_DEBUG("nothing to compute !");
+ }
+}
+
+void process::send(neighbor& nb, double amount)
+{
+ set_load(get_load() - amount);
+ nb.set_to_send(nb.get_to_send() + amount);
+ nb.set_load(nb.get_load() + amount); // fixme: make this optional?
+}
+
+void process::send1_no_bookkeeping(neighbor& nb)
+{
+ if (real_load != prev_load_broadcast)
+ comm.ctrl_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.data_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.ctrl_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.ctrl_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.data_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.ctrl_flush(false);
+ comm.data_flush(false);
+}
+
+void process::receive(double timeout)