Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 1 Mar 2016 23:54:16 +0000 (00:54 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 1 Mar 2016 23:54:16 +0000 (00:54 +0100)
27 files changed:
include/simgrid/forward.h
include/simgrid/msg.h
include/simgrid/s4u/engine.hpp
src/include/surf/surf.h
src/instr/jedule/jedule_output.cpp
src/instr/jedule/jedule_sd_binding.cpp
src/msg/msg_environment.cpp
src/s4u/s4u_engine.cpp
src/simdag/sd_global.cpp
src/simgrid/sg_config.c
src/simix/smx_context.cpp
src/surf/instr_routing.cpp
src/surf/network_ns3.cpp
src/surf/sg_platf.cpp
src/surf/surf_interface.cpp
src/surf/surf_private.h
src/surf/surf_routing.cpp
src/surf/surf_routing.hpp
src/surf/surf_routing_RoutedGraph.cpp
src/surf/surf_routing_RoutedGraph.hpp
src/surf/surf_routing_cluster.hpp
src/surf/surf_routing_dijkstra.cpp
src/surf/surf_routing_floyd.cpp
src/surf/surf_routing_full.cpp
src/surf/surf_routing_none.hpp
src/surf/xml/platf_private.hpp
tools/cmake/DefinePackages.cmake

index 629feb6..ddf58ff 100644 (file)
 
 namespace simgrid {
   namespace s4u {
+    class As;
     class Host;
   }
   namespace surf {
     class Resource;
     class Cpu;
     class NetCard;
-    class As;
     class Link;
   }
   namespace trace_mgr {
@@ -26,7 +26,7 @@ namespace simgrid {
 }
 
 typedef simgrid::s4u::Host simgrid_Host;
-typedef simgrid::surf::As surf_As;
+typedef simgrid::s4u::As simgrid_As;
 typedef simgrid::surf::Cpu surf_Cpu;
 typedef simgrid::surf::NetCard surf_NetCard;
 typedef simgrid::surf::Link Link;
@@ -35,7 +35,7 @@ typedef simgrid::surf::Resource surf_Resource;
 #else
 
 typedef struct simgrid_Host simgrid_Host;
-typedef struct surf_As surf_As;
+typedef struct simgrid_As   simgrid_As;
 typedef struct surf_Cpu surf_Cpu;
 typedef struct surf_NetCard surf_NetCard;
 typedef struct surf_Resource surf_Resource;
@@ -43,7 +43,8 @@ typedef struct Link Link;
 #endif
 
 typedef simgrid_Host* sg_host_t;
-typedef surf_As *AS_t;
+typedef simgrid_As *AS_t;
+
 typedef surf_Cpu *surf_cpu_t;
 typedef surf_NetCard *sg_netcard_t;
 typedef surf_Resource *sg_resource_t;
index fe968e2..c1a2cf3 100644 (file)
@@ -29,7 +29,7 @@ SG_BEGIN_DECL()
 typedef struct s_smx_rvpoint *msg_mailbox_t;
 
 /* ******************************** Environment ************************************ */
-typedef surf_As *msg_as_t;
+typedef simgrid_As *msg_as_t;
 
 /* ******************************** Host ************************************ */
 
index 2c9fa3c..68d3de2 100644 (file)
@@ -51,7 +51,13 @@ public:
   static s4u::Engine *instance();
 private:
   static s4u::Engine *instance_;
+
+public:
+  /** @brief Retrieve the root AS, containing all others */
+  simgrid::s4u::As *rootAs();
+  /** @brief Retrieve the AS of the given name (or nullptr if not found) */
+  simgrid::s4u::As *asByNameOrNull(const char *name);
 };
-}} // namespace simgrid::sgo
+}} // namespace simgrid::s4u
 
 #endif /* SIMGRID_S4U_ENGINE_HPP */
index beceec4..11f12e4 100644 (file)
@@ -58,7 +58,6 @@ class NetworkCm02Link;
 class Action;
 class ActionLmm;
 class StorageActionLmm;
-class As;
 class RoutingPlatf;
 }
 }
@@ -738,14 +737,6 @@ XBT_PUBLIC_DATA(xbt_dynar_t) host_that_restart;
  */
 XBT_PUBLIC_DATA(xbt_dict_t) watched_hosts_lib;
 
