Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
even better handling ...
[simgrid.git] / src / smpi / bindings / smpi_pmpi_request.cpp
index 21eaa19..82d2642 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2018. 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. */
@@ -288,7 +288,6 @@ int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI
     retval = MPI_ERR_TAG;
   } else {
     int my_proc_id         = simgrid::s4u::Actor::self()->getPid();
-    int src_traced         = getPid(comm, src);
     TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
                        new simgrid::instr::Pt2PtTIData("recv", src,
                                                        datatype->is_replayable() ? count : count * datatype->size(),
@@ -299,7 +298,7 @@ int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI
 
     // the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
     if (status != MPI_STATUS_IGNORE) {
-      src_traced = getPid(comm, status->MPI_SOURCE);
+      int src_traced = getPid(comm, status->MPI_SOURCE);
       if (not TRACE_smpi_view_internals()) {
         TRACE_smpi_recv(src_traced, my_proc_id, tag);
       }
@@ -397,10 +396,17 @@ int PMPI_Sendrecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, int dst,
     retval = MPI_ERR_COMM;
   } else if (not sendtype->is_valid() || not recvtype->is_valid()) {
     retval = MPI_ERR_TYPE;
-  } else if (src == MPI_PROC_NULL || dst == MPI_PROC_NULL) {
-    simgrid::smpi::Status::empty(status);
-    status->MPI_SOURCE = MPI_PROC_NULL;
-    retval             = MPI_SUCCESS;
+  } else if (src == MPI_PROC_NULL) {
+    if(status!=MPI_STATUS_IGNORE){
+      simgrid::smpi::Status::empty(status);
+      status->MPI_SOURCE = MPI_PROC_NULL;
+    }
+    if(dst != MPI_PROC_NULL)
+      simgrid::smpi::Request::send(sendbuf, sendcount, sendtype, dst, sendtag, comm);
+    retval = MPI_SUCCESS;
+  }else if (dst == MPI_PROC_NULL){
+    simgrid::smpi::Request::recv(recvbuf, recvcount, recvtype, src, recvtag, comm, status);
+    retval = MPI_SUCCESS;
   }else if (dst >= comm->group()->size() || dst <0 ||
       (src!=MPI_ANY_SOURCE && (src >= comm->group()->size() || src <0))){
     retval = MPI_ERR_RANK;