From 787c3df2b6b7b5a64b7459b7f5932e5ccb7b0933 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Wed, 27 Dec 2017 00:22:32 +0100 Subject: [PATCH] implement s4u::Comm::test_any() (fix #194) It's not tested, sorry @henricasanova. --- ChangeLog | 1 + include/simgrid/s4u/Comm.hpp | 2 ++ src/s4u/s4u_comm.cpp | 10 ++++++++++ 3 files changed, 13 insertions(+) diff --git a/ChangeLog b/ChangeLog index e4c7963152..b9f4bdd631 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ SimGrid (3.19) NOT RELEASED YET (target: March 20 2018, 16:15:27 UTC) S4U - Execution->setHost() can be called after start() to migrate it. + - Comm::test_any() is now implemented. Fixed bugs: - #245: migrating an actor does not migrate its execution diff --git a/include/simgrid/s4u/Comm.hpp b/include/simgrid/s4u/Comm.hpp index ac66a7acd6..7c615fe215 100644 --- a/include/simgrid/s4u/Comm.hpp +++ b/include/simgrid/s4u/Comm.hpp @@ -64,6 +64,8 @@ public: comm->wait(); } } + /*! take a vector s4u::CommPtr and return the rank of the first finished one (or -1 if none is done). */ + static int test_any(std::vector * comms); /** Creates (but don't start) an async send to the mailbox @p dest */ XBT_ATTRIB_DEPRECATED_v320("Use Mailbox::put_init(): v3.20 will turn this warning into an error.") static CommPtr diff --git a/src/s4u/s4u_comm.cpp b/src/s4u/s4u_comm.cpp index 02d7492d5b..ac5581783f 100644 --- a/src/s4u/s4u_comm.cpp +++ b/src/s4u/s4u_comm.cpp @@ -136,6 +136,16 @@ Activity* Comm::wait(double timeout) } return this; } +int Comm::test_any(std::vector* comms) +{ + smx_activity_t* array = static_cast(malloc(sizeof(smx_activity_t) * comms->size())); + for (unsigned int i = 0; i < comms->size(); i++) { + array[i] = comms->at(i)->pimpl_; + } + int res = simcall_comm_testany(array, static_cast(comms->size())); + free(array); + return res; +} Activity* Comm::detach() { -- 2.20.1