-/*** SURF Platform *************************/
-XBT_PUBLIC_DATA(AS_t) surf_AS_get_routing_root(void);
-XBT_PUBLIC_DATA(const char *) surf_AS_get_name(AS_t as);
-XBT_PUBLIC_DATA(AS_t) surf_AS_get_by_name(const char * name);
-XBT_PUBLIC_DATA(xbt_dict_t) surf_AS_get_children(AS_t as);
-XBT_PUBLIC_DATA(xbt_dynar_t) surf_AS_get_hosts(AS_t as);
-XBT_PUBLIC_DATA(void) surf_AS_get_graph(AS_t as, xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges);
-
 /*** SURF Globals **************************/
 
 /** \ingroup SURF_simulation
index fa047a5..1655a20 100644 (file)
@@ -88,23 +88,6 @@ static void print_key_value_dict(xbt_dict_t key_value_dict) {
   }
 }
 
-static void print_container(jed_simgrid_container_t container) {
-  unsigned int i;
-  jed_simgrid_container_t child_container;
-
-  xbt_assert( container != NULL );
-
-  fprintf(jed_file, "    <res name=\"%s\">\n", container->name);
-  if( container->container_children != NULL ) {
-    xbt_dynar_foreach(container->container_children, i, child_container) {
-      print_container(child_container);
-    }
-  } else {
-    print_resources(container);
-  }
-  fprintf(jed_file, "    </res>\n");
-}
-
 static void print_resources(jed_simgrid_container_t resource_parent) {
   unsigned int res_nb;
   unsigned int i;
@@ -126,6 +109,23 @@ static void print_resources(jed_simgrid_container_t resource_parent) {
   fprintf(jed_file, "\" />\n");
 }
 
+static void print_container(jed_simgrid_container_t container) {
+  unsigned int i;
+  jed_simgrid_container_t child_container;
+
+  xbt_assert( container != NULL );
+
+  fprintf(jed_file, "    <res name=\"%s\">\n", container->name);
+  if( container->container_children != NULL ) {
+    xbt_dynar_foreach(container->container_children, i, child_container) {
+      print_container(child_container);
+    }
+  } else {
+    print_resources(container);
+  }
+  fprintf(jed_file, "    </res>\n");
+}
+
 static void print_platform(jed_simgrid_container_t root_container) {
   fprintf(jed_file, "  <platform>\n");
   print_container(root_container);
index f22c577..b82c48b 100644 (file)
@@ -18,6 +18,9 @@
 #include "simgrid/simdag.h"
 #include "src/simdag/simdag_private.h"
 
+#include "simgrid/s4u/as.hpp"
+#include "simgrid/s4u/engine.hpp"
+
 #include <stdio.h>
 
 #ifdef HAVE_JEDULE
@@ -53,12 +56,12 @@ static void create_hierarchy(AS_t current_comp, jed_simgrid_container_t current_
   xbt_dict_cursor_t cursor = NULL;
   char *key;
   AS_t elem;
-  xbt_dict_t routing_sons = surf_AS_get_children(current_comp);
+  xbt_dict_t routing_sons = current_comp->children();
 
   if (xbt_dict_is_empty(routing_sons)) {
     // I am no AS
     // add hosts to jedule platform
-    xbt_dynar_t table = surf_AS_get_hosts(current_comp);
+    xbt_dynar_t table = current_comp->hosts();
     xbt_dynar_t hosts;
     unsigned int dynar_cursor;
     sg_host_t host_elem;
@@ -75,9 +78,9 @@ static void create_hierarchy(AS_t current_comp, jed_simgrid_container_t current_
   } else {
     xbt_dict_foreach(routing_sons, cursor, key, elem) {
       jed_simgrid_container_t child_container;
-      jed_simgrid_create_container(&child_container, surf_AS_get_name(elem));
+      jed_simgrid_create_container(&child_container, elem->name());
       jed_simgrid_add_container(current_container, child_container);
-      XBT_DEBUG("name : %s\n", surf_AS_get_name(elem));
+      XBT_DEBUG("name : %s\n", elem->name());
       create_hierarchy(elem, child_container);
     }
   }
@@ -85,16 +88,13 @@ static void create_hierarchy(AS_t current_comp, jed_simgrid_container_t current_
 
 void jedule_setup_platform()
 {
-  AS_t root_comp;
-
-  jed_simgrid_container_t root_container;
-
   jed_create_jedule(&jedule);
 
-  root_comp = surf_AS_get_routing_root();
-  XBT_DEBUG("root name %s\n", surf_AS_get_name(root_comp));
+  AS_t root_comp = simgrid::s4u::Engine::instance()->rootAs();
+  XBT_DEBUG("root name %s\n", root_comp->name());
 
-  jed_simgrid_create_container(&root_container, surf_AS_get_name(root_comp));
+  jed_simgrid_container_t root_container;
+  jed_simgrid_create_container(&root_container, root_comp->name());
   jedule->root_container = root_container;
 
   create_hierarchy(root_comp, root_container);
index 067eb5f..a3a3b47 100644 (file)
@@ -8,6 +8,9 @@
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 
+#include "simgrid/s4u/as.hpp"
+#include "simgrid/s4u/engine.hpp"
+
 #ifdef HAVE_LUA
 #include <lua.h>
 #include <lauxlib.h>
@@ -48,20 +51,19 @@ void MSG_post_create_environment(void) {
 }
 
 msg_as_t MSG_environment_get_routing_root() {
-  return surf_AS_get_routing_root();
+  return simgrid::s4u::Engine::instance()->rootAs();
 }
 
 const char *MSG_environment_as_get_name(msg_as_t as) {
-  return surf_AS_get_name(as);
+  return as->name();
 }
 
 msg_as_t MSG_environment_as_get_by_name(const char * name) {
-  return surf_AS_get_by_name(name);
+  return simgrid::s4u::Engine::instance()->asByNameOrNull(name);
 }
 
 xbt_dict_t MSG_environment_as_get_routing_sons(msg_as_t as) {
-  xbt_dict_t res = surf_AS_get_children(as);
-  return res;
+  return as->children();
 }
 
 const char *MSG_environment_as_get_property_value(msg_as_t as, const char *name)
@@ -73,5 +75,5 @@ const char *MSG_environment_as_get_property_value(msg_as_t as, const char *name)
 }
 
 xbt_dynar_t MSG_environment_as_get_hosts(msg_as_t as) {
-  return surf_AS_get_hosts(as);
+  return as->hosts();
 }
index ce3cc47..fdba03e 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "simgrid/simix.h"
 #include "mc/mc.h"
+#include "simgrid/s4u/as.hpp"
 #include "simgrid/s4u/engine.hpp"
 
 XBT_LOG_NEW_CATEGORY(s4u,"Log channels of the S4U (Simgrid for you) interface");
@@ -28,21 +29,26 @@ s4u::Engine *s4u::Engine::instance() {
   return s4u::Engine::instance_;
 }
 
-double s4u::Engine::getClock() {
+double s4u::Engine::getClock()
+{
   return SIMIX_get_clock();
 }
 
-void s4u::Engine::loadPlatform(const char *platf) {
+void s4u::Engine::loadPlatform(const char *platf)
+{
   SIMIX_create_environment(platf);
 }
 
-void s4u::Engine::registerFunction(const char*name, int (*code)(int,char**)) {
+void s4u::Engine::registerFunction(const char*name, int (*code)(int,char**))
+{
   SIMIX_function_register(name,code);
 }
-void s4u::Engine::registerDefault(int (*code)(int,char**)) {
+void s4u::Engine::registerDefault(int (*code)(int,char**))
+{
   SIMIX_function_register_default(code);
 }
-void s4u::Engine::loadDeployment(const char *deploy) {
+void s4u::Engine::loadDeployment(const char *deploy)
+{
   SIMIX_launch_application(deploy);
 }
 
@@ -53,3 +59,32 @@ void s4u::Engine::run() {
     SIMIX_run();
   }
 }
+
+#include "surf/surf.h"               // routing_platf. FIXME:KILLME. SOON
+#include "src/surf/surf_routing.hpp" // routing_platf. FIXME:KILLME. SOON
+
+s4u::As *s4u::Engine::rootAs()
+{
+  return routing_platf->root_; // FIXME: get the root into the Engine directly (and kill the platf)
+}
+
+static s4u::As *asByNameRecursive(s4u::As *current, const char *name)
+{
+  if(!strcmp(current->name(), name))
+    return current;
+
+  xbt_dict_cursor_t cursor = NULL;
+  char *key;
+  AS_t elem;
+  xbt_dict_foreach(current->children(), cursor, key, elem) {
+    simgrid::s4u::As *tmp = asByNameRecursive(elem, name);
+    if (tmp != NULL )
+        return tmp;
+  }
+  return nullptr;
+}
+/** @brief Retrieve the AS of the given name (or nullptr if not found) */
+s4u::As *s4u::Engine::asByNameOrNull(const char *name) {
+  return asByNameRecursive(rootAs(),name);
+}
+
index 649f2c0..2ec7169 100644 (file)
@@ -276,6 +276,4 @@ void SD_exit(void)
   xbt_dynar_free_container(&(sd_global->return_set));
   xbt_free(sd_global);
   sd_global = NULL;
-
-  surf_exit();
 }
index 187e8ae..ae2e69a 100644 (file)
@@ -935,7 +935,6 @@ void sg_config_init(int *argc, char **argv)
     sg_config_cmd_line(argc, argv);
 
     xbt_mallocator_initialization_is_done(SIMIX_context_is_parallel());
-
   } else {
     XBT_WARN("Call to sg_config_init() after initialization ignored");
   }
index a07051b..e88b271 100644 (file)
@@ -115,7 +115,6 @@ void SIMIX_context_mod_exit(void)
 {
   delete simix_global->context_factory;
   simix_global->context_factory = nullptr;
-  xbt_dict_remove((xbt_dict_t) _sg_cfg_set,"contexts/factory");
 }
 
 void *SIMIX_context_stack_new(void)
index d53c5d2..1512a6a 100644 (file)
@@ -6,7 +6,9 @@
 
 #include "src/instr/instr_private.h"
 
-#include "src/surf/surf_routing.hpp"
+#include "simgrid/s4u/as.hpp"
+#include "simgrid/s4u/engine.hpp"
+#include "surf/surf.h"
 #include "src/surf/xml/platf_private.hpp"
 #include "xbt/graph.h"
 
@@ -123,21 +125,20 @@ static void linkContainers (container_t src, container_t dst, xbt_dict_t filter)
   XBT_DEBUG ("  linkContainers %s <-> %s", src->name, dst->name);
 }
 
