1 #include "deployment.h"
11 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(depl);
13 void MY_launch_application()
15 deployment_generator* gen;
16 gen = opt::topologies.new_instance(opt::auto_depl::topology);
22 deployment_generator::deployment_generator()
23 : hosts(opt::auto_depl::nhosts)
25 set_load(0, opt::auto_depl::load);
28 void deployment_generator::set_load(int host, double load)
30 hosts[host].load = load;
33 void deployment_generator::set_neighbor(int host, int neighbor)
35 hosts[host].neighbors.push_back(neighbor);
38 void deployment_generator::set_link(int host1, int host2)
40 set_neighbor(host1, host2);
41 set_neighbor(host2, host1);
44 void deployment_generator::deploy()
46 const char* func = "simulation_main";
47 xbt_dynar_t args = xbt_dynar_new(sizeof(const char*), NULL);
48 for (unsigned i = 0 ; i < hosts.size() ; ++i) {
49 const char* hostname = hostdata::at(i).get_name();
50 std::ostringstream oss;
51 oss << std::setprecision(12) << hosts[i].load;
52 std::string strload = oss.str();
53 DEBUG2("%s/load -> \"%s\"", hostname, strload.c_str());
54 xbt_dynar_push_as(args, const char*, strload.c_str());
55 for (unsigned j = 0 ; j < hosts[i].neighbors.size() ; ++j) {
56 int neighbor = hosts[i].neighbors[j];
57 const char* neighbor_name = hostdata::at(neighbor).get_name();
58 DEBUG2("%s/neighbor -> \"%s\"", hostname, neighbor_name);
59 xbt_dynar_push_as(args, const char*, neighbor_name);
61 MSG_set_function(hostname, func, args);
62 xbt_dynar_reset(args);
64 xbt_dynar_free(&args);
67 void deployment_btree::generate()
69 for (unsigned i = 0 ; i < size() / 2 ; ++i) {
70 unsigned left_child = 2 * i + 1;
71 unsigned right_child = 2 * i + 2;
72 if (left_child < size()) {
73 set_link(i, left_child);
74 if (right_child < size())
75 set_link(i, right_child);
80 void deployment_clique::generate()
82 for (unsigned i = 0 ; i < size() ; ++i)
83 for (unsigned j = 0 ; j < i ; ++j)
87 void deployment_hcube::generate()
89 for (unsigned i = 0 ; i < size() ; ++i)
90 for (unsigned j = 0 ; j < i ; ++j) {
91 // Adapted from rom http://en.wikipedia.org/wiki/Hamming_distance
95 // Count the number of set bits
96 while (val && dist < 2) {
105 void deployment_line::generate()
107 for (unsigned i = 0 ; i < size() - 1 ; ++i)
111 void deployment_ring::generate()
113 set_neighbor(0, size() - 1);
114 for (unsigned i = 0 ; i < size() - 1 ; ++i)
116 set_neighbor(size() - 1, 0);
119 void deployment_star::generate()
121 for (unsigned i = 1 ; i < size() ; ++i)
125 // void deployment_torus::generate()