Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Yet another dlopen merge
[simgrid.git] / src / smpi / smpi_datatype.cpp
index da145d1..4ce4985 100644 (file)
@@ -1,5 +1,5 @@
 /* smpi_datatype.cpp -- MPI primitives to handle datatypes                      */
-/* Copyright (c) 2009-2015. The SimGrid Team.
+/* Copyright (c) 2009-2017. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -19,7 +19,7 @@
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_datatype, smpi, "Logging specific to SMPI (datatype)");
 
 #define CREATE_MPI_DATATYPE(name, type)               \
-  static Datatype mpi_##name (         \
+  static simgrid::smpi::Datatype mpi_##name (         \
     (char*) # name,                                   \
     sizeof(type),   /* size */                        \
     0,              /* lb */                          \
@@ -29,7 +29,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_datatype, smpi, "Logging specific to SMPI (
 const MPI_Datatype name = &mpi_##name;
 
 #define CREATE_MPI_DATATYPE_NULL(name)                \
-  static Datatype mpi_##name (         \
+  static simgrid::smpi::Datatype mpi_##name (         \
     (char*) # name,                                   \
     0,              /* size */                        \
     0,              /* lb */                          \
@@ -270,8 +270,15 @@ int Datatype::unpack(void* inbuf, int insize, int* position, void* outbuf, int o
 int Datatype::copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
                        void *recvbuf, int recvcount, MPI_Datatype recvtype){
   int count;
-  if(smpi_privatize_global_variables){
-    smpi_switch_data_segment(smpi_process_index());
+
+  if(smpi_is_shared(sendbuf)){
+    XBT_DEBUG("Copy input buf %p is shared. Let's ignore it.", sendbuf);
+  }else if(smpi_is_shared(recvbuf)){
+    XBT_DEBUG("Copy output buf %p is shared. Let's ignore it.", recvbuf);
+  }
+
+  if(smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP){
+    smpi_switch_data_segment(smpi_process()->index());
   }
   /* First check if we really have something to do */
   if (recvcount > 0 && recvbuf != sendbuf) {
@@ -280,7 +287,7 @@ int Datatype::copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
     count = sendcount < recvcount ? sendcount : recvcount;
 
     if(!(sendtype->flags() & DT_FLAG_DERIVED) && !(recvtype->flags() & DT_FLAG_DERIVED)) {
-      if(!smpi_process_get_replaying()) 
+      if(!smpi_process()->replaying()) 
         memcpy(recvbuf, sendbuf, count);
     }
     else if (!(sendtype->flags() & DT_FLAG_DERIVED))