Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Persistent comms may be reused after a wait, do not put their handle to MPI_REQUEST_NULL
[simgrid.git] / src / smpi / smpi_base.c
index 952db70..eb2103e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2013. The SimGrid Team.
+/* Copyright (c) 2007-2014. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -331,7 +331,9 @@ void smpi_mpi_start(MPI_Request request)
     request->real_size=request->size;
     smpi_datatype_use(request->old_type);
     smpi_comm_use(request->comm);
-    request->action = simcall_comm_irecv(mailbox, request->buf, &request->real_size, &match_recv, request);
+    request->action = simcall_comm_irecv(mailbox, request->buf,
+                                         &request->real_size, &match_recv,
+                                         request, -1.0);
 
     //integrate pseudo-timing for buffering of small messages, do not bother to execute the simcall if 0
     double sleeptime = request->detached ? smpi_or(request->size) : 0.0;
@@ -368,7 +370,7 @@ void smpi_mpi_start(MPI_Request request)
       request->refcount++;
       if(request->old_type->has_subtype == 0){
         oldbuf = request->buf;
-        if (oldbuf && request->size!=0){
+        if (!_xbt_replay_is_active() && oldbuf && request->size!=0){
           request->buf = xbt_malloc(request->size);
           memcpy(request->buf,oldbuf,request->size);
         }
@@ -397,7 +399,7 @@ void smpi_mpi_start(MPI_Request request)
       simcall_comm_isend(mailbox, request->size, -1.0,
                          request->buf, request->real_size,
                          &match_send,
-                         &smpi_mpi_request_free_voidp, // how to free the userdata if a detached send fails
+                         &xbt_free, // how to free the userdata if a detached send fails
                          request,
                          // detach if msg size < eager/rdv switch limit
                          request->detached);
@@ -762,15 +764,15 @@ void smpi_mpi_wait(MPI_Request * request, MPI_Status * status)
 
   if ((*request)->action != NULL) { // this is not a detached send
     simcall_comm_wait((*request)->action, -1.0);
-  }
-
 #ifdef HAVE_MC
   if(MC_is_active())
     (*request)->action->comm.dst_data = NULL; // dangling pointer : dst_data is freed with a wait, need to set it to NULL for system state comparison
 #endif
+  }
 
   finish_wait(request, status);
-  *request = MPI_REQUEST_NULL;
+  if (*request != MPI_REQUEST_NULL && !((*request)->flags & PERSISTENT))
+      *request = MPI_REQUEST_NULL;
   // FIXME for a detached send, finish_wait is not called:
 }