-static void recursiveGraphExtraction (simgrid::surf::As *rc, container_t container, xbt_dict_t filter)
+static void recursiveGraphExtraction (simgrid::s4u::As *as, container_t container, xbt_dict_t filter)
 {
   if (!TRACE_platform_topology()){
     XBT_DEBUG("Graph extraction disabled by user.");
     return;
   }
-  XBT_DEBUG ("Graph extraction for routing_component = %s", rc->name_);
-  if (!xbt_dict_is_empty(rc->children_)){
+  XBT_DEBUG ("Graph extraction for routing_component = %s", as->name());
+  if (!xbt_dict_is_empty(as->children())){
     xbt_dict_cursor_t cursor = NULL;
     AS_t rc_son;
     char *child_name;
     //bottom-up recursion
-    xbt_dict_foreach(surf_AS_get_children(rc), cursor, child_name, rc_son) {
-      container_t child_container = (container_t) xbt_dict_get (
-        container->children, surf_AS_get_name(rc_son));
+    xbt_dict_foreach(as->children(), cursor, child_name, rc_son) {
+      container_t child_container = (container_t) xbt_dict_get (container->children, rc_son->name());
       recursiveGraphExtraction (rc_son, child_container, filter);
     }
   }
@@ -151,7 +152,7 @@ static void recursiveGraphExtraction (simgrid::surf::As *rc, container_t contain
     xbt_dict_cursor_t cursor = NULL;
     char *edge_name;
 
-    surf_AS_get_graph(rc, graph, nodes, edges);
+    as->getGraph(graph, nodes, edges);
     xbt_dict_foreach(edges,cursor,edge_name,edge) {
         linkContainers(
           PJ_container_get((const char*) edge->src->data),
@@ -331,7 +332,7 @@ static void instr_routing_parse_end_platform ()
   currentContainer = NULL;
   xbt_dict_t filter = xbt_dict_new_homogeneous(xbt_free_f);
   XBT_DEBUG ("Starting graph extraction.");
-  recursiveGraphExtraction (surf_AS_get_routing_root(), PJ_container_get_root(), filter);
+  recursiveGraphExtraction (simgrid::s4u::Engine::instance()->rootAs(), PJ_container_get_root(), filter);
   XBT_DEBUG ("Graph extraction finished.");
   xbt_dict_free(&filter);
   platform_created = 1;
@@ -444,21 +445,21 @@ int instr_platform_traced ()
 
 
 static void recursiveXBTGraphExtraction (xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges,
-    AS_t rc, container_t container)
+    AS_t as, container_t container)
 {
-  if (!xbt_dict_is_empty(surf_AS_get_children(rc))){
+  if (!xbt_dict_is_empty(as->children())){
     xbt_dict_cursor_t cursor = NULL;
-    AS_t rc_son;
+    AS_t as_child;
     char *child_name;
     //bottom-up recursion
-    xbt_dict_foreach(surf_AS_get_children(rc), cursor, child_name, rc_son) {
+    xbt_dict_foreach(as->children(), cursor, child_name, as_child) {
       container_t child_container = (container_t) xbt_dict_get (
-        container->children, surf_AS_get_name(rc_son));
-      recursiveXBTGraphExtraction (graph, nodes, edges, rc_son, child_container);
+        container->children, as_child->name());
+      recursiveXBTGraphExtraction (graph, nodes, edges, as_child, child_container);
     }
   }
 
-  surf_AS_get_graph(rc, graph, nodes, edges);
+  as->getGraph(graph, nodes, edges);
 }
 
 xbt_graph_t instr_routing_platform_graph (void)
@@ -466,7 +467,7 @@ xbt_graph_t instr_routing_platform_graph (void)
   xbt_graph_t ret = xbt_graph_new_graph (0, NULL);
   xbt_dict_t nodes = xbt_dict_new_homogeneous(NULL);
   xbt_dict_t edges = xbt_dict_new_homogeneous(NULL);
-  recursiveXBTGraphExtraction (ret, nodes, edges, surf_AS_get_routing_root(), PJ_container_get_root());
+  recursiveXBTGraphExtraction (ret, nodes, edges, simgrid::s4u::Engine::instance()->rootAs(), PJ_container_get_root());
   xbt_dict_free (&nodes);
   xbt_dict_free (&edges);
   return ret;
index c20f3c9..ea21715 100644 (file)
@@ -11,6 +11,8 @@
 #include "simgrid/sg_config.h"
 #include "src/instr/instr_private.h" // TRACE_is_enabled(). FIXME: remove by subscribing tracing to the surf signals
 
+#include "simgrid/s4u/as.hpp"
+
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ns3);
 
 int NS3_EXTENSION_ID;
@@ -55,9 +57,9 @@ static void simgrid_ns3_add_router(simgrid::surf::NetCard* router)
     );
 }
 
-static void parse_ns3_add_AS(simgrid::surf::As* as)
+static void parse_ns3_add_AS(simgrid::s4u::As* as)
 {
-  const char* as_id = as->name_;
+  const char* as_id = as->name();
   XBT_DEBUG("NS3_ADD_AS '%s'", as_id);
   xbt_lib_set(as_router_lib, as_id, NS3_ASR_LEVEL, ns3_add_AS(as_id) );
 }
index e3f704f..8e4a5a3 100644 (file)
@@ -62,9 +62,9 @@ void sg_platf_new_host(sg_platf_host_cbarg_t host)
   xbt_assert(! sg_host_by_name(host->id),
       "Refusing to create a second host named '%s'.", host->id);
 
-  simgrid::surf::As* current_routing = routing_get_current();
-  if (current_routing->hierarchy_ == SURF_ROUTING_NULL)
-    current_routing->hierarchy_ = SURF_ROUTING_BASE;
+  simgrid::s4u::As* current_routing = routing_get_current();
+  if (current_routing->hierarchy_ == simgrid::s4u::As::ROUTING_NULL)
+    current_routing->hierarchy_ = simgrid::s4u::As::ROUTING_BASE;
 
   simgrid::surf::NetCard *netcard =
       new simgrid::surf::NetCardImpl(host->id, SURF_NETWORK_ELEMENT_HOST, current_routing);
@@ -120,10 +120,10 @@ void sg_platf_new_host(sg_platf_host_cbarg_t host)
  */
 void sg_platf_new_router(sg_platf_router_cbarg_t router)
 {
-  simgrid::surf::As* current_routing = routing_get_current();
+  simgrid::s4u::As* current_routing = routing_get_current();
 
-  if (current_routing->hierarchy_ == SURF_ROUTING_NULL)
-    current_routing->hierarchy_ = SURF_ROUTING_BASE;
+  if (current_routing->hierarchy_ == simgrid::s4u::As::ROUTING_NULL)
+    current_routing->hierarchy_ = simgrid::s4u::As::ROUTING_BASE;
   xbt_assert(nullptr == xbt_lib_get_or_null(as_router_lib, router->id, ROUTING_ASR_LEVEL),
              "Refusing to create a router named '%s': this name already describes a node.", router->id);
 
@@ -202,7 +202,7 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster)
 
   // What an inventive way of initializing the AS that I have as ancestor :-(
   sg_platf_new_AS_begin(&AS);
-  simgrid::surf::As *current_routing = routing_get_current();
+  simgrid::s4u::As *current_routing = routing_get_current();
   static_cast<AsCluster*>(current_routing)->parse_specific_arguments(cluster);
 
   if(cluster->loopback_bw!=0 || cluster->loopback_lat!=0){
@@ -310,8 +310,7 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster)
         info_loop.link_up   = Link::byName(tmp_link);
         info_loop.link_down = info_loop.link_up;
         free(tmp_link);
-        xbt_dynar_set(current_routing->upDownLinks,
-          rankId*(static_cast<AsCluster*>(current_routing))->nb_links_per_node_, &info_loop);
+        xbt_dynar_set(current_routing->upDownLinks, rankId*(static_cast<AsCluster*>(current_routing))->nb_links_per_node_, &info_loop);
       }
 
       //add a limiter link (shared link to account for maximal bandwidth of the node)
@@ -331,9 +330,7 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster)
         info_lim.link_down = info_lim.link_up;
         free(tmp_link);
         auto as_cluster = static_cast<AsCluster*>(current_routing);
-        xbt_dynar_set(current_routing->upDownLinks,
-            rankId*(as_cluster)->nb_links_per_node_ + as_cluster->has_loopback_ ,
-            &info_lim);
+        xbt_dynar_set(current_routing->upDownLinks, rankId*(as_cluster)->nb_links_per_node_ + as_cluster->has_loopback_ , &info_lim);
 
       }
 
