From 3b2ab08f23278e55db69b18e3ec5bce1c73df322 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Wed, 12 Feb 2020 06:01:32 +0100 Subject: [PATCH] this test has been converted --- teshsuite/msg/CMakeLists.txt | 3 +- teshsuite/msg/async-waitany/async-waitany.c | 117 ------------------ .../msg/async-waitany/async-waitany.tesh | 34 ----- .../msg/async-waitany/async-waitany_d.xml | 21 ---- 4 files changed, 1 insertion(+), 174 deletions(-) delete mode 100644 teshsuite/msg/async-waitany/async-waitany.c delete mode 100644 teshsuite/msg/async-waitany/async-waitany.tesh delete mode 100644 teshsuite/msg/async-waitany/async-waitany_d.xml diff --git a/teshsuite/msg/CMakeLists.txt b/teshsuite/msg/CMakeLists.txt index d083580469..96351f5765 100644 --- a/teshsuite/msg/CMakeLists.txt +++ b/teshsuite/msg/CMakeLists.txt @@ -1,5 +1,5 @@ # C examples -foreach(x async-wait async-waitany +foreach(x async-wait cloud-capping cloud-migration cloud-two-tasks cloud-simple get_sender host_on_off host_on_off_recv process-lifetime @@ -64,7 +64,6 @@ set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/ap ${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-waitany/async-waitany_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/io-file-remote/io-file-remote_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/platform-properties/platform-properties_d.xml ${CMAKE_CURRENT_SOURCE_DIR}/process-lifetime/baseline_d.xml diff --git a/teshsuite/msg/async-waitany/async-waitany.c b/teshsuite/msg/async-waitany/async-waitany.c deleted file mode 100644 index 49d75230f0..0000000000 --- a/teshsuite/msg/async-waitany/async-waitany.c +++ /dev/null @@ -1,117 +0,0 @@ -/* Copyright (c) 2010-2020. 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 "simgrid/msg.h" - -#include /* snprintf */ - -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_async_waitany, "Messages specific for this msg example"); - -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"); - 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"); - - xbt_dynar_t comms = xbt_dynar_new(sizeof(msg_comm_t), NULL); - /* First pack the communications in the dynar */ - for (int i = 0; i < number_of_tasks; i++) { - double coef = (diff_com == 0) ? 1 : (i + 1); - - char mailbox[80]; - char taskname[80]; - 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); - XBT_INFO("Send to receiver-%ld %s comm_size %f", i % receivers_count, taskname, task_comm_size / coef); - } - - /* Here we are waiting for the completion of all communications */ - while (xbt_dynar_is_empty(comms) == 0) { - msg_comm_t comm; - xbt_dynar_remove_at(comms, MSG_comm_waitany(comms), &comm); - MSG_comm_destroy(comm); - } - xbt_dynar_free(&comms); - - /* 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_error_t res_wait = MSG_comm_wait(comm, -1); - xbt_assert(res_wait == MSG_OK, "MSG_comm_wait failed"); - MSG_comm_destroy(comm); - MSG_task_destroy(task); - } - - XBT_INFO("Goodbye now!"); - return 0; -} - -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_dynar_t comms = xbt_dynar_new(sizeof(msg_comm_t), NULL); - - char mailbox[80]; - 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; - msg_comm_t comm = MSG_task_irecv(&tasks[i], mailbox); - xbt_dynar_push_as(comms, msg_comm_t, comm); - } - - /* Here we are waiting for the receiving of all communications */ - while (!xbt_dynar_is_empty(comms)) { - msg_comm_t comm; - // MSG_comm_waitany returns the rank of the comm that just ended. Remove it. - xbt_dynar_remove_at(comms, MSG_comm_waitany(comms), &comm); - msg_task_t task = MSG_comm_get_task(comm); - MSG_comm_destroy(comm); - XBT_INFO("Processing \"%s\"", MSG_task_get_name(task)); - MSG_task_execute(task); - XBT_INFO("\"%s\" done", MSG_task_get_name(task)); - msg_error_t err = MSG_task_destroy(task); - xbt_assert(err == MSG_OK, "MSG_task_destroy failed"); - } - xbt_dynar_free(&comms); - xbt_free(tasks); - - /* Here we tell to sender that all tasks are done */ - MSG_task_send(MSG_task_create(NULL, 0, 0, NULL), "finalize"); - XBT_INFO("I'm done. See you!"); - return 0; -} - -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]); - - MSG_create_environment(argv[1]); - - MSG_function_register("sender", sender); - MSG_function_register("receiver", receiver); - MSG_launch_application(argv[2]); - - msg_error_t res = MSG_main(); - - XBT_INFO("Simulation time %g", MSG_get_clock()); - - return res != MSG_OK; -} diff --git a/teshsuite/msg/async-waitany/async-waitany.tesh b/teshsuite/msg/async-waitany/async-waitany.tesh deleted file mode 100644 index 4027e42175..0000000000 --- a/teshsuite/msg/async-waitany/async-waitany.tesh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env tesh - -p Testing the MSG_comm_waitany function - -! output sort 19 -$ ${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 -> [ 0.000000] (1:sender@Tremblay) Send to receiver-1 Task_3 comm_size 1000000.000000 -> [ 0.000000] (1:sender@Tremblay) Send to receiver-0 Task_4 comm_size 1000000.000000 -> [ 0.000000] (1:sender@Tremblay) Send to receiver-1 Task_5 comm_size 1000000.000000 -> [ 10.000000] (2:receiver@Fafard) Wait to receive task 0 -> [ 10.000000] (2:receiver@Fafard) Wait to receive task 1 -> [ 10.000000] (2:receiver@Fafard) Wait to receive task 2 -> [ 10.000000] (3:receiver@Jupiter) Wait to receive task 0 -> [ 10.000000] (3:receiver@Jupiter) Wait to receive task 1 -> [ 10.000000] (3:receiver@Jupiter) Wait to receive task 2 -> [ 10.423774] (2:receiver@Fafard) Processing "Task_4" -> [ 10.469435] (3:receiver@Jupiter) Processing "Task_5" -> [ 11.079116] (2:receiver@Fafard) "Task_4" done -> [ 11.079116] (2:receiver@Fafard) Processing "Task_0" -> [ 11.124778] (3:receiver@Jupiter) "Task_5" done -> [ 11.124778] (3:receiver@Jupiter) Processing "Task_1" -> [ 11.734459] (2:receiver@Fafard) "Task_0" done -> [ 11.734459] (2:receiver@Fafard) Processing "Task_2" -> [ 11.780120] (3:receiver@Jupiter) "Task_1" done -> [ 11.780120] (3:receiver@Jupiter) Processing "Task_3" -> [ 12.389801] (2:receiver@Fafard) "Task_2" done -> [ 12.415509] (2:receiver@Fafard) I'm done. See you! -> [ 12.435462] (3:receiver@Jupiter) "Task_3" done -> [ 12.454477] (0:maestro@) Simulation time 12.4545 -> [ 12.454477] (1:sender@Tremblay) Goodbye now! -> [ 12.454477] (3:receiver@Jupiter) I'm done. See you! diff --git a/teshsuite/msg/async-waitany/async-waitany_d.xml b/teshsuite/msg/async-waitany/async-waitany_d.xml deleted file mode 100644 index 0bf5bdd122..0000000000 --- a/teshsuite/msg/async-waitany/async-waitany_d.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - -- 2.20.1