Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add new callbacks to the Workstation's models, and define new lua methods to extend...
authorcoldpeace <coldpeace@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 4 Aug 2010 10:25:10 +0000 (10:25 +0000)
committercoldpeace <coldpeace@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 4 Aug 2010 10:25:10 +0000 (10:25 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8095 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/bindings/lua/simgrid_lua.c
src/config_unit.c
src/dict_unit.c
src/include/surf/surf.h
src/msg/deployment.c
src/surf/surfxml_parse.c
src/surf/workstation.c
src/surf/workstation_ptask_L07.c

index f7ba149..4b9ffd1 100644 (file)
@@ -10,6 +10,7 @@
 #include <lauxlib.h>
 #include <lualib.h>
 #include "msg/msg.h"
+#include "simdag/simdag.h"
 #include "xbt.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua,bindings,"Lua Bindings");
@@ -340,7 +341,9 @@ static xbt_dynar_t link_list_d ;
 static xbt_dynar_t route_list_d ;
 
 
-//create resource
+/**
+ * create host resource via CPU model [for MSG]
+ */
 
 static void create_host(const char* id,double power_peak,double power_sc,
                                                const char* power_tr,int state_init,
@@ -371,6 +374,39 @@ static void create_host(const char* id,double power_peak,double power_sc,
 
 }
 
+/*
+ *create host resource via workstation_ptask_L07 model [for SimDag]
+ */
+static void create_host_wsL07(const char* id,double power_peak,double power_sc,
+                                               const char* power_tr,int state_init,
+                                               const char* state_tr)
+{
+       double power_scale = 1.0;
+       tmgr_trace_t power_trace = NULL;
+       e_surf_resource_state_t state_initial;
+       tmgr_trace_t state_trace;
+       if(power_sc) // !=0
+               power_scale = power_sc;
+       if (state_init == -1)
+               state_initial = SURF_RESOURCE_OFF;
+       else
+               state_initial = SURF_RESOURCE_ON;
+       if(power_tr)
+               power_trace = tmgr_trace_new(power_tr);
+       else
+               power_trace = tmgr_trace_new("");
+       if(state_tr)
+               state_trace = tmgr_trace_new(state_tr);
+       else
+               state_trace = tmgr_trace_new("");
+       current_property_set = xbt_dict_new();
+       surf_wsL07_host_create_resource(xbt_strdup(id), power_peak, power_scale,
+                                              power_trace, state_initial, state_trace, current_property_set);
+
+}
+/*
+ * add new host to platform hosts list
+ */
 static int Host_new(lua_State *L)
 {
 
@@ -440,6 +476,9 @@ static int Host_new(lua_State *L)
     return 0;
 }
 
+/**
+ * add link to platform links list
+ */
 static int Link_new(lua_State *L) // (id,bandwidth,latency)
 {
        if(xbt_dynar_is_empty(link_list_d))
@@ -480,6 +519,9 @@ static int Link_new(lua_State *L) // (id,bandwidth,latency)
        return 0;
 }
 
+/**
+ * add route to platform routes list
+ */
 static int Route_new(lua_State *L) // (src_id,dest_id,links_number,link_table)
 {
        if(xbt_dynar_is_empty(route_list_d))
@@ -503,6 +545,9 @@ static int Route_new(lua_State *L) // (src_id,dest_id,links_number,link_table)
        return 0;
 }
 
+/**
+ * set function to process
+ */
 static int Host_set_function(lua_State *L) //(host,function,nb_args,list_args)
 {
        // look for the index of host in host_list
@@ -537,7 +582,9 @@ static int Host_set_function(lua_State *L) //(host,function,nb_args,list_args)
 
 /*
  * surf parse bypass platform
+ * through CPU/network Models
  */
+
 static int surf_parse_bypass_platform()
 {
        unsigned int i;
@@ -557,7 +604,7 @@ static int surf_parse_bypass_platform()
        //add Links
        xbt_dynar_foreach(link_list_d,i,p_link)
        {
-               surf_link_create_resouce((char*)p_link->id,p_link->bandwidth,p_link->latency);
+               surf_link_create_resource((char*)p_link->id,p_link->bandwidth,p_link->latency);
        }
        // add route
        xbt_dynar_foreach(route_list_d,i,p_route)
@@ -572,9 +619,51 @@ static int surf_parse_bypass_platform()
 
        return 0; // must return 0 ?!!
 
+}
+
+/**
+ *
+ * surf parse bypass platform
+ * through workstation_ptask_L07 Model
+ */
+
+
+static int surf_wsL07_parse_bypass_platform()
+{
+       unsigned int i;
+       p_host_attr p_host;
+       p_link_attr p_link;
+       p_route_attr p_route;
+
+       // Add Hosts
+       xbt_dynar_foreach(host_list_d,i,p_host)
+       {
+               create_host_wsL07(p_host->id,p_host->power_peak,p_host->power_scale,p_host->power_trace,
+                                       p_host->state_initial,p_host->state_trace);
+               //add to routing model host list
+               surf_route_add_host((char*)p_host->id);
+       }
+
+       //add Links
+       xbt_dynar_foreach(link_list_d,i,p_link)
+       {
+               surf_wsL07_link_create_resource((char*)p_link->id,p_link->bandwidth,p_link->latency);
+       }
+       // add route
+       xbt_dynar_foreach(route_list_d,i,p_route)
+       {
+               surf_route_set_resource((char*)p_route->src_id,(char*)p_route->dest_id,p_route->links_id,0);
+       }
+       /* </platform> */
+
+       surf_wsL07_add_traces();
+       surf_set_routes();
+
+       return 0;
+
 }
 /*
- * surf parse bypass application
+ * surf parse bypass application for MSG Module
  */
 static int surf_parse_bypass_application()
 {
@@ -715,7 +804,11 @@ static int clean(lua_State *L) {
 /*
  * Bypass XML Parser
  */
-static int register_platform(lua_State *L)
+
+/*
+ * Register platform for MSG
+ */
+static int msg_register_platform(lua_State *L)
 {
        /* Tell Simgrid we dont wanna use its parser*/
        surf_parse = surf_parse_bypass_platform;
@@ -723,7 +816,20 @@ static int register_platform(lua_State *L)
        return 0;
 }
 
-static int register_application(lua_State *L)
+/*
+ * Register platform for Simdag
+ */
+
+static int sd_register_platform(lua_State *L)
+{
+       surf_parse = surf_wsL07_parse_bypass_platform;
+       SD_create_environment(NULL);
+       return 0;
+}
+/**
+ * Register applicaiton for MSG
+ */
+static int msg_register_application(lua_State *L)
 {
         MSG_function_register_default(run_lua_code);
         surf_parse = surf_parse_bypass_application;
@@ -742,8 +848,9 @@ static const luaL_Reg simgrid_funcs[] = {
     { "platform", create_environment},
     { "application", launch_application},
     /* methods to bypass XML parser*/
-    { "register_platform",register_platform},
-    { "register_application",register_application},
+    { "msg_register_platform",msg_register_platform},
+    { "sd_register_platform",sd_register_platform},
+    { "msg_register_application",msg_register_application},
     { NULL, NULL }
 };
 
index f8f3584..3469166 100644 (file)
@@ -15,6 +15,7 @@
 XBT_LOG_EXTERNAL_CATEGORY(xbt_cfg);
 XBT_LOG_DEFAULT_CATEGORY(xbt_cfg);
 
+
 static xbt_cfg_t make_set()
 {
   xbt_cfg_t set = NULL;
index fa125dd..4ca205f 100644 (file)
@@ -16,6 +16,7 @@
 XBT_LOG_EXTERNAL_CATEGORY(xbt_dict);
 XBT_LOG_DEFAULT_CATEGORY(xbt_dict);
 
+
 static void print_str(void *str)
 {
   printf("%s", (char *) PRINTF_STR(str));
index e39025e..63aa9fa 100644 (file)
@@ -35,11 +35,13 @@ XBT_PUBLIC(void *) surf_action_new(size_t size, double cost,
                                    surf_model_t model, int failed);
 
 /**
- * FIXME : this should be done in the binding code !!
+ * FIXME : still improvaleb [this should be done in the binding code]
  */
 XBT_PUBLIC(void) network_create_resource(char *name,
         double initial_bandwidth,double initial_latency);
 
+XBT_PUBLIC(void) workstation_link_create_resource(char *name,
+        double initial_bandwidth,double initial_latency);
 
 /** \brief Resource model description
  */
@@ -212,7 +214,15 @@ XBT_PUBLIC_DATA(routing_t) used_routing;
        double (*get_link_bandwidth) (const void *link);                                    /**< Return the current bandwidth of a network link */
        double (*get_link_latency) (const void *link);                                      /**< Return the current latency of a network link */
        int (*link_shared) (const void *link);
-         xbt_dict_t(*get_properties) (const void *resource);
+       xbt_dict_t(*get_properties) (const void *resource);
+       void (*link_create_resource) (char *name,double bw_initial,double lat_initial);
+       void (*cpu_create_resource)(char *name, double power_peak,
+                      double power_scale,
+                      tmgr_trace_t power_trace,
+                      e_surf_resource_state_t state_initial,
+                      tmgr_trace_t state_trace,
+                      xbt_dict_t cpu_properties);
+       void (*add_traces) (void);
      } s_surf_model_extension_workstation_t;
 
 /** \brief Model datatype
@@ -247,11 +257,9 @@ XBT_PUBLIC_DATA(routing_t) used_routing;
        xbt_dict_t resource_set;
 
 
-
        surf_model_private_t model_private;
 
 
-
        union extension {
          s_surf_model_extension_timer_t timer;
          s_surf_model_extension_cpu_t cpu;
@@ -337,11 +345,6 @@ XBT_PUBLIC(void) surf_cpu_model_init_ti(const char *filename);
  */
 XBT_PUBLIC(void) surf_cpu_model_init_Cas01_im(const char *filename);
 
-/**brief Initialise the cpu_im model bypassing the parser
- *
- */
-XBT_PUBLIC(void) surf_cpu_model_init_bypass_im(const char*id,double power);
-
 /** \brief The list of all available cpu model models
  *  \ingroup SURF_models
  */
@@ -667,14 +670,27 @@ XBT_PUBLIC(void) surf_host_create_resource(char *name, double power_peak,
         tmgr_trace_t state_trace,
         xbt_dict_t cpu_properties);
 
+/*public interface to create resource bypassing the parser via workstation_ptask_L07 model
+ *
+ * see surfxml_parse.c
+ * */
+XBT_PUBLIC(void) surf_wsL07_host_create_resource(char *name, double power_peak,
+        double power_scale,
+        tmgr_trace_t power_trace,
+        e_surf_resource_state_t state_initial,
+        tmgr_trace_t state_trace,
+        xbt_dict_t cpu_properties);
 /**
  * create link resource
- * see network.c
+ * see surfxml_parse.c
  * FIXME : shoudl have the same prototype as net_link_new
  */
-XBT_PUBLIC(void) surf_link_create_resouce(char *name,
+XBT_PUBLIC(void) surf_link_create_resource(char *name,
         double bw_initial,double lat_initial);
 
+
+XBT_PUBLIC(void) surf_wsL07_link_create_resource(char *name,
+        double bw_initial,double lat_initial);
 /**
  * add route element (link_ctn) bypassing the parser
  *
@@ -686,7 +702,7 @@ XBT_PUBLIC(void) surf_add_route_element(char *link_ctn_id);
 /**
  * set route src_id,dest_id, and create a route resource
  *
- * see surf_routing.c
+ * see surf_routing.c && surfxml_parse.c
  */
 XBT_PUBLIC(void) surf_route_set_resource(char* src_id,char *dest_id,xbt_dynar_t links_id,int action);
 XBT_PUBLIC(void) surf_set_routes(void);
@@ -696,12 +712,13 @@ XBT_PUBLIC(void) surf_set_routes(void);
  */
 XBT_PUBLIC(void) surf_route_add_host(char * host_id);
 
-
 /**
  * add traces
+ * see surfxml_parse.c
  */
 XBT_PUBLIC(void) surf_add_host_traces(void);
 XBT_PUBLIC(void) surf_add_link_traces(void);
+XBT_PUBLIC(void) surf_wsL07_add_traces(void);
 
 #include "surf/surf_resource.h"
 #include "surf/surf_resource_lmm.h"
index 01b9c9e..984792c 100644 (file)
@@ -8,7 +8,6 @@
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
 
-
 /** \ingroup msg_easier_life
  * \brief An application deployer.
  *
index 0556aa7..933996d 100644 (file)
@@ -709,7 +709,6 @@ static void parse_host_foreach(void){
   const char *surfxml_host_availability_file = A_surfxml_host_availability_file;
   const char *surfxml_host_state_file = A_surfxml_host_state_file;
 
-
   xbt_dict_t cluster_host_props = current_property_set;
 
   names = xbt_dict_get_or_null(set_list, foreach_set_name);
@@ -1167,6 +1166,9 @@ static void add_randomness(void)
   xbt_dict_set(random_data_list, random_id, (void *) random, NULL);
 }
 
+/**
+ * create CPU resource via CPU Model
+ */
 void surf_host_create_resource(char *name, double power_peak,
         double power_scale,
         tmgr_trace_t power_trace,
@@ -1178,8 +1180,24 @@ void surf_host_create_resource(char *name, double power_peak,
                create_resource(name,power_peak,power_scale,power_trace,state_initial,state_trace,cpu_properties);
 }
 
+/*
+ * create CPU resource via worsktation_ptask_L07 model
+ */
 
-void surf_link_create_resouce(char *name,
+void surf_wsL07_host_create_resource(char *name, double power_peak,
+        double power_scale,
+        tmgr_trace_t power_trace,
+        e_surf_resource_state_t state_initial,
+        tmgr_trace_t state_trace,
+        xbt_dict_t cpu_properties)
+{
+       surf_workstation_model->extension.workstation.
+               cpu_create_resource(name,power_peak,power_scale,power_trace,state_initial,state_trace,cpu_properties);
+}
+/*
+ * create link resource via network Model
+ */
+void surf_link_create_resource(char *name,
         double bw_initial,
         double lat_initial)
 {
@@ -1188,6 +1206,19 @@ void surf_link_create_resouce(char *name,
 
 }
 
+/*
+ * create link resource via workstation_ptask_L07 model
+ */
+
+void surf_wsL07_link_create_resource(char *name,
+        double bw_initial,
+        double lat_initial)
+{
+       return surf_workstation_model->extension.workstation.
+       link_create_resource(name,bw_initial,lat_initial);
+}
+
+
 /**
  * Route: add route element bypassing the parser :
  * same job as parse_route_elem
@@ -1231,6 +1262,12 @@ void surf_add_link_traces(void)
        return surf_network_model->extension.network.
                         add_traces();
 }
+
+void surf_wsL07_add_traces(void)
+{
+       return surf_workstation_model->extension.workstation.
+                       add_traces();
+}
 /**
  * set routes
  */
@@ -1238,3 +1275,4 @@ void surf_set_routes(void)
 {
        routing_set_routes();
 }
+
index 5200b00..d0232b2 100644 (file)
@@ -51,6 +51,21 @@ void create_workstations(void)
   }
 }
 
+static void ws_cpu_create_resource(char *name, double power_peak,
+        double power_scale,
+        tmgr_trace_t power_trace,
+        e_surf_resource_state_t state_initial,
+        tmgr_trace_t state_trace,
+        xbt_dict_t cpu_properties)
+{
+       THROW_UNIMPLEMENTED;
+}
+
+static void ws_link_create_resource(char *name,double bw_initial,double lat_initial)
+{
+       THROW_UNIMPLEMENTED;
+}
+
 static int ws_resource_used(void *resource_id)
 {
   THROW_IMPOSSIBLE;             /* This model does not implement parallel tasks */
@@ -310,6 +325,10 @@ static void surf_workstation_model_init_internal(void)
   surf_workstation_model->extension.workstation.link_shared = ws_link_shared;
   surf_workstation_model->extension.workstation.get_properties =
     ws_get_properties;
+  surf_workstation_model->extension.workstation.link_create_resource =
+    ws_link_create_resource;
+  surf_workstation_model->extension.workstation.cpu_create_resource =
+       ws_cpu_create_resource;
 }
 
 /********************************************************************/
index 7fbc8e9..bd50678 100644 (file)
@@ -664,6 +664,17 @@ static void ptask_parse_cpu_init(void)
           state_initial, state_trace, current_property_set);
 }
 
+static void ptask_cpu_create_resource(char *name, double power_peak,
+        double power_scale,
+        tmgr_trace_t power_trace,
+        e_surf_resource_state_t state_initial,
+        tmgr_trace_t state_trace,
+        xbt_dict_t cpu_properties)
+{
+       ptask_cpu_new(xbt_strdup(name),power_peak,power_scale,power_trace,
+                                         state_initial,state_trace,cpu_properties);
+}
+
 static link_L07_t ptask_link_new(char *name,
                            double bw_initial,
                            tmgr_trace_t bw_trace,
@@ -748,6 +759,38 @@ static void ptask_parse_link_init(void)
            current_property_set);
 }
 
+/**
+ * FIXME : still improvable
+ */
+void workstation_link_create_resource(char *name,
+        double initial_bandwidth,double initial_latency)
+{
+
+       char* name_link;
+       double bw_initial;
+       tmgr_trace_t bw_trace;
+       double lat_initial;
+       tmgr_trace_t lat_trace;
+       e_surf_resource_state_t state_initial_link = SURF_RESOURCE_ON;
+       e_surf_link_sharing_policy_t policy_initial_link = SURF_LINK_SHARED;
+       tmgr_trace_t state_trace;
+
+       name_link = xbt_strdup(name);
+       bw_initial = initial_bandwidth;
+       bw_trace = tmgr_trace_new("");
+       lat_initial = initial_latency;
+       lat_trace = tmgr_trace_new("");
+       // FIXME Hard Coded Values
+       //state_initial_link = SURF_RESOURCE_ON;
+       //policy_initial_link = SURF_LINK_SHARED;
+       state_trace = tmgr_trace_new("");
+
+       ptask_link_new(name_link, bw_initial, bw_trace,
+                  lat_initial, lat_trace, state_initial_link, state_trace,
+                  policy_initial_link, xbt_dict_new());
+}
+
+
 static void ptask_add_traces(void)
 {
   xbt_dict_cursor_t cursor = NULL;
@@ -821,7 +864,6 @@ static void ptask_define_callbacks(const char *file)
   surfxml_add_callback(ETag_surfxml_platform_cb_list, &ptask_add_traces);
 }
 
-
 /**************************************/
 /********* Module  creation ***********/
 /**************************************/
@@ -849,6 +891,7 @@ static void ptask_model_init_internal(void)
     ptask_update_resource_state;
   surf_workstation_model->model_private->finalize = ptask_finalize;
 
+
   surf_workstation_model->extension.workstation.execute = ptask_execute;
   surf_workstation_model->extension.workstation.sleep = ptask_action_sleep;
   surf_workstation_model->extension.workstation.get_state =
@@ -867,7 +910,12 @@ static void ptask_model_init_internal(void)
   surf_workstation_model->extension.workstation.link_shared = ptask_link_shared;
   surf_workstation_model->extension.workstation.get_properties =
     surf_resource_properties;
-
+  //FIXME
+  /*surf_workstation_model->extension.workstation.link_create_resource =
+       workstation_link_create_resource;
+  surf_workstation_model->extension.workstation.cpu_create_resource =
+       ptask_cpu_create_resource;
+  surf_workstation_model->extension.workstation.add_traces = ptask_add_traces;*/
 
   if (!ptask_maxmin_system)
     ptask_maxmin_system = lmm_system_new();
@@ -885,6 +933,7 @@ static void ptask_model_init_internal(void)
 /**************************************/
 void surf_workstation_model_init_ptask_L07(const char *filename)
 {
+  INFO0("surf_workstation_model_init_ptask_L07");
   xbt_assert0(!surf_cpu_model, "CPU model type already defined");
   xbt_assert0(!surf_network_model, "network model type already defined");
   surf_network_model = surf_model_init();