#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");
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,
}
+/*
+ *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)
{
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))
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))
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
/*
* surf parse bypass platform
+ * through CPU/network Models
*/
+
static int surf_parse_bypass_platform()
{
unsigned int i;
//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)
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()
{
/*
* 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;
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;
{ "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 }
};
XBT_LOG_EXTERNAL_CATEGORY(xbt_cfg);
XBT_LOG_DEFAULT_CATEGORY(xbt_cfg);
+
static xbt_cfg_t make_set()
{
xbt_cfg_t set = NULL;
XBT_LOG_EXTERNAL_CATEGORY(xbt_dict);
XBT_LOG_DEFAULT_CATEGORY(xbt_dict);
+
static void print_str(void *str)
{
printf("%s", (char *) PRINTF_STR(str));
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
*/
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
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;
*/
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
*/
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
*
/**
* 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);
*/
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"
#include "xbt/sysdep.h"
#include "xbt/log.h"
-
/** \ingroup msg_easier_life
* \brief An application deployer.
*
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);
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,
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)
{
}
+/*
+ * 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
return surf_network_model->extension.network.
add_traces();
}
+
+void surf_wsL07_add_traces(void)
+{
+ return surf_workstation_model->extension.workstation.
+ add_traces();
+}
/**
* set routes
*/
{
routing_set_routes();
}
+
}
}
+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 */
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;
}
/********************************************************************/
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,
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;
surfxml_add_callback(ETag_surfxml_platform_cb_list, &ptask_add_traces);
}
-
/**************************************/
/********* Module creation ***********/
/**************************************/
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 =
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();
/**************************************/
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();