Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a new simcall that modifies the rate of the first smx_action_t on smx_rdv_t
authorJonathan Rouzaud-Cornabas <jonathan.rouzaud-cornabas@ens-lyon.fr>
Thu, 7 Feb 2013 14:04:11 +0000 (15:04 +0100)
committerJonathan Rouzaud-Cornabas <jonathan.rouzaud-cornabas@ens-lyon.fr>
Thu, 7 Feb 2013 14:04:11 +0000 (15:04 +0100)
include/simgrid/simix.h
src/simix/smx_user.c
src/surf/surf_routing.c
src/surf/surf_routing_cluster.c
src/surf/surf_routing_private.h

index b22e1e8..5a0dfde 100644 (file)
@@ -409,6 +409,7 @@ XBT_PUBLIC(smx_action_t) simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff,
 XBT_PUBLIC(void) simcall_comm_destroy(smx_action_t comm);
 XBT_PUBLIC(smx_action_t) simcall_comm_iprobe(smx_rdv_t rdv, int src, int tag,
                                 int (*match_fun)(void *, void *, smx_action_t), void *data);
+XBT_PUBLIC(double) simcall_comm_change_rate_first_action(smx_rdv_t rdv, double newrate);
 XBT_PUBLIC(void) simcall_comm_cancel(smx_action_t comm);
 
 /* FIXME: waitany is going to be a vararg function, and should take a timeout */
index b9099f5..3d17a05 100644 (file)
@@ -738,6 +738,29 @@ smx_action_t simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_
 /**
  * \ingroup simix_comm_management
  */
+double simcall_comm_change_rate_first_action(smx_rdv_t rdv, double newrate)
+{
+  xbt_assert(rdv, "No rendez-vous point defined for change_rate_first_action");
+
+  smx_action_t action;
+  xbt_fifo_item_t item;
+
+  item = xbt_fifo_get_first_item(rdv->comm_fifo);
+  if (item != NULL) {
+         action = (smx_action_t) xbt_fifo_get_item_content(item);
+         if (action->comm.rate > newrate) {
+                 action->comm.rate = newrate;
+                 return newrate;
+         } else
+                 return action->comm.rate;
+  } else
+         return -1.0;
+}
+
+
+/**
+ * \ingroup simix_comm_management
+ */
 smx_action_t simcall_comm_iprobe(smx_rdv_t rdv, int src, int tag,
                                 int (*match_fun)(void *, void *, smx_action_t), void *data)
 {
index cf77d31..8e25069 100644 (file)
@@ -920,6 +920,7 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster)
         bprintf("%s%s_router%s", cluster->prefix, cluster->id,
                 cluster->suffix);
   sg_platf_new_router(&router);
+  ((as_cluster_t)current_routing)->router = xbt_lib_get_or_null(as_router_lib, router.id, ROUTING_ASR_LEVEL);
   free(newid);
 
   //Make the backbone
