Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'stable'
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 31 Jan 2022 07:50:57 +0000 (08:50 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 31 Jan 2022 07:50:57 +0000 (08:50 +0100)
13 files changed:
CMakeLists.txt
ChangeLog
NEWS
docs/source/conf.py
setup.py
sonar-project.properties
src/instr/instr_private.hpp
src/smpi/bindings/smpi_pmpi_request.cpp
src/smpi/include/smpi_comm.hpp
src/smpi/include/smpi_request.hpp
src/smpi/internals/smpi_replay.cpp
src/smpi/mpi/smpi_comm.cpp
src/smpi/mpi/smpi_request.cpp

index 1d6874f..6d51656 100644 (file)
@@ -2,7 +2,7 @@
 
 set(SIMGRID_VERSION_MAJOR "3")
 set(SIMGRID_VERSION_MINOR "30")
-set(SIMGRID_VERSION_PATCH "0") # odd => git branch; even => stable release or released snapshot
+set(SIMGRID_VERSION_PATCH "1") # odd => git branch; even => stable release or released snapshot
 
 if(${SIMGRID_VERSION_PATCH} EQUAL "0")
   set(release_version "${SIMGRID_VERSION_MAJOR}.${SIMGRID_VERSION_MINOR}")
index 42cd05a..581d490 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,5 @@
+SimGrid (3.30.1) NOT RELEASED YET (v3.31 expected March 20. 2022, 15:33 UTC)
+
 ----------------------------------------------------------------------------
 
 SimGrid (3.30) January 30. 2022.
diff --git a/NEWS b/NEWS
index 5361f35..2cb98eb 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,11 @@
+                    _               _____  _____ _
+__   _____ _ __ ___(_) ___  _ __   |___ / |___ // |
+\ \ / / _ \ '__/ __| |/ _ \| '_ \    |_ \   |_ \| |
+ \ V /  __/ |  \__ \ | (_) | | | |  ___) | ___) | |
+  \_/ \___|_|  |___/_|\___/|_| |_| |____(_)____/|_|
+               (unreleased)
+
+
                     _               _____  _____  ___
 __   _____ _ __ ___(_) ___  _ __   |___ / |___ / / _ \
 \ \ / / _ \ '__/ __| |/ _ \| '_ \    |_ \   |_ \| | | |
@@ -7,7 +15,7 @@ __   _____ _ __ ___(_) ___  _ __   |___ / |___ / / _ \
 
 The Sunday Bloody Sunday release.
 
-  * SimDAG is finally removed, fully superseeded by S4U.
+  * SimDAG is finally removed, fully superseded by S4U.
   * New documentation on calibrating MPI.
   * The Algorithms tutorial can now be taken in Python.
   * (+ many bug fixes and internal refactoring)
index 7be3c94..2be4218 100644 (file)
@@ -36,7 +36,7 @@ copyright = u'2002-2022, The SimGrid Team'
 author = u'The SimGrid Team'
 
 # The short X.Y version
-version = u'3.30'
+version = u'3.30.1'
 
 # -- General configuration ---------------------------------------------------
 
