#define ROUTE(i,j) routing_table[(i)+(j)*nb_workstation]
static network_link_KCCFLN05_t loopback = NULL;
static xbt_dict_t parallel_task_network_link_set = NULL;
+//added to work with GTNETS
+static xbt_dict_t router_set = NULL;
/*xbt_dict_t network_link_set = NULL;*/
+
/* convenient function */
static void __update_cpu_usage(cpu_KCCFLN05_t cpu)
{
static void *name_service(const char *name)
{
- return xbt_dict_get_or_null(workstation_set, name);
+ xbt_ex_t e;
+ void *res=NULL;
+
+ TRY {
+ res = xbt_dict_get_or_null(workstation_set, name);
+ } CATCH(e) {
+ if (e.category != not_found_error)
+ RETHROW;
+ WARN1("Host '%s' not found, verifing if it is a router", name);
+ res = NULL;
+ xbt_ex_free(e);
+ }
+
+ return res;
}
static const char *get_resource_name(void *resource_id)
xbt_dict_free(&network_link_set);
xbt_dict_free(&workstation_set);
+ xbt_dict_free(&router_set);
if (parallel_task_network_link_set != NULL) {
xbt_dict_free(¶llel_task_network_link_set);
}
/*** Resource Creation & Destruction **/
/**************************************/
+
+static void router_free(void *router)
+{
+ free( ((router_KCCFLN05_t) router)->name );
+}
+
+static void router_new(const char *name)
+{
+ static unsigned int nb_routers = 0;
+
+ INFO1("Creating a router %s", name);
+
+ router_KCCFLN05_t router;
+ router = xbt_new0(s_router_KCCFLN05_t, 1);
+
+ router->name = xbt_strdup(name);
+ router->id = nb_routers++;
+ xbt_dict_set(router_set, name, router, router_free);
+}
+
+static void parse_routers(void)
+{
+ //add a dumb router just to be GTNETS compatible
+ router_new(A_surfxml_router_name);
+}
+
static void cpu_free(void *cpu)
{
free(((cpu_KCCFLN05_t) cpu)->name);
static void parse_route_set_endpoints(void)
{
- src_id = ((cpu_KCCFLN05_t) name_service(A_surfxml_route_src))->id;
- dst_id = ((cpu_KCCFLN05_t) name_service(A_surfxml_route_dst))->id;
+ cpu_KCCFLN05_t cpu_tmp = NULL;
+
+ cpu_tmp = (cpu_KCCFLN05_t) name_service(A_surfxml_route_src);
+ if(cpu_tmp != NULL) {
+ src_id = cpu_tmp->id;
+ }else {
+ xbt_assert1(xbt_dict_get_or_null(router_set, A_surfxml_route_src),
+ "Invalid name '%s': neither a cpu nor a router!",
+ A_surfxml_route_src);
+ src_id=-1;
+ return;
+ }
+
+ cpu_tmp = (cpu_KCCFLN05_t) name_service(A_surfxml_route_dst);
+ if(cpu_tmp != NULL) {
+ dst_id = cpu_tmp->id;
+ }else {
+ xbt_assert1(xbt_dict_get_or_null(router_set, A_surfxml_route_dst),
+ "Invalid name '%s': neither a cpu nor a router!",
+ A_surfxml_route_dst);
+ dst_id=-1;
+ return ;
+ }
+
surf_parse_get_double(&impact_on_src, A_surfxml_route_impact_on_src);
surf_parse_get_double(&impact_on_dst, A_surfxml_route_impact_on_dst);
surf_parse_get_double(&impact_on_src_with_other_recv,
A_surfxml_route_impact_on_src_with_other_recv);
surf_parse_get_double(&impact_on_dst_with_other_send,
A_surfxml_route_impact_on_dst_with_other_send);
-
+
nb_link = 0;
- link_list_capacity = 20;
+ link_list_capacity = 1;
link_list = xbt_new(network_link_KCCFLN05_t, link_list_capacity);
+
}
static void parse_route_elem(void)
{
+ xbt_ex_t e;
if (nb_link == link_list_capacity) {
link_list_capacity *= 2;
link_list = xbt_realloc(link_list, (link_list_capacity) * sizeof(network_link_KCCFLN05_t));
}
- link_list[nb_link++] = xbt_dict_get_or_null(network_link_set, A_surfxml_route_element_name);
+ TRY {
+ link_list[nb_link++] = xbt_dict_get(network_link_set, A_surfxml_route_element_name);
+ } CATCH(e) {
+ RETHROW1("Link %s not found (dict raised this exception: %s)",A_surfxml_route_element_name);
+ }
}
static void parse_route_set_route(void)
{
+ if( src_id != -1 && dst_id != -1 )
route_new(src_id, dst_id, link_list, nb_link, impact_on_src,
impact_on_dst, impact_on_src_with_other_recv,
impact_on_dst_with_other_send);
static void parse_file(const char *file)
{
- int i ;
+ int i;
/* Figuring out the cpus */
surf_parse_reset_parser();
create_routing_table();
+ /* Figuring out the router (added after GTNETS) */
+ surf_parse_reset_parser();
+ STag_surfxml_router_fun=parse_routers;
+ surf_parse_open(file);
+ xbt_assert1((!surf_parse()),"Parse error in %s",file);
+ surf_parse_close();
+
/* Figuring out the network links */
surf_parse_reset_parser();
ETag_surfxml_network_link_fun = parse_network_link;
surf_workstation_resource->extension_public->get_link_bandwidth = get_link_bandwidth;
surf_workstation_resource->extension_public->get_link_latency = get_link_latency;
- workstation_set = xbt_dict_new();
+ workstation_set = xbt_dict_new();
+ router_set = xbt_dict_new();
network_link_set = xbt_dict_new();
xbt_assert0(maxmin_system, "surf_init has to be called first!");
xbt_dynar_push(resource_list, &surf_workstation_resource);
}
-
-void surf_workstation_resource_init_KCCFLN05_proportionnal(const char *filename)
-{
- xbt_assert0(!surf_cpu_resource, "CPU resource type already defined");
- xbt_assert0(!surf_network_resource, "network resource type already defined");
- resource_init_internal();
- parse_file(filename);
-
- surf_workstation_resource->common_public->name = "Workstation KCCFLN05 (proportionnal)";
- use_sdp_solver=1;
- xbt_dynar_push(resource_list, &surf_workstation_resource);
-}