/* Hook for the different tags. All the functions which pointer to are push into here are run when the tag is encountered */
XBT_PUBLIC_DATA(xbt_dynar_t) STag_surfxml_platform_cb_list;
XBT_PUBLIC_DATA(xbt_dynar_t) ETag_surfxml_platform_cb_list;
-XBT_PUBLIC_DATA(xbt_dynar_t) STag_surfxml_host_cb_list;
XBT_PUBLIC_DATA(xbt_dynar_t) ETag_surfxml_host_cb_list;
XBT_PUBLIC_DATA(xbt_dynar_t) STag_surfxml_router_cb_list;
XBT_PUBLIC_DATA(xbt_dynar_t) ETag_surfxml_router_cb_list;
typedef struct s_surf_parsing_host_arg *surf_parsing_host_arg_t;
typedef struct s_surf_parsing_host_arg {
- char* V_host_id; //id
- double V_host_power_peak; //power
- int V_host_core; //core
- double V_host_power_scale; //availability
- tmgr_trace_t V_host_power_trace; //availability file
- e_surf_resource_state_t V_host_state_initial; //state
- tmgr_trace_t V_host_state_trace; //state file
+ char* V_host_id; //id
+ double V_host_power_peak; //power
+ int V_host_core; //core
+ double V_host_power_scale; //availability
+ tmgr_trace_t V_host_power_trace; //availability file
+ e_surf_resource_state_t V_host_state_initial; //state
+ tmgr_trace_t V_host_state_trace; //state file
const char* V_host_coord;
} s_surf_parsing_host_arg_t;
-extern surf_parsing_host_arg_t struct_host;
-extern surf_parsing_router_arg_t struct_router;
-extern surf_parsing_cluster_arg_t struct_cluster;
-extern surf_parsing_peer_arg_t struct_peer;
-extern surf_parsing_link_arg_t struct_lnk;
-
typedef struct s_surf_parsing_link_up_down *surf_parsing_link_up_down_t;
typedef struct s_surf_parsing_link_up_down {
void* link_up;
void* link_down;
} s_surf_parsing_link_up_down_t;
-void surf_parse_host(void);
+
+typedef void (*surf_parse_host_fct_t)(surf_parsing_host_arg_t);
+void surf_parse_host_add_cb(surf_parse_host_fct_t);
+
+extern surf_parsing_router_arg_t struct_router;
+extern surf_parsing_cluster_arg_t struct_cluster;
+extern surf_parsing_peer_arg_t struct_peer;
+extern surf_parsing_link_arg_t struct_lnk;
+
+void surf_parse_host(surf_parsing_host_arg_t h);
void surf_parse_link(void);
#endif /* SURFXML_PARSE_VALUES_H_ */
xbt_dynar_free (&links_to_create);
}
-static void instr_routing_parse_start_host ()
+static void instr_routing_parse_start_host (surf_parsing_host_arg_t host)
{
container_t father = *(container_t*)xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1);
- container_t new = newContainer (struct_host->V_host_id, INSTR_HOST, father);
+ container_t new = newContainer (host->V_host_id, INSTR_HOST, father);
if (TRACE_categorized() || TRACE_uncategorized()) {
type_t power = getVariableType ("power", NULL, new->type);
- new_pajeSetVariable (0, new, power, struct_host->V_host_power_peak);
+ new_pajeSetVariable (0, new, power, host->V_host_power_peak);
}
if (TRACE_uncategorized()){
getVariableType ("power_used", "0.5 0.5 0.5", new->type);
surfxml_add_callback(ETag_surfxml_AS_cb_list, &instr_routing_parse_end_AS);
if (!TRACE_needs_platform()) return;
surfxml_add_callback(STag_surfxml_link_cb_list, &instr_routing_parse_start_link);
- surfxml_add_callback(STag_surfxml_host_cb_list, &instr_routing_parse_start_host);
+ surf_parse_host_add_cb(instr_routing_parse_start_host);
surfxml_add_callback(STag_surfxml_router_cb_list, &instr_routing_parse_start_router);
surfxml_add_callback(ETag_surfxml_platform_cb_list, &instr_routing_parse_end_platform);
}
}
-static void parse_cpu_init(void)
+static void parse_cpu_init(surf_parsing_host_arg_t host)
{
- if(strcmp(struct_host->V_host_coord,"")) xbt_die("Coordinates not implemented yet!");
-
- cpu_create_resource(struct_host->V_host_id,
- struct_host->V_host_power_peak,
- struct_host->V_host_power_scale,
- struct_host->V_host_power_trace,
- struct_host->V_host_core,
- struct_host->V_host_state_initial,
- struct_host->V_host_state_trace,
+ if(strcmp(host->V_host_coord,"")) xbt_die("Coordinates not implemented yet!");
+
+ cpu_create_resource(host->V_host_id,
+ host->V_host_power_peak,
+ host->V_host_power_scale,
+ host->V_host_power_trace,
+ host->V_host_core,
+ host->V_host_state_initial,
+ host->V_host_state_trace,
current_property_set);
current_property_set = NULL;
}
static void cpu_define_callbacks(void)
{
- surfxml_add_callback(ETag_surfxml_host_cb_list, parse_cpu_init);
+ surf_parse_host_add_cb(parse_cpu_init);
surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_traces_cpu);
}
}
-static void parse_cpu_im_init(void)
+static void parse_cpu_im_init(surf_parsing_host_arg_t host)
{
- cpu_im_create_resource(struct_host->V_host_id,
- struct_host->V_host_power_peak,
- struct_host->V_host_power_scale,
- struct_host->V_host_power_trace,
- struct_host->V_host_core,
- struct_host->V_host_state_initial,
- struct_host->V_host_state_trace,
+ cpu_im_create_resource(host->V_host_id,
+ host->V_host_power_peak,
+ host->V_host_power_scale,
+ host->V_host_power_trace,
+ host->V_host_core,
+ host->V_host_state_initial,
+ host->V_host_state_trace,
current_property_set);
current_property_set = NULL;
}
static void cpu_im_define_callbacks()
{
- surfxml_add_callback(ETag_surfxml_host_cb_list, parse_cpu_im_init);
+ surf_parse_host_add_cb(parse_cpu_im_init);
surfxml_add_callback(ETag_surfxml_platform_cb_list,
&cpu_im_add_traces_cpu);
}
}
-static void parse_cpu_ti_init(void)
+static void parse_cpu_ti_init(surf_parsing_host_arg_t host)
{
- cpu_ti_create_resource(struct_host->V_host_id,
- struct_host->V_host_power_peak,
- struct_host->V_host_power_scale,
- struct_host->V_host_power_trace,
- struct_host->V_host_core,
- struct_host->V_host_state_initial,
- struct_host->V_host_state_trace,
+ cpu_ti_create_resource(host->V_host_id,
+ host->V_host_power_peak,
+ host->V_host_power_scale,
+ host->V_host_power_trace,
+ host->V_host_core,
+ host->V_host_state_initial,
+ host->V_host_state_trace,
current_property_set);
current_property_set = NULL;
static void cpu_ti_define_callbacks()
{
- surfxml_add_callback(ETag_surfxml_host_cb_list, parse_cpu_ti_init);
+ surf_parse_host_add_cb(parse_cpu_ti_init);
surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_traces_cpu_ti);
}
static random_data_t random_latency = NULL;
static int host_number_int = 0;
-static void netcste_count_hosts(void)
+static void netcste_count_hosts(surf_parsing_host_arg_t h)
{
host_number_int++;
}
static void netcste_define_callbacks(void)
{
- surfxml_add_callback(STag_surfxml_host_cb_list, &netcste_count_hosts);
+ surf_parse_host_add_cb(netcste_count_hosts);
}
static int netcste_resource_used(void *resource_id)
/*
* \brief Add a host to the network element list from XML
*/
-static void parse_S_host_XML(void)
+static void parse_S_host_XML(surf_parsing_host_arg_t h)
{
-// XBT_INFO("parse_S_host_XML");
-// XBT_INFO("'%s' '%s'",struct_host->V_host_id, struct_host->V_host_coord);
- parse_S_host(struct_host->V_host_id, struct_host->V_host_coord);
+ parse_S_host(h->V_host_id, h->V_host_coord);
}
static void parse_E_host_XML(void)
{
current_routing = NULL;
/* parse generic elements */
- surfxml_add_callback(STag_surfxml_host_cb_list, &parse_S_host_XML);
+ surf_parse_host_add_cb(parse_S_host_XML);
surfxml_add_callback(ETag_surfxml_host_cb_list, &parse_E_host_XML);
surfxml_add_callback(STag_surfxml_router_cb_list, &parse_S_router_XML);
static void parse_create_host_link(int i)
{
char *host_id, *link_id = NULL;
+ s_surf_parsing_host_arg_t host;
+ memset(&host,0,sizeof(host));
host_id = bprintf("%s%d%s", struct_cluster->V_cluster_prefix, i, struct_cluster->V_cluster_suffix);
link_id = bprintf("%s_link_%d", struct_cluster->V_cluster_id, i);
A_surfxml_host_state = A_surfxml_host_state_ON;
XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%f\">", host_id, struct_cluster->S_cluster_power);
- struct_host = xbt_new0(s_surf_parsing_host_arg_t, 1);
- struct_host->V_host_id = xbt_strdup(host_id);
+ host.V_host_id = xbt_strdup(host_id);
if(strcmp(struct_cluster->V_cluster_availability_file,"")){
xbt_dict_set(patterns, "radical", bprintf("%d", i), xbt_free);
char* tmp_availability_file = xbt_strdup(struct_cluster->V_cluster_availability_file);
xbt_str_varsubst(tmp_availability_file,patterns);
XBT_DEBUG("\tavailability_file=\"%s\"",tmp_availability_file);
- struct_host->V_host_power_trace = tmgr_trace_new(tmp_availability_file);
+ host.V_host_power_trace = tmgr_trace_new(tmp_availability_file);
xbt_free(tmp_availability_file);
}
else
char *tmp_state_file = xbt_strdup(struct_cluster->V_cluster_state_file);
xbt_str_varsubst(tmp_state_file,patterns);
XBT_DEBUG("\tstate_file=\"%s\"",tmp_state_file);
- struct_host->V_host_state_trace = tmgr_trace_new(tmp_state_file);
+ host.V_host_state_trace = tmgr_trace_new(tmp_state_file);
xbt_free(tmp_state_file);
}
else
XBT_DEBUG("\tstate_file=\"\"");
}
- struct_host->V_host_power_peak = struct_cluster->S_cluster_power;
- struct_host->V_host_power_scale = 1.0;
- struct_host->V_host_core = struct_cluster->S_cluster_core;
- struct_host->V_host_state_initial = SURF_RESOURCE_ON;
- struct_host->V_host_coord = "";
- surf_parse_host();
+ host.V_host_power_peak = struct_cluster->S_cluster_power;
+ host.V_host_power_scale = 1.0;
+ host.V_host_core = struct_cluster->S_cluster_core;
+ host.V_host_state_initial = SURF_RESOURCE_ON;
+ host.V_host_coord = "";
+ surf_parse_host(&host);
XBT_DEBUG("</host>");
A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED;
static int AX_ptr = 0;
char *host_id, *groups, *link_id = NULL;
+ s_surf_parsing_host_arg_t host;
+
if( strcmp(struct_cluster->V_cluster_availability_file,"")
|| strcmp(struct_cluster->V_cluster_state_file,"") )
{
//Make all hosts
radical_elements = xbt_str_split(struct_cluster->V_cluster_radical, ",");
xbt_dynar_foreach(radical_elements, iter, groups) {
+ memset(&host,0,sizeof(host));
+
radical_ends = xbt_str_split(groups, "-");
switch (xbt_dynar_length(radical_ends)) {
case 1:
link_id = bprintf("%s_link_%d", struct_cluster->V_cluster_id, start);
XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%f\">", host_id, struct_cluster->S_cluster_power);
- struct_host = xbt_new0(s_surf_parsing_host_arg_t, 1);
- struct_host->V_host_id = host_id;
+ host.V_host_id = host_id;
if(strcmp(struct_cluster->V_cluster_availability_file,"")){
xbt_dict_set(patterns, "radical", bprintf("%d", start), xbt_free);
char* tmp_availability_file = xbt_strdup(struct_cluster->V_cluster_availability_file);
xbt_str_varsubst(tmp_availability_file,patterns);
XBT_DEBUG("\tavailability_file=\"%s\"",tmp_availability_file);
- struct_host->V_host_power_trace = tmgr_trace_new(tmp_availability_file);
+ host.V_host_power_trace = tmgr_trace_new(tmp_availability_file);
xbt_free(tmp_availability_file);
}
else
char *tmp_state_file = xbt_strdup(struct_cluster->V_cluster_state_file);
xbt_str_varsubst(tmp_state_file,patterns);
XBT_DEBUG("\tstate_file=\"%s\"",tmp_state_file);
- struct_host->V_host_state_trace = tmgr_trace_new(tmp_state_file);
+ host.V_host_state_trace = tmgr_trace_new(tmp_state_file);
xbt_free(tmp_state_file);
}
else
XBT_DEBUG("\tstate_file=\"\"");
}
- struct_host->V_host_power_peak = struct_cluster->S_cluster_power;
- struct_host->V_host_power_scale = 1.0;
- struct_host->V_host_core = struct_cluster->S_cluster_core;
- struct_host->V_host_state_initial = SURF_RESOURCE_ON;
- struct_host->V_host_coord = "";
- surf_parse_host();
+ host.V_host_power_peak = struct_cluster->S_cluster_power;
+ host.V_host_power_scale = 1.0;
+ host.V_host_core = struct_cluster->S_cluster_core;
+ host.V_host_state_initial = SURF_RESOURCE_ON;
+ host.V_host_coord = "";
+ surf_parse_host(&host);
XBT_DEBUG("</host>");
A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED;
A_surfxml_host_state = A_surfxml_host_state_ON;
XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%f\">", host_id, struct_cluster->S_cluster_power);
- struct_host = xbt_new0(s_surf_parsing_host_arg_t, 1);
- struct_host->V_host_id = host_id;
+ host.V_host_id = host_id;
if(strcmp(struct_cluster->V_cluster_availability_file,"")){
xbt_dict_set(patterns, "radical", bprintf("%d", i), xbt_free);
char* tmp_availability_file = xbt_strdup(struct_cluster->V_cluster_availability_file);
xbt_str_varsubst(tmp_availability_file,patterns);
XBT_DEBUG("\tavailability_file=\"%s\"",tmp_availability_file);
- struct_host->V_host_power_trace = tmgr_trace_new(tmp_availability_file);
+ host.V_host_power_trace = tmgr_trace_new(tmp_availability_file);
xbt_free(tmp_availability_file);
}
else
char *tmp_state_file = xbt_strdup(struct_cluster->V_cluster_state_file);
xbt_str_varsubst(tmp_state_file,patterns);
XBT_DEBUG("\tstate_file=\"%s\"",tmp_state_file);
- struct_host->V_host_state_trace = tmgr_trace_new(tmp_state_file);
+ host.V_host_state_trace = tmgr_trace_new(tmp_state_file);
xbt_free(tmp_state_file);
}
else
XBT_DEBUG("\tstate_file=\"\"");
}
- struct_host->V_host_power_peak = struct_cluster->S_cluster_power;
- struct_host->V_host_power_scale = 1.0;
- struct_host->V_host_core = struct_cluster->S_cluster_core;
- struct_host->V_host_state_initial = SURF_RESOURCE_ON;
- struct_host->V_host_coord = "";
- surf_parse_host();
+ host.V_host_power_peak = struct_cluster->S_cluster_power;
+ host.V_host_power_scale = 1.0;
+ host.V_host_core = struct_cluster->S_cluster_core;
+ host.V_host_state_initial = SURF_RESOURCE_ON;
+ host.V_host_coord = "";
+ surf_parse_host(&host);
XBT_DEBUG("</host>");
A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED;
xbt_dynar_t links_list = xbt_dynar_new(global_routing->size_of_link, NULL);
- char *link_src,*link_bb,*link_dst,*link_src_up,*link_dst_down;
surf_parsing_link_up_down_t info;
info = xbt_dict_get_or_null(cluster_host_link,src);
*/
/* make sure these symbols are defined as strong ones in this file so that the linker can resolve them */
+//xbt_dynar_t STag_surfxml_host_cb_list = NULL;
+xbt_dynar_t surf_parse_host_cb_list = NULL; // of functions of type: surf_parsing_host_arg_t -> void
xbt_dynar_t STag_surfxml_platform_cb_list = NULL;
xbt_dynar_t ETag_surfxml_platform_cb_list = NULL;
-xbt_dynar_t STag_surfxml_host_cb_list = NULL;
xbt_dynar_t ETag_surfxml_host_cb_list = NULL;
xbt_dynar_t STag_surfxml_router_cb_list = NULL;
xbt_dynar_t ETag_surfxml_router_cb_list = NULL;
xbt_dynar_new(sizeof(void_f_void_t), NULL);
ETag_surfxml_platform_cb_list =
xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_host_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+
+ surf_parse_host_cb_list = xbt_dynar_new(sizeof(surf_parse_host_fct_t), NULL);
+
ETag_surfxml_host_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
STag_surfxml_router_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
ETag_surfxml_router_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
void surf_parse_free_callbacks(void)
{
+ xbt_dynar_free(&surf_parse_host_cb_list);
+
xbt_dynar_free(&STag_surfxml_platform_cb_list);
xbt_dynar_free(&ETag_surfxml_platform_cb_list);
- xbt_dynar_free(&STag_surfxml_host_cb_list);
xbt_dynar_free(&ETag_surfxml_host_cb_list);
xbt_dynar_free(&STag_surfxml_router_cb_list);
xbt_dynar_free(&ETag_surfxml_router_cb_list);
void STag_surfxml_host(void){
// XBT_INFO("STag_surfxml_host [%s]",A_surfxml_host_id);
- struct_host = xbt_new0(s_surf_parsing_host_arg_t, 1);
- struct_host->V_host_id = xbt_strdup(A_surfxml_host_id);
- struct_host->V_host_power_peak = get_cpu_power(A_surfxml_host_power);
- surf_parse_get_double(&(struct_host->V_host_power_scale), A_surfxml_host_availability);
- surf_parse_get_int(&(struct_host->V_host_core),A_surfxml_host_core);
- struct_host->V_host_power_trace = tmgr_trace_new(A_surfxml_host_availability_file);
- struct_host->V_host_state_trace = tmgr_trace_new(A_surfxml_host_state_file);
+ s_surf_parsing_host_arg_t host;
+ memset(&host,0,sizeof(host));
+
+ host.V_host_id = xbt_strdup(A_surfxml_host_id);
+ host.V_host_power_peak = get_cpu_power(A_surfxml_host_power);
+ surf_parse_get_double(&(host.V_host_power_scale), A_surfxml_host_availability);
+ surf_parse_get_int(&(host.V_host_core),A_surfxml_host_core);
+ host.V_host_power_trace = tmgr_trace_new(A_surfxml_host_availability_file);
+ host.V_host_state_trace = tmgr_trace_new(A_surfxml_host_state_file);
xbt_assert((A_surfxml_host_state == A_surfxml_host_state_ON) ||
(A_surfxml_host_state == A_surfxml_host_state_OFF), "Invalid state");
if (A_surfxml_host_state == A_surfxml_host_state_ON)
- struct_host->V_host_state_initial = SURF_RESOURCE_ON;
+ host.V_host_state_initial = SURF_RESOURCE_ON;
if (A_surfxml_host_state == A_surfxml_host_state_OFF)
- struct_host->V_host_state_initial = SURF_RESOURCE_OFF;
- struct_host->V_host_coord = xbt_strdup(A_surfxml_host_coordinates);
+ host.V_host_state_initial = SURF_RESOURCE_OFF;
+ host.V_host_coord = xbt_strdup(A_surfxml_host_coordinates);
- surf_parse_host();
+ surf_parse_host(&host);
}
-void surf_parse_host(void){
- surfxml_call_cb_functions(STag_surfxml_host_cb_list);
+void surf_parse_host(surf_parsing_host_arg_t h){
+ unsigned int iterator;
+ surf_parse_host_fct_t fun;
+ xbt_dynar_foreach(surf_parse_host_cb_list, iterator, fun) {
+ if (fun) (*fun) (h);
+ }
+}
+void surf_parse_host_add_cb(surf_parse_host_fct_t fct) {
+ xbt_dynar_push(surf_parse_host_cb_list, &fct);
}
void ETag_surfxml_host(void){
surfxml_call_cb_functions(ETag_surfxml_host_cb_list);
- xbt_free(struct_host->V_host_id);
- xbt_free(struct_host);
}
+
void STag_surfxml_router(void){
struct_router = xbt_new0(s_surf_parsing_router_arg_t, 1);
struct_router->V_router_id = xbt_strdup(A_surfxml_router_id);
* Pass arguments to parsing callback as structures to save some time (and allow callbacks to ignore some)
*/
-surf_parsing_host_arg_t struct_host = NULL;
surf_parsing_router_arg_t struct_router = NULL;
surf_parsing_cluster_arg_t struct_cluster = NULL;
surf_parsing_peer_arg_t struct_peer = NULL;
return cpu;
}
-static void ptask_parse_cpu_init(void)
+static void ptask_parse_cpu_init(surf_parsing_host_arg_t host)
{
ptask_cpu_create_resource(
- struct_host->V_host_id,
- struct_host->V_host_power_peak,
- struct_host->V_host_power_scale,
- struct_host->V_host_power_trace,
- struct_host->V_host_state_initial,
- struct_host->V_host_state_trace,
- current_property_set);
+ host->V_host_id,
+ host->V_host_power_peak,
+ host->V_host_power_scale,
+ host->V_host_power_trace,
+ host->V_host_state_initial,
+ host->V_host_state_trace,
+ current_property_set);
current_property_set=NULL;
}
static void ptask_define_callbacks()
{
/* Adding callback functions */
- surfxml_add_callback(ETag_surfxml_host_cb_list, &ptask_parse_cpu_init);
+ surf_parse_host_add_cb(ptask_parse_cpu_init);
surfxml_add_callback(ETag_surfxml_link_cb_list, &ptask_parse_link_init);
surfxml_add_callback(ETag_surfxml_platform_cb_list, &ptask_add_traces);
}