index 8cef095..e1424f4 100644 (file)
@@ -266,6 +266,9 @@ void sg_version(int *ver_major,int *ver_minor,int *ver_patch) {
 
 void surf_init(int *argc, char **argv)
 {
+  if (host_list != nullptr) // Already initialized
+    return;
+
   XBT_DEBUG("Create all Libs");
   host_list = xbt_dict_new_homogeneous([](void*p) {
     simgrid::s4u::Host* host = static_cast<simgrid::s4u::Host*>(p);
index e427e58..2d74f70 100644 (file)
@@ -45,12 +45,6 @@ XBT_PRIVATE int __surf_is_absolute_file_path(const char *file_path);
  * Routing logic
  */
 
-/* This enum used in the routing structure helps knowing in which situation we are. */
-typedef enum {
-  SURF_ROUTING_NULL = 0,   /**< Undefined type                                   */
-  SURF_ROUTING_BASE,       /**< Base case: use simple link lists for routing     */
-  SURF_ROUTING_RECURSIVE   /**< Recursive case: also return gateway informations */
-} e_surf_routing_hierarchy_t;
 extern XBT_PRIVATE simgrid::trace_mgr::future_evt_set *future_evt_set;
 
 
index eef8fe4..4cd3d07 100644 (file)
@@ -27,212 +27,16 @@ namespace surf {
 
   /* Callbacks */
   simgrid::xbt::signal<void(simgrid::surf::NetCard*)> netcardCreatedCallbacks;
-  simgrid::xbt::signal<void(simgrid::surf::As*)> asCreatedCallbacks;
-
-  As::As(const char*name)
-  : name_(xbt_strdup(name))
-  {}
-  As::~As()
-  {
-    xbt_dict_cursor_t cursor = NULL;
-    char *key;
-    AS_t elem;
-    xbt_dict_foreach(children_, cursor, key, elem) {
-      delete (As*)elem;
-    }
-
-
-    xbt_dict_free(&children_);
-    xbt_dynar_free(&vertices_);
-    xbt_dynar_free(&upDownLinks);
-    for (auto &kv : bypassRoutes_)
-      delete kv.second;
-    xbt_free(name_);
-    delete netcard_;
-  }
-  void As::Seal()
-  {
-    sealed_ = true;
-  }
-
-  /** @brief Get the common ancestor and its first childs in each line leading to src and dst */
-  static void find_common_ancestors(NetCard *src, NetCard *dst,
-      /* OUT */ As **common_ancestor, As **src_ancestor, As **dst_ancestor)
-  {
-  #define ROUTING_HIERARCHY_MAXDEPTH 32     /* increase if it is not enough */
-    simgrid::surf::As *path_src[ROUTING_HIERARCHY_MAXDEPTH];
-    simgrid::surf::As *path_dst[ROUTING_HIERARCHY_MAXDEPTH];
-    int index_src = 0;
-    int index_dst = 0;
-    simgrid::surf::As *current_src;
-    simgrid::surf::As *current_dst;
-    simgrid::surf::As *father;
-
-    /* (1) find the path to root of src and dst*/
-    simgrid::surf::As *src_as = src->containingAS();
-    simgrid::surf::As *dst_as = dst->containingAS();
-
-    xbt_assert(src_as, "Host %s must be in an AS", src->name());
-    xbt_assert(dst_as, "Host %s must be in an AS", dst->name());
-
-    /* (2) find the path to the root routing component */
-    for (simgrid::surf::As *current = src_as; current != NULL; current = current->father_) {
-      xbt_assert(index_src < ROUTING_HIERARCHY_MAXDEPTH, "ROUTING_HIERARCHY_MAXDEPTH should be increased for element %s", src->name());
-      path_src[index_src++] = current;
-    }
-    for (simgrid::surf::As *current = dst_as; current != NULL; current = current->father_) {
-      xbt_assert(index_dst < ROUTING_HIERARCHY_MAXDEPTH,"ROUTING_HIERARCHY_MAXDEPTH should be increased for path_dst");
-      path_dst[index_dst++] = current;
-    }
-
-    /* (3) find the common father.
-     * Before that, index_src and index_dst may be different, they both point to NULL in path_src/path_dst
-     * So we move them down simultaneously as long as they point to the same content.
-     */
-    do {
-      current_src = path_src[--index_src];
-      current_dst = path_dst[--index_dst];
-    } while (index_src > 0 && index_dst > 0 && current_src == current_dst);
-
-    /* (4) if we did not find a difference (index_src or index_dst went to 0), both elements are in the same AS */
-    if (current_src == current_dst)
-      father = current_src;
-    else // we found a difference
-      father = path_src[index_src + 1];
-
-    /* (5) result generation */
-    *common_ancestor = father;    /* the common father of src and dst */
-    *src_ancestor = current_src;  /* the first different father of src */
-    *dst_ancestor = current_dst;  /* the first different father of dst */
-  #undef ROUTING_HIERARCHY_MAXDEPTH
-  }
+  simgrid::xbt::signal<void(simgrid::s4u::As*)> asCreatedCallbacks;
 
 
-  xbt_dynar_t As::getOneLinkRoutes() {
-    return NULL;
-  }
-
-  int As::addComponent(NetCard *elm) {
-    xbt_dynar_push_as(vertices_, NetCard*, elm);
-    return xbt_dynar_length(vertices_)-1;
-  }
-
-  void As::addRoute(sg_platf_route_cbarg_t /*route*/){
-    xbt_die("AS %s does not accept new routes (wrong class).",name_);
-  }
-
-  /* PRECONDITION: this is the common ancestor of src and dst */
-  std::vector<Link*> *As::getBypassRoute(NetCard *src, NetCard *dst)
-  {
-    // If never set a bypass route return NULL without any further computations
-    XBT_DEBUG("generic_get_bypassroute from %s to %s", src->name(), dst->name());
-    if (bypassRoutes_.empty())
-      return nullptr;
-
-    std::vector<Link*> *bypassedRoute = nullptr;
-
-    if(dst->containingAS() == this && src->containingAS() == this ){
-      if (bypassRoutes_.find({src->name(),dst->name()}) != bypassRoutes_.end()) {
-        bypassedRoute = bypassRoutes_.at({src->name(),dst->name()});
-        XBT_DEBUG("Found a bypass route with %zu links",bypassedRoute->size());
-      }
-      return bypassedRoute;
-    }
-
-    /* (2) find the path to the root routing component */
-    std::vector<As*> path_src;
-    As *current = src->containingAS();
-    while (current != NULL) {
-      path_src.push_back(current);
-      current = current->father_;
-    }
-
-    std::vector<As*> path_dst;
-    current = dst->containingAS();
-    while (current != NULL) {
-      path_dst.push_back(current);
-      current = current->father_;
-    }
-
-    /* (3) find the common father */
-    while (path_src.size() > 1 && path_dst.size() >1
-        && path_src.at(path_src.size() -1) == path_dst.at(path_dst.size() -1)) {
-      path_src.pop_back();
-      path_dst.pop_back();
-    }
-
-    int max_index_src = path_src.size() - 1;
-    int max_index_dst = path_dst.size() - 1;
-
-    int max_index = std::max(max_index_src, max_index_dst);
-
-    for (int max = 0; max <= max_index; max++) {
-      for (int i = 0; i < max; i++) {
-        if (i <= max_index_src && max <= max_index_dst) {
-          const std::pair<std::string, std::string> key = {path_src.at(i)->name_, path_dst.at(max)->name_};
-          if (bypassRoutes_.find(key) != bypassRoutes_.end())
-            bypassedRoute = bypassRoutes_.at(key);
-        }
-        if (bypassedRoute)
-          break;
-        if (max <= max_index_src && i <= max_index_dst) {
-          const std::pair<std::string, std::string> key = {path_src.at(max)->name_, path_dst.at(i)->name_};
-          if (bypassRoutes_.find(key) != bypassRoutes_.end())
-            bypassedRoute = bypassRoutes_.at(key);
-        }
-        if (bypassedRoute)
-          break;
-      }
-
-      if (bypassedRoute)
-        break;
-
-      if (max <= max_index_src && max <= max_index_dst) {
-        const std::pair<std::string, std::string> key = {path_src.at(max)->name_, path_dst.at(max)->name_};
-        if (bypassRoutes_.find(key) != bypassRoutes_.end())
-          bypassedRoute = bypassRoutes_.at(key);
-      }
-      if (bypassedRoute)
-        break;
-    }
-
-    return bypassedRoute;
-  }
-
-  void As::addBypassRoute(sg_platf_route_cbarg_t e_route){
-    const char *src = e_route->src;
-    const char *dst = e_route->dst;
-
-    /* Argument validity checks */
-    if (e_route->gw_dst) {
-      XBT_DEBUG("Load bypassASroute from %s@%s to %s@%s",
-          src, e_route->gw_src->name(), dst, e_route->gw_dst->name());
-      xbt_assert(!e_route->link_list->empty(), "Bypass route between %s@%s and %s@%s cannot be empty.",
-          src, e_route->gw_src->name(), dst, e_route->gw_dst->name());
-      xbt_assert(bypassRoutes_.find({src,dst}) == bypassRoutes_.end(), "The bypass route between %s@%s and %s@%s already exists.",
-          src, e_route->gw_src->name(), dst, e_route->gw_dst->name());
-    } else {
-      XBT_DEBUG("Load bypassRoute from %s to %s", src, dst);
-      xbt_assert(!e_route->link_list->empty(),                         "Bypass route between %s and %s cannot be empty.",    src, dst);
-      xbt_assert(bypassRoutes_.find({src,dst}) == bypassRoutes_.end(), "The bypass route between %s and %s already exists.", src, dst);
-    }
-
-    /* Build a copy that will be stored in the dict */
-    std::vector<Link*> *newRoute = new std::vector<Link*>();
-    for (auto link: *e_route->link_list)
-      newRoute->push_back(link);
-
-    /* Store it */
-    bypassRoutes_.insert({{src,dst}, newRoute});
-  }
-
 }} // namespace simgrid::surf
 
 /**
  * @ingroup SURF_build_api
  * @brief A library containing all known hosts
  */
-xbt_dict_t host_list;
+xbt_dict_t host_list = nullptr;
 
 int COORD_HOST_LEVEL=0;         //Coordinates level
 
@@ -265,8 +69,8 @@ simgrid::surf::RoutingPlatf *routing_platf = NULL;
 
 
 /** The current AS in the parsing */
-static simgrid::surf::As *current_routing = NULL;
-simgrid::surf::As* routing_get_current()
+static simgrid::s4u::As *current_routing = NULL;
+simgrid::s4u::As* routing_get_current()
 {
   return current_routing;
 }
@@ -334,7 +138,7 @@ void routing_AS_begin(sg_platf_AS_cbarg_t AS)
 
 
   /* search the routing model */
-  simgrid::surf::As *new_as = NULL;
+  simgrid::s4u::As *new_as = NULL;
   switch(AS->routing){
     case A_surfxml_AS_routing_Cluster:        new_as = new simgrid::surf::AsCluster(AS->id);        break;
     case A_surfxml_AS_routing_ClusterTorus:   new_as = new simgrid::surf::AsClusterTorus(AS->id);   break;
@@ -349,24 +153,23 @@ void routing_AS_begin(sg_platf_AS_cbarg_t AS)
   }
 
   /* make a new routing component */
-  simgrid::surf::NetCard *netcard = new simgrid::surf::NetCardImpl(new_as->name_, SURF_NETWORK_ELEMENT_AS, current_routing);
+  simgrid::surf::NetCard *netcard = new simgrid::surf::NetCardImpl(new_as->name(), SURF_NETWORK_ELEMENT_AS, current_routing);
 
   if (current_routing == NULL && routing_platf->root_ == NULL) {
     /* it is the first one */
-    new_as->father_ = NULL;
     routing_platf->root_ = new_as;
     netcard->setId(-1);
   } else if (current_routing != NULL && routing_platf->root_ != NULL) {
 
-    xbt_assert(!xbt_dict_get_or_null(current_routing->children_, AS->id),
+    xbt_assert(!xbt_dict_get_or_null(current_routing->children(), AS->id),
                "The AS \"%s\" already exists", AS->id);
     /* it is a part of the tree */
     new_as->father_ = current_routing;
     /* set the father behavior */
-    if (current_routing->hierarchy_ == SURF_ROUTING_NULL)
-      current_routing->hierarchy_ = SURF_ROUTING_RECURSIVE;
+    if (current_routing->hierarchy_ == simgrid::s4u::As::ROUTING_NULL)
+      current_routing->hierarchy_ = simgrid::s4u::As::ROUTING_RECURSIVE;
     /* add to the sons dictionary */
-    xbt_dict_set(current_routing->children_, AS->id, (void *) new_as, NULL);
+    xbt_dict_set(current_routing->children(), AS->id, (void *) new_as, NULL);
     /* add to the father element list */
     netcard->setId(current_routing->addComponent(netcard));
   } else {
@@ -374,7 +177,7 @@ void routing_AS_begin(sg_platf_AS_cbarg_t AS)
   }
 
   xbt_lib_set(as_router_lib, netcard->name(), ROUTING_ASR_LEVEL, (void *) netcard);
-  XBT_DEBUG("Having set name '%s' id '%d'", new_as->name_, netcard->id());
+  XBT_DEBUG("Having set name '%s' id '%d'", new_as->name(), netcard->id());
 
   /* set the new current component of the tree */
   current_routing = new_as;
@@ -394,72 +197,12 @@ void routing_AS_end()
 {
   xbt_assert(current_routing, "Cannot seal the current AS: none under construction");
   current_routing->Seal();
-  current_routing = current_routing->father_;
+  current_routing = current_routing->father();
 }
 
 namespace simgrid {
 namespace surf {
 
-/**
- * \brief Recursive function for getRouteAndLatency
- *
- * \param src the source host
- * \param dst the destination host
- * \param links Where to store the links and the gw information
- * \param latency If not NULL, the latency of all links will be added in it
- */
-void As::getRouteRecursive(NetCard *src, NetCard *dst,
-    /* OUT */ std::vector<Link*> * links, double *latency)
-{
-  s_sg_platf_route_cbarg_t route;
-  memset(&route,0,sizeof(route));
-
-  XBT_DEBUG("Solve route/latency \"%s\" to \"%s\"", src->name(), dst->name());
-
-  /* Find how src and dst are interconnected */
-  simgrid::surf::As *common_ancestor, *src_ancestor, *dst_ancestor;
-  find_common_ancestors(src, dst, &common_ancestor, &src_ancestor, &dst_ancestor);
-  XBT_DEBUG("elements_father: common ancestor '%s' src ancestor '%s' dst ancestor '%s'",
-      common_ancestor->name_, src_ancestor->name_, dst_ancestor->name_);
-
-  /* Check whether a direct bypass is defined. If so, use it and bail out */
-  std::vector<Link*> *bypassed_route = common_ancestor->getBypassRoute(src, dst);
-  if (nullptr != bypassed_route) {
-    for (Link *link : *bypassed_route) {
-      links->push_back(link);
-      if (latency)
-        *latency += link->getLatency();
-    }
-    return;
-  }
-
-  /* If src and dst are in the same AS, life is good */
-  if (src_ancestor == dst_ancestor) {       /* SURF_ROUTING_BASE */
-    route.link_list = links;
-    common_ancestor->getRouteAndLatency(src, dst, &route, latency);
-    return;
-  }
-
-  /* Not in the same AS, no bypass. We'll have to find our path between the ASes recursively*/
-
-  route.link_list = new std::vector<Link*>();
-
-  common_ancestor->getRouteAndLatency(src_ancestor->netcard_, dst_ancestor->netcard_, &route, latency);
-  xbt_assert((route.gw_src != NULL) && (route.gw_dst != NULL),
-      "bad gateways for route from \"%s\" to \"%s\"", src->name(), dst->name());
-
-  /* If source gateway is not our source, we have to recursively find our way up to this point */
-  if (src != route.gw_src)
-    getRouteRecursive(src, route.gw_src, links, latency);
-  for (auto link: *route.link_list)
-    links->push_back(link);
-
-  /* If dest gateway is not our destination, we have to recursively find our way from this point */
-  if (route.gw_dst != dst)
-    getRouteRecursive(route.gw_dst, dst, links, latency);
-
-}
-
 /**
  * \brief Find a route between hosts
  *
@@ -478,15 +221,15 @@ void RoutingPlatf::getRouteAndLatency(NetCard *src, NetCard *dst, std::vector<Li
 {
   XBT_DEBUG("getRouteAndLatency from %s to %s", src->name(), dst->name());
 
-  As::getRouteRecursive(src, dst, route, latency);
+  s4u::As::getRouteRecursive(src, dst, route, latency);
 }
 
-static xbt_dynar_t _recursiveGetOneLinkRoutes(As *rc)
+static xbt_dynar_t _recursiveGetOneLinkRoutes(s4u::As *as)
 {
   xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f);
 
   //adding my one link routes
-  xbt_dynar_t onelink_mine = rc->getOneLinkRoutes();
+  xbt_dynar_t onelink_mine = as->getOneLinkRoutes();
   if (onelink_mine)
     xbt_dynar_merge(&ret,&onelink_mine);
 
@@ -494,7 +237,7 @@ static xbt_dynar_t _recursiveGetOneLinkRoutes(As *rc)
   char *key;
   xbt_dict_cursor_t cursor = NULL;
   AS_t rc_child;
-  xbt_dict_foreach(rc->children_, cursor, key, rc_child) {
+  xbt_dict_foreach(as->children(), cursor, key, rc_child) {
     xbt_dynar_t onelink_child = _recursiveGetOneLinkRoutes(rc_child);
     if (onelink_child)
       xbt_dynar_merge(&ret,&onelink_child);
@@ -522,10 +265,10 @@ void routing_cluster_add_backbone(simgrid::surf::Link* bb) {
   simgrid::surf::AsCluster *cluster = dynamic_cast<simgrid::surf::AsCluster*>(current_routing);
 
   xbt_assert(cluster, "Only hosts from Cluster can get a backbone.");
-  xbt_assert(nullptr == cluster->backbone_, "Cluster %s already has a backbone link!", cluster->name_);
+  xbt_assert(nullptr == cluster->backbone_, "Cluster %s already has a backbone link!", cluster->name());
 
   cluster->backbone_ = bb;
-  XBT_DEBUG("Add a backbone to AS '%s'", current_routing->name_);
+  XBT_DEBUG("Add a backbone to AS '%s'", current_routing->name());
 }
 
 void sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet)
@@ -707,77 +450,11 @@ void routing_exit(void) {
   delete routing_platf;
 }
 
-namespace simgrid {
-namespace surf {
-
-  RoutingPlatf::RoutingPlatf(Link *loopback)
-  : loopback_(loopback)
-  {
-  }
-  RoutingPlatf::~RoutingPlatf()
-  {
-    delete root_;
-  }
-
-}
-}
-
-AS_t surf_AS_get_routing_root() {
-  return routing_platf->root_;
-}
-
-const char *surf_AS_get_name(simgrid::surf::As *as) {
-  return as->name_;
-}
-
-static simgrid::surf::As *surf_AS_recursive_get_by_name(simgrid::surf::As *current, const char * name)
+simgrid::surf::RoutingPlatf::RoutingPlatf(simgrid::surf::Link *loopback)
+: loopback_(loopback)
 {
-  xbt_dict_cursor_t cursor = NULL;
-  char *key;
-  AS_t elem;
-  simgrid::surf::As *tmp = NULL;
-
-  if(!strcmp(current->name_, name))
-    return current;
-
-  xbt_dict_foreach(current->children_, cursor, key, elem) {
-    tmp = surf_AS_recursive_get_by_name(elem, name);
-    if(tmp != NULL ) {
-        break;
-    }
-  }
-  return tmp;
 }
-
-simgrid::surf::As *surf_AS_get_by_name(const char * name)
+simgrid::surf::RoutingPlatf::~RoutingPlatf()
 {
-  simgrid::surf::As *as = surf_AS_recursive_get_by_name(routing_platf->root_, name);
-  if(as == NULL)
-    XBT_WARN("Impossible to find an AS with name %s, please check your input", name);
-  return as;
-}
-
-xbt_dict_t surf_AS_get_children(simgrid::surf::As *as)
-{
-  return as->children_;
-}
-
-xbt_dynar_t surf_AS_get_hosts(simgrid::surf::As *as)
-{
-  xbt_dynar_t elms = as->vertices_;
-  int count = xbt_dynar_length(elms);
-  xbt_dynar_t res =  xbt_dynar_new(sizeof(sg_host_t), NULL);
-  for (int index = 0; index < count; index++) {
-     sg_netcard_t relm =
-      xbt_dynar_get_as(elms, index, simgrid::surf::NetCard*);
-     sg_host_t delm = simgrid::s4u::Host::by_name_or_null(relm->name());
-     if (delm!=NULL) {
-       xbt_dynar_push(res, &delm);
-     }
-  }
-  return res;
-}
-
-void surf_AS_get_graph(AS_t as, xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) {
-  as->getGraph(graph, nodes, edges);
+  delete root_;
 }
index 6007faf..cb29f19 100644 (file)
@@ -30,7 +30,6 @@ namespace surf {
  * Classes *
  ***********/
 
-class As;
 class XBT_PRIVATE RoutingModelDescription;
 class XBT_PRIVATE Onelink;
 class RoutingPlatf;
@@ -46,80 +45,15 @@ public:
   virtual int id()=0; // Our rank in the vertices_ array of our containing AS.
   virtual void setId(int id)=0;
   virtual char *name()=0;
-  virtual As *containingAS()=0; // This is the AS in which I am
+  virtual s4u::As *containingAS()=0; // This is the AS in which I am
   virtual bool isAS()=0;
   virtual bool isHost()=0;
   virtual bool isRouter()=0;
 };
 
-/** @ingroup SURF_routing_interface
- * @brief Network Autonomous System (AS)
- */
-class As {
-public:
-  As(const char*name);
-  /** @brief Close that AS: no more content can be added to it */
-  virtual void Seal();
-  virtual ~As();
-
-  e_surf_routing_hierarchy_t hierarchy_ = SURF_ROUTING_NULL;
-  xbt_dynar_t upDownLinks = xbt_dynar_new(sizeof(s_surf_parsing_link_up_down_t),NULL);
-
-  char *name_ = nullptr;
-  NetCard *netcard_ = nullptr; // Our representative in the father AS
-  As *father_ = nullptr;
-  xbt_dict_t children_ = xbt_dict_new_homogeneous(NULL); // sub-ASes
-  xbt_dynar_t vertices_ = xbt_dynar_new(sizeof(char*),NULL); // our content, as known to our graph routing algorithm (maps vertexId -> vertex)
-
-private:
-  bool sealed_ = false; // We cannot add more content when sealed
-
-  friend RoutingPlatf;
-  std::map<std::pair<std::string, std::string>, std::vector<Link*>*> bypassRoutes_; // srcName x dstName -> route
-  static void getRouteRecursive(NetCard *src, NetCard *dst, /* OUT */ std::vector<Link*> * links, double *latency);
-  std::vector<Link*> *getBypassRoute(NetCard *src, NetCard *dst);
-
-public:
-  /**
-   * @brief Probe the routing path between two points
-   *
-   * The networking model uses this function when creating a communication
-   * to retrieve both the list of links that the create communication will use,
-   * and the summed latency that these links represent.
-   *
-   * The network could recompute the latency by itself from the list, but it would
-   * require an additional link set traversal. This operation being on the critical
-   * path of SimGrid, the routing computes the latency in behalf of the network.
-   *
-   * Things are rather complex here because we have to find the path from ASes to ASes, and within each.
-   * In addition, the different ASes may use differing routing models.
-   * Some ASes may be routed in full, others may have only some connection information and use a shortest path on top of that, and so on.
-   * Some ASes may even not have any predefined links and use only coordinate informations to compute the latency.
-   *
-   * So, the path is constructed recursively, with each traversed AS adding its information to the set.
-   * The algorithm for that is explained in http://hal.inria.fr/hal-00650233/
-   * 
-   * @param src Initial point of the routing path
-   * @param dst Final point of the routing path
-   * @param into Container into which the traversed links should be pushed
-   * @param latency Accumulator in which the latencies should be added (caller must set it to 0)
-   */
-  virtual void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency)=0;
-  /** @brief retrieves the list of all routes of size 1 (of type src x dst x Link) */
-  virtual xbt_dynar_t getOneLinkRoutes();
-
-  virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)=0;
-
-  /* Add content to the AS, at parsing time. It should be sealed afterward. */
-  virtual int addComponent(NetCard *elm); /* A host, a router or an AS, whatever */
-  virtual void addRoute(sg_platf_route_cbarg_t route);
-  void addBypassRoute(sg_platf_route_cbarg_t e_route);
-
-};
-
 struct XBT_PRIVATE NetCardImpl : public NetCard {
 public:
-  NetCardImpl(const char *name, e_surf_network_element_type_t componentType, As *as)
+  NetCardImpl(const char *name, e_surf_network_element_type_t componentType, s4u::As *as)
   : name_(xbt_strdup(name)),
     componentType_(componentType),
     containingAS_(as)
@@ -129,7 +63,7 @@ public:
   int id()           override {return id_;}
   void setId(int id) override {id_ = id;}
   char *name()       override {return name_;}
-  As *containingAS() override {return containingAS_;}
+  s4u::As *containingAS() override {return containingAS_;}
 
   bool isAS()        override {return componentType_ == SURF_NETWORK_ELEMENT_AS;}
   bool isHost()      override {return componentType_ == SURF_NETWORK_ELEMENT_HOST;}
@@ -139,7 +73,7 @@ private:
   int id_ = -1;
   char *name_;
   e_surf_network_element_type_t componentType_;
-  As *containingAS_;
+  s4u::As *containingAS_;
 };
 
 /** @ingroup SURF_routing_interface
@@ -161,7 +95,7 @@ XBT_PUBLIC_CLASS RoutingPlatf {
 public:
   RoutingPlatf(Link *loopback);
   ~RoutingPlatf();
-  As *root_ = nullptr;
+  s4u::As *root_ = nullptr;
   Link *loopback_;
   xbt_dynar_t getOneLinkRoutes(void);
   void getRouteAndLatency(NetCard *src, NetCard *dst, std::vector<Link*> * links, double *latency);
@@ -172,7 +106,7 @@ public:
  *************/
 
 XBT_PUBLIC_DATA(simgrid::xbt::signal<void(NetCard*)>) netcardCreatedCallbacks;
-XBT_PUBLIC_DATA(simgrid::xbt::signal<void(As*)>) asCreatedCallbacks;
+XBT_PUBLIC_DATA(simgrid::xbt::signal<void(s4u::As*)>) asCreatedCallbacks;
 
 }
 }
index cd85779..4fe6acc 100644 (file)
@@ -108,9 +108,9 @@ namespace surf {
         if (route->link_list->size() == 1) {
           Link *link = route->link_list->at(0);
           Onelink *onelink;
-          if (hierarchy_ == SURF_ROUTING_BASE)
+          if (hierarchy_ == s4u::As::ROUTING_BASE)
             onelink = new Onelink(link, src_elm, dst_elm);
-          else if (hierarchy_ == SURF_ROUTING_RECURSIVE)
+          else if (hierarchy_ == s4u::As::ROUTING_RECURSIVE)
             onelink = new Onelink(link, route->gw_src, route->gw_dst);
           else
             onelink = new Onelink(link, NULL, NULL);
@@ -184,7 +184,7 @@ void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edg
 /* ************************************************************************** */
 /* ************************* GENERIC AUX FUNCTIONS ************************** */
 /* change a route containing link names into a route containing link entities */
-sg_platf_route_cbarg_t AsRoutedGraph::newExtendedRoute(e_surf_routing_hierarchy_t hierarchy,
+sg_platf_route_cbarg_t AsRoutedGraph::newExtendedRoute(s4u::As::RoutingKind hierarchy,
     sg_platf_route_cbarg_t routearg, int change_order)
 {
 
@@ -193,15 +193,12 @@ sg_platf_route_cbarg_t AsRoutedGraph::newExtendedRoute(e_surf_routing_hierarchy_
   result = xbt_new0(s_sg_platf_route_cbarg_t, 1);
   result->link_list = new std::vector<Link*>();
 
-  xbt_assert(hierarchy == SURF_ROUTING_BASE
-      || hierarchy == SURF_ROUTING_RECURSIVE,
+  xbt_assert(hierarchy == s4u::As::ROUTING_BASE || hierarchy == s4u::As::ROUTING_RECURSIVE,
       "The hierarchy of this AS is neither BASIC nor RECURSIVE, I'm lost here.");
 
-  if (hierarchy == SURF_ROUTING_RECURSIVE) {
-
+  if (hierarchy == s4u::As::ROUTING_RECURSIVE) {
     xbt_assert(routearg->gw_src && routearg->gw_dst, "NULL is obviously a deficient gateway");
 
-    /* remember not erase the gateway names */
     result->gw_src = routearg->gw_src;
     result->gw_dst = routearg->gw_dst;
   }
@@ -225,11 +222,11 @@ void AsRoutedGraph::getRouteCheckParams(NetCard *src, NetCard *dst)
   As *dst_as = dst->containingAS();
 
   xbt_assert(src_as == dst_as, "Internal error: %s@%s and %s@%s are not in the same AS as expected. Please report that bug.",
-        src->name(), src_as->name_, dst->name(), dst_as->name_);
+        src->name(), src_as->name(), dst->name(), dst_as->name());
 
   xbt_assert(this == dst_as,
       "Internal error: route destination %s@%s is not in AS %s as expected (route source: %s@%s). Please report that bug.",
-        src->name(), dst->name(),  src_as->name_, dst_as->name_,  name_);
+        src->name(), dst->name(),  src_as->name(), dst_as->name(),  name());
 }
 void AsRoutedGraph::addRouteCheckParams(sg_platf_route_cbarg_t route) {
   const char *srcName = route->src;
index 5a2feac..c21833d 100644 (file)
@@ -7,6 +7,7 @@
 #include <xbt/base.h>
 
 #include "surf_routing.hpp"
+#include "simgrid/s4u/as.hpp"
 
 #ifndef SURF_ROUTING_GENERIC_HPP_
 #define SURF_ROUTING_GENERIC_HPP_
@@ -16,7 +17,7 @@ namespace surf {
 
 class XBT_PRIVATE AsRoutedGraph;
 
-class XBT_PRIVATE AsRoutedGraph : public As {
+class XBT_PRIVATE AsRoutedGraph : public s4u::As {
 public:
   AsRoutedGraph(const char*name);
   ~AsRoutedGraph();
@@ -24,7 +25,7 @@ public:
   xbt_dynar_t getOneLinkRoutes() override;
 
   virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) override;
-  virtual sg_platf_route_cbarg_t newExtendedRoute(e_surf_routing_hierarchy_t hierarchy, sg_platf_route_cbarg_t routearg, int change_order);
+  virtual sg_platf_route_cbarg_t newExtendedRoute(s4u::As::RoutingKind hierarchy, sg_platf_route_cbarg_t routearg, int change_order);
 protected:
   void getRouteCheckParams(NetCard *src, NetCard *dst);
   void addRouteCheckParams(sg_platf_route_cbarg_t route);
index 8ea4836..b3f283a 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "surf_routing.hpp"
 #include "network_interface.hpp"
+#include "simgrid/s4u/as.hpp"
 
 namespace simgrid {
 namespace surf {
@@ -24,7 +25,7 @@ class XBT_PRIVATE AsCluster;
 /* ************************************************** */
 /* **************  Cluster ROUTING   **************** */
 
-class AsCluster: public As {
+class AsCluster: public s4u::As {
 public:
   AsCluster(const char*name);
 
index 1c5c486..1a7521e 100644 (file)
@@ -51,7 +51,7 @@ void AsDijkstra::Seal()
     graphNodeMap_ = xbt_dict_new_homogeneous(&graph_node_map_elem_free);
 
   /* Add the loopback if needed */
-  if (routing_platf->loopback_ && hierarchy_ == SURF_ROUTING_BASE) {
+  if (routing_platf->loopback_ && hierarchy_ == s4u::As::ROUTING_BASE) {
     xbt_dynar_foreach(xbt_graph_get_nodes(routeGraph_), cursor, node) {
       xbt_edge_t edge = NULL;
 
@@ -259,7 +259,7 @@ void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_c
     if (v == dst_node_id)
       first_gw = gw_dst;
 
-    if (hierarchy_ == SURF_ROUTING_RECURSIVE && v != dst_node_id && strcmp(gw_dst->name(), prev_gw_src->name())) {
+    if (hierarchy_ == s4u::As::ROUTING_RECURSIVE && v != dst_node_id && strcmp(gw_dst->name(), prev_gw_src->name())) {
       std::vector<Link*> *e_route_as_to_as = new std::vector<Link*>();
 
       routing_platf->getRouteAndLatency(gw_dst_net_elm, prev_gw_src_net_elm, e_route_as_to_as, NULL);
@@ -280,7 +280,7 @@ void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_c
     size++;
   }
 
-  if (hierarchy_ == SURF_ROUTING_RECURSIVE) {
+  if (hierarchy_ == s4u::As::ROUTING_RECURSIVE) {
     route->gw_src = gw_src;
     route->gw_dst = first_gw;
   }
index 5bfe3df..705a648 100644 (file)
@@ -57,7 +57,7 @@ void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbar
     cur = pred;
   } while (cur != src->id());
 
-  if (hierarchy_ == SURF_ROUTING_RECURSIVE) {
+  if (hierarchy_ == s4u::As::ROUTING_RECURSIVE) {
     route->gw_src = xbt_dynar_getlast_as(route_stack, sg_platf_route_cbarg_t)->gw_src;
     route->gw_dst = xbt_dynar_getfirst_as(route_stack, sg_platf_route_cbarg_t)->gw_dst;
   }
@@ -66,7 +66,7 @@ void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbar
   while (!xbt_dynar_is_empty(route_stack)) {
     sg_platf_route_cbarg_t e_route = xbt_dynar_pop_as(route_stack, sg_platf_route_cbarg_t);
 
-    if (hierarchy_ == SURF_ROUTING_RECURSIVE && prev_dst_gw != NULL && strcmp(prev_dst_gw->name(), e_route->gw_src->name())) {
+    if (hierarchy_ == s4u::As::ROUTING_RECURSIVE && prev_dst_gw != NULL && strcmp(prev_dst_gw->name(), e_route->gw_src->name())) {
       routing_platf->getRouteAndLatency(prev_dst_gw, e_route->gw_src, route->link_list, lat);
     }
 
@@ -169,7 +169,7 @@ void AsFloyd::Seal(){
   }
 
   /* Add the loopback if needed */
-  if (routing_platf->loopback_ && hierarchy_ == SURF_ROUTING_BASE) {
+  if (routing_platf->loopback_ && hierarchy_ == s4u::As::ROUTING_BASE) {
     for (unsigned int i = 0; i < table_size; i++) {
       sg_platf_route_cbarg_t e_route = TO_FLOYD_LINK(i, i);
       if (!e_route) {
index 1180fe0..35468f1 100644 (file)
@@ -30,7 +30,7 @@ void AsFull::Seal() {
     routingTable_ = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size);
 
   /* Add the loopback if needed */
-  if (routing_platf->loopback_ && hierarchy_ == SURF_ROUTING_BASE) {
+  if (routing_platf->loopback_ && hierarchy_ == s4u::As::ROUTING_BASE) {
     for (i = 0; i < table_size; i++) {
       e_route = TO_ROUTE_FULL(i, i);
       if (!e_route) {
index 16b97a4..78716e7 100644 (file)
@@ -7,6 +7,8 @@
 #include <xbt/base.h>
 
 #include "surf_routing.hpp"
+#include "simgrid/s4u/as.hpp"
+
 
 #ifndef SURF_ROUTING_NONE_HPP_
 #define SURF_ROUTING_NONE_HPP_
@@ -15,7 +17,7 @@ namespace simgrid {
 namespace surf {
 
 /** No specific routing. Mainly useful with the constant network model */
-class XBT_PRIVATE AsNone : public As {
+class XBT_PRIVATE AsNone : public s4u::As {
 public:
   AsNone(const char*name);
   ~AsNone();
index 9e99d90..3ff896b 100644 (file)
@@ -247,7 +247,7 @@ typedef struct probabilist_event_generator *probabilist_event_generator_t;
 void routing_AS_begin(sg_platf_AS_cbarg_t AS);
 void routing_AS_end(void);
 void routing_cluster_add_backbone(Link* bb);
-surf_As* routing_get_current();
+AS_t routing_get_current();
 /*** END of the parsing cruft ***/
 
 XBT_PUBLIC(void) sg_platf_begin(void);  // Start a new platform
index 67c7b4f..8062cf4 100644 (file)
@@ -384,6 +384,7 @@ endif()
 
 set(S4U_SRC
   src/s4u/s4u_actor.cpp
+  src/s4u/s4u_as.cpp
   src/s4u/s4u_async.cpp
   src/s4u/s4u_comm.cpp
   src/s4u/s4u_engine.cpp  
@@ -648,6 +649,7 @@ set(headers_to_install
   include/simgrid/link.h
   include/simgrid/s4u/forward.hpp
   include/simgrid/s4u/actor.hpp
+  include/simgrid/s4u/as.hpp
   include/simgrid/s4u/async.hpp
   include/simgrid/s4u/comm.hpp
   include/simgrid/s4u/engine.hpp