From: Arnaud Giersch Date: Wed, 26 Jan 2011 12:39:08 +0000 (+0100) Subject: Use MSG_comm_waitall for communicator::flush(true). X-Git-Tag: v0.1~188^2~3 X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/commitdiff_plain/cd6b2539af2f8564684f287983ffb05bb0f7b285?hp=61c63b5df9b55aec7c072edb5b392569b215cb83 Use MSG_comm_waitall for communicator::flush(true). It is cleaner and, with SG 3.5, it makes a deadlock vanish. --- diff --git a/BUGS b/BUGS index ff54efc..e69de29 100644 --- a/BUGS +++ b/BUGS @@ -1,3 +0,0 @@ -./loba cluster1000.xml -N64 -L100 -i100 -a fair -T hcube -=> leads to deadlock (with stable) - diff --git a/communicator.cpp b/communicator.cpp index bcdce2f..e30d731 100644 --- a/communicator.cpp +++ b/communicator.cpp @@ -9,6 +9,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(comm); #include "misc.h" #include "options.h" +#include "simgrid_features.h" #include "tracing.h" #include "communicator.h" @@ -128,21 +129,14 @@ bool communicator::recv(message*& msg, m_host_t& from, double timeout) void communicator::flush(bool wait) { - using std::tr1::bind; - using std::tr1::placeholders::_1; - sent_comm.remove_if(comm_test_n_destroy); if (wait && !sent_comm.empty()) { - xbt_dynar_t comms = xbt_dynar_new(sizeof(msg_comm_t), NULL); - while (!sent_comm.empty()) { - std::for_each(sent_comm.begin(), sent_comm.end(), - bind(xbt_dynar_push, - comms, bind(misc::address(), _1))); - MSG_comm_waitany(comms); - xbt_dynar_reset(comms); - sent_comm.remove_if(comm_test_n_destroy); - } - xbt_dynar_free(&comms); + msg_comm_t comms[sent_comm.size()]; + std::copy(sent_comm.begin(), sent_comm.end(), comms); + MSG_comm_waitall(comms, sent_comm.size(), -1.0); + if (!MSG_WAIT_DESTROYS_COMMS) + std::for_each(sent_comm.begin(), sent_comm.end(), MSG_comm_destroy); + sent_comm.clear(); } } diff --git a/process.cpp b/process.cpp index 9959376..57c0661 100644 --- a/process.cpp +++ b/process.cpp @@ -315,10 +315,10 @@ void process::finalize() std::for_each(neigh.begin(), neigh.end(), bind(&process::finalize1, this, _1)); - DEBUG2("wait for CLOSE from %lu neighbor%s", - (unsigned long )neigh.size(), ESSE(neigh.size())); while (may_receive()) { comm.flush(false); + DEBUG2("waiting for %d CTRL and %d DATA CLOSE", + ctrl_close_pending, data_close_pending); receive(-1.0); }