Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Ooups. I was still using Mb instead of b...:(
[simgrid.git] / src / surf / workstation_KCCFLN05.c
index ab6ebc7..8695b1b 100644 (file)
@@ -16,6 +16,7 @@ static int nb_workstation = 0;
 static s_route_KCCFLN05_t *routing_table = NULL;
 #define ROUTE(i,j) routing_table[(i)+(j)*nb_workstation]
 static network_link_KCCFLN05_t loopback = NULL;
 static s_route_KCCFLN05_t *routing_table = NULL;
 #define ROUTE(i,j) routing_table[(i)+(j)*nb_workstation]
 static network_link_KCCFLN05_t loopback = NULL;
+static xbt_dict_t parallel_task_network_link_set = NULL;
 
 /*xbt_dict_t network_link_set = NULL;*/
 
 
 /*xbt_dict_t network_link_set = NULL;*/
 
@@ -251,10 +252,10 @@ static void update_actions_state(double now, double delta)
     deltap = delta;
     if (action->latency > 0) {
       if (action->latency > deltap) {
     deltap = delta;
     if (action->latency > 0) {
       if (action->latency > deltap) {
-       surf_double_update(&(action->latency), deltap);
+       double_update(&(action->latency), deltap);
        deltap = 0.0;
       } else {
        deltap = 0.0;
       } else {
-       surf_double_update(&(deltap), action->latency);
+       double_update(&(deltap), action->latency);
        action->latency = 0.0;
       }
       if ((action->latency == 0.0) && !(action->suspended)) {
        action->latency = 0.0;
       }
       if ((action->latency == 0.0) && !(action->suspended)) {
@@ -265,10 +266,10 @@ static void update_actions_state(double now, double delta)
                                     action->lat_current);
       }
     }
                                     action->lat_current);
       }
     }
-    surf_double_update(&(action->generic_action.remains),
+    double_update(&(action->generic_action.remains),
                       lmm_variable_getvalue(action->variable) * deltap);
     if (action->generic_action.max_duration != NO_MAX_DURATION)
                       lmm_variable_getvalue(action->variable) * deltap);
     if (action->generic_action.max_duration != NO_MAX_DURATION)
-      surf_double_update(&(action->generic_action.max_duration), delta);
+      double_update(&(action->generic_action.max_duration), delta);
 
     /*   if(action->generic_action.remains<.00001) action->generic_action.remains=0; */
 
 
     /*   if(action->generic_action.remains<.00001) action->generic_action.remains=0; */
 
@@ -374,6 +375,9 @@ static void finalize(void)
 
   xbt_dict_free(&network_link_set);
   xbt_dict_free(&workstation_set);
 
   xbt_dict_free(&network_link_set);
   xbt_dict_free(&workstation_set);
+  if (parallel_task_network_link_set != NULL) {
+    xbt_dict_free(&parallel_task_network_link_set);
+  }
   xbt_swag_free(surf_workstation_resource->common_public->states.
                ready_action_set);
   xbt_swag_free(surf_workstation_resource->common_public->states.
   xbt_swag_free(surf_workstation_resource->common_public->states.
                ready_action_set);
   xbt_swag_free(surf_workstation_resource->common_public->states.
@@ -548,7 +552,6 @@ static surf_action_t communicate(void *src, void *dst, double size, double rate)
   return (surf_action_t) action;
 }
 
   return (surf_action_t) action;
 }
 
-/* FIXME: execute_parallel_task */
 static surf_action_t execute_parallel_task(int workstation_nb,
                                           void **workstation_list, 
                                           double *computation_amount, 
 static surf_action_t execute_parallel_task(int workstation_nb,
                                           void **workstation_list, 
                                           double *computation_amount, 
@@ -558,12 +561,12 @@ static surf_action_t execute_parallel_task(int workstation_nb,
 {
   surf_action_workstation_KCCFLN05_t action = NULL;
   int i, j, k;
 {
   surf_action_workstation_KCCFLN05_t action = NULL;
   int i, j, k;
-  xbt_dict_t network_link_set = xbt_dict_new();
-  xbt_dict_cursor_t cursor = NULL;
-  char *name = NULL;
   int nb_link = 0;
   int nb_host = 0;
   int nb_link = 0;
   int nb_host = 0;
-  network_link_KCCFLN05_t link;
+
+  if (parallel_task_network_link_set == NULL) {
+    parallel_task_network_link_set = xbt_dict_new_ext(workstation_nb * workstation_nb * 10);
+  }
 
   /* Compute the number of affected resources... */
   for(i=0; i< workstation_nb; i++) {
 
   /* Compute the number of affected resources... */
   for(i=0; i< workstation_nb; i++) {
@@ -575,16 +578,13 @@ static surf_action_t execute_parallel_task(int workstation_nb,
       
       if(communication_amount[i*workstation_nb+j]>0)
        for(k=0; k< route_size; k++) {
       
       if(communication_amount[i*workstation_nb+j]>0)
        for(k=0; k< route_size; k++) {
-         xbt_dict_set(network_link_set, route[k]->name, route[k], NULL);
+         xbt_dict_set(parallel_task_network_link_set, route[k]->name, route[k], NULL);
        }
     }
   }
 
        }
     }
   }
 
-  xbt_dict_foreach(network_link_set, cursor, name, link) {
-    nb_link++;
-  }
-
-  xbt_dict_free(&network_link_set);
+  nb_link = xbt_dict_length(parallel_task_network_link_set);
+  xbt_dict_reset(parallel_task_network_link_set);
 
   for (i = 0; i<workstation_nb; i++)
     if(computation_amount[i]>0) nb_host++;
 
   for (i = 0; i<workstation_nb; i++)
     if(computation_amount[i]>0) nb_host++;
@@ -858,30 +858,24 @@ static void parse_network_link(void)
                   policy_initial);
 }
 
                   policy_initial);
 }
 
