From: Martin Quinson Date: Tue, 8 Nov 2011 11:05:51 +0000 (+0100) Subject: Also cleanup the fields of s_sg_platf_link_cbarg_t X-Git-Tag: exp_20120216~439 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/f5b15e157009dbaef93d579aaf5f093864fc7cc7?hp=04c10dad7fa6089786021b0f8b4413f86bafd6fd Also cleanup the fields of s_sg_platf_link_cbarg_t This one is not just a renaming: - kill the unused V_policy_initial_link - make V_link_sharing_policy (now 'policy') a e_surf_link_sharing_policy_t (which thus become public) This should be enough for field renaming for now. But the cleanup is definitly not finished :-/ --- diff --git a/include/simgrid/platf.h b/include/simgrid/platf.h index 3837ac9ad9..c9c0ede461 100644 --- a/include/simgrid/platf.h +++ b/include/simgrid/platf.h @@ -19,6 +19,11 @@ typedef enum { SURF_RESOURCE_OFF = 0 /**< Down & broken */ } e_surf_resource_state_t; +typedef enum { + SURF_LINK_FULLDUPLEX = 2, + SURF_LINK_SHARED = 1, + SURF_LINK_FATPIPE = 0 +} e_surf_link_sharing_policy_t; /* * Platform creation functions. Instead of passing 123 arguments to the creation functions @@ -48,15 +53,14 @@ typedef struct { } s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t; typedef struct { - const char* V_link_id; - double V_link_bandwidth; - tmgr_trace_t V_link_bandwidth_file; - double V_link_latency; - tmgr_trace_t V_link_latency_file; - e_surf_resource_state_t V_link_state; - tmgr_trace_t V_link_state_file; - int V_link_sharing_policy; - int V_policy_initial_link; + const char* id; + double bandwidth; + tmgr_trace_t bandwidth_trace; + double latency; + tmgr_trace_t latency_trace; + e_surf_resource_state_t state; + tmgr_trace_t state_trace; + e_surf_link_sharing_policy_t policy; xbt_dict_t properties; } s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t; diff --git a/src/bindings/lua/lua_console.c b/src/bindings/lua/lua_console.c index c62713fbe1..c6f01ae2b4 100644 --- a/src/bindings/lua/lua_console.c +++ b/src/bindings/lua/lua_console.c @@ -104,19 +104,19 @@ int console_add_link(lua_State *L) { // get Id Value lua_pushstring(L, "id"); lua_gettable(L, -2); - link.V_link_id = lua_tostring(L, -1); + link.id = lua_tostring(L, -1); lua_pop(L, 1); // get bandwidth value lua_pushstring(L, "bandwidth"); lua_gettable(L, -2); - link.V_link_bandwidth = lua_tonumber(L, -1); + link.bandwidth = lua_tonumber(L, -1); lua_pop(L, 1); //get latency value lua_pushstring(L, "latency"); lua_gettable(L, -2); - link.V_link_latency = lua_tonumber(L, -1); + link.latency = lua_tonumber(L, -1); lua_pop(L, 1); /*Optional Arguments */ @@ -124,28 +124,28 @@ int console_add_link(lua_State *L) { //get bandwidth_trace value lua_pushstring(L, "bandwidth_trace"); lua_gettable(L, -2); - link.V_link_bandwidth_file = tmgr_trace_new(lua_tostring(L, -1)); + link.bandwidth_trace = tmgr_trace_new(lua_tostring(L, -1)); lua_pop(L, 1); //get latency_trace value lua_pushstring(L, "latency_trace"); lua_gettable(L, -2); - link.V_link_latency_file = tmgr_trace_new(lua_tostring(L, -1)); + link.latency_trace = tmgr_trace_new(lua_tostring(L, -1)); lua_pop(L, 1); //get state_trace value lua_pushstring(L, "state_trace"); lua_gettable(L, -2); - link.V_link_state_file = tmgr_trace_new(lua_tostring(L, -1)); + link.state_trace = tmgr_trace_new(lua_tostring(L, -1)); lua_pop(L, 1); //get state_initial value lua_pushstring(L, "state_initial"); lua_gettable(L, -2); if (lua_tonumber(L, -1)) - link.V_link_state = SURF_RESOURCE_ON; + link.state = SURF_RESOURCE_ON; else - link.V_link_state = SURF_RESOURCE_OFF; + link.state = SURF_RESOURCE_OFF; lua_pop(L, 1); //get policy value @@ -154,11 +154,11 @@ int console_add_link(lua_State *L) { policy = lua_tostring(L, -1); lua_pop(L, 1); if (policy && !strcmp(policy,"FULLDUPLEX")) { - link.V_link_sharing_policy = SURF_LINK_FULLDUPLEX; + link.policy = SURF_LINK_FULLDUPLEX; } else if (policy && !strcmp(policy,"FATPIPE")) { - link.V_link_sharing_policy = SURF_LINK_FATPIPE; + link.policy = SURF_LINK_FATPIPE; } else { - link.V_link_sharing_policy = SURF_LINK_SHARED; + link.policy = SURF_LINK_SHARED; } sg_platf_new_link(&link); diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index a0ed25ce70..cafb3d3295 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -21,12 +21,6 @@ SG_BEGIN_DECL() /* Actions and models are highly connected structures... */ -typedef enum { - SURF_LINK_FULLDUPLEX = 2, - SURF_LINK_SHARED = 1, - SURF_LINK_FATPIPE = 0 -} e_surf_link_sharing_policy_t; - typedef enum { SURF_NETWORK_ELEMENT_NULL = 0, /* NULL */ SURF_NETWORK_ELEMENT_HOST, /* host type */ diff --git a/src/instr/instr_routing.c b/src/instr/instr_routing.c index 1eed752721..765dcea227 100644 --- a/src/instr/instr_routing.c +++ b/src/instr/instr_routing.c @@ -190,19 +190,19 @@ static void instr_routing_parse_start_link (sg_platf_link_cbarg_t link) { container_t father = *(container_t*)xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1); - double bandwidth_value = link->V_link_bandwidth; - double latency_value = link->V_link_latency; + double bandwidth_value = link->bandwidth; + double latency_value = link->latency; xbt_dynar_t links_to_create = xbt_dynar_new (sizeof(char*), &xbt_free_ref); - if (link->V_link_sharing_policy == A_surfxml_link_sharing_policy_FULLDUPLEX){ - char *up = bprintf("%s_UP", link->V_link_id); - char *down = bprintf("%s_DOWN", link->V_link_id); + if (link->policy == SURF_LINK_FULLDUPLEX){ + char *up = bprintf("%s_UP", link->id); + char *down = bprintf("%s_DOWN", link->id); xbt_dynar_push_as (links_to_create, char*, xbt_strdup(up)); xbt_dynar_push_as (links_to_create, char*, xbt_strdup(down)); free (up); free (down); }else{ - xbt_dynar_push_as (links_to_create, char*, strdup(link->V_link_id)); + xbt_dynar_push_as (links_to_create, char*, strdup(link->id)); } char *link_name = NULL; diff --git a/src/surf/network.c b/src/surf/network.c index e42e22a7f7..65c2fe4a0b 100644 --- a/src/surf/network.c +++ b/src/surf/network.c @@ -196,20 +196,20 @@ static void net_parse_link_init(sg_platf_link_cbarg_t link) { XBT_DEBUG("link_CM02"); - if(link->V_policy_initial_link == SURF_LINK_FULLDUPLEX) + if(link->policy == SURF_LINK_FULLDUPLEX) { - net_create_resource(bprintf("%s_UP",link->V_link_id), link->V_link_bandwidth, link->V_link_bandwidth_file, - link->V_link_latency, link->V_link_latency_file, link->V_link_state, link->V_link_state_file, - link->V_policy_initial_link, link->properties); - net_create_resource(bprintf("%s_DOWN",link->V_link_id), link->V_link_bandwidth, link->V_link_bandwidth_file, - link->V_link_latency, link->V_link_latency_file, link->V_link_state, link->V_link_state_file, - link->V_policy_initial_link, NULL); // FIXME: We need to deep copy the properties or we won't be able to free it + net_create_resource(bprintf("%s_UP",link->id), link->bandwidth, link->bandwidth_trace, + link->latency, link->latency_trace, link->state, link->state_trace, + link->policy, link->properties); + net_create_resource(bprintf("%s_DOWN",link->id), link->bandwidth, link->bandwidth_trace, + link->latency, link->latency_trace, link->state, link->state_trace, + link->policy, NULL); // FIXME: We need to deep copy the properties or we won't be able to free it } else { - net_create_resource(xbt_strdup(link->V_link_id), link->V_link_bandwidth, link->V_link_bandwidth_file, - link->V_link_latency, link->V_link_latency_file, link->V_link_state, link->V_link_state_file, - link->V_policy_initial_link, link->properties); + net_create_resource(xbt_strdup(link->id), link->bandwidth, link->bandwidth_trace, + link->latency, link->latency_trace, link->state, link->state_trace, + link->policy, link->properties); } } diff --git a/src/surf/network_im.c b/src/surf/network_im.c index f53574adc2..bc94690fac 100644 --- a/src/surf/network_im.c +++ b/src/surf/network_im.c @@ -190,20 +190,20 @@ static void* im_net_create_resource(const char *name, static void im_net_parse_link_init(sg_platf_link_cbarg_t link) { - if(link->V_policy_initial_link == SURF_LINK_FULLDUPLEX) + if(link->policy == SURF_LINK_FULLDUPLEX) { - im_net_create_resource(bprintf("%s_UP",link->V_link_id), link->V_link_bandwidth, link->V_link_bandwidth_file, - link->V_link_latency, link->V_link_latency_file, link->V_link_state, link->V_link_state_file, - link->V_policy_initial_link, link->properties); - im_net_create_resource(bprintf("%s_DOWN",link->V_link_id), link->V_link_bandwidth, link->V_link_bandwidth_file, - link->V_link_latency, link->V_link_latency_file, link->V_link_state, link->V_link_state_file, - link->V_policy_initial_link, NULL); // FIXME: We need to deep copy the properties or we won't be able to free it + im_net_create_resource(bprintf("%s_UP",link->id), link->bandwidth, link->bandwidth_trace, + link->latency, link->latency_trace, link->state, link->state_trace, + link->policy, link->properties); + im_net_create_resource(bprintf("%s_DOWN",link->id), link->bandwidth, link->bandwidth_trace, + link->latency, link->latency_trace, link->state, link->state_trace, + link->policy, NULL); // FIXME: We need to deep copy the properties or we won't be able to free it } else { - im_net_create_resource(xbt_strdup(link->V_link_id), link->V_link_bandwidth, link->V_link_bandwidth_file, - link->V_link_latency, link->V_link_latency_file, link->V_link_state, link->V_link_state_file, - link->V_policy_initial_link, link->properties); + im_net_create_resource(xbt_strdup(link->id), link->bandwidth, link->bandwidth_trace, + link->latency, link->latency_trace, link->state, link->state_trace, + link->policy, link->properties); } } diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 24f8467e32..6e62f79fea 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -1467,24 +1467,20 @@ void routing_parse_Scluster(void) XBT_DEBUG("", link_id,struct_cluster->S_cluster_bw, struct_cluster->S_cluster_lat); memset(&link,0,sizeof(link)); - link.V_link_id = link_id; - link.V_link_bandwidth = struct_cluster->S_cluster_bw; - link.V_link_latency = struct_cluster->S_cluster_lat; - link.V_link_bandwidth_file = NULL; - link.V_link_latency_file = NULL; - link.V_link_state_file = NULL; - link.V_link_state = SURF_RESOURCE_ON; - link.V_link_sharing_policy = A_surfxml_link_sharing_policy; + link.id = link_id; + link.bandwidth = struct_cluster->S_cluster_bw; + link.latency = struct_cluster->S_cluster_lat; + link.state = SURF_RESOURCE_ON; switch (A_surfxml_link_sharing_policy) { case A_surfxml_link_sharing_policy_SHARED: - link.V_policy_initial_link = SURF_LINK_SHARED; + link.policy = SURF_LINK_SHARED; break; case A_surfxml_link_sharing_policy_FATPIPE: - link.V_policy_initial_link = SURF_LINK_FATPIPE; + link.policy = SURF_LINK_FATPIPE; break; case A_surfxml_link_sharing_policy_FULLDUPLEX: - link.V_policy_initial_link = SURF_LINK_FULLDUPLEX; + link.policy = SURF_LINK_FULLDUPLEX; break; case AU_surfxml_link_sharing_policy: surf_parse_error(bprintf("Invalid sharing policy in cluster %s (please report this bug, this shouldn't happen)",struct_cluster->V_cluster_id)); @@ -1564,23 +1560,20 @@ void routing_parse_Scluster(void) XBT_DEBUG("", link_id,struct_cluster->S_cluster_bw, struct_cluster->S_cluster_lat); memset(&link,0,sizeof(link)); - link.V_link_id = link_id; - link.V_link_bandwidth = struct_cluster->S_cluster_bw; - link.V_link_latency = struct_cluster->S_cluster_lat; - link.V_link_bandwidth_file = NULL; - link.V_link_latency_file = NULL; - link.V_link_state_file = NULL; - link.V_link_state = SURF_RESOURCE_ON; - link.V_link_sharing_policy = A_surfxml_link_sharing_policy; + link.id = link_id; + link.bandwidth = struct_cluster->S_cluster_bw; + link.latency = struct_cluster->S_cluster_lat; + link.state = SURF_RESOURCE_ON; + /* FIXME: use a switch here */ if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_SHARED) - link.V_policy_initial_link = SURF_LINK_SHARED; + link.policy = SURF_LINK_SHARED; else { if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_FATPIPE) - link.V_policy_initial_link = SURF_LINK_FATPIPE; + link.policy = SURF_LINK_FATPIPE; else if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_FULLDUPLEX) - link.V_policy_initial_link = SURF_LINK_FULLDUPLEX; + link.policy = SURF_LINK_FULLDUPLEX; } sg_platf_new_link(&link); @@ -1633,19 +1626,16 @@ void routing_parse_Scluster(void) {A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_FATPIPE;} memset(&link,0,sizeof(link)); - link.V_link_id = link_backbone; - link.V_link_bandwidth = struct_cluster->S_cluster_bb_bw; - link.V_link_latency = struct_cluster->S_cluster_bb_lat; - link.V_link_bandwidth_file = NULL; - link.V_link_latency_file = NULL; - link.V_link_state_file = NULL; - link.V_link_state = SURF_RESOURCE_ON; - link.V_link_sharing_policy = A_surfxml_link_sharing_policy; + link.id = link_backbone; + link.bandwidth = struct_cluster->S_cluster_bb_bw; + link.latency = struct_cluster->S_cluster_bb_lat; + link.state = SURF_RESOURCE_ON; + /* FIXME: use a switch, and deal with FULLDUPLEX here */ if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_SHARED) - link.V_policy_initial_link = SURF_LINK_SHARED; + link.policy = SURF_LINK_SHARED; else - link.V_policy_initial_link = SURF_LINK_FATPIPE; + link.policy = SURF_LINK_FATPIPE; sg_platf_new_link(&link); ETag_surfxml_link(); diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index 48cbb044af..d9a920695e 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -377,28 +377,29 @@ void STag_surfxml_link(void){ xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)"); link.properties = current_property_set = xbt_dict_new(); - link.V_link_id = A_surfxml_link_id; - link.V_link_bandwidth = surf_parse_get_double(A_surfxml_link_bandwidth); - link.V_link_bandwidth_file = tmgr_trace_new(A_surfxml_link_bandwidth_file); - link.V_link_latency = surf_parse_get_double(A_surfxml_link_latency); - link.V_link_latency_file = tmgr_trace_new(A_surfxml_link_latency_file); + link.id = A_surfxml_link_id; + link.bandwidth = surf_parse_get_double(A_surfxml_link_bandwidth); + link.bandwidth_trace = tmgr_trace_new(A_surfxml_link_bandwidth_file); + link.latency = surf_parse_get_double(A_surfxml_link_latency); + link.latency_trace = tmgr_trace_new(A_surfxml_link_latency_file); + /* FIXME: use a switch here */ xbt_assert((A_surfxml_link_state == A_surfxml_link_state_ON) || (A_surfxml_link_state == A_surfxml_link_state_OFF), "Invalid state"); if (A_surfxml_link_state == A_surfxml_link_state_ON) - link.V_link_state = SURF_RESOURCE_ON; + link.state = SURF_RESOURCE_ON; if (A_surfxml_link_state == A_surfxml_link_state_OFF) - link.V_link_state = SURF_RESOURCE_OFF; - link.V_link_state_file = tmgr_trace_new(A_surfxml_link_state_file); - link.V_link_sharing_policy = A_surfxml_link_sharing_policy; + link.state = SURF_RESOURCE_OFF; + link.state_trace = tmgr_trace_new(A_surfxml_link_state_file); + /* FIXME: use a switch here */ if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_SHARED) - link.V_policy_initial_link = SURF_LINK_SHARED; + link.policy = SURF_LINK_SHARED; else { if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_FATPIPE) - link.V_policy_initial_link = SURF_LINK_FATPIPE; + link.policy = SURF_LINK_FATPIPE; else if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_FULLDUPLEX) - link.V_policy_initial_link = SURF_LINK_FULLDUPLEX; + link.policy = SURF_LINK_FULLDUPLEX; } sg_platf_new_link(&link); diff --git a/src/surf/workstation_ptask_L07.c b/src/surf/workstation_ptask_L07.c index cf5ca3056e..ee32783777 100644 --- a/src/surf/workstation_ptask_L07.c +++ b/src/surf/workstation_ptask_L07.c @@ -712,20 +712,20 @@ static void* ptask_link_create_resource(const char *name, static void ptask_parse_link_init(sg_platf_link_cbarg_t link) { - if(link->V_policy_initial_link == SURF_LINK_FULLDUPLEX) + if(link->policy == SURF_LINK_FULLDUPLEX) { - ptask_link_create_resource(bprintf("%s_UP",link->V_link_id), link->V_link_bandwidth, link->V_link_bandwidth_file, - link->V_link_latency, link->V_link_latency_file, link->V_link_state, link->V_link_state_file, - link->V_policy_initial_link, link->properties); - ptask_link_create_resource(bprintf("%s_DOWN",link->V_link_id), link->V_link_bandwidth, link->V_link_bandwidth_file, - link->V_link_latency, link->V_link_latency_file, link->V_link_state, link->V_link_state_file, - link->V_policy_initial_link, NULL); // FIXME: We need to deep copy the properties or we won't be able to free it + ptask_link_create_resource(bprintf("%s_UP",link->id), link->bandwidth, link->bandwidth_trace, + link->latency, link->latency_trace, link->state, link->state_trace, + link->policy, link->properties); + ptask_link_create_resource(bprintf("%s_DOWN",link->id), link->bandwidth, link->bandwidth_trace, + link->latency, link->latency_trace, link->state, link->state_trace, + link->policy, NULL); // FIXME: We need to deep copy the properties or we won't be able to free it } else { - ptask_link_create_resource(xbt_strdup(link->V_link_id), link->V_link_bandwidth, link->V_link_bandwidth_file, - link->V_link_latency, link->V_link_latency_file, link->V_link_state, link->V_link_state_file, - link->V_policy_initial_link, link->properties); + ptask_link_create_resource(xbt_strdup(link->id), link->bandwidth, link->bandwidth_trace, + link->latency, link->latency_trace, link->state, link->state_trace, + link->policy, link->properties); } current_property_set = NULL;