From 14ad54e6f735bfec4e8feb60a6089ef866fd2554 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 10 Dec 2017 21:44:30 +0100 Subject: [PATCH] move another msg example to the dungeon --- .gitignore | 2 +- examples/msg/CMakeLists.txt | 6 +-- examples/msg/README.doc | 8 --- teshsuite/msg/CMakeLists.txt | 4 +- .../msg/app-pingpong/app-pingpong.c | 49 ++++++++++--------- .../msg/app-pingpong/app-pingpong.tesh | 14 +++--- .../msg/app-pingpong/app-pingpong_d.xml | 0 7 files changed, 39 insertions(+), 44 deletions(-) rename {examples => teshsuite}/msg/app-pingpong/app-pingpong.c (52%) rename {examples => teshsuite}/msg/app-pingpong/app-pingpong.tesh (84%) rename {examples => teshsuite}/msg/app-pingpong/app-pingpong_d.xml (100%) diff --git a/.gitignore b/.gitignore index 8b2e59ae12..c3ef7ba5af 100644 --- a/.gitignore +++ b/.gitignore @@ -157,7 +157,6 @@ examples/msg/network-ns3/network-ns3 examples/msg/task-priority/task-priority examples/msg/procmig.trace examples/msg/synchro-semaphore/synchro-semaphore -examples/msg/app-pingpong/app-pingpong examples/msg/maestro-set/maestro-set examples/msg/simulation.trace examples/msg/app-token-ring/app-token-ring @@ -252,6 +251,7 @@ teshsuite/mc/mutex-handling/without-mutex-handling teshsuite/msg/actions-comm/actions-comm teshsuite/msg/actions-storage/actions-storage teshsuite/msg/app-bittorrent/bittorrent +teshsuite/msg/app-pingpong/app-pingpong teshsuite/msg/async-wait/async-wait teshsuite/msg/async-waitall/async-waitall teshsuite/msg/async-waitany/async-waitany diff --git a/examples/msg/CMakeLists.txt b/examples/msg/CMakeLists.txt index 14f84eb9af..824b75f186 100644 --- a/examples/msg/CMakeLists.txt +++ b/examples/msg/CMakeLists.txt @@ -1,5 +1,5 @@ # C examples -foreach(x app-masterworker app-pingpong app-token-ring +foreach(x app-masterworker app-token-ring cloud-capping cloud-masterworker cloud-migration cloud-simple cloud-two-tasks dht-pastry energy-consumption energy-onoff energy-vm platform-failures plugin-hostload @@ -43,7 +43,7 @@ foreach (file answer dht-kademlia node routing_table task) set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/${file}.c ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/${file}.h) endforeach() -foreach (file app-chainsend app-masterworker app-pingpong dht-kademlia dht-pastry) +foreach (file app-chainsend app-masterworker dht-kademlia dht-pastry) set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/${file}/${file}_d.xml) endforeach() @@ -70,7 +70,7 @@ set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/a ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/one_cluster_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/two_clusters_d.xml PARENT_SCOPE) -foreach(x app-chainsend app-masterworker app-pingpong app-token-ring +foreach(x app-chainsend app-masterworker app-token-ring cloud-capping cloud-masterworker cloud-migration cloud-simple cloud-two-tasks dht-pastry dht-kademlia platform-failures energy-consumption energy-onoff energy-vm diff --git a/examples/msg/README.doc b/examples/msg/README.doc index 8516d2031e..ce70c791c8 100644 --- a/examples/msg/README.doc +++ b/examples/msg/README.doc @@ -17,13 +17,6 @@ documentation, but it should remain readable directly. @section msg_ex_basics Basic examples and features - - Ping Pong: @ref examples/msg/app-pingpong/app-pingpong.c\n - It's hard to think of a simpler example: it is just sending one - message back and forth. - The tesh file laying in the directory show how to start the - simulator binary, highlighting how to pass options to the simulators - (as detailed in Section \ref options). - - Token Ring. @ref examples/msg/app-token-ring/app-token-ring.c\n Classical communication pattern, where a token is exchanged @@ -143,7 +136,6 @@ top of the example file). /** -@example examples/msg/app-pingpong/app-pingpong.c @example examples/msg/app-token-ring/app-token-ring.c @example examples/msg/app-masterworker/app-masterworker.c diff --git a/teshsuite/msg/CMakeLists.txt b/teshsuite/msg/CMakeLists.txt index 740950dcd3..0db2486914 100644 --- a/teshsuite/msg/CMakeLists.txt +++ b/teshsuite/msg/CMakeLists.txt @@ -1,5 +1,6 @@ # C examples foreach(x actions-comm actions-storage + app-pingpong async-wait async-waitall async-waitany cloud-sharing get_sender host_on_off host_on_off_recv host_on_off_processes process-daemon process-kill process-join process-lifetime process-migration process-suspend process-yield @@ -44,6 +45,7 @@ set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/acti ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/actions-comm_split_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/actions-storage/actions-storage_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/app-bittorrent_d.xml + ${CMAKE_CURRENT_SOURCE_DIR}/app-pingpong/app-pingpong_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait2_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait3_d.xml @@ -74,7 +76,7 @@ set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/acti foreach(x actions-comm actions-storage async-wait async-waitall async-waitany - app-bittorrent + app-bittorrent app-pingpong energy-pstate host_on_off host_on_off_processes host_on_off_recv get_sender diff --git a/examples/msg/app-pingpong/app-pingpong.c b/teshsuite/msg/app-pingpong/app-pingpong.c similarity index 52% rename from examples/msg/app-pingpong/app-pingpong.c rename to teshsuite/msg/app-pingpong/app-pingpong.c index 3e12e81fe8..c4ed0d50ba 100644 --- a/examples/msg/app-pingpong/app-pingpong.c +++ b/teshsuite/msg/app-pingpong/app-pingpong.c @@ -7,26 +7,26 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_app_pingpong, "Messages specific for this msg example"); -static int pinger(int argc, char *argv[]) +static int pinger(int argc, char* argv[]) { - xbt_assert(argc==2, "The pinger function one argument from the XML deployment file"); + xbt_assert(argc == 2, "The pinger function one argument from the XML deployment file"); XBT_INFO("Ping -> %s", argv[1]); xbt_assert(MSG_host_by_name(argv[1]) != NULL, "Unknown host %s. Stopping Now! ", argv[1]); /* - Do the ping with a 1-Byte task (latency bound) ... */ - double now = MSG_get_clock(); - msg_task_t ping_task = MSG_task_create("small communication (latency bound)", 0.0, 1, NULL); - ping_task->data = xbt_new(double, 1); - *(double *) ping_task->data = now; + double now = MSG_get_clock(); + msg_task_t ping_task = MSG_task_create("small communication (latency bound)", 0.0, 1, NULL); + ping_task->data = xbt_new(double, 1); + *(double*)ping_task->data = now; MSG_task_send(ping_task, argv[1]); /* - ... then wait for the (large) pong */ msg_task_t pong_task = NULL; - int a = MSG_task_receive(&pong_task,MSG_host_get_name(MSG_host_self())); + int a = MSG_task_receive(&pong_task, MSG_host_get_name(MSG_host_self())); xbt_assert(a == MSG_OK, "Unexpected behavior"); - double sender_time = *((double *) (pong_task->data)); - double communication_time = MSG_get_clock() - sender_time; + double sender_time = *((double*)(pong_task->data)); + double communication_time = MSG_get_clock() - sender_time; XBT_INFO("Task received : %s", pong_task->name); xbt_free(pong_task->data); MSG_task_destroy(pong_task); @@ -35,18 +35,18 @@ static int pinger(int argc, char *argv[]) return 0; } -static int ponger(int argc, char *argv[]) +static int ponger(int argc, char* argv[]) { - xbt_assert(argc==2, "The ponger function one argument from the XML deployment file"); + xbt_assert(argc == 2, "The ponger function one argument from the XML deployment file"); XBT_INFO("Pong -> %s", argv[1]); xbt_assert(MSG_host_by_name(argv[1]) != NULL, "Unknown host %s. Stopping Now! ", argv[1]); /* - Receive the (small) ping first ....*/ msg_task_t ping_task = NULL; - int a = MSG_task_receive(&ping_task, MSG_host_get_name(MSG_host_self())); + int a = MSG_task_receive(&ping_task, MSG_host_get_name(MSG_host_self())); xbt_assert(a == MSG_OK, "Unexpected behavior"); - double sender_time = *((double *) (ping_task->data)); + double sender_time = *((double*)(ping_task->data)); double communication_time = MSG_get_clock() - sender_time; XBT_INFO("Task received : %s", ping_task->name); xbt_free(ping_task->data); @@ -54,32 +54,33 @@ static int ponger(int argc, char *argv[]) XBT_INFO(" Ping time (latency bound) %f", communication_time); /* - ... Then send a 1GB pong back (bandwidth bound) */ - double now = MSG_get_clock(); - msg_task_t pong_task = MSG_task_create("large communication (bandwidth bound)", 0.0, 1e9, NULL); - pong_task->data = xbt_new(double, 1); - *(double *) pong_task->data = now; + double now = MSG_get_clock(); + msg_task_t pong_task = MSG_task_create("large communication (bandwidth bound)", 0.0, 1e9, NULL); + pong_task->data = xbt_new(double, 1); + *(double*)pong_task->data = now; XBT_INFO("task_bw->data = %.3f", *((double*)pong_task->data)); MSG_task_send(pong_task, argv[1]); return 0; } -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { MSG_init(&argc, argv); xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" - "\tExample: %s ../../platforms/small_platform.xml app-pingpong_d.xml\n", argv[0], argv[0]); + "\tExample: %s ../../platforms/small_platform.xml app-pingpong_d.xml\n", + argv[0], argv[0]); - MSG_create_environment(argv[1]); /* - Load the platform description */ + MSG_create_environment(argv[1]); /* - Load the platform description */ - MSG_function_register("pinger", pinger); /* - Register the functions to be executed by the processes */ + MSG_function_register("pinger", pinger); /* - Register the functions to be executed by the processes */ MSG_function_register("ponger", ponger); - MSG_launch_application(argv[2]); /* - Deploy the application */ + MSG_launch_application(argv[2]); /* - Deploy the application */ - msg_error_t res = MSG_main(); /* - Run the simulation */ + msg_error_t res = MSG_main(); /* - Run the simulation */ XBT_INFO("Total simulation time: %.3f", MSG_get_clock()); - return res!=MSG_OK; + return res != MSG_OK; } diff --git a/examples/msg/app-pingpong/app-pingpong.tesh b/teshsuite/msg/app-pingpong/app-pingpong.tesh similarity index 84% rename from examples/msg/app-pingpong/app-pingpong.tesh rename to teshsuite/msg/app-pingpong/app-pingpong.tesh index b1e237e191..3ac7058367 100644 --- a/examples/msg/app-pingpong/app-pingpong.tesh +++ b/teshsuite/msg/app-pingpong/app-pingpong.tesh @@ -2,7 +2,7 @@ p Testing with default compound -$ $SG_TEST_EXENV ${bindir:=.}/app-pingpong$EXEEXT ${platfdir}/small_platform.xml ${srcdir}/app-pingpong_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ $SG_TEST_EXENV ${bindir:=.}/app-pingpong$EXEEXT ${platfdir}/small_platform.xml app-pingpong_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 0.000000] (1:pinger@Tremblay) Ping -> Jupiter > [ 0.000000] (2:ponger@Jupiter) Pong -> Tremblay > [ 0.019014] (2:ponger@Jupiter) Task received : small communication (latency bound) @@ -14,7 +14,7 @@ $ $SG_TEST_EXENV ${bindir:=.}/app-pingpong$EXEEXT ${platfdir}/small_platform.xml p Testing with default compound and Full network optimization -$ $SG_TEST_EXENV ${bindir:=.}/app-pingpong$EXEEXT ${platfdir}/small_platform.xml ${srcdir}/app-pingpong_d.xml "--cfg=network/optim:Full" "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ $SG_TEST_EXENV ${bindir:=.}/app-pingpong$EXEEXT ${platfdir}/small_platform.xml app-pingpong_d.xml "--cfg=network/optim:Full" "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 0.000000] (0:maestro@) Configuration change: Set 'network/optim' to 'Full' > [ 0.000000] (1:pinger@Tremblay) Ping -> Jupiter > [ 0.000000] (2:ponger@Jupiter) Pong -> Tremblay @@ -27,7 +27,7 @@ $ $SG_TEST_EXENV ${bindir:=.}/app-pingpong$EXEEXT ${platfdir}/small_platform.xml p Testing the deprecated CM02 network model -$ $SG_TEST_EXENV ${bindir:=.}/app-pingpong$EXEEXT ${platfdir}/small_platform.xml ${srcdir}/app-pingpong_d.xml --cfg=cpu/model:Cas01 --cfg=network/model:CM02 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ $SG_TEST_EXENV ${bindir:=.}/app-pingpong$EXEEXT ${platfdir}/small_platform.xml app-pingpong_d.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] (1:pinger@Tremblay) Ping -> Jupiter @@ -41,7 +41,7 @@ $ $SG_TEST_EXENV ${bindir:=.}/app-pingpong$EXEEXT ${platfdir}/small_platform.xml p Testing the surf network Reno fairness model using lagrangian approach -$ $SG_TEST_EXENV ${bindir:=.}/app-pingpong$EXEEXT ${platfdir}/small_platform.xml ${srcdir}/app-pingpong_d.xml "--cfg=host/model:compound cpu/model:Cas01 network/model:Reno" --log=surf_lagrange.thres=critical "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ $SG_TEST_EXENV ${bindir:=.}/app-pingpong$EXEEXT ${platfdir}/small_platform.xml app-pingpong_d.xml "--cfg=host/model:compound cpu/model:Cas01 network/model:Reno" --log=surf_lagrange.thres=critical "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 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' @@ -56,7 +56,7 @@ $ $SG_TEST_EXENV ${bindir:=.}/app-pingpong$EXEEXT ${platfdir}/small_platform.xml p Testing the surf network Reno2 fairness model using lagrangian approach -$ $SG_TEST_EXENV ${bindir:=.}/app-pingpong$EXEEXT ${platfdir}/small_platform.xml ${srcdir}/app-pingpong_d.xml "--cfg=host/model:compound cpu/model:Cas01 network/model:Reno2" --log=surf_lagrange.thres=critical "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ $SG_TEST_EXENV ${bindir:=.}/app-pingpong$EXEEXT ${platfdir}/small_platform.xml app-pingpong_d.xml "--cfg=host/model:compound cpu/model:Cas01 network/model:Reno2" --log=surf_lagrange.thres=critical "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 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 'Reno2' @@ -71,7 +71,7 @@ $ $SG_TEST_EXENV ${bindir:=.}/app-pingpong$EXEEXT ${platfdir}/small_platform.xml p Testing the surf network Vegas fairness model using lagrangian approach -$ $SG_TEST_EXENV ${bindir:=.}/app-pingpong$EXEEXT ${platfdir}/small_platform.xml ${srcdir}/app-pingpong_d.xml "--cfg=host/model:compound cpu/model:Cas01 network/model:Vegas" "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ $SG_TEST_EXENV ${bindir:=.}/app-pingpong$EXEEXT ${platfdir}/small_platform.xml app-pingpong_d.xml "--cfg=host/model:compound cpu/model:Cas01 network/model:Vegas" "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 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' @@ -86,7 +86,7 @@ $ $SG_TEST_EXENV ${bindir:=.}/app-pingpong$EXEEXT ${platfdir}/small_platform.xml p Testing the surf network constant model -$ $SG_TEST_EXENV ${bindir:=.}/app-pingpong$EXEEXT ${platfdir}/small_platform_constant.xml ${srcdir}/app-pingpong_d.xml "--cfg=host/model:compound cpu/model:Cas01 network/model:Constant" "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ $SG_TEST_EXENV ${bindir:=.}/app-pingpong$EXEEXT ${platfdir}/small_platform_constant.xml app-pingpong_d.xml "--cfg=host/model:compound cpu/model:Cas01 network/model:Constant" "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 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 'Constant' diff --git a/examples/msg/app-pingpong/app-pingpong_d.xml b/teshsuite/msg/app-pingpong/app-pingpong_d.xml similarity index 100% rename from examples/msg/app-pingpong/app-pingpong_d.xml rename to teshsuite/msg/app-pingpong/app-pingpong_d.xml -- 2.20.1