From 7fd073cc7b2b6a385a0e5c14ff4ee4c82c1667da Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Tue, 19 Jan 2016 14:19:24 +0100 Subject: [PATCH] Start the SimDag revolution: function renaming + number -> count (workstation/link lists) + remove 'current' in bandwidth/latency getters --- examples/simdag/dax/dax_test.c | 4 +-- examples/simdag/dot/dot_test.c | 2 +- examples/simdag/dot/ptg_test.c | 2 +- examples/simdag/goal/goal_test.c | 2 +- examples/simdag/io/sd_io.c | 2 +- examples/simdag/metaxml/sd_meta.c | 6 ++--- examples/simdag/scheduling/minmin_test.c | 6 ++--- examples/simdag/sd_avail.c | 4 +-- examples/simdag/sd_test.c | 8 +++--- examples/simdag/sd_test2.c | 2 +- include/simgrid/simdag.h | 12 ++++----- src/simdag/sd_global.cpp | 2 +- src/simdag/sd_workstation.cpp | 26 +++++++++---------- .../simdag/availability/availability_test.c | 9 +++---- .../platforms/Evaluate_get_route_time.c | 2 +- .../simdag/platforms/Evaluate_parse_time.c | 2 +- teshsuite/simdag/platforms/basic_link_test.c | 8 +++--- .../simdag/platforms/basic_parsing_test.c | 20 +++++++------- teshsuite/simdag/platforms/flatifier.cpp | 11 ++++---- teshsuite/simdag/platforms/is_router_test.c | 2 +- 20 files changed, 66 insertions(+), 66 deletions(-) diff --git a/examples/simdag/dax/dax_test.c b/examples/simdag/dax/dax_test.c index 6bc8f25538..92b035d1e6 100644 --- a/examples/simdag/dax/dax_test.c +++ b/examples/simdag/dax/dax_test.c @@ -84,11 +84,11 @@ int main(int argc, char **argv) /* Schedule them all on the first workstation */ XBT_INFO("------------------- Schedule tasks ---------------------------"); const SD_workstation_t *ws_list = SD_workstation_get_list(); - int totalHosts = SD_workstation_get_number(); + int totalHosts = SD_workstation_get_count(); qsort((void *) ws_list, totalHosts, sizeof(SD_workstation_t), name_compare_hosts); - int count = SD_workstation_get_number(); + int count = SD_workstation_get_count(); xbt_dynar_foreach(dax, cursor, task) { if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ) { if (!strcmp(SD_task_get_name(task), "end")) diff --git a/examples/simdag/dot/dot_test.c b/examples/simdag/dot/dot_test.c index f263870764..382c9217f1 100644 --- a/examples/simdag/dot/dot_test.c +++ b/examples/simdag/dot/dot_test.c @@ -75,7 +75,7 @@ int main(int argc, char **argv) XBT_INFO("------------------- Schedule tasks ---------------------------"); const SD_workstation_t *ws_list = SD_workstation_get_list(); - int count = SD_workstation_get_number(); + int count = SD_workstation_get_count(); xbt_dynar_foreach(dot, cursor, task) { if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ) { if (!strcmp(SD_task_get_name(task), "end")) diff --git a/examples/simdag/dot/ptg_test.c b/examples/simdag/dot/ptg_test.c index ab2fc095c5..623e461755 100644 --- a/examples/simdag/dot/ptg_test.c +++ b/examples/simdag/dot/ptg_test.c @@ -59,7 +59,7 @@ int main(int argc, char **argv){ /* Schedule them all on all the first workstation */ XBT_INFO("------------------- Schedule tasks ---------------------------"); const SD_workstation_t *ws_list = SD_workstation_get_list(); - int count = SD_workstation_get_number(); + int count = SD_workstation_get_count(); xbt_dynar_foreach(dot, cursor, task) { if (SD_task_get_kind(task) == SD_TASK_COMP_PAR_AMDAHL) { SD_task_schedulev(task, count, ws_list); diff --git a/examples/simdag/goal/goal_test.c b/examples/simdag/goal/goal_test.c index bba9ac7634..1b2e514d9b 100644 --- a/examples/simdag/goal/goal_test.c +++ b/examples/simdag/goal/goal_test.c @@ -73,7 +73,7 @@ int main(int argc, char **argv) { xbt_dynar_t done = NULL; xbt_os_cputimer_start(timer); - send_one(0,SD_workstation_get_number()); + send_one(0,SD_workstation_get_count()); do { if (done != NULL && !xbt_dynar_is_empty(done)) { unsigned int cursor; diff --git a/examples/simdag/io/sd_io.c b/examples/simdag/io/sd_io.c index c215a235b9..5dc9a57578 100644 --- a/examples/simdag/io/sd_io.c +++ b/examples/simdag/io/sd_io.c @@ -29,7 +29,7 @@ int main(int argc, char **argv) SD_config("host/model", "default"); SD_create_environment(argv[1]); workstations = SD_workstation_get_list(); - total_nworkstations = SD_workstation_get_number(); + total_nworkstations = SD_workstation_get_count(); for (ctr=0; ctr 0, "There is no workstation!"); + xbt_assert(SD_workstation_get_count() > 0, "There is no workstation!"); if (sd_global->workstation_list == NULL) /* this is the first time the function is called */ sd_global->workstation_list = (SD_workstation_t*)xbt_dynar_to_array(sg_hosts_as_dynar()); @@ -97,7 +97,7 @@ const SD_workstation_t *SD_workstation_get_list(void) { * \return the number of existing workstations * \see SD_workstation_get_list() */ -int SD_workstation_get_number(void) +int SD_workstation_get_count(void) { return sg_host_count(); } @@ -222,7 +222,7 @@ const SD_link_t *SD_route_get_list(SD_workstation_t src, if (sd_global->recyclable_route == NULL) { /* first run */ - sd_global->recyclable_route = xbt_new(SD_link_t, SD_link_get_number()); + sd_global->recyclable_route = xbt_new(SD_link_t, SD_link_get_count()); } surf_route = surf_host_model_get_route((surf_host_model_t)surf_host_model, src, dst); @@ -301,9 +301,9 @@ double SD_workstation_get_computation_time(SD_workstation_t workstation, * \param src the first workstation * \param dst the second workstation * \return the latency of the route between the two workstations (in seconds) - * \see SD_route_get_current_bandwidth() + * \see SD_route_get_bandwidth() */ -double SD_route_get_current_latency(SD_workstation_t src, SD_workstation_t dst) +double SD_route_get_latency(SD_workstation_t src, SD_workstation_t dst) { xbt_dynar_t route = NULL; double latency; @@ -315,16 +315,16 @@ double SD_route_get_current_latency(SD_workstation_t src, SD_workstation_t dst) } /** - * \brief Returns the bandwidth of the route between two workstations, i.e. the minimum link bandwidth of all - * between the workstations. + * \brief Returns the bandwidth of the route between two workstations, + * i.e. the minimum link bandwidth of all between the workstations. * * \param src the first workstation * \param dst the second workstation - * \return the bandwidth of the route between the two workstations (in bytes/second) - * \see SD_route_get_current_latency() + * \return the bandwidth of the route between the two workstations + * (in bytes/second) + * \see SD_route_get_latency() */ -double SD_route_get_current_bandwidth(SD_workstation_t src, - SD_workstation_t dst) +double SD_route_get_bandwidth(SD_workstation_t src, SD_workstation_t dst) { const SD_link_t *links; @@ -338,7 +338,7 @@ double SD_route_get_current_bandwidth(SD_workstation_t src, min_bandwidth = -1.0; for (i = 0; i < nb_links; i++) { - bandwidth = SD_link_get_current_bandwidth(links[i]); + bandwidth = SD_link_get_bandwidth(links[i]); if (bandwidth < min_bandwidth || min_bandwidth == -1.0) min_bandwidth = bandwidth; } @@ -386,7 +386,7 @@ double SD_route_get_communication_time(SD_workstation_t src, min_bandwidth = -1.0; for (i = 0; i < nb_links; i++) { - bandwidth = SD_link_get_current_bandwidth(links[i]); + bandwidth = SD_link_get_bandwidth(links[i]); if (bandwidth < min_bandwidth || min_bandwidth == -1.0) min_bandwidth = bandwidth; } diff --git a/teshsuite/simdag/availability/availability_test.c b/teshsuite/simdag/availability/availability_test.c index d4fd48f330..02a70204ea 100644 --- a/teshsuite/simdag/availability/availability_test.c +++ b/teshsuite/simdag/availability/availability_test.c @@ -69,12 +69,11 @@ static void scheduleDAX(xbt_dynar_t dax) SD_task_t task; const SD_workstation_t *ws_list = SD_workstation_get_list(); - int totalHosts = SD_workstation_get_number(); + int totalHosts = SD_workstation_get_count(); qsort((void *) ws_list, totalHosts, sizeof(SD_workstation_t), name_compare_hosts); - int count = SD_workstation_get_number(); - //fprintf(stdout, "No. workstations: %d, %d\n", count, (dax != NULL)); + //fprintf(stdout, "No. workstations: %d, %d\n", totalHosts, (dax != NULL)); xbt_dynar_foreach(dax, cursor, task) { if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ) { @@ -85,8 +84,8 @@ static void scheduleDAX(xbt_dynar_t dax) SD_task_schedulel(task, 1, ws_list[0]); } else { fprintf(stdout, "Scheduling %s to node: %s\n", SD_task_get_name(task), - SD_workstation_get_name(ws_list[(cursor) % count])); - SD_task_schedulel(task, 1, ws_list[(cursor) % count]); + SD_workstation_get_name(ws_list[(cursor) % totalHosts])); + SD_task_schedulel(task, 1, ws_list[(cursor) % totalHosts]); } } } diff --git a/teshsuite/simdag/platforms/Evaluate_get_route_time.c b/teshsuite/simdag/platforms/Evaluate_get_route_time.c index 7bc2794577..5eb24b367a 100644 --- a/teshsuite/simdag/platforms/Evaluate_get_route_time.c +++ b/teshsuite/simdag/platforms/Evaluate_get_route_time.c @@ -31,7 +31,7 @@ int main(int argc, char **argv) SD_create_environment(argv[1]); workstations = SD_workstation_get_list(); - list_size = SD_workstation_get_number(); + list_size = SD_workstation_get_count(); /* Random number initialization */ srand( (int) (xbt_os_time()*1000) ); diff --git a/teshsuite/simdag/platforms/Evaluate_parse_time.c b/teshsuite/simdag/platforms/Evaluate_parse_time.c index 33ea0cc3a0..3256886c20 100644 --- a/teshsuite/simdag/platforms/Evaluate_parse_time.c +++ b/teshsuite/simdag/platforms/Evaluate_parse_time.c @@ -29,7 +29,7 @@ int main(int argc, char **argv) /* Display the result and exit after cleanup */ printf( "%f\n", xbt_os_timer_elapsed(timer) ); printf("Workstation number: %d, link number: %d\n", - SD_workstation_get_number(), SD_link_get_number()); + SD_workstation_get_count(), SD_link_get_count()); if(argv[2]){ printf("Wait for %ss\n",argv[2]); sleep(atoi(argv[2])); diff --git a/teshsuite/simdag/platforms/basic_link_test.c b/teshsuite/simdag/platforms/basic_link_test.c index 04a3566f6c..2493e63df8 100644 --- a/teshsuite/simdag/platforms/basic_link_test.c +++ b/teshsuite/simdag/platforms/basic_link_test.c @@ -30,15 +30,15 @@ int main(int argc, char **argv) /* creation of the environment */ SD_create_environment(argv[1]); links = SD_link_get_list(); - int count = SD_link_get_number(); + int count = SD_link_get_count(); XBT_INFO("Link count: %d", count); qsort((void *)links, count, sizeof(SD_link_t), cmp_link); - for(i=0; i= 3) { if (!strcmp(argv[2], "ONE_LINK")) { @@ -49,16 +49,16 @@ int main(int argc, char **argv) for (i = 0; i < route_size; i++) { printf(" Link %s: latency = %f, bandwidth = %f\n", SD_link_get_name(route[i]), - SD_link_get_current_latency(route[i]), - SD_link_get_current_bandwidth(route[i])); + SD_link_get_latency(route[i]), + SD_link_get_bandwidth(route[i])); } printf("Route latency = %f, route bandwidth = %f\n", - SD_route_get_current_latency(w1, w2), - SD_route_get_current_bandwidth(w1, w2)); + SD_route_get_latency(w1, w2), + SD_route_get_bandwidth(w1, w2)); } if (!strcmp(argv[2], "FULL_LINK")) { workstations = SD_workstation_get_list(); - list_size = SD_workstation_get_number(); + list_size = SD_workstation_get_count(); for (i = 0; i < list_size; i++) { w1 = workstations[i]; name1 = SD_workstation_get_name(w1); @@ -72,12 +72,12 @@ int main(int argc, char **argv) for (k = 0; k < route_size; k++) { printf(" Link %s: latency = %f, bandwidth = %f\n", SD_link_get_name(route[k]), - SD_link_get_current_latency(route[k]), - SD_link_get_current_bandwidth(route[k])); + SD_link_get_latency(route[k]), + SD_link_get_bandwidth(route[k])); } printf(" Route latency = %f, route bandwidth = %f\n", - SD_route_get_current_latency(w1, w2), - SD_route_get_current_bandwidth(w1, w2)); + SD_route_get_latency(w1, w2), + SD_route_get_bandwidth(w1, w2)); } } } diff --git a/teshsuite/simdag/platforms/flatifier.cpp b/teshsuite/simdag/platforms/flatifier.cpp index 1adbc2cec8..34c2888d50 100644 --- a/teshsuite/simdag/platforms/flatifier.cpp +++ b/teshsuite/simdag/platforms/flatifier.cpp @@ -128,7 +128,8 @@ int main(int argc, char **argv) if (timings) { XBT_INFO("Parsing time: %fs (%d hosts, %d links)", - xbt_os_timer_elapsed(parse_time),SD_workstation_get_number(),SD_link_get_number()); + xbt_os_timer_elapsed(parse_time),SD_workstation_get_count(), + SD_link_get_count()); } else { printf("\n"); printf("\n"); @@ -137,7 +138,7 @@ int main(int argc, char **argv) printf("\n"); // Hosts - totalHosts = SD_workstation_get_number(); + totalHosts = SD_workstation_get_count(); hosts = SD_workstation_get_list(); qsort((void *) hosts, totalHosts, sizeof(SD_workstation_t), name_compare_hosts); @@ -171,7 +172,7 @@ int main(int argc, char **argv) } // Links - totalLinks = SD_link_get_number(); + totalLinks = SD_link_get_count(); links = SD_link_get_list(); qsort((void *) links, totalLinks, sizeof(SD_link_t), name_compare_links); @@ -181,8 +182,8 @@ int main(int argc, char **argv) printf("%s\" bandwidth=\"%.0f\" latency=\"%.9f\"", SD_link_get_name(links[i]), - SD_link_get_current_bandwidth(links[i]), - SD_link_get_current_latency(links[i])); + SD_link_get_bandwidth(links[i]), + SD_link_get_latency(links[i])); if (SD_link_is_shared(links[i])) { printf("/>\n"); } else { diff --git a/teshsuite/simdag/platforms/is_router_test.c b/teshsuite/simdag/platforms/is_router_test.c index 9d87429944..f6abd93e78 100644 --- a/teshsuite/simdag/platforms/is_router_test.c +++ b/teshsuite/simdag/platforms/is_router_test.c @@ -30,7 +30,7 @@ int main(int argc, char **argv) size = xbt_dict_length(host_list) + xbt_lib_length(as_router_lib); printf("Workstation number: %d, link number: %d, elmts number: %d\n", - SD_workstation_get_number(), SD_link_get_number(), size); + SD_workstation_get_count(), SD_link_get_count(), size); xbt_dict_foreach(host_list, cursor, key, data) { printf(" - Seen: \"%s\" is type : %d\n", key, -- 2.20.1