Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
dupplicate the sender buffer in eager mode, when isends are changed into dsends ...
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 26 Dec 2011 01:23:21 +0000 (02:23 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 26 Dec 2011 01:23:21 +0000 (02:23 +0100)
include/simix/simix.h
src/simix/smx_network.c
src/smpi/smpi_base.c
src/smpi/smpi_global.c

index 7c6a70a..b64385e 100644 (file)
@@ -72,6 +72,8 @@ XBT_PUBLIC(void) SIMIX_process_set_context(smx_process_t p,smx_context_t c);
 XBT_PUBLIC(void) SIMIX_comm_set_copy_data_callback(void (*callback) (smx_action_t, size_t));
 XBT_PUBLIC(void) SIMIX_comm_copy_pointer_callback(smx_action_t comm, size_t buff_size);
 XBT_PUBLIC(void) SIMIX_comm_copy_buffer_callback(smx_action_t comm, size_t buff_size);
+XBT_PUBLIC(void) smpi_comm_copy_data_callback(smx_action_t comm, size_t buff_size);
+
 XBT_PUBLIC(smx_action_t) SIMIX_comm_get_send_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data);
 XBT_PUBLIC(int) SIMIX_comm_has_send_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data);
 XBT_PUBLIC(int) SIMIX_comm_has_recv_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data);
index c06c6a4..49222ba 100644 (file)
@@ -823,6 +823,13 @@ void SIMIX_comm_copy_buffer_callback(smx_action_t comm, size_t buff_size)
   memcpy(comm->comm.dst_buff, comm->comm.src_buff, buff_size);
 }
 
+void smpi_comm_copy_data_callback(smx_action_t comm, size_t buff_size)
+{
+  memcpy(comm->comm.dst_buff, comm->comm.src_buff, buff_size);
+  if (comm->comm.detached) // if this is a detached send, the source buffer was duplicated by SMPI sender to make the original buffer available to the application ASAP
+         free(comm->comm.src_buff);
+}
+
 /**
  *  \brief Copy the communication data from the sender's buffer to the receiver's one
  *  \param comm The communication
index fc093b5..f5aa890 100644 (file)
@@ -87,6 +87,7 @@ MPI_Request smpi_mpi_recv_init(void *buf, int count, MPI_Datatype datatype,
 void smpi_mpi_start(MPI_Request request)
 {
   smx_rdv_t mailbox;
+  int detached = 0;
 
   xbt_assert(!request->action,
               "Cannot (re)start a non-finished communication");
@@ -101,12 +102,19 @@ void smpi_mpi_start(MPI_Request request)
                          smpi_group_index(smpi_comm_group(request->comm), request->dst));
     // FIXME: SIMIX does not yet support non-contiguous datatypes
 
+    if (request->size < 64*1024 ) { // eager mode => detached send (FIXME: this limit should be configurable)
+       void *oldbuf = request->buf;
+       detached = 1;
+       request->buf = malloc(request->size);
+       memcpy(request->buf,oldbuf,request->size);
+    }
+
     request->action = 
                SIMIX_req_comm_isend(mailbox, request->size, -1.0,
                                    request->buf, request->size, &match_send, request,  
                                    // detach if msg size < eager/rdv switch limit
-                                   request->size < 64*1024 ? 1:0);
-    // if detached  request->action == NULL
+                                   detached);
+
 #ifdef HAVE_TRACING
     SIMIX_req_set_category (request->action, TRACE_internal_smpi_get_category());
 #endif
index ad839cb..0089372 100644 (file)
@@ -180,8 +180,7 @@ void smpi_global_init(void)
   MPI_Group group;
   char name[MAILBOX_NAME_MAXLEN];
 
-  SIMIX_comm_set_copy_data_callback
-      (&SIMIX_comm_copy_buffer_callback);
+  SIMIX_comm_set_copy_data_callback(&smpi_comm_copy_data_callback);
   process_count = SIMIX_process_count();
   process_data = xbt_new(smpi_process_data_t, process_count);
   for (i = 0; i < process_count; i++) {