Each surf::As is given a Seal() method in charge of finalizing its
initialization once the last element is added.
NetCard *p_netcard;
xbt_dynar_t p_linkUpDownList = NULL;
NetCard *p_netcard;
xbt_dynar_t p_linkUpDownList = NULL;
- /**
- * @brief The As constructor
- */
+ /* Close that AS: no more content can be added to it */
+ virtual void Seal()=0;
- /**
- * @brief The As destructor
- */
virtual ~As(){
xbt_dict_free(&p_routingSons);
xbt_dynar_free(&p_indexNetworkElm);
virtual ~As(){
xbt_dict_free(&p_routingSons);
xbt_dynar_free(&p_indexNetworkElm);
class AsCluster: public AsNone {
public:
AsCluster() {}
class AsCluster: public AsNone {
public:
AsCluster() {}
+ void Seal() override {}; // nothing to do
virtual void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) override;
virtual void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) override;
virtual void create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position);
virtual void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster) {}
virtual void create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position);
virtual void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster) {}
Link* p_backbone = nullptr;
void *p_loopback = nullptr;
NetCard *p_router = nullptr;
Link* p_backbone = nullptr;
void *p_loopback = nullptr;
NetCard *p_router = nullptr;
void model_dijkstra_both_end(AS_t as)
{
void model_dijkstra_both_end(AS_t as)
{
- simgrid::surf::AsDijkstra *THIS_AS
- = static_cast<simgrid::surf::AsDijkstra*>(as);
- xbt_node_t node = NULL;
- unsigned int cursor2;
- xbt_dynar_t nodes = NULL;
+/* Utility functions */
+
+namespace simgrid {
+namespace surf {
+void AsDijkstra::Seal()
+{
/* Create the topology graph */
/* Create the topology graph */
- if(!THIS_AS->p_routeGraph)
- THIS_AS->p_routeGraph = xbt_graph_new_graph(1, NULL);
- if(!THIS_AS->p_graphNodeMap)
- THIS_AS->p_graphNodeMap = xbt_dict_new_homogeneous(&graph_node_map_elem_free);
+ if(!p_routeGraph)
+ p_routeGraph = xbt_graph_new_graph(1, NULL);
+ if(!p_graphNodeMap)
+ p_graphNodeMap = xbt_dict_new_homogeneous(&graph_node_map_elem_free);
- if (THIS_AS->m_cached && !THIS_AS->p_routeCache)
- THIS_AS->p_routeCache = xbt_dict_new_homogeneous(&route_cache_elem_free);
+ if (m_cached && !p_routeCache)
+ p_routeCache = xbt_dict_new_homogeneous(&route_cache_elem_free);
/* Add the loopback if needed */
/* Add the loopback if needed */
- if (routing_platf->p_loopback && as->p_hierarchy == SURF_ROUTING_BASE)
- THIS_AS->addLoopback();
+ if (routing_platf->p_loopback && p_hierarchy == SURF_ROUTING_BASE)
+ addLoopback();
/* initialize graph indexes in nodes after graph has been built */
/* initialize graph indexes in nodes after graph has been built */
- nodes = xbt_graph_get_nodes(THIS_AS->p_routeGraph);
+ xbt_dynar_t nodes = xbt_graph_get_nodes(p_routeGraph);
+ xbt_node_t node = NULL;
+ unsigned int cursor2;
xbt_dynar_foreach(nodes, cursor2, node) {
graph_node_data_t data = (graph_node_data_t) xbt_graph_node_get_data(node);
data->graph_id = cursor2;
}
}
xbt_dynar_foreach(nodes, cursor2, node) {
graph_node_data_t data = (graph_node_data_t) xbt_graph_node_get_data(node);
data->graph_id = cursor2;
}
}
-/* Utility functions */
-
-namespace simgrid {
-namespace surf {
-
xbt_node_t AsDijkstra::routeGraphNewNode(int id, int graph_id)
{
xbt_node_t node = NULL;
xbt_node_t AsDijkstra::routeGraphNewNode(int id, int graph_id)
{
xbt_node_t node = NULL;
class AsDijkstra : public AsGeneric {
public:
AsDijkstra();
class AsDijkstra : public AsGeneric {
public:
AsDijkstra();
+ void Seal() override;
+
AsDijkstra(bool cached);
~AsDijkstra();
xbt_node_t routeGraphNewNode(int id, int graph_id);
AsDijkstra(bool cached);
~AsDijkstra();
xbt_node_t routeGraphNewNode(int id, int graph_id);
void model_floyd_end(AS_t current_routing)
{
void model_floyd_end(AS_t current_routing)
{
- static_cast<simgrid::surf::AsFloyd*>(current_routing)->end();
+ current_routing->Seal();
xbt_dynar_free(&route->link_list);
}
xbt_dynar_free(&route->link_list);
}
unsigned int i, j, a, b, c;
/* set the size of table routing */
unsigned int i, j, a, b, c;
/* set the size of table routing */
xbt_dynar_t getOneLinkRoutes() override;
void parseASroute(sg_platf_route_cbarg_t route) override;
void parseRoute(sg_platf_route_cbarg_t route) override;
xbt_dynar_t getOneLinkRoutes() override;
void parseASroute(sg_platf_route_cbarg_t route) override;
void parseRoute(sg_platf_route_cbarg_t route) override;
private:
/* vars to compute the Floyd algorithm. */
private:
/* vars to compute the Floyd algorithm. */
void model_full_end(AS_t _routing)
{
void model_full_end(AS_t _routing)
{
+ _routing->Seal();
+}
+
+namespace simgrid {
+namespace surf {
+void AsFull::Seal() {
int i;
sg_platf_route_cbarg_t e_route;
/* set utils vars */
int i;
sg_platf_route_cbarg_t e_route;
/* set utils vars */
- simgrid::surf::AsFull *routing = static_cast<simgrid::surf::AsFull*>(_routing);
- int table_size = (int)xbt_dynar_length(routing->p_indexNetworkElm);
+ int table_size = (int)xbt_dynar_length(p_indexNetworkElm);
/* Create table if necessary */
/* Create table if necessary */
- if (!routing->p_routingTable)
- routing->p_routingTable = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size);
+ if (!p_routingTable)
+ p_routingTable = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size);
/* Add the loopback if needed */
/* Add the loopback if needed */
- if (routing_platf->p_loopback && routing->p_hierarchy == SURF_ROUTING_BASE) {
+ if (routing_platf->p_loopback && p_hierarchy == SURF_ROUTING_BASE) {
for (i = 0; i < table_size; i++) {
for (i = 0; i < table_size; i++) {
- e_route = routing->TO_ROUTE_FULL(i, i);
+ e_route = TO_ROUTE_FULL(i, i);
if (!e_route) {
e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
e_route->gw_src = NULL;
e_route->gw_dst = NULL;
e_route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
xbt_dynar_push(e_route->link_list, &routing_platf->p_loopback);
if (!e_route) {
e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
e_route->gw_src = NULL;
e_route->gw_dst = NULL;
e_route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
xbt_dynar_push(e_route->link_list, &routing_platf->p_loopback);
- routing->TO_ROUTE_FULL(i, i) = e_route;
+ TO_ROUTE_FULL(i, i) = e_route;
-namespace simgrid {
-namespace surf {
-
AsFull::~AsFull(){
if (p_routingTable) {
int table_size = (int)xbt_dynar_length(p_indexNetworkElm);
AsFull::~AsFull(){
if (p_routingTable) {
int table_size = (int)xbt_dynar_length(p_indexNetworkElm);
~AsFull();
void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
~AsFull();
void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
class XBT_PRIVATE AsNone : public As {
public:
AsNone() {}
class XBT_PRIVATE AsNone : public As {
public:
AsNone() {}
+ void Seal() override {}; // nothing to do
~AsNone() {}
void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
~AsNone() {}
void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
class AsVivaldi: public AsGeneric {
public:
AsVivaldi() : AsGeneric() {};
class AsVivaldi: public AsGeneric {
public:
AsVivaldi() : AsGeneric() {};
+ void Seal() override {}; // nothing to do
~AsVivaldi() {};
void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
~AsVivaldi() {};
void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;