From: Frederic Suter Date: Thu, 8 Sep 2016 11:03:03 +0000 (+0200) Subject: simplifications X-Git-Tag: v3_14~414 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a9361ff5f9057e93ed0bbdfac0eab6e5ba8aeab8 simplifications --- diff --git a/include/simgrid/jedule/jedule.hpp b/include/simgrid/jedule/jedule.hpp index 372f265ad4..8d7fd7bee8 100644 --- a/include/simgrid/jedule/jedule.hpp +++ b/include/simgrid/jedule/jedule.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2010-2012, 2014-2015. The SimGrid Team. +/* Copyright (c) 2010-2012, 2014-2016. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it diff --git a/include/simgrid/jedule/jedule_events.hpp b/include/simgrid/jedule/jedule_events.hpp index cb86fa3004..757e720eb9 100644 --- a/include/simgrid/jedule/jedule_events.hpp +++ b/include/simgrid/jedule/jedule_events.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2010-2012, 2014-2015. The SimGrid Team. +/* Copyright (c) 2010-2012, 2014-2016. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it diff --git a/include/simgrid/jedule/jedule_platform.hpp b/include/simgrid/jedule/jedule_platform.hpp index 204ddc87e7..3efd11cf4a 100644 --- a/include/simgrid/jedule/jedule_platform.hpp +++ b/include/simgrid/jedule/jedule_platform.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2010-2012, 2014-2015. The SimGrid Team. +/* Copyright (c) 2010-2012, 2014-2016. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it diff --git a/include/simgrid/jedule/jedule_sd_binding.h b/include/simgrid/jedule/jedule_sd_binding.h index 8f2a162391..9a494b7ed7 100644 --- a/include/simgrid/jedule/jedule_sd_binding.h +++ b/include/simgrid/jedule/jedule_sd_binding.h @@ -13,9 +13,7 @@ #if HAVE_JEDULE SG_BEGIN_DECL() XBT_PUBLIC(void) jedule_log_sd_event(SD_task_t task); -XBT_PUBLIC(void) jedule_setup_platform(void); XBT_PUBLIC(void) jedule_sd_init(void); -XBT_PUBLIC(void) jedule_sd_cleanup(void); XBT_PUBLIC(void) jedule_sd_exit(void); XBT_PUBLIC(void) jedule_sd_dump(const char* filename); SG_END_DECL() diff --git a/src/instr/jedule/jedule.cpp b/src/instr/jedule/jedule.cpp index a687a255f2..ed3d6e51aa 100644 --- a/src/instr/jedule/jedule.cpp +++ b/src/instr/jedule/jedule.cpp @@ -1,15 +1,9 @@ -/* Copyright (c) 2010-2014. The SimGrid Team. +/* Copyright (c) 2010-2016. The SimGrid Team. * All rights reserved. */ /* 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/host.h" - -#include -#include -#include - #include "xbt/asserts.h" #include "simgrid/jedule/jedule.hpp" @@ -32,14 +26,8 @@ void Jedule::addMetaInfo(char *key, char *value) { this->meta_info.insert({key, value}); } -void Jedule::cleanupOutput() { - for (auto evt: this->event_set) - delete evt; - this->event_set.clear(); -} void Jedule::writeOutput(FILE *file) { if (!this->event_set.empty()){ - fprintf(file, "\n"); if (!this->meta_info.empty()){ diff --git a/src/instr/jedule/jedule_events.cpp b/src/instr/jedule/jedule_events.cpp index d363720508..5d4c94977c 100644 --- a/src/instr/jedule/jedule_events.cpp +++ b/src/instr/jedule/jedule_events.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2010-2014. The SimGrid Team. +/* Copyright (c) 2010-2016. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -6,9 +6,6 @@ #include "simgrid/jedule/jedule_events.hpp" #include "simgrid/jedule/jedule.hpp" -#include -#include -#include #include "xbt/asserts.h" diff --git a/src/instr/jedule/jedule_platform.cpp b/src/instr/jedule/jedule_platform.cpp index c644294cb2..060dbe06c6 100644 --- a/src/instr/jedule/jedule_platform.cpp +++ b/src/instr/jedule/jedule_platform.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2010-2015. The SimGrid Team. +/* Copyright (c) 2010-2016. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -7,15 +7,9 @@ #include "simgrid/jedule/jedule.hpp" #include "simgrid/jedule/jedule_platform.hpp" #include "simgrid/s4u/As.hpp" -#include "simgrid/host.h" #include "xbt/asserts.h" #include "xbt/dynar.h" -#include "xbt/str.h" -#include - -#include -#include #if HAVE_JEDULE @@ -28,11 +22,9 @@ Container::Container(std::string name) } Container::~Container(){ - if(!this->children.empty()) { - for (auto child: this->children){ + if(!this->children.empty()) + for (auto child: this->children) delete child; - } - } } void Container::addChild(jed_container_t child){ @@ -189,9 +181,7 @@ static void add_subset_to(xbt_dynar_t subset_list, int start, int end, jed_conta xbt_dynar_push(subset_list, &subset); } -static void add_subsets_to(xbt_dynar_t subset_list, xbt_dynar_t hostgroup, jed_container_t parent) { - unsigned int iter; - char *host_name; +static void add_subsets_to(xbt_dynar_t subset_list, std::vector hostgroup, jed_container_t parent) { int id; // get ids for each host @@ -200,15 +190,13 @@ static void add_subsets_to(xbt_dynar_t subset_list, xbt_dynar_t hostgroup, jed_c // create subset for each id group xbt_assert( subset_list != nullptr ); - xbt_assert( hostgroup != nullptr ); xbt_assert( parent != nullptr ); xbt_dynar_t id_list = xbt_dynar_new(sizeof(int), nullptr); - xbt_dynar_foreach(hostgroup, iter, host_name) { - jed_container_t parent; + for (auto host_name : hostgroup) { xbt_assert( host_name != nullptr ); - parent = (jed_container_t)host2_simgrid_parent_container.at(host_name); + jed_container_t parent = host2_simgrid_parent_container.at(host_name); id = parent->name2id.at(host_name); xbt_dynar_push(id_list, &id); } @@ -242,35 +230,27 @@ static void add_subsets_to(xbt_dynar_t subset_list, xbt_dynar_t hostgroup, jed_c } void jed_simgrid_get_resource_selection_by_hosts(xbt_dynar_t subset_list, std::vector *host_list) { - std::unordered_map parent2hostgroup; // group hosts by parent - xbt_assert( host_list != nullptr ); - // for each host name // find parent container // group by parent container - + std::unordered_map> parent2hostgroup; for (auto host: *host_list) { const char *host_name = sg_host_get_name(host); - jed_container_t parent = (jed_container_t)host2_simgrid_parent_container.at(host_name); + jed_container_t parent = host2_simgrid_parent_container.at(host_name); xbt_assert( parent != nullptr ); auto host_group = parent2hostgroup.find(parent->name.c_str()); - if (host_group == parent2hostgroup.end()){ - xbt_dynar_t group = xbt_dynar_new(sizeof(char*), nullptr); - xbt_dynar_push(group, &host_name); - parent2hostgroup.insert({parent->name.c_str(), group}); - } else { - xbt_dynar_push(host_group->second, &host_name); - } + if (host_group == parent2hostgroup.end()) + parent2hostgroup.insert({parent->name.c_str(), std::vector(1,host_name)}); + else + host_group->second.push_back(host_name); } for (auto elm: parent2hostgroup) { - jed_container_t parent = (jed_container_t)container_name2container.at(elm.first); + jed_container_t parent = container_name2container.at(elm.first); add_subsets_to(subset_list, elm.second, parent); - xbt_dynar_free_container(&elm.second); } } - #endif diff --git a/src/instr/jedule/jedule_sd_binding.cpp b/src/instr/jedule/jedule_sd_binding.cpp index 0da355cfdd..ee3c1105da 100644 --- a/src/instr/jedule/jedule_sd_binding.cpp +++ b/src/instr/jedule/jedule_sd_binding.cpp @@ -1,25 +1,16 @@ -/* Copyright (c) 2010-2015. The SimGrid Team. +/* Copyright (c) 2010-2016. The SimGrid Team. * All rights reserved. */ /* 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 "xbt/asserts.h" - -#include "src/surf/surf_private.h" -#include "surf/surf.h" - #include "simgrid/jedule/jedule_sd_binding.h" -#include "simgrid/simdag.h" -#include "simgrid/s4u/As.hpp" -#include "simgrid/s4u/engine.hpp" - -#include #include "simgrid/forward.h" +#include "simgrid/s4u/As.hpp" +#include "simgrid/s4u/engine.hpp" #include "simgrid/jedule/jedule.hpp" -#include "simgrid/jedule/jedule_events.hpp" -#include "simgrid/jedule/jedule_platform.hpp" #include "../../simdag/simdag_private.hpp" #if HAVE_JEDULE @@ -33,13 +24,13 @@ void jedule_log_sd_event(SD_task_t task) { xbt_assert(task != nullptr); - jed_event_t event = - new simgrid::jedule::Event(std::string(SD_task_get_name(task)), task->start_time, task->finish_time,"SD"); + jed_event_t event = new simgrid::jedule::Event(std::string(SD_task_get_name(task)), + SD_task_get_start_time(task), SD_task_get_finish_time(task), "SD"); event->addResources(task->allocation); my_jedule->event_set.push_back(event); } -void jedule_setup_platform() +void jedule_sd_init() { AS_t root_comp = simgrid::s4u::Engine::instance()->rootAs(); XBT_DEBUG("root name %s\n", root_comp->name()); @@ -51,15 +42,6 @@ void jedule_setup_platform() my_jedule->root_container = root_container; } -void jedule_sd_cleanup() -{ - my_jedule->cleanupOutput(); -} - -void jedule_sd_init() -{ -} - void jedule_sd_exit(void) { delete my_jedule; diff --git a/src/simdag/sd_global.cpp b/src/simdag/sd_global.cpp index 7b8a101ae1..38a5852596 100644 --- a/src/simdag/sd_global.cpp +++ b/src/simdag/sd_global.cpp @@ -162,10 +162,6 @@ void SD_init(int *argc, char **argv) xbt_cfg_setdefault_string("host/model", "ptask_L07"); -#if HAVE_JEDULE - jedule_sd_init(); -#endif - if (_sg_cfg_exit_asap) { SD_exit(); exit(0); @@ -207,7 +203,7 @@ void SD_create_environment(const char *platform_file) XBT_DEBUG("Host number: %zu, link number: %d", sg_host_count(), sg_link_count()); #if HAVE_JEDULE - jedule_setup_platform(); + jedule_sd_init(); #endif XBT_VERB("Starting simulation..."); surf_presolve(); /* Takes traces into account */ @@ -249,7 +245,6 @@ double SD_get_clock() { void SD_exit() { #if HAVE_JEDULE - jedule_sd_cleanup(); jedule_sd_exit(); #endif delete sd_global;