From: navarrop Date: Tue, 28 Sep 2010 08:54:21 +0000 (+0000) Subject: Clean code. X-Git-Tag: v3_5~547 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/8f3f851daa42c5485ec0fedf68b24c639e43aee5 Clean code. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8277 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/examples/msg/masterslave/masterslave_bypass.c b/examples/msg/masterslave/masterslave_bypass.c index e953f1a99f..60dfc3c873 100644 --- a/examples/msg/masterslave/masterslave_bypass.c +++ b/examples/msg/masterslave/masterslave_bypass.c @@ -18,6 +18,8 @@ static int surf_parse_bypass_platform(void) { static int AX_ptr = 0; static int surfxml_bufferstack_size = 2048; + static int surfxml_buffer_stack_stack_ptr = 0; + static int surfxml_buffer_stack_stack[1024]; /* allocating memory for the buffer, I think 2kB should be enough */ surfxml_bufferstack = xbt_new0(char, surfxml_bufferstack_size); @@ -95,7 +97,8 @@ static int surf_parse_bypass_application(void) { static int AX_ptr; static int surfxml_bufferstack_size = 2048; - + static int surfxml_buffer_stack_stack_ptr = 0; + static int surfxml_buffer_stack_stack[1024]; /* allocating memory to the buffer, I think 2MB should be enough */ surfxml_bufferstack = xbt_new0(char, surfxml_bufferstack_size); diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 6919f834c5..456750487d 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -128,11 +128,8 @@ XBT_PUBLIC(void) model_help(const char* category, s_surf_model_description_t * t /***************************/ /* Generic model object */ /***************************/ -// typedef struct s_routing s_routing_t, *routing_t; // COMMENT BY DAVID -//XBT_PUBLIC_DATA(routing_t) used_routing; // COMMENT BY DAVID - - typedef struct s_routing_global s_routing_global_t, *routing_global_t; // ADDED BY DAVID -XBT_PUBLIC_DATA(routing_global_t) global_routing; // ADDED BY DAVID + typedef struct s_routing_global s_routing_global_t, *routing_global_t; +XBT_PUBLIC_DATA(routing_global_t) global_routing; /** \brief Private data available on all models diff --git a/src/instr/variables_instr.c b/src/instr/variables_instr.c index 9fb2106078..56ce031c08 100644 --- a/src/instr/variables_instr.c +++ b/src/instr/variables_instr.c @@ -10,7 +10,6 @@ #ifdef HAVE_TRACING -// extern routing_t used_routing; // COMMENTED BY DAVID extern routing_global_t global_routing; void __TRACE_link_variable (double time, const char *src, const char *dst, const char *variable, double value, const char *what) diff --git a/src/surf/network.c b/src/surf/network.c index cb676e7a1d..9664b6b8e8 100644 --- a/src/surf/network.c +++ b/src/surf/network.c @@ -325,15 +325,15 @@ static void net_update_actions_state(double now, double delta) xbt_swag_foreach_safe(action, next_action, running_actions) { #ifdef HAVE_TRACING -// COMMENTED BY DAVID -// xbt_dynar_t route = used_routing->get_route(action->src, action->dst); -// -// link_CM02_t link; -// unsigned int i; -// xbt_dynar_foreach(route, i, link) { -// TRACE_surf_link_set_utilization (link->lmm_resource.generic_resource.name, -// action->generic_action.data, lmm_variable_getvalue(action->variable), now-delta, delta); -// } + // COMMENTED BY DAVID + xbt_dynar_t route = global_routing->get_route(action->src_name, action->dst_name); + + link_CM02_t link; + unsigned int i; + xbt_dynar_foreach(route, i, link) { + TRACE_surf_link_set_utilization (link->lmm_resource.generic_resource.name, + action->generic_action.data, lmm_variable_getvalue(action->variable), now-delta, delta); + } #endif deltap = delta; if (action->latency > 0) { @@ -495,13 +495,11 @@ static surf_action_t net_communicate(const char *src_name, const char *dst_name, Add a link_CM02_t *link and a int link_nb to network_card_CM02_t. It will represent local links for this node Use the cluster_id for ->id */ - //xbt_dynar_t route = used_routing->get_route(src, dst); // COMMENTED BY DAVID xbt_dynar_t route = global_routing->get_route(src_name, dst_name); xbt_dynar_t back_route = NULL; int constraints_per_variable = 0; if( sg_network_fullduplex == 1){ - //back_route = used_routing->get_route(dst, src); // COMMENTED BY DAVID back_route = global_routing->get_route(src_name, dst_name); } @@ -596,6 +594,8 @@ static surf_action_t net_communicate(const char *src_name, const char *dst_name, } /* LARGE PLATFORMS HACK: expand also with src->link and dst->link */ + + XBT_OUT; return (surf_action_t) action; @@ -645,8 +645,6 @@ static void net_finalize(void) { surf_model_exit(surf_network_model); surf_network_model = NULL; - - //used_routing->finalize(); // COMMENTED BY DAVID global_routing->finalize(); diff --git a/src/surf/surf.c b/src/surf/surf.c index 82ca9d0a86..792cacccbf 100644 --- a/src/surf/surf.c +++ b/src/surf/surf.c @@ -339,7 +339,6 @@ void surf_exit(void) tmgr_finalize(); surf_parse_lex_destroy(); surf_parse_free_callbacks(); -// xbt_dict_free(&route_table); // COMMENTED BY DAVID NOW = 0; /* Just in case the user plans to restart the simulation afterward */ } diff --git a/src/surf/surf_private.h b/src/surf/surf_private.h index a076a98208..9be116555f 100644 --- a/src/surf/surf_private.h +++ b/src/surf/surf_private.h @@ -186,6 +186,7 @@ xbt_dict_t surf_resource_properties(const void *resource); XBT_PUBLIC(void) surfxml_bufferstack_push(int new); XBT_PUBLIC(void) surfxml_bufferstack_pop(int new); + XBT_PUBLIC_DATA(int) surfxml_bufferstack_size; #endif /* _SURF_SURF_PRIVATE_H */ diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 62c1c006ad..1e89a6e388 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -581,6 +581,16 @@ static void finalize(void) { xbt_free(global_routing); } +static void get_onelink_routes(void) +{ + xbt_die("get_onelink_routes function not implemented yet!!!"); +} + +static int is_router(const char *name) +{ + xbt_die("is_router function not implemented yet!!!"); +} + /** * \brief Generic method: create the global routing schema * @@ -1882,7 +1892,6 @@ static void generic_set_route(routing_component_t rc, const char* src, const cha static void generic_set_ASroute(routing_component_t rc, const char* src, const char* dst, route_extended_t e_route) { DEBUG4("Load ASroute from \"%s(%s)\" to \"%s(%s)\"",src,e_route->src_gateway,dst,e_route->dst_gateway); - printf("Load ASroute from \"%s(%s)\" to \"%s(%s)\"\n",src,e_route->src_gateway,dst,e_route->dst_gateway); model_type_t modeltype = rc->routing; xbt_dict_t _parse_routes; xbt_dict_t _to_index; @@ -2213,15 +2222,10 @@ static void routing_full_parse_Scluster(void) xbt_dynar_t radical_elements; xbt_dynar_t radical_ends; - surfxml_bufferstack_push(1); - - /* allocating memory for the buffer, I think 2kB should be enough */ - // surfxml_bufferstack = xbt_new0(char, surfxml_bufferstack_size); + static int surfxml_buffer_stack_stack_ptr = 0; + static int surfxml_buffer_stack_stack[1024]; -// DEBUG4("id='%s' prefix='%s' suffix='%s' radical='%s'", -// cluster_id,cluster_prefix,cluster_suffix,cluster_radical); -// DEBUG5("power='%s' bw='%s' lat='%s' bb_bw='%s' bb_lat='%s'", -// cluster_power,cluster_bw,cluster_lat,cluster_bb_bw,cluster_bb_lat); + surfxml_bufferstack_push(1); DEBUG1("",cluster_id); SURFXML_BUFFER_SET(AS_id, cluster_id); @@ -2240,7 +2244,6 @@ static void routing_full_parse_Scluster(void) link_id = bprintf("%s_link_%d", cluster_id, start); DEBUG2("",host_id,cluster_power); - SURFXML_BUFFER_RESET(); SURFXML_BUFFER_SET(host_id, host_id); SURFXML_BUFFER_SET(host_power, cluster_power); SURFXML_BUFFER_SET(host_availability, "1.0"); @@ -2255,7 +2258,6 @@ static void routing_full_parse_Scluster(void) SURFXML_END_TAG(host); DEBUG3("",link_id,cluster_bw,cluster_lat); - SURFXML_BUFFER_RESET(); SURFXML_BUFFER_SET(link_id, link_id); SURFXML_BUFFER_SET(link_bandwidth, cluster_bw); SURFXML_BUFFER_SET(link_latency, cluster_lat); @@ -2279,7 +2281,6 @@ static void routing_full_parse_Scluster(void) link_id = bprintf("%s_link_%d", cluster_id, i); DEBUG2("",host_id,cluster_power); - SURFXML_BUFFER_RESET(); SURFXML_BUFFER_SET(host_id, host_id); SURFXML_BUFFER_SET(host_power, cluster_power); SURFXML_BUFFER_SET(host_availability, "1.0"); @@ -2294,7 +2295,6 @@ static void routing_full_parse_Scluster(void) SURFXML_END_TAG(host); DEBUG3("",link_id,cluster_bw,cluster_lat); - SURFXML_BUFFER_RESET(); SURFXML_BUFFER_SET(link_id, link_id); SURFXML_BUFFER_SET(link_bandwidth, cluster_bw); SURFXML_BUFFER_SET(link_latency, cluster_lat); @@ -2321,13 +2321,11 @@ static void routing_full_parse_Scluster(void) link_backbone = bprintf("%s_backbone",cluster_id); DEBUG1("",router_id); - SURFXML_BUFFER_RESET(); SURFXML_BUFFER_SET(router_id, router_id);; SURFXML_START_TAG(router); SURFXML_END_TAG(router); DEBUG3("",link_router,cluster_bw,cluster_lat); - SURFXML_BUFFER_RESET(); SURFXML_BUFFER_SET(link_id, link_router); SURFXML_BUFFER_SET(link_bandwidth, cluster_bw); SURFXML_BUFFER_SET(link_latency, cluster_lat); @@ -2340,7 +2338,6 @@ static void routing_full_parse_Scluster(void) SURFXML_END_TAG(link); DEBUG3("",link_backbone,cluster_bb_bw,cluster_bb_lat); - SURFXML_BUFFER_RESET(); SURFXML_BUFFER_SET(link_id, link_backbone); SURFXML_BUFFER_SET(link_bandwidth, cluster_bb_bw); SURFXML_BUFFER_SET(link_latency, cluster_bb_lat); @@ -2367,25 +2364,21 @@ static void routing_full_parse_Scluster(void) DEBUG0(" "); DEBUG2("",route_src_dst,route_src_dst); - SURFXML_BUFFER_RESET(); SURFXML_BUFFER_SET(route_src, route_src_dst); SURFXML_BUFFER_SET(route_dst, route_src_dst); SURFXML_START_TAG(route); DEBUG1("",cluster_id); - SURFXML_BUFFER_RESET(); SURFXML_BUFFER_SET(link_c_ctn_id, bprintf("%s_link_$1src",cluster_id)); SURFXML_START_TAG(link_c_ctn); SURFXML_END_TAG(link_c_ctn); DEBUG1("",cluster_id); - SURFXML_BUFFER_RESET(); SURFXML_BUFFER_SET(link_c_ctn_id, bprintf("%s_backbone",cluster_id)); SURFXML_START_TAG(link_c_ctn); SURFXML_END_TAG(link_c_ctn); DEBUG1("",cluster_id); - SURFXML_BUFFER_RESET(); SURFXML_BUFFER_SET(link_c_ctn_id, bprintf("%s_link_$1dst",cluster_id)); SURFXML_START_TAG(link_c_ctn); SURFXML_END_TAG(link_c_ctn); diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index 13a387bdcc..e101d03a32 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -27,6 +27,7 @@ xbt_dict_t trace_connect_list_latency = NULL; /* This buffer is used to store the original buffer before substituting it by out own buffer. Useful for the foreach tag */ static xbt_dynar_t surfxml_bufferstack_stack = NULL; int surfxml_bufferstack_size = 2048; + static char *old_buff = NULL; static void surf_parse_error(char *msg); @@ -485,7 +486,7 @@ static void add_randomness(void) { /* If needed aditional properties can be added by using the prop tag */ random_data_t random = random_new(random_generator, 0, random_min, random_max, random_mean, random_std_deviation); - xbt_dict_set(random_data_list, random_id, (void *) random, &xbt_free_ref); // FIX BY DAVID, add the xbt_free_ref function + xbt_dict_set(random_data_list, random_id, (void *) random, &xbt_free_ref); } /** @@ -573,8 +574,8 @@ void surf_add_route_element(char* link_ctn_id) void surf_route_set_resource(char *source_id,char *destination_id,xbt_dynar_t links_id,int action) { xbt_die("\"surf_route_set_resource\" not support"); - //route_link_list = xbt_dynar_new(sizeof(char *), NULL); // COMMENTED BY DAVID - //routing_add_route(source_id,destination_id,links_id,action); // COMMENTED BY DAVID + //route_link_list = xbt_dynar_new(sizeof(char *), NULL); + //routing_add_route(source_id,destination_id,links_id,action); } @@ -584,7 +585,7 @@ void surf_route_set_resource(char *source_id,char *destination_id,xbt_dynar_t li void surf_route_add_host(char *host_id) { xbt_die("\"surf_route_add_host\" not support"); - //routing_add_host(host_id); // COMMENTED BY DAVID + //routing_add_host(host_id); } /** @@ -611,5 +612,5 @@ void surf_wsL07_add_traces(void) void surf_set_routes(void) { xbt_die("\"surf_set_routes\" not support"); - //routing_set_routes(); // COMMENTED BY DAVID + //routing_set_routes(); } diff --git a/src/surf/workstation_ptask_L07.c b/src/surf/workstation_ptask_L07.c index f073976812..54b74271c6 100644 --- a/src/surf/workstation_ptask_L07.c +++ b/src/surf/workstation_ptask_L07.c @@ -399,7 +399,6 @@ static void ptask_finalize(void) surf_workstation_model = NULL; surf_model_exit(surf_network_model); surf_network_model = NULL; - // used_routing->finalize(); // COMMENTED BY DAVID global_routing->finalize(); ptask_host_count = 0;