index d8f3323..22d45d2 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -88,7 +88,7 @@ class CMakeBuild(build_ext):
 
 setup(
     name='simgrid',
-    version='3.30',
+    version='3.30.1',
     author='Da SimGrid Team',
     author_email='simgrid-devel@lists.gforge.inria.fr',
     description='Toolkit for scalable simulation of distributed applications',
index 42c7ccf..8b097f4 100644 (file)
@@ -4,7 +4,7 @@
 sonar.organization=simgrid
 sonar.projectKey=simgrid_simgrid
 sonar.projectName=SimGrid
-sonar.projectVersion=3.30
+sonar.projectVersion=3.30.1
 
 sonar.links.homepage=https://simgrid.org
 sonar.links.issue=https://framagit.org/simgrid/simgrid/issues
index 33516a3..40d2e07 100644 (file)
@@ -205,7 +205,7 @@ class WaitTIData : public TIData {
   int tag_;
 
 public:
-  WaitTIData(int src, int dest, int tag) : TIData("wait"), src_(src), dest_(dest), tag_(tag){};
+  WaitTIData(std::string name, int src, int dest, int tag) : TIData(name), src_(src), dest_(dest), tag_(tag){};
 
   std::string print() override
   {
index a41a306..527e60b 100644 (file)
@@ -464,7 +464,9 @@ int PMPI_Test(MPI_Request * request, int *flag, MPI_Status * status)
   } else {
     aid_t my_proc_id = ((*request)->comm() != MPI_COMM_NULL) ? simgrid::s4u::this_actor::get_pid() : -1;
 
-    TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("test"));
+    TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::WaitTIData("test", MPI_COMM_WORLD->group()->rank((*request)->src()),
+                                             MPI_COMM_WORLD->group()->rank((*request)->dst()),
+                                            (*request)->tag()));;
     retval = simgrid::smpi::Request::test(request,status, flag);
 
     TRACE_smpi_comm_out(my_proc_id);
@@ -599,7 +601,7 @@ int PMPI_Wait(MPI_Request * request, MPI_Status * status)
 
     aid_t my_proc_id = (*request)->comm() != MPI_COMM_NULL ? simgrid::s4u::this_actor::get_pid() : -1;
     TRACE_smpi_comm_in(my_proc_id, __func__,
-                       new simgrid::instr::WaitTIData(MPI_COMM_WORLD->group()->rank((*request)->src()),
+                       new simgrid::instr::WaitTIData("wait", MPI_COMM_WORLD->group()->rank((*request)->src()),
                                                       MPI_COMM_WORLD->group()->rank((*request)->dst()),
                                                       (*request)->tag()));
 
index 7ef18c9..d8dd8e8 100644 (file)
@@ -40,6 +40,8 @@ class Comm : public F2C, public Keyval{
   MPI_Errhandler errhandler_ =  _smpi_cfg_default_errhandler_is_error ? MPI_ERRORS_ARE_FATAL : MPI_ERRORS_RETURN;;
   MPI_Errhandler* errhandlers_ = nullptr; //for MPI_COMM_WORLD only
 
+  std::unordered_map<std::string, unsigned int> sent_messages_;
+  std::unordered_map<std::string, unsigned int> recv_messages_;
 public:
   static std::unordered_map<int, smpi_key_elem> keyvals_;
   static int keyval_id_;
@@ -90,6 +92,11 @@ public:
   void remove_rma_win(MPI_Win win);
   void finish_rma_calls() const;
   MPI_Comm split_type(int type, int key, const Info* info);
+  unsigned int get_sent_messages_count(int src, int dst, int tag);
+  void increment_sent_messages_count(int src, int dst, int tag);
+  unsigned int get_received_messages_count(int src, int dst, int tag);
+  void increment_received_messages_count(int src, int dst, int tag);
+
 };
 
 } // namespace smpi
index e3a3089..a91b6ab 100644 (file)
@@ -48,6 +48,7 @@ class Request : public F2C {
   bool detached_;
   MPI_Request detached_sender_;
   int refcount_;
+  unsigned int message_id_;
   MPI_Op op_;
   std::unique_ptr<smpi_mpi_generalized_request_funcs_t> generalized_funcs;
   std::vector<MPI_Request> nbc_requests_;
index a45fd2a..8ea0c90 100644 (file)
@@ -433,7 +433,7 @@ void WaitAction::kernel(simgrid::xbt::ReplayAction& action)
   // MPI_REQUEST_NULL by Request::wait!
   bool is_wait_for_receive = (request->flags() & MPI_REQ_RECV);
 
-  TRACE_smpi_comm_in(get_pid(), __func__, new simgrid::instr::WaitTIData(args.src, args.dst, args.tag));
+  TRACE_smpi_comm_in(get_pid(), __func__, new simgrid::instr::WaitTIData("wait", args.src, args.dst, args.tag));
 
   MPI_Status status;
   Request::wait(&request, &status);
@@ -532,7 +532,7 @@ void TestAction::kernel(simgrid::xbt::ReplayAction&)
   // Different times in traced application and replayed version may lead to this
   // In this case, ignore the extra calls.
   if (request != MPI_REQUEST_NULL) {
-    TRACE_smpi_comm_in(get_pid(), __func__, new simgrid::instr::NoOpTIData("test"));
+    TRACE_smpi_comm_in(get_pid(), __func__, new simgrid::instr::WaitTIData("test", args.src, args.dst, args.tag));
 
     MPI_Status status;
     int flag = 0;
index 193d88b..683a64a 100644 (file)
@@ -360,7 +360,7 @@ void Comm::unref(Comm* comm){
       simgrid::smpi::Info::unref(comm->info_);
     if(comm->errhandlers_!=nullptr){
       for (int i=0; i<comm->size(); i++)
-       if (comm->errhandlers_[i]!=MPI_ERRHANDLER_NULL)
+        if (comm->errhandlers_[i]!=MPI_ERRHANDLER_NULL)
           simgrid::smpi::Errhandler::unref(comm->errhandlers_[i]);
       delete[] comm->errhandlers_;
     } else if (comm->errhandler_ != MPI_ERRHANDLER_NULL)
@@ -630,5 +630,29 @@ MPI_Comm Comm::split_type(int type, int /*key*/, const Info*)
   }
 }
 
+static inline std::string hash_message(int src, int dst, int tag){
+  return std::to_string(tag) + '_' + std::to_string(src) + '_' + std::to_string(dst);
+}
+
+unsigned int Comm::get_sent_messages_count(int src, int dst, int tag)
+{
+  return sent_messages_[hash_message(src, dst, tag)];
+}
+
+void Comm::increment_sent_messages_count(int src, int dst, int tag)
+{
+  sent_messages_[hash_message(src, dst, tag)]++;
+}
+
+unsigned int Comm::get_received_messages_count(int src, int dst, int tag)
+{
+  return recv_messages_[hash_message(src, dst, tag)];
+}
+
+void Comm::increment_received_messages_count(int src, int dst, int tag)
+{
+  recv_messages_[hash_message(src, dst, tag)]++;
+}
+
 } // namespace smpi
 } // namespace simgrid
