Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Start handling the core attribute (store in cpu.c and yell everywhere else for now).
authoralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 2 Dec 2010 22:23:31 +0000 (22:23 +0000)
committeralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 2 Dec 2010 22:23:31 +0000 (22:23 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8937 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/include/surf/surf.h
src/surf/cpu.c
src/surf/cpu_im.c
src/surf/cpu_ti.c
src/surf/surfxml_parse.c

index 275b481..78317ba 100644 (file)
@@ -160,6 +160,7 @@ typedef struct surf_cpu_model_extension_public {
   void (*create_resource) (char *name, double power_peak,
                            double power_scale,
                            tmgr_trace_t power_trace,
+                           int core,
                            e_surf_resource_state_t state_initial,
                            tmgr_trace_t state_trace,
                            xbt_dict_t cpu_properties);
@@ -674,6 +675,7 @@ XBT_PUBLIC(double) get_cpu_power(const char *power);
 XBT_PUBLIC(void) surf_host_create_resource(char *name, double power_peak,
                                            double power_scale,
                                            tmgr_trace_t power_trace,
+                                           int core,
                                            e_surf_resource_state_t
                                            state_initial,
                                            tmgr_trace_t state_trace,
index 7feee6f..d900720 100644 (file)
@@ -13,6 +13,7 @@ typedef struct cpu_Cas01 {
   s_surf_resource_t generic_resource;
   double power_peak;
   double power_scale;
+  int core;
   tmgr_trace_event_t power_event;
   e_surf_resource_state_t state_current;
   tmgr_trace_event_t state_event;
@@ -34,6 +35,7 @@ static xbt_swag_t cpu_running_action_set_that_does_not_need_being_checked =
 static cpu_Cas01_t cpu_new(char *name, double power_peak,
                            double power_scale,
                            tmgr_trace_t power_trace,
+                           int core,
                            e_surf_resource_state_t state_initial,
                            tmgr_trace_t state_trace,
                            xbt_dict_t cpu_properties)
@@ -48,6 +50,8 @@ static cpu_Cas01_t cpu_new(char *name, double power_peak,
   cpu->power_peak = power_peak;
   xbt_assert0(cpu->power_peak > 0, "Power has to be >0");
   cpu->power_scale = power_scale;
+  cpu->core = core;
+  xbt_assert1(core>0,"Invalid number of cores %d",core);
   if (power_trace)
     cpu->power_event =
         tmgr_history_add_trace(history, power_trace, 0.0, 0, cpu);
@@ -75,6 +79,7 @@ static void parse_cpu_init(void)
 {
   double power_peak = 0.0;
   double power_scale = 0.0;
+  int core = 0;
   tmgr_trace_t power_trace = NULL;
   e_surf_resource_state_t state_initial = SURF_RESOURCE_OFF;
   tmgr_trace_t state_trace = NULL;
@@ -82,6 +87,7 @@ static void parse_cpu_init(void)
   power_peak = get_cpu_power(A_surfxml_host_power);
   surf_parse_get_double(&power_scale, A_surfxml_host_availability);
   power_trace = tmgr_trace_new(A_surfxml_host_availability_file);
+  surf_parse_get_int(&core, A_surfxml_host_core);
 
   xbt_assert0((A_surfxml_host_state == A_surfxml_host_state_ON) ||
               (A_surfxml_host_state == A_surfxml_host_state_OFF),
@@ -94,7 +100,7 @@ static void parse_cpu_init(void)
 
   current_property_set = xbt_dict_new();
   cpu_new(xbt_strdup(A_surfxml_host_id), power_peak, power_scale,
-          power_trace, state_initial, state_trace, current_property_set);
+          power_trace, core, state_initial, state_trace, current_property_set);
 
 }
 
@@ -399,11 +405,12 @@ static double cpu_get_available_speed(void *cpu)
 static void cpu_create_resource(char *name, double power_peak,
                                 double power_scale,
                                 tmgr_trace_t power_trace,
+                                int core,
                                 e_surf_resource_state_t state_initial,
                                 tmgr_trace_t state_trace,
                                 xbt_dict_t cpu_properties)
 {
-  cpu_new(name, power_peak, power_scale, power_trace,
+  cpu_new(name, power_peak, power_scale, power_trace, core,
           state_initial, state_trace, cpu_properties);
 }
 
index 699b59b..29af6df 100644 (file)
@@ -49,6 +49,7 @@ static xbt_swag_t
 static cpu_Cas01_im_t cpu_im_new(char *name, double power_peak,
                                  double power_scale,
                                  tmgr_trace_t power_trace,
+                                 int core,
                                  e_surf_resource_state_t state_initial,
                                  tmgr_trace_t state_trace,
                                  xbt_dict_t cpu_properties)
@@ -57,6 +58,7 @@ static cpu_Cas01_im_t cpu_im_new(char *name, double power_peak,
   s_surf_action_cpu_Cas01_im_t action;
   cpu = xbt_new0(s_cpu_Cas01_im_t, 1);
 
+  xbt_assert0(core==1,"Multi-core not handled with this model yet");
 #ifdef HAVE_TRACING
   TRACE_surf_host_declaration(name, power_scale * power_peak);
 #endif
@@ -95,6 +97,7 @@ static void parse_cpu_im_init(void)
 {
   double power_peak = 0.0;
   double power_scale = 0.0;
+  int core = 0;
   tmgr_trace_t power_trace = NULL;
   e_surf_resource_state_t state_initial = SURF_RESOURCE_OFF;
   tmgr_trace_t state_trace = NULL;
@@ -102,6 +105,7 @@ static void parse_cpu_im_init(void)
   power_peak = get_cpu_power(A_surfxml_host_power);
   surf_parse_get_double(&power_scale, A_surfxml_host_availability);
   power_trace = tmgr_trace_new(A_surfxml_host_availability_file);
+  surf_parse_get_int(&core, A_surfxml_host_core);
 
   xbt_assert0((A_surfxml_host_state == A_surfxml_host_state_ON) ||
               (A_surfxml_host_state == A_surfxml_host_state_OFF),
@@ -114,7 +118,7 @@ static void parse_cpu_im_init(void)
 
   current_property_set = xbt_dict_new();
   cpu_im_new(xbt_strdup(A_surfxml_host_id), power_peak, power_scale,
-             power_trace, state_initial, state_trace,
+             power_trace, core, state_initial, state_trace,
              current_property_set);
 
 }
@@ -540,11 +544,13 @@ static void cpu_im_action_update_index_heap(void *action, int i)
 static void cpu_im_create_resource(char *name, double power_peak,
                                    double power_scale,
                                    tmgr_trace_t power_trace,
+                                   int core,
                                    e_surf_resource_state_t state_initial,
                                    tmgr_trace_t state_trace,
                                    xbt_dict_t cpu_properties)
 {
-  cpu_im_new(name, power_peak, power_scale, power_trace,
+       xbt_assert0(core==1,"Multi-core not handled with this model yet");
+  cpu_im_new(name, power_peak, power_scale, power_trace, core,
              state_initial, state_trace, cpu_properties);
 }
 
index ef6de97..5408098 100644 (file)
@@ -147,6 +147,7 @@ static surf_cpu_ti_tgmr_t cpu_ti_parse_trace(tmgr_trace_t power_trace,
 static cpu_ti_t cpu_ti_new(char *name, double power_peak,
                            double power_scale,
                            tmgr_trace_t power_trace,
+                           int core,
                            e_surf_resource_state_t state_initial,
                            tmgr_trace_t state_trace,
                            xbt_dict_t cpu_properties)
@@ -158,6 +159,7 @@ static cpu_ti_t cpu_ti_new(char *name, double power_peak,
   xbt_assert1(!surf_model_resource_by_name(surf_cpu_model, name),
               "Host '%s' declared several times in the platform file",
               name);
+  xbt_assert0(core==1,"Multi-core not handled with this model yet");
   cpu->action_set =
       xbt_swag_new(xbt_swag_offset(ti_action, cpu_list_hookup));
   cpu->generic_resource.model = surf_cpu_model;
@@ -194,6 +196,7 @@ static void parse_cpu_ti_init(void)
 {
   double power_peak = 0.0;
   double power_scale = 0.0;
+  int core = 0;
   tmgr_trace_t power_trace = NULL;
   e_surf_resource_state_t state_initial = SURF_RESOURCE_OFF;
   tmgr_trace_t state_trace = NULL;
@@ -201,6 +204,7 @@ static void parse_cpu_ti_init(void)
   power_peak = get_cpu_power(A_surfxml_host_power);
   surf_parse_get_double(&power_scale, A_surfxml_host_availability);
   power_trace = tmgr_trace_new(A_surfxml_host_availability_file);
+  surf_parse_get_int(&core, A_surfxml_host_core);
 
   xbt_assert0((A_surfxml_host_state == A_surfxml_host_state_ON) ||
               (A_surfxml_host_state == A_surfxml_host_state_OFF),
@@ -213,7 +217,7 @@ static void parse_cpu_ti_init(void)
 
   current_property_set = xbt_dict_new();
   cpu_ti_new(xbt_strdup(A_surfxml_host_id), power_peak, power_scale,
-             power_trace, state_initial, state_trace,
+             power_trace, core, state_initial, state_trace,
              current_property_set);
 
 }
@@ -747,11 +751,13 @@ static double cpu_ti_get_available_speed(void *cpu)
 static void cpu_ti_create_resource(char *name, double power_peak,
                                    double power_scale,
                                    tmgr_trace_t power_trace,
+                                   int core,
                                    e_surf_resource_state_t state_initial,
                                    tmgr_trace_t state_trace,
                                    xbt_dict_t cpu_properties)
 {
-  cpu_ti_new(name, power_peak, power_scale, power_trace,
+       xbt_assert0(core==1,"Multi-core not handled with this model yet");
+  cpu_ti_new(name, power_peak, power_scale, power_trace, core,
              state_initial, state_trace, cpu_properties);
 }
 
index 4912d13..03e8b0a 100644 (file)
@@ -554,7 +554,7 @@ static void add_randomness(void)
  */
 void surf_host_create_resource(char *name, double power_peak,
                                double power_scale,
-                               tmgr_trace_t power_trace,
+                               tmgr_trace_t power_trace, int core,
                                e_surf_resource_state_t state_initial,
                                tmgr_trace_t state_trace,
                                xbt_dict_t cpu_properties)
@@ -562,6 +562,7 @@ void surf_host_create_resource(char *name, double power_peak,
   return surf_cpu_model->extension.cpu.create_resource(name, power_peak,
                                                        power_scale,
                                                        power_trace,
+                                                       core,
                                                        state_initial,
                                                        state_trace,
                                                        cpu_properties);