From: coldpeace Date: Tue, 20 Jul 2010 13:54:13 +0000 (+0000) Subject: add methods allowing routing, bypass the parser... this still crude and improvable X-Git-Tag: v3_5~785 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/eff3b8aba0af43e3294a007d806867641ec6d3b6?hp=a0319214b0d4f9b17f316e9938ce7f8e69eb3182 add methods allowing routing, bypass the parser... this still crude and improvable git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8035 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/bindings/lua/simgrid_lua.c b/src/bindings/lua/simgrid_lua.c index 0c6e8fb921..faf9d447e6 100644 --- a/src/bindings/lua/simgrid_lua.c +++ b/src/bindings/lua/simgrid_lua.c @@ -575,8 +575,10 @@ static int surf_parse_bypass_platform() #ifdef BYPASS_MODEL INFO0("Bypass_Cpu"); - create_host(p_host->id,p_host->power,p_host->power_scale,p_host->power_trace, + create_host(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); #else SURFXML_BUFFER_SET(host_id,p_host->id); @@ -624,7 +626,9 @@ static int surf_parse_bypass_platform() INFO0("Start Adding routes"); xbt_dynar_foreach(route_list_d,i,p_route) { -#ifndef BYPASS_MODEL +#ifdef BYPASS_MODEL + surf_route_set_resource((char*)p_route->src_id,(char*)p_route->dest_id,p_route->links_id,0); +#else SURFXML_BUFFER_SET(route_src,p_route->src_id); SURFXML_BUFFER_SET(route_dst,p_route->dest_id); @@ -639,15 +643,14 @@ static int surf_parse_bypass_platform() SURFXML_BUFFER_SET(link_c_ctn_id,link_id); SURFXML_START_TAG(link_c_ctn); SURFXML_END_TAG(link_c_ctn); -#ifdef BYPASS_MODEL - surf_add_route_element(link_id); -#endif + } SURFXML_END_TAG(route); #endif } /* */ + INFO0("Register Platform"); #ifndef BYPASS_MODEL SURFXML_END_TAG(platform); #endif diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index cc2847d21f..18c6799ba3 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -668,7 +668,6 @@ XBT_PUBLIC(void) surf_host_create_resource(char *name, double power_peak, XBT_PUBLIC(void) surf_link_create_resouce(char *name, double bw_initial,double lat_initial); - /** * add route element (link_ctn) bypassing the parser * @@ -677,6 +676,19 @@ XBT_PUBLIC(void) surf_link_create_resouce(char *name, */ 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 + */ +XBT_PUBLIC(void) surf_route_set_resource(char* src_id,char *dest_id,xbt_dynar_t links_id,int action); + +/** + * add host to routing model ( xbt_dict ) + * + */ +XBT_PUBLIC(void) surf_route_add_host(char * host_id); + #include "surf/surf_resource.h" #include "surf/surf_resource_lmm.h" diff --git a/src/surf/surf_private.h b/src/surf/surf_private.h index e1c110e605..564f1416bb 100644 --- a/src/surf/surf_private.h +++ b/src/surf/surf_private.h @@ -110,6 +110,12 @@ struct s_routing { }; XBT_PUBLIC(void) routing_model_create(size_t size_of_link,void *loopback); +/* + * generic methods to create resources bypassing the parser + * FIXME : better if added to the routing model instead + */ +XBT_PUBLIC(void) routing_set_route(char *source_id,char *destination_id,xbt_dynar_t links_id,int action); +XBT_PUBLIC(void) routing_add_host(char* host_id); /* * Resource protected methods diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 9c7d787752..76b95857b5 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -1039,7 +1039,6 @@ static void routing_none_finalize(void) { static void routing_model_none_create(size_t size_of_link,void *loopback) { routing_t routing = xbt_new0(s_routing_t,1); - INFO0("Null routing"); routing->name = "none"; routing->host_count = 0; routing->host_id = xbt_dict_new(); @@ -1052,3 +1051,42 @@ static void routing_model_none_create(size_t size_of_link,void *loopback) { /* Set it in position */ used_routing = (routing_t) routing; } + +/*****************************************************************/ +/******************* BYBASS THE PARSER ***************************/ + +/* + * FIXME : better to add to the routing model instead !! + * + */ +void routing_set_route(char *source_id,char *destination_id,xbt_dynar_t links_id,int action) +{ + char * link_id; + char * name; + unsigned int i; + src_id = *(int*)xbt_dict_get(used_routing->host_id,source_id); + dst_id = *(int*)xbt_dict_get(used_routing->host_id,destination_id); + DEBUG4("Route %s %d -> %s %d",source_id,src_id,destination_id,dst_id); + //set Links + xbt_dynar_foreach(links_id,i,link_id) + { + surf_add_route_element(link_id); + } + route_action = action; + if (src_id != -1 && dst_id != -1) { + name = bprintf("%x#%x", src_id, dst_id); + manage_route(route_table, name, route_action, 0); + free(name); + } +} + +void routing_add_host(char* host_id) +{ + int *val = xbt_malloc(sizeof(int)); + DEBUG2("Seen host %s (#%d)",host_id,used_routing->host_count); + *val = used_routing->host_count++; + xbt_dict_set(used_routing->host_id,host_id,val,xbt_free); + #ifdef HAVE_TRACING + TRACE_surf_host_define_id (host_id, *val); + #endif +} diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index 4d4bbb2741..48cb08d5ae 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -1195,5 +1195,24 @@ void surf_link_create_resouce(char *name, void surf_add_route_element(char* link_ctn_id) { - xbt_dynar_push(route_link_list,&link_ctn_id); + char *val; + val = xbt_strdup(link_ctn_id); + xbt_dynar_push(route_link_list,&val); +} +/** + * set route + */ +void surf_route_set_resource(char *source_id,char *destination_id,xbt_dynar_t links_id,int action) +{ + route_link_list = xbt_dynar_new(sizeof(char *), NULL); + routing_set_route(source_id,destination_id,links_id,action); + +} + +/** + * add host to routing host list + */ +void surf_route_add_host(char *host_id) +{ + routing_add_host(host_id); }