From: Martin Quinson Date: Sun, 28 Feb 2016 12:02:28 +0000 (+0100) Subject: Merge branch 'master' of github.com:mquinson/simgrid X-Git-Tag: v3_13~646 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/c46aba70aa4ccf22cc19fac31d451c7158e922dd?hp=ba9a4cfeba4eb00e84cd17603fc9654e81445655 Merge branch 'master' of github.com:mquinson/simgrid --- diff --git a/ChangeLog b/ChangeLog index 116bc1d3ef..8a780fd781 100644 --- a/ChangeLog +++ b/ChangeLog @@ -81,6 +81,7 @@ SimGrid (3.13) UNRELEASED; urgency=low * Kill the xbt_peer_t data type: it's useless without GRAS. * Kill rm_cb feature of config sets: it was never useful. * Kill graphxml parsing feature. It was not used. + * Kill the deprecated code protected by XBT_USE_DEPRECATED * New functions: - xbt_dynar_sort_strings(), when the content is char* - xbt_str_parse_int / xbt_str_parse_double, wrapping strtol/strtod diff --git a/examples/msg/parallel_task/parallel_task.c b/examples/msg/parallel_task/parallel_task.c index 13866dd96c..e291efdd79 100644 --- a/examples/msg/parallel_task/parallel_task.c +++ b/examples/msg/parallel_task/parallel_task.c @@ -4,32 +4,21 @@ /* 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. */ -#include -#include "simgrid/msg.h" /* Yeah! If you want to use msg, you need to include simgrid/msg.h */ -#include "xbt/sysdep.h" /* calloc, printf */ +#include "simgrid/msg.h" -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -#include "xbt/asserts.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); /** @addtogroup MSG_examples * - * - parallel_task/parallel_task.c: Demonstrates the use of - * @ref MSG_parallel_task_create, to create special tasks that run - * on several hosts at the same time. The resulting simulations are - * very close to what can be achieved in @ref SD_API, but still - * allows to use the other features of MSG (it'd be cool to be able - * to mix interfaces, but it's not possible ATM). + * - parallel_task/parallel_task.c: Demonstrates the use of @ref MSG_parallel_task_create, to create special + * tasks that run on several hosts at the same time. The resulting simulations are very close to what can be + * achieved in @ref SD_API, but still allows to use the other features of MSG (it'd be cool to be able to mix + * interfaces, but it's not possible ATM). */ -/** Function in charge of running the example (that's a simgrid process) */ static int runner(int argc, char *argv[]) { - int i, j; - /* Retrieve the list of all hosts as an array of hosts */ xbt_dynar_t slaves_dynar = MSG_hosts_as_dynar(); int slaves_count = xbt_dynar_length(slaves_dynar); @@ -39,24 +28,25 @@ static int runner(int argc, char *argv[]) double *computation_amounts = xbt_new0(double, slaves_count); double *communication_amounts = xbt_new0(double, slaves_count * slaves_count); - for (i = 0; i < slaves_count; i++) + for (int i = 0; i < slaves_count; i++) computation_amounts[i] = 1e9; // 1 Gflop - for (i = 0; i < slaves_count; i++) - for (j = i + 1; j < slaves_count; j++) + for (int i = 0; i < slaves_count; i++) + for (int j = i + 1; j < slaves_count; j++) communication_amounts[i * slaves_count + j] = 1e7; // 10 MB - msg_task_t ptask = MSG_parallel_task_create("parallel task", - slaves_count, slaves, computation_amounts, communication_amounts, NULL /* no specific data to attach */); + msg_task_t ptask = + MSG_parallel_task_create("parallel task", slaves_count, slaves, computation_amounts, communication_amounts, NULL); MSG_parallel_task_execute(ptask); MSG_task_destroy(ptask); /* The arrays communication_amounts and computation_amounts are not to be freed manually */ XBT_INFO("Then, build a parallel task involving only computations and no communication (1 Gflop per node)"); computation_amounts = xbt_new0(double, slaves_count); - for (i = 0; i < slaves_count; i++) + for (int i = 0; i < slaves_count; i++) computation_amounts[i] = 1e9; // 1 Gflop - ptask = MSG_parallel_task_create("parallel exec", slaves_count, slaves, computation_amounts, NULL/* no comm */, NULL /* no data */); + ptask = + MSG_parallel_task_create("parallel exec", slaves_count, slaves, computation_amounts, NULL/* no comm */, NULL); MSG_parallel_task_execute(ptask); MSG_task_destroy(ptask); @@ -65,7 +55,7 @@ static int runner(int argc, char *argv[]) computation_amounts[0] = 1e9; // 1 Gflop msg_host_t *remote = xbt_new(msg_host_t,1); remote[0] = slaves[1]; - ptask = MSG_parallel_task_create("remote exec", 1, remote, computation_amounts, NULL/* no comm */, NULL /* no data */); + ptask = MSG_parallel_task_create("remote exec", 1, remote, computation_amounts, NULL/* no comm */, NULL); MSG_parallel_task_execute(ptask); MSG_task_destroy(ptask); free(remote); diff --git a/examples/msg/priority/priority.c b/examples/msg/priority/priority.c index b184bf5c86..6b951e443e 100644 --- a/examples/msg/priority/priority.c +++ b/examples/msg/priority/priority.c @@ -4,22 +4,13 @@ /* 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. */ -#include -#include "simgrid/msg.h" /* Yeah! If you want to use msg, you need to include simgrid/msg.h */ -#include "xbt/sysdep.h" /* calloc, printf */ - -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -#include "xbt/asserts.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); +#include "simgrid/msg.h" +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); /** @addtogroup MSG_examples * * - priority/priority.c: Demonstrates the use of @ref - * MSG_task_set_priority to change the computation priority of a - * given task. - * + * MSG_task_set_priority to change the computation priority of a given task. */ static int test(int argc, char *argv[]) @@ -33,8 +24,7 @@ static int test(int argc, char *argv[]) res = sscanf(argv[2], "%lg", &priority); xbt_assert(res, "Invalid argument %s\n", argv[2]); - XBT_INFO("Hello! Running a task of size %g with priority %g", - computation_amount, priority); + XBT_INFO("Hello! Running a task of size %g with priority %g", computation_amount, priority); task = MSG_task_create("Task", computation_amount, 0.0, NULL); MSG_task_set_priority(task, priority); @@ -45,44 +35,21 @@ static int test(int argc, char *argv[]) return 0; } -static msg_error_t test_all(const char *platform_file, - const char *application_file) -{ - msg_error_t res = MSG_OK; - - { /* Simulation setting */ - MSG_create_environment(platform_file); - } - { /* Application deployment */ - MSG_function_register("test", test); - MSG_launch_application(application_file); - } - res = MSG_main(); - - XBT_INFO("Simulation time %g", MSG_get_clock()); - return res; -} - int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; -#ifdef _MSC_VER - unsigned int prev_exponent_format = - _set_output_format(_TWO_DIGIT_EXPONENT); -#endif - - MSG_init(&argc, argv); xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" - "\tExample: %s msg_platform.xml msg_deployment.xml\n", - argv[0], argv[0]); - - res = test_all(argv[1], argv[2]); + "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); + + MSG_create_environment(argv[1]); + MSG_function_register("test", test); + MSG_launch_application(argv[2]); -#ifdef _MSC_VER - _set_output_format(prev_exponent_format); -#endif + res = MSG_main(); + + XBT_INFO("Simulation time %g", MSG_get_clock()); return res != MSG_OK; } diff --git a/examples/msg/sendrecv/CMakeLists.txt b/examples/msg/sendrecv/CMakeLists.txt index d9597ccaa7..62f6367369 100644 --- a/examples/msg/sendrecv/CMakeLists.txt +++ b/examples/msg/sendrecv/CMakeLists.txt @@ -7,7 +7,6 @@ set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/sendrecv_CLM03_main.tesh ${CMAKE_CURRENT_SOURCE_DIR}/sendrecv_CLM03.tesh - ${CMAKE_CURRENT_SOURCE_DIR}/sendrecv_KCCFLN05.tesh ${CMAKE_CURRENT_SOURCE_DIR}/sendrecv_Reno.tesh ${CMAKE_CURRENT_SOURCE_DIR}/sendrecv_Vegas.tesh PARENT_SCOPE) diff --git a/examples/msg/sendrecv/sendrecv.c b/examples/msg/sendrecv/sendrecv.c index fbff3868fa..1c3f625d78 100644 --- a/examples/msg/sendrecv/sendrecv.c +++ b/examples/msg/sendrecv/sendrecv.c @@ -4,14 +4,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. */ -#include - -#include "simgrid/msg.h" /* Yeah! If you want to use msg, you need to include simgrid/msg.h */ -#include "xbt/sysdep.h" /* calloc */ - -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -#include "xbt/asserts.h" +#include "simgrid/msg.h" /** @addtogroup MSG_examples * @@ -20,20 +13,12 @@ * directory are instructive concerning the way to pass options to the simulators (as described in \ref options). */ -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); - -int sender(int argc, char *argv[]); -int receiver(int argc, char *argv[]); - -msg_error_t test_all(const char *platform_file, - const char *application_file); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); double task_comm_size_lat = 1; double task_comm_size_bw = 10e8; -/** Emitter function */ -int sender(int argc, char *argv[]) +static int sender(int argc, char *argv[]) { msg_host_t host = NULL; double time; @@ -43,9 +28,6 @@ int sender(int argc, char *argv[]) char sprintf_buffer_bw[64]; XBT_INFO("sender"); - - /*host = xbt_new0(msg_host_t,1); */ - XBT_INFO("host = %s", argv[1]); host = MSG_host_by_name(argv[1]); @@ -55,8 +37,7 @@ int sender(int argc, char *argv[]) /* Latency */ time = MSG_get_clock(); sprintf(sprintf_buffer_la, "latency task"); - task_la = - MSG_task_create(sprintf_buffer_la, 0.0, task_comm_size_lat, NULL); + task_la = MSG_task_create(sprintf_buffer_la, 0.0, task_comm_size_lat, NULL); task_la->data = xbt_new(double, 1); *(double *) task_la->data = time; XBT_INFO("task_la->data = %e", *((double *) task_la->data)); @@ -65,36 +46,31 @@ int sender(int argc, char *argv[]) /* Bandwidth */ time = MSG_get_clock(); sprintf(sprintf_buffer_bw, "bandwidth task"); - task_bw = - MSG_task_create(sprintf_buffer_bw, 0.0, task_comm_size_bw, NULL); + task_bw = MSG_task_create(sprintf_buffer_bw, 0.0, task_comm_size_bw, NULL); task_bw->data = xbt_new(double, 1); *(double *) task_bw->data = time; XBT_INFO("task_bw->data = %e", *((double *) task_bw->data)); MSG_task_send(task_bw, argv[1]); return 0; -} /* end_of_client */ +} -/** Receiver function */ -int receiver(int argc, char *argv[]) +static int receiver(int argc, char *argv[]) { - double time, time1, sender_time; msg_task_t task_la = NULL; msg_task_t task_bw = NULL; - int a; - double communication_time = 0; XBT_INFO("receiver"); /* Get Latency */ - a = MSG_task_receive(&task_la,MSG_host_get_name(MSG_host_self())); + int a = MSG_task_receive(&task_la,MSG_host_get_name(MSG_host_self())); xbt_assert(a == MSG_OK, "Unexpected behavior"); - time1 = MSG_get_clock(); - sender_time = *((double *) (task_la->data)); - time = sender_time; - communication_time = time1 - time; + double time1 = MSG_get_clock(); + double sender_time = *((double *) (task_la->data)); + double time = sender_time; + double communication_time = time1 - time; XBT_INFO("Task received : %s", task_la->name); xbt_free(task_la->data); MSG_task_destroy(task_la); @@ -103,7 +79,6 @@ int receiver(int argc, char *argv[]) /* Get Bandwidth */ a = MSG_task_receive(&task_bw,MSG_host_get_name(MSG_host_self())); - xbt_assert(a == MSG_OK, "Unexpected behavior"); time1 = MSG_get_clock(); @@ -117,54 +92,26 @@ int receiver(int argc, char *argv[]) XBT_INFO("--- bw %f ----", task_comm_size_bw / communication_time); return 0; -} /* end_of_receiver */ +} - -/** Test function */ -msg_error_t test_all(const char *platform_file, - const char *application_file) +int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; - XBT_INFO("test_all"); + MSG_init(&argc, argv); + + xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" + "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); - /* Simulation setting */ - MSG_create_environment(platform_file); + MSG_create_environment(argv[1]); - /* Application deployment */ MSG_function_register("sender", sender); MSG_function_register("receiver", receiver); - MSG_launch_application(application_file); + MSG_launch_application(argv[2]); res = MSG_main(); - return res; -} /* end_of_test_all */ - - -/** Main function */ -int main(int argc, char *argv[]) -{ - msg_error_t res = MSG_OK; - -#ifdef _MSC_VER - unsigned int prev_exponent_format = - _set_output_format(_TWO_DIGIT_EXPONENT); -#endif - - MSG_init(&argc, argv); - - xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" - "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); - - res = test_all(argv[1], argv[2]); - XBT_INFO("Total simulation time: %e", MSG_get_clock()); - -#ifdef _MSC_VER - _set_output_format(prev_exponent_format); -#endif - - return res != MSG_OK; -} /* end_of_main */ + return res!=MSG_OK; +} diff --git a/examples/msg/sendrecv/sendrecv_CLM03.tesh b/examples/msg/sendrecv/sendrecv_CLM03.tesh index eb9d53f061..1012f2f4db 100644 --- a/examples/msg/sendrecv/sendrecv_CLM03.tesh +++ b/examples/msg/sendrecv/sendrecv_CLM03.tesh @@ -6,7 +6,6 @@ p Testing the deprecated CM02 network model $ $SG_TEST_EXENV sendrecv/sendrecv$EXEEXT ${srcdir:=.}/../platforms/small_platform.xml ${srcdir:=.}/sendrecv/deployment_sendrecv.xml --cfg=cpu/model:Cas01 --cfg=network/model:CM02 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 0.000000] (0:maestro@) Configuration change: Set 'cpu/model' to 'Cas01' > [ 0.000000] (0:maestro@) Configuration change: Set 'network/model' to 'CM02' -> [ 0.000000] (0:maestro@) test_all > [ 0.000000] (1:sender@Tremblay) sender > [ 0.000000] (1:sender@Tremblay) host = Jupiter > [ 0.000000] (1:sender@Tremblay) task_la->data = 0.000000e+00 @@ -15,7 +14,7 @@ $ $SG_TEST_EXENV sendrecv/sendrecv$EXEEXT ${srcdir:=.}/../platforms/small_platfo > [ 0.001462] (2:receiver@Jupiter) Communic. time 1.461656e-03 > [ 0.001462] (2:receiver@Jupiter) --- la 0.001462 ---- > [ 0.001462] (1:sender@Tremblay) task_bw->data = 1.461656e-03 +> [138.703988] (0:maestro@) Total simulation time: 1.387040e+02 > [138.703988] (2:receiver@Jupiter) Task received : bandwidth task > [138.703988] (2:receiver@Jupiter) Communic. time 1.387025e+02 > [138.703988] (2:receiver@Jupiter) --- bw 7209674.030423 ---- -> [138.703988] (0:maestro@) Total simulation time: 1.387040e+02 diff --git a/examples/msg/sendrecv/sendrecv_CLM03_main.tesh b/examples/msg/sendrecv/sendrecv_CLM03_main.tesh index 8cfd78411c..683db7203f 100644 --- a/examples/msg/sendrecv/sendrecv_CLM03_main.tesh +++ b/examples/msg/sendrecv/sendrecv_CLM03_main.tesh @@ -6,7 +6,6 @@ p Testing the deprecated CM02 network model $ $SG_TEST_EXENV sendrecv/sendrecv_main$EXEEXT ${srcdir:=.}/../platforms/small_platform.xml ${srcdir:=.}/sendrecv/deployment_sendrecv_main.xml --cfg=cpu/model:Cas01 --cfg=network/model:CM02 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 0.000000] (0:maestro@) Configuration change: Set 'cpu/model' to 'Cas01' > [ 0.000000] (0:maestro@) Configuration change: Set 'network/model' to 'CM02' -> [ 0.000000] (0:maestro@) test_all > [ 0.000000] (1:sender@Tremblay) sender > [ 0.000000] (1:sender@Tremblay) host = Jupiter > [ 0.000000] (1:sender@Tremblay) task_la->data = 0.000000e+00 @@ -15,7 +14,7 @@ $ $SG_TEST_EXENV sendrecv/sendrecv_main$EXEEXT ${srcdir:=.}/../platforms/small_p > [ 0.001462] (2:receiver@Jupiter) Communic. time 1.461656e-03 > [ 0.001462] (2:receiver@Jupiter) --- la 0.001462 ---- > [ 0.001462] (1:sender@Tremblay) task_bw->data = 1.461656e-03 +> [138.703988] (0:maestro@) Total simulation time: 1.387040e+02 > [138.703988] (2:receiver@Jupiter) Task received : bandwidth task > [138.703988] (2:receiver@Jupiter) Communic. time 1.387025e+02 > [138.703988] (2:receiver@Jupiter) --- bw 7209674.030423 ---- -> [138.703988] (0:maestro@) Total simulation time: 1.387040e+02 diff --git a/examples/msg/sendrecv/sendrecv_KCCFLN05.tesh b/examples/msg/sendrecv/sendrecv_KCCFLN05.tesh deleted file mode 100644 index 2355d9cfa8..0000000000 --- a/examples/msg/sendrecv/sendrecv_KCCFLN05.tesh +++ /dev/null @@ -1,18 +0,0 @@ -#! ./tesh - -p Testing the surf network maxmin fairness model - -$ $SG_TEST_EXENV sendrecv/sendrecv$EXEEXT ${srcdir:=.}/sendrecv/platform_sendrecv.xml ${srcdir:=.}/sendrecv/deployment_sendrecv.xml -> [0.000000] [msg_test/INFO] test_all -> [Inmos:sender:(1) 0.000000] [msg_test/INFO] sender -> [Inmos:sender:(1) 0.000000] [msg_test/INFO] host = Bellevue -> [Inmos:sender:(1) 0.000000] [msg_test/INFO] task_la->data = 0.000000e+00 -> [Bellevue:receiver:(2) 0.000000] [msg_test/INFO] receiver -> [Inmos:sender:(1) 0.100100] [msg_test/INFO] task_bw->data = 1.001000e-01 -> [Bellevue:receiver:(2) 0.100100] [msg_test/INFO] Task received : latency task -> [Bellevue:receiver:(2) 0.100100] [msg_test/INFO] Communic. time 1.001000e-01 -> [Bellevue:receiver:(2) 0.100100] [msg_test/INFO] --- la 0.100100 ---- -> [Bellevue:receiver:(2) 10000.200100] [msg_test/INFO] Task received : bandwidth task -> [Bellevue:receiver:(2) 10000.200100] [msg_test/INFO] Communic. time 1.000010e+04 -> [Bellevue:receiver:(2) 10000.200100] [msg_test/INFO] --- bw 99999.000010 ---- -> [10000.200100] [msg_test/INFO] Total simulation time: 1.000020e+04 diff --git a/examples/msg/sendrecv/sendrecv_Reno.tesh b/examples/msg/sendrecv/sendrecv_Reno.tesh index b67abaaea6..cd6a6acc1b 100644 --- a/examples/msg/sendrecv/sendrecv_Reno.tesh +++ b/examples/msg/sendrecv/sendrecv_Reno.tesh @@ -7,7 +7,6 @@ $ $SG_TEST_EXENV sendrecv/sendrecv$EXEEXT ${srcdir:=.}/../platforms/small_platfo > [ 0.000000] (0:maestro@) Configuration change: Set 'host/model' to 'compound' > [ 0.000000] (0:maestro@) Configuration change: Set 'cpu/model' to 'Cas01' > [ 0.000000] (0:maestro@) Configuration change: Set 'network/model' to 'Reno' -> [ 0.000000] (0:maestro@) test_all > [ 0.000000] (1:sender@Tremblay) sender > [ 0.000000] (1:sender@Tremblay) host = Jupiter > [ 0.000000] (1:sender@Tremblay) task_la->data = 0.000000e+00 diff --git a/examples/msg/sendrecv/sendrecv_Vegas.tesh b/examples/msg/sendrecv/sendrecv_Vegas.tesh index 47f4e6012c..3f8202ba60 100644 --- a/examples/msg/sendrecv/sendrecv_Vegas.tesh +++ b/examples/msg/sendrecv/sendrecv_Vegas.tesh @@ -7,7 +7,6 @@ $ $SG_TEST_EXENV sendrecv/sendrecv$EXEEXT ${srcdir:=.}/../platforms/small_platfo > [ 0.000000] (0:maestro@) Configuration change: Set 'host/model' to 'compound' > [ 0.000000] (0:maestro@) Configuration change: Set 'cpu/model' to 'Cas01' > [ 0.000000] (0:maestro@) Configuration change: Set 'network/model' to 'Vegas' -> [ 0.000000] (0:maestro@) test_all > [ 0.000000] (1:sender@Tremblay) sender > [ 0.000000] (1:sender@Tremblay) host = Jupiter > [ 0.000000] (1:sender@Tremblay) task_la->data = 0.000000e+00 diff --git a/examples/msg/sendrecv/sendrecv_main.c b/examples/msg/sendrecv/sendrecv_main.c index 684693488c..859f14536c 100644 --- a/examples/msg/sendrecv/sendrecv_main.c +++ b/examples/msg/sendrecv/sendrecv_main.c @@ -4,33 +4,20 @@ /* 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. */ -#include - -#include "simgrid/msg.h" /* Yeah! If you want to use msg, you need to include simgrid/msg.h */ -#include "xbt/sysdep.h" /* calloc */ - -/* Create a log channel to have nice outputs. */ -#include "xbt/log.h" -#include "xbt/asserts.h" +#include "simgrid/msg.h" /** @addtogroup MSG_examples * - * - sendrecv/sendrecv.c: Ping-pong example. It's hard to - * think of a simpler example. The tesh files laying in the - * directory are instructive concerning the way to pass options to the simulators (as described in \ref options). + * - sendrecv/sendrecv.c: Ping-pong example. It's hard to think of a simpler example. The tesh files laying in + * the directory are instructive concerning the way to pass options to the simulators (as described in \ref options). */ -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, - "Messages specific for this msg example"); - -int sender(int argc, char *argv[]); -int receiver(int argc, char *argv[]); +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); double task_comm_size_lat = 1; double task_comm_size_bw = 10e8; -/** Emitter function */ -int sender(int argc, char *argv[]) +static int sender(int argc, char *argv[]) { msg_host_t host = NULL; double time; @@ -40,9 +27,6 @@ int sender(int argc, char *argv[]) char sprintf_buffer_bw[64]; XBT_INFO("sender"); - - /*host = xbt_new0(msg_host_t,1); */ - XBT_INFO("host = %s", argv[1]); host = MSG_host_by_name(argv[1]); @@ -55,8 +39,7 @@ int sender(int argc, char *argv[]) /* Latency */ time = MSG_get_clock(); sprintf(sprintf_buffer_la, "latency task"); - task_la = - MSG_task_create(sprintf_buffer_la, 0.0, task_comm_size_lat, NULL); + task_la = MSG_task_create(sprintf_buffer_la, 0.0, task_comm_size_lat, NULL); task_la->data = xbt_new(double, 1); *(double *) task_la->data = time; XBT_INFO("task_la->data = %e", *((double *) task_la->data)); @@ -65,62 +48,51 @@ int sender(int argc, char *argv[]) /* Bandwidth */ time = MSG_get_clock(); sprintf(sprintf_buffer_bw, "bandwidth task"); - task_bw = - MSG_task_create(sprintf_buffer_bw, 0.0, task_comm_size_bw, NULL); + task_bw = MSG_task_create(sprintf_buffer_bw, 0.0, task_comm_size_bw, NULL); task_bw->data = xbt_new(double, 1); *(double *) task_bw->data = time; XBT_INFO("task_bw->data = %e", *((double *) task_bw->data)); MSG_task_send(task_bw, argv[1]); return 0; -} /* end_of_client */ +} -/** Receiver function */ -int receiver(int argc, char *argv[]) +static int receiver(int argc, char *argv[]) { - double time, time1, sender_time; msg_task_t task_la = NULL; msg_task_t task_bw = NULL; - int a; - double communication_time = 0; XBT_INFO("receiver"); /* Get Latency */ - a = MSG_task_receive(&task_la,MSG_host_get_name(MSG_host_self())); - if (a == MSG_OK) { - time1 = MSG_get_clock(); - sender_time = *((double *) (task_la->data)); - time = sender_time; - communication_time = time1 - time; - XBT_INFO("Task received : %s", task_la->name); - xbt_free(task_la->data); - MSG_task_destroy(task_la); - XBT_INFO("Communic. time %e", communication_time); - XBT_INFO("--- la %f ----", communication_time); - } else { - xbt_die("Unexpected behavior"); - } + int a = MSG_task_receive(&task_la,MSG_host_get_name(MSG_host_self())); + xbt_assert(a == MSG_OK, "Unexpected behavior"); + + double time1 = MSG_get_clock(); + double sender_time = *((double *) (task_la->data)); + double time = sender_time; + double communication_time = time1 - time; + XBT_INFO("Task received : %s", task_la->name); + xbt_free(task_la->data); + MSG_task_destroy(task_la); + XBT_INFO("Communic. time %e", communication_time); + XBT_INFO("--- la %f ----", communication_time); /* Get Bandwidth */ a = MSG_task_receive(&task_bw,MSG_host_get_name(MSG_host_self())); - if (a == MSG_OK) { - time1 = MSG_get_clock(); - sender_time = *((double *) (task_bw->data)); - time = sender_time; - communication_time = time1 - time; - XBT_INFO("Task received : %s", task_bw->name); - xbt_free(task_bw->data); - MSG_task_destroy(task_bw); - XBT_INFO("Communic. time %e", communication_time); - XBT_INFO("--- bw %f ----", task_comm_size_bw / communication_time); - } else { - xbt_die("Unexpected behavior"); - } - + xbt_assert(a == MSG_OK, "Unexpected behavior"); + time1 = MSG_get_clock(); + sender_time = *((double *) (task_bw->data)); + time = sender_time; + communication_time = time1 - time; + XBT_INFO("Task received : %s", task_bw->name); + xbt_free(task_bw->data); + MSG_task_destroy(task_bw); + XBT_INFO("Communic. time %e", communication_time); + XBT_INFO("--- bw %f ----", task_comm_size_bw / communication_time); return 0; -} /* end_of_receiver */ +} struct application { const char* platform_file; @@ -132,18 +104,13 @@ static msg_error_t test_all(struct application* app) { msg_error_t res = MSG_OK; - XBT_INFO("test_all"); - - /* Simulation setting */ MSG_create_environment(app->platform_file); /* Become one of the simulated process. * - * This must be done after the creation of the platform - * because we are depending attaching to a host.*/ + * This must be done after the creation of the platform because we are depending attaching to a host.*/ MSG_process_attach("sender", NULL, MSG_host_by_name("Tremblay"), NULL); - /* Application deployment */ MSG_function_register("receiver", receiver); MSG_launch_application(app->application_file); @@ -156,10 +123,8 @@ static msg_error_t test_all(struct application* app) return res; } /* end_of_test_all */ -static -void maestro(void* data) +static void maestro(void* data) { - // struct application* app = (struct application*) data; MSG_main(); } @@ -168,11 +133,6 @@ int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; -#ifdef _MSC_VER - unsigned int prev_exponent_format = - _set_output_format(_TWO_DIGIT_EXPONENT); -#endif - struct application app; app.platform_file = argv[1]; app.application_file = argv[2]; @@ -181,21 +141,12 @@ int main(int argc, char *argv[]) MSG_init(&argc, argv); if (argc != 3) { - XBT_CRITICAL("Usage: %s platform_file deployment_file\n", - argv[0]); + XBT_CRITICAL("Usage: %s platform_file deployment_file\n", argv[0]); xbt_die("example: %s msg_platform.xml msg_deployment.xml\n",argv[0]); } res = test_all(&app); XBT_INFO("Total simulation time: %e", MSG_get_clock()); - -#ifdef _MSC_VER - _set_output_format(prev_exponent_format); -#endif - - if (res == MSG_OK) - return 0; - else - return 1; -} /* end_of_main */ + return res != MSG_OK; +} diff --git a/examples/msg/suspend/suspend.c b/examples/msg/suspend/suspend.c index 13db39fea6..84da0a8b30 100644 --- a/examples/msg/suspend/suspend.c +++ b/examples/msg/suspend/suspend.c @@ -78,7 +78,9 @@ int main(int argc, char *argv[]) MSG_create_environment(argv[1]); MSG_function_register("dream_master", dream_master); - MSG_process_create("dream_master", dream_master, NULL, xbt_dynar_getfirst_as(MSG_hosts_as_dynar(), msg_host_t)); + xbt_dynar_t hosts = MSG_hosts_as_dynar(); + MSG_process_create("dream_master", dream_master, NULL, xbt_dynar_getfirst_as(hosts, msg_host_t)); + xbt_dynar_free(&hosts); res = MSG_main(); XBT_INFO("Simulation time %g", MSG_get_clock()); diff --git a/include/xbt/asserts.h b/include/xbt/asserts.h index 58c226d4e5..33bacf3816 100644 --- a/include/xbt/asserts.h +++ b/include/xbt/asserts.h @@ -41,17 +41,6 @@ SG_BEGIN_DECL() do { if (!(cond)) THROWF(0, 0, __VA_ARGS__); } while (0) #endif -#ifdef XBT_USE_DEPRECATED - -#define xbt_assert0(...) xbt_assert(__VA_ARGS__) -#define xbt_assert1(...) xbt_assert(__VA_ARGS__) -#define xbt_assert2(...) xbt_assert(__VA_ARGS__) -#define xbt_assert3(...) xbt_assert(__VA_ARGS__) -#define xbt_assert4(...) xbt_assert(__VA_ARGS__) -#define xbt_assert5(...) xbt_assert(__VA_ARGS__) -#define xbt_assert6(...) xbt_assert(__VA_ARGS__) - -#endif /** @} */ SG_END_DECL() #endif /* _XBT_ASSERTS_H */ diff --git a/include/xbt/cunit.h b/include/xbt/cunit.h index 18b7b2b7c0..d7b80c56c6 100644 --- a/include/xbt/cunit.h +++ b/include/xbt/cunit.h @@ -151,39 +151,5 @@ XBT_PUBLIC(void) xbt_test_skip(void); /** @} */ -#ifdef XBT_USE_DEPRECATED - -/* Kept for backward compatibility. */ - -#define xbt_test_add0(...) xbt_test_add(__VA_ARGS__) -#define xbt_test_add1(...) xbt_test_add(__VA_ARGS__) -#define xbt_test_add2(...) xbt_test_add(__VA_ARGS__) -#define xbt_test_add3(...) xbt_test_add(__VA_ARGS__) -#define xbt_test_add4(...) xbt_test_add(__VA_ARGS__) -#define xbt_test_add5(...) xbt_test_add(__VA_ARGS__) - -#define xbt_test_fail0(...) xbt_test_fail(__VA_ARGS__) -#define xbt_test_fail1(...) xbt_test_fail(__VA_ARGS__) -#define xbt_test_fail2(...) xbt_test_fail(__VA_ARGS__) -#define xbt_test_fail3(...) xbt_test_fail(__VA_ARGS__) -#define xbt_test_fail4(...) xbt_test_fail(__VA_ARGS__) -#define xbt_test_fail5(...) xbt_test_fail(__VA_ARGS__) - -#define xbt_test_assert0(...) xbt_test_assert(__VA_ARGS__) -#define xbt_test_assert1(...) xbt_test_assert(__VA_ARGS__) -#define xbt_test_assert2(...) xbt_test_assert(__VA_ARGS__) -#define xbt_test_assert3(...) xbt_test_assert(__VA_ARGS__) -#define xbt_test_assert4(...) xbt_test_assert(__VA_ARGS__) -#define xbt_test_assert5(...) xbt_test_assert(__VA_ARGS__) - -#define xbt_test_log0(...) xbt_test_log(__VA_ARGS__) -#define xbt_test_log1(...) xbt_test_log(__VA_ARGS__) -#define xbt_test_log2(...) xbt_test_log(__VA_ARGS__) -#define xbt_test_log3(...) xbt_test_log(__VA_ARGS__) -#define xbt_test_log4(...) xbt_test_log(__VA_ARGS__) -#define xbt_test_log5(...) xbt_test_log(__VA_ARGS__) - -#endif - SG_END_DECL() -#endif /* _TS_H_ */ +#endif /* _XBT_CUNIT_H_ */ diff --git a/include/xbt/dict.h b/include/xbt/dict.h index 0c0ec92599..61b2f14957 100644 --- a/include/xbt/dict.h +++ b/include/xbt/dict.h @@ -107,13 +107,6 @@ XBT_PUBLIC(void *) xbt_dict_get_or_null_ext(xbt_dict_t dict, XBT_PUBLIC(void) xbt_dict_remove_ext(xbt_dict_t dict, const char *key, int key_len); -#ifdef XBT_USE_DEPRECATED -XBT_PUBLIC(void) xbt_dicti_set(xbt_dict_t dict, uintptr_t key, - uintptr_t data); -XBT_PUBLIC(uintptr_t) xbt_dicti_get(xbt_dict_t dict, uintptr_t key); -XBT_PUBLIC(void) xbt_dicti_remove(xbt_dict_t dict, uintptr_t key); -#endif - struct s_xbt_dict_cursor { xbt_dictelm_t current; int line; @@ -191,44 +184,5 @@ xbt_dict_foreach(head, cursor, key, data) { /** @} */ -#ifdef XBT_USE_DEPRECATED -/** @defgroup XBT_dict_multi Multi-level dictionaries - * @ingroup XBT_dict - * - * They can be seen as dictionary of multiple keys or as dictionary of - * dictionary of ... of data. Most of the functions here work the same way - * than their simple dictionary counterpart. - * - * Note that there is no xbt_multidict_free neither xbt_multi_dict_new functions. - * Use xbt_dict_free() and xbt_dict_new() instead. - * - * @{ - */ - -/*----[ xbt_multidict_set ]--------------------------------------------------*/ -XBT_PUBLIC(void) -xbt_multidict_set(xbt_dict_t mdict, - xbt_dynar_t keys, void *data, void (*free_ctn) (void *)); -XBT_PUBLIC(void) -xbt_multidict_set_ext(xbt_dict_t mdict, - xbt_dynar_t keys, xbt_dynar_t lens, - void *data, void_f_pvoid_t free_ctn); - -/*----[ xbt_multidict_get ]--------------------------------------------------*/ -XBT_PUBLIC(void *) xbt_multidict_get(xbt_dict_t mdict, xbt_dynar_t keys); -XBT_PUBLIC(void *) xbt_multidict_get_ext(xbt_dict_t mdict, - xbt_dynar_t keys, - xbt_dynar_t lens); - -/*----[ xbt_multidict_remove ]-----------------------------------------------*/ -/*---------------------------------------------------------------------------*/ -XBT_PUBLIC(void) xbt_multidict_remove(xbt_dict_t mdict, xbt_dynar_t keys); -XBT_PUBLIC(void) xbt_multidict_remove_ext(xbt_dict_t mdict, - xbt_dynar_t keys, - xbt_dynar_t lens); - -/** @} */ -#endif - SG_END_DECL() #endif /* _XBT_DICT_H */ diff --git a/include/xbt/ex.h b/include/xbt/ex.h index 526c374181..54a55f3483 100644 --- a/include/xbt/ex.h +++ b/include/xbt/ex.h @@ -500,29 +500,6 @@ XBT_PUBLIC(void) xbt_backtrace_display(xbt_ex_t * e); /** @brief Get current backtrace with libunwind */ XBT_PUBLIC(int) xbt_libunwind_backtrace(void *bt[XBT_BACKTRACE_SIZE], int size); -#ifdef XBT_USE_DEPRECATED - -/* Kept for backward compatibility. */ - -#define THROW0(c, v, m) \ - do { if (m) THROWF(c, v, m); else THROW(c, v); } while (0) -#define THROW1(c, v, ...) THROWF(c, v, __VA_ARGS__) -#define THROW2(c, v, ...) THROWF(c, v, __VA_ARGS__) -#define THROW3(c, v, ...) THROWF(c, v, __VA_ARGS__) -#define THROW4(c, v, ...) THROWF(c, v, __VA_ARGS__) -#define THROW5(c, v, ...) THROWF(c, v, __VA_ARGS__) -#define THROW6(c, v, ...) THROWF(c, v, __VA_ARGS__) -#define THROW7(c, v, ...) THROWF(c, v, __VA_ARGS__) - -#define RETHROW0(...) RETHROWF(__VA_ARGS__) -#define RETHROW1(...) RETHROWF(__VA_ARGS__) -#define RETHROW2(...) RETHROWF(__VA_ARGS__) -#define RETHROW3(...) RETHROWF(__VA_ARGS__) -#define RETHROW4(...) RETHROWF(__VA_ARGS__) -#define RETHROW5(...) RETHROWF(__VA_ARGS__) - -#endif - SG_END_DECL() /** @} */ diff --git a/include/xbt/log.h b/include/xbt/log.h index fbde8e2efa..72cdf84266 100644 --- a/include/xbt/log.h +++ b/include/xbt/log.h @@ -693,186 +693,5 @@ extern xbt_log_layout_t xbt_log_default_layout; */ #define XBT_HERE(...) XBT_LOG(xbt_log_priority_trace, "-- was here" __VA_ARGS__) -#ifdef XBT_USE_DEPRECATED - -/* Kept for backward compatibility. */ - -#define CLOG0(...) XBT_CLOG(__VA_ARGS__) -#define CLOG1(...) XBT_CLOG(__VA_ARGS__) -#define CLOG2(...) XBT_CLOG(__VA_ARGS__) -#define CLOG3(...) XBT_CLOG(__VA_ARGS__) -#define CLOG4(...) XBT_CLOG(__VA_ARGS__) -#define CLOG5(...) XBT_CLOG(__VA_ARGS__) -#define CLOG6(...) XBT_CLOG(__VA_ARGS__) -#define CLOG7(...) XBT_CLOG(__VA_ARGS__) -#define CLOG8(...) XBT_CLOG(__VA_ARGS__) -#define CLOG9(...) XBT_CLOG(__VA_ARGS__) -#define CLOG10(...) XBT_CLOG(__VA_ARGS__) - -#define CDEBUG0(...) XBT_CDEBUG(__VA_ARGS__) -#define CDEBUG1(...) XBT_CDEBUG(__VA_ARGS__) -#define CDEBUG2(...) XBT_CDEBUG(__VA_ARGS__) -#define CDEBUG3(...) XBT_CDEBUG(__VA_ARGS__) -#define CDEBUG4(...) XBT_CDEBUG(__VA_ARGS__) -#define CDEBUG5(...) XBT_CDEBUG(__VA_ARGS__) -#define CDEBUG6(...) XBT_CDEBUG(__VA_ARGS__) -#define CDEBUG7(...) XBT_CDEBUG(__VA_ARGS__) -#define CDEBUG8(...) XBT_CDEBUG(__VA_ARGS__) -#define CDEBUG9(...) XBT_CDEBUG(__VA_ARGS__) -#define CDEBUG10(...) XBT_CDEBUG(__VA_ARGS__) - -#define CVERB0(...) XBT_CVERB(__VA_ARGS__) -#define CVERB1(...) XBT_CVERB(__VA_ARGS__) -#define CVERB2(...) XBT_CVERB(__VA_ARGS__) -#define CVERB3(...) XBT_CVERB(__VA_ARGS__) -#define CVERB4(...) XBT_CVERB(__VA_ARGS__) -#define CVERB5(...) XBT_CVERB(__VA_ARGS__) -#define CVERB6(...) XBT_CVERB(__VA_ARGS__) -#define CVERB7(...) XBT_CVERB(__VA_ARGS__) -#define CVERB8(...) XBT_CVERB(__VA_ARGS__) -#define CVERB9(...) XBT_CVERB(__VA_ARGS__) -#define CVERB10(...) XBT_CVERB(__VA_ARGS__) - -#define CINFO0(...) XBT_CINFO(__VA_ARGS__) -#define CINFO1(...) XBT_CINFO(__VA_ARGS__) -#define CINFO2(...) XBT_CINFO(__VA_ARGS__) -#define CINFO3(...) XBT_CINFO(__VA_ARGS__) -#define CINFO4(...) XBT_CINFO(__VA_ARGS__) -#define CINFO5(...) XBT_CINFO(__VA_ARGS__) -#define CINFO6(...) XBT_CINFO(__VA_ARGS__) -#define CINFO7(...) XBT_CINFO(__VA_ARGS__) -#define CINFO8(...) XBT_CINFO(__VA_ARGS__) -#define CINFO9(...) XBT_CINFO(__VA_ARGS__) -#define CINFO10(...) XBT_CINFO(__VA_ARGS__) - -#define CWARN0(...) XBT_CWARN(__VA_ARGS__) -#define CWARN1(...) XBT_CWARN(__VA_ARGS__) -#define CWARN2(...) XBT_CWARN(__VA_ARGS__) -#define CWARN3(...) XBT_CWARN(__VA_ARGS__) -#define CWARN4(...) XBT_CWARN(__VA_ARGS__) -#define CWARN5(...) XBT_CWARN(__VA_ARGS__) -#define CWARN6(...) XBT_CWARN(__VA_ARGS__) -#define CWARN7(...) XBT_CWARN(__VA_ARGS__) -#define CWARN8(...) XBT_CWARN(__VA_ARGS__) -#define CWARN9(...) XBT_CWARN(__VA_ARGS__) -#define CWARN10(...) XBT_CWARN(__VA_ARGS__) - -#define CERROR0(...) XBT_CERROR(__VA_ARGS__) -#define CERROR1(...) XBT_CERROR(__VA_ARGS__) -#define CERROR2(...) XBT_CERROR(__VA_ARGS__) -#define CERROR3(...) XBT_CERROR(__VA_ARGS__) -#define CERROR4(...) XBT_CERROR(__VA_ARGS__) -#define CERROR5(...) XBT_CERROR(__VA_ARGS__) -#define CERROR6(...) XBT_CERROR(__VA_ARGS__) -#define CERROR7(...) XBT_CERROR(__VA_ARGS__) -#define CERROR8(...) XBT_CERROR(__VA_ARGS__) -#define CERROR9(...) XBT_CERROR(__VA_ARGS__) -#define CERROR10(...) XBT_CERROR(__VA_ARGS__) - -#define CCRITICAL0(...) XBT_CCRITICAL(__VA_ARGS__) -#define CCRITICAL1(...) XBT_CCRITICAL(__VA_ARGS__) -#define CCRITICAL2(...) XBT_CCRITICAL(__VA_ARGS__) -#define CCRITICAL3(...) XBT_CCRITICAL(__VA_ARGS__) -#define CCRITICAL4(...) XBT_CCRITICAL(__VA_ARGS__) -#define CCRITICAL5(...) XBT_CCRITICAL(__VA_ARGS__) -#define CCRITICAL6(...) XBT_CCRITICAL(__VA_ARGS__) -#define CCRITICAL7(...) XBT_CCRITICAL(__VA_ARGS__) -#define CCRITICAL8(...) XBT_CCRITICAL(__VA_ARGS__) -#define CCRITICAL9(...) XBT_CCRITICAL(__VA_ARGS__) -#define CCRITICAL10(...) XBT_CCRITICAL(__VA_ARGS__) - -#define LOG0(...) XBT_LOG(__VA_ARGS__) -#define LOG1(...) XBT_LOG(__VA_ARGS__) -#define LOG2(...) XBT_LOG(__VA_ARGS__) -#define LOG3(...) XBT_LOG(__VA_ARGS__) -#define LOG4(...) XBT_LOG(__VA_ARGS__) -#define LOG5(...) XBT_LOG(__VA_ARGS__) -#define LOG6(...) XBT_LOG(__VA_ARGS__) -#define LOG7(...) XBT_LOG(__VA_ARGS__) -#define LOG8(...) XBT_LOG(__VA_ARGS__) -#define LOG9(...) XBT_LOG(__VA_ARGS__) -#define LOG10(...) XBT_LOG(__VA_ARGS__) - -#define DEBUG0(...) XBT_DEBUG(__VA_ARGS__) -#define DEBUG1(...) XBT_DEBUG(__VA_ARGS__) -#define DEBUG2(...) XBT_DEBUG(__VA_ARGS__) -#define DEBUG3(...) XBT_DEBUG(__VA_ARGS__) -#define DEBUG4(...) XBT_DEBUG(__VA_ARGS__) -#define DEBUG5(...) XBT_DEBUG(__VA_ARGS__) -#define DEBUG6(...) XBT_DEBUG(__VA_ARGS__) -#define DEBUG7(...) XBT_DEBUG(__VA_ARGS__) -#define DEBUG8(...) XBT_DEBUG(__VA_ARGS__) -#define DEBUG9(...) XBT_DEBUG(__VA_ARGS__) -#define DEBUG10(...) XBT_DEBUG(__VA_ARGS__) - -#define VERB0(...) XBT_VERB(__VA_ARGS__) -#define VERB1(...) XBT_VERB(__VA_ARGS__) -#define VERB2(...) XBT_VERB(__VA_ARGS__) -#define VERB3(...) XBT_VERB(__VA_ARGS__) -#define VERB4(...) XBT_VERB(__VA_ARGS__) -#define VERB5(...) XBT_VERB(__VA_ARGS__) -#define VERB6(...) XBT_VERB(__VA_ARGS__) -#define VERB7(...) XBT_VERB(__VA_ARGS__) -#define VERB8(...) XBT_VERB(__VA_ARGS__) -#define VERB9(...) XBT_VERB(__VA_ARGS__) -#define VERB10(...) XBT_VERB(__VA_ARGS__) - -#define INFO0(...) XBT_INFO(__VA_ARGS__) -#define INFO1(...) XBT_INFO(__VA_ARGS__) -#define INFO2(...) XBT_INFO(__VA_ARGS__) -#define INFO3(...) XBT_INFO(__VA_ARGS__) -#define INFO4(...) XBT_INFO(__VA_ARGS__) -#define INFO5(...) XBT_INFO(__VA_ARGS__) -#define INFO6(...) XBT_INFO(__VA_ARGS__) -#define INFO7(...) XBT_INFO(__VA_ARGS__) -#define INFO8(...) XBT_INFO(__VA_ARGS__) -#define INFO9(...) XBT_INFO(__VA_ARGS__) -#define INFO10(...) XBT_INFO(__VA_ARGS__) - -#define WARN0(...) XBT_WARN(__VA_ARGS__) -#define WARN1(...) XBT_WARN(__VA_ARGS__) -#define WARN2(...) XBT_WARN(__VA_ARGS__) -#define WARN3(...) XBT_WARN(__VA_ARGS__) -#define WARN4(...) XBT_WARN(__VA_ARGS__) -#define WARN5(...) XBT_WARN(__VA_ARGS__) -#define WARN6(...) XBT_WARN(__VA_ARGS__) -#define WARN7(...) XBT_WARN(__VA_ARGS__) -#define WARN8(...) XBT_WARN(__VA_ARGS__) -#define WARN9(...) XBT_WARN(__VA_ARGS__) -#define WARN10(...) XBT_WARN(__VA_ARGS__) - -#define ERROR0(...) XBT_ERROR(__VA_ARGS__) -#define ERROR1(...) XBT_ERROR(__VA_ARGS__) -#define ERROR2(...) XBT_ERROR(__VA_ARGS__) -#define ERROR3(...) XBT_ERROR(__VA_ARGS__) -#define ERROR4(...) XBT_ERROR(__VA_ARGS__) -#define ERROR5(...) XBT_ERROR(__VA_ARGS__) -#define ERROR6(...) XBT_ERROR(__VA_ARGS__) -#define ERROR7(...) XBT_ERROR(__VA_ARGS__) -#define ERROR8(...) XBT_ERROR(__VA_ARGS__) -#define ERROR9(...) XBT_ERROR(__VA_ARGS__) -#define ERROR10(...) XBT_ERROR(__VA_ARGS__) - -#define CRITICAL0(...) XBT_CRITICAL(__VA_ARGS__) -#define CRITICAL1(...) XBT_CRITICAL(__VA_ARGS__) -#define CRITICAL2(...) XBT_CRITICAL(__VA_ARGS__) -#define CRITICAL3(...) XBT_CRITICAL(__VA_ARGS__) -#define CRITICAL4(...) XBT_CRITICAL(__VA_ARGS__) -#define CRITICAL5(...) XBT_CRITICAL(__VA_ARGS__) -#define CRITICAL6(...) XBT_CRITICAL(__VA_ARGS__) -#define CRITICAL7(...) XBT_CRITICAL(__VA_ARGS__) -#define CRITICAL8(...) XBT_CRITICAL(__VA_ARGS__) -#define CRITICAL9(...) XBT_CRITICAL(__VA_ARGS__) -#define CRITICAL10(...) XBT_CRITICAL(__VA_ARGS__) - -#define XBT_IN1(...) XBT_IN(__VA_ARGS__); -#define XBT_IN2(...) XBT_IN(__VA_ARGS__); -#define XBT_IN3(...) XBT_IN(__VA_ARGS__); -#define XBT_IN4(...) XBT_IN(__VA_ARGS__); -#define XBT_IN5(...) XBT_IN(__VA_ARGS__); -#define XBT_IN6(...) XBT_IN(__VA_ARGS__); - -#endif - SG_END_DECL() #endif /* ! _XBT_LOG_H_ */ diff --git a/src/bindings/bindings_global.c b/src/bindings/bindings_global.c deleted file mode 100644 index 807cf179a4..0000000000 --- a/src/bindings/bindings_global.c +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright (c) 2012-2014. The SimGrid Team. - * All rights reserved. */ - -/* 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. */ - -#include - -XBT_LOG_NEW_CATEGORY(bindings, "All bindings categories"); diff --git a/src/bindings/java/JavaContext.cpp b/src/bindings/java/JavaContext.cpp index 586fd13194..cce9499f5c 100644 --- a/src/bindings/java/JavaContext.cpp +++ b/src/bindings/java/JavaContext.cpp @@ -18,7 +18,7 @@ #include "../../simix/smx_private.h" extern JavaVM *__java_vm; -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(jmsg, bindings, "MSG for Java(TM)"); +XBT_LOG_NEW_DEFAULT_CATEGORY(jmsg, "MSG for Java(TM)"); namespace simgrid { namespace java { diff --git a/src/bindings/java/jtrace.cpp b/src/bindings/java/jtrace.cpp index 342d25837f..343934001d 100644 --- a/src/bindings/java/jtrace.cpp +++ b/src/bindings/java/jtrace.cpp @@ -22,7 +22,7 @@ /* end of eclipse-mandated pimple */ // Define a new category -XBT_LOG_NEW_DEFAULT_SUBCATEGORY (jtrace, bindings, "TRACE for Java(TM)"); +XBT_LOG_NEW_DEFAULT_CATEGORY (jtrace, "TRACE for Java(TM)"); JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostStateDeclare(JNIEnv * env, jclass cls, jstring js) diff --git a/src/bindings/lua/lua_debug.cpp b/src/bindings/lua/lua_debug.cpp index ef795da9f3..d0c0db6411 100644 --- a/src/bindings/lua/lua_debug.cpp +++ b/src/bindings/lua/lua_debug.cpp @@ -18,7 +18,7 @@ extern "C" { #include "lua_utils.h" #include "xbt.h" -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua_debug, bindings, "Lua helper functions"); +XBT_LOG_NEW_DEFAULT_CATEGORY(lua_debug, "Lua bindings (helper functions)"); /** * @brief Returns a string representation of a value in the Lua stack. diff --git a/src/bindings/lua/lua_host.cpp b/src/bindings/lua/lua_host.cpp index cf6e1abb7c..09f6a5dc74 100644 --- a/src/bindings/lua/lua_host.cpp +++ b/src/bindings/lua/lua_host.cpp @@ -12,7 +12,7 @@ extern "C" { #include } -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua_host, bindings, "Lua bindings (host module)"); +XBT_LOG_NEW_DEFAULT_CATEGORY(lua_host, "Lua bindings (host module)"); #define HOST_MODULE_NAME "simgrid.host" #define HOST_FIELDNAME "__simgrid_host" diff --git a/src/bindings/lua/lua_platf.cpp b/src/bindings/lua/lua_platf.cpp index 8d07cfbad2..5d186cc42f 100644 --- a/src/bindings/lua/lua_platf.cpp +++ b/src/bindings/lua/lua_platf.cpp @@ -8,6 +8,7 @@ #include "lua_private.h" #include "src/surf/xml/platf_private.hpp" +#include "src/surf/network_interface.hpp" #include "surf/surf_routing.h" #include #include @@ -19,7 +20,7 @@ extern "C" { #include #include "src/surf/surf_private.h" -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua_platf, bindings, "Lua bindings (platform module)"); +XBT_LOG_NEW_DEFAULT_CATEGORY(lua_platf, "Lua bindings (platform module)"); #define PLATF_MODULE_NAME "simgrid.platf" @@ -364,9 +365,22 @@ int console_add_route(lua_State *L) { if (type != LUA_TSTRING) { XBT_ERROR("Attribute 'links' must be specified for any route and must be a string (different links separated by commas or single spaces."); } - route.link_list = xbt_str_split(lua_tostring(L, -1), ", \t\r\n"); - if (xbt_dynar_is_empty(route.link_list)) - xbt_dynar_push_as(route.link_list,char*,xbt_strdup(lua_tostring(L, -1))); + route.link_list = new std::vector(); + xbt_dynar_t names = xbt_str_split(lua_tostring(L, -1), ", \t\r\n"); + if (xbt_dynar_is_empty(names)) { + /* unique name */ + route.link_list->push_back(Link::byName(lua_tostring(L, -1))); + } else { + // Several names separated by , \t\r\n + unsigned int cpt; + char *name; + xbt_dynar_foreach(names, cpt, name) { + if (strlen(name)>0) { + Link *link = Link::byName(name); + route.link_list->push_back(link); + } + } + } lua_pop(L,1); /* We are relying on the XML bypassing mechanism since the corresponding sg_platf does not exist yet. @@ -434,9 +448,22 @@ int console_add_ASroute(lua_State *L) { lua_pushstring(L,"links"); lua_gettable(L,-2); - ASroute.link_list = xbt_str_split(lua_tostring(L, -1), ", \t\r\n"); - if (xbt_dynar_is_empty(ASroute.link_list)) - xbt_dynar_push_as(ASroute.link_list,char*,xbt_strdup(lua_tostring(L, -1))); + ASroute.link_list = new std::vector(); + xbt_dynar_t names = xbt_str_split(lua_tostring(L, -1), ", \t\r\n"); + if (xbt_dynar_is_empty(names)) { + /* unique name */ + ASroute.link_list->push_back(Link::byName(lua_tostring(L, -1))); + } else { + // Several names separated by , \t\r\n + unsigned int cpt; + char *name; + xbt_dynar_foreach(names, cpt, name) { + if (strlen(name)>0) { + Link *link = Link::byName(name); + ASroute.link_list->push_back(link); + } + } + } lua_pop(L,1); lua_pushstring(L,"symmetrical"); diff --git a/src/bindings/lua/simgrid_lua.cpp b/src/bindings/lua/simgrid_lua.cpp index ea77144ba5..8510071d25 100644 --- a/src/bindings/lua/simgrid_lua.cpp +++ b/src/bindings/lua/simgrid_lua.cpp @@ -11,7 +11,7 @@ #include "src/surf/xml/platf.hpp" -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua, bindings, "Lua Bindings"); +XBT_LOG_NEW_DEFAULT_CATEGORY(lua, "Lua Bindings"); extern "C" { #include diff --git a/src/instr/instr_interface.cpp b/src/instr/instr_interface.cpp index 84d70e6a78..5be023c7fb 100644 --- a/src/instr/instr_interface.cpp +++ b/src/instr/instr_interface.cpp @@ -364,20 +364,17 @@ static void instr_user_srcdst_variable(double time, double value, InstrUserVariable what) { - xbt_dynar_t route=NULL; sg_netcard_t src_elm = sg_netcard_by_name_or_null(src); if(!src_elm) xbt_die("Element '%s' not found!",src); sg_netcard_t dst_elm = sg_netcard_by_name_or_null(dst); if(!dst_elm) xbt_die("Element '%s' not found!",dst); - routing_platf->getRouteAndLatency (src_elm, dst_elm, &route,NULL); - unsigned int i; - surf_cpp_resource_t link; - xbt_dynar_foreach (route, i, link) { - char *link_name = (char*)surf_resource_name(link); - instr_user_variable (time, link_name, variable, father_type, value, what, NULL, user_link_variables); - } + std::vector *route = new std::vector(); + routing_platf->getRouteAndLatency (src_elm, dst_elm, route,NULL); + for (auto link : *route) + instr_user_variable (time, link->getName(), variable, father_type, value, what, NULL, user_link_variables); + delete route; } /** \ingroup TRACE_API diff --git a/src/simdag/sd_workstation.cpp b/src/simdag/sd_workstation.cpp index e77d274f80..5241965829 100644 --- a/src/simdag/sd_workstation.cpp +++ b/src/simdag/sd_workstation.cpp @@ -20,15 +20,15 @@ */ SD_link_t *SD_route_get_list(sg_host_t src, sg_host_t dst) { - void *surf_link; - unsigned int cpt; - xbt_dynar_t surf_route = NULL; - routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, &surf_route, NULL); + std::vector *route = new std::vector(); + routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, route, NULL); - SD_link_t *list = xbt_new(SD_link_t, xbt_dynar_length(surf_route)); - xbt_dynar_foreach(surf_route, cpt, surf_link) { - list[cpt] = (SD_link_t)surf_link; - } + int cpt=0; + SD_link_t *list = xbt_new(SD_link_t, route->size()); + for (auto link : *route) + list[cpt++] = link; + + delete route; return list; } @@ -42,9 +42,11 @@ SD_link_t *SD_route_get_list(sg_host_t src, sg_host_t dst) */ int SD_route_get_size(sg_host_t src, sg_host_t dst) { - xbt_dynar_t surf_route = NULL; - routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, &surf_route, NULL); - return xbt_dynar_length(surf_route); + std::vector *route = new std::vector(); + routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, route, NULL); + int size = route->size(); + delete route; + return size; } /** @@ -57,10 +59,10 @@ int SD_route_get_size(sg_host_t src, sg_host_t dst) */ double SD_route_get_latency(sg_host_t src, sg_host_t dst) { - xbt_dynar_t route = NULL; double latency = 0; - - routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, &route, &latency); + std::vector *route = new std::vector(); + routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, route, &latency); + delete route; return latency; } @@ -76,19 +78,17 @@ double SD_route_get_latency(sg_host_t src, sg_host_t dst) */ double SD_route_get_bandwidth(sg_host_t src, sg_host_t dst) { - xbt_dynar_t route = NULL; - unsigned int cpt; - double latency = 0; double min_bandwidth = -1.0; - SD_link_t link; - routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, &route, &latency); + std::vector *route = new std::vector(); + routing_platf->getRouteAndLatency(src->pimpl_netcard, dst->pimpl_netcard, route, NULL); - xbt_dynar_foreach(route, cpt, link){ + for (auto link : *route) { double bandwidth = sg_link_bandwidth(link); if (bandwidth < min_bandwidth || min_bandwidth == -1.0) min_bandwidth = bandwidth; } + delete route; return min_bandwidth; } diff --git a/src/simgrid/host.cpp b/src/simgrid/host.cpp index 99aa45eaee..98049d9190 100644 --- a/src/simgrid/host.cpp +++ b/src/simgrid/host.cpp @@ -68,7 +68,7 @@ xbt_dynar_t sg_hosts_as_dynar(void) const char* name = nullptr; simgrid::s4u::Host* host = nullptr; xbt_dict_foreach(host_list, cursor, name, host) - if (host && host->pimpl_netcard && host->pimpl_netcard->getRcType() == SURF_NETWORK_ELEMENT_HOST) + if (host && host->pimpl_netcard && host->pimpl_netcard->isHost()) xbt_dynar_push(res, &host); return res; } diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index 64ba10d033..1f075189ca 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -308,41 +308,32 @@ void NetworkCm02Model::updateActionsStateFull(double now, double delta) Action *NetworkCm02Model::communicate(NetCard *src, NetCard *dst, double size, double rate) { - unsigned int i; - void *_link; - NetworkCm02Link *link; int failed = 0; NetworkCm02Action *action = NULL; double bandwidth_bound; double latency = 0.0; - xbt_dynar_t back_route = NULL; + std::vector * back_route = NULL; int constraints_per_variable = 0; - xbt_dynar_t route = xbt_dynar_new(sizeof(NetCard*), NULL); + std::vector *route = new std::vector(); XBT_IN("(%s,%s,%g,%g)", src->name(), dst->name(), size, rate); - routing_platf->getRouteAndLatency(src, dst, &route, &latency); - xbt_assert(!xbt_dynar_is_empty(route) || latency, + routing_platf->getRouteAndLatency(src, dst, route, &latency); + xbt_assert(! route->empty() || latency, "You're trying to send data from %s to %s but there is no connecting path between these two hosts.", src->name(), dst->name()); - xbt_dynar_foreach(route, i, _link) { - link = static_cast(_link); - if (link->isOff()) { + for (auto link: *route) + if (link->isOff()) failed = 1; - break; - } - } + if (sg_network_crosstraffic == 1) { - routing_platf->getRouteAndLatency(dst, src, &back_route, NULL); - xbt_dynar_foreach(back_route, i, _link) { - link = static_cast(_link); - if (link->isOff()) { + back_route = new std::vector(); + routing_platf->getRouteAndLatency(dst, src, back_route, NULL); + for (auto link: *back_route) + if (link->isOff()) failed = 1; - break; - } - } } action = new NetworkCm02Action(this, size, failed); @@ -359,45 +350,37 @@ Action *NetworkCm02Model::communicate(NetCard *src, NetCard *dst, } bandwidth_bound = -1.0; - if (sg_weight_S_parameter > 0) { - xbt_dynar_foreach(route, i, _link) { - link = static_cast(_link); + if (sg_weight_S_parameter > 0) + for (auto link : *route) action->m_weight += sg_weight_S_parameter / link->getBandwidth(); - } - } - xbt_dynar_foreach(route, i, _link) { - link = static_cast(_link); + + for (auto link : *route) { double bb = bandwidthFactor(size) * link->getBandwidth(); - bandwidth_bound = - (bandwidth_bound < 0.0) ? bb : std::min(bandwidth_bound, bb); + bandwidth_bound = (bandwidth_bound < 0.0) ? bb : std::min(bandwidth_bound, bb); } action->m_latCurrent = action->m_latency; action->m_latency *= latencyFactor(size); action->m_rate = bandwidthConstraint(action->m_rate, bandwidth_bound, size); if (m_haveGap) { - xbt_assert(!xbt_dynar_is_empty(route), + xbt_assert(! route->empty(), "Using a model with a gap (e.g., SMPI) with a platform without links (e.g. vivaldi)!!!"); - link = *static_cast(xbt_dynar_get_ptr(route, 0)); - gapAppend(size, link, action); - XBT_DEBUG("Comm %p: %s -> %s gap=%f (lat=%f)", - action, src->name(), dst->name(), action->m_senderGap, - action->m_latency); + gapAppend(size, route->at(0), action); + XBT_DEBUG("Comm %p: %s -> %s gap=%f (lat=%f)", action, src->name(), dst->name(), action->m_senderGap, action->m_latency); } - constraints_per_variable = xbt_dynar_length(route); + constraints_per_variable = route->size(); if (back_route != NULL) - constraints_per_variable += xbt_dynar_length(back_route); + constraints_per_variable += back_route->size(); if (action->m_latency > 0) { action->p_variable = lmm_variable_new(p_maxminSystem, action, 0.0, -1.0, constraints_per_variable); if (p_updateMechanism == UM_LAZY) { // add to the heap the event when the latency is payed - XBT_DEBUG("Added action (%p) one latency event at date %f", action, - action->m_latency + action->m_lastUpdate); - action->heapInsert(p_actionHeap, action->m_latency + action->m_lastUpdate, xbt_dynar_is_empty(route) ? NORMAL : LATENCY); + XBT_DEBUG("Added action (%p) one latency event at date %f", action, action->m_latency + action->m_lastUpdate); + action->heapInsert(p_actionHeap, action->m_latency + action->m_lastUpdate, route->empty() ? NORMAL : LATENCY); } } else action->p_variable = lmm_variable_new(p_maxminSystem, action, 1.0, -1.0, constraints_per_variable); @@ -408,23 +391,20 @@ Action *NetworkCm02Model::communicate(NetCard *src, NetCard *dst, lmm_update_variable_bound(p_maxminSystem, action->getVariable(), (action->m_latCurrent > 0) ? std::min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent)) : action->m_rate); } - xbt_dynar_foreach(route, i, _link) { - link = static_cast(_link); + for (auto link: *route) lmm_expand(p_maxminSystem, link->getConstraint(), action->getVariable(), 1.0); - } if (sg_network_crosstraffic == 1) { XBT_DEBUG("Fullduplex active adding backward flow using 5%%"); - xbt_dynar_foreach(back_route, i, _link) { - link = static_cast(_link); + for (auto link : *back_route) lmm_expand(p_maxminSystem, link->getConstraint(), action->getVariable(), .05); - } + //Change concurrency_share here, if you want that cross-traffic is included in the SURF concurrency //(You would also have to change lmm_element_concurrency()) //lmm_variable_concurrency_share_set(action->getVariable(),2); } - xbt_dynar_free(&route); + delete route; XBT_OUT(); networkCommunicateCallbacks(action, src, dst, size, rate); diff --git a/src/surf/network_constant.cpp b/src/surf/network_constant.cpp index 533be80bd1..ce90e8ad18 100644 --- a/src/surf/network_constant.cpp +++ b/src/surf/network_constant.cpp @@ -20,94 +20,94 @@ void surf_network_model_init_Constant() routing_model_create(NULL); simgrid::surf::on_link.connect([](sg_platf_link_cbarg_t link){ - xbt_die("There is no link in the Constant network model. " - "Please remove any link from your platform (and switch to routing='None')"); + xbt_die("There is no link in the Constant network model. " + "Please remove any link from your platform (and switch to routing='None')"); }); } namespace simgrid { -namespace surf { - -double NetworkConstantModel::next_occuring_event(double /*now*/) -{ - NetworkConstantAction *action = NULL; - double min = -1.0; - - ActionList *actionSet = getRunningActionSet(); - for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end()) - ; it != itend ; ++it) { - action = static_cast(&*it); - if (action->m_latency > 0 && (min < 0 || action->m_latency < min)) - min = action->m_latency; - } + namespace surf { + + double NetworkConstantModel::next_occuring_event(double /*now*/) + { + NetworkConstantAction *action = NULL; + double min = -1.0; + + ActionList *actionSet = getRunningActionSet(); + for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end()) + ; it != itend ; ++it) { + action = static_cast(&*it); + if (action->m_latency > 0 && (min < 0 || action->m_latency < min)) + min = action->m_latency; + } - return min; -} + return min; + } -void NetworkConstantModel::updateActionsState(double /*now*/, double delta) -{ - NetworkConstantAction *action = NULL; - ActionList *actionSet = getRunningActionSet(); - for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end()) - ; it != itend ; it=itNext) { - ++itNext; - action = static_cast(&*it); - if (action->m_latency > 0) { - if (action->m_latency > delta) { - double_update(&(action->m_latency), delta, sg_surf_precision); - } else { - action->m_latency = 0.0; + void NetworkConstantModel::updateActionsState(double /*now*/, double delta) + { + NetworkConstantAction *action = NULL; + ActionList *actionSet = getRunningActionSet(); + for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end()) + ; it != itend ; it=itNext) { + ++itNext; + action = static_cast(&*it); + if (action->m_latency > 0) { + if (action->m_latency > delta) { + double_update(&(action->m_latency), delta, sg_surf_precision); + } else { + action->m_latency = 0.0; + } + } + action->updateRemains(action->getCost() * delta / action->m_latInit); + if (action->getMaxDuration() != NO_MAX_DURATION) + action->updateMaxDuration(delta); + + if (action->getRemainsNoUpdate() <= 0) { + action->finish(); + action->setState(SURF_ACTION_DONE); + } else if ((action->getMaxDuration() != NO_MAX_DURATION) + && (action->getMaxDuration() <= 0)) { + action->finish(); + action->setState(SURF_ACTION_DONE); + } } } - action->updateRemains(action->getCost() * delta / action->m_latInit); - if (action->getMaxDuration() != NO_MAX_DURATION) - action->updateMaxDuration(delta); - - if (action->getRemainsNoUpdate() <= 0) { - action->finish(); - action->setState(SURF_ACTION_DONE); - } else if ((action->getMaxDuration() != NO_MAX_DURATION) - && (action->getMaxDuration() <= 0)) { - action->finish(); - action->setState(SURF_ACTION_DONE); - } - } -} - -Action *NetworkConstantModel::communicate(NetCard *src, NetCard *dst, - double size, double rate) -{ - char *src_name = src->name(); - char *dst_name = dst->name(); - XBT_IN("(%s,%s,%g,%g)", src_name, dst_name, size, rate); - NetworkConstantAction *action = new NetworkConstantAction(this, size, sg_latency_factor); - XBT_OUT(); + Action *NetworkConstantModel::communicate(NetCard *src, NetCard *dst, + double size, double rate) + { + char *src_name = src->name(); + char *dst_name = dst->name(); - networkCommunicateCallbacks(action, src, dst, size, rate); - return action; -} + XBT_IN("(%s,%s,%g,%g)", src_name, dst_name, size, rate); + NetworkConstantAction *action = new NetworkConstantAction(this, size, sg_latency_factor); + XBT_OUT(); -/********** - * Action * - **********/ + networkCommunicateCallbacks(action, src, dst, size, rate); + return action; + } -int NetworkConstantAction::unref() -{ - m_refcount--; - if (!m_refcount) { - if (action_hook.is_linked()) - p_stateSet->erase(p_stateSet->iterator_to(*this)); - delete this; - return 1; - } - return 0; -} + /********** + * Action * + **********/ + + int NetworkConstantAction::unref() + { + m_refcount--; + if (!m_refcount) { + if (action_hook.is_linked()) + p_stateSet->erase(p_stateSet->iterator_to(*this)); + delete this; + return 1; + } + return 0; + } -void NetworkConstantAction::cancel() -{ - return; -} + void NetworkConstantAction::cancel() + { + return; + } -} + } } diff --git a/src/surf/network_constant.hpp b/src/surf/network_constant.hpp index fea074d119..60f166e633 100644 --- a/src/surf/network_constant.hpp +++ b/src/surf/network_constant.hpp @@ -12,59 +12,59 @@ #include "network_interface.hpp" namespace simgrid { -namespace surf { + namespace surf { -/*********** - * Classes * - ***********/ - -class XBT_PRIVATE NetworkConstantModel; -class XBT_PRIVATE NetworkConstantAction; + /*********** + * Classes * + ***********/ -/********* - * Model * - *********/ -class NetworkConstantModel : public NetworkModel { -public: - NetworkConstantModel() : NetworkModel() { }; - ~NetworkConstantModel() { } + class XBT_PRIVATE NetworkConstantModel; + class XBT_PRIVATE NetworkConstantAction; - Action *communicate(NetCard *src, NetCard *dst, double size, double rate) override; - double next_occuring_event(double now) override; - bool next_occuring_event_isIdempotent() override {return true;} - void updateActionsState(double now, double delta) override; + /********* + * Model * + *********/ + class NetworkConstantModel : public NetworkModel { + public: + NetworkConstantModel() : NetworkModel() { }; + ~NetworkConstantModel() { } - Link* - createLink(const char *name, - double bw_initial, tmgr_trace_t bw_trace, - double lat_initial, tmgr_trace_t lat_trace, - tmgr_trace_t state_trace, - e_surf_link_sharing_policy_t policy, - xbt_dict_t properties) override { DIE_IMPOSSIBLE; } -}; + Action *communicate(NetCard *src, NetCard *dst, double size, double rate) override; + double next_occuring_event(double now) override; + bool next_occuring_event_isIdempotent() override {return true;} + void updateActionsState(double now, double delta) override; -/********** - * Action * - **********/ -class NetworkConstantAction : public NetworkAction { -public: - NetworkConstantAction(NetworkConstantModel *model_, double size, double latency) - : NetworkAction(model_, size, false) - , m_latInit(latency) - { - m_latency = latency; - if (m_latency <= 0.0) { - p_stateSet = getModel()->getDoneActionSet(); - p_stateSet->push_back(*this); - } - p_variable = NULL; - }; - int unref() override; - void cancel() override; - double m_latInit; -}; + Link* + createLink(const char *name, + double bw_initial, tmgr_trace_t bw_trace, + double lat_initial, tmgr_trace_t lat_trace, + tmgr_trace_t state_trace, + e_surf_link_sharing_policy_t policy, + xbt_dict_t properties) override { DIE_IMPOSSIBLE; } + }; -} + /********** + * Action * + **********/ + class NetworkConstantAction : public NetworkAction { + public: + NetworkConstantAction(NetworkConstantModel *model_, double size, double latency) + : NetworkAction(model_, size, false) + , m_latInit(latency) + { + m_latency = latency; + if (m_latency <= 0.0) { + p_stateSet = getModel()->getDoneActionSet(); + p_stateSet->push_back(*this); + } + p_variable = NULL; + }; + int unref() override; + void cancel() override; + double m_latInit; + }; + + } } #endif /* NETWORK_CONSTANT_HPP_ */ diff --git a/src/surf/network_ib.cpp b/src/surf/network_ib.cpp index ecc9e63597..7b743d5d82 100644 --- a/src/surf/network_ib.cpp +++ b/src/surf/network_ib.cpp @@ -17,61 +17,61 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network); static void IB_create_host_callback(simgrid::s4u::Host& host){ using namespace simgrid::surf; - + static int id=0; -// pour t->id -> rajouter une nouvelle struct dans le dict, pour stocker les comms actives + // pour t->id -> rajouter une nouvelle struct dans le dict, pour stocker les comms actives if(((NetworkIBModel*)surf_network_model)->active_nodes==NULL) ((NetworkIBModel*)surf_network_model)->active_nodes=xbt_dict_new(); - + IBNode* act = new IBNode(id); id++; xbt_dict_set(((NetworkIBModel*)surf_network_model)->active_nodes, - host.name().c_str(), act, NULL); + host.name().c_str(), act, NULL); } static void IB_action_state_changed_callback( - simgrid::surf::NetworkAction *action, - e_surf_action_state_t statein, e_surf_action_state_t stateout) + simgrid::surf::NetworkAction *action, + e_surf_action_state_t statein, e_surf_action_state_t stateout) { - using namespace simgrid::surf; - if(statein!=SURF_ACTION_RUNNING|| stateout!=SURF_ACTION_DONE) + using namespace simgrid::surf; + if(statein!=SURF_ACTION_RUNNING|| stateout!=SURF_ACTION_DONE) return; std::pair pair = ((NetworkIBModel*)surf_network_model)->active_comms[action]; XBT_DEBUG("IB callback - action %p finished", action); - - ((NetworkIBModel*)surf_network_model)->updateIBfactors(action, pair.first, pair.second, 1); + + ((NetworkIBModel*)surf_network_model)->updateIBfactors(action, pair.first, pair.second, 1); ((NetworkIBModel*)surf_network_model)->active_comms.erase(action); - + } static void IB_action_init_callback( - simgrid::surf::NetworkAction *action, simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst, - double size, double rate) + simgrid::surf::NetworkAction *action, simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst, + double size, double rate) { using namespace simgrid::surf; if(((NetworkIBModel*)surf_network_model)->active_nodes==NULL) xbt_die("IB comm added, without any node connected !"); - + IBNode* act_src= (IBNode*) xbt_dict_get_or_null(((NetworkIBModel*)surf_network_model)->active_nodes, src->name()); if(act_src==NULL) xbt_die("could not find src node active comms !"); //act_src->rate=rate; - + IBNode* act_dst= (IBNode*) xbt_dict_get_or_null(((NetworkIBModel*)surf_network_model)->active_nodes, dst->name()); if(act_dst==NULL) xbt_die("could not find dst node active comms !"); - // act_dst->rate=rate; - + // act_dst->rate=rate; + ((NetworkIBModel*)surf_network_model)->active_comms[action]=std::make_pair(act_src, act_dst); //post the action in the second dist, to retrieve in the other callback XBT_DEBUG("IB callback - action %p init", action); ((NetworkIBModel*)surf_network_model)->updateIBfactors(action, act_src, act_dst, 0); - + } /********* @@ -103,147 +103,147 @@ void surf_network_model_init_IB(void) networkCommunicateCallbacks.connect(IB_action_init_callback); simgrid::s4u::Host::onCreation.connect(IB_create_host_callback); xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 8775); - + } #include "src/surf/xml/platf.hpp" // FIXME: move that back to the parsing area namespace simgrid { -namespace surf { - -NetworkIBModel::NetworkIBModel() - : NetworkSmpiModel() { - m_haveGap=false; - active_nodes=NULL; - - const char* IB_factors_string=sg_cfg_get_string("smpi/IB_penalty_factors"); - xbt_dynar_t radical_elements = xbt_str_split(IB_factors_string, ";"); - - surf_parse_assert(xbt_dynar_length(radical_elements)==3, - "smpi/IB_penalty_factors should be provided and contain 3 elements, semi-colon separated : for example 0.965;0.925;1.35"); - - Be = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 0, char *), "First part of smpi/IB_penalty_factors is not numerical: %s"); - Bs = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 1, char *), "Second part of smpi/IB_penalty_factors is not numerical: %s"); - ys = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 2, char *), "Third part of smpi/IB_penalty_factors is not numerical: %s"); - - xbt_dynar_free(&radical_elements); -} + namespace surf { -NetworkIBModel::~NetworkIBModel() -{ - xbt_dict_cursor_t cursor = NULL; - IBNode* instance = NULL; - char *name = NULL; - xbt_dict_foreach(active_nodes, cursor, name, instance) - delete instance; - xbt_dict_free(&active_nodes); -} + NetworkIBModel::NetworkIBModel() + : NetworkSmpiModel() { + m_haveGap=false; + active_nodes=NULL; -void NetworkIBModel::computeIBfactors(IBNode *root) { - double penalized_bw=0.0; - double num_comm_out = (double) root->ActiveCommsUp.size(); - double max_penalty_out=0.0; - //first, compute all outbound penalties to get their max - for (std::vector::iterator it= root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) { - double my_penalty_out = 1.0; - - if(num_comm_out!=1){ - if((*it)->destination->nbActiveCommsDown > 2)//number of comms sent to the receiving node - my_penalty_out = num_comm_out * Bs * ys; - else - my_penalty_out = num_comm_out * Bs; - } + const char* IB_factors_string=sg_cfg_get_string("smpi/IB_penalty_factors"); + xbt_dynar_t radical_elements = xbt_str_split(IB_factors_string, ";"); - max_penalty_out = std::max(max_penalty_out,my_penalty_out); - } + surf_parse_assert(xbt_dynar_length(radical_elements)==3, + "smpi/IB_penalty_factors should be provided and contain 3 elements, semi-colon separated : for example 0.965;0.925;1.35"); - for (std::vector::iterator it= root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) { - - //compute inbound penalty - double my_penalty_in = 1.0; - int nb_comms = (*it)->destination->nbActiveCommsDown;//total number of incoming comms - if(nb_comms!=1) - my_penalty_in = ((*it)->destination->ActiveCommsDown)[root] //number of comm sent to dest by root node - * Be - * (*it)->destination->ActiveCommsDown.size();//number of different nodes sending to dest - - double penalty = std::max(my_penalty_in,max_penalty_out); - - double rate_before_update = (*it)->action->getBound(); - //save initial rate of the action - if((*it)->init_rate==-1) - (*it)->init_rate= rate_before_update; - - penalized_bw= ! num_comm_out ? (*it)->init_rate : (*it)->init_rate /penalty; - - if (!double_equals(penalized_bw, rate_before_update, sg_surf_precision)){ - XBT_DEBUG("%d->%d action %p penalty updated : bw now %f, before %f , initial rate %f", root->id,(*it)->destination->id,(*it)->action,penalized_bw, (*it)->action->getBound(), (*it)->init_rate ); - lmm_update_variable_bound(p_maxminSystem, (*it)->action->getVariable(), penalized_bw); - }else{ - XBT_DEBUG("%d->%d action %p penalty not updated : bw %f, initial rate %f", root->id,(*it)->destination->id,(*it)->action,penalized_bw, (*it)->init_rate ); + Be = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 0, char *), "First part of smpi/IB_penalty_factors is not numerical: %s"); + Bs = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 1, char *), "Second part of smpi/IB_penalty_factors is not numerical: %s"); + ys = xbt_str_parse_double(xbt_dynar_get_as(radical_elements, 2, char *), "Third part of smpi/IB_penalty_factors is not numerical: %s"); + + xbt_dynar_free(&radical_elements); } - } - XBT_DEBUG("Finished computing IB penalties"); -} + NetworkIBModel::~NetworkIBModel() + { + xbt_dict_cursor_t cursor = NULL; + IBNode* instance = NULL; + char *name = NULL; + xbt_dict_foreach(active_nodes, cursor, name, instance) + delete instance; + xbt_dict_free(&active_nodes); + } -void NetworkIBModel::updateIBfactors_rec(IBNode *root, bool* updatedlist) { - if(updatedlist[root->id]==0){ - XBT_DEBUG("IB - Updating rec %d", root->id); - computeIBfactors(root); - updatedlist[root->id]=1; - for (std::vector::iterator it= root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) { - if(updatedlist[(*it)->destination->id]!=1) - updateIBfactors_rec((*it)->destination, updatedlist); + void NetworkIBModel::computeIBfactors(IBNode *root) { + double penalized_bw=0.0; + double num_comm_out = (double) root->ActiveCommsUp.size(); + double max_penalty_out=0.0; + //first, compute all outbound penalties to get their max + for (std::vector::iterator it= root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) { + double my_penalty_out = 1.0; + + if(num_comm_out!=1){ + if((*it)->destination->nbActiveCommsDown > 2)//number of comms sent to the receiving node + my_penalty_out = num_comm_out * Bs * ys; + else + my_penalty_out = num_comm_out * Bs; + } + + max_penalty_out = std::max(max_penalty_out,my_penalty_out); + } + + for (std::vector::iterator it= root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) { + + //compute inbound penalty + double my_penalty_in = 1.0; + int nb_comms = (*it)->destination->nbActiveCommsDown;//total number of incoming comms + if(nb_comms!=1) + my_penalty_in = ((*it)->destination->ActiveCommsDown)[root] //number of comm sent to dest by root node + * Be + * (*it)->destination->ActiveCommsDown.size();//number of different nodes sending to dest + + double penalty = std::max(my_penalty_in,max_penalty_out); + + double rate_before_update = (*it)->action->getBound(); + //save initial rate of the action + if((*it)->init_rate==-1) + (*it)->init_rate= rate_before_update; + + penalized_bw= ! num_comm_out ? (*it)->init_rate : (*it)->init_rate /penalty; + + if (!double_equals(penalized_bw, rate_before_update, sg_surf_precision)){ + XBT_DEBUG("%d->%d action %p penalty updated : bw now %f, before %f , initial rate %f", root->id,(*it)->destination->id,(*it)->action,penalized_bw, (*it)->action->getBound(), (*it)->init_rate ); + lmm_update_variable_bound(p_maxminSystem, (*it)->action->getVariable(), penalized_bw); + }else{ + XBT_DEBUG("%d->%d action %p penalty not updated : bw %f, initial rate %f", root->id,(*it)->destination->id,(*it)->action,penalized_bw, (*it)->init_rate ); + } + + } + XBT_DEBUG("Finished computing IB penalties"); } - for (std::map::iterator it= root->ActiveCommsDown.begin(); it != root->ActiveCommsDown.end(); ++it) { - if(updatedlist[it->first->id]!=1) - updateIBfactors_rec(it->first, updatedlist); + + void NetworkIBModel::updateIBfactors_rec(IBNode *root, bool* updatedlist) { + if(updatedlist[root->id]==0){ + XBT_DEBUG("IB - Updating rec %d", root->id); + computeIBfactors(root); + updatedlist[root->id]=1; + for (std::vector::iterator it= root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) { + if(updatedlist[(*it)->destination->id]!=1) + updateIBfactors_rec((*it)->destination, updatedlist); + } + for (std::map::iterator it= root->ActiveCommsDown.begin(); it != root->ActiveCommsDown.end(); ++it) { + if(updatedlist[it->first->id]!=1) + updateIBfactors_rec(it->first, updatedlist); + } + } } - } -} -void NetworkIBModel::updateIBfactors(NetworkAction *action, IBNode *from, IBNode * to, int remove) { - if (from == to)//disregard local comms (should use loopback) - return; - - bool* updated=(bool*)xbt_malloc0(xbt_dict_size(active_nodes)*sizeof(bool)); - ActiveComm* comm=NULL; - if(remove){ - if(to->ActiveCommsDown[from]==1) - to->ActiveCommsDown.erase(from); - else - to->ActiveCommsDown[from]-=1; - - to->nbActiveCommsDown--; - for (std::vector::iterator it= from->ActiveCommsUp.begin(); - it != from->ActiveCommsUp.end(); ++it) { - if((*it)->action==action){ - comm=(*it); - from->ActiveCommsUp.erase(it); - break; + void NetworkIBModel::updateIBfactors(NetworkAction *action, IBNode *from, IBNode * to, int remove) { + if (from == to)//disregard local comms (should use loopback) + return; + + bool* updated=(bool*)xbt_malloc0(xbt_dict_size(active_nodes)*sizeof(bool)); + ActiveComm* comm=NULL; + if(remove){ + if(to->ActiveCommsDown[from]==1) + to->ActiveCommsDown.erase(from); + else + to->ActiveCommsDown[from]-=1; + + to->nbActiveCommsDown--; + for (std::vector::iterator it= from->ActiveCommsUp.begin(); + it != from->ActiveCommsUp.end(); ++it) { + if((*it)->action==action){ + comm=(*it); + from->ActiveCommsUp.erase(it); + break; + } + } + action->unref(); + + }else{ + action->ref(); + ActiveComm* comm=new ActiveComm(); + comm->action=action; + comm->destination=to; + from->ActiveCommsUp.push_back(comm); + + to->ActiveCommsDown[from]+=1; + to->nbActiveCommsDown++; } + XBT_DEBUG("IB - Updating %d", from->id); + updateIBfactors_rec(from, updated); + XBT_DEBUG("IB - Finished updating %d", from->id); + if(comm) + delete comm; + xbt_free(updated); } - action->unref(); - }else{ - action->ref(); - ActiveComm* comm=new ActiveComm(); - comm->action=action; - comm->destination=to; - from->ActiveCommsUp.push_back(comm); - - to->ActiveCommsDown[from]+=1; - to->nbActiveCommsDown++; } - XBT_DEBUG("IB - Updating %d", from->id); - updateIBfactors_rec(from, updated); - XBT_DEBUG("IB - Finished updating %d", from->id); - if(comm) - delete comm; - xbt_free(updated); -} - -} } diff --git a/src/surf/network_ib.hpp b/src/surf/network_ib.hpp index 553f9419e9..b8357fb559 100644 --- a/src/surf/network_ib.hpp +++ b/src/surf/network_ib.hpp @@ -12,53 +12,53 @@ #include "network_smpi.hpp" namespace simgrid { -namespace surf { + namespace surf { -class XBT_PRIVATE IBNode; + class XBT_PRIVATE IBNode; -class XBT_PRIVATE ActiveComm{ -public : - //IBNode* origin; - IBNode* destination; - NetworkAction *action; - double init_rate; - ActiveComm() : destination(NULL),action(NULL),init_rate(-1){}; - ~ActiveComm(){}; -}; + class XBT_PRIVATE ActiveComm{ + public : + //IBNode* origin; + IBNode* destination; + NetworkAction *action; + double init_rate; + ActiveComm() : destination(NULL),action(NULL),init_rate(-1){}; + ~ActiveComm(){}; + }; -class IBNode{ -public : - int id; - //store related links, to ease computation of the penalties - std::vector ActiveCommsUp; - //store the number of comms received from each node - std::map ActiveCommsDown; - //number of comms the node is receiving - int nbActiveCommsDown; - IBNode(int id) : id(id),nbActiveCommsDown(0){}; - ~IBNode(){}; -}; + class IBNode{ + public : + int id; + //store related links, to ease computation of the penalties + std::vector ActiveCommsUp; + //store the number of comms received from each node + std::map ActiveCommsDown; + //number of comms the node is receiving + int nbActiveCommsDown; + IBNode(int id) : id(id),nbActiveCommsDown(0){}; + ~IBNode(){}; + }; -class XBT_PRIVATE NetworkIBModel : public NetworkSmpiModel { -private: - void updateIBfactors_rec(IBNode *root, bool* updatedlist); - void computeIBfactors(IBNode *root); -public: - NetworkIBModel(); - NetworkIBModel(const char *name); - ~NetworkIBModel(); - void updateIBfactors(NetworkAction *action, IBNode *from, IBNode * to, int remove); - - xbt_dict_t active_nodes; - std::map > active_comms; - - double Bs; - double Be; - double ys; + class XBT_PRIVATE NetworkIBModel : public NetworkSmpiModel { + private: + void updateIBfactors_rec(IBNode *root, bool* updatedlist); + void computeIBfactors(IBNode *root); + public: + NetworkIBModel(); + NetworkIBModel(const char *name); + ~NetworkIBModel(); + void updateIBfactors(NetworkAction *action, IBNode *from, IBNode * to, int remove); -}; + xbt_dict_t active_nodes; + std::map > active_comms; -} + double Bs; + double Be; + double ys; + + }; + + } } #endif diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index a1cb5d3f50..4629706ab3 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -13,7 +13,7 @@ #define NETWORK_INTERFACE_CPP_ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network, surf, - "Logging specific to the SURF network module"); + "Logging specific to the SURF network module"); /********* * C API * @@ -21,37 +21,37 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network, surf, extern "C" { -const char* sg_link_name(Link *link) { - return link->getName(); -} -Link * sg_link_by_name(const char* name) { - return Link::byName(name); -} + const char* sg_link_name(Link *link) { + return link->getName(); + } + Link * sg_link_by_name(const char* name) { + return Link::byName(name); + } -int sg_link_is_shared(Link *link){ - return link->sharingPolicy(); -} -double sg_link_bandwidth(Link *link){ - return link->getBandwidth(); -} -double sg_link_latency(Link *link){ - return link->getLatency(); -} -void* sg_link_data(Link *link) { - return link->getData(); -} -void sg_link_data_set(Link *link,void *data) { - link->setData(data); -} -int sg_link_count(void) { - return Link::linksCount(); -} -Link** sg_link_list(void) { - return Link::linksList(); -} -void sg_link_exit(void) { - Link::linksExit(); -} + int sg_link_is_shared(Link *link){ + return link->sharingPolicy(); + } + double sg_link_bandwidth(Link *link){ + return link->getBandwidth(); + } + double sg_link_latency(Link *link){ + return link->getLatency(); + } + void* sg_link_data(Link *link) { + return link->getData(); + } + void sg_link_data_set(Link *link,void *data) { + link->setData(data); + } + int sg_link_count(void) { + return Link::linksCount(); + } + Link** sg_link_list(void) { + return Link::linksList(); + } + void sg_link_exit(void) { + Link::linksExit(); + } } @@ -60,49 +60,49 @@ void sg_link_exit(void) { *****************/ namespace simgrid { -namespace surf { + namespace surf { -boost::unordered_map *Link::links = new boost::unordered_map(); -Link *Link::byName(const char* name) { - Link * res = NULL; - try { - res = links->at(name); - } catch (std::out_of_range& e) {} + boost::unordered_map *Link::links = new boost::unordered_map(); + Link *Link::byName(const char* name) { + Link * res = NULL; + try { + res = links->at(name); + } catch (std::out_of_range& e) {} - return res; -} -/** @brief Returns the amount of links in the platform */ -int Link::linksCount() { - return links->size(); -} -/** @brief Returns a list of all existing links */ -Link **Link::linksList() { - Link **res = xbt_new(Link*, (int)links->size()); - int i=0; - for (auto kv : *links) { - res[i++] = kv.second; + return res; + } + /** @brief Returns the amount of links in the platform */ + int Link::linksCount() { + return links->size(); + } + /** @brief Returns a list of all existing links */ + Link **Link::linksList() { + Link **res = xbt_new(Link*, (int)links->size()); + int i=0; + for (auto kv : *links) { + res[i++] = kv.second; + } + return res; + } + /** @brief destructor of the static data */ + void Link::linksExit() { + for (auto kv : *links) + (kv.second)->destroy(); + delete links; } - return res; -} -/** @brief destructor of the static data */ -void Link::linksExit() { - for (auto kv : *links) - (kv.second)->destroy(); - delete links; -} -/************* - * Callbacks * - *************/ + /************* + * Callbacks * + *************/ -simgrid::xbt::signal Link::onCreation; -simgrid::xbt::signal Link::onDestruction; -simgrid::xbt::signal Link::onStateChange; + simgrid::xbt::signal Link::onCreation; + simgrid::xbt::signal Link::onDestruction; + simgrid::xbt::signal Link::onStateChange; -simgrid::xbt::signal networkActionStateChangedCallbacks; -simgrid::xbt::signal networkCommunicateCallbacks; + simgrid::xbt::signal networkActionStateChangedCallbacks; + simgrid::xbt::signal networkCommunicateCallbacks; -} + } } void netlink_parse_init(sg_platf_link_cbarg_t link){ @@ -110,19 +110,19 @@ void netlink_parse_init(sg_platf_link_cbarg_t link){ char *link_id; link_id = bprintf("%s_UP", link->id); surf_network_model->createLink(link_id, - link->bandwidth, - link->bandwidth_trace, - link->latency, - link->latency_trace, - link->state_trace, link->policy, link->properties); + link->bandwidth, + link->bandwidth_trace, + link->latency, + link->latency_trace, + link->state_trace, link->policy, link->properties); xbt_free(link_id); link_id = bprintf("%s_DOWN", link->id); surf_network_model->createLink(link_id, - link->bandwidth, - link->bandwidth_trace, - link->latency, - link->latency_trace, - link->state_trace, link->policy, link->properties); + link->bandwidth, + link->bandwidth_trace, + link->latency, + link->latency_trace, + link->state_trace, link->policy, link->properties); xbt_free(link_id); } else { surf_network_model->createLink(link->id, @@ -141,159 +141,159 @@ void netlink_parse_init(sg_platf_link_cbarg_t link){ simgrid::surf::NetworkModel *surf_network_model = NULL; namespace simgrid { -namespace surf { + namespace surf { -double NetworkModel::latencyFactor(double /*size*/) { - return sg_latency_factor; -} + double NetworkModel::latencyFactor(double /*size*/) { + return sg_latency_factor; + } -double NetworkModel::bandwidthFactor(double /*size*/) { - return sg_bandwidth_factor; -} + double NetworkModel::bandwidthFactor(double /*size*/) { + return sg_bandwidth_factor; + } -double NetworkModel::bandwidthConstraint(double rate, double /*bound*/, double /*size*/) { - return rate; -} + double NetworkModel::bandwidthConstraint(double rate, double /*bound*/, double /*size*/) { + return rate; + } -double NetworkModel::next_occuring_event_full(double now) -{ - NetworkAction *action = NULL; - ActionList *runningActions = surf_network_model->getRunningActionSet(); - double minRes; + double NetworkModel::next_occuring_event_full(double now) + { + NetworkAction *action = NULL; + ActionList *runningActions = surf_network_model->getRunningActionSet(); + double minRes; - minRes = shareResourcesMaxMin(runningActions, surf_network_model->p_maxminSystem, surf_network_model->f_networkSolve); + minRes = shareResourcesMaxMin(runningActions, surf_network_model->p_maxminSystem, surf_network_model->f_networkSolve); - for(ActionList::iterator it(runningActions->begin()), itend(runningActions->end()) - ; it != itend ; ++it) { - action = static_cast(&*it); + for(ActionList::iterator it(runningActions->begin()), itend(runningActions->end()) + ; it != itend ; ++it) { + action = static_cast(&*it); #ifdef HAVE_LATENCY_BOUND_TRACKING - if (lmm_is_variable_limited_by_latency(action->getVariable())) { - action->m_latencyLimited = 1; - } else { - action->m_latencyLimited = 0; - } + if (lmm_is_variable_limited_by_latency(action->getVariable())) { + action->m_latencyLimited = 1; + } else { + action->m_latencyLimited = 0; + } #endif - if (action->m_latency > 0) { - minRes = (minRes < 0) ? action->m_latency : std::min(minRes, action->m_latency); - } - } + if (action->m_latency > 0) { + minRes = (minRes < 0) ? action->m_latency : std::min(minRes, action->m_latency); + } + } - XBT_DEBUG("Min of share resources %f", minRes); + XBT_DEBUG("Min of share resources %f", minRes); - return minRes; -} + return minRes; + } -/************ - * Resource * - ************/ + /************ + * Resource * + ************/ -Link::Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props) -: Resource(model, name), - PropertyHolder(props) -{ - links->insert({name, this}); + Link::Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props) + : Resource(model, name), + PropertyHolder(props) + { + links->insert({name, this}); - m_latency.scale = 1; - m_bandwidth.scale = 1; - XBT_DEBUG("Create link '%s'",name); -} + m_latency.scale = 1; + m_bandwidth.scale = 1; + XBT_DEBUG("Create link '%s'",name); + } -Link::Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props, - lmm_constraint_t constraint, - tmgr_trace_t state_trace) -: Resource(model, name, constraint), - PropertyHolder(props) -{ - m_latency.scale = 1; - m_bandwidth.scale = 1; - if (state_trace) - m_stateEvent = future_evt_set->add_trace(state_trace, 0.0, this); + Link::Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props, + lmm_constraint_t constraint, + tmgr_trace_t state_trace) + : Resource(model, name, constraint), + PropertyHolder(props) + { + m_latency.scale = 1; + m_bandwidth.scale = 1; + if (state_trace) + m_stateEvent = future_evt_set->add_trace(state_trace, 0.0, this); - links->insert({name, this}); - XBT_DEBUG("Create link '%s'",name); + links->insert({name, this}); + XBT_DEBUG("Create link '%s'",name); -} + } -/** @brief use destroy() instead of this destructor */ -Link::~Link() { - xbt_assert(currentlyDestroying_, "Don't delete Links directly. Call destroy() instead."); -} -/** @brief Fire the require callbacks and destroy the object - * - * Don't delete directly an Link, call l->destroy() instead. - */ -void Link::destroy() -{ - if (!currentlyDestroying_) { - currentlyDestroying_ = true; - onDestruction(this); - delete this; - } -} + /** @brief use destroy() instead of this destructor */ + Link::~Link() { + xbt_assert(currentlyDestroying_, "Don't delete Links directly. Call destroy() instead."); + } + /** @brief Fire the require callbacks and destroy the object + * + * Don't delete directly an Link, call l->destroy() instead. + */ + void Link::destroy() + { + if (!currentlyDestroying_) { + currentlyDestroying_ = true; + onDestruction(this); + delete this; + } + } -bool Link::isUsed() -{ - return lmm_constraint_used(getModel()->getMaxminSystem(), getConstraint()); -} + bool Link::isUsed() + { + return lmm_constraint_used(getModel()->getMaxminSystem(), getConstraint()); + } -double Link::getLatency() -{ - return m_latency.peak * m_latency.scale; -} + double Link::getLatency() + { + return m_latency.peak * m_latency.scale; + } -double Link::getBandwidth() -{ - return m_bandwidth.peak * m_bandwidth.scale; -} + double Link::getBandwidth() + { + return m_bandwidth.peak * m_bandwidth.scale; + } -int Link::sharingPolicy() -{ - return lmm_constraint_sharing_policy(getConstraint()); -} + int Link::sharingPolicy() + { + return lmm_constraint_sharing_policy(getConstraint()); + } -void Link::turnOn(){ - if (isOff()) { - Resource::turnOn(); - onStateChange(this); - } -} -void Link::turnOff(){ - if (isOn()) { - Resource::turnOff(); - onStateChange(this); - } -} -void Link::set_state_trace(tmgr_trace_t trace) -{ - xbt_assert(m_stateEvent==NULL,"Cannot set a second state trace to Link %s", getName()); + void Link::turnOn(){ + if (isOff()) { + Resource::turnOn(); + onStateChange(this); + } + } + void Link::turnOff(){ + if (isOn()) { + Resource::turnOff(); + onStateChange(this); + } + } + void Link::set_state_trace(tmgr_trace_t trace) + { + xbt_assert(m_stateEvent==NULL,"Cannot set a second state trace to Link %s", getName()); - m_stateEvent = future_evt_set->add_trace(trace, 0.0, this); -} -void Link::set_bandwidth_trace(tmgr_trace_t trace) -{ - xbt_assert(m_bandwidth.event==NULL,"Cannot set a second bandwidth trace to Link %s", getName()); + m_stateEvent = future_evt_set->add_trace(trace, 0.0, this); + } + void Link::set_bandwidth_trace(tmgr_trace_t trace) + { + xbt_assert(m_bandwidth.event==NULL,"Cannot set a second bandwidth trace to Link %s", getName()); - m_bandwidth.event = future_evt_set->add_trace(trace, 0.0, this); -} -void Link::set_latency_trace(tmgr_trace_t trace) -{ - xbt_assert(m_latency.event==NULL,"Cannot set a second latency trace to Link %s", getName()); + m_bandwidth.event = future_evt_set->add_trace(trace, 0.0, this); + } + void Link::set_latency_trace(tmgr_trace_t trace) + { + xbt_assert(m_latency.event==NULL,"Cannot set a second latency trace to Link %s", getName()); - m_latency.event = future_evt_set->add_trace(trace, 0.0, this); -} + m_latency.event = future_evt_set->add_trace(trace, 0.0, this); + } -/********** - * Action * - **********/ + /********** + * Action * + **********/ -void NetworkAction::setState(e_surf_action_state_t state){ - e_surf_action_state_t old = getState(); - Action::setState(state); - networkActionStateChangedCallbacks(this, old, state); -} + void NetworkAction::setState(e_surf_action_state_t state){ + e_surf_action_state_t old = getState(); + Action::setState(state); + networkActionStateChangedCallbacks(this, old, state); + } -} + } } #endif /* NETWORK_INTERFACE_CPP_ */ diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index 1977d9695d..1b69f74584 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -24,25 +24,25 @@ ***********/ namespace simgrid { -namespace surf { + namespace surf { -class NetworkModel; -class NetworkAction; + class NetworkModel; + class NetworkAction; -/************* - * Callbacks * - *************/ + /************* + * Callbacks * + *************/ -/** @brief Callback signal fired when the state of a NetworkAction changes - * Signature: `void(NetworkAction *action, e_surf_action_state_t old, e_surf_action_state_t current)` */ -XBT_PUBLIC_DATA(simgrid::xbt::signal) networkActionStateChangedCallbacks; + /** @brief Callback signal fired when the state of a NetworkAction changes + * Signature: `void(NetworkAction *action, e_surf_action_state_t old, e_surf_action_state_t current)` */ + XBT_PUBLIC_DATA(simgrid::xbt::signal) networkActionStateChangedCallbacks; -/** @brief Callback signal fired when a NetworkAction is created (when a communication starts) - * Signature: `void(NetworkAction *action, RoutingEdge *src, RoutingEdge *dst, double size, double rate)` */ -XBT_PUBLIC_DATA(simgrid::xbt::signal) networkCommunicateCallbacks; + /** @brief Callback signal fired when a NetworkAction is created (when a communication starts) + * Signature: `void(NetworkAction *action, RoutingEdge *src, RoutingEdge *dst, double size, double rate)` */ + XBT_PUBLIC_DATA(simgrid::xbt::signal) networkCommunicateCallbacks; -} + } } /********* @@ -55,264 +55,264 @@ XBT_PUBLIC(void) netlink_parse_init(sg_platf_link_cbarg_t link); *********/ namespace simgrid { -namespace surf { - -/** @ingroup SURF_network_interface - * @brief SURF network model interface class - * @details A model is an object which handles the interactions between its Resources and its Actions - */ -class NetworkModel : public Model { -public: - /** @brief Constructor */ - NetworkModel() : Model() { } - - /** @brief Destructor */ - ~NetworkModel() { - if (p_maxminSystem) - lmm_system_free(p_maxminSystem); - if (p_actionHeap) - xbt_heap_free(p_actionHeap); - if (p_modifiedSet) - delete p_modifiedSet; - } - - /** - * @brief Create a Link - * - * @param name The name of the Link - * @param bw_initial The initial bandwidth of the Link in bytes per second - * @param bw_trace The trace associated to the Link bandwidth - * @param lat_initial The initial latency of the Link in seconds - * @param lat_trace The trace associated to the Link latency - * @param state_trace The trace associated to the Link (state)[e_surf_resource_state_t] - * @param policy The sharing policy of the Link - * @param properties Dictionary of properties associated to this Resource - * @return The created Link - */ - virtual Link* createLink(const char *name, - double bw_initial, - tmgr_trace_t bw_trace, - double lat_initial, - tmgr_trace_t lat_trace, - tmgr_trace_t state_trace, - e_surf_link_sharing_policy_t policy, - xbt_dict_t properties)=0; - - /** - * @brief Create a communication between two hosts. - * @details It makes calls to the routing part, and execute the communication - * between the two end points. - * - * @param src The source of the communication - * @param dst The destination of the communication - * @param size The size of the communication in bytes - * @param rate Allows to limit the transfer rate. Negative value means - * unlimited. - * @return The action representing the communication - */ - virtual Action *communicate(NetCard *src, NetCard *dst, - double size, double rate)=0; - - /** @brief Function pointer to the function to use to solve the lmm_system_t - * - * @param system The lmm_system_t to solve - */ - void (*f_networkSolve)(lmm_system_t) = lmm_solve; - - /** - * @brief Get the right multiplicative factor for the latency. - * @details Depending on the model, the effective latency when sending - * a message might be different from the theoretical latency of the link, - * in function of the message size. In order to account for this, this - * function gets this factor. - * - * @param size The size of the message. - * @return The latency factor. - */ - virtual double latencyFactor(double size); - - /** - * @brief Get the right multiplicative factor for the bandwidth. - * @details Depending on the model, the effective bandwidth when sending - * a message might be different from the theoretical bandwidth of the link, - * in function of the message size. In order to account for this, this - * function gets this factor. - * - * @param size The size of the message. - * @return The bandwidth factor. - */ - virtual double bandwidthFactor(double size); - - /** - * @brief Get definitive bandwidth. - * @details It gives the minimum bandwidth between the one that would - * occur if no limitation was enforced, and the one arbitrary limited. - * @param rate The desired maximum bandwidth. - * @param bound The bandwidth with only the network taken into account. - * @param size The size of the message. - * @return The new bandwidth. - */ - virtual double bandwidthConstraint(double rate, double bound, double size); - double next_occuring_event_full(double now) override; -}; - -/************ - * Resource * - ************/ - /** @ingroup SURF_network_interface - * @brief SURF network link interface class - * @details A Link represents the link between two [hosts](\ref Host) - */ -class Link : - public simgrid::surf::Resource, - public simgrid::surf::PropertyHolder { -public: - /** - * @brief Link constructor - * - * @param model The NetworkModel associated to this Link - * @param name The name of the Link - * @param props Dictionary of properties associated to this Link - */ - Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props); - - /** - * @brief Link constructor - * - * @param model The NetworkModel associated to this Link - * @param name The name of the Link - * @param props Dictionary of properties associated to this Link - * @param constraint The lmm constraint associated to this Cpu if it is part of a LMM component - * @param state_trace [TODO] - */ - Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props, - lmm_constraint_t constraint, - tmgr_trace_t state_trace); - - /* Link destruction logic */ - /**************************/ -protected: - ~Link(); -public: - void destroy(); // Must be called instead of the destructor -private: - bool currentlyDestroying_ = false; - -public: - /** @brief Callback signal fired when a new Link is created. - * Signature: void(Link*) */ - static simgrid::xbt::signal onCreation; - - /** @brief Callback signal fired when a Link is destroyed. - * Signature: void(Link*) */ - static simgrid::xbt::signal onDestruction; - - /** @brief Callback signal fired when the state of a Link changes (when it is turned on or off) - * Signature: `void(Link*)` */ - static simgrid::xbt::signal onStateChange; - - - /** @brief Get the bandwidth in bytes per second of current Link */ - virtual double getBandwidth(); - - /** @brief Update the bandwidth in bytes per second of current Link */ - virtual void updateBandwidth(double value)=0; - - /** @brief Get the latency in seconds of current Link */ - virtual double getLatency(); - - /** @brief Update the latency in seconds of current Link */ - virtual void updateLatency(double value)=0; - - /** @brief The sharing policy is a @{link e_surf_link_sharing_policy_t::EType} (0: FATPIPE, 1: SHARED, 2: FULLDUPLEX) */ - virtual int sharingPolicy(); - - /** @brief Check if the Link is used */ - bool isUsed() override; - - void turnOn() override; - void turnOff() override; - - virtual void set_state_trace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF). Trace must contain boolean values. */ - virtual void set_bandwidth_trace(tmgr_trace_t trace); /*< setup the trace file with bandwidth events (peak speed changes due to external load). Trace must contain percentages (value between 0 and 1). */ - virtual void set_latency_trace(tmgr_trace_t trace); /*< setup the trace file with latency events (peak latency changes due to external load). Trace must contain absolute values */ - - tmgr_trace_iterator_t m_stateEvent = NULL; - s_surf_metric_t m_latency = {1.0,0,NULL}; - s_surf_metric_t m_bandwidth = {1.0,0,NULL}; - - /* User data */ -public: - void *getData() { return userData;} - void setData(void *d) { userData=d;} -private: - void *userData = NULL; - - /* List of all links */ -private: - static boost::unordered_map *links; -public: - static Link *byName(const char* name); - static int linksCount(); - static Link **linksList(); - static void linksExit(); -}; - -/********** - * Action * - **********/ -/** @ingroup SURF_network_interface - * @brief SURF network action interface class - * @details A NetworkAction represents a communication between two [hosts](\ref Host) - */ -class NetworkAction : public simgrid::surf::Action { -public: - /** @brief Constructor - * - * @param model The NetworkModel associated to this NetworkAction - * @param cost The cost of this NetworkAction in [TODO] - * @param failed [description] - */ - NetworkAction(simgrid::surf::Model *model, double cost, bool failed) - : simgrid::surf::Action(model, cost, failed) {} - - /** - * @brief NetworkAction constructor - * - * @param model The NetworkModel associated to this NetworkAction - * @param cost The cost of this NetworkAction in [TODO] - * @param failed [description] - * @param var The lmm variable associated to this Action if it is part of a - * LMM component - */ - NetworkAction(simgrid::surf::Model *model, double cost, bool failed, lmm_variable_t var) - : simgrid::surf::Action(model, cost, failed, var) {}; - - void setState(e_surf_action_state_t state); + namespace surf { + + /** @ingroup SURF_network_interface + * @brief SURF network model interface class + * @details A model is an object which handles the interactions between its Resources and its Actions + */ + class NetworkModel : public Model { + public: + /** @brief Constructor */ + NetworkModel() : Model() { } + + /** @brief Destructor */ + ~NetworkModel() { + if (p_maxminSystem) + lmm_system_free(p_maxminSystem); + if (p_actionHeap) + xbt_heap_free(p_actionHeap); + if (p_modifiedSet) + delete p_modifiedSet; + } + + /** + * @brief Create a Link + * + * @param name The name of the Link + * @param bw_initial The initial bandwidth of the Link in bytes per second + * @param bw_trace The trace associated to the Link bandwidth + * @param lat_initial The initial latency of the Link in seconds + * @param lat_trace The trace associated to the Link latency + * @param state_trace The trace associated to the Link (state)[e_surf_resource_state_t] + * @param policy The sharing policy of the Link + * @param properties Dictionary of properties associated to this Resource + * @return The created Link + */ + virtual Link* createLink(const char *name, + double bw_initial, + tmgr_trace_t bw_trace, + double lat_initial, + tmgr_trace_t lat_trace, + tmgr_trace_t state_trace, + e_surf_link_sharing_policy_t policy, + xbt_dict_t properties)=0; + + /** + * @brief Create a communication between two hosts. + * @details It makes calls to the routing part, and execute the communication + * between the two end points. + * + * @param src The source of the communication + * @param dst The destination of the communication + * @param size The size of the communication in bytes + * @param rate Allows to limit the transfer rate. Negative value means + * unlimited. + * @return The action representing the communication + */ + virtual Action *communicate(NetCard *src, NetCard *dst, + double size, double rate)=0; + + /** @brief Function pointer to the function to use to solve the lmm_system_t + * + * @param system The lmm_system_t to solve + */ + void (*f_networkSolve)(lmm_system_t) = lmm_solve; + + /** + * @brief Get the right multiplicative factor for the latency. + * @details Depending on the model, the effective latency when sending + * a message might be different from the theoretical latency of the link, + * in function of the message size. In order to account for this, this + * function gets this factor. + * + * @param size The size of the message. + * @return The latency factor. + */ + virtual double latencyFactor(double size); + + /** + * @brief Get the right multiplicative factor for the bandwidth. + * @details Depending on the model, the effective bandwidth when sending + * a message might be different from the theoretical bandwidth of the link, + * in function of the message size. In order to account for this, this + * function gets this factor. + * + * @param size The size of the message. + * @return The bandwidth factor. + */ + virtual double bandwidthFactor(double size); + + /** + * @brief Get definitive bandwidth. + * @details It gives the minimum bandwidth between the one that would + * occur if no limitation was enforced, and the one arbitrary limited. + * @param rate The desired maximum bandwidth. + * @param bound The bandwidth with only the network taken into account. + * @param size The size of the message. + * @return The new bandwidth. + */ + virtual double bandwidthConstraint(double rate, double bound, double size); + double next_occuring_event_full(double now) override; + }; + + /************ + * Resource * + ************/ + /** @ingroup SURF_network_interface + * @brief SURF network link interface class + * @details A Link represents the link between two [hosts](\ref Host) + */ + class Link : + public simgrid::surf::Resource, + public simgrid::surf::PropertyHolder { + public: + /** + * @brief Link constructor + * + * @param model The NetworkModel associated to this Link + * @param name The name of the Link + * @param props Dictionary of properties associated to this Link + */ + Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props); + + /** + * @brief Link constructor + * + * @param model The NetworkModel associated to this Link + * @param name The name of the Link + * @param props Dictionary of properties associated to this Link + * @param constraint The lmm constraint associated to this Cpu if it is part of a LMM component + * @param state_trace [TODO] + */ + Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props, + lmm_constraint_t constraint, + tmgr_trace_t state_trace); + + /* Link destruction logic */ + /**************************/ + protected: + ~Link(); + public: + void destroy(); // Must be called instead of the destructor + private: + bool currentlyDestroying_ = false; + + public: + /** @brief Callback signal fired when a new Link is created. + * Signature: void(Link*) */ + static simgrid::xbt::signal onCreation; + + /** @brief Callback signal fired when a Link is destroyed. + * Signature: void(Link*) */ + static simgrid::xbt::signal onDestruction; + + /** @brief Callback signal fired when the state of a Link changes (when it is turned on or off) + * Signature: `void(Link*)` */ + static simgrid::xbt::signal onStateChange; + + + /** @brief Get the bandwidth in bytes per second of current Link */ + virtual double getBandwidth(); + + /** @brief Update the bandwidth in bytes per second of current Link */ + virtual void updateBandwidth(double value)=0; + + /** @brief Get the latency in seconds of current Link */ + virtual double getLatency(); + + /** @brief Update the latency in seconds of current Link */ + virtual void updateLatency(double value)=0; + + /** @brief The sharing policy is a @{link e_surf_link_sharing_policy_t::EType} (0: FATPIPE, 1: SHARED, 2: FULLDUPLEX) */ + virtual int sharingPolicy(); + + /** @brief Check if the Link is used */ + bool isUsed() override; + + void turnOn() override; + void turnOff() override; + + virtual void set_state_trace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF). Trace must contain boolean values. */ + virtual void set_bandwidth_trace(tmgr_trace_t trace); /*< setup the trace file with bandwidth events (peak speed changes due to external load). Trace must contain percentages (value between 0 and 1). */ + virtual void set_latency_trace(tmgr_trace_t trace); /*< setup the trace file with latency events (peak latency changes due to external load). Trace must contain absolute values */ + + tmgr_trace_iterator_t m_stateEvent = NULL; + s_surf_metric_t m_latency = {1.0,0,NULL}; + s_surf_metric_t m_bandwidth = {1.0,0,NULL}; + + /* User data */ + public: + void *getData() { return userData;} + void setData(void *d) { userData=d;} + private: + void *userData = NULL; + + /* List of all links */ + private: + static boost::unordered_map *links; + public: + static Link *byName(const char* name); + static int linksCount(); + static Link **linksList(); + static void linksExit(); + }; + + /********** + * Action * + **********/ + /** @ingroup SURF_network_interface + * @brief SURF network action interface class + * @details A NetworkAction represents a communication between two [hosts](\ref Host) + */ + class NetworkAction : public simgrid::surf::Action { + public: + /** @brief Constructor + * + * @param model The NetworkModel associated to this NetworkAction + * @param cost The cost of this NetworkAction in [TODO] + * @param failed [description] + */ + NetworkAction(simgrid::surf::Model *model, double cost, bool failed) + : simgrid::surf::Action(model, cost, failed) {} + + /** + * @brief NetworkAction constructor + * + * @param model The NetworkModel associated to this NetworkAction + * @param cost The cost of this NetworkAction in [TODO] + * @param failed [description] + * @param var The lmm variable associated to this Action if it is part of a + * LMM component + */ + NetworkAction(simgrid::surf::Model *model, double cost, bool failed, lmm_variable_t var) + : simgrid::surf::Action(model, cost, failed, var) {}; + + void setState(e_surf_action_state_t state); #ifdef HAVE_LATENCY_BOUND_TRACKING - /** - * @brief Check if the action is limited by latency. - * - * @return 1 if action is limited by latency, 0 otherwise - */ - virtual int getLatencyLimited() {return m_latencyLimited;} + /** + * @brief Check if the action is limited by latency. + * + * @return 1 if action is limited by latency, 0 otherwise + */ + virtual int getLatencyLimited() {return m_latencyLimited;} #endif - double m_latency; - double m_latCurrent; - double m_weight; - double m_rate; - const char* p_senderLinkName; - double m_senderSize; - xbt_fifo_item_t p_senderFifoItem; + double m_latency; + double m_latCurrent; + double m_weight; + double m_rate; + const char* p_senderLinkName; + double m_senderSize; + xbt_fifo_item_t p_senderFifoItem; #ifdef HAVE_LATENCY_BOUND_TRACKING - int m_latencyLimited; + int m_latencyLimited; #endif -}; + }; -} + } } #endif /* SURF_NETWORK_INTERFACE_HPP_ */ diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index 491fa43437..c20f3c9b5b 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -273,13 +273,6 @@ Link* NetworkNS3Model::createLink(const char *name, return link; } -xbt_dynar_t NetworkNS3Model::getRoute(NetCard *src, NetCard *dst) -{ - xbt_dynar_t route = NULL; - routing_platf->getRouteAndLatency(src, dst, &route, NULL); - return route; -} - Action *NetworkNS3Model::communicate(NetCard *src, NetCard *dst, double size, double rate) { @@ -345,18 +338,13 @@ void NetworkNS3Model::updateActionsState(double now, double delta) double data_sent = ns3_get_socket_sent(data); double data_delta_sent = data_sent - action->m_lastSent; - xbt_dynar_t route = NULL; - - routing_platf->getRouteAndLatency (action->p_srcElm, action->p_dstElm, &route, NULL); - unsigned int i; - for (i = 0; i < xbt_dynar_length (route); i++){ - NetworkNS3Link* link = ((NetworkNS3Link*)xbt_dynar_get_ptr(route, i)); - TRACE_surf_link_set_utilization (link->getName(), - action->getCategory(), - (data_delta_sent)/delta, - now-delta, - delta); - } + std::vector *route = new std::vector(); + + routing_platf->getRouteAndLatency (action->p_srcElm, action->p_dstElm, route, NULL); + for (auto link : *route) + TRACE_surf_link_set_utilization (link->getName(), action->getCategory(), (data_delta_sent)/delta, now-delta, delta); + delete route; + action->m_lastSent = data_sent; } diff --git a/src/surf/network_ns3.hpp b/src/surf/network_ns3.hpp index fa19671278..0a0dd90aaf 100644 --- a/src/surf/network_ns3.hpp +++ b/src/surf/network_ns3.hpp @@ -49,7 +49,6 @@ public: tmgr_trace_t state_trace, e_surf_link_sharing_policy_t policy, xbt_dict_t properties) override; - xbt_dynar_t getRoute(NetCard *src, NetCard *dst); Action *communicate(NetCard *src, NetCard *dst, double size, double rate); double next_occuring_event(double now) override; bool next_occuring_event_isIdempotent() {return false;} diff --git a/src/surf/network_smpi.hpp b/src/surf/network_smpi.hpp index 30cf4eefa1..c369fdb109 100644 --- a/src/surf/network_smpi.hpp +++ b/src/surf/network_smpi.hpp @@ -9,45 +9,31 @@ #include "network_cm02.hpp" namespace simgrid { -namespace surf { + namespace surf { -/*********** - * Classes * - ***********/ + class XBT_PRIVATE NetworkSmpiModel : public NetworkCm02Model { + public: + NetworkSmpiModel(); + ~NetworkSmpiModel(); -class XBT_PRIVATE NetworkSmpiModel; + using NetworkCm02Model::gapAppend; // Explicit about overloaded method (silence Woverloaded-virtual from clang) + void gapAppend(double size, Link* link, NetworkAction *action); + void gapRemove(Action *action); + double latencyFactor(double size); + double bandwidthFactor(double size); + double bandwidthConstraint(double rate, double bound, double size); + void communicateCallBack() {}; + }; -/********* - * Tools * - *********/ -/********* - * Model * - *********/ + /************ + * Resource * + ************/ -class NetworkSmpiModel : public NetworkCm02Model { -public: - NetworkSmpiModel(); - ~NetworkSmpiModel(); - using NetworkCm02Model::gapAppend; // Explicit about overloaded method (silence Woverloaded-virtual from clang) - void gapAppend(double size, Link* link, NetworkAction *action); - void gapRemove(Action *action); - double latencyFactor(double size); - double bandwidthFactor(double size); - double bandwidthConstraint(double rate, double bound, double size); - void communicateCallBack() {}; -}; + /********** + * Action * + **********/ - -/************ - * Resource * - ************/ - - -/********** - * Action * - **********/ - -} + } } diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index 5d5e099766..d7cf81c4dd 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -186,14 +186,10 @@ Action *HostL07Model::executeParallelTask(int host_nb, sg_host_t *host_list, } -L07Action::L07Action(Model *model, int host_nb, - sg_host_t*host_list, - double *flops_amount, - double *bytes_amount, - double rate) +L07Action::L07Action(Model *model, int host_nb, sg_host_t*host_list, + double *flops_amount, double *bytes_amount, double rate) : CpuAction(model, 1, 0) { - unsigned int cpt; int nb_link = 0; int nb_used_host = 0; /* Only the hosts with something to compute (>0 flops) are counted) */ double latency = 0.0; @@ -211,16 +207,14 @@ L07Action::L07Action(Model *model, int host_nb, if (bytes_amount[i * host_nb + j] > 0) { double lat=0.0; - xbt_dynar_t route=NULL; + std::vector *route = new std::vector(); - routing_platf->getRouteAndLatency((*p_netcardList)[i], (*p_netcardList)[j], &route, &lat); + routing_platf->getRouteAndLatency((*p_netcardList)[i], (*p_netcardList)[j], route, &lat); latency = MAX(latency, lat); - void *_link; - xbt_dynar_foreach(route, cpt, _link) { - LinkL07 *link = static_cast(_link); + for (auto link : *route) xbt_dict_set(ptask_parallel_task_link_set, link->getName(), link, NULL); - } + delete route; } } } @@ -254,19 +248,16 @@ L07Action::L07Action(Model *model, int host_nb, for (int i = 0; i < host_nb; i++) { for (int j = 0; j < host_nb; j++) { - xbt_dynar_t route=NULL; if (bytes_amount[i * host_nb + j] == 0.0) continue; + std::vector *route = new std::vector(); - routing_platf->getRouteAndLatency((*p_netcardList)[i], (*p_netcardList)[j], - &route, NULL); + routing_platf->getRouteAndLatency((*p_netcardList)[i], (*p_netcardList)[j], route, NULL); - void *_link; - xbt_dynar_foreach(route, cpt, _link) { - LinkL07 *link = static_cast(_link); - lmm_expand_add(model->getMaxminSystem(), link->getConstraint(), - this->getVariable(), bytes_amount[i * host_nb + j]); - } + for (auto link : *route) + lmm_expand_add(model->getMaxminSystem(), link->getConstraint(), this->getVariable(), bytes_amount[i * host_nb + j]); + + delete route; } } } @@ -495,14 +486,14 @@ void L07Action::updateBound() if (p_communicationAmount != NULL) { for (i = 0; i < hostNb; i++) { for (j = 0; j < hostNb; j++) { - xbt_dynar_t route=NULL; if (p_communicationAmount[i * hostNb + j] > 0) { double lat = 0.0; - routing_platf->getRouteAndLatency((*p_netcardList)[i], (*p_netcardList)[j], - &route, &lat); + std::vector *route = new std::vector(); + routing_platf->getRouteAndLatency((*p_netcardList)[i], (*p_netcardList)[j], route, &lat); lat_current = MAX(lat_current, lat * p_communicationAmount[i * hostNb + j]); + delete route; } } } diff --git a/src/surf/surf_private.h b/src/surf/surf_private.h index 336a532a84..e427e58483 100644 --- a/src/surf/surf_private.h +++ b/src/surf/surf_private.h @@ -54,7 +54,6 @@ typedef enum { extern XBT_PRIVATE simgrid::trace_mgr::future_evt_set *future_evt_set; -XBT_PUBLIC(void) routing_model_create(void *loopback); XBT_PUBLIC(void) routing_exit(void); XBT_PUBLIC(void) storage_register_callbacks(void); diff --git a/src/surf/surf_routing.cpp b/src/surf/surf_routing.cpp index 073de7043f..1ef547b3c5 100644 --- a/src/surf/surf_routing.cpp +++ b/src/surf/surf_routing.cpp @@ -181,28 +181,21 @@ namespace surf { if (e_route->gw_dst) { XBT_DEBUG("Load bypassASroute from %s@%s to %s@%s", src, e_route->gw_src->name(), dst, e_route->gw_dst->name()); - xbt_assert(!xbt_dynar_is_empty(e_route->link_list), "Bypass route between %s@%s and %s@%s cannot be empty.", + xbt_assert(!e_route->link_list->empty(), "Bypass route between %s@%s and %s@%s cannot be empty.", src, e_route->gw_src->name(), dst, e_route->gw_dst->name()); xbt_assert(bypassRoutes_->find(route_name) == bypassRoutes_->end(), "The bypass route between %s@%s and %s@%s already exists.", src, e_route->gw_src->name(), dst, e_route->gw_dst->name()); } else { XBT_DEBUG("Load bypassRoute from %s to %s", src, dst); - xbt_assert(!xbt_dynar_is_empty(e_route->link_list), "Bypass route between %s and %s cannot be empty.", src, dst); + xbt_assert(!e_route->link_list->empty(), "Bypass route between %s and %s cannot be empty.", src, dst); xbt_assert(bypassRoutes_->find(route_name) == bypassRoutes_->end(), "The bypass route between %s and %s already exists.", src, dst); } - /* Build the value that will be stored in the dict */ + /* Build a copy that will be stored in the dict */ std::vector *newRoute = new std::vector(); - char *linkName; - unsigned int cpt; - xbt_dynar_foreach(e_route->link_list, cpt, linkName) { - Link *link = Link::byName(linkName); - if (link) - newRoute->push_back(link); - else - THROWF(mismatch_error, 0, "Link '%s' not found", linkName); - } + for (auto link: *e_route->link_list) + newRoute->push_back(link); /* Store it */ bypassRoutes_->insert({route_name, newRoute}); @@ -460,7 +453,7 @@ static void elements_father(sg_netcard_t src, sg_netcard_t dst, * \param *latency the latency, if needed */ static void _get_route_and_latency(simgrid::surf::NetCard *src, simgrid::surf::NetCard *dst, - xbt_dynar_t * links, double *latency) + std::vector * links, double *latency) { s_sg_platf_route_cbarg_t route = SG_PLATF_ROUTE_INITIALIZER; memset(&route,0,sizeof(route)); @@ -478,7 +471,7 @@ static void _get_route_and_latency(simgrid::surf::NetCard *src, simgrid::surf::N std::vector *bypassed_route = common_father->getBypassRoute(src, dst); if (nullptr != bypassed_route) { for (Link *link : *bypassed_route) { - xbt_dynar_push(*links,&link); + links->push_back(link); if (latency) *latency += link->getLatency(); } @@ -487,14 +480,14 @@ static void _get_route_and_latency(simgrid::surf::NetCard *src, simgrid::surf::N /* If src and dst are in the same AS, life is good */ if (src_father == dst_father) { /* SURF_ROUTING_BASE */ - route.link_list = *links; + route.link_list = links; common_father->getRouteAndLatency(src, dst, &route, latency); return; } /* Not in the same AS, no bypass. We'll have to find our path between the ASes recursively*/ - route.link_list = xbt_dynar_new(sizeof(Link*), NULL); + route.link_list = new std::vector(); common_father->getRouteAndLatency(src_father->netcard_, dst_father->netcard_, &route, latency); xbt_assert((route.gw_src != NULL) && (route.gw_dst != NULL), @@ -503,7 +496,8 @@ static void _get_route_and_latency(simgrid::surf::NetCard *src, simgrid::surf::N /* If source gateway is not our source, we have to recursively find our way up to this point */ if (src != route.gw_src) _get_route_and_latency(src, route.gw_src, links, latency); - xbt_dynar_merge(links, &route.link_list); + for (auto link: *route.link_list) + links->push_back(link); /* If dest gateway is not our destination, we have to recursively find our way from this point */ if (route.gw_dst != dst) @@ -528,13 +522,9 @@ namespace surf { * walk through the routing components tree and find a route between hosts * by calling each "get_route" function in each routing component. */ -void RoutingPlatf::getRouteAndLatency(NetCard *src, NetCard *dst, xbt_dynar_t* route, double *latency) +void RoutingPlatf::getRouteAndLatency(NetCard *src, NetCard *dst, std::vector * route, double *latency) { XBT_DEBUG("getRouteAndLatency from %s to %s", src->name(), dst->name()); - if (NULL == *route) { - xbt_dynar_reset(routing_platf->lastRoute_); - *route = routing_platf->lastRoute_; - } _get_route_and_latency(src, dst, route, latency); } @@ -568,7 +558,7 @@ xbt_dynar_t RoutingPlatf::getOneLinkRoutes(){ } /** @brief create the root AS */ -void routing_model_create( void *loopback) +void routing_model_create(Link *loopback) { routing_platf = new simgrid::surf::RoutingPlatf(loopback); } @@ -908,7 +898,7 @@ void routing_exit(void) { namespace simgrid { namespace surf { - RoutingPlatf::RoutingPlatf(void *loopback) + RoutingPlatf::RoutingPlatf(Link *loopback) : loopback_(loopback) { } diff --git a/src/surf/surf_routing.hpp b/src/surf/surf_routing.hpp index c3b614bdd8..07afc8d76e 100644 --- a/src/surf/surf_routing.hpp +++ b/src/surf/surf_routing.hpp @@ -18,7 +18,7 @@ #include SG_BEGIN_DECL() -XBT_PUBLIC(void) routing_model_create( void *loopback); +XBT_PUBLIC(void) routing_model_create(Link *loopback); XBT_PRIVATE xbt_node_t new_xbt_graph_node (xbt_graph_t graph, const char *name, xbt_dict_t nodes); XBT_PRIVATE xbt_edge_t new_xbt_graph_edge (xbt_graph_t graph, xbt_node_t s, xbt_node_t d, xbt_dict_t edges); SG_END_DECL() @@ -47,12 +47,13 @@ public: virtual void setId(int id)=0; virtual char *name()=0; virtual As *containingAS()=0; // This is the AS in which I am - virtual e_surf_network_element_type_t getRcType()=0; + virtual bool isAS()=0; + virtual bool isHost()=0; + virtual bool isRouter()=0; }; /** @ingroup SURF_routing_interface * @brief Network Autonomous System (AS) - * @details [TODO] */ class As { public: @@ -126,7 +127,11 @@ public: void setId(int id) override {id_ = id;} char *name() override {return name_;} As *containingAS() override {return containingAS_;} - e_surf_network_element_type_t getRcType() override {return componentType_;} + + bool isAS() override {return componentType_ == SURF_NETWORK_ELEMENT_AS;} + bool isHost() override {return componentType_ == SURF_NETWORK_ELEMENT_HOST;} + bool isRouter() override {return componentType_ == SURF_NETWORK_ELEMENT_ROUTER;} + private: int id_ = -1; char *name_; @@ -151,13 +156,13 @@ public: */ XBT_PUBLIC_CLASS RoutingPlatf { public: - RoutingPlatf(void *loopback); + RoutingPlatf(Link *loopback); ~RoutingPlatf(); As *root_ = nullptr; - void *loopback_; + Link *loopback_; xbt_dynar_t lastRoute_ = xbt_dynar_new(sizeof(Link*),NULL); xbt_dynar_t getOneLinkRoutes(void); - void getRouteAndLatency(NetCard *src, NetCard *dst, xbt_dynar_t * links, double *latency); + void getRouteAndLatency(NetCard *src, NetCard *dst, std::vector * links, double *latency); }; /************* diff --git a/src/surf/surf_routing_RoutedGraph.cpp b/src/surf/surf_routing_RoutedGraph.cpp index 6af5f560a9..5c00da327b 100644 --- a/src/surf/surf_routing_RoutedGraph.cpp +++ b/src/surf/surf_routing_RoutedGraph.cpp @@ -23,7 +23,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_routing_generic, surf_route, "Generic imple void routing_route_free(sg_platf_route_cbarg_t route) { if (route) { - xbt_dynar_free(&route->link_list); + delete route->link_list; xbt_free(route); } } @@ -54,8 +54,7 @@ static const char *instr_node_name(xbt_node_t node) return str; } -xbt_node_t new_xbt_graph_node(xbt_graph_t graph, const char *name, - xbt_dict_t nodes) +xbt_node_t new_xbt_graph_node(xbt_graph_t graph, const char *name, xbt_dict_t nodes) { xbt_node_t ret = (xbt_node_t) xbt_dict_get_or_null(nodes, name); if (ret) @@ -66,11 +65,8 @@ xbt_node_t new_xbt_graph_node(xbt_graph_t graph, const char *name, return ret; } -xbt_edge_t new_xbt_graph_edge(xbt_graph_t graph, xbt_node_t s, xbt_node_t d, - xbt_dict_t edges) +xbt_edge_t new_xbt_graph_edge(xbt_graph_t graph, xbt_node_t s, xbt_node_t d, xbt_dict_t edges) { - xbt_edge_t ret; - const char *sn = instr_node_name(s); const char *dn = instr_node_name(d); int len = strlen(sn) + strlen(dn) + 1; @@ -78,7 +74,7 @@ xbt_edge_t new_xbt_graph_edge(xbt_graph_t graph, xbt_node_t s, xbt_node_t d, snprintf(name, len, "%s%s", sn, dn); - ret = (xbt_edge_t) xbt_dict_get_or_null(edges, name); + xbt_edge_t ret = (xbt_edge_t) xbt_dict_get_or_null(edges, name); if (ret == NULL) { snprintf(name, len, "%s%s", dn, sn); ret = (xbt_edge_t) xbt_dict_get_or_null(edges, name); @@ -111,15 +107,12 @@ void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edg xbt_dynar_get_as(vertices_, dst, NetCard*); sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1); - route->link_list = xbt_dynar_new(sizeof(Link*), NULL); + route->link_list = new std::vector(); getRouteAndLatency(my_src, my_dst, route, NULL); XBT_DEBUG ("get_route_and_latency %s -> %s", my_src->name(), my_dst->name()); - unsigned int cpt; - void *link; - xbt_node_t current, previous; const char *previous_name, *current_name; @@ -131,9 +124,8 @@ void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edg previous_name = my_src->name(); } - xbt_dynar_foreach(route->link_list, cpt, link) { - const char *link_name = static_cast( - link)->getName(); + for (auto link: *route->link_list) { + const char *link_name = link->getName(); current = new_xbt_graph_node(graph, link_name, nodes); current_name = link_name; new_xbt_graph_edge(graph, previous, current, edges); @@ -152,7 +144,7 @@ void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edg new_xbt_graph_edge(graph, previous, current, edges); XBT_DEBUG (" %s -> %s", previous_name, current_name); - xbt_dynar_free (&(route->link_list)); + delete route->link_list; xbt_free (route); } } @@ -163,14 +155,13 @@ void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edg /* ************************* GENERIC AUX FUNCTIONS ************************** */ /* change a route containing link names into a route containing link entities */ sg_platf_route_cbarg_t AsRoutedGraph::newExtendedRoute(e_surf_routing_hierarchy_t hierarchy, - sg_platf_route_cbarg_t routearg, int change_order) { + sg_platf_route_cbarg_t routearg, int change_order) +{ sg_platf_route_cbarg_t result; - char *link_name; - unsigned int cpt; result = xbt_new0(s_sg_platf_route_cbarg_t, 1); - result->link_list = xbt_dynar_new(sizeof(Link*), NULL); + result->link_list = new std::vector(); xbt_assert(hierarchy == SURF_ROUTING_BASE || hierarchy == SURF_ROUTING_RECURSIVE, @@ -185,16 +176,11 @@ sg_platf_route_cbarg_t AsRoutedGraph::newExtendedRoute(e_surf_routing_hierarchy_ result->gw_dst = routearg->gw_dst; } - xbt_dynar_foreach(routearg->link_list, cpt, link_name) { - - Link *link = Link::byName(link_name); - if (link) { - if (change_order) - xbt_dynar_push(result->link_list, &link); - else - xbt_dynar_unshift(result->link_list, &link); - } else - THROWF(mismatch_error, 0, "Link '%s' not found", link_name); + for (auto link : *routearg->link_list) { + if (change_order) + result->link_list->push_back(link); + else + result->link_list->insert(result->link_list->begin(), link); } return result; @@ -225,21 +211,17 @@ void AsRoutedGraph::addRouteCheckParams(sg_platf_route_cbarg_t route) { XBT_DEBUG("Load Route from \"%s\" to \"%s\"", srcName, dstName); xbt_assert(src, "Cannot add a route from %s to %s: %s does not exist.", srcName, dstName, srcName); xbt_assert(dst, "Cannot add a route from %s to %s: %s does not exist.", srcName, dstName, dstName); - xbt_assert(!xbt_dynar_is_empty(route->link_list), "Empty route (between %s and %s) forbidden.", srcName, dstName); - xbt_assert(src->getRcType()==SURF_NETWORK_ELEMENT_HOST || src->getRcType()==SURF_NETWORK_ELEMENT_ROUTER, - "When defining a route, src must be an host or a router but '%s' is not. Did you meant to have an ASroute?", srcName); - xbt_assert(dst->getRcType()==SURF_NETWORK_ELEMENT_HOST || dst->getRcType()==SURF_NETWORK_ELEMENT_ROUTER, - "When defining a route, dst must be an host or a router but '%s' is not. Did you meant to have an ASroute?", dstName); + xbt_assert(! route->link_list->empty(), "Empty route (between %s and %s) forbidden.", srcName, dstName); + xbt_assert(! src->isAS(), "When defining a route, src cannot be an AS such as '%s'. Did you meant to have an ASroute?", srcName); + xbt_assert(! dst->isAS(), "When defining a route, dst cannot be an AS such as '%s'. Did you meant to have an ASroute?", dstName); } else { XBT_DEBUG("Load ASroute from %s@%s to %s@%s", srcName, route->gw_src->name(), dstName, route->gw_dst->name()); - xbt_assert(src->getRcType()==SURF_NETWORK_ELEMENT_AS, - "When defining an ASroute, src must be an AS but '%s' is not", srcName); - xbt_assert(dst->getRcType()==SURF_NETWORK_ELEMENT_AS, - "When defining an ASroute, dst must be an AS but '%s' is not", dstName); + xbt_assert(src->isAS(), "When defining an ASroute, src must be an AS but '%s' is not", srcName); + xbt_assert(dst->isAS(), "When defining an ASroute, dst must be an AS but '%s' is not", dstName); - xbt_assert(route->gw_src->getRcType()==SURF_NETWORK_ELEMENT_HOST || route->gw_src->getRcType()==SURF_NETWORK_ELEMENT_ROUTER, + xbt_assert(route->gw_src->isHost() || route->gw_src->isRouter(), "When defining an ASroute, gw_src must be an host or a router but '%s' is not.", srcName); - xbt_assert(route->gw_dst->getRcType()==SURF_NETWORK_ELEMENT_HOST || route->gw_dst->getRcType()==SURF_NETWORK_ELEMENT_ROUTER, + xbt_assert(route->gw_dst->isHost() || route->gw_dst->isRouter(), "When defining an ASroute, gw_dst must be an host or a router but '%s' is not.", dstName); xbt_assert(route->gw_src != route->gw_dst, "Cannot define an ASroute from '%s' to itself", route->gw_src->name()); @@ -248,7 +230,7 @@ void AsRoutedGraph::addRouteCheckParams(sg_platf_route_cbarg_t route) { srcName,route->gw_src->name(), dstName,route->gw_dst->name(), srcName); xbt_assert(dst, "Cannot add a route from %s@%s to %s@%s: %s does not exist.", srcName,route->gw_src->name(), dstName,route->gw_dst->name(), dstName); - xbt_assert(!xbt_dynar_is_empty(route->link_list), "Empty route (between %s@%s and %s@%s) forbidden.", + xbt_assert(! route->link_list->empty(), "Empty route (between %s@%s and %s@%s) forbidden.", srcName,route->gw_src->name(), dstName,route->gw_dst->name()); } } diff --git a/src/surf/surf_routing_cluster.cpp b/src/surf/surf_routing_cluster.cpp index be5d60692b..3cdfdb027e 100644 --- a/src/surf/surf_routing_cluster.cpp +++ b/src/surf/surf_routing_cluster.cpp @@ -24,49 +24,48 @@ void AsCluster::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb XBT_VERB("cluster_get_route_and_latency from '%s'[%d] to '%s'[%d]", src->name(), src->id(), dst->name(), dst->id()); - if (src->getRcType() != SURF_NETWORK_ELEMENT_ROUTER) { // No specific link for router + if (! src->isRouter()) { // No specific link for router if((src->id() == dst->id()) && has_loopback_ ){ info = xbt_dynar_get_as(upDownLinks, src->id() * nb_links_per_node_, s_surf_parsing_link_up_down_t); - xbt_dynar_push_as(route->link_list, void *, info.link_up); + route->link_list->push_back(info.link_up); if (lat) - *lat += static_cast(info.link_up)->getLatency(); + *lat += info.link_up->getLatency(); return; } if (has_limiter_){ // limiter for sender info = xbt_dynar_get_as(upDownLinks, src->id() * nb_links_per_node_ + has_loopback_, s_surf_parsing_link_up_down_t); - xbt_dynar_push_as(route->link_list, void *, info.link_up); + route->link_list->push_back((Link*)info.link_up); } info = xbt_dynar_get_as(upDownLinks, src->id() * nb_links_per_node_ + has_loopback_ + has_limiter_, s_surf_parsing_link_up_down_t); if (info.link_up) { // link up - xbt_dynar_push_as(route->link_list, void *, info.link_up); + route->link_list->push_back(info.link_up); if (lat) - *lat += static_cast(info.link_up)->getLatency(); + *lat += info.link_up->getLatency(); } } if (backbone_) { - xbt_dynar_push_as(route->link_list, void *, - static_cast(backbone_)); + route->link_list->push_back(backbone_); if (lat) *lat += backbone_->getLatency(); } - if (dst->getRcType() != SURF_NETWORK_ELEMENT_ROUTER) { // No specific link for router + if (! dst->isRouter()) { // No specific link for router info = xbt_dynar_get_as(upDownLinks, dst->id() * nb_links_per_node_ + has_loopback_ + has_limiter_, s_surf_parsing_link_up_down_t); if (info.link_down) { // link down - xbt_dynar_push_as(route->link_list, void *, info.link_down); + route->link_list->push_back(info.link_down); if (lat) - *lat += static_cast(info.link_down)->getLatency(); + *lat += info.link_down->getLatency(); } if (has_limiter_){ // limiter for receiver info = xbt_dynar_get_as(upDownLinks, dst->id() * nb_links_per_node_ + has_loopback_, s_surf_parsing_link_up_down_t); - xbt_dynar_push_as(route->link_list, void *, info.link_up); + route->link_list->push_back(info.link_up); } } } @@ -96,7 +95,7 @@ void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) for (isrc = 0; isrc < table_size; isrc++) { src = xbt_dynar_get_as(vertices_, isrc, NetCard*); - if (src->getRcType() != SURF_NETWORK_ELEMENT_ROUTER) { + if (! src->isRouter()) { previous = new_xbt_graph_node(graph, src->name(), nodes); info = xbt_dynar_get_as(upDownLinks, src->id(), s_surf_parsing_link_up_down_t); diff --git a/src/surf/surf_routing_cluster_fat_tree.cpp b/src/surf/surf_routing_cluster_fat_tree.cpp index 93ba4eba94..579e1e3475 100644 --- a/src/surf/surf_routing_cluster_fat_tree.cpp +++ b/src/surf/surf_routing_cluster_fat_tree.cpp @@ -66,7 +66,8 @@ void AsClusterFatTree::getRouteAndLatency(NetCard *src, std::map::const_iterator tempIter; -if (dst->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || src->getRcType() == SURF_NETWORK_ELEMENT_ROUTER) return; + if (dst->isRouter() || src->isRouter()) + return; /* Let's find the source and the destination in our internal structure */ tempIter = this->computeNodes_.find(src->id()); @@ -92,7 +93,7 @@ if (dst->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || src->getRcType() == SURF_ /* In case destination is the source, and there is a loopback, let's get through it instead of going up to a switch*/ if(source->id == destination->id && this->has_loopback_) { - xbt_dynar_push_as(into->link_list, void*, source->loopback); + into->link_list->push_back(source->loopback); if(latency) { *latency += source->loopback->getLatency(); } @@ -111,14 +112,14 @@ if (dst->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || src->getRcType() == SURF_ } k = this->upperLevelNodesNumber_[currentNode->level]; d = d % k; - xbt_dynar_push_as(into->link_list, void*,currentNode->parents[d]->upLink); + into->link_list->push_back(currentNode->parents[d]->upLink); if(latency) { *latency += currentNode->parents[d]->upLink->getLatency(); } if (this->has_limiter_) { - xbt_dynar_push_as(into->link_list, void*,currentNode->limiterLink); + into->link_list->push_back(currentNode->limiterLink); } currentNode = currentNode->parents[d]->upNode; } @@ -132,13 +133,13 @@ if (dst->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || src->getRcType() == SURF_ for(unsigned int i = 0 ; i < currentNode->children.size() ; i++) { if(i % this->lowerLevelNodesNumber_[currentNode->level - 1] == destination->label[currentNode->level - 1]) { - xbt_dynar_push_as(into->link_list, void*,currentNode->children[i]->downLink); + into->link_list->push_back(currentNode->children[i]->downLink); if(latency) { *latency += currentNode->children[i]->downLink->getLatency(); } currentNode = currentNode->children[i]->downNode; if (this->has_limiter_) { - xbt_dynar_push_as(into->link_list, void*,currentNode->limiterLink); + into->link_list->push_back(currentNode->limiterLink); } XBT_DEBUG("%d(%u,%u) is accessible through %d(%u,%u)", destination->id, destination->level, destination->position, currentNode->id, diff --git a/src/surf/surf_routing_cluster_torus.cpp b/src/surf/surf_routing_cluster_torus.cpp index 8cd9b740aa..294c12718a 100644 --- a/src/surf/surf_routing_cluster_torus.cpp +++ b/src/surf/surf_routing_cluster_torus.cpp @@ -115,16 +115,15 @@ namespace simgrid { XBT_VERB("torus_get_route_and_latency from '%s'[%d] to '%s'[%d]", src->name(), src->id(), dst->name(), dst->id()); - if (dst->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || src->getRcType() == SURF_NETWORK_ELEMENT_ROUTER) + if (dst->isRouter() || src->isRouter()) return; if ((src->id() == dst->id()) && has_loopback_) { - s_surf_parsing_link_up_down_t info = - xbt_dynar_get_as(upDownLinks, src->id() * nb_links_per_node_, s_surf_parsing_link_up_down_t); - xbt_dynar_push_as(route->link_list, void *, info.link_up); + s_surf_parsing_link_up_down_t info = xbt_dynar_get_as(upDownLinks, src->id() * nb_links_per_node_, s_surf_parsing_link_up_down_t); + route->link_list->push_back(info.link_up); if (lat) - *lat += static_cast < Link * >(info.link_up)->getLatency(); + *lat += info.link_up->getLatency(); return; } @@ -203,21 +202,19 @@ namespace simgrid { if (has_limiter_) { // limiter for sender info = xbt_dynar_get_as(upDownLinks, nodeOffset + has_loopback_, s_surf_parsing_link_up_down_t); - xbt_dynar_push_as(route->link_list, void *, info.link_up); + route->link_list->push_back(info.link_up); } info = xbt_dynar_get_as(upDownLinks, linkOffset, s_surf_parsing_link_up_down_t); if (use_lnk_up == false) { - xbt_dynar_push_as(route->link_list, void *, info.link_down); - + route->link_list->push_back(info.link_down); if (lat) - *lat += static_cast < Link * >(info.link_down)->getLatency(); + *lat += info.link_down->getLatency(); } else { - xbt_dynar_push_as(route->link_list, void *, info.link_up); - + route->link_list->push_back(info.link_up); if (lat) - *lat += static_cast < Link * >(info.link_up)->getLatency(); + *lat += info.link_up->getLatency(); } current_node = next_node; next_node = 0; @@ -225,8 +222,6 @@ namespace simgrid { free(myCoords); free(targetCoords); - - return; } diff --git a/src/surf/surf_routing_dijkstra.cpp b/src/surf/surf_routing_dijkstra.cpp index 0d2108d4d7..fcaac996a2 100644 --- a/src/surf/surf_routing_dijkstra.cpp +++ b/src/surf/surf_routing_dijkstra.cpp @@ -30,7 +30,7 @@ static void graph_edge_data_free(void *e) // FIXME: useless code duplication { sg_platf_route_cbarg_t e_route = (sg_platf_route_cbarg_t) e; if (e_route) { - xbt_dynar_free(&(e_route->link_list)); + delete e_route->link_list; xbt_free(e_route); } } @@ -65,8 +65,8 @@ void AsDijkstra::Seal() if (!found) { sg_platf_route_cbarg_t e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1); - e_route->link_list = xbt_dynar_new(sizeof(Link*), NULL); - xbt_dynar_push(e_route->link_list, &routing_platf->loopback_); + e_route->link_list = new std::vector(); + e_route->link_list->push_back(routing_platf->loopback_); xbt_graph_new_edge(routeGraph_, node, node, e_route); } } @@ -142,18 +142,18 @@ xbt_dynar_t AsDijkstra::getOneLinkRoutes() { xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f); sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1); - route->link_list = xbt_dynar_new(sizeof(Link*),NULL); + route->link_list = new std::vector(); int table_size = (int)xbt_dynar_length(vertices_); for(int src=0; src < table_size; src++) { for(int dst=0; dst< table_size; dst++) { - xbt_dynar_reset(route->link_list); + route->link_list->clear(); NetCard *src_elm = xbt_dynar_get_as(vertices_, src, NetCard*); NetCard *dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*); this->getRouteAndLatency(src_elm, dst_elm,route, NULL); - if (xbt_dynar_length(route->link_list) == 1) { - void *link = *(void **) xbt_dynar_get_ptr(route->link_list, 0); + if (route->link_list->size() == 1) { + Link *link = route->link_list->at(0); Onelink *onelink; if (hierarchy_ == SURF_ROUTING_BASE) onelink = new Onelink(link, src_elm, dst_elm); @@ -177,8 +177,6 @@ void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_c int *pred_arr = NULL; sg_platf_route_cbarg_t e_route; int size = 0; - unsigned int cpt; - void *link; xbt_dynar_t nodes = xbt_graph_get_nodes(routeGraph_); /* Use the graph_node id mapping set to quickly find the nodes */ @@ -200,8 +198,8 @@ void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_c e_route = (sg_platf_route_cbarg_t) xbt_graph_edge_get_data(edge); - xbt_dynar_foreach(e_route->link_list, cpt, link) { - xbt_dynar_unshift(route->link_list, &link); + for (auto link: *e_route->link_list) { + route->link_list->insert(route->link_list->begin(), link); if (lat) *lat += static_cast(link)->getLatency(); } @@ -210,8 +208,7 @@ void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_c route_cache_element_t elm = NULL; if (routeCache_) { /* cache mode */ - elm = (route_cache_element_t) - xbt_dict_get_or_null_ext(routeCache_, (char *) (&src_id), sizeof(int)); + elm = (route_cache_element_t) xbt_dict_get_or_null_ext(routeCache_, (char *) (&src_id), sizeof(int)); } if (elm) { /* cached mode and cache hit */ @@ -252,7 +249,7 @@ void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_c graph_node_data_t data = (graph_node_data_t) xbt_graph_node_get_data(u_node); int u_id = data->graph_id; sg_platf_route_cbarg_t tmp_e_route = (sg_platf_route_cbarg_t) xbt_graph_edge_get_data(edge); - int cost_v_u = (tmp_e_route->link_list)->used; /* count of links, old model assume 1 */ + int cost_v_u = tmp_e_route->link_list->size(); /* count of links, old model assume 1 */ if (cost_v_u + cost_arr[*v_id] < cost_arr[u_id]) { pred_arr[u_id] = *v_id; @@ -293,22 +290,20 @@ void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_c first_gw = gw_dst; if (hierarchy_ == SURF_ROUTING_RECURSIVE && v != dst_node_id && strcmp(gw_dst->name(), prev_gw_src->name())) { - xbt_dynar_t e_route_as_to_as=NULL; - - routing_platf->getRouteAndLatency(gw_dst_net_elm, prev_gw_src_net_elm, &e_route_as_to_as, NULL); - if (edge == NULL) - THROWF(arg_error,0,"No route from '%s' to '%s'", src->name(), dst->name()); - int pos = 0; - xbt_dynar_foreach(e_route_as_to_as, cpt, link) { - xbt_dynar_insert_at(route->link_list, pos, &link); + std::vector *e_route_as_to_as = new std::vector(); + + routing_platf->getRouteAndLatency(gw_dst_net_elm, prev_gw_src_net_elm, e_route_as_to_as, NULL); + auto pos = route->link_list->begin(); + for (auto link : *e_route_as_to_as) { + route->link_list->insert(pos, link); if (lat) - *lat += static_cast(link)->getLatency(); + *lat += link->getLatency(); pos++; } } - xbt_dynar_foreach(e_route->link_list, cpt, link) { - xbt_dynar_unshift(route->link_list, &link); + for (auto link: *e_route->link_list) { + route->link_list->insert(route->link_list->begin(), link); if (lat) *lat += static_cast(link)->getLatency(); } @@ -392,7 +387,7 @@ void AsDijkstra::addRoute(sg_platf_route_cbarg_t route) sg_platf_route_cbarg_t link_route_back = newExtendedRoute(hierarchy_, route, 0); newRoute(dst->id(), src->id(), link_route_back); } - xbt_dynar_free(&route->link_list); + delete route->link_list; } } diff --git a/src/surf/surf_routing_floyd.cpp b/src/surf/surf_routing_floyd.cpp index 2f297fd65a..c902ac3844 100644 --- a/src/surf/surf_routing_floyd.cpp +++ b/src/surf/surf_routing_floyd.cpp @@ -43,21 +43,19 @@ AsFloyd::~AsFloyd(){ xbt_dynar_t AsFloyd::getOneLinkRoutes() { xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f); - sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1); - route->link_list = xbt_dynar_new(sizeof(Link*), NULL); + sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1); + route->link_list = new std::vector(); - int src,dst; - sg_netcard_t src_elm, dst_elm; int table_size = xbt_dynar_length(vertices_); - for(src=0; src < table_size; src++) { - for(dst=0; dst< table_size; dst++) { - xbt_dynar_reset(route->link_list); - src_elm = xbt_dynar_get_as(vertices_, src, NetCard*); - dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*); + for(int src=0; src < table_size; src++) { + for(int dst=0; dst< table_size; dst++) { + route->link_list->clear(); + NetCard *src_elm = xbt_dynar_get_as(vertices_, src, NetCard*); + NetCard *dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*); this->getRouteAndLatency(src_elm, dst_elm, route, NULL); - if (xbt_dynar_length(route->link_list) == 1) { - void *link = *(void **) xbt_dynar_get_ptr(route->link_list, 0); + if (route->link_list->size() == 1) { + void *link = route->link_list->at(0); Onelink *onelink; if (hierarchy_ == SURF_ROUTING_BASE) onelink = new Onelink(link, src_elm, dst_elm); @@ -73,7 +71,7 @@ xbt_dynar_t AsFloyd::getOneLinkRoutes() return ret; } -void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t res, double *lat) +void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat) { size_t table_size = xbt_dynar_length(vertices_); @@ -93,26 +91,22 @@ void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbar } while (cur != src->id()); if (hierarchy_ == SURF_ROUTING_RECURSIVE) { - res->gw_src = xbt_dynar_getlast_as(route_stack, sg_platf_route_cbarg_t)->gw_src; - res->gw_dst = xbt_dynar_getfirst_as(route_stack, sg_platf_route_cbarg_t)->gw_dst; + route->gw_src = xbt_dynar_getlast_as(route_stack, sg_platf_route_cbarg_t)->gw_src; + route->gw_dst = xbt_dynar_getfirst_as(route_stack, sg_platf_route_cbarg_t)->gw_dst; } sg_netcard_t prev_dst_gw = NULL; while (!xbt_dynar_is_empty(route_stack)) { sg_platf_route_cbarg_t e_route = xbt_dynar_pop_as(route_stack, sg_platf_route_cbarg_t); - xbt_dynar_t links; - void *link; - unsigned int cpt; if (hierarchy_ == SURF_ROUTING_RECURSIVE && prev_dst_gw != NULL && strcmp(prev_dst_gw->name(), e_route->gw_src->name())) { - routing_platf->getRouteAndLatency(prev_dst_gw, e_route->gw_src, &res->link_list, lat); + routing_platf->getRouteAndLatency(prev_dst_gw, e_route->gw_src, route->link_list, lat); } - links = e_route->link_list; - xbt_dynar_foreach(links, cpt, link) { - xbt_dynar_push_as(res->link_list, Link*, (Link*)link); + for (auto link: *e_route->link_list) { + route->link_list->push_back(link); if (lat) - *lat += static_cast(link)->getLatency(); + *lat += link->getLatency(); } prev_dst_gw = e_route->gw_dst; @@ -120,10 +114,6 @@ void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbar xbt_dynar_free(&route_stack); } -static int floyd_pointer_resource_cmp(const void *a, const void *b) { - return a != b; -} - void AsFloyd::addRoute(sg_platf_route_cbarg_t route) { /* set the size of table routing */ @@ -160,53 +150,35 @@ void AsFloyd::addRoute(sg_platf_route_cbarg_t route) TO_FLOYD_LINK(src->id(), dst->id()) = newExtendedRoute(hierarchy_, route, 1); TO_FLOYD_PRED(src->id(), dst->id()) = src->id(); - TO_FLOYD_COST(src->id(), dst->id()) = ((TO_FLOYD_LINK(src->id(), dst->id()))->link_list)->used; + TO_FLOYD_COST(src->id(), dst->id()) = (TO_FLOYD_LINK(src->id(), dst->id()))->link_list->size(); if (route->symmetrical == TRUE) { - if(TO_FLOYD_LINK(dst->id(), src->id())) - { - if(!route->gw_dst && !route->gw_src) - XBT_DEBUG("See Route from \"%s\" to \"%s\"", dst->name(), src->name()); - else - XBT_DEBUG("See ASroute from \"%s(%s)\" to \"%s(%s)\"", dst->name(), route->gw_src->name(), src->name(), route->gw_dst->name()); - - char * link_name; - xbt_dynar_t link_route_to_test = xbt_dynar_new(sizeof(Link*), NULL); - for(int i=xbt_dynar_length(route->link_list) ;i>0 ;i--) { - link_name = xbt_dynar_get_as(route->link_list,i-1,char *); - void *link = Link::byName(link_name); - xbt_assert(link,"Link : '%s' doesn't exists.",link_name); - xbt_dynar_push(link_route_to_test,&link); - } - xbt_assert(!xbt_dynar_compare( - TO_FLOYD_LINK(dst->id(), src->id())->link_list, - link_route_to_test, - (int_f_cpvoid_cpvoid_t) floyd_pointer_resource_cmp), - "The route between \"%s\" and \"%s\" already exists", src->name(),dst->name()); + if (route->gw_dst) // AS route (to adapt the error message, if any) + xbt_assert(nullptr == TO_FLOYD_LINK(dst->id(), src->id()), + "The route between %s@%s and %s@%s already exists. You should not declare the reverse path as symmetrical.", + dst->name(),route->gw_dst->name(),src->name(),route->gw_src->name()); + else + xbt_assert(nullptr == TO_FLOYD_LINK(dst->id(), src->id()), + "The route between %s and %s already exists. You should not declare the reverse path as symmetrical.", + dst->name(),src->name()); + + if(route->gw_dst && route->gw_src) { + NetCard* gw_tmp = route->gw_src; + route->gw_src = route->gw_dst; + route->gw_dst = gw_tmp; } - else { - if(route->gw_dst && route->gw_src) { - NetCard* gw_tmp = route->gw_src; - route->gw_src = route->gw_dst; - route->gw_dst = gw_tmp; - } + if(!route->gw_src && !route->gw_dst) + XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dst->name(), src->name()); + else + XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", dst->name(), + route->gw_src->name(), src->name(), route->gw_dst->name()); - if(!route->gw_src && !route->gw_dst) - XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dst->name(), src->name()); - else - XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", dst->name(), - route->gw_src->name(), src->name(), route->gw_dst->name()); - - TO_FLOYD_LINK(dst->id(), src->id()) = - newExtendedRoute(hierarchy_, route, 0); - TO_FLOYD_PRED(dst->id(), src->id()) = dst->id(); - TO_FLOYD_COST(dst->id(), src->id()) = - ((TO_FLOYD_LINK(dst->id(), src->id()))->link_list)->used; /* count of links, old model assume 1 */ - } + TO_FLOYD_LINK(dst->id(), src->id()) = newExtendedRoute(hierarchy_, route, 0); + TO_FLOYD_PRED(dst->id(), src->id()) = dst->id(); + TO_FLOYD_COST(dst->id(), src->id()) = (TO_FLOYD_LINK(dst->id(), src->id()))->link_list->size(); /* count of links, old model assume 1 */ } - xbt_dynar_free(&route->link_list); } void AsFloyd::Seal(){ @@ -237,8 +209,8 @@ void AsFloyd::Seal(){ e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1); e_route->gw_src = NULL; e_route->gw_dst = NULL; - e_route->link_list = xbt_dynar_new(sizeof(Link*), NULL); - xbt_dynar_push(e_route->link_list, &routing_platf->loopback_); + e_route->link_list = new std::vector(); + e_route->link_list->push_back(routing_platf->loopback_); TO_FLOYD_LINK(i, i) = e_route; TO_FLOYD_PRED(i, i) = i; TO_FLOYD_COST(i, i) = 1; diff --git a/src/surf/surf_routing_full.cpp b/src/surf/surf_routing_full.cpp index 9a000f4731..7d52469d64 100644 --- a/src/surf/surf_routing_full.cpp +++ b/src/surf/surf_routing_full.cpp @@ -37,8 +37,8 @@ void AsFull::Seal() { e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1); e_route->gw_src = NULL; e_route->gw_dst = NULL; - e_route->link_list = xbt_dynar_new(sizeof(Link*), NULL); - xbt_dynar_push(e_route->link_list, &routing_platf->loopback_); + e_route->link_list = new std::vector(); + e_route->link_list->push_back(routing_platf->loopback_); TO_ROUTE_FULL(i, i) = e_route; } } @@ -53,7 +53,7 @@ AsFull::~AsFull(){ for (i = 0; i < table_size; i++) for (j = 0; j < table_size; j++) { if (TO_ROUTE_FULL(i,j)){ - xbt_dynar_free(&TO_ROUTE_FULL(i,j)->link_list); + delete TO_ROUTE_FULL(i,j)->link_list; xbt_free(TO_ROUTE_FULL(i,j)); } } @@ -72,8 +72,8 @@ xbt_dynar_t AsFull::getOneLinkRoutes() for(dst=0; dst< table_size; dst++) { sg_platf_route_cbarg_t route = TO_ROUTE_FULL(src,dst); if (route) { - if (xbt_dynar_length(route->link_list) == 1) { - void *link = *(void **) xbt_dynar_get_ptr(route->link_list, 0); + if (route->link_list->size() == 1) { + Link *link = route->link_list->at(0); Onelink *onelink; if (hierarchy_ == SURF_ROUTING_BASE) { NetCard *tmp_src = xbt_dynar_get_as(vertices_, src, sg_netcard_t); @@ -108,27 +108,20 @@ void AsFull::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg size_t table_size = xbt_dynar_length(vertices_); sg_platf_route_cbarg_t e_route = NULL; - void *link; - unsigned int cpt = 0; e_route = TO_ROUTE_FULL(src->id(), dst->id()); if (e_route) { res->gw_src = e_route->gw_src; res->gw_dst = e_route->gw_dst; - xbt_dynar_foreach(e_route->link_list, cpt, link) { - xbt_dynar_push(res->link_list, &link); + for (auto link : *e_route->link_list) { + res->link_list->push_back(link); if (lat) *lat += static_cast(link)->getLatency(); } } } -static int full_pointer_resource_cmp(const void *a, const void *b) -{ - return a != b; -} - void AsFull::addRoute(sg_platf_route_cbarg_t route) { const char *src = route->src; @@ -154,40 +147,25 @@ void AsFull::addRoute(sg_platf_route_cbarg_t route) /* Add the route to the base */ TO_ROUTE_FULL(src_net_elm->id(), dst_net_elm->id()) = newExtendedRoute(hierarchy_, route, 1); - xbt_dynar_shrink(TO_ROUTE_FULL(src_net_elm->id(), dst_net_elm->id())->link_list, 0); + TO_ROUTE_FULL(src_net_elm->id(), dst_net_elm->id())->link_list->shrink_to_fit(); - if (route->symmetrical == TRUE) { + if (route->symmetrical == TRUE && src_net_elm != dst_net_elm) { if (route->gw_dst && route->gw_src) { NetCard* gw_tmp = route->gw_src; route->gw_src = route->gw_dst; route->gw_dst = gw_tmp; } - if (TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id())) { - char *link_name; - unsigned int i; - xbt_dynar_t link_route_to_test = xbt_dynar_new(sizeof(Link*), NULL); - for (i = xbt_dynar_length(route->link_list); i > 0; i--) { - link_name = xbt_dynar_get_as(route->link_list, i - 1, char *); - void *link = Link::byName(link_name); - xbt_assert(link, "Link : '%s' doesn't exists.", link_name); - xbt_dynar_push(link_route_to_test, &link); - } - xbt_assert(!xbt_dynar_compare(TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id())->link_list, - link_route_to_test, - full_pointer_resource_cmp), - "The route between \"%s\" and \"%s\" already exists", src, - dst); - } else { - if (!route->gw_dst && !route->gw_src) - XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dst, src); - else - XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", - dst, route->gw_src->name(), src, route->gw_dst->name()); - TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id()) = newExtendedRoute(hierarchy_, route, 0); - xbt_dynar_shrink(TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id())->link_list, 0); - } + if (route->gw_dst) // AS route (to adapt the error message, if any) + xbt_assert(nullptr == TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id()), + "The route between %s@%s and %s@%s already exists. You should not declare the reverse path as symmetrical.", + dst,route->gw_dst->name(),src,route->gw_src->name()); + else + xbt_assert(nullptr == TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id()), + "The route between %s and %s already exists. You should not declare the reverse path as symmetrical.", dst,src); + + TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id()) = newExtendedRoute(hierarchy_, route, 0); + TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id())->link_list->shrink_to_fit(); } - xbt_dynar_free(&route->link_list); } } diff --git a/src/surf/surf_routing_vivaldi.cpp b/src/surf/surf_routing_vivaldi.cpp index 377c13f3ab..278d195ff8 100644 --- a/src/surf/surf_routing_vivaldi.cpp +++ b/src/surf/surf_routing_vivaldi.cpp @@ -35,7 +35,7 @@ void AsVivaldi::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb XBT_DEBUG("vivaldi_get_route_and_latency from '%s'[%d] '%s'[%d]", src->name(), src->id(), dst->name(), dst->id()); - if(src->getRcType() == SURF_NETWORK_ELEMENT_AS) { + if(src->isAS()) { char *src_name = ROUTER_PEER(src->name()); char *dst_name = ROUTER_PEER(dst->name()); route->gw_src = (sg_netcard_t) xbt_lib_get_or_null(as_router_lib, src_name, ROUTING_ASR_LEVEL); @@ -48,13 +48,13 @@ void AsVivaldi::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb xbt_dynar_t src_ctn, dst_ctn; char *tmp_src_name, *tmp_dst_name; - if(src->getRcType() == SURF_NETWORK_ELEMENT_HOST){ + if(src->isHost()){ tmp_src_name = HOST_PEER(src->name()); if ((int)xbt_dynar_length(upDownLinks)>src->id()) { info = xbt_dynar_get_as(upDownLinks, src->id(), s_surf_parsing_link_up_down_t); if(info.link_up) { // link up - xbt_dynar_push_as(route->link_list, void*, info.link_up); + route->link_list->push_back(info.link_up); if (lat) *lat += static_cast(info.link_up)->getLatency(); } @@ -63,7 +63,7 @@ void AsVivaldi::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb if (src_ctn == nullptr) src_ctn = (xbt_dynar_t) simgrid::s4u::Host::by_name_or_create(src->name())->extension(COORD_HOST_LEVEL); } - else if(src->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || src->getRcType() == SURF_NETWORK_ELEMENT_AS){ + else if(src->isRouter() || src->isAS()){ tmp_src_name = ROUTER_PEER(src->name()); src_ctn = (xbt_dynar_t) xbt_lib_get_or_null(as_router_lib, tmp_src_name, COORD_ASR_LEVEL); } @@ -71,13 +71,13 @@ void AsVivaldi::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb THROW_IMPOSSIBLE; } - if(dst->getRcType() == SURF_NETWORK_ELEMENT_HOST){ + if(dst->isHost()){ tmp_dst_name = HOST_PEER(dst->name()); if ((int)xbt_dynar_length(upDownLinks)>dst->id()) { info = xbt_dynar_get_as(upDownLinks, dst->id(), s_surf_parsing_link_up_down_t); if(info.link_down) { // link down - xbt_dynar_push_as(route->link_list,void*,info.link_down); + route->link_list->push_back(info.link_down); if (lat) *lat += static_cast(info.link_down)->getLatency(); } @@ -88,7 +88,7 @@ void AsVivaldi::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb dst_ctn = (xbt_dynar_t) simgrid::s4u::Host::by_name_or_create(dst->name()) ->extension(COORD_HOST_LEVEL); } - else if(dst->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || dst->getRcType() == SURF_NETWORK_ELEMENT_AS){ + else if(dst->isRouter() || dst->isAS()){ tmp_dst_name = ROUTER_PEER(dst->name()); dst_ctn = (xbt_dynar_t) xbt_lib_get_or_null(as_router_lib, tmp_dst_name, COORD_ASR_LEVEL); } diff --git a/src/surf/xml/platf_private.hpp b/src/surf/xml/platf_private.hpp index 260e117c49..9e99d90ea7 100644 --- a/src/surf/xml/platf_private.hpp +++ b/src/surf/xml/platf_private.hpp @@ -105,7 +105,7 @@ typedef struct s_sg_platf_route_cbarg { const char *dst; sg_netcard_t gw_src; sg_netcard_t gw_dst; - xbt_dynar_t link_list; + std::vector *link_list; } s_sg_platf_route_cbarg_t; #define SG_PLATF_ROUTE_INITIALIZER {1,NULL,NULL,NULL,NULL,NULL} @@ -305,8 +305,8 @@ XBT_PRIVATE void sg_instr_AS_end(void); typedef struct s_surf_parsing_link_up_down *surf_parsing_link_up_down_t; typedef struct s_surf_parsing_link_up_down { - void* link_up; - void* link_down; + Link* link_up; + Link* link_down; } s_surf_parsing_link_up_down_t; diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index ea86273e04..9ba84302f7 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -14,6 +14,7 @@ #include "xbt/file.h" #include "xbt/dict.h" #include "src/surf/surf_private.h" +#include "src/surf/network_interface.hpp" #include "simgrid/sg_config.h" #include "simgrid/link.h" @@ -748,7 +749,15 @@ void ETag_surfxml_route(void){ route.dst = A_surfxml_route_dst; route.gw_src = NULL; route.gw_dst = NULL; - route.link_list = parsed_link_list; + route.link_list = new std::vector(); + + unsigned int cpt; + char *link_name; + xbt_dynar_foreach(parsed_link_list, cpt, link_name) { + simgrid::surf::Link *link = Link::byName(link_name); + route.link_list->push_back(link); + } + switch (A_surfxml_route_symmetrical) { case AU_surfxml_route_symmetrical: @@ -781,7 +790,14 @@ void ETag_surfxml_ASroute(void){ surf_parse_error("gw_dst=\"%s\" not found for ASroute from \"%s\" to \"%s\"", A_surfxml_ASroute_gw___dst, ASroute.src, ASroute.dst); - ASroute.link_list = parsed_link_list; + ASroute.link_list = new std::vector(); + + unsigned int cpt; + char *link_name; + xbt_dynar_foreach(parsed_link_list, cpt, link_name) { + simgrid::surf::Link *link = Link::byName(link_name); + ASroute.link_list->push_back(link); + } switch (A_surfxml_ASroute_symmetrical) { case AU_surfxml_ASroute_symmetrical: @@ -805,11 +821,18 @@ void ETag_surfxml_bypassRoute(void){ route.dst = A_surfxml_bypassRoute_dst; route.gw_src = NULL; route.gw_dst = NULL; - route.link_list = parsed_link_list; route.symmetrical = FALSE; + route.link_list = new std::vector(); - sg_platf_new_bypassRoute(&route); + unsigned int cpt; + char *link_name; + xbt_dynar_foreach(parsed_link_list, cpt, link_name) { + simgrid::surf::Link *link = Link::byName(link_name); + route.link_list->push_back(link); + } xbt_dynar_free(&parsed_link_list); + + sg_platf_new_bypassRoute(&route); } void ETag_surfxml_bypassASroute(void){ @@ -818,14 +841,20 @@ void ETag_surfxml_bypassASroute(void){ ASroute.src = A_surfxml_bypassASroute_src; ASroute.dst = A_surfxml_bypassASroute_dst; - ASroute.link_list = parsed_link_list; + ASroute.link_list = new std::vector(); + unsigned int cpt; + char *link_name; + xbt_dynar_foreach(parsed_link_list, cpt, link_name) { + simgrid::surf::Link *link = Link::byName(link_name); + ASroute.link_list->push_back(link); + } + xbt_dynar_free(&parsed_link_list); ASroute.symmetrical = FALSE; ASroute.gw_src = sg_netcard_by_name_or_null(A_surfxml_bypassASroute_gw___src); ASroute.gw_dst = sg_netcard_by_name_or_null(A_surfxml_bypassASroute_gw___dst); sg_platf_new_bypassRoute(&ASroute); - xbt_dynar_free(&parsed_link_list); } void ETag_surfxml_trace(void){ diff --git a/src/xbt/dict.c b/src/xbt/dict.c index 46d7509ad7..f04465a5c7 100644 --- a/src/xbt/dict.c +++ b/src/xbt/dict.c @@ -412,43 +412,6 @@ XBT_INLINE void xbt_dict_remove(xbt_dict_t dict, const char *key) xbt_dict_remove_ext(dict, key, strlen(key)); } -#ifdef XBT_USE_DEPRECATED -/** - * \brief Add data to the dict (arbitrary key) - * \param dict the container - * \param key the key to set the new data - * \param data the data to add in the dict - * - * Set the \a data in the structure under the \a key. - * Both \a data and \a key are considered as uintptr_t. - */ -XBT_INLINE void xbt_dicti_set(xbt_dict_t dict, - uintptr_t key, uintptr_t data) -{ - xbt_dict_set_ext(dict, (void *)&key, sizeof key, (void*)data, NULL); -} - -/** - * \brief Retrieve data from the dict (key considered as a uintptr_t) - * - * \param dict the dealer of data - * \param key the key to find data - * \return the data that we are looking for (or 0 if not found) - * - * Mixing uintptr_t keys with regular keys in the same dict is discouraged - */ -XBT_INLINE uintptr_t xbt_dicti_get(xbt_dict_t dict, uintptr_t key) -{ - return (uintptr_t)xbt_dict_get_or_null_ext(dict, (void *)&key, sizeof key); -} - -/** Remove a uintptr_t key from the dict */ -XBT_INLINE void xbt_dicti_remove(xbt_dict_t dict, uintptr_t key) -{ - xbt_dict_remove_ext(dict, (void *)&key, sizeof key); -} -#endif - /** @brief Remove all data from the dict */ void xbt_dict_reset(xbt_dict_t dict) { diff --git a/src/xbt/dict_multi.c b/src/xbt/dict_multi.c deleted file mode 100644 index a8ef163d02..0000000000 --- a/src/xbt/dict_multi.c +++ /dev/null @@ -1,248 +0,0 @@ -/* dict_multi - dictionnaries of dictionnaries of ... of data */ - -/* Copyright (c) 2004-2014. The SimGrid Team. - * All rights reserved. */ - -/* 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. */ - -#ifdef XBT_USE_DEPRECATED - -#include "dict_private.h" - -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_dict_multi, xbt_dict, - "Dictionaries of multiple keys"); - -static void _free_dict(void *d) -{ - XBT_VERB("free dict %p", d); - xbt_dict_free((xbt_dict_t *) & d); -} - -/** \brief Insert \e data under all the keys contained in \e keys, providing their sizes in \e lens. - * - * \arg mdict: the multi-dict - * \arg keys: dynar of (char *) containing all the keys - * \arg lens: length of each element of \e keys - * \arg data: what to store in the structure - * \arg free_ctn: function to use to free the pushed content on need - * - * Dynars are not modified during the operation. - */ - -void -xbt_multidict_set_ext(xbt_dict_t mdict, - xbt_dynar_t keys, xbt_dynar_t lens, - void *data, void_f_pvoid_t free_ctn) -{ - - xbt_dict_t thislevel, nextlevel = NULL; - int i; - - unsigned long int thislen; - char *thiskey; - int keys_len = xbt_dynar_length(keys); - - xbt_assert(xbt_dynar_length(keys) == xbt_dynar_length(lens)); - xbt_assert(keys_len, "Can't set a zero-long key set in a multidict"); - - XBT_DEBUG("xbt_multidict_set(%p,%d)", mdict, keys_len); - - for (i = 0, thislevel = mdict; i < keys_len - 1; - i++, thislevel = nextlevel) { - - xbt_dynar_get_cpy(keys, i, &thiskey); - xbt_dynar_get_cpy(lens, i, &thislen); - - XBT_DEBUG("multi_set: at level %d, len=%ld, key=%p |%*s|", i, thislen, - thiskey, (int) thislen, thiskey); - - /* search the dict of next level */ - nextlevel = xbt_dict_get_or_null_ext(thislevel, thiskey, thislen); - if (nextlevel == NULL) { - /* make sure the dict of next level exists */ - nextlevel = xbt_dict_new(); - XBT_VERB("Create a dict (%p)", nextlevel); - xbt_dict_set_ext(thislevel, thiskey, thislen, nextlevel, - &_free_dict); - } - } - - xbt_dynar_get_cpy(keys, i, &thiskey); - xbt_dynar_get_cpy(lens, i, &thislen); - - xbt_dict_set_ext(thislevel, thiskey, thislen, data, free_ctn); -} - -/** \brief Insert \e data under all the keys contained in \e keys - * - * \arg head: the head of dict - * \arg keys: dynar of null-terminated strings containing all the keys - * \arg data: what to store in the structure - * \arg free_ctn: function to use to free the pushed content on need - */ -void -xbt_multidict_set(xbt_dict_t mdict, - xbt_dynar_t keys, void *data, void_f_pvoid_t free_ctn) -{ - xbt_dynar_t lens = xbt_dynar_new(sizeof(unsigned long int), NULL); - unsigned long i; - - for (i = 0; i < xbt_dynar_length(keys); i++) { - char *thiskey = xbt_dynar_get_as(keys, i, char *); - unsigned long int thislen = (unsigned long int) strlen(thiskey); - XBT_DEBUG("Push %ld as level %lu length", thislen, i); - xbt_dynar_push(lens, &thislen); - } - - TRY { - xbt_multidict_set_ext(mdict, keys, lens, data, free_ctn); - } - TRY_CLEANUP { - xbt_dynar_free(&lens); - } - CATCH_ANONYMOUS { - RETHROW; - } -} - -/** \brief Insert \e data under all the keys contained in \e keys, providing their sizes in \e lens. - * - * \arg mdict: the multi-dict - * \arg keys: dynar of (char *) containing all the keys - * \arg lens: length of each element of \e keys - * \arg data: where to put what was found in structure - * \arg free_ctn: function to use to free the pushed content on need - * - * Dynars are not modified during the operation. - */ -void *xbt_multidict_get_ext(xbt_dict_t mdict, - xbt_dynar_t keys, xbt_dynar_t lens) -{ - xbt_dict_t thislevel, nextlevel; - int i; - - unsigned long int thislen; - char *thiskey; - int keys_len = xbt_dynar_length(keys); - - xbt_assert(xbt_dynar_length(keys) == xbt_dynar_length(lens)); - xbt_assert(!xbt_dynar_is_empty(keys), - "Can't get a zero-long key set in a multidict"); - - XBT_DEBUG("xbt_multidict_get(%p, %ld)", mdict, xbt_dynar_length(keys)); - - for (i = 0, thislevel = mdict; i < keys_len - 1; - i++, thislevel = nextlevel) { - - xbt_dynar_get_cpy(keys, i, &thiskey); - xbt_dynar_get_cpy(lens, i, &thislen); - - XBT_DEBUG("multi_get: at level %d (%p), len=%ld, key=%p |%*s|", - i, thislevel, thislen, thiskey, (int) thislen, thiskey); - - /* search the dict of next level: let mismatch raise if not found */ - nextlevel = xbt_dict_get_ext(thislevel, thiskey, thislen); - } - - xbt_dynar_get_cpy(keys, i, &thiskey); - xbt_dynar_get_cpy(lens, i, &thislen); - - return xbt_dict_get_ext(thislevel, thiskey, thislen); -} - -void *xbt_multidict_get(xbt_dict_t mdict, xbt_dynar_t keys) -{ - xbt_dynar_t lens = xbt_dynar_new(sizeof(unsigned long int), NULL); - unsigned long i; - void *res; - - for (i = 0; i < xbt_dynar_length(keys); i++) { - char *thiskey = xbt_dynar_get_as(keys, i, char *); - unsigned long int thislen = (unsigned long int) strlen(thiskey); - xbt_dynar_push(lens, &thislen); - } - - res = xbt_multidict_get_ext(mdict, keys, lens), xbt_dynar_free(&lens); - return res; -} - - -/** \brief Remove the entry under all the keys contained in \e keys, providing their sizes in \e lens. - * - * \arg mdict: the multi-dict - * \arg keys: dynar of (char *) containing all the keys - * \arg lens: length of each element of \e keys - * \arg data: what to store in the structure - * \arg free_ctn: function to use to free the pushed content on need - * - * Dynars are not modified during the operation. - * - * Removing a non-existant key is ok. - */ - -void -xbt_multidict_remove_ext(xbt_dict_t mdict, xbt_dynar_t keys, - xbt_dynar_t lens) -{ - volatile xbt_dict_t thislevel; - volatile xbt_dict_t nextlevel = NULL; - volatile int i; - xbt_ex_t e; - - unsigned long int thislen; - char *thiskey; - int keys_len = xbt_dynar_length(keys); - - xbt_assert(xbt_dynar_length(keys) == xbt_dynar_length(lens)); - xbt_assert(xbt_dynar_length(keys), - "Can't remove a zero-long key set in a multidict"); - - for (i = 0, thislevel = mdict; i < keys_len - 1; - i++, thislevel = nextlevel) { - - xbt_dynar_get_cpy(keys, i, &thiskey); - xbt_dynar_get_cpy(lens, i, &thislen); - - /* search the dict of next level */ - TRY { - nextlevel = xbt_dict_get_ext(thislevel, thiskey, thislen); - } - CATCH(e) { - /* If non-existant entry, nothing to do */ - if (e.category == arg_error) - xbt_ex_free(e); - else - RETHROW; - } - } - - xbt_dynar_get_cpy(keys, i, &thiskey); - xbt_dynar_get_cpy(lens, i, &thislen); - - xbt_dict_remove_ext(thislevel, thiskey, thislen); -} - -void xbt_multidict_remove(xbt_dict_t mdict, xbt_dynar_t keys) -{ - xbt_dynar_t lens = xbt_dynar_new(sizeof(unsigned long int), NULL); - unsigned long i; - - for (i = 0; i < xbt_dynar_length(keys); i++) { - char *thiskey = xbt_dynar_get_as(keys, i, char *); - unsigned long int thislen = strlen(thiskey); - xbt_dynar_push(lens, &thislen); - } - - TRY { - xbt_multidict_remove_ext(mdict, keys, lens); - } - TRY_CLEANUP { - xbt_dynar_free(&lens); - } - CATCH_ANONYMOUS { - RETHROW; - } -} - -#endif diff --git a/src/xbt/log.c b/src/xbt/log.c index 76ecb58d60..296e594885 100644 --- a/src/xbt/log.c +++ b/src/xbt/log.c @@ -570,9 +570,6 @@ static void xbt_log_connect_categories(void) XBT_LOG_CONNECT(xbt_dict); XBT_LOG_CONNECT(xbt_dict_cursor); XBT_LOG_CONNECT(xbt_dict_elm); -#ifdef XBT_USE_DEPRECATED - XBT_LOG_CONNECT(xbt_dict_multi); -#endif XBT_LOG_CONNECT(xbt_dyn); XBT_LOG_CONNECT(xbt_ex); XBT_LOG_CONNECT(xbt_fifo); @@ -590,7 +587,6 @@ static void xbt_log_connect_categories(void) /* bindings */ #ifdef HAVE_LUA - XBT_LOG_CONNECT(bindings); XBT_LOG_CONNECT(lua); XBT_LOG_CONNECT(lua_host); XBT_LOG_CONNECT(lua_platf); diff --git a/teshsuite/bug-17132/CMakeLists.txt b/teshsuite/bug-17132/CMakeLists.txt index 84e79b1435..510f29702d 100644 --- a/teshsuite/bug-17132/CMakeLists.txt +++ b/teshsuite/bug-17132/CMakeLists.txt @@ -13,7 +13,6 @@ endif(enable_smpi) set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/bug-17132.tesh - ${CMAKE_CURRENT_SOURCE_DIR}/bug-17132-surf-debug.tesh PARENT_SCOPE) set(teshsuite_src ${teshsuite_src} @@ -22,5 +21,6 @@ set(teshsuite_src set(txt_files ${txt_files} ${CMAKE_CURRENT_SOURCE_DIR}/hostfile.txt - ${CMAKE_CURRENT_SOURCE_DIR}/README PARENT_SCOPE) + +ADD_TESH_FACTORIES(tesh-smpi-bug-17132 "thread" --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR} --cd ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/bug-17132.tesh) diff --git a/teshsuite/bug-17132/README b/teshsuite/bug-17132/README deleted file mode 100644 index 22e35b9bb3..0000000000 --- a/teshsuite/bug-17132/README +++ /dev/null @@ -1,8 +0,0 @@ -This is the bug #17132 described on gforge [1]. This small SMPI code -triggers an issue in SURF, which is still to be debugged. - -The problem seems to be related to the order of events, as changing it -(with another platform or another message size or a MPI_barrier in -between) fixes the problem. - -[1] https://gforge.inria.fr/tracker/index.php?func=detail&aid=17132&group_id=12&atid=165 \ No newline at end of file diff --git a/teshsuite/bug-17132/bug-17132-surf-debug.tesh b/teshsuite/bug-17132/bug-17132-surf-debug.tesh deleted file mode 100644 index c089cff44c..0000000000 --- a/teshsuite/bug-17132/bug-17132-surf-debug.tesh +++ /dev/null @@ -1,2 +0,0 @@ -! output ignore -$ ../../smpi_script/bin/smpirun -np 16 -platform ${srcdir:=.}/../../examples/platforms/small_platform.xml -hostfile ${srcdir:=.}/hostfile.txt ./bug-17132 --cfg=smpi/cpu_threshold:-1 --log=surf.thres:debug diff --git a/teshsuite/bug-17132/bug-17132.c b/teshsuite/bug-17132/bug-17132.c index 9cd6985a3a..469066b747 100644 --- a/teshsuite/bug-17132/bug-17132.c +++ b/teshsuite/bug-17132/bug-17132.c @@ -4,6 +4,8 @@ /* 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. */ +/* Bug report: https://gforge.inria.fr/tracker/index.php?func=detail&aid=17132&group_id=12&atid=165 */ + #include "xbt/log.h" #include #include diff --git a/teshsuite/simdag/platforms/basic_parsing_test.tesh b/teshsuite/simdag/platforms/basic_parsing_test.tesh index c6be629b32..b41132bb2d 100644 --- a/teshsuite/simdag/platforms/basic_parsing_test.tesh +++ b/teshsuite/simdag/platforms/basic_parsing_test.tesh @@ -58,26 +58,26 @@ $ rm -f ./bob0_availability_file.trace ./bob2_availability_file.trace ./bob0_sta $ ${bindir:=.}/is_router_test ./test_of_is_router.xml > [0.000000] [xbt_cfg/INFO] Switching to the L07 model to handle parallel tasks. -> Workstation number: 10, link number: 1, elmts number: 21 -> - Seen: "host01" is type : 1 -> - Seen: "host02" is type : 1 -> - Seen: "host03" is type : 1 -> - Seen: "host04" is type : 1 -> - Seen: "host05" is type : 1 -> - Seen: "host06" is type : 1 -> - Seen: "host07" is type : 1 -> - Seen: "host08" is type : 1 -> - Seen: "host09" is type : 1 -> - Seen: "host10" is type : 1 -> - Seen: "router1" is type : 2 -> - Seen: "router2" is type : 2 -> - Seen: "router3" is type : 2 -> - Seen: "router4" is type : 2 -> - Seen: "router5" is type : 2 -> - Seen: "AS0" is type : 3 -> - Seen: "AS1" is type : 3 -> - Seen: "AS2" is type : 3 -> - Seen: "AS3" is type : 3 -> - Seen: "AS4" is type : 3 -> - Seen: "AS" is type : 3 +> Host number: 10, link number: 1, elmts number: 21 +> - Seen: "host01". Type: host +> - Seen: "host02". Type: host +> - Seen: "host03". Type: host +> - Seen: "host04". Type: host +> - Seen: "host05". Type: host +> - Seen: "host06". Type: host +> - Seen: "host07". Type: host +> - Seen: "host08". Type: host +> - Seen: "host09". Type: host +> - Seen: "host10". Type: host +> - Seen: "router1". Type: router +> - Seen: "router2". Type: router +> - Seen: "router3". Type: router +> - Seen: "router4". Type: router +> - Seen: "router5". Type: router +> - Seen: "AS0". Type: AS +> - Seen: "AS1". Type: AS +> - Seen: "AS2". Type: AS +> - Seen: "AS3". Type: AS +> - Seen: "AS4". Type: AS +> - Seen: "AS". Type: AS diff --git a/teshsuite/simdag/platforms/flatifier.cpp b/teshsuite/simdag/platforms/flatifier.cpp index 6b347b70bf..b70a5910f9 100644 --- a/teshsuite/simdag/platforms/flatifier.cpp +++ b/teshsuite/simdag/platforms/flatifier.cpp @@ -131,7 +131,7 @@ int main(int argc, char **argv) // Routers xbt_lib_foreach(as_router_lib, cursor_src, key, value1) { value1 = (sg_netcard_t)xbt_lib_get_or_null(as_router_lib, key, ROUTING_ASR_LEVEL); - if(value1->getRcType() == SURF_NETWORK_ELEMENT_ROUTER) { + if(value1->isRouter()) { printf(" \n",key); } } @@ -158,31 +158,26 @@ int main(int argc, char **argv) xbt_dict_foreach(host_list, cursor_src, src, host1){ // Routes from host value1 = sg_host_by_name(src)->pimpl_netcard; xbt_dict_foreach(host_list, cursor_dst, dst, host2){ //to host - xbt_dynar_t route=NULL; + std::vector *route = new std::vector(); value2 = sg_host_by_name(dst)->pimpl_netcard; - routing_platf->getRouteAndLatency(value1, value2, &route,NULL); - if (!xbt_dynar_is_empty(route)){ + routing_platf->getRouteAndLatency(value1, value2, route,NULL); + if (! route->empty()){ printf(" \n ", src, dst); - for(i=0;i",link_ctn,link_name); - free(link_name); - } + for (auto link: *route) + printf("<%s id=\"%s\"/>",link_ctn,link->getName()); printf("\n \n"); } + delete route; } xbt_lib_foreach(as_router_lib, cursor_dst, dst, value2){ //to router value2 = (sg_netcard_t)xbt_lib_get_or_null(as_router_lib,dst,ROUTING_ASR_LEVEL); - if(value2->getRcType() == SURF_NETWORK_ELEMENT_ROUTER){ + if(value2->isRouter()){ printf(" \n ", src, dst); - xbt_dynar_t route=NULL; - routing_platf->getRouteAndLatency((sg_netcard_t)value1,(sg_netcard_t)value2,&route,NULL); - for(i=0;i",link_ctn,surf_resource_name((surf_cpp_resource_t)link)); - } + std::vector *route = new std::vector(); + routing_platf->getRouteAndLatency((sg_netcard_t)value1,(sg_netcard_t)value2,route,NULL); + for (auto link : *route) + printf("<%s id=\"%s\"/>",link_ctn,link->getName()); + delete route; printf("\n \n"); } } @@ -190,35 +185,27 @@ int main(int argc, char **argv) xbt_lib_foreach(as_router_lib, cursor_src, src, value1){ // Routes from router value1 = (sg_netcard_t)xbt_lib_get_or_null(as_router_lib,src,ROUTING_ASR_LEVEL); - if (value1->getRcType() == SURF_NETWORK_ELEMENT_ROUTER){ + if (value1->isRouter()){ xbt_lib_foreach(as_router_lib, cursor_dst, dst, value2){ //to router value2 = (sg_netcard_t)xbt_lib_get_or_null(as_router_lib,dst,ROUTING_ASR_LEVEL); - if(value2->getRcType() == SURF_NETWORK_ELEMENT_ROUTER){ + if(value2->isRouter()){ printf(" \n ", src, dst); - xbt_dynar_t route=NULL; - routing_platf->getRouteAndLatency((sg_netcard_t)value1,(sg_netcard_t)value2,&route,NULL); - for(i=0;i",link_ctn,link_name); - free(link_name); - } + std::vector *route = new std::vector(); + routing_platf->getRouteAndLatency((sg_netcard_t)value1,(sg_netcard_t)value2,route,NULL); + for(auto link :*route) + printf("<%s id=\"%s\"/>",link_ctn,link->getName()); + delete route; printf("\n \n"); } } xbt_dict_foreach(host_list, cursor_dst, dst, value2){ //to host printf(" \n ",src, dst); - xbt_dynar_t route=NULL; + std::vector *route = new std::vector(); value2 = sg_host_by_name(dst)->pimpl_netcard; - routing_platf->getRouteAndLatency((sg_netcard_t)value1,(sg_netcard_t)value2,&route, NULL); - for(i=0;i",link_ctn,link_name); - free(link_name); - } + routing_platf->getRouteAndLatency((sg_netcard_t)value1,(sg_netcard_t)value2,route, NULL); + for(auto link : *route) + printf("<%s id=\"%s\"/>",link_ctn,link->getName()); + delete route; printf("\n \n"); } } diff --git a/teshsuite/simdag/platforms/is_router_test.cpp b/teshsuite/simdag/platforms/is_router_test.cpp index fbe96d08ae..1579d0c3ab 100644 --- a/teshsuite/simdag/platforms/is_router_test.cpp +++ b/teshsuite/simdag/platforms/is_router_test.cpp @@ -24,13 +24,17 @@ int main(int argc, char **argv) size = xbt_dict_length(host_list) + xbt_lib_length(as_router_lib); - printf("Workstation number: %zu, link number: %d, elmts number: %d\n", sg_host_count(), sg_link_count(), size); + printf("Host number: %zu, link number: %d, elmts number: %d\n", sg_host_count(), sg_link_count(), size); - xbt_dict_foreach(host_list, cursor, key, data) - printf(" - Seen: \"%s\" is type : %d\n", key, (int) sg_netcard_by_name_or_null(key)->getRcType()); + xbt_dict_foreach(host_list, cursor, key, data) { + simgrid::surf::NetCard * nc = sg_netcard_by_name_or_null(key); + printf(" - Seen: \"%s\". Type: %s\n", key, nc->isRouter() ? "router" : (nc->isAS()?"AS":"host")); + } - xbt_lib_foreach(as_router_lib, cursor, key, data) - printf(" - Seen: \"%s\" is type : %d\n", key, (int) sg_netcard_by_name_or_null(key)->getRcType()); + xbt_lib_foreach(as_router_lib, cursor, key, data) { + simgrid::surf::NetCard * nc = sg_netcard_by_name_or_null(key); + printf(" - Seen: \"%s\". Type: %s\n", key, nc->isRouter() ? "router" : (nc->isAS()?"AS":"host")); + } SD_exit(); return 0; diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 6765bf9595..27263131f1 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -249,7 +249,6 @@ set(XBT_SRC src/xbt/dict.c src/xbt/dict_cursor.c src/xbt/dict_elm.c - src/xbt/dict_multi.c src/xbt/dynar.c src/xbt/ex.c src/xbt/fifo.c @@ -438,7 +437,6 @@ else() endif() set(BINDINGS_SRC - src/bindings/bindings_global.c src/bindings/lua/lua_private.h src/bindings/lua/lua_utils.h src/bindings/lua/simgrid_lua.h diff --git a/tools/cmake/Tests.cmake b/tools/cmake/Tests.cmake index bdacb15efc..6288648351 100644 --- a/tools/cmake/Tests.cmake +++ b/tools/cmake/Tests.cmake @@ -363,11 +363,6 @@ IF(NOT enable_memcheck) ENDIF() # smpi broken usage ADD_TESH_FACTORIES(tesh-smpi-broken "thread" --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/smpi/pingpong --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/pingpong broken_hostfiles.tesh) - # https://gforge.inria.fr/tracker/index.php?func=detail&aid=17132&group_id=12&atid=165 - ADD_TESH_FACTORIES(tesh-smpi-bug-17132 "thread" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/bug-17132 --cd ${CMAKE_BINARY_DIR}/teshsuite/bug-17132 ${CMAKE_HOME_DIRECTORY}/teshsuite/bug-17132/bug-17132.tesh) - IF(enable_debug) - ADD_TESH_FACTORIES(tesh-smpi-bug-17132-surf-debug "thread" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/bug-17132 --cd ${CMAKE_BINARY_DIR}/teshsuite/bug-17132 ${CMAKE_HOME_DIRECTORY}/teshsuite/bug-17132/bug-17132-surf-debug.tesh) - ENDIF() ADD_TESH(tesh-smpi-replay-ti-tracing --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/smpi/pingpong --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/pingpong TI_output.tesh) FOREACH (GATHER_COLL default ompi mpich ompi_basic_linear ompi_linear_sync ompi_binomial mvapich2 mvapich2_two_level impi) ADD_TESH(tesh-smpi-gather-coll-${GATHER_COLL} --cfg smpi/gather:${GATHER_COLL} --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/smpi/gather --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/gather gather_coll.tesh) diff --git a/tools/jenkins/DynamicAnalysis.sh b/tools/jenkins/DynamicAnalysis.sh index 55bab495f8..fbe85e3021 100755 --- a/tools/jenkins/DynamicAnalysis.sh +++ b/tools/jenkins/DynamicAnalysis.sh @@ -45,7 +45,7 @@ done cd $WORKSPACE/build ### Proceed with the tests -ctest -D ExperimentalStart || true +ctest -D ExperimentalStart cmake -Denable_documentation=OFF -Denable_lua=OFF -Denable_tracing=ON \ -Denable_compile_optimizations=OFF -Denable_compile_warnings=ON \ @@ -54,7 +54,7 @@ cmake -Denable_documentation=OFF -Denable_lua=OFF -Denable_tracing=ON \ -Denable_memcheck_xml=ON $WORKSPACE ctest -D ExperimentalBuild -V -ctest -D ExperimentalMemCheck || true +ctest -D ExperimentalMemCheck cd $WORKSPACE/build if [ -f Testing/TAG ] ; then @@ -63,7 +63,7 @@ if [ -f Testing/TAG ] ; then fi make clean -ctest -D ExperimentalStart || true +ctest -D ExperimentalStart cmake -Denable_documentation=OFF -Denable_lua=ON -Denable_java=ON -Denable_tracing=ON \ -Denable_compile_optimizations=OFF -Denable_compile_warnings=ON \ @@ -72,8 +72,8 @@ cmake -Denable_documentation=OFF -Denable_lua=ON -Denable_java=ON -Denable_traci -Denable_memcheck=OFF -Denable_memcheck_xml=OFF -Denable_smpi_ISP_testsuite=ON -Denable_coverage=ON $WORKSPACE ctest -D ExperimentalBuild -V -ctest -D ExperimentalTest || true -ctest -D ExperimentalCoverage || true +ctest -D ExperimentalTest +ctest -D ExperimentalCoverage if [ -f Testing/TAG ] ; then gcovr -r .. --xml-pretty -e teshsuite.* -u -o $WORKSPACE/xml_coverage.xml