12 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simu);
14 process::process(int argc, char* argv[])
16 if (argc < 2 || !(std::istringstream(argv[1]) >> load))
17 throw std::invalid_argument("bad or missing initial load");
18 neigh.assign(argv + 2, argv + argc);
20 e_xbt_log_priority_t logp = xbt_log_priority_verbose;
21 if (!LOG_ISENABLED(logp))
23 LOG1(logp, "My initial load is: %g", load);
24 std::ostringstream oss;
25 oss << neigh.size() << " neighbor";
27 oss << (neigh.size() > 1 ? "s: " : ": ");
28 std::transform(neigh.begin(), neigh.end() - 1,
29 std::ostream_iterator<const char*>(oss, ", "),
30 std::mem_fun_ref(&neighbor::get_name));
31 oss << neigh.back().get_name();
33 LOG1(logp, "Got %s.", oss.str().c_str());
46 xbt_sleep(0.5); // fixme
49 // MSG_process_sleep(100.0); // xxx
51 * while (there is something to do) {
54 * compute load balancing;
55 * send tasks to neighbors;
60 * - definition of load on heterogeneous hosts ?
61 * - how to detect convergence ?
62 * - how to manage link failures ?
65 // xxx: shall we retrieve pending tasks?
70 void process::receive()
77 if (comm.recv_info(amount, from)) {
78 // fixme: update neighbor
81 if (comm.recv_credit(amount, from)) {
82 expected_load += amount;
85 if (comm.recv_load(amount, from)) {
92 void process::compute()
94 double duration = opt::comp_cost(load);
95 m_task_t task = MSG_task_create("computation", duration, 0.0, NULL);
96 DEBUG2("Compute %g flop%s.", duration, duration > 1 ? "s" : "");
97 MSG_task_execute(task);
98 MSG_task_destroy(task);
101 void process::print_loads(e_xbt_log_priority_t logp)
103 if (!LOG_ISENABLED(logp))
105 std::ostringstream oss;
107 oss << "no neighbor!";
109 std::transform(neigh.begin(), neigh.end() - 1,
110 std::ostream_iterator<double>(oss, ", "),
111 std::mem_fun_ref(&neighbor::get_load));
112 oss << neigh.back().get_load();
114 LOG1(logp, "Neighbor loads: %s", oss.str().c_str());