--- /dev/null
+/* Copyright (c) 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. */
+
+#ifndef SIMGRID_S4U_AS_HPP
+#define SIMGRID_S4U_AS_HPP
+
+#include "xbt/base.h"
+#include "xbt/graph.h"
+
+#include "simgrid/s4u/forward.hpp"
+#include <vector>
+#include <map>
+
+#include "src/surf/xml/platf_private.hpp" // FIXME: kill sg_platf_route_cbarg_t to remove that UGLY include
+
+namespace simgrid {
+
+namespace surf {
+ class AsImpl;
+ class Link;
+ class NetCard;
+}
+namespace s4u {
+
+/** @brief Autonomous Systems
+ *
+ * An AS is a network container, in charge of routing information between elements (hosts) and to the nearby ASes.
+ * In SimGrid, there is a hierarchy of ASes, with a unique root AS (that you can retrieve from the s4u::Engine).
+ */
+XBT_PUBLIC_CLASS As {
+protected:
+ friend simgrid::surf::AsImpl;
+
+ As(const char *name);
+ virtual ~As();
+
+public:
+ /** @brief Seal your AS once you're done adding content, and before routing stuff through it */
+ virtual void Seal();
+ char *name();
+ As *father();;
+ xbt_dict_t children(); // Sub AS
+ xbt_dynar_t hosts(); // my content
+
+ As *father_ = nullptr; // FIXME: hide me
+public:
+ /* Add content to the AS, at parsing time. It should be sealed afterward. */
+ virtual int addComponent(surf::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);
+
+protected:
+ char *name_ = 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)
+
+ std::map<std::pair<std::string, std::string>, std::vector<surf::Link*>*> bypassRoutes_; // srcName x dstName -> route
+
+private:
+ bool sealed_ = false; // We cannot add more content when sealed
+};
+
+}}; // Namespace simgrid::s4u
+
+#endif /* SIMGRID_S4U_AS_HPP */
#include "simgrid/simdag.h"
#include "src/simdag/simdag_private.h"
-#include "simgrid/s4u/as.hpp"
+#include "simgrid/s4u/As.hpp"
#include "simgrid/s4u/engine.hpp"
#include <stdio.h>
#include "xbt/sysdep.h"
#include "xbt/log.h"
-#include "simgrid/s4u/as.hpp"
+#include "simgrid/s4u/As.hpp"
#include "simgrid/s4u/engine.hpp"
#ifdef HAVE_LUA
#include "xbt/log.h"
-#include "simgrid/s4u/as.hpp"
+#include "simgrid/s4u/As.hpp"
#include "src/surf/surf_routing.hpp"
#include "src/surf/network_interface.hpp" // Link FIXME: move to proper header
xbt_dict_free(&children_);
xbt_dynar_free(&vertices_);
- xbt_dynar_free(&upDownLinks);
for (auto &kv : bypassRoutes_)
delete kv.second;
xbt_free(name_);
- delete netcard_;
}
xbt_dict_t As::children()
return res;
}
- xbt_dynar_t As::getOneLinkRoutes() {
- return NULL;
- }
-
int As::addComponent(surf::NetCard *elm) {
xbt_dynar_push_as(vertices_, surf::NetCard*, elm);
return xbt_dynar_length(vertices_)-1;
xbt_die("AS %s does not accept new routes (wrong class).",name_);
}
- /** @brief Get the common ancestor and its first childs in each line leading to src and dst */
- static void find_common_ancestors(surf::NetCard *src, surf::NetCard *dst,
- /* OUT */ As **common_ancestor, As **src_ancestor, As **dst_ancestor)
- {
- #define ROUTING_HIERARCHY_MAXDEPTH 32 /* increase if it is not enough */
- simgrid::s4u::As *path_src[ROUTING_HIERARCHY_MAXDEPTH];
- simgrid::s4u::As *path_dst[ROUTING_HIERARCHY_MAXDEPTH];
- int index_src = 0;
- int index_dst = 0;
- simgrid::s4u::As *current_src;
- simgrid::s4u::As *current_dst;
- simgrid::s4u::As *father;
-
- /* (1) find the path to root of src and dst*/
- simgrid::s4u::As *src_as = src->containingAS();
- simgrid::s4u::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::s4u::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::s4u::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
- }
-
-
- /* PRECONDITION: this is the common ancestor of src and dst */
- std::vector<surf::Link*> *As::getBypassRoute(surf::NetCard *src, surf::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<surf::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;
bypassRoutes_.insert({{src,dst}, newRoute});
}
- /**
- * \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(surf::NetCard *src, surf::NetCard *dst,
- /* OUT */ std::vector<surf::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::s4u::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<surf::Link*> *bypassed_route = common_ancestor->getBypassRoute(src, dst);
- if (nullptr != bypassed_route) {
- for (surf::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<surf::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);
-
- }
-
- }
-};
+} }; // namespace simgrid::s4u
#include "simgrid/simix.h"
#include "mc/mc.h"
-#include "simgrid/s4u/as.hpp"
+#include "simgrid/s4u/As.hpp"
#include "simgrid/s4u/engine.hpp"
XBT_LOG_NEW_CATEGORY(s4u,"Log channels of the S4U (Simgrid for you) interface");
--- /dev/null
+/* Copyright (c) 2006-2014. 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/log.h"
+
+#include "simgrid/s4u/As.hpp"
+#include "src/surf/AsImpl.hpp"
+#include "src/surf/network_interface.hpp" // Link FIXME: move to proper header
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(AsImpl,surf, "Implementation of S4U autonomous systems");
+
+namespace simgrid {
+ namespace surf {
+
+ AsImpl::AsImpl(const char *name)
+ : As(name)
+ {
+ }
+ AsImpl::~AsImpl()
+ {
+ xbt_dynar_free(&upDownLinks);
+ delete netcard_;
+ }
+
+ xbt_dynar_t AsImpl::getOneLinkRoutes() {
+ return NULL;
+ }
+
+ /** @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 */ AsImpl **common_ancestor, AsImpl **src_ancestor, AsImpl **dst_ancestor)
+ {
+ #define ROUTING_HIERARCHY_MAXDEPTH 32 /* increase if it is not enough */
+ AsImpl *path_src[ROUTING_HIERARCHY_MAXDEPTH];
+ AsImpl *path_dst[ROUTING_HIERARCHY_MAXDEPTH];
+ int index_src = 0;
+ int index_dst = 0;
+ AsImpl *current_src;
+ AsImpl *current_dst;
+ AsImpl *father;
+
+ /* (1) find the path to root of src and dst*/
+ AsImpl *src_as = src->containingAS();
+ AsImpl *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 (AsImpl *current = src_as; current != NULL; current = static_cast<AsImpl*>(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 (AsImpl *current = dst_as; current != NULL; current = static_cast<AsImpl*>(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
+ }
+
+
+ /* PRECONDITION: this is the common ancestor of src and dst */
+ std::vector<surf::Link*> *AsImpl::getBypassRoute(surf::NetCard *src, surf::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<surf::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;
+ }
+
+ /**
+ * \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 AsImpl::getRouteRecursive(surf::NetCard *src, surf::NetCard *dst,
+ /* OUT */ std::vector<surf::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 */
+ AsImpl *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<surf::Link*> *bypassed_route = common_ancestor->getBypassRoute(src, dst);
+ if (nullptr != bypassed_route) {
+ for (surf::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<surf::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);
+
+ }
+
+ }
+};
/* 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. */
-#ifndef SIMGRID_S4U_AS_HPP
-#define SIMGRID_S4U_AS_HPP
+#ifndef SIMGRID_SURF_AS_HPP
+#define SIMGRID_SURF_AS_HPP
#include "xbt/base.h"
#include "xbt/graph.h"
#include "simgrid/s4u/forward.hpp"
+#include "simgrid/s4u/As.hpp"
#include <vector>
#include <map>
#include "src/surf/xml/platf_private.hpp" // FIXME: kill sg_platf_route_cbarg_t to remove that UGLY include
namespace simgrid {
-
namespace surf {
class Link;
class NetCard;
class RoutingPlatf; // FIXME: KILLME
-}
-namespace s4u {
/** @brief Autonomous Systems
*
* An AS is a network container, in charge of routing information between elements (hosts) and to the nearby ASes.
* In SimGrid, there is a hierarchy of ASes, with a unique root AS (that you can retrieve from the s4u::Engine).
*/
-XBT_PUBLIC_CLASS As {
+XBT_PUBLIC_CLASS AsImpl : public s4u::As {
+ friend simgrid::surf::RoutingPlatf;
protected:
- As(const char *name);
- virtual ~As();
+ AsImpl(const char *name);
+ ~AsImpl();
-public:
- /** @brief Seal your AS once you're done adding content, and before routing stuff through it */
- virtual void Seal();
- char *name();
- As *father();;
- xbt_dict_t children(); // Sub AS
- xbt_dynar_t hosts(); // my content
-
-
public:
/**
* @brief Probe the routing path between two points
virtual void getRouteAndLatency(surf::NetCard *src, surf::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();
+ std::vector<surf::Link*> *getBypassRoute(surf::NetCard *src, surf::NetCard *dst);
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(surf::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);
+ static void getRouteRecursive(surf::NetCard *src, surf::NetCard *dst, /* OUT */ std::vector<surf::Link*> * links, double *latency);
enum RoutingKind {
/* FIXME: protect the following fields once the construction madness is sorted out */
RoutingKind hierarchy_ = ROUTING_NULL;
xbt_dynar_t upDownLinks = xbt_dynar_new(sizeof(s_surf_parsing_link_up_down_t),NULL);
- As *father_ = nullptr;
surf::NetCard *netcard_ = nullptr; // Our representative in the father AS
-
-protected:
- char *name_ = 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 surf::RoutingPlatf;
- std::map<std::pair<std::string, std::string>, std::vector<surf::Link*>*> bypassRoutes_; // srcName x dstName -> route
- static void getRouteRecursive(surf::NetCard *src, surf::NetCard *dst, /* OUT */ std::vector<surf::Link*> * links, double *latency);
- std::vector<surf::Link*> *getBypassRoute(surf::NetCard *src, surf::NetCard *dst);
-
};
}}; // Namespace simgrid::s4u
-#endif /* SIMGRID_S4U_AS_HPP */
+#endif /* SIMGRID_SURF_AS_HPP */
#include "src/instr/instr_private.h"
-#include "simgrid/s4u/as.hpp"
+#include "src/surf/AsImpl.hpp"
#include "simgrid/s4u/engine.hpp"
#include "surf/surf.h"
#include "src/surf/xml/platf_private.hpp"
xbt_dict_cursor_t cursor = NULL;
char *edge_name;
- as->getGraph(graph, nodes, edges);
+ static_cast<simgrid::surf::AsImpl*>(as)->getGraph(graph, nodes, edges);
xbt_dict_foreach(edges,cursor,edge_name,edge) {
linkContainers(
PJ_container_get((const char*) edge->src->data),
}
}
- as->getGraph(graph, nodes, edges);
+ static_cast<simgrid::surf::AsImpl*>(as)->getGraph(graph, nodes, edges);
}
xbt_graph_t instr_routing_platform_graph (void)
#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"
+#include "simgrid/s4u/As.hpp"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ns3);
#include "src/surf/cpu_interface.hpp"
#include "src/surf/network_interface.hpp"
#include "surf/surf_routing.h" // FIXME: brain dead public header
+#include "src/surf/AsImpl.hpp"
+
#include "src/surf/surf_routing_cluster.hpp"
#include "src/surf/surf_routing_cluster_torus.hpp"
#include "src/surf/surf_routing_cluster_fat_tree.hpp"
+#include "src/surf/surf_routing_dijkstra.hpp"
+#include "src/surf/surf_routing_floyd.hpp"
+#include "src/surf/surf_routing_full.hpp"
+#include "src/surf/surf_routing_vivaldi.hpp"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse);
static int surf_parse_models_setup_already_called = 0;
+/** The current AS in the parsing */
+static simgrid::surf::AsImpl *current_routing = NULL;
+static simgrid::surf::AsImpl* routing_get_current()
+{
+ return current_routing;
+}
+
/** Module management function: creates all internal data structures */
void sg_platf_init(void) {
}
xbt_assert(! sg_host_by_name(host->id),
"Refusing to create a second host named '%s'.", host->id);
- 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::AsImpl* current_routing = routing_get_current();
+ if (current_routing->hierarchy_ == simgrid::surf::AsImpl::ROUTING_NULL)
+ current_routing->hierarchy_ = simgrid::surf::AsImpl::ROUTING_BASE;
simgrid::surf::NetCard *netcard =
new simgrid::surf::NetCardImpl(host->id, SURF_NETWORK_ELEMENT_HOST, current_routing);
*/
void sg_platf_new_router(sg_platf_router_cbarg_t router)
{
- simgrid::s4u::As* current_routing = routing_get_current();
+ simgrid::surf::AsImpl* current_routing = routing_get_current();
- if (current_routing->hierarchy_ == simgrid::s4u::As::ROUTING_NULL)
- current_routing->hierarchy_ = simgrid::s4u::As::ROUTING_BASE;
+ if (current_routing->hierarchy_ == simgrid::surf::AsImpl::ROUTING_NULL)
+ current_routing->hierarchy_ = simgrid::surf::AsImpl::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);
// What an inventive way of initializing the AS that I have as ancestor :-(
sg_platf_new_AS_begin(&AS);
- simgrid::s4u::As *current_routing = routing_get_current();
+ simgrid::surf::AsImpl *current_routing = routing_get_current();
static_cast<AsCluster*>(current_routing)->parse_specific_arguments(cluster);
if(cluster->loopback_bw!=0 || cluster->loopback_lat!=0){
simgrid::surf::on_cluster(cluster);
}
+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());
+
+ cluster->backbone_ = bb;
+ XBT_DEBUG("Add a backbone to AS '%s'", current_routing->name());
+}
void sg_platf_new_storage(sg_platf_storage_cbarg_t storage)
{
current_property_set = NULL;
}
+void sg_platf_new_peer(sg_platf_peer_cbarg_t peer)
+{
+ using simgrid::surf::NetCard;
+ using simgrid::surf::AsCluster;
+
+ char *host_id = NULL;
+ char *link_id = NULL;
+ char *router_id = NULL;
+
+ XBT_DEBUG(" ");
+ host_id = bprintf("peer_%s", peer->id);
+ link_id = bprintf("link_%s", peer->id);
+ router_id = bprintf("router_%s", peer->id);
+
+ XBT_DEBUG("<AS id=\"%s\"\trouting=\"Cluster\">", peer->id);
+ s_sg_platf_AS_cbarg_t AS = SG_PLATF_AS_INITIALIZER;
+ AS.id = peer->id;
+ AS.routing = A_surfxml_AS_routing_Cluster;
+ sg_platf_new_AS_begin(&AS);
+
+ XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%f\"/>", host_id, peer->speed);
+ s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER;
+ memset(&host, 0, sizeof(host));
+ host.id = host_id;
+
+ host.speed_peak = xbt_dynar_new(sizeof(double), NULL);
+ xbt_dynar_push(host.speed_peak,&peer->speed);
+ host.pstate = 0;
+ //host.power_peak = peer->power;
+ host.speed_trace = peer->availability_trace;
+ host.state_trace = peer->state_trace;
+ host.core_amount = 1;
+ sg_platf_new_host(&host);
+ xbt_dynar_free(&host.speed_peak);
+
+ s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
+ memset(&link, 0, sizeof(link));
+ link.policy = SURF_LINK_SHARED;
+ link.latency = peer->lat;
+
+ char* link_up = bprintf("%s_UP",link_id);
+ XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_up,
+ peer->bw_out, peer->lat);
+ link.id = link_up;
+ link.bandwidth = peer->bw_out;
+ sg_platf_new_link(&link);
+
+ char* link_down = bprintf("%s_DOWN",link_id);
+ XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_down,
+ peer->bw_in, peer->lat);
+ link.id = link_down;
+ link.bandwidth = peer->bw_in;
+ sg_platf_new_link(&link);
+
+ XBT_DEBUG("<host_link\tid=\"%s\"\tup=\"%s\"\tdown=\"%s\" />", host_id,link_up,link_down);
+ s_sg_platf_host_link_cbarg_t host_link = SG_PLATF_HOST_LINK_INITIALIZER;
+ memset(&host_link, 0, sizeof(host_link));
+ host_link.id = host_id;
+ host_link.link_up = link_up;
+ host_link.link_down = link_down;
+ sg_platf_new_hostlink(&host_link);
+
+ XBT_DEBUG("<router id=\"%s\"/>", router_id);
+ s_sg_platf_router_cbarg_t router = SG_PLATF_ROUTER_INITIALIZER;
+ memset(&router, 0, sizeof(router));
+ router.id = router_id;
+ router.coord = peer->coord;
+ sg_platf_new_router(&router);
+ static_cast<AsCluster*>(current_routing)->router_ = static_cast<NetCard*>(xbt_lib_get_or_null(as_router_lib, router.id, ROUTING_ASR_LEVEL));
+
+ XBT_DEBUG("</AS>");
+ sg_platf_new_AS_end();
+ XBT_DEBUG(" ");
+
+ //xbt_dynar_free(&tab_elements_num);
+ free(router_id);
+ free(host_id);
+ free(link_id);
+ free(link_up);
+ free(link_down);
+}
+
void sg_platf_begin() { /* Do nothing: just for symmetry of user code */ }
void sg_platf_end() {
}
+/**
+ * \brief Make a new routing component to the platform
+ *
+ * Add a new autonomous system to the platform. Any elements (such as host,
+ * router or sub-AS) added after this call and before the corresponding call
+ * to sg_platf_new_AS_close() will be added to this AS.
+ *
+ * Once this function was called, the configuration concerning the used
+ * models cannot be changed anymore.
+ *
+ * @param AS_id name of this autonomous system. Must be unique in the platform
+ * @param wanted_routing_type one of Full, Floyd, Dijkstra or similar. Full list in the variable routing_models, in src/surf/surf_routing.c
+ */
+void routing_AS_begin(sg_platf_AS_cbarg_t AS)
+{
+ XBT_DEBUG("routing_AS_begin");
+
+ xbt_assert(nullptr == xbt_lib_get_or_null(as_router_lib, AS->id, ROUTING_ASR_LEVEL),
+ "Refusing to create a second AS called \"%s\".", AS->id);
+
+ _sg_cfg_init_status = 2; /* HACK: direct access to the global controlling the level of configuration to prevent
+ * any further config now that we created some real content */
+
+
+ /* search the routing model */
+ simgrid::surf::AsImpl *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;
+ case A_surfxml_AS_routing_ClusterFatTree: new_as = new simgrid::surf::AsClusterFatTree(AS->id); break;
+ case A_surfxml_AS_routing_Dijkstra: new_as = new simgrid::surf::AsDijkstra(AS->id, 0); break;
+ case A_surfxml_AS_routing_DijkstraCache: new_as = new simgrid::surf::AsDijkstra(AS->id, 1); break;
+ case A_surfxml_AS_routing_Floyd: new_as = new simgrid::surf::AsFloyd(AS->id); break;
+ case A_surfxml_AS_routing_Full: new_as = new simgrid::surf::AsFull(AS->id); break;
+ case A_surfxml_AS_routing_None: new_as = new simgrid::surf::AsNone(AS->id); break;
+ case A_surfxml_AS_routing_Vivaldi: new_as = new simgrid::surf::AsVivaldi(AS->id); break;
+ default: xbt_die("Not a valid model!"); break;
+ }
+
+ /* make a new routing component */
+ 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 */
+ 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),
+ "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_ == simgrid::surf::AsImpl::ROUTING_NULL)
+ current_routing->hierarchy_ = simgrid::surf::AsImpl::ROUTING_RECURSIVE;
+ /* add to the sons dictionary */
+ 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 {
+ THROWF(arg_error, 0, "All defined components must belong to a 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());
+
+ /* set the new current component of the tree */
+ current_routing = new_as;
+ current_routing->netcard_ = netcard;
+
+ simgrid::surf::netcardCreatedCallbacks(netcard);
+ simgrid::surf::asCreatedCallbacks(new_as);
+}
+
void sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS)
{
if (!surf_parse_models_setup_already_called) {
if (TRACE_is_enabled())
sg_instr_AS_end();
}
+/**
+ * \brief Specify that the current description of AS is finished
+ *
+ * Once you've declared all the content of your AS, you have to close
+ * it with this call. Your AS is not usable until you call this function.
+ */
+void routing_AS_end()
+{
+ xbt_assert(current_routing, "Cannot seal the current AS: none under construction");
+ current_routing->Seal();
+ current_routing = static_cast<simgrid::surf::AsImpl*>(current_routing->father());
+}
+
+/** @brief Add a link connecting an host to the rest of its AS (which must be cluster or vivaldi) */
+void sg_platf_new_hostlink(sg_platf_host_link_cbarg_t netcard_arg)
+{
+ simgrid::surf::NetCard *netcard = sg_host_by_name(netcard_arg->id)->pimpl_netcard;
+ xbt_assert(netcard, "Host '%s' not found!", netcard_arg->id);
+ xbt_assert(dynamic_cast<simgrid::surf::AsCluster*>(current_routing) ||
+ dynamic_cast<simgrid::surf::AsVivaldi*>(current_routing),
+ "Only hosts from Cluster and Vivaldi ASes can get a host_link.");
+
+ s_surf_parsing_link_up_down_t link_up_down;
+ link_up_down.link_up = Link::byName(netcard_arg->link_up);
+ link_up_down.link_down = Link::byName(netcard_arg->link_down);
+
+ xbt_assert(link_up_down.link_up, "Link '%s' not found!",netcard_arg->link_up);
+ xbt_assert(link_up_down.link_down, "Link '%s' not found!",netcard_arg->link_down);
+
+ // If dynar is is greater than netcard id and if the host_link is already defined
+ if((int)xbt_dynar_length(current_routing->upDownLinks) > netcard->id() &&
+ xbt_dynar_get_as(current_routing->upDownLinks, netcard->id(), void*))
+ surf_parse_error("Host_link for '%s' is already defined!",netcard_arg->id);
+
+ XBT_DEBUG("Push Host_link for host '%s' to position %d", netcard->name(), netcard->id());
+ xbt_dynar_set_as(current_routing->upDownLinks, netcard->id(), s_surf_parsing_link_up_down_t, link_up_down);
+}
#include "simgrid/sg_config.h"
#include "storage_interface.hpp"
+#include "src/surf/AsImpl.hpp"
#include "src/surf/surf_routing_cluster_torus.hpp"
#include "src/surf/surf_routing_cluster_fat_tree.hpp"
#include "src/surf/surf_routing_dijkstra.hpp"
simgrid::surf::RoutingPlatf *routing_platf = NULL;
-/** The current AS in the parsing */
-static simgrid::s4u::As *current_routing = NULL;
-simgrid::s4u::As* routing_get_current()
-{
- return current_routing;
-}
-
-/** @brief Add a link connecting an host to the rest of its AS (which must be cluster or vivaldi) */
-void sg_platf_new_hostlink(sg_platf_host_link_cbarg_t netcard_arg)
-{
- simgrid::surf::NetCard *netcard = sg_host_by_name(netcard_arg->id)->pimpl_netcard;
- xbt_assert(netcard, "Host '%s' not found!", netcard_arg->id);
- xbt_assert(dynamic_cast<simgrid::surf::AsCluster*>(current_routing) ||
- dynamic_cast<simgrid::surf::AsVivaldi*>(current_routing),
- "Only hosts from Cluster and Vivaldi ASes can get a host_link.");
-
- s_surf_parsing_link_up_down_t link_up_down;
- link_up_down.link_up = Link::byName(netcard_arg->link_up);
- link_up_down.link_down = Link::byName(netcard_arg->link_down);
-
- xbt_assert(link_up_down.link_up, "Link '%s' not found!",netcard_arg->link_up);
- xbt_assert(link_up_down.link_down, "Link '%s' not found!",netcard_arg->link_down);
-
- // If dynar is is greater than netcard id and if the host_link is already defined
- if((int)xbt_dynar_length(current_routing->upDownLinks) > netcard->id() &&
- xbt_dynar_get_as(current_routing->upDownLinks, netcard->id(), void*))
- surf_parse_error("Host_link for '%s' is already defined!",netcard_arg->id);
-
- XBT_DEBUG("Push Host_link for host '%s' to position %d", netcard->name(), netcard->id());
- xbt_dynar_set_as(current_routing->upDownLinks, netcard->id(), s_surf_parsing_link_up_down_t, link_up_down);
-}
-
void sg_platf_new_trace(sg_platf_trace_cbarg_t trace)
{
tmgr_trace_t tmgr_trace;
xbt_dict_set(traces_set_list, trace->id, (void *) tmgr_trace, NULL);
}
-/**
- * \brief Make a new routing component to the platform
- *
- * Add a new autonomous system to the platform. Any elements (such as host,
- * router or sub-AS) added after this call and before the corresponding call
- * to sg_platf_new_AS_close() will be added to this AS.
- *
- * Once this function was called, the configuration concerning the used
- * models cannot be changed anymore.
- *
- * @param AS_id name of this autonomous system. Must be unique in the platform
- * @param wanted_routing_type one of Full, Floyd, Dijkstra or similar. Full list in the variable routing_models, in src/surf/surf_routing.c
- */
-void routing_AS_begin(sg_platf_AS_cbarg_t AS)
-{
- XBT_DEBUG("routing_AS_begin");
-
- xbt_assert(nullptr == xbt_lib_get_or_null(as_router_lib, AS->id, ROUTING_ASR_LEVEL),
- "Refusing to create a second AS called \"%s\".", AS->id);
-
- _sg_cfg_init_status = 2; /* HACK: direct access to the global controlling the level of configuration to prevent
- * any further config now that we created some real content */
-
-
- /* search the routing model */
- 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;
- case A_surfxml_AS_routing_ClusterFatTree: new_as = new simgrid::surf::AsClusterFatTree(AS->id); break;
- case A_surfxml_AS_routing_Dijkstra: new_as = new simgrid::surf::AsDijkstra(AS->id, 0); break;
- case A_surfxml_AS_routing_DijkstraCache: new_as = new simgrid::surf::AsDijkstra(AS->id, 1); break;
- case A_surfxml_AS_routing_Floyd: new_as = new simgrid::surf::AsFloyd(AS->id); break;
- case A_surfxml_AS_routing_Full: new_as = new simgrid::surf::AsFull(AS->id); break;
- case A_surfxml_AS_routing_None: new_as = new simgrid::surf::AsNone(AS->id); break;
- case A_surfxml_AS_routing_Vivaldi: new_as = new simgrid::surf::AsVivaldi(AS->id); break;
- default: xbt_die("Not a valid model!"); break;
- }
-
- /* make a new routing component */
- 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 */
- 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),
- "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_ == 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);
- /* add to the father element list */
- netcard->setId(current_routing->addComponent(netcard));
- } else {
- THROWF(arg_error, 0, "All defined components must belong to a 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());
-
- /* set the new current component of the tree */
- current_routing = new_as;
- current_routing->netcard_ = netcard;
-
- simgrid::surf::netcardCreatedCallbacks(netcard);
- simgrid::surf::asCreatedCallbacks(new_as);
-}
-
-/**
- * \brief Specify that the current description of AS is finished
- *
- * Once you've declared all the content of your AS, you have to close
- * it with this call. Your AS is not usable until you call this function.
- */
-void routing_AS_end()
-{
- xbt_assert(current_routing, "Cannot seal the current AS: none under construction");
- current_routing->Seal();
- current_routing = current_routing->father();
-}
-
namespace simgrid {
namespace surf {
{
XBT_DEBUG("getRouteAndLatency from %s to %s", src->name(), dst->name());
- s4u::As::getRouteRecursive(src, dst, route, latency);
+ AsImpl::getRouteRecursive(src, dst, route, latency);
}
-static xbt_dynar_t _recursiveGetOneLinkRoutes(s4u::As *as)
+static xbt_dynar_t _recursiveGetOneLinkRoutes(surf::AsImpl *as)
{
xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f);
//recursing
char *key;
xbt_dict_cursor_t cursor = NULL;
- AS_t rc_child;
+ AsImpl *rc_child;
xbt_dict_foreach(as->children(), cursor, key, rc_child) {
xbt_dynar_t onelink_child = _recursiveGetOneLinkRoutes(rc_child);
if (onelink_child)
/* ************************************************************************** */
/* ************************* GENERIC PARSE FUNCTIONS ************************ */
-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());
-
- cluster->backbone_ = bb;
- XBT_DEBUG("Add a backbone to AS '%s'", current_routing->name());
-}
-
void sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet)
{
int start, end, i;
xbt_dynar_free(&radical_elements);
}
-void sg_platf_new_peer(sg_platf_peer_cbarg_t peer)
-{
- using simgrid::surf::NetCard;
- using simgrid::surf::AsCluster;
-
- char *host_id = NULL;
- char *link_id = NULL;
- char *router_id = NULL;
-
- XBT_DEBUG(" ");
- host_id = bprintf("peer_%s", peer->id);
- link_id = bprintf("link_%s", peer->id);
- router_id = bprintf("router_%s", peer->id);
-
- XBT_DEBUG("<AS id=\"%s\"\trouting=\"Cluster\">", peer->id);
- s_sg_platf_AS_cbarg_t AS = SG_PLATF_AS_INITIALIZER;
- AS.id = peer->id;
- AS.routing = A_surfxml_AS_routing_Cluster;
- sg_platf_new_AS_begin(&AS);
-
- XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%f\"/>", host_id, peer->speed);
- s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER;
- memset(&host, 0, sizeof(host));
- host.id = host_id;
-
- host.speed_peak = xbt_dynar_new(sizeof(double), NULL);
- xbt_dynar_push(host.speed_peak,&peer->speed);
- host.pstate = 0;
- //host.power_peak = peer->power;
- host.speed_trace = peer->availability_trace;
- host.state_trace = peer->state_trace;
- host.core_amount = 1;
- sg_platf_new_host(&host);
- xbt_dynar_free(&host.speed_peak);
-
- s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
- memset(&link, 0, sizeof(link));
- link.policy = SURF_LINK_SHARED;
- link.latency = peer->lat;
-
- char* link_up = bprintf("%s_UP",link_id);
- XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_up,
- peer->bw_out, peer->lat);
- link.id = link_up;
- link.bandwidth = peer->bw_out;
- sg_platf_new_link(&link);
-
- char* link_down = bprintf("%s_DOWN",link_id);
- XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_down,
- peer->bw_in, peer->lat);
- link.id = link_down;
- link.bandwidth = peer->bw_in;
- sg_platf_new_link(&link);
-
- XBT_DEBUG("<host_link\tid=\"%s\"\tup=\"%s\"\tdown=\"%s\" />", host_id,link_up,link_down);
- s_sg_platf_host_link_cbarg_t host_link = SG_PLATF_HOST_LINK_INITIALIZER;
- memset(&host_link, 0, sizeof(host_link));
- host_link.id = host_id;
- host_link.link_up = link_up;
- host_link.link_down = link_down;
- sg_platf_new_hostlink(&host_link);
-
- XBT_DEBUG("<router id=\"%s\"/>", router_id);
- s_sg_platf_router_cbarg_t router = SG_PLATF_ROUTER_INITIALIZER;
- memset(&router, 0, sizeof(router));
- router.id = router_id;
- router.coord = peer->coord;
- sg_platf_new_router(&router);
- static_cast<AsCluster*>(current_routing)->router_ = static_cast<NetCard*>(xbt_lib_get_or_null(as_router_lib, router.id, ROUTING_ASR_LEVEL));
-
- XBT_DEBUG("</AS>");
- sg_platf_new_AS_end();
- XBT_DEBUG(" ");
-
- //xbt_dynar_free(&tab_elements_num);
- free(router_id);
- free(host_id);
- free(link_id);
- free(link_up);
- free(link_down);
-}
-
static void check_disk_attachment()
{
xbt_lib_cursor_t cursor;
#include "surf_interface.hpp"
#include "src/surf/xml/platf_private.hpp" // FIXME: including this here is pure madness. KILKILKIL XML.
-#include <float.h>
+#include "src/surf/AsImpl.hpp"
+#include <float.h>
#include <vector>
#include <map>
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 s4u::As *containingAS()=0; // This is the AS in which I am
+ virtual AsImpl *containingAS()=0; // This is the AS in which I am
virtual bool isAS()=0;
virtual bool isHost()=0;
virtual bool isRouter()=0;
struct XBT_PRIVATE NetCardImpl : public NetCard {
public:
- NetCardImpl(const char *name, e_surf_network_element_type_t componentType, s4u::As *as)
+ NetCardImpl(const char *name, e_surf_network_element_type_t componentType, AsImpl *as)
: name_(xbt_strdup(name)),
componentType_(componentType),
containingAS_(as)
int id() override {return id_;}
void setId(int id) override {id_ = id;}
char *name() override {return name_;}
- s4u::As *containingAS() override {return containingAS_;}
+ AsImpl *containingAS() override {return containingAS_;}
bool isAS() override {return componentType_ == SURF_NETWORK_ELEMENT_AS;}
bool isHost() override {return componentType_ == SURF_NETWORK_ELEMENT_HOST;}
int id_ = -1;
char *name_;
e_surf_network_element_type_t componentType_;
- s4u::As *containingAS_;
+ AsImpl *containingAS_;
};
/** @ingroup SURF_routing_interface
public:
RoutingPlatf(Link *loopback);
~RoutingPlatf();
- s4u::As *root_ = nullptr;
+ AsImpl *root_ = nullptr;
Link *loopback_;
xbt_dynar_t getOneLinkRoutes(void);
void getRouteAndLatency(NetCard *src, NetCard *dst, std::vector<Link*> * links, double *latency);
namespace surf {
AsRoutedGraph::AsRoutedGraph(const char*name)
- : As(name)
+ : AsImpl(name)
{
}
if (route->link_list->size() == 1) {
Link *link = route->link_list->at(0);
Onelink *onelink;
- if (hierarchy_ == s4u::As::ROUTING_BASE)
+ if (hierarchy_ == AsImpl::ROUTING_BASE)
onelink = new Onelink(link, src_elm, dst_elm);
- else if (hierarchy_ == s4u::As::ROUTING_RECURSIVE)
+ else if (hierarchy_ == AsImpl::ROUTING_RECURSIVE)
onelink = new Onelink(link, route->gw_src, route->gw_dst);
else
onelink = new Onelink(link, NULL, NULL);
/* ************************************************************************** */
/* ************************* GENERIC AUX FUNCTIONS ************************** */
/* change a route containing link names into a route containing link entities */
-sg_platf_route_cbarg_t AsRoutedGraph::newExtendedRoute(s4u::As::RoutingKind hierarchy,
+sg_platf_route_cbarg_t AsRoutedGraph::newExtendedRoute(AsImpl::RoutingKind hierarchy,
sg_platf_route_cbarg_t routearg, int change_order)
{
result = xbt_new0(s_sg_platf_route_cbarg_t, 1);
result->link_list = new std::vector<Link*>();
- xbt_assert(hierarchy == s4u::As::ROUTING_BASE || hierarchy == s4u::As::ROUTING_RECURSIVE,
+ xbt_assert(hierarchy == AsImpl::ROUTING_BASE || hierarchy == AsImpl::ROUTING_RECURSIVE,
"The hierarchy of this AS is neither BASIC nor RECURSIVE, I'm lost here.");
- if (hierarchy == s4u::As::ROUTING_RECURSIVE) {
+ if (hierarchy == AsImpl::ROUTING_RECURSIVE) {
xbt_assert(routearg->gw_src && routearg->gw_dst, "NULL is obviously a deficient gateway");
result->gw_src = routearg->gw_src;
#include <xbt/base.h>
#include "surf_routing.hpp"
-#include "simgrid/s4u/as.hpp"
+#include "src/surf/AsImpl.hpp"
#ifndef SURF_ROUTING_GENERIC_HPP_
#define SURF_ROUTING_GENERIC_HPP_
class XBT_PRIVATE AsRoutedGraph;
-class XBT_PRIVATE AsRoutedGraph : public s4u::As {
+class XBT_PRIVATE AsRoutedGraph : public AsImpl {
public:
AsRoutedGraph(const char*name);
~AsRoutedGraph();
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(s4u::As::RoutingKind hierarchy, sg_platf_route_cbarg_t routearg, int change_order);
+ virtual sg_platf_route_cbarg_t newExtendedRoute(AsImpl::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);
namespace simgrid {
namespace surf {
AsCluster::AsCluster(const char*name)
- : As(name)
+ : AsImpl(name)
{}
void AsCluster::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat)
#include "surf_routing.hpp"
#include "network_interface.hpp"
-#include "simgrid/s4u/as.hpp"
+#include "src/surf/AsImpl.hpp"
namespace simgrid {
namespace surf {
/* ************************************************** */
/* ************** Cluster ROUTING **************** */
-class AsCluster: public s4u::As {
+class AsCluster: public AsImpl {
public:
AsCluster(const char*name);
graphNodeMap_ = xbt_dict_new_homogeneous(&graph_node_map_elem_free);
/* Add the loopback if needed */
- if (routing_platf->loopback_ && hierarchy_ == s4u::As::ROUTING_BASE) {
+ if (routing_platf->loopback_ && hierarchy_ == AsImpl::ROUTING_BASE) {
xbt_dynar_foreach(xbt_graph_get_nodes(routeGraph_), cursor, node) {
xbt_edge_t edge = NULL;
if (v == dst_node_id)
first_gw = gw_dst;
- if (hierarchy_ == s4u::As::ROUTING_RECURSIVE && v != dst_node_id && strcmp(gw_dst->name(), prev_gw_src->name())) {
+ if (hierarchy_ == AsImpl::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);
size++;
}
- if (hierarchy_ == s4u::As::ROUTING_RECURSIVE) {
+ if (hierarchy_ == AsImpl::ROUTING_RECURSIVE) {
route->gw_src = gw_src;
route->gw_dst = first_gw;
}
cur = pred;
} while (cur != src->id());
- if (hierarchy_ == s4u::As::ROUTING_RECURSIVE) {
+ if (hierarchy_ == AsImpl::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;
}
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_ == s4u::As::ROUTING_RECURSIVE && prev_dst_gw != NULL && strcmp(prev_dst_gw->name(), e_route->gw_src->name())) {
+ if (hierarchy_ == AsImpl::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);
}
}
/* Add the loopback if needed */
- if (routing_platf->loopback_ && hierarchy_ == s4u::As::ROUTING_BASE) {
+ if (routing_platf->loopback_ && hierarchy_ == AsImpl::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) {
routingTable_ = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size);
/* Add the loopback if needed */
- if (routing_platf->loopback_ && hierarchy_ == s4u::As::ROUTING_BASE) {
+ if (routing_platf->loopback_ && hierarchy_ == AsImpl::ROUTING_BASE) {
for (i = 0; i < table_size; i++) {
e_route = TO_ROUTE_FULL(i, i);
if (!e_route) {
namespace simgrid {
namespace surf {
AsNone::AsNone(const char*name)
- : As(name)
+ : AsImpl(name)
{}
AsNone::~AsNone()
{}
void AsNone::getGraph(xbt_graph_t /*graph*/, xbt_dict_t /*nodes*/, xbt_dict_t /*edges*/)
{
- XBT_INFO("No routing no graph");
+ XBT_ERROR("No routing no graph");
}
}
}
/* 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/base.h>
-
-#include "surf_routing.hpp"
-#include "simgrid/s4u/as.hpp"
-
+#include "src/surf/AsImpl.hpp"
#ifndef SURF_ROUTING_NONE_HPP_
#define SURF_ROUTING_NONE_HPP_
namespace surf {
/** No specific routing. Mainly useful with the constant network model */
-class XBT_PRIVATE AsNone : public s4u::As {
+class XBT_PRIVATE AsNone : public AsImpl {
public:
AsNone(const char*name);
~AsNone();
void routing_AS_begin(sg_platf_AS_cbarg_t AS);
void routing_AS_end(void);
void routing_cluster_add_backbone(Link* bb);
-AS_t routing_get_current();
/*** END of the parsing cruft ***/
XBT_PUBLIC(void) sg_platf_begin(void); // Start a new platform
src/surf/xml/simgrid_dtd.h
src/surf/xml/simgrid_dtd.c
src/surf/xml/surfxml_sax_cb.cpp
+ src/surf/AsImpl.hpp
src/surf/storage_interface.hpp
src/surf/storage_n11.hpp
src/surf/surf_interface.hpp
)
set(SURF_SRC
+ src/surf/AsImpl.cpp
src/surf/cpu_cas01.cpp
src/surf/cpu_interface.cpp
src/surf/cpu_ti.cpp
include/simgrid/link.h
include/simgrid/s4u/forward.hpp
include/simgrid/s4u/actor.hpp
- include/simgrid/s4u/as.hpp
+ include/simgrid/s4u/As.hpp
include/simgrid/s4u/async.hpp
include/simgrid/s4u/comm.hpp
include/simgrid/s4u/engine.hpp