Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
implement s4u::Comm::test_any() (fix #194)
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 26 Dec 2017 23:22:32 +0000 (00:22 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 26 Dec 2017 23:22:35 +0000 (00:22 +0100)
It's not tested, sorry @henricasanova.

ChangeLog
include/simgrid/s4u/Comm.hpp
src/s4u/s4u_comm.cpp

index e4c7963..b9f4bdd 100644 (file)
--- 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
index ac66a7a..7c615fe 100644 (file)
@@ -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<CommPtr> * 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
index 02d7492..ac55817 100644 (file)
@@ -136,6 +136,16 @@ Activity* Comm::wait(double timeout)
   }
   return this;
 }
+int Comm::test_any(std::vector<CommPtr>* comms)
+{
+  smx_activity_t* array = static_cast<smx_activity_t*>(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<size_t>(comms->size()));
+  free(array);
+  return res;
+}
 
 Activity* Comm::detach()
 {