11 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simu);
18 process::process(int argc, char *argv[])
20 if (argc < 2 || !(std::istringstream(argv[1]) >> load))
21 throw std::invalid_argument("bad or missing initial load");
22 neigh.assign(argv + 2, argv + argc);
23 e_xbt_log_priority_t logp = xbt_log_priority_verbose;
24 if (!LOG_ISENABLED(logp))
26 LOG1(logp, "My initial load is: %g", load);
27 std::ostringstream oss;
28 oss << neigh.size() << " neighbor";
30 oss << (neigh.size() > 1 ? "s: " : ": ");
31 std::transform(neigh.begin(), neigh.end() - 1,
32 std::ostream_iterator<std::string>(oss, ", "),
33 std::mem_fun_ref(&neighbor::getName));
34 oss << neigh.back().getName();
36 LOG1(logp, "Got %s.", oss.str().c_str());
43 MSG_process_sleep(100.0); // xxx
45 * while (there is something to do) {
48 * compute load balancing;
49 * send tasks to neighbors;
54 * - definition of load on heterogeneous hosts ?
55 * - how to detect convergence ?
56 * - how to manage link failures ?
59 // xxx: shall we retrieve pending tasks?
64 void process::compute()
66 double duration = opt::comp_cost(load);
67 m_task_t task = MSG_task_create("computation", duration, 0.0, NULL);
68 MSG_task_execute(task);
69 MSG_task_destroy(task);
72 void process::print_loads(e_xbt_log_priority_t logp)
74 if (!LOG_ISENABLED(logp))
76 std::ostringstream oss;
78 oss << "no neighbor!";
80 std::transform(neigh.begin(), neigh.end() - 1,
81 std::ostream_iterator<double>(oss, ", "),
82 std::mem_fun_ref(&neighbor::getLoad));
83 oss << neigh.back().getLoad();
85 LOG1(logp, "Neighbor loads: %s", oss.str().c_str());