Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
protect smpi against problems with replay+collectives.
authorAugustin Degomme <degomme@idpann.imag.fr>
Fri, 14 Feb 2014 14:52:22 +0000 (15:52 +0100)
committerAugustin Degomme <degomme@idpann.imag.fr>
Fri, 14 Feb 2014 16:16:55 +0000 (17:16 +0100)
Previous protection was ignoring NULL as a buffer.
But some collective algorithms use chunks of data from the buffer, instead, trying to use NULL+offset as an address.

include/xbt/replay.h
src/smpi/smpi_base.c
src/smpi/smpi_global.c
src/smpi/smpi_mpi_dt.c
src/xbt/xbt_replay.c

index 196ce79..675a5ad 100644 (file)
@@ -28,6 +28,8 @@ XBT_PUBLIC(const char *) xbt_replay_reader_position(xbt_replay_reader_t reader);
 
 XBT_PUBLIC(int) xbt_replay_action_runner(int argc, char *argv[]);
 
+XBT_PUBLIC(int) _xbt_replay_is_active(void);
+
 XBT_PUBLIC(void) _xbt_replay_action_init(void);
 XBT_PUBLIC(void) _xbt_replay_action_exit(void);
 
index 1887ec0..b72d6ce 100644 (file)
@@ -370,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);
         }
index 876889f..89f5cb5 100644 (file)
@@ -7,6 +7,7 @@
 #include "private.h"
 #include "smpi_mpi_dt_private.h"
 #include "mc/mc.h"
+#include "xbt/replay.h"
 #include "surf/surf.h"
 #include "simix/smx_private.h"
 #include "simgrid/sg_config.h"
@@ -318,6 +319,7 @@ static void smpi_comm_copy_buffer_callback(smx_action_t comm,
                                            void *buff, size_t buff_size)
 {
   XBT_DEBUG("Copy the data over");
+  if(_xbt_replay_is_active()) return;
   memcpy(comm->comm.dst_buff, buff, buff_size);
   if (comm->comm.detached) {
     // if this is a detached send, the source buffer was duplicated by SMPI
index eb1d71c..8be8134 100644 (file)
@@ -14,6 +14,7 @@
 #include "private.h"
 #include "smpi_mpi_dt_private.h"
 #include "mc/mc.h"
+#include "xbt/replay.h"
 #include "simgrid/modelchecker.h"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_mpi_dt, smpi,
@@ -165,7 +166,7 @@ int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
     count = sendcount < recvcount ? sendcount : recvcount;
 
     if(sendtype->has_subtype == 0 && recvtype->has_subtype == 0) {
-      memcpy(recvbuf, sendbuf, count);
+      if(!_xbt_replay_is_active()) memcpy(recvbuf, sendbuf, count);
     }
     else if (sendtype->has_subtype == 0)
     {
@@ -1488,5 +1489,6 @@ void smpi_op_destroy(MPI_Op op)
 void smpi_op_apply(MPI_Op op, void *invec, void *inoutvec, int *len,
                    MPI_Datatype * datatype)
 {
+  if(!_xbt_replay_is_active())
   op->func(invec, inoutvec, len, datatype);
 }
index 211940d..ffd8002 100644 (file)
@@ -31,6 +31,8 @@ xbt_dict_t action_queues;
 static char *action_line = NULL;
 static size_t action_len = 0;
 
+int is_replay_active = 0 ;
+
 static char **action_get_action(char *name);
 
 static char *str_tolower (const char *str)
@@ -42,6 +44,9 @@ static char *str_tolower (const char *str)
   return ret;
 }
 
+int _xbt_replay_is_active(void){
+  return is_replay_active;
+}
 
 xbt_replay_reader_t xbt_replay_reader_new(const char *filename)
 {
@@ -127,6 +132,7 @@ void xbt_replay_action_unregister(const char *action_name)
 
 void _xbt_replay_action_init(void)
 {
+  is_replay_active = 1;
   action_funs = xbt_dict_new_homogeneous(NULL);
   action_queues = xbt_dict_new_homogeneous(NULL);
 }