From bdb4583c13ad9df1cec6f128debedb0e36673640 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Tue, 7 Nov 2017 13:36:04 +0100 Subject: [PATCH] split platform dump in sub function to reduce overload have to sort host and netpoint lists twice, but we sure can afford it --- teshsuite/simdag/flatifier/flatifier.cpp | 83 +++++++++++++++++------- 1 file changed, 59 insertions(+), 24 deletions(-) diff --git a/teshsuite/simdag/flatifier/flatifier.cpp b/teshsuite/simdag/flatifier/flatifier.cpp index 622d3bca57..524e44f50f 100644 --- a/teshsuite/simdag/flatifier/flatifier.cpp +++ b/teshsuite/simdag/flatifier/flatifier.cpp @@ -47,17 +47,9 @@ static void create_environment(xbt_os_timer_t parse_time, const char *platformFi } } -static void dump_platform() +static void dump_hosts() { - int version = 4; std::map* props = nullptr; - - std::printf("\n"); - std::printf("\n"); - std::printf("\n", version); - std::printf("\n"); - - // Hosts unsigned int totalHosts = sg_host_count(); sg_host_t* hosts = sg_host_list(); std::sort(hosts, hosts + totalHosts, @@ -79,20 +71,11 @@ static void dump_platform() std::printf("/>\n"); } } + std::free(hosts); +} - // Routers - std::vector netcardList; - simgrid::s4u::Engine::getInstance()->getNetpointList(&netcardList); - std::sort(netcardList.begin(), netcardList.end(), - [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) { - return a->getName() < b->getName(); - }); - - for (auto const& srcCard : netcardList) - if (srcCard->isRouter()) - std::printf(" \n", srcCard->getCname()); - - // Links +static void dump_links() +{ unsigned int totalLinks = sg_link_count(); simgrid::s4u::Link** links = sg_link_list(); @@ -111,6 +94,36 @@ static void dump_platform() } } + std::free(links); +} + +static void dump_routers() +{ + std::vector netcardList; + simgrid::s4u::Engine::getInstance()->getNetpointList(&netcardList); + std::sort(netcardList.begin(), netcardList.end(), + [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) { + return a->getName() < b->getName(); + }); + + for (auto const& srcCard : netcardList) + if (srcCard->isRouter()) + std::printf(" \n", srcCard->getCname()); +} + +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 netcardList; + simgrid::s4u::Engine::getInstance()->getNetpointList(&netcardList); + std::sort(netcardList.begin(), netcardList.end(), + [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) { + return a->getName() < b->getName(); + }); + 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* netcardSrc = host1->pimpl_netpoint; @@ -126,6 +139,7 @@ static void dump_platform() std::printf("\n \n"); } } + for (auto const& netcardDst : netcardList) { // to router if (netcardDst->isRouter()) { std::printf(" \n ", host1->getCname(), netcardDst->getCname()); @@ -162,11 +176,32 @@ static void dump_platform() } } } + std::free(hosts); +} + +static void dump_platform() +{ + int version = 4; + + std::printf("\n"); + std::printf("\n"); + std::printf("\n", version); + std::printf("\n"); + + // Hosts + dump_hosts(); + + // Routers + dump_routers(); + + // Links + dump_links(); + + // Routes + dump_routes(); std::printf("\n"); std::printf("\n"); - std::free(hosts); - std::free(links); } int main(int argc, char** argv) -- 2.20.1