Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
simplifications
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 8 Sep 2016 11:03:03 +0000 (13:03 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 8 Sep 2016 11:44:33 +0000 (13:44 +0200)
include/simgrid/jedule/jedule.hpp
include/simgrid/jedule/jedule_events.hpp
include/simgrid/jedule/jedule_platform.hpp
include/simgrid/jedule/jedule_sd_binding.h
src/instr/jedule/jedule.cpp
src/instr/jedule/jedule_events.cpp
src/instr/jedule/jedule_platform.cpp
src/instr/jedule/jedule_sd_binding.cpp
src/simdag/sd_global.cpp

index 372f265..8d7fd7b 100644 (file)
@@ -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
index cb86fa3..757e720 100644 (file)
@@ -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
index 204ddc8..3efd11c 100644 (file)
@@ -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
index 8f2a162..9a494b7 100644 (file)
@@ -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()
index a687a25..ed3d6e5 100644 (file)
@@ -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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
 #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, "<jedule>\n");
 
     if (!this->meta_info.empty()){
index d363720..5d4c949 100644 (file)
@@ -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 <stdio.h>
-#include <stdlib.h>
-#include <string>
 
 #include "xbt/asserts.h"
 
index c644294..060dbe0 100644 (file)
@@ -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 <string>
-
-#include <stdlib.h>
-#include <stdio.h>
 
 #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<const char*> 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<sg_host_t> *host_list) {
-  std::unordered_map<const char*, xbt_dynar_t> parent2hostgroup;  // group hosts by parent
-
   xbt_assert( host_list != nullptr );
-
   // for each host name
   //  find parent container
   //  group by parent container
-
+  std::unordered_map<const char*, std::vector<const char*>> 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<const char*>(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
index 0da355c..ee3c110 100644 (file)
@@ -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 <stdio.h>
 #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;
index 7b8a101..38a5852 100644 (file)
@@ -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;