#include <xbt/sysdep.h>
#include <xbt/xbt_os_time.h>
-#include <simgrid/s4u/host.hpp>
+#include "simgrid/s4u/engine.hpp"
+#include "simgrid/s4u/host.hpp"
#include <simgrid/simdag.h>
unsigned int i;
xbt_dict_t props = nullptr;
xbt_dict_cursor_t cursor = nullptr;
- xbt_lib_cursor_t cursor_src = nullptr;
- xbt_lib_cursor_t cursor_dst = nullptr;
- char *src,*dst,*key,*data;
+ char *key, *data;
sg_netcard_t value1;
sg_netcard_t value2;
create_environment(parse_time, platformFile);
+ std::vector<simgrid::kernel::routing::NetCard*> netcardList;
+ simgrid::s4u::Engine::instance()->netcardList(&netcardList);
+
if (timings) {
XBT_INFO("Parsing time: %fs (%zu hosts, %d links)", xbt_os_timer_elapsed(parse_time),
sg_host_count(), sg_link_count());
}
// Routers
- xbt_dict_foreach (netcards_dict, cursor_src, key, value1) {
- if(value1->isRouter()) {
- std::printf(" <router id=\"%s\"/>\n",key);
- }
- }
+ for (auto srcCard : netcardList)
+ if (srcCard->isRouter())
+ std::printf(" <router id=\"%s\"/>\n", srcCard->cname());
// Links
unsigned int totalLinks = sg_link_count();
}
}
- sg_host_t host1, host2;
for (unsigned int it_src = 0; it_src < totalHosts; it_src++) { // Routes from host
- host1 = hosts[it_src];
+ simgrid::s4u::Host* host1 = hosts[it_src];
value1 = host1->pimpl_netcard;
for (unsigned int it_dst = 0; it_dst < totalHosts; it_dst++) { // Routes to host
- host2 = hosts[it_dst];
+ simgrid::s4u::Host* host2 = hosts[it_dst];
std::vector<Link*> *route = new std::vector<Link*>();
value2 = host2->pimpl_netcard;
simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(value1, value2, route, nullptr);
}
delete route;
}
- xbt_dict_foreach (netcards_dict, cursor_dst, dst, value2) { // to router
+ for (auto value2 : netcardList) { // to router
if(value2->isRouter()){
- std::printf(" <route src=\"%s\" dst=\"%s\">\n ", host1->cname(), dst);
+ std::printf(" <route src=\"%s\" dst=\"%s\">\n ", host1->cname(), value2->cname());
std::vector<Link*> *route = new std::vector<Link*>();
simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(value1, value2, route, nullptr);
for (auto link : *route)
}
}
- xbt_dict_foreach (netcards_dict, cursor_src, src, value1) { // Routes from router
+ for (auto value1 : netcardList) { // Routes from router
if (value1->isRouter()){
- xbt_dict_foreach (netcards_dict, cursor_dst, dst, value2) { // to router
- if(value2->isRouter()){
- std::printf(" <route src=\"%s\" dst=\"%s\">\n ", src, dst);
- std::vector<Link*> *route = new std::vector<Link*>();
+ for (auto value2 : netcardList) { // to router
+ if (value2->isRouter()) {
+ std::printf(" <route src=\"%s\" dst=\"%s\">\n ", value1->cname(), value2->cname());
+ std::vector<Link*>* route = new std::vector<Link*>();
simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(value1, value2, route, nullptr);
for(auto link :*route)
std::printf("<link_ctn id=\"%s\"/>",link->getName());
}
}
for (unsigned int it_dst = 0; it_dst < totalHosts; it_dst++) { // Routes to host
- host2 = hosts[it_dst];
- std::printf(" <route src=\"%s\" dst=\"%s\">\n ", src, host2->cname());
+ simgrid::s4u::Host* host2 = hosts[it_dst];
+ std::printf(" <route src=\"%s\" dst=\"%s\">\n ", value1->cname(), host2->cname());
std::vector<Link*> *route = new std::vector<Link*>();
value2 = host2->pimpl_netcard;
simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(value1, value2, route, nullptr);
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
+#include "simgrid/s4u/engine.hpp"
#include "simgrid/s4u/host.hpp"
#include "simgrid/simdag.h"
#include "src/kernel/routing/NetCard.hpp"
xbt_dynar_t hosts = sg_hosts_as_dynar();
printf("Host count: %zu, link number: %d\n", sg_host_count(), sg_link_count());
+ std::vector<simgrid::kernel::routing::NetCard*> netcardList;
+ simgrid::s4u::Engine::instance()->netcardList(&netcardList);
+
int it;
sg_host_t host;
xbt_dynar_foreach(hosts, it, host) {
xbt_dynar_free(&hosts);
printf("NetCards count: %d\n", xbt_dict_length(netcards_dict));
- xbt_lib_cursor_t cursor = nullptr;
- char* key;
- void *ignored;
- xbt_dict_foreach (netcards_dict, cursor, key, ignored) {
- simgrid::kernel::routing::NetCard * nc = sg_netcard_by_name_or_null(key);
- printf(" - Seen: \"%s\". Type: %s\n", key, nc->isRouter() ? "router" : (nc->isNetZone() ? "netzone" : "host"));
- }
+ for (auto nc : netcardList)
+ printf(" - Seen: \"%s\". Type: %s\n", nc->cname(),
+ nc->isRouter() ? "router" : (nc->isNetZone() ? "netzone" : "host"));
SD_exit();
return 0;