index 2b54eac..07b98cb 100644 (file)
@@ -69,6 +69,7 @@ Request::Request(const void* buf, int count, MPI_Datatype datatype, aid_t src, a
     refcount_ = 1;
   else
     refcount_ = 0;
+  message_id_ = 0;
   init_buffer(count);
   this->add_f();
 }
@@ -146,8 +147,6 @@ bool Request::match_common(MPI_Request req, MPI_Request sender, MPI_Request rece
       if (receiver->real_size_ < sender->real_size_){
         XBT_DEBUG("Truncating message - should not happen: receiver size : %zu < sender size : %zu", receiver->real_size_, sender->real_size_);
         receiver->truncated_ = true;
-      } else if (receiver->real_size_ > sender->real_size_){
-        receiver->real_size_=sender->real_size_;
       }
     }
     //0-sized datatypes/counts should not interfere and match
@@ -186,7 +185,24 @@ bool Request::match_recv(void* a, void* b, simgrid::kernel::activity::CommImpl*)
 {
   auto ref = static_cast<MPI_Request>(a);
   auto req = static_cast<MPI_Request>(b);
-  return match_common(req, req, ref);
+  bool match = match_common(req, req, ref);
+  if (match && (ref->comm_ != MPI_COMM_UNINITIALIZED) && !ref->comm_->is_smp_comm()){
+    if (ref->comm_->get_received_messages_count(ref->comm_->group()->rank(req->src_), ref->comm_->group()->rank(req->dst_), req->tag_) == req->message_id_ ){
+      if (((ref->flags_ & MPI_REQ_PROBE) == 0 ) && ((req->flags_ & MPI_REQ_PROBE) == 0)){
+        XBT_DEBUG("increasing count in comm %p, which was %u from pid %ld, to pid %ld with tag %d", ref->comm_, ref->comm_->get_received_messages_count(ref->comm_->group()->rank(req->src_), ref->comm_->group()->rank(req->dst_), req->tag_), req->src_, req->dst_, req->tag_);
+        ref->comm_->increment_received_messages_count(ref->comm_->group()->rank(req->src_), ref->comm_->group()->rank(req->dst_), req->tag_);
+        if (ref->real_size_ > req->real_size_){
+          ref->real_size_=req->real_size_;
+        }
+      }
+    } else {
+      match = false;
+      req->flags_ &= ~MPI_REQ_MATCHED;
+      ref->detached_sender_=nullptr;
+      XBT_DEBUG("Refusing to match message, as its ID is not the one I expect. in comm %p, %u != %u, from pid %ld to pid %ld, with tag %d",ref->comm_, ref->comm_->get_received_messages_count(ref->comm_->group()->rank(req->src_), ref->comm_->group()->rank(req->dst_), req->tag_), req->message_id_ , req->src_, req->dst_, req->tag_);
+    }
+  }
+  return match;
 }
 
 bool Request::match_send(void* a, void* b, simgrid::kernel::activity::CommImpl*)
