Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add methods allowing routing, bypass the parser... this still crude and improvable
authorcoldpeace <coldpeace@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 20 Jul 2010 13:54:13 +0000 (13:54 +0000)
committercoldpeace <coldpeace@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 20 Jul 2010 13:54:13 +0000 (13:54 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8035 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/bindings/lua/simgrid_lua.c
src/include/surf/surf.h
src/surf/surf_private.h
src/surf/surf_routing.c
src/surf/surfxml_parse.c

index 0c6e8fb..faf9d44 100644 (file)
@@ -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
        }
        /* </platform> */
+       INFO0("Register Platform");
 #ifndef BYPASS_MODEL
        SURFXML_END_TAG(platform);
 #endif
index cc2847d..18c6799 100644 (file)
@@ -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"
 
index e1c110e..564f141 100644 (file)
@@ -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
index 9c7d787..76b9585 100644 (file)
@@ -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
+}
index 4d4bbb2..48cb08d 100644 (file)
@@ -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);
 }