-static void route_new(int src_id, int dst_id, char **links, int nb_link,
+static void route_new(int src_id, int dst_id, network_link_KCCFLN05_t *link_list, int nb_link,
                      double impact_on_src, double impact_on_dst,
                      double impact_on_src_with_other_recv,
                      double impact_on_dst_with_other_send)
 {
                      double impact_on_src, double impact_on_dst,
                      double impact_on_src_with_other_recv,
                      double impact_on_dst_with_other_send)
 {
-  network_link_KCCFLN05_t *link_list = NULL;
-  int i;
   route_KCCFLN05_t route = &(ROUTE(src_id, dst_id));
 
   route->size = nb_link;
   route_KCCFLN05_t route = &(ROUTE(src_id, dst_id));
 
   route->size = nb_link;
-  link_list = route->links = xbt_new0(network_link_KCCFLN05_t, nb_link);
-  for (i = 0; i < nb_link; i++) {
-    link_list[i] = xbt_dict_get_or_null(network_link_set, links[i]);
-    free(links[i]);
-  }
-  free(links);
+  route->links = link_list = xbt_realloc(link_list, sizeof(network_link_KCCFLN05_t) * nb_link);
   route->impact_on_src = impact_on_src;
   route->impact_on_dst = impact_on_src;
   route->impact_on_src_with_other_recv = impact_on_src_with_other_recv;
   route->impact_on_dst_with_other_send = impact_on_dst_with_other_send;
 }
 
   route->impact_on_src = impact_on_src;
   route->impact_on_dst = impact_on_src;
   route->impact_on_src_with_other_recv = impact_on_src_with_other_recv;
   route->impact_on_dst_with_other_send = impact_on_dst_with_other_send;
 }
 
-static int nb_link = 0;
-static char **link_name = NULL;
+static int nb_link;
+static int link_list_capacity;
+static network_link_KCCFLN05_t *link_list = NULL;
 static int src_id = -1;
 static int dst_id = -1;
 static double impact_on_src;
 static int src_id = -1;
 static int dst_id = -1;
 static double impact_on_src;
@@ -901,19 +895,22 @@ static void parse_route_set_endpoints(void)
                        A_surfxml_route_impact_on_dst_with_other_send);
 
   nb_link = 0;
                        A_surfxml_route_impact_on_dst_with_other_send);
 
   nb_link = 0;
-  link_name = NULL;
+  link_list_capacity = 20;
+  link_list = xbt_new(network_link_KCCFLN05_t, link_list_capacity);
 }
 
 static void parse_route_elem(void)
 {
 }
 
 static void parse_route_elem(void)
 {
-  nb_link++;
-  link_name = xbt_realloc(link_name, (nb_link) * sizeof(char *));
-  link_name[(nb_link) - 1] = xbt_strdup(A_surfxml_route_element_name);
+  if (nb_link == link_list_capacity) {
+    link_list_capacity *= 2;
+    link_list = xbt_realloc(link_list, (link_list_capacity) * sizeof(network_link_KCCFLN05_t));
+  }
+  link_list[nb_link++] = xbt_dict_get_or_null(network_link_set, A_surfxml_route_element_name);
 }
 
 static void parse_route_set_route(void)
 {
 }
 
 static void parse_route_set_route(void)
 {
-  route_new(src_id, dst_id, link_name, nb_link, impact_on_src,
+  route_new(src_id, dst_id, link_list, nb_link, impact_on_src,
            impact_on_dst, impact_on_src_with_other_recv,
            impact_on_dst_with_other_send);
 }
            impact_on_dst, impact_on_src_with_other_recv,
            impact_on_dst_with_other_send);
 }
@@ -952,7 +949,7 @@ static void parse_file(const char *file)
     if(!ROUTE(i,i).size) {
       if(!loopback)
        loopback = network_link_new(xbt_strdup("__MSG_loopback__"), 
     if(!ROUTE(i,i).size) {
       if(!loopback)
        loopback = network_link_new(xbt_strdup("__MSG_loopback__"), 
-                                  498.00, NULL, 0.000015, NULL, 
+                                  498000000, NULL, 0.000015, NULL, 
                                   SURF_NETWORK_LINK_ON, NULL,
                                   SURF_NETWORK_LINK_FATPIPE);
       ROUTE(i,i).size=1;
                                   SURF_NETWORK_LINK_ON, NULL,
                                   SURF_NETWORK_LINK_FATPIPE);
       ROUTE(i,i).size=1;