#include "src/surf/surf_routing_full.hpp"
#include "src/surf/surf_routing_vivaldi.hpp"
-/*************
- * Callbacks *
- *************/
namespace simgrid {
namespace surf {
-simgrid::xbt::signal<void(simgrid::surf::NetCard*)> netcardCreatedCallbacks;
-simgrid::xbt::signal<void(simgrid::surf::As*)> asCreatedCallbacks;
+ /* Callbacks */
+ simgrid::xbt::signal<void(simgrid::surf::NetCard*)> netcardCreatedCallbacks;
+ simgrid::xbt::signal<void(simgrid::surf::As*)> asCreatedCallbacks;
-}
-}
+ As::As(const char*name)
+ : p_name(xbt_strdup(name))
+ {}
+ As::~As()
+ {
+ xbt_dict_free(&p_routingSons);
+ xbt_dynar_free(&p_indexNetworkElm);
+ xbt_dynar_free(&p_linkUpDownList);
+ xbt_free(p_name);
+ if (p_netcard)
+ delete p_netcard;
+ }
+
+}} // namespace simgrid::surf
/**
* @ingroup SURF_build_api
return current_routing;
}
-/* this lines are only for replace use like index in the model table */
-typedef enum {
- SURF_MODEL_FULL = 0,
- SURF_MODEL_FLOYD,
- SURF_MODEL_DIJKSTRA,
- SURF_MODEL_DIJKSTRACACHE,
- SURF_MODEL_NONE,
- SURF_MODEL_VIVALDI,
- SURF_MODEL_CLUSTER,
- SURF_MODEL_TORUS_CLUSTER,
- SURF_MODEL_FAT_TREE_CLUSTER,
-} e_routing_types;
-
/** @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)
{
_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 */
- simgrid::surf::As *new_as = NULL;
/* search the routing model */
+ simgrid::surf::As *new_as = NULL;
switch(AS->routing){
- case A_surfxml_AS_routing_Cluster: new_as = new simgrid::surf::AsCluster(); break;
- case A_surfxml_AS_routing_ClusterTorus: new_as = new simgrid::surf::AsClusterTorus(); break;
- case A_surfxml_AS_routing_ClusterFatTree: new_as = new simgrid::surf::AsClusterFatTree(); break;
- case A_surfxml_AS_routing_Dijkstra: new_as = new simgrid::surf::AsDijkstra(0); break;
- case A_surfxml_AS_routing_DijkstraCache: new_as = new simgrid::surf::AsDijkstra(1); break;
- case A_surfxml_AS_routing_Floyd: new_as = new simgrid::surf::AsFloyd(); break;
- case A_surfxml_AS_routing_Full: new_as = new simgrid::surf::AsFull(); break;
- case A_surfxml_AS_routing_None: new_as = new simgrid::surf::AsNone(); break;
- case A_surfxml_AS_routing_Vivaldi: new_as = new simgrid::surf::AsVivaldi(); break;
- default: xbt_die("Not a valid model!"); break;
+ 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 */
-
- new_as->p_hierarchy = SURF_ROUTING_NULL;
- new_as->p_name = xbt_strdup(AS->id);
-
simgrid::surf::NetCard *netcard = new simgrid::surf::NetCardImpl(new_as->p_name, SURF_NETWORK_ELEMENT_AS, current_routing);
- if (current_routing == NULL && routing_platf->p_root == NULL) {
+ if (current_routing == NULL && routing_platf->p_root == NULL) {
/* it is the first one */
new_as->p_routingFather = NULL;
routing_platf->p_root = new_as;
netcard->setId(-1);
} else if (current_routing != NULL && routing_platf->p_root != NULL) {
- xbt_assert(!xbt_dict_get_or_null
- (current_routing->p_routingSons, AS->id),
+ xbt_assert(!xbt_dict_get_or_null(current_routing->p_routingSons, AS->id),
"The AS \"%s\" already exists", AS->id);
/* it is a part of the tree */
new_as->p_routingFather = current_routing;
*/
class As {
public:
- xbt_dynar_t p_indexNetworkElm = xbt_dynar_new(sizeof(char*),NULL);
- xbt_dict_t p_bypassRoutes; /* store bypass routes */
- e_surf_routing_hierarchy_t p_hierarchy;
+ As(const char*name);
+ /** @brief Close that AS: no more content can be added to it */
+ virtual void Seal()=0;
+ virtual ~As();
+
char *p_name = nullptr;
+ NetCard *p_netcard = nullptr;
As *p_routingFather = nullptr;
+
+ xbt_dynar_t p_indexNetworkElm = xbt_dynar_new(sizeof(char*),NULL);
+ xbt_dict_t p_bypassRoutes = nullptr;
+ e_surf_routing_hierarchy_t p_hierarchy = SURF_ROUTING_NULL;
xbt_dict_t p_routingSons = xbt_dict_new_homogeneous(NULL);
- NetCard *p_netcard;
xbt_dynar_t p_linkUpDownList = xbt_dynar_new(sizeof(s_surf_parsing_link_up_down_t),NULL);
- As(){};
- /* Close that AS: no more content can be added to it */
- virtual void Seal()=0;
- virtual ~As(){
- xbt_dict_free(&p_routingSons);
- xbt_dynar_free(&p_indexNetworkElm);
- xbt_dynar_free(&p_linkUpDownList);
- xbt_free(p_name);
- if (p_netcard)
- delete p_netcard;
- };
/**
* @brief Get the characteristics of the routing path between two points
namespace simgrid {
namespace surf {
+ AsCluster::AsCluster(const char*name)
+ : AsNone(name)
+ {}
-/* Business methods */
void AsCluster::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat)
{
s_surf_parsing_link_up_down_t info;
class AsCluster: public AsNone {
public:
- AsCluster() {}
+ AsCluster(const char*name);
void Seal() override {}; // nothing to do
virtual void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
namespace simgrid {
namespace surf {
-AsClusterFatTree::AsClusterFatTree() : levels(0) {
+AsClusterFatTree::AsClusterFatTree(const char*name)
+ : AsCluster(name)
+{
XBT_DEBUG("Creating a new fat tree.");
}
*/
class XBT_PRIVATE AsClusterFatTree : public AsCluster {
public:
- AsClusterFatTree();
+ AsClusterFatTree(const char*name);
~AsClusterFatTree();
virtual void getRouteAndLatency(NetCard *src, NetCard *dst,
sg_platf_route_cbarg_t into,
private:
//description of a PGFT (TODO : better doc)
- unsigned int levels;
+ unsigned int levels = 0;
std::vector<unsigned int> lowerLevelNodesNumber; // number of children by node
std::vector<unsigned int> upperLevelNodesNumber; // number of parents by node
std::vector<unsigned int> lowerLevelPortsNumber; // ports between each level l and l-1
namespace simgrid {
namespace surf {
- AsClusterTorus::AsClusterTorus():AsCluster() {
+ AsClusterTorus::AsClusterTorus(const char*name)
+ : AsCluster(name) {
}
AsClusterTorus::~AsClusterTorus() {
xbt_dynar_free(&p_dimensions);
class XBT_PRIVATE AsClusterTorus:public simgrid::surf::AsCluster {
public:
- AsClusterTorus();
+ AsClusterTorus(const char*name);
virtual ~AsClusterTorus();
void create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position) override;
void getRouteAndLatency(NetCard * src, NetCard * dst, sg_platf_route_cbarg_t into, double *latency) override;
/* Creation routing model functions */
-AsDijkstra::AsDijkstra() : AsGeneric() {
-}
-
-AsDijkstra::AsDijkstra(bool cached) : AsGeneric(), m_cached(cached)
+AsDijkstra::AsDijkstra(const char*name, bool cached)
+ : AsGeneric(name)
+ , m_cached(cached)
{
p_routeGraph = NULL;
p_graphNodeMap = NULL;
/** Dijkstra routing data: fast initialization, slow lookup, small memory requirements, shortest path routing only */
class AsDijkstra : public AsGeneric {
public:
- AsDijkstra();
+ AsDijkstra(const char*name, bool cached);
void Seal() override;
- AsDijkstra(bool cached);
~AsDijkstra();
xbt_node_t routeGraphNewNode(int id, int graph_id);
graph_node_map_element_t nodeMapSearch(int id);
namespace simgrid {
namespace surf {
-AsFloyd::AsFloyd(): AsGeneric() {
+AsFloyd::AsFloyd(const char*name)
+ : AsGeneric(name)
+{
p_predecessorTable = NULL;
p_costTable = NULL;
p_linkTable = NULL;
/** Floyd routing data: slow initialization, fast lookup, lesser memory requirements, shortest path routing only */
class AsFloyd: public AsGeneric {
public:
- AsFloyd();
+ AsFloyd(const char *name);
~AsFloyd();
void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
namespace simgrid {
namespace surf {
+ AsFull::AsFull(const char*name)
+ : AsGeneric(name)
+ {
+ }
+
void AsFull::Seal() {
int i;
sg_platf_route_cbarg_t e_route;
class AsFull: public AsGeneric {
public:
- AsFull() {}
+ AsFull(const char*name);
void Seal() override;
~AsFull();
THROW_IMPOSSIBLE;
}
-AsGeneric::AsGeneric() {
+AsGeneric::AsGeneric(const char*name)
+ : AsNone(name)
+{
p_bypassRoutes = xbt_dict_new_homogeneous((void (*)(void *)) routing_route_free);
}
-AsGeneric::~AsGeneric() {
+AsGeneric::~AsGeneric()
+{
xbt_dict_free(&p_bypassRoutes);
}
class XBT_PRIVATE AsGeneric : public AsNone {
public:
- AsGeneric();
+ AsGeneric(const char*name);
~AsGeneric();
virtual void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
namespace simgrid {
namespace surf {
+AsNone::AsNone(const char*name)
+ : As(name)
+{}
+AsNone::~AsNone()
+{}
xbt_dynar_t AsNone::getOneLinkRoutes() {
return NULL;
/** No specific routing. Mainly useful with the constant network model */
class XBT_PRIVATE AsNone : public As {
public:
- AsNone() {}
+ AsNone(const char*name);
void Seal() override {}; // nothing to do
- ~AsNone() {}
+ ~AsNone();
void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
xbt_dynar_t getOneLinkRoutes() override;
namespace simgrid {
namespace surf {
+ AsVivaldi::AsVivaldi(const char *name)
+ : AsGeneric(name)
+ {}
void AsVivaldi::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat)
{
class AsVivaldi: public AsGeneric {
public:
- AsVivaldi() : AsGeneric() {};
+ AsVivaldi(const char *name);
void Seal() override {}; // nothing to do
~AsVivaldi() {};