Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[SMPI] Don't use local structure in PMPI_Waitany
[simgrid.git] / src / smpi / bindings / smpi_pmpi_request.cpp
index 53bd024..d6268ca 100644 (file)
@@ -161,7 +161,7 @@ int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MP
 
     TRACE_smpi_comm_in(rank, __FUNCTION__,
                        new simgrid::instr::Pt2PtTIData("Irecv", comm->group()->index(src),
-                                                       datatype->is_basic() ? count : count * datatype->size(),
+                                                       datatype->is_replayable() ? count : count * datatype->size(),
                                                        encode_datatype(datatype)));
 
     *request = simgrid::smpi::Request::irecv(buf, count, datatype, src, tag, comm);
@@ -202,7 +202,7 @@ int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MP
     int trace_dst = comm->group()->index(dst);
     TRACE_smpi_comm_in(rank, __FUNCTION__,
                        new simgrid::instr::Pt2PtTIData("Isend", trace_dst,
-                                                       datatype->is_basic() ? count : count * datatype->size(),
+                                                       datatype->is_replayable() ? count : count * datatype->size(),
                                                        encode_datatype(datatype)));
 
     TRACE_smpi_send(rank, rank, trace_dst, tag, count * datatype->size());
@@ -244,7 +244,7 @@ int PMPI_Issend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, M
     int trace_dst = comm->group()->index(dst);
     TRACE_smpi_comm_in(rank, __FUNCTION__,
                        new simgrid::instr::Pt2PtTIData("ISsend", trace_dst,
-                                                       datatype->is_basic() ? count : count * datatype->size(),
+                                                       datatype->is_replayable() ? count : count * datatype->size(),
                                                        encode_datatype(datatype)));
     TRACE_smpi_send(rank, rank, trace_dst, tag, count * datatype->size());
 
@@ -284,7 +284,7 @@ int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI
     int src_traced         = comm->group()->index(src);
     TRACE_smpi_comm_in(rank, __FUNCTION__,
                        new simgrid::instr::Pt2PtTIData("recv", src_traced,
-                                                       datatype->is_basic() ? count : count * datatype->size(),
+                                                       datatype->is_replayable() ? count : count * datatype->size(),
                                                        encode_datatype(datatype)));
 
     simgrid::smpi::Request::recv(buf, count, datatype, src, tag, comm, status);
@@ -327,7 +327,7 @@ int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI
     int dst_traced         = comm->group()->index(dst);
     TRACE_smpi_comm_in(rank, __FUNCTION__,
                        new simgrid::instr::Pt2PtTIData("send", dst_traced,
-                                                       datatype->is_basic() ? count : count * datatype->size(),
+                                                       datatype->is_replayable() ? count : count * datatype->size(),
                                                        encode_datatype(datatype)));
     if (not TRACE_smpi_view_internals()) {
       TRACE_smpi_send(rank, rank, dst_traced, tag,count*datatype->size());
@@ -365,7 +365,7 @@ int PMPI_Ssend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MP
     int dst_traced         = comm->group()->index(dst);
     TRACE_smpi_comm_in(rank, __FUNCTION__,
                        new simgrid::instr::Pt2PtTIData("Ssend", dst_traced,
-                                                       datatype->is_basic() ? count : count * datatype->size(),
+                                                       datatype->is_replayable() ? count : count * datatype->size(),
                                                        encode_datatype(datatype)));
     TRACE_smpi_send(rank, rank, dst_traced, tag, count * datatype->size());
 
@@ -406,14 +406,18 @@ int PMPI_Sendrecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, int dst,
     int rank               = smpi_process()->index();
     int dst_traced         = comm->group()->index(dst);
     int src_traced         = comm->group()->index(src);
-    //    extra->src             = src_traced;
-    //    extra->dst             = dst_traced;
-    //    extra->send_size       = sendtype->is_basic() ? sendcount : sendcount * sendtype->size();
-    //    extra->recv_size       = recvtype->is_basic() ? recvcount : recvcount * recvtype->size();
-    //    extra->datatype1       = encode_datatype(sendtype);
-    //    extra->datatype2       = encode_datatype(recvtype);
-
-    // TODO TRACE_smpi_comm_in(rank, __FUNCTION__, extra);
+
+    // FIXME: Hack the way to trace this one
+    std::vector<int>* dst_hack = new std::vector<int>;
+    std::vector<int>* src_hack = new std::vector<int>;
+    dst_hack->push_back(dst_traced);
+    src_hack->push_back(src_traced);
+    TRACE_smpi_comm_in(rank, __FUNCTION__,
+                       new simgrid::instr::VarCollTIData(
+                           "sendRecv", -1, sendtype->is_replayable() ? sendcount : sendcount * sendtype->size(), dst_hack,
+                           recvtype->is_replayable() ? recvcount : recvcount * recvtype->size(), src_hack,
+                           encode_datatype(sendtype), encode_datatype(recvtype)));
+
     TRACE_smpi_send(rank, rank, dst_traced, sendtag, sendcount * sendtype->size());
 
     simgrid::smpi::Request::sendrecv(sendbuf, sendcount, sendtype, dst, sendtag, recvbuf, recvcount, recvtype, src,
@@ -613,15 +617,17 @@ int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * sta
   *index = simgrid::smpi::Request::waitany(count, requests, status);
 
   if(*index!=MPI_UNDEFINED){
-    int src_traced = savedvals[*index].src;
-    //the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
-    int dst_traced = savedvals[*index].dst;
-    int is_wait_for_receive = savedvals[*index].recv;
-    if (is_wait_for_receive) {
-      if(savedvals[*index].src==MPI_ANY_SOURCE)
-        src_traced = (status != MPI_STATUSES_IGNORE) ? savedvals[*index].comm->group()->rank(status->MPI_SOURCE)
-                                                     : savedvals[*index].src;
-      TRACE_smpi_recv(src_traced, dst_traced, savedvals[*index].tag);
+    MPI_Request req = requests[*index];
+    if (req != nullptr) { // Requests that were already received will be a nullptr
+      int src_traced = req->src();
+      // the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
+      int dst_traced          = req->dst();
+      int is_wait_for_receive = req->flags() & RECV;
+      if (is_wait_for_receive) {
+        if (req->src() == MPI_ANY_SOURCE)
+          src_traced = (status != MPI_STATUSES_IGNORE) ? req->comm()->group()->rank(status->MPI_SOURCE) : req->src();
+        TRACE_smpi_recv(src_traced, dst_traced, req->tag());
+      }
     }
     TRACE_smpi_comm_out(rank_traced);
   }