index d30c073..ab45c3f 100644 (file)
@@ -64,12 +64,99 @@ static void cluster_get_route_and_latency(AS_t as,
 static void cluster_get_graph(xbt_graph_t graph, xbt_dict_t nodes,
                               xbt_dict_t edges, AS_t rc)
 {
-  int isrc = 0, idst;
+  int isrc;
   int table_size = xbt_dynar_length(rc->index_network_elm);
 
   sg_routing_edge_t src, dst;
-  xbt_node_t current, previous, revCurrent, revPrevious;
+  xbt_node_t current, previous, backboneNode,routerNode;
+  s_surf_parsing_link_up_down_t info;
+
+  xbt_assert(((as_cluster_t) rc)->router,"Malformed cluster");
+
+  /* create the router */
+  char *link_name =
+                 ((sg_routing_edge_t) ((as_cluster_t) rc)->router)->name;
+  routerNode = new_xbt_graph_node(graph, link_name, nodes);
+
+  if(((as_cluster_t) rc)->backbone) {
+         char *link_nameR =
+                         ((surf_resource_t) ((as_cluster_t) rc)->backbone)->name;
+         backboneNode = new_xbt_graph_node(graph, link_nameR, nodes);
+
+         new_xbt_graph_edge(graph, routerNode, backboneNode, edges);
+  }
+
+  for (isrc = 0; isrc < table_size; isrc++) {
+         src = xbt_dynar_get_as(rc->index_network_elm, isrc, sg_routing_edge_t);
+
+         if (src->rc_type != SURF_NETWORK_ELEMENT_ROUTER) {
+                         previous = new_xbt_graph_node(graph, src->name, nodes);
+
+                         info = xbt_dynar_get_as(rc->link_up_down_list, src->id,
+                                         s_surf_parsing_link_up_down_t);
+
+                         if (info.link_up) {     // link up
 
+                                 char *link_name = ((surf_resource_t) info.link_up)->name;
+                                 current = new_xbt_graph_node(graph, link_name, nodes);
+                                 new_xbt_graph_edge(graph, previous, current, edges);
+
+                                 if (((as_cluster_t) rc)->backbone) {
+                                         new_xbt_graph_edge(graph, current, backboneNode, edges);
+                                 } else {
+                                         new_xbt_graph_edge(graph, current, routerNode, edges);
+                                 }
+
+                         }
+
+                         if (info.link_down) {    // link down
+                                 char *link_name = ((surf_resource_t) info.link_down)->name;
+                                 current = new_xbt_graph_node(graph, link_name, nodes);
+                                 new_xbt_graph_edge(graph, previous, current, edges);
+
+                                 if (((as_cluster_t) rc)->backbone) {
+                                         new_xbt_graph_edge(graph, current, backboneNode, edges);
+                                 } else {
+                                         new_xbt_graph_edge(graph, current, routerNode, edges);
+                                 }
+
+                         }
+                 }
+  }
+
+/*
+                 if (((as_cluster_t) rc)->backbone) {
+                         char *link_name =
+                                         ((surf_resource_t) ((as_cluster_t) rc)->backbone)->name;
+
+                         current = new_xbt_graph_node(graph, link_name, nodes);
+                         new_xbt_graph_edge(graph, previous, current, edges);
+                         previous = current;
+
+                         revCurrent = new_xbt_graph_node(graph, link_name, nodes);
+                         new_xbt_graph_edge(graph, revCurrent, revPrevious, edges);
+                         revPrevious = revCurrent;
+                 } else {
+                         info = xbt_dynar_get_as(rc->link_up_down_list, dst->id,
+                                                                         s_surf_parsing_link_up_down_t);
+
+                         if (info.link_up) {     // link up
+                                 char *link_name = ((surf_resource_t) info.link_up)->name;
+                                 current = new_xbt_graph_node(graph, link_name, nodes);
+                                 new_xbt_graph_edge(graph, previous, current, edges);
+                                 previous = current;
+                         } else if (info.link_down) {    // link down
+                                 char *link_name = ((surf_resource_t) info.link_down)->name;
+                                 revCurrent = new_xbt_graph_node(graph, link_name, nodes);
+                                 new_xbt_graph_edge(graph, revCurrent, revPrevious, edges);
+                                 revPrevious = revCurrent;
+                         }
+                 }
+
+         }
+  }*/
+/*
+  if(rc->)
   for (isrc = 0; isrc < table_size; isrc++) {
     src = xbt_dynar_get_as(rc->index_network_elm, isrc, sg_routing_edge_t);
 
@@ -79,10 +166,6 @@ static void cluster_get_graph(xbt_graph_t graph, xbt_dict_t nodes,
     for (idst = isrc + 1; idst < table_size; idst++) {
       dst = xbt_dynar_get_as(rc->index_network_elm, idst, sg_routing_edge_t);
 
-      sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
-      route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
-      rc->get_route_and_latency(rc, src, dst, route, NULL);
-
       s_surf_parsing_link_up_down_t info;
 
       if (src->rc_type != SURF_NETWORK_ELEMENT_ROUTER) {        // No specific link for router
@@ -103,6 +186,8 @@ static void cluster_get_graph(xbt_graph_t graph, xbt_dict_t nodes,
         }
       }
 
+
+
       if (((as_cluster_t) rc)->backbone) {
         char *link_name =
             ((surf_resource_t) ((as_cluster_t) rc)->backbone)->name;
@@ -135,7 +220,7 @@ static void cluster_get_graph(xbt_graph_t graph, xbt_dict_t nodes,
       }
 
     }
-  }
+  }*/
 }
 
 static void model_cluster_finalize(AS_t as)
index ac4cbe3..c1369d0 100644 (file)
@@ -72,6 +72,7 @@ AS_t model_rulebased_create(void);      /* create structures for rulebased routi
 typedef struct {
   s_as_t generic_routing;
   void *backbone;
+  sg_routing_edge_t router;
 } s_as_cluster_t, *as_cluster_t;
 
 AS_t model_cluster_create(void);      /* create structures for cluster routing model */