Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
please sonar with a few smells
[simgrid.git] / src / simdag / sd_dotloader.cpp
index ee34cab..ef435c4 100644 (file)
@@ -1,21 +1,22 @@
-/* Copyright (c) 2009-2018. The SimGrid Team.
+/* Copyright (c) 2009-2019. 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 "simdag_private.hpp"
+#include "simgrid/s4u/Engine.hpp"
 #include "simgrid/simdag.h"
 #include "src/internal_config.h"
 #include "xbt/file.hpp"
 #include <cstring>
 #include <unordered_map>
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_dotparse, sd, "Parsing DOT files");
-
 #if HAVE_GRAPHVIZ
 #include <graphviz/cgraph.h>
 
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_dotparse, sd, "Parsing DOT files");
+
 xbt_dynar_t SD_dotload_generic(const char* filename, bool sequential, bool schedule);
 
 static void dot_task_p_free(void *task) {
@@ -212,7 +213,8 @@ xbt_dynar_t SD_dotload_generic(const char* filename, bool sequential, bool sched
 
   if(schedule){
     if (schedule_success) {
-      sg_host_t* workstations = sg_host_list();
+      std::vector<simgrid::s4u::Host*> hosts = simgrid::s4u::Engine::get_instance()->get_all_hosts();
+
       for (auto const& elm : computers) {
         SD_task_t previous_task = nullptr;
         for (auto const& task : *elm.second) {
@@ -221,13 +223,12 @@ xbt_dynar_t SD_dotload_generic(const char* filename, bool sequential, bool sched
             if (previous_task && not SD_task_dependency_exists(previous_task, task))
               SD_task_dependency_add(previous_task, task);
 
-            SD_task_schedulel(task, 1, workstations[atoi(elm.first.c_str())]);
+            SD_task_schedulel(task, 1, hosts[atoi(elm.first.c_str())]);
             previous_task = task;
           }
         }
         delete elm.second;
       }
-      xbt_free(workstations);
     } else {
       XBT_WARN("The scheduling is ignored");
       for (auto const& elm : computers)
@@ -238,7 +239,7 @@ xbt_dynar_t SD_dotload_generic(const char* filename, bool sequential, bool sched
   }
 
   if (result && not acyclic_graph_detail(result)) {
-    std::string base = simgrid::xbt::Path(filename).getBasename();
+    std::string base = simgrid::xbt::Path(filename).get_base_name();
     XBT_ERROR("The DOT described in %s is not a DAG. It contains a cycle.", base.c_str());
     xbt_dynar_free(&result);
     result = nullptr;