Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Handle FAT_PIPES.
[simgrid.git] / src / surf / workstation_ptask_L07.c
index 359a003..3e5a5de 100644 (file)
@@ -68,6 +68,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_workstation);
 static int nb_workstation = 0;
 static s_route_L07_t *routing_table = NULL;
 #define ROUTE(i,j) routing_table[(i)+(j)*nb_workstation]
+static network_link_L07_t loopback = NULL;
 static xbt_dict_t parallel_task_network_link_set = NULL;
 lmm_system_t ptask_maxmin_system = NULL;
 
@@ -357,26 +358,6 @@ static void finalize(void)
 /******* Resource Private    **********/
 /**************************************/
 
-static surf_action_t execute(void *cpu, double size)
-{
-  xbt_assert0(0,"This model does not implement plain computations");
-}
-
-static surf_action_t action_sleep(void *cpu, double duration)
-{
-  surf_action_workstation_L07_t action = NULL;
-
-  XBT_IN2("(%s,%g)",((cpu_L07_t)cpu)->name,duration);
-
-  action = (surf_action_workstation_L07_t) execute(cpu, 1.0);
-  action->generic_action.max_duration = duration;
-  action->suspended = 2;
-  lmm_update_variable_weight(ptask_maxmin_system, action->variable, 0.0);
-
-  XBT_OUT;
-  return (surf_action_t) action;
-}
-
 static e_surf_cpu_state_t resource_get_state(void *cpu)
 {
   return ((cpu_L07_t) cpu)->state_current;
@@ -392,11 +373,6 @@ static double get_available_speed(void *cpu)
   return ((cpu_L07_t) cpu)->power_current;
 }
 
-static surf_action_t communicate(void *src, void *dst, double size, double rate)
-{
-  xbt_assert0(0,"This model does not implement plain communications");
-}
-
 static surf_action_t execute_parallel_task(int workstation_nb,
                                           void **workstation_list, 
                                           double *computation_amount, 
@@ -488,6 +464,50 @@ static surf_action_t execute_parallel_task(int workstation_nb,
   return (surf_action_t) action;
 }
 
+static surf_action_t execute(void *cpu, double size)
+{
+  double val = 0.0;
+
+  return execute_parallel_task(1, &cpu, &size, &val, 1, -1);
+}
+
+static surf_action_t communicate(void *src, void *dst, double size, double rate)
+{
+  void **workstation_list = xbt_new0(void*,2);
+  double *computation_amount = xbt_new0(double,2);
+  double *communication_amount = xbt_new0(double,4);
+  surf_action_t res = NULL;
+
+  workstation_list[0]=src;
+  workstation_list[1]=src;
+  communication_amount[1] = size;
+
+  res = execute_parallel_task(2, workstation_list, 
+                             computation_amount, communication_amount,
+                             1, rate);
+  
+  free(computation_amount);
+  free(communication_amount);
+  free(workstation_list);
+
+  return res;
+}
+
+static surf_action_t action_sleep(void *cpu, double duration)
+{
+  surf_action_workstation_L07_t action = NULL;
+
+  XBT_IN2("(%s,%g)",((cpu_L07_t)cpu)->name,duration);
+
+  action = (surf_action_workstation_L07_t) execute(cpu, 1.0);
+  action->generic_action.max_duration = duration;
+  action->suspended = 2;
+  lmm_update_variable_weight(ptask_maxmin_system, action->variable, 0.0);
+
+  XBT_OUT;
+  return (surf_action_t) action;
+}
+
 /* returns an array of network_link_L07_t */
 static const void** get_route(void *src, void *dst) {
   cpu_L07_t card_src = src;
@@ -747,12 +767,15 @@ static void parse_file(const char *file)
   /* Adding loopback if needed */    
   for (i = 0; i < nb_workstation; i++) 
     if(!ROUTE(i,i).size) {
+      if(!loopback)
+       loopback = network_link_new(xbt_strdup("__MSG_loopback__"), 
+                                  498000000, NULL, 
+                                  SURF_NETWORK_LINK_ON, NULL,
+                                  SURF_NETWORK_LINK_FATPIPE);
+
       ROUTE(i,i).size=1;
       ROUTE(i,i).links = xbt_new0(network_link_L07_t, 1);
-      ROUTE(i,i).links[0] = network_link_new(xbt_strdup("__MSG_loopback__"), 
-                                  498000000, NULL,
-                                  SURF_NETWORK_LINK_ON, NULL,
-                                  SURF_NETWORK_LINK_SHARED);
+      ROUTE(i,i).links[0] = loopback;
     }
 }