From 201a288a0907c8c80037d719412fb139d67fe9c0 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 22 Jul 2023 01:08:54 +0200 Subject: [PATCH] Remove C test exec-waitany and deprecate the last exec-waitany functions --- MANIFEST.in | 2 - examples/c/CMakeLists.txt | 4 +- examples/c/exec-waitany/exec-waitany.c | 77 ----------------------- examples/c/exec-waitany/exec-waitany.tesh | 21 ------- include/simgrid/exec.h | 9 +-- 5 files changed, 7 insertions(+), 106 deletions(-) delete mode 100644 examples/c/exec-waitany/exec-waitany.c delete mode 100644 examples/c/exec-waitany/exec-waitany.tesh diff --git a/MANIFEST.in b/MANIFEST.in index 7ec687908c..e2a2725404 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -110,8 +110,6 @@ include examples/c/exec-dvfs/exec-dvfs.c include examples/c/exec-dvfs/exec-dvfs.tesh include examples/c/exec-remote/exec-remote.c include examples/c/exec-remote/exec-remote.tesh -include examples/c/exec-waitany/exec-waitany.c -include examples/c/exec-waitany/exec-waitany.tesh include examples/c/io-disk-raw/io-disk-raw.c include examples/c/io-disk-raw/io-disk-raw.tesh include examples/c/io-file-remote/io-file-remote.c diff --git a/examples/c/CMakeLists.txt b/examples/c/CMakeLists.txt index 89060add35..13349f7a61 100644 --- a/examples/c/CMakeLists.txt +++ b/examples/c/CMakeLists.txt @@ -9,7 +9,7 @@ foreach(x comm-pingpong comm-wait comm-waitall comm-waitany cloud-capping cloud-masterworker cloud-migration cloud-simple dht-pastry - exec-async exec-basic exec-dvfs exec-remote exec-waitany + exec-async exec-basic exec-dvfs exec-remote energy-exec energy-exec-ptask energy-vm io-disk-raw io-file-remote io-file-system platform-failures platform-properties @@ -102,7 +102,7 @@ foreach(x comm-pingpong comm-wait comm-waitall comm-waitany cloud-capping cloud-masterworker cloud-migration cloud-simple dht-kademlia dht-pastry - exec-async exec-basic exec-dvfs exec-remote exec-waitany + exec-async exec-basic exec-dvfs exec-remote energy-exec energy-exec-ptask energy-vm io-disk-raw io-file-remote io-file-system platform-failures platform-properties diff --git a/examples/c/exec-waitany/exec-waitany.c b/examples/c/exec-waitany/exec-waitany.c deleted file mode 100644 index 2dd9d86471..0000000000 --- a/examples/c/exec-waitany/exec-waitany.c +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright (c) 2019-2023. 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/actor.h" -#include "simgrid/engine.h" -#include "simgrid/exec.h" -#include "simgrid/host.h" - -#include "xbt/log.h" -#include "xbt/sysdep.h" - -XBT_LOG_NEW_DEFAULT_CATEGORY(exec_waitany, "Messages specific for this example"); - -static void worker(int argc, char* argv[]) -{ - xbt_assert(argc > 1); - int with_timeout = !strcmp(argv[1], "true"); - - /* Vector in which we store all pending executions*/ - sg_exec_t* pending_execs = xbt_malloc(sizeof(sg_exec_t) * 3); - int pending_execs_count = 0; - - for (int i = 0; i < 3; i++) { - char* name = bprintf("Exec-%d", i); - double amount = (6 * (i % 2) + i + 1) * sg_host_get_speed(sg_host_self()); - - sg_exec_t exec = sg_actor_exec_init(amount); - sg_exec_set_name(exec, name); - pending_execs[pending_execs_count++] = exec; - sg_exec_start(exec); - - XBT_INFO("Activity %s has started for %.0f seconds", name, amount / sg_host_get_speed(sg_host_self())); - free(name); - } - - /* Now that executions were initiated, wait for their completion, in order of termination. - * - * This loop waits for first terminating execution with wait_any() and remove it with erase(), until all execs are - * terminated. - */ - while (pending_execs_count > 0) { - ssize_t pos; - if (with_timeout) - pos = sg_exec_wait_any_for(pending_execs, pending_execs_count, 4); - else - pos = sg_exec_wait_any(pending_execs, pending_execs_count); - - if (pos < 0) { - XBT_INFO("Do not wait any longer for an activity (timeout received)"); - pending_execs_count = 0; - } else { - XBT_INFO("Activity at position %zd is complete", pos); - memmove(pending_execs + pos, pending_execs + pos + 1, sizeof(sg_exec_t) * (pending_execs_count - pos - 1)); - pending_execs_count--; - } - XBT_INFO("%d activities remain pending", pending_execs_count); - } - - xbt_free(pending_execs); -} - -int main(int argc, char* argv[]) -{ - simgrid_init(&argc, argv); - simgrid_load_platform(argv[1]); - - const char* worker_argv[] = {"worker", "false"}; - sg_actor_create_("worker", sg_host_by_name("Tremblay"), worker, 2, worker_argv); - - worker_argv[1] = "true"; - sg_actor_create_("worker_timeout", sg_host_by_name("Tremblay"), worker, 2, worker_argv); - - simgrid_run(); - return 0; -} diff --git a/examples/c/exec-waitany/exec-waitany.tesh b/examples/c/exec-waitany/exec-waitany.tesh deleted file mode 100644 index 57fb2bab93..0000000000 --- a/examples/c/exec-waitany/exec-waitany.tesh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env tesh - -$ ${bindir:=.}/c-exec-waitany ${platfdir}/multicore_machine.xml "--log=root.fmt:[%10.6r]%e[%14P]%e%m%n" -> [ 0.000000] [ worker] Activity Exec-0 has started for 1 seconds -> [ 0.000000] [worker_timeout] Activity Exec-0 has started for 1 seconds -> [ 0.000000] [ worker] Activity Exec-1 has started for 8 seconds -> [ 0.000000] [worker_timeout] Activity Exec-1 has started for 8 seconds -> [ 0.000000] [ worker] Activity Exec-2 has started for 3 seconds -> [ 0.000000] [worker_timeout] Activity Exec-2 has started for 3 seconds -> [ 1.000000] [worker_timeout] Activity at position 0 is complete -> [ 1.000000] [worker_timeout] 2 activities remain pending -> [ 1.000000] [ worker] Activity at position 0 is complete -> [ 1.000000] [ worker] 2 activities remain pending -> [ 3.000000] [worker_timeout] Activity at position 1 is complete -> [ 3.000000] [worker_timeout] 1 activities remain pending -> [ 3.000000] [ worker] Activity at position 1 is complete -> [ 3.000000] [ worker] 1 activities remain pending -> [ 7.000000] [worker_timeout] Do not wait any longer for an activity (timeout received) -> [ 7.000000] [worker_timeout] 0 activities remain pending -> [ 8.000000] [ worker] Activity at position 0 is complete -> [ 8.000000] [ worker] 0 activities remain pending diff --git a/include/simgrid/exec.h b/include/simgrid/exec.h index 7779a5ab3b..565684c3e9 100644 --- a/include/simgrid/exec.h +++ b/include/simgrid/exec.h @@ -26,10 +26,11 @@ XBT_PUBLIC void sg_exec_cancel(sg_exec_t exec); XBT_PUBLIC int sg_exec_test(sg_exec_t exec); XBT_PUBLIC sg_error_t sg_exec_wait(sg_exec_t exec); XBT_PUBLIC sg_error_t sg_exec_wait_for(sg_exec_t exec, double timeout); -// XBT_ATTRIB_DEPRECATED_v339("Please use sg_activity_set instead") TODO: C bindings of ActivitySet -XBT_PUBLIC ssize_t sg_exec_wait_any_for(sg_exec_t* execs, size_t count, double timeout); -// XBT_ATTRIB_DEPRECATED_v339("Please use sg_activity_set instead") TODO: C bindings of ActivitySet -XBT_PUBLIC ssize_t sg_exec_wait_any(sg_exec_t* execs, size_t count); + +XBT_ATTRIB_DEPRECATED_v339("Please use sg_activity_set_t instead") XBT_PUBLIC ssize_t + sg_exec_wait_any_for(sg_exec_t* execs, size_t count, double timeout); +XBT_ATTRIB_DEPRECATED_v339("Please use sg_activity_set_t instead") XBT_PUBLIC ssize_t + sg_exec_wait_any(sg_exec_t* execs, size_t count); SG_END_DECL -- 2.20.1