#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);
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);
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
XBT_PUBLIC(void) surf_link_create_resouce(char *name,
double bw_initial,double lat_initial);
-
/**
* add route element (link_ctn) bypassing the parser
*
*/
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"
};
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
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();
/* 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
+}
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);
}