From dfe0a18d70c56a5e1d5442ea6f59196a92915bfc Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Wed, 17 Feb 2021 19:25:29 +0100 Subject: [PATCH] get flatifier rid of SimDag --- .../flatifier/bogus_missing_gateway.tesh | 2 - .../flatifier/bogus_two_hosts_asymetric.tesh | 1 - teshsuite/simdag/flatifier/flatifier.cpp | 78 ++++++++----------- teshsuite/simdag/flatifier/flatifier.tesh | 10 --- 4 files changed, 34 insertions(+), 57 deletions(-) diff --git a/teshsuite/simdag/flatifier/bogus_missing_gateway.tesh b/teshsuite/simdag/flatifier/bogus_missing_gateway.tesh index cc2b34bbb8..340bd960a6 100644 --- a/teshsuite/simdag/flatifier/bogus_missing_gateway.tesh +++ b/teshsuite/simdag/flatifier/bogus_missing_gateway.tesh @@ -1,13 +1,11 @@ ! expect signal SIGABRT $ $VALGRIND_NO_LEAK_CHECK ${bindir:=.}/flatifier ../platforms/bogus_missing_src_gateway.xml "--log=root.fmt:[%10.6r]%e[%i:%a@%h]%e%m%n" -> [ 0.000000] [0:maestro@] Switching to the L07 model to handle parallel tasks. > [ 0.000000] [0:maestro@] Parse error at ../platforms/bogus_missing_src_gateway.xml:14: zoneRoute gw_src='nod-cluster_router.cluster.us' does name a node. Existing netpoints: > 'node-1.cluster.us','node-2.cluster.us','node-3.cluster.us','node-4.cluster.us','node-cluster_router.cluster.us','noeud-1.grappe.fr','noeud-2.grappe.fr','noeud-3.grappe.fr','noeud-4.grappe.fr','noeud-grappe_router.grappe.fr' > [ 0.000000] [0:maestro@] Exiting now. ! expect signal SIGABRT $ $VALGRIND_NO_LEAK_CHECK ${bindir:=.}/flatifier ../platforms/bogus_missing_dst_gateway.xml "--log=root.fmt:[%10.6r]%e[%i:%a@%h]%e%m%n" -> [ 0.000000] [0:maestro@] Switching to the L07 model to handle parallel tasks. > [ 0.000000] [0:maestro@] Parse error at ../platforms/bogus_missing_dst_gateway.xml:14: zoneRoute gw_dst='neud-grappe_router.grappe.fr' does name a node. Existing netpoints: > 'node-1.cluster.us','node-2.cluster.us','node-3.cluster.us','node-4.cluster.us','node-cluster_router.cluster.us','noeud-1.grappe.fr','noeud-2.grappe.fr','noeud-3.grappe.fr','noeud-4.grappe.fr','noeud-grappe_router.grappe.fr' > [ 0.000000] [0:maestro@] Exiting now. diff --git a/teshsuite/simdag/flatifier/bogus_two_hosts_asymetric.tesh b/teshsuite/simdag/flatifier/bogus_two_hosts_asymetric.tesh index f18b7e3afb..a34a29c930 100644 --- a/teshsuite/simdag/flatifier/bogus_two_hosts_asymetric.tesh +++ b/teshsuite/simdag/flatifier/bogus_two_hosts_asymetric.tesh @@ -1,4 +1,3 @@ ! expect signal SIGABRT $ $VALGRIND_NO_LEAK_CHECK ${bindir:=.}/flatifier ../platforms/bogus_two_hosts_asymetric.xml "--log=root.fmt:[%10.6r]%e[%i:%a@%h]%e%m%n" --log=no_loc -> [ 0.000000] [0:maestro@] Switching to the L07 model to handle parallel tasks. > [ 0.000000] [0:maestro@] The route between alice and bob already exists (Rq: routes are symmetrical by default). diff --git a/teshsuite/simdag/flatifier/flatifier.cpp b/teshsuite/simdag/flatifier/flatifier.cpp index 9f230dae59..d9496b9629 100644 --- a/teshsuite/simdag/flatifier/flatifier.cpp +++ b/teshsuite/simdag/flatifier/flatifier.cpp @@ -8,7 +8,6 @@ #include "simgrid/kernel/routing/NetPoint.hpp" #include "simgrid/s4u/Engine.hpp" #include "simgrid/s4u/Host.hpp" -#include "simgrid/simdag.h" #include "src/surf/network_interface.hpp" #include @@ -16,6 +15,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(flatifier, "Logging specific to this platform parsing tool"); +namespace sg4 = simgrid::s4u; + static bool parse_cmdline(int* timings, char** platformFile, int argc, char** argv) { bool parse_ok = true; @@ -34,25 +35,24 @@ static bool parse_cmdline(int* timings, char** platformFile, int argc, char** ar return parse_ok; } -static void create_environment(xbt_os_timer_t parse_time, const char *platformFile) +static void create_environment(xbt_os_timer_t parse_time, const std::string platformFile) { xbt_os_cputimer_start(parse_time); - SD_create_environment(platformFile); + sg4::Engine::get_instance()->load_platform(platformFile); xbt_os_cputimer_stop(parse_time); } static void dump_hosts() { - size_t totalHosts = sg_host_count(); - sg_host_t* hosts = sg_host_list(); - std::sort(hosts, hosts + totalHosts, - [](const_sg_host_t a, const_sg_host_t b) { return strcmp(sg_host_get_name(a), sg_host_get_name(b)) < 0; }); - - for (size_t i = 0; i < totalHosts; i++) { - std::printf(" get_cname(), sg_host_get_speed(hosts[i])); - const std::unordered_map* props = hosts[i]->get_properties(); - if (hosts[i]->get_core_count() > 1) { - std::printf(" core=\"%d\"", hosts[i]->get_core_count()); + std::vector hosts = sg4::Engine::get_instance()->get_all_hosts(); + std::sort(hosts.begin(), hosts.end(), + [](const sg4::Host* a, const sg4::Host* b) { return a->get_name() < b->get_name(); }); + + for (auto h : hosts) { + std::printf(" get_cname(), h->get_speed()); + const std::unordered_map* props = h->get_properties(); + if (h->get_core_count() > 1) { + std::printf(" core=\"%d\"", h->get_core_count()); } // Sort the properties before displaying them, so that the tests are perfectly reproducible std::vector keys; @@ -68,20 +68,17 @@ static void dump_hosts() std::printf("/>\n"); } } - xbt_free(hosts); } static void dump_links() { - size_t totalLinks = sg_link_count(); - simgrid::s4u::Link** links = sg_link_list(); + std::vector links = sg4::Engine::get_instance()->get_all_links(); - std::sort(links, links + totalLinks, [](const simgrid::s4u::Link* a, const simgrid::s4u::Link* b) { - return strcmp(sg_link_get_name(a), sg_link_get_name(b)) < 0; + std::sort(links.begin(), links.end(), [](const sg4::Link* a, const sg4::Link* b) { + return a->get_name() < b->get_name(); }); - for (size_t i = 0; i < totalLinks; i++) { - const simgrid::s4u::Link* link = links[i]; + for (auto link : links) { std::printf(" get_cname(), link->get_bandwidth(), link->get_latency()); @@ -91,14 +88,12 @@ static void dump_links() std::printf(" sharing_policy=\"FATPIPE\"/>\n"); } } - - xbt_free(links); } static void dump_routers() { std::vector netpoints = - simgrid::s4u::Engine::get_instance()->get_all_netpoints(); + sg4::Engine::get_instance()->get_all_netpoints(); std::sort(netpoints.begin(), netpoints.end(), [](const simgrid::kernel::routing::NetPoint* a, const simgrid::kernel::routing::NetPoint* b) { return a->get_name() < b->get_name(); @@ -111,28 +106,25 @@ static void dump_routers() static void dump_routes() { - size_t totalHosts = sg_host_count(); - sg_host_t* hosts = sg_host_list(); - std::sort(hosts, hosts + totalHosts, - [](const_sg_host_t a, const_sg_host_t b) { return strcmp(sg_host_get_name(a), sg_host_get_name(b)) < 0; }); + std::vector hosts = sg4::Engine::get_instance()->get_all_hosts(); + std::sort(hosts.begin(), hosts.end(), + [](const sg4::Host* a, const sg4::Host* b) { return a->get_name() < b->get_name(); }); std::vector netpoints = - simgrid::s4u::Engine::get_instance()->get_all_netpoints(); + sg4::Engine::get_instance()->get_all_netpoints(); std::sort(netpoints.begin(), netpoints.end(), [](const simgrid::kernel::routing::NetPoint* a, const simgrid::kernel::routing::NetPoint* b) { return a->get_name() < b->get_name(); }); - for (size_t it_src = 0; it_src < totalHosts; it_src++) { // Routes from host - const 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 - const simgrid::s4u::Host* host2 = hosts[it_dst]; + for (auto src_host : hosts) { // Routes from host + simgrid::kernel::routing::NetPoint* src = src_host->get_netpoint(); + for (auto dst_host : hosts) { // Routes to host std::vector route; - simgrid::kernel::routing::NetPoint* dst = host2->get_netpoint(); + simgrid::kernel::routing::NetPoint* dst = dst_host->get_netpoint(); simgrid::kernel::routing::NetZoneImpl::get_global_route(src, dst, route, nullptr); if (route.empty()) continue; - std::printf(" \n ", host1->get_cname(), host2->get_cname()); + std::printf(" \n ", src_host->get_cname(), dst_host->get_cname()); for (auto const& link : route) std::printf("", link->get_cname()); std::printf("\n \n"); @@ -141,7 +133,7 @@ static void dump_routes() for (auto const& dst : netpoints) { // to router if (not dst->is_router()) continue; - std::printf(" \n ", host1->get_cname(), dst->get_cname()); + std::printf(" \n ", src_host->get_cname(), dst->get_cname()); std::vector route; simgrid::kernel::routing::NetZoneImpl::get_global_route(src, dst, route, nullptr); for (auto const& link : route) @@ -163,18 +155,16 @@ static void dump_routes() std::printf("", link->get_cname()); std::printf("\n \n"); } - for (unsigned int it_dst = 0; it_dst < totalHosts; it_dst++) { // Routes to host - const simgrid::s4u::Host* host2 = hosts[it_dst]; - std::printf(" \n ", value1->get_cname(), host2->get_cname()); + for (auto dst_host : hosts) { // Routes to host + std::printf(" \n ", value1->get_cname(), dst_host->get_cname()); std::vector route; - simgrid::kernel::routing::NetPoint* netcardDst = host2->get_netpoint(); + simgrid::kernel::routing::NetPoint* netcardDst = dst_host->get_netpoint(); simgrid::kernel::routing::NetZoneImpl::get_global_route(value1, netcardDst, route, nullptr); for (auto const& link : route) std::printf("", link->get_cname()); std::printf("\n \n"); } } - xbt_free(hosts); } static void dump_platform() @@ -209,7 +199,7 @@ int main(int argc, char** argv) xbt_os_timer_t parse_time = xbt_os_timer_new(); - SD_init(&argc, argv); + sg4::Engine e(&argc, argv); if (not parse_cmdline(&timings, &platformFile, argc, argv) || not platformFile) xbt_die("Invalid command line arguments: expected [--timings] platformFile"); @@ -219,8 +209,8 @@ int main(int argc, char** argv) create_environment(parse_time, platformFile); if (timings) { - XBT_INFO("Parsing time: %fs (%zu hosts, %d links)", xbt_os_timer_elapsed(parse_time), sg_host_count(), - sg_link_count()); + XBT_INFO("Parsing time: %fs (%zu hosts, %zu links)", xbt_os_timer_elapsed(parse_time), e.get_host_count(), + e.get_link_count()); } else { dump_platform(); } diff --git a/teshsuite/simdag/flatifier/flatifier.tesh b/teshsuite/simdag/flatifier/flatifier.tesh index 1b3acda8c1..3f8b607750 100644 --- a/teshsuite/simdag/flatifier/flatifier.tesh +++ b/teshsuite/simdag/flatifier/flatifier.tesh @@ -1,6 +1,5 @@ #!/usr/bin/env tesh $ ${bindir:=.}/flatifier ../platforms/one_cluster.xml "--log=root.fmt:[%10.6r]%e[%i:%a@%h]%e%m%n" -> [ 0.000000] [0:maestro@] Switching to the L07 model to handle parallel tasks. > > > @@ -135,7 +134,6 @@ $ ${bindir:=.}/flatifier ../platforms/one_cluster.xml "--log=root.fmt:[%10.6r]%e > $ ${bindir:=.}/flatifier ../platforms/one_cluster_multicore.xml "--log=root.fmt:[%10.6r]%e[%i:%a@%h]%e%m%n" -> [ 0.000000] [0:maestro@] Switching to the L07 model to handle parallel tasks. > > > @@ -269,7 +267,6 @@ $ ${bindir:=.}/flatifier ../platforms/one_cluster_multicore.xml "--log=root.fmt: > $ ${bindir:=.}/flatifier ../platforms/host_attributes.xml "--log=root.fmt:[%10.6r]%e[%i:%a@%h]%e%m%n" -> [ 0.000000] [0:maestro@] Switching to the L07 model to handle parallel tasks. > > > @@ -303,7 +300,6 @@ $ ${bindir:=.}/flatifier ../platforms/host_attributes.xml "--log=root.fmt:[%10.6 > $ ${bindir:=.}/flatifier ../platforms/link_attributes.xml "--log=root.fmt:[%10.6r]%e[%i:%a@%h]%e%m%n" -> [ 0.000000] [0:maestro@] Switching to the L07 model to handle parallel tasks. > > > @@ -321,7 +317,6 @@ $ ${bindir:=.}/flatifier ../platforms/link_attributes.xml "--log=root.fmt:[%10.6 > $ ${bindir:=.}/flatifier ../platforms/three_hosts_non_symmetric_route.xml "--log=root.fmt:[%10.6r]%e[%i:%a@%h]%e%m%n" -> [ 0.000000] [0:maestro@] Switching to the L07 model to handle parallel tasks. > > > @@ -364,7 +359,6 @@ $ ${bindir:=.}/flatifier ../platforms/three_hosts_non_symmetric_route.xml "--log > $ ${bindir:=.}/flatifier ../platforms/two_clusters.xml "--log=root.fmt:[%10.6r]%e[%i:%a@%h]%e%m%n" -> [ 0.000000] [0:maestro@] Switching to the L07 model to handle parallel tasks. > > > @@ -499,7 +493,6 @@ $ ${bindir:=.}/flatifier ../platforms/two_clusters.xml "--log=root.fmt:[%10.6r]% > $ ${bindir:=.}/flatifier ../platforms/two_hosts_multi_hop.xml "--log=root.fmt:[%10.6r]%e[%i:%a@%h]%e%m%n" -> [ 0.000000] [0:maestro@] Switching to the L07 model to handle parallel tasks. > > > @@ -526,7 +519,6 @@ $ ${bindir:=.}/flatifier ../platforms/two_hosts_multi_hop.xml "--log=root.fmt:[% > $ ${bindir:=.}/flatifier ../platforms/two_hosts_one_link.xml "--log=root.fmt:[%10.6r]%e[%i:%a@%h]%e%m%n" -> [ 0.000000] [0:maestro@] Switching to the L07 model to handle parallel tasks. > > > @@ -551,7 +543,6 @@ $ ${bindir:=.}/flatifier ../platforms/two_hosts_one_link.xml "--log=root.fmt:[%1 > $ ${bindir:=.}/flatifier ${srcdir:=.}/examples/platforms/bypassZoneRoute.xml "--log=root.fmt:[%10.6r]%e[%i:%a@%h]%e%m%n" -> [ 0.000000] [0:maestro@] Switching to the L07 model to handle parallel tasks. > > > @@ -685,7 +676,6 @@ $ ${bindir:=.}/flatifier ${srcdir:=.}/examples/platforms/bypassZoneRoute.xml "-- > $ ${bindir:=.}/flatifier ${srcdir:=.}/examples/platforms/cluster_torus.xml "--log=root.fmt:[%10.6r]%e[%i:%a@%h]%e%m%n" -> [ 0.000000] [0:maestro@] Switching to the L07 model to handle parallel tasks. > > > -- 2.20.1