From c8eac09e9fea8df05ac324368525b417998a60b3 Mon Sep 17 00:00:00 2001 From: quasar Date: Tue, 4 Dec 2007 14:01:00 +0000 Subject: [PATCH] fixed a bug in add_route in all models + dict uses DJB2 hash func now + modified the metaxml example file git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5101 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- examples/platforms/metaxml.xml | 4 ++-- src/cunit_unit.c | 2 +- src/dict_unit.c | 14 +++++++++----- src/surf/network.c | 1 - src/surf/network_gtnets.c | 1 - src/surf/surfxml_parse.c | 3 ++- src/surf/workstation_KCCFLN05.c | 19 ++++++++++--------- src/surf/workstation_ptask_L07.c | 1 - src/xbt/dict.c | 2 +- src/xbt/dict_private.h | 2 +- 10 files changed, 26 insertions(+), 23 deletions(-) diff --git a/examples/platforms/metaxml.xml b/examples/platforms/metaxml.xml index 3d31e0e66b..a223c7a0c1 100644 --- a/examples/platforms/metaxml.xml +++ b/examples/platforms/metaxml.xml @@ -32,8 +32,8 @@ - - + + diff --git a/src/cunit_unit.c b/src/cunit_unit.c index a38d38c55c..b4f05cf696 100644 --- a/src/cunit_unit.c +++ b/src/cunit_unit.c @@ -8,7 +8,7 @@ /* GENERATED FILE, DO NOT EDIT */ /*******************************/ -# 729 "xbt/cunit.c" +# 731 "xbt/cunit.c" XBT_TEST_UNIT("expect",test_expected_failure,"expected failures") { diff --git a/src/dict_unit.c b/src/dict_unit.c index 8064938f99..23e17166f8 100644 --- a/src/dict_unit.c +++ b/src/dict_unit.c @@ -8,7 +8,7 @@ /* GENERATED FILE, DO NOT EDIT */ /*******************************/ -# 472 "xbt/dict.c" +# 603 "xbt/dict.c" #include "xbt.h" #include "xbt/ex.h" #include "portable.h" @@ -89,7 +89,7 @@ static void traverse(xbt_dict_t head) { xbt_test_log2("Seen #%d: %s",++i,PRINTF_STR(key)); } xbt_test_assert2(!data || !strcmp(key,data), - "Key(%s) != value(%s). Abording\n",key,data); + "Key(%s) != value(%s). Abording",key,data); } } @@ -312,7 +312,7 @@ static int countelems(xbt_dict_t head) { } return res; } - + XBT_TEST_UNIT("crash",test_dict_crash,"Crash test"){ xbt_dict_t head=NULL; int i,j,k, nb; @@ -363,7 +363,8 @@ XBT_TEST_UNIT("crash",test_dict_crash,"Crash test"){ sprintf(key,"%d",j); xbt_dict_set(head,key,key,&free); } - + /*xbt_dict_dump(head,(void (*)(void*))&printf);*/ + xbt_test_add0("Count the elements (retrieving the key and data for each)"); i = countelems(head); xbt_test_log1("There is %d elements",i); @@ -377,7 +378,10 @@ XBT_TEST_UNIT("crash",test_dict_crash,"Crash test"){ sprintf(key,"%d",j); data = xbt_dict_get(head,key); xbt_test_assert2(!strcmp(key,(char*)data), - "key=%s != data=%s\n",key,(char*)data); + "with get, key=%s != data=%s",key,(char*)data); + data = xbt_dict_get_ext(head,key,strlen(key)); + xbt_test_assert2(!strcmp(key,(char*)data), + "with get_ext, key=%s != data=%s",key,(char*)data); } } free(key); diff --git a/src/surf/network.c b/src/surf/network.c index 697a67463c..b3b8adba47 100644 --- a/src/surf/network.c +++ b/src/surf/network.c @@ -226,7 +226,6 @@ static void add_route(void) } } route_new(src_id, dst_id, link_list, nb_link); - xbt_dynar_free(&links); } xbt_dict_free(&route_table); diff --git a/src/surf/network_gtnets.c b/src/surf/network_gtnets.c index fb04b380d3..a37cdac2bb 100644 --- a/src/surf/network_gtnets.c +++ b/src/surf/network_gtnets.c @@ -301,7 +301,6 @@ static void add_route() route_new(src_id, dst_id, link_name, nb_link); if (nb_link == 1) route_onehop_new(src_id, dst_id, link_name, nb_link); - xbt_dynar_free(&links); } xbt_dict_free(&route_table); diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index 76ee1b51d1..7fd132a908 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -802,6 +802,7 @@ static void add_multi_links(const char* src, const char* dst, xbt_dynar_t links, val = xbt_strdup(src_name); else val = xbt_strdup(value); + DEBUG1("\t\tELEMENT: %s", val); xbt_dynar_push(route_link_list, &val); } surfxml_call_cb_functions(ETag_surfxml_route_cb_list); @@ -931,7 +932,7 @@ void parse_cluster(void) char * backbone_name = bprintf("%s_bb", cluster_id); parse_change_link_data(backbone_name, cluster_bb_bw, "", cluster_bb_lat, "", ""); A_surfxml_link_state = A_surfxml_link_state_ON; - A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED; + A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_FATPIPE; SURFXML_START_TAG(link); SURFXML_END_TAG(link); diff --git a/src/surf/workstation_KCCFLN05.c b/src/surf/workstation_KCCFLN05.c index fd1329e528..62aaf4f1c3 100644 --- a/src/surf/workstation_KCCFLN05.c +++ b/src/surf/workstation_KCCFLN05.c @@ -909,6 +909,7 @@ static cpu_KCCFLN05_t cpu_new(const char *name, double power_scale, xbt_dict_t cpu_properties_k) { cpu_KCCFLN05_t cpu = xbt_new0(s_cpu_KCCFLN05_t, 1); + xbt_assert1(! xbt_dict_get_or_null(workstation_set, name), "Host '%s' declared several times in the platform file.",name); @@ -1159,9 +1160,7 @@ static void parse_route_set_route(void) { char* name; if (src_id != -1 && dst_id != -1) { - name = bprintf("%x#%x#%lf#%lf#%lf#%lf",src_id, dst_id,impact_on_src, - impact_on_dst, impact_on_src_with_other_recv, - impact_on_dst_with_other_send); + name = bprintf("%x#%x",src_id, dst_id); manage_route(route_table, name, route_action, 0); free(name); @@ -1211,24 +1210,26 @@ static void add_route(void) src_id = strtol(xbt_dynar_get_as(keys, 0, char*), &end, 16); dst_id = strtol(xbt_dynar_get_as(keys, 1, char*), &end, 16); - impact_on_src = atof(xbt_dynar_get_as(keys, 2, char*)); - impact_on_dst = atof(xbt_dynar_get_as(keys, 3, char*)); - impact_on_src_with_other_recv = atof(xbt_dynar_get_as(keys, 4, char*)); - impact_on_dst_with_other_send = atof(xbt_dynar_get_as(keys, 5, char*)); + /*ATTRIBUTES NOT USED ANYMORE. WILL BE REMOVED FROM MODEL.*/ + impact_on_src = 0;//atof(xbt_dynar_get_as(keys, 2, char*)); + impact_on_dst = 0; //atof(xbt_dynar_get_as(keys, 3, char*)); + impact_on_src_with_other_recv = 0;//atof(xbt_dynar_get_as(keys, 4, char*)); + impact_on_dst_with_other_send = 0;//atof(xbt_dynar_get_as(keys, 5, char*)); char* link = NULL; + INFO2("%d - %d", src_id, dst_id); xbt_dynar_foreach (links, cpt, link) { TRY { + INFO1("\t%s",link); link_list[nb_link++] = xbt_dict_get(link_set, link); } CATCH(e) { - RETHROW1("Link %s not found (dict raised this exception: %s)", link); + RETHROW3("Link %s not found between %s and %s (dict raised this exception: %s)", link,src,dst); } } 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); - xbt_dynar_free(&links); } xbt_dict_free(&route_table); diff --git a/src/surf/workstation_ptask_L07.c b/src/surf/workstation_ptask_L07.c index 258322b9ec..2d553aea45 100644 --- a/src/surf/workstation_ptask_L07.c +++ b/src/surf/workstation_ptask_L07.c @@ -935,7 +935,6 @@ static void add_route(void) } } route_new(src_id, dst_id, link_list, nb_link); - xbt_dynar_free(&links); } xbt_dict_free(&route_table); diff --git a/src/xbt/dict.c b/src/xbt/dict.c index 1c926c4432..52e22b9aec 100644 --- a/src/xbt/dict.c +++ b/src/xbt/dict.c @@ -7,7 +7,7 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -//#define DJB2_HASH_FUNCTION +#define DJB2_HASH_FUNCTION //#define FNV_HASH_FUNCTION #include diff --git a/src/xbt/dict_private.h b/src/xbt/dict_private.h index bbb2ffb65b..1332b75e39 100644 --- a/src/xbt/dict_private.h +++ b/src/xbt/dict_private.h @@ -20,7 +20,7 @@ typedef struct xbt_dictelm_ *xbt_dictelm_t; -#define MAX_FILL_PERCENT 60 +#define MAX_FILL_PERCENT 80 typedef struct xbt_dictelm_ { char *key; -- 2.20.1