@@ -444,6 +460,9 @@ void Request::start()
     if (smpi_cfg_async_small_thresh() != 0 || (flags_ & MPI_REQ_RMA) != 0)
       mut->lock();
 
+    bool is_probe = ((flags_ & MPI_REQ_PROBE) != 0);
+    flags_ |= MPI_REQ_PROBE;
+
     if (smpi_cfg_async_small_thresh() == 0 && (flags_ & MPI_REQ_RMA) == 0) {
       mailbox = process->mailbox();
     } else if (((flags_ & MPI_REQ_RMA) != 0) || static_cast<int>(size_) < smpi_cfg_async_small_thresh()) {
@@ -463,7 +482,7 @@ void Request::start()
           mailbox = process->mailbox_small();
         }
       } else {
-        XBT_DEBUG("yes there was something for us in the large mailbox");
+        XBT_DEBUG("yes there was something for us in the small mailbox");
       }
     } else {
       mailbox = process->mailbox_small();
@@ -477,6 +496,8 @@ void Request::start()
         XBT_DEBUG("yes there was something for us in the small mailbox");
       }
     }
+    if(!is_probe)
+      flags_ &= ~MPI_REQ_PROBE;
 
     action_   = simcall_comm_irecv(
         process->get_actor()->get_impl(), mailbox->get_impl(), buf_, &real_size_, &match_recv,
@@ -492,6 +513,9 @@ void Request::start()
       TRACE_smpi_send(src_, src_, dst_, tag_, size_);
     this->print_request("New send");
 
+    message_id_=comm_->get_sent_messages_count(comm_->group()->rank(src_), comm_->group()->rank(dst_), tag_);
+    comm_->increment_sent_messages_count(comm_->group()->rank(src_), comm_->group()->rank(dst_), tag_);
+
     void* buf = buf_;
     if ((flags_ & MPI_REQ_SSEND) == 0 &&
         ((flags_ & MPI_REQ_RMA) != 0 || (flags_ & MPI_REQ_BSEND) != 0 ||
@@ -541,6 +565,9 @@ void Request::start()
     if (not(smpi_cfg_async_small_thresh() != 0 || (flags_ & MPI_REQ_RMA) != 0)) {
       mailbox = process->mailbox();
     } else if (((flags_ & MPI_REQ_RMA) != 0) || static_cast<int>(size_) < smpi_cfg_async_small_thresh()) { // eager mode
+      bool is_probe = ((flags_ & MPI_REQ_PROBE) != 0);
+      flags_ |= MPI_REQ_PROBE;
+
       mailbox = process->mailbox();
       XBT_DEBUG("Is there a corresponding recv already posted in the large mailbox %s?", mailbox->get_cname());
       simgrid::kernel::activity::ActivityImplPtr action = mailbox->iprobe(1, &match_send, static_cast<void*>(this));
@@ -562,6 +589,8 @@ void Request::start()
       } else {
         XBT_DEBUG("Yes there was something for us in the large mailbox");
       }
+      if(!is_probe)
+        flags_ &= ~MPI_REQ_PROBE;
     } else {
       mailbox = process->mailbox();
       XBT_DEBUG("Send request %p is in the large mailbox %s (buf: %p)", this, mailbox->get_cname(), buf_);