From 280061007b2915d5b4bffbc32346c8ea43ce86f4 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Sat, 2 Dec 2017 11:56:40 +0100 Subject: [PATCH 1/1] move MSG async examples to the dungeon --- .gitignore | 6 +-- examples/msg/CMakeLists.txt | 16 +++---- examples/msg/README.doc | 30 ------------ teshsuite/msg/CMakeLists.txt | 13 ++++- .../msg/async-wait/async-wait.c | 47 ++++++++++--------- .../msg/async-wait/async-wait.tesh | 8 ++-- .../msg/async-wait/async-wait2_d.xml | 0 .../msg/async-wait/async-wait3_d.xml | 0 .../msg/async-wait/async-wait4_d.xml | 0 .../msg/async-wait/async-wait_d.xml | 0 .../msg/async-waitall/async-waitall.c | 31 ++++++------ .../msg/async-waitall/async-waitall.tesh | 2 +- .../msg/async-waitall/async-waitall_d.xml | 0 .../msg/async-waitany/async-waitany.c | 37 ++++++++------- .../msg/async-waitany/async-waitany.tesh | 2 +- .../msg/async-waitany/async-waitany_d.xml | 0 16 files changed, 85 insertions(+), 107 deletions(-) rename {examples => teshsuite}/msg/async-wait/async-wait.c (62%) rename {examples => teshsuite}/msg/async-wait/async-wait.tesh (88%) rename {examples => teshsuite}/msg/async-wait/async-wait2_d.xml (100%) rename {examples => teshsuite}/msg/async-wait/async-wait3_d.xml (100%) rename {examples => teshsuite}/msg/async-wait/async-wait4_d.xml (100%) rename {examples => teshsuite}/msg/async-wait/async-wait_d.xml (100%) rename {examples => teshsuite}/msg/async-waitall/async-waitall.c (71%) rename {examples => teshsuite}/msg/async-waitall/async-waitall.tesh (86%) rename {examples => teshsuite}/msg/async-waitall/async-waitall_d.xml (100%) rename {examples => teshsuite}/msg/async-waitany/async-waitany.c (72%) rename {examples => teshsuite}/msg/async-waitany/async-waitany.tesh (91%) rename {examples => teshsuite}/msg/async-waitany/async-waitany_d.xml (100%) diff --git a/.gitignore b/.gitignore index 0d6f60d2d4..38cb12727c 100644 --- a/.gitignore +++ b/.gitignore @@ -121,9 +121,6 @@ doc/msg-tuto-src/masterworker1 doc/msg-tuto-src/masterworker2 doc/msg-tuto-src/masterworker3 doc/msg-tuto-src/masterworker4 -examples/msg/async-wait/async-wait -examples/msg/async-waitall/async-waitall -examples/msg/async-waitany/async-waitany examples/msg/app-chainsend/chainsend examples/msg/cloud-capping/cloud-capping examples/msg/cloud-masterworker/cloud-masterworker @@ -260,6 +257,9 @@ 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/async-wait/async-wait +teshsuite/msg/async-waitall/async-waitall +teshsuite/msg/async-waitany/async-waitany teshsuite/msg/cloud-sharing/cloud-sharing teshsuite/msg/concurrent_rw/concurrent_rw teshsuite/msg/energy-ptask/energy-ptask diff --git a/examples/msg/CMakeLists.txt b/examples/msg/CMakeLists.txt index 7b17a53644..52029159fa 100644 --- a/examples/msg/CMakeLists.txt +++ b/examples/msg/CMakeLists.txt @@ -1,10 +1,10 @@ # C examples -foreach(x app-masterworker app-pingpong app-token-ring async-wait async-waitall - async-waitany cloud-capping cloud-masterworker cloud-migration cloud-simple cloud-two-tasks +foreach(x app-masterworker app-pingpong app-token-ring + cloud-capping cloud-masterworker cloud-migration cloud-simple cloud-two-tasks dht-pastry energy-consumption energy-onoff energy-pstate energy-vm platform-failures io-file io-remote io-storage task-priority - plugin-hostload - process-create process-join + plugin-hostload + process-create process-join platform-properties process-startkilltime synchro-semaphore trace-categories trace-route-user-variables trace-link-user-variables trace-masterworker trace-platform trace-process-migration trace-host-user-variables) @@ -44,8 +44,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 async-wait - async-waitall async-waitany dht-kademlia dht-pastry io-remote platform-properties +foreach (file app-chainsend app-masterworker app-pingpong dht-kademlia dht-pastry io-remote platform-properties task-priority) set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/${file}/${file}_d.xml) endforeach() @@ -63,9 +62,6 @@ set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-chainsend/app- ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/network-ns3.tesh PARENT_SCOPE) set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/app-masterworker-multicore_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/app-masterworker-vivaldi_d.xml - ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait2_d.xml - ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait3_d.xml - ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait4_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/energy-onoff/platform_onoff.xml ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3hosts_2links_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3links-timer_d.xml @@ -81,7 +77,7 @@ set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/a ${CMAKE_CURRENT_SOURCE_DIR}/process-startkilltime/start_kill_d.xml PARENT_SCOPE) foreach(x app-chainsend app-masterworker app-pingpong app-token-ring - async-wait async-waitall async-waitany cloud-capping cloud-masterworker cloud-migration cloud-simple + cloud-capping cloud-masterworker cloud-migration cloud-simple cloud-two-tasks dht-pastry dht-kademlia platform-failures io-file io-remote io-storage task-priority process-create process-join process-startkilltime platform-properties synchro-semaphore) diff --git a/examples/msg/README.doc b/examples/msg/README.doc index 20898639c7..18acfac99c 100644 --- a/examples/msg/README.doc +++ b/examples/msg/README.doc @@ -7,7 +7,6 @@ documentation, but it should remain readable directly. @brief Find the MSG example fitting your needs from the extensive set provided in the archive. - @ref msg_ex_basics - - @ref msg_ex_async - @ref msg_ex_process - @ref msg_ex_tracing - @ref msg_ex_tracing_user_variables @@ -39,31 +38,6 @@ documentation, but it should remain readable directly. task to dispatch to a set of several Worker processes. It is fully commented in @ref msg_ex_master_worker. -@section msg_ex_async Asynchronous communications - -In addition to the fully documented example of @ref -MSG_ex_asynchronous_communications, there are several other examples -shipped in the archive: - - - Basic asynchronous communications. - @ref examples/msg/async-wait/async-wait.c \n - Illustrates how to have non-blocking communications, that are - communications running in the background leaving the process free - to do something else during their completion. The main functions - involved are @ref MSG_task_isend, @ref MSG_task_irecv, and @ref - MSG_comm_wait. - - - Waiting for all communications in a set. - @ref examples/msg/async-waitall/async-waitall.c\n - The @ref MSG_comm_waitall function is useful when you want to block - until all activities in a given set have completed. - - - Waiting for the first completed communication in a set. - @ref examples/msg/async-waitany/async-waitany.c\n - The @ref MSG_comm_waitany function is useful when you want to block - until one activity of the set completes, no matter which terminates - first. - @section msg_ex_process Acting on Processes - Creating processes. @@ -213,10 +187,6 @@ top of the example file). @example examples/msg/app-token-ring/app-token-ring.c @example examples/msg/app-masterworker/app-masterworker.c -@example examples/msg/async-wait/async-wait.c -@example examples/msg/async-waitall/async-waitall.c -@example examples/msg/async-waitany/async-waitany.c - @example examples/msg/process-create/process-create.c @example examples/msg/process-startkilltime/process-startkilltime.c diff --git a/teshsuite/msg/CMakeLists.txt b/teshsuite/msg/CMakeLists.txt index 62b1507a78..0ad9b87cae 100644 --- a/teshsuite/msg/CMakeLists.txt +++ b/teshsuite/msg/CMakeLists.txt @@ -1,5 +1,7 @@ # C examples -foreach(x actions-comm actions-storage cloud-sharing get_sender host_on_off host_on_off_recv host_on_off_processes +foreach(x actions-comm actions-storage + 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-migration process-suspend process-yield energy-ptask trace_integration) @@ -40,7 +42,13 @@ 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}/process-yield/process-yield_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 + ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/async-wait4_d.xml + ${CMAKE_CURRENT_SOURCE_DIR}/async-waitall/async-waitall_d.xml + ${CMAKE_CURRENT_SOURCE_DIR}/async-waitany/async-waitany_d.xml + ${CMAKE_CURRENT_SOURCE_DIR}/process-yield/process-yield_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp1.0-hbp1.0-hbp1.0.xml ${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp1.0-hbp3.0-hbp4.0.xml ${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp1.5-hbp1.5.xml @@ -55,6 +63,7 @@ set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/acti ${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp2.5-hbp1.5.xml PARENT_SCOPE) foreach(x get_sender host_on_off host_on_off_processes host_on_off_recv + async-wait async-waitall async-waitany task_destroy_cancel task_listen_from task_progress process-daemon process-kill process-migration process-suspend process-yield energy-ptask diff --git a/examples/msg/async-wait/async-wait.c b/teshsuite/msg/async-wait/async-wait.c similarity index 62% rename from examples/msg/async-wait/async-wait.c rename to teshsuite/msg/async-wait/async-wait.c index 0c4d599ee9..beb85caca6 100644 --- a/examples/msg/async-wait/async-wait.c +++ b/teshsuite/msg/async-wait/async-wait.c @@ -8,15 +8,15 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_async_wait, "Messages specific for this msg example"); /* Main function of the Sender process */ -static int sender(int argc, char *argv[]) +static int sender(int argc, char* argv[]) { - xbt_assert(argc==7, "The sender function expects 6 arguments from the XML deployment file"); - long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s"); /* - number of tasks */ - double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s"); /* - computational cost */ - double task_comm_size = xbt_str_parse_double(argv[3], "Invalid communication size: %s"); /* - communication cost */ - long receivers_count = xbt_str_parse_int(argv[4], "Invalid amount of receivers: %s"); /* - number of receivers */ - double sleep_start_time = xbt_str_parse_double(argv[5], "Invalid sleep start time: %s"); /* - start time */ - double sleep_test_time = xbt_str_parse_double(argv[6], "Invalid test time: %s"); /* - test time */ + xbt_assert(argc == 7, "The sender function expects 6 arguments from the XML deployment file"); + long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s"); /* - number of tasks */ + double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s"); /* - computational cost */ + double task_comm_size = xbt_str_parse_double(argv[3], "Invalid communication size: %s"); /* - communication cost */ + long receivers_count = xbt_str_parse_int(argv[4], "Invalid amount of receivers: %s"); /* - number of receivers */ + double sleep_start_time = xbt_str_parse_double(argv[5], "Invalid sleep start time: %s"); /* - start time */ + double sleep_test_time = xbt_str_parse_double(argv[6], "Invalid test time: %s"); /* - test time */ XBT_INFO("sleep_start_time : %f , sleep_test_time : %f", sleep_start_time, sleep_test_time); @@ -25,15 +25,15 @@ static int sender(int argc, char *argv[]) char mailbox[80]; char taskname[80]; - snprintf(mailbox,79, "receiver-%ld", i % receivers_count); - snprintf(taskname,79, "Task_%d", i); + snprintf(mailbox, 79, "receiver-%ld", i % receivers_count); + snprintf(taskname, 79, "Task_%d", i); /* This process first creates a task and send it asynchronously with @ref MSG_task_isend. Then, if: */ msg_task_t task = MSG_task_create(taskname, task_comp_size, task_comm_size, NULL); msg_comm_t comm = MSG_task_isend(task, mailbox); XBT_INFO("Send to receiver-%ld Task_%d", i % receivers_count, i); - if (sleep_test_time > 0) { /* - "test_time" is set to 0, wait on @ref MSG_comm_wait */ + if (sleep_test_time > 0) { /* - "test_time" is set to 0, wait on @ref MSG_comm_wait */ while (MSG_comm_test(comm) == 0) { /* - Call @ref MSG_comm_test every "test_time" otherwise */ MSG_process_sleep(sleep_test_time); } @@ -64,25 +64,25 @@ static int sender(int argc, char *argv[]) } /* Receiver process expects 3 arguments: */ -static int receiver(int argc, char *argv[]) +static int receiver(int argc, char* argv[]) { - xbt_assert(argc==4, "The relay_runner function does not accept any parameter from the XML deployment file"); - int id = xbt_str_parse_int(argv[1], "Invalid id: %s"); /* - unique id */ + xbt_assert(argc == 4, "The relay_runner function does not accept any parameter from the XML deployment file"); + int id = xbt_str_parse_int(argv[1], "Invalid id: %s"); /* - unique id */ double sleep_start_time = xbt_str_parse_double(argv[2], "Invalid sleep start parameter: %s"); /* - start time */ - double sleep_test_time = xbt_str_parse_double(argv[3], "Invalid sleep test parameter: %s"); /* - test time */ + double sleep_test_time = xbt_str_parse_double(argv[3], "Invalid sleep test parameter: %s"); /* - test time */ XBT_INFO("sleep_start_time : %f , sleep_test_time : %f", sleep_start_time, sleep_test_time); MSG_process_sleep(sleep_start_time); /* This process first sleeps for "start time" seconds. */ char mailbox[80]; - snprintf(mailbox,79, "receiver-%d", id); + snprintf(mailbox, 79, "receiver-%d", id); while (1) { msg_task_t task = NULL; msg_comm_t comm = MSG_task_irecv(&task, mailbox); /* Then it posts asynchronous receives (@ref MSG_task_irecv) and*/ XBT_INFO("Wait to receive a task"); - if (sleep_test_time > 0) { /* - if "test_time" is set to 0, wait on @ref MSG_comm_wait */ - while (MSG_comm_test(comm) == 0) { /* - Call @ref MSG_comm_test every "test_time" otherwise */ + if (sleep_test_time > 0) { /* - if "test_time" is set to 0, wait on @ref MSG_comm_wait */ + while (MSG_comm_test(comm) == 0) { /* - Call @ref MSG_comm_test every "test_time" otherwise */ MSG_process_sleep(sleep_test_time); } } else { @@ -106,19 +106,20 @@ static int receiver(int argc, char *argv[]) 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 msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); + "\tExample: %s msg_platform.xml msg_deployment.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("sender", sender); MSG_function_register("receiver", receiver); - MSG_launch_application(argv[2]);/* - Deploy the sender and receiver processes */ + MSG_launch_application(argv[2]); /* - Deploy the sender and receiver processes */ - msg_error_t res = MSG_main(); /* - Run the simulation */ + msg_error_t res = MSG_main(); /* - Run the simulation */ XBT_INFO("Simulation time %g", MSG_get_clock()); diff --git a/examples/msg/async-wait/async-wait.tesh b/teshsuite/msg/async-wait/async-wait.tesh similarity index 88% rename from examples/msg/async-wait/async-wait.tesh rename to teshsuite/msg/async-wait/async-wait.tesh index ad11802309..c68fb5a707 100644 --- a/examples/msg/async-wait/async-wait.tesh +++ b/teshsuite/msg/async-wait/async-wait.tesh @@ -2,7 +2,7 @@ p Test1 MSG_comm_test() with Sleep_sender > Sleep_receiver -$ $SG_TEST_EXENV ${bindir:=.}/async-wait ${srcdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/../msg/async-wait/async-wait_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ $SG_TEST_EXENV ${bindir:=.}/async-wait ${platfdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/async-wait_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 0.000000] (1:sender@Tremblay) sleep_start_time : 5.000000 , sleep_test_time : 0.100000 > [ 0.000000] (2:receiver@Ruby) sleep_start_time : 1.000000 , sleep_test_time : 0.100000 > [ 1.000000] (2:receiver@Ruby) Wait to receive a task @@ -29,7 +29,7 @@ $ $SG_TEST_EXENV ${bindir:=.}/async-wait ${srcdir:=.}/small_platform_fatpipe.xml p Test2 MSG_comm_test() with Sleep_sender < Sleep_receiver -$ $SG_TEST_EXENV ${bindir:=.}/async-wait ${srcdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/../msg/async-wait/async-wait2_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ $SG_TEST_EXENV ${bindir:=.}/async-wait ${platfdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/async-wait2_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 0.000000] (1:sender@Tremblay) sleep_start_time : 1.000000 , sleep_test_time : 0.100000 > [ 0.000000] (2:receiver@Ruby) sleep_start_time : 5.000000 , sleep_test_time : 0.100000 > [ 1.000000] (1:sender@Tremblay) Send to receiver-0 Task_0 @@ -56,7 +56,7 @@ $ $SG_TEST_EXENV ${bindir:=.}/async-wait ${srcdir:=.}/small_platform_fatpipe.xml p Test1 MSG_comm_wait() with Sleep_sender > Sleep_receiver -$ $SG_TEST_EXENV ${bindir:=.}/async-wait ${srcdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/../msg/async-wait/async-wait3_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ $SG_TEST_EXENV ${bindir:=.}/async-wait ${platfdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/async-wait3_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 0.000000] (1:sender@Tremblay) sleep_start_time : 5.000000 , sleep_test_time : 0.000000 > [ 0.000000] (2:receiver@Ruby) sleep_start_time : 1.000000 , sleep_test_time : 0.000000 > [ 1.000000] (2:receiver@Ruby) Wait to receive a task @@ -84,7 +84,7 @@ $ $SG_TEST_EXENV ${bindir:=.}/async-wait ${srcdir:=.}/small_platform_fatpipe.xml p Test2 MSG_comm_wait() with Sleep_sender < Sleep_receiver -$ $SG_TEST_EXENV ${bindir:=.}/async-wait ${srcdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/../msg/async-wait/async-wait4_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ $SG_TEST_EXENV ${bindir:=.}/async-wait ${platfdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/async-wait4_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 0.000000] (1:sender@Tremblay) sleep_start_time : 1.000000 , sleep_test_time : 0.000000 > [ 0.000000] (2:receiver@Ruby) sleep_start_time : 5.000000 , sleep_test_time : 0.000000 > [ 1.000000] (1:sender@Tremblay) Send to receiver-0 Task_0 diff --git a/examples/msg/async-wait/async-wait2_d.xml b/teshsuite/msg/async-wait/async-wait2_d.xml similarity index 100% rename from examples/msg/async-wait/async-wait2_d.xml rename to teshsuite/msg/async-wait/async-wait2_d.xml diff --git a/examples/msg/async-wait/async-wait3_d.xml b/teshsuite/msg/async-wait/async-wait3_d.xml similarity index 100% rename from examples/msg/async-wait/async-wait3_d.xml rename to teshsuite/msg/async-wait/async-wait3_d.xml diff --git a/examples/msg/async-wait/async-wait4_d.xml b/teshsuite/msg/async-wait/async-wait4_d.xml similarity index 100% rename from examples/msg/async-wait/async-wait4_d.xml rename to teshsuite/msg/async-wait/async-wait4_d.xml diff --git a/examples/msg/async-wait/async-wait_d.xml b/teshsuite/msg/async-wait/async-wait_d.xml similarity index 100% rename from examples/msg/async-wait/async-wait_d.xml rename to teshsuite/msg/async-wait/async-wait_d.xml diff --git a/examples/msg/async-waitall/async-waitall.c b/teshsuite/msg/async-waitall/async-waitall.c similarity index 71% rename from examples/msg/async-waitall/async-waitall.c rename to teshsuite/msg/async-waitall/async-waitall.c index c828b13c6d..b5866909e9 100644 --- a/examples/msg/async-waitall/async-waitall.c +++ b/teshsuite/msg/async-waitall/async-waitall.c @@ -7,28 +7,28 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_async_waitall, "Messages specific for this msg example"); -static int sender(int argc, char *argv[]) +static int sender(int argc, char* argv[]) { - xbt_assert(argc==5,"This function expects 4 parameters from the XML deployment file"); - long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s"); + xbt_assert(argc == 5, "This function expects 4 parameters from the XML deployment file"); + long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s"); double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s"); double task_comm_size = xbt_str_parse_double(argv[3], "Invalid communication size: %s"); - long receivers_count = xbt_str_parse_int(argv[4], "Invalid amount of receivers: %s"); + long receivers_count = xbt_str_parse_int(argv[4], "Invalid amount of receivers: %s"); - msg_comm_t *comm = xbt_new(msg_comm_t, number_of_tasks + receivers_count); + msg_comm_t* comm = xbt_new(msg_comm_t, number_of_tasks + receivers_count); for (int i = 0; i < number_of_tasks; i++) { char mailbox[80]; char taskname[80]; - snprintf(mailbox,79, "receiver-%ld", i % receivers_count); - snprintf(taskname,79, "Task_%d", i); + snprintf(mailbox, 79, "receiver-%ld", i % receivers_count); + snprintf(taskname, 79, "Task_%d", i); msg_task_t task = MSG_task_create(taskname, task_comp_size, task_comm_size, NULL); - comm[i] = MSG_task_isend(task, mailbox); + comm[i] = MSG_task_isend(task, mailbox); XBT_INFO("Send to receiver-%ld Task_%d", i % receivers_count, i); } for (int i = 0; i < receivers_count; i++) { char mailbox[80]; - snprintf(mailbox,79, "receiver-%ld", i % receivers_count); - msg_task_t task = MSG_task_create("finalize", 0, 0, 0); + snprintf(mailbox, 79, "receiver-%ld", i % receivers_count); + msg_task_t task = MSG_task_create("finalize", 0, 0, 0); comm[i + number_of_tasks] = MSG_task_isend(task, mailbox); XBT_INFO("Send to receiver-%ld finalize", i % receivers_count); } @@ -43,13 +43,13 @@ static int sender(int argc, char *argv[]) return 0; } -static int receiver(int argc, char *argv[]) +static int receiver(int argc, char* argv[]) { - xbt_assert(argc==2,"This function expects 1 parameter from the XML deployment file"); + xbt_assert(argc == 2, "This function expects 1 parameter from the XML deployment file"); int id = xbt_str_parse_int(argv[1], "Any process of this example must have a numerical name, not %s"); char mailbox[80]; - snprintf(mailbox,79, "receiver-%d", id); + snprintf(mailbox, 79, "receiver-%d", id); MSG_process_sleep(10); while (1) { @@ -74,11 +74,12 @@ static int receiver(int argc, char *argv[]) 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 msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); + "\tExample: %s msg_platform.xml msg_deployment.xml\n", + argv[0], argv[0]); MSG_create_environment(argv[1]); MSG_function_register("sender", sender); diff --git a/examples/msg/async-waitall/async-waitall.tesh b/teshsuite/msg/async-waitall/async-waitall.tesh similarity index 86% rename from examples/msg/async-waitall/async-waitall.tesh rename to teshsuite/msg/async-waitall/async-waitall.tesh index e6d3b38336..838c2e9952 100644 --- a/examples/msg/async-waitall/async-waitall.tesh +++ b/teshsuite/msg/async-waitall/async-waitall.tesh @@ -2,7 +2,7 @@ p Test1 MSG_comm_waitall() for sender ! output sort 19 -$ $SG_TEST_EXENV ${bindir:=.}/async-waitall ${srcdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/../msg/async-waitall/async-waitall_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ $SG_TEST_EXENV ${bindir:=.}/async-waitall ${platfdir:=.}/small_platform_fatpipe.xml ${srcdir:=.}/async-waitall_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 0.000000] (1:sender@Tremblay) Send to receiver-0 Task_0 > [ 0.000000] (1:sender@Tremblay) Send to receiver-0 Task_1 > [ 0.000000] (1:sender@Tremblay) Send to receiver-0 Task_2 diff --git a/examples/msg/async-waitall/async-waitall_d.xml b/teshsuite/msg/async-waitall/async-waitall_d.xml similarity index 100% rename from examples/msg/async-waitall/async-waitall_d.xml rename to teshsuite/msg/async-waitall/async-waitall_d.xml diff --git a/examples/msg/async-waitany/async-waitany.c b/teshsuite/msg/async-waitany/async-waitany.c similarity index 72% rename from examples/msg/async-waitany/async-waitany.c rename to teshsuite/msg/async-waitany/async-waitany.c index 95b92aa18d..2ae48e6d45 100644 --- a/examples/msg/async-waitany/async-waitany.c +++ b/teshsuite/msg/async-waitany/async-waitany.c @@ -7,14 +7,14 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_async_waitany, "Messages specific for this msg example"); -static int sender(int argc, char *argv[]) +static int sender(int argc, char* argv[]) { - xbt_assert(argc==6, "This function expects 5 parameters from the XML deployment file"); - long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s"); + xbt_assert(argc == 6, "This function expects 5 parameters from the XML deployment file"); + long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s"); double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s"); double task_comm_size = xbt_str_parse_double(argv[3], "Invalid communication size: %s"); - long receivers_count = xbt_str_parse_int(argv[4], "Invalid amount of receivers: %s"); - int diff_com = xbt_str_parse_int(argv[5], "Invalid value for diff_comm: %s"); + long receivers_count = xbt_str_parse_int(argv[4], "Invalid amount of receivers: %s"); + int diff_com = xbt_str_parse_int(argv[5], "Invalid value for diff_comm: %s"); xbt_dynar_t comms = xbt_dynar_new(sizeof(msg_comm_t), NULL); /* First pack the communications in the dynar */ @@ -23,8 +23,8 @@ static int sender(int argc, char *argv[]) char mailbox[80]; char taskname[80]; - snprintf(mailbox,79, "receiver-%ld", (i % receivers_count)); - snprintf(taskname,79, "Task_%d", i); + snprintf(mailbox, 79, "receiver-%ld", (i % receivers_count)); + snprintf(taskname, 79, "Task_%d", i); msg_task_t task = MSG_task_create(taskname, task_comp_size, task_comm_size / coef, NULL); msg_comm_t comm = MSG_task_isend(task, mailbox); xbt_dynar_push_as(comms, msg_comm_t, comm); @@ -41,8 +41,8 @@ static int sender(int argc, char *argv[]) /* Here we are waiting for the completion of all tasks */ for (int i = 0; i < receivers_count; i++) { - msg_task_t task = NULL; - msg_comm_t comm = MSG_task_irecv(&task, "finalize"); + msg_task_t task = NULL; + msg_comm_t comm = MSG_task_irecv(&task, "finalize"); msg_error_t res_wait = MSG_comm_wait(comm, -1); xbt_assert(res_wait == MSG_OK, "MSG_comm_wait failed"); MSG_comm_destroy(comm); @@ -53,21 +53,21 @@ static int sender(int argc, char *argv[]) return 0; } -static int receiver(int argc, char *argv[]) +static int receiver(int argc, char* argv[]) { - xbt_assert(argc==3, "This function expects 2 parameters from the XML deployment file"); - int id = xbt_str_parse_int(argv[1], "ID should be numerical, not %s"); - int task_amount = xbt_str_parse_int(argv[2], "Invalid amount of tasks: %s"); - msg_task_t *tasks = xbt_new(msg_task_t, task_amount); + xbt_assert(argc == 3, "This function expects 2 parameters from the XML deployment file"); + int id = xbt_str_parse_int(argv[1], "ID should be numerical, not %s"); + int task_amount = xbt_str_parse_int(argv[2], "Invalid amount of tasks: %s"); + msg_task_t* tasks = xbt_new(msg_task_t, task_amount); xbt_dynar_t comms = xbt_dynar_new(sizeof(msg_comm_t), NULL); char mailbox[80]; - snprintf(mailbox,79, "receiver-%d", id); + snprintf(mailbox, 79, "receiver-%d", id); MSG_process_sleep(10); for (int i = 0; i < task_amount; i++) { XBT_INFO("Wait to receive task %d", i); - tasks[i] = NULL; + tasks[i] = NULL; msg_comm_t comm = MSG_task_irecv(&tasks[i], mailbox); xbt_dynar_push_as(comms, msg_comm_t, comm); } @@ -94,11 +94,12 @@ static int receiver(int argc, char *argv[]) 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 msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); + "\tExample: %s msg_platform.xml msg_deployment.xml\n", + argv[0], argv[0]); MSG_create_environment(argv[1]); diff --git a/examples/msg/async-waitany/async-waitany.tesh b/teshsuite/msg/async-waitany/async-waitany.tesh similarity index 91% rename from examples/msg/async-waitany/async-waitany.tesh rename to teshsuite/msg/async-waitany/async-waitany.tesh index 97c19dd08d..b9f7384783 100644 --- a/examples/msg/async-waitany/async-waitany.tesh +++ b/teshsuite/msg/async-waitany/async-waitany.tesh @@ -3,7 +3,7 @@ p Testing the MSG_comm_waitany function ! output sort 19 -$ $SG_TEST_EXENV ${bindir:=.}/async-waitany ${srcdir:=.}/small_platform.xml ${srcdir:=.}/../msg/async-waitany/async-waitany_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ $SG_TEST_EXENV ${bindir:=.}/async-waitany ${platfdir:=.}/small_platform.xml ${srcdir:=.}/async-waitany_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 0.000000] (1:sender@Tremblay) Send to receiver-0 Task_0 comm_size 1000000.000000 > [ 0.000000] (1:sender@Tremblay) Send to receiver-1 Task_1 comm_size 1000000.000000 > [ 0.000000] (1:sender@Tremblay) Send to receiver-0 Task_2 comm_size 1000000.000000 diff --git a/examples/msg/async-waitany/async-waitany_d.xml b/teshsuite/msg/async-waitany/async-waitany_d.xml similarity index 100% rename from examples/msg/async-waitany/async-waitany_d.xml rename to teshsuite/msg/async-waitany/async-waitany_d.xml -- 2.20.1