- if (timings) {
- XBT_INFO("Parsing time: %fs (%zu hosts, %d links)", xbt_os_timer_elapsed(parse_time),
- sg_host_count(), sg_link_count());
- } else {
- std::printf("<?xml version='1.0'?>\n");
- std::printf("<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n");
- std::printf("<platform version=\"%d\">\n", version);
- std::printf("<AS id=\"AS0\" routing=\"Full\">\n");
-
- // Hosts
- unsigned int totalHosts = sg_host_count();
- sg_host_t *hosts = sg_host_list();
- std::qsort((void *) hosts, totalHosts, sizeof(sg_host_t), name_compare_hosts);
-
- for (i = 0; i < totalHosts; i++) {
- std::printf(" <host id=\"%s\" speed=\"%.0f\"", hosts[i]->cname(), sg_host_speed(hosts[i]));
- props = sg_host_get_properties(hosts[i]);
- if (hosts[i]->coreCount()>1) {
- std::printf(" core=\"%d\"", hosts[i]->coreCount());
- }
- if (props && !xbt_dict_is_empty(props)) {
- std::printf(">\n");
- xbt_dict_foreach(props, cursor, key, data) {
- std::printf(" <prop id=\"%s\" value=\"%s\"/>\n", key, data);
- }
- std::printf(" </host>\n");
- } else {
- std::printf("/>\n");
+static void dump_routes()
+{
+ unsigned int totalHosts = sg_host_count();
+ sg_host_t* hosts = sg_host_list();
+ std::sort(hosts, hosts + totalHosts,
+ [](sg_host_t a, sg_host_t b) { return strcmp(sg_host_get_name(a), sg_host_get_name(b)) < 0; });
+ std::vector<simgrid::kernel::routing::NetPoint*> netpoints =
+ simgrid::s4u::Engine::get_instance()->get_all_netpoints();
+ std::sort(netpoints.begin(), netpoints.end(),
+ [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) {
+ return a->get_name() < b->get_name();
+ });
+
+ for (unsigned int it_src = 0; it_src < totalHosts; it_src++) { // Routes from host
+ simgrid::s4u::Host* host1 = hosts[it_src];
+ simgrid::kernel::routing::NetPoint* src = host1->get_netpoint();
+ for (unsigned int it_dst = 0; it_dst < totalHosts; it_dst++) { // Routes to host
+ simgrid::s4u::Host* host2 = hosts[it_dst];
+ std::vector<simgrid::kernel::resource::LinkImpl*> route;
+ simgrid::kernel::routing::NetPoint* dst = host2->get_netpoint();
+ simgrid::kernel::routing::NetZoneImpl::get_global_route(src, dst, route, nullptr);
+ if (not route.empty()) {
+ std::printf(" <route src=\"%s\" dst=\"%s\">\n ", host1->get_cname(), host2->get_cname());
+ for (auto const& link : route)
+ std::printf("<link_ctn id=\"%s\"/>", link->get_cname());
+ std::printf("\n </route>\n");