Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 16 Mar 2017 17:26:28 +0000 (18:26 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 16 Mar 2017 17:26:28 +0000 (18:26 +0100)
23 files changed:
include/smpi/smpi_extended_traces.h
include/smpi/smpi_extended_traces_fortran.h
src/simgrid/sg_config.cpp
src/smpi/smpi_coll.cpp
src/smpi/smpi_coll.hpp
src/smpi/smpi_comm.cpp
src/smpi/smpi_comm.hpp
src/smpi/smpi_datatype.cpp
src/smpi/smpi_datatype.hpp
src/smpi/smpi_datatype_derived.cpp
src/smpi/smpi_datatype_derived.hpp
src/smpi/smpi_dvfs.cpp
src/smpi/smpi_f2c.cpp
src/smpi/smpi_f2c.hpp
src/smpi/smpi_f77.cpp
src/smpi/smpi_group.cpp
src/smpi/smpi_info.cpp
src/smpi/smpi_info.hpp
src/smpi/smpi_keyvals.cpp
src/smpi/smpi_keyvals.hpp
src/smpi/smpi_pmpi.cpp
src/smpi/smpi_request.cpp
tools/smpi/generate_smpi_defines.pl

index 5bbf03a..8d4aea3 100644 (file)
@@ -1,5 +1,5 @@
 // This file has been automatically generated by the script
-// in tools/smpi/../tools/smpi/generate_smpi_defines.pl
+// in tools/smpi/generate_smpi_defines.pl
 // DO NOT EDIT MANUALLY. ALL CHANGES WILL BE OVERWRITTEN!
 #define MPI_Init(...) ({ smpi_process_init(__VA_ARGS__); smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Init(NULL, NULL); })
 #define MPI_Finalize(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Finalize(__VA_ARGS__); })
@@ -14,6 +14,7 @@
 #define MPI_Get_address(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Get_address(__VA_ARGS__); })
 #define MPI_Type_free(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_free(__VA_ARGS__); })
 #define MPI_Type_size(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_size(__VA_ARGS__); })
+#define MPI_Type_size_x(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_size_x(__VA_ARGS__); })
 #define MPI_Type_get_extent(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_get_extent(__VA_ARGS__); })
 #define MPI_Type_get_true_extent(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_get_true_extent(__VA_ARGS__); })
 #define MPI_Type_extent(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Type_extent(__VA_ARGS__); })
@@ -55,6 +56,7 @@
 #define MPI_Comm_group(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_group(__VA_ARGS__); })
 #define MPI_Comm_compare(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_compare(__VA_ARGS__); })
 #define MPI_Comm_create(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_create(__VA_ARGS__); })
+#define MPI_Comm_create_group(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_create_group(__VA_ARGS__); })
 #define MPI_Comm_free(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_free(__VA_ARGS__); })
 #define MPI_Comm_disconnect(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_disconnect(__VA_ARGS__); })
 #define MPI_Comm_split(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Comm_split(__VA_ARGS__); })
 #define MPI_Win_get_name(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_get_name(__VA_ARGS__); })
 #define MPI_Win_get_group(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_get_group(__VA_ARGS__); })
 #define MPI_Win_fence(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_fence(__VA_ARGS__); })
+#define MPI_Win_get_attr(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_get_attr(__VA_ARGS__); })
+#define MPI_Win_set_attr(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_set_attr(__VA_ARGS__); })
+#define MPI_Win_delete_attr(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_delete_attr(__VA_ARGS__); })
+#define MPI_Win_create_keyval(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_create_keyval(__VA_ARGS__); })
+#define MPI_Win_free_keyval(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Win_free_keyval(__VA_ARGS__); })
 #define MPI_Get(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Get(__VA_ARGS__); })
 #define MPI_Put(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Put(__VA_ARGS__); })
 #define MPI_Accumulate(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Accumulate(__VA_ARGS__); })
 #define MPI_File_get_view(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_get_view(__VA_ARGS__); })
 #define MPI_File_read_at(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_read_at(__VA_ARGS__); })
 #define MPI_File_read_at_all(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_read_at_all(__VA_ARGS__); })
+#define MPI_File_read(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_read(__VA_ARGS__); })
+#define MPI_File_write(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_write(__VA_ARGS__); })
 #define MPI_File_write_at(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_write_at(__VA_ARGS__); })
 #define MPI_File_write_at_all(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_write_at_all(__VA_ARGS__); })
 #define MPI_File_set_atomicity(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_File_set_atomicity(__VA_ARGS__); })
index 5fcf369..c585962 100644 (file)
@@ -1,5 +1,5 @@
 ! This file has been automatically generated by the script
-! in tools/smpi/../tools/smpi/generate_smpi_defines.pl
+! in tools/smpi/generate_smpi_defines.pl
 ! DO NOT EDIT MANUALLY. ALL CHANGES WILL BE OVERWRITTEN!
 #define MPI_INIT smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_init
 #define MPI_FINALIZE smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_finalize
@@ -14,6 +14,7 @@
 #define MPI_GET_ADDRESS smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_get_address
 #define MPI_TYPE_FREE smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_type_free
 #define MPI_TYPE_SIZE smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_type_size
+#define MPI_TYPE_SIZE_X smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_type_size_x
 #define MPI_TYPE_GET_EXTENT smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_type_get_extent
 #define MPI_TYPE_GET_TRUE_EXTENT smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_type_get_true_extent
 #define MPI_TYPE_EXTENT smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_type_extent
@@ -55,6 +56,7 @@
 #define MPI_COMM_GROUP smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_comm_group
 #define MPI_COMM_COMPARE smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_comm_compare
 #define MPI_COMM_CREATE smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_comm_create
+#define MPI_COMM_CREATE_GROUP smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_comm_create_group
 #define MPI_COMM_FREE smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_comm_free
 #define MPI_COMM_DISCONNECT smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_comm_disconnect
 #define MPI_COMM_SPLIT smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_comm_split
 #define MPI_WIN_GET_NAME smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_win_get_name
 #define MPI_WIN_GET_GROUP smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_win_get_group
 #define MPI_WIN_FENCE smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_win_fence
+#define MPI_WIN_GET_ATTR smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_win_get_attr
+#define MPI_WIN_SET_ATTR smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_win_set_attr
+#define MPI_WIN_DELETE_ATTR smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_win_delete_attr
+#define MPI_WIN_CREATE_KEYVAL smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_win_create_keyval
+#define MPI_WIN_FREE_KEYVAL smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_win_free_keyval
 #define MPI_GET smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_get
 #define MPI_PUT smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_put
 #define MPI_ACCUMULATE smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_accumulate
 #define MPI_FILE_GET_VIEW smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_file_get_view
 #define MPI_FILE_READ_AT smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_file_read_at
 #define MPI_FILE_READ_AT_ALL smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_file_read_at_all
+#define MPI_FILE_READ smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_file_read
+#define MPI_FILE_WRITE smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_file_write
 #define MPI_FILE_WRITE_AT smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_file_write_at
 #define MPI_FILE_WRITE_AT_ALL smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_file_write_at_all
 #define MPI_FILE_SET_ATOMICITY smpi_trace_set_call_location(__FILE__,__LINE__); call mpi_file_set_atomicity
index 9f2d3d3..e30c0fc 100644 (file)
@@ -518,8 +518,8 @@ void sg_config_init(int *argc, char **argv)
     xbt_cfg_register_string("smpi/gather",        nullptr, nullptr, "Which collective to use for gather");
     xbt_cfg_register_string("smpi/allgather",     nullptr, nullptr, "Which collective to use for allgather");
     xbt_cfg_register_string("smpi/barrier",       nullptr, nullptr, "Which collective to use for barrier");
-    xbt_cfg_register_string("smpi/reduce-scatter",nullptr, nullptr, "Which collective to use for reduce_scatter");
-    xbt_cfg_register_alias("smpi/reduce-scatter","smpi/reduce_scatter");
+    xbt_cfg_register_string("smpi/reduce_scatter",nullptr, nullptr, "Which collective to use for reduce_scatter");
+    xbt_cfg_register_alias("smpi/reduce_scatter","smpi/reduce-scatter");
     xbt_cfg_register_string("smpi/scatter",       nullptr, nullptr, "Which collective to use for scatter");
     xbt_cfg_register_string("smpi/allgatherv",    nullptr, nullptr, "Which collective to use for allgatherv");
     xbt_cfg_register_string("smpi/allreduce",     nullptr, nullptr, "Which collective to use for allreduce");
index eefd819..112c9da 100644 (file)
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_coll, smpi, "Logging specific to SMPI (coll)");
 
+#define COLL_SETTER(cat, ret, args, args2)\
+int (*Colls::cat ) args;\
+void Colls::set_##cat (const char * name){\
+    int id = find_coll_description(mpi_coll_## cat ##_description,\
+                                             name,#cat);\
+    cat = reinterpret_cast<ret (*) args>\
+        (mpi_coll_## cat ##_description[id].coll);\
+    if (cat == nullptr)\
+      xbt_die("Collective "#cat" set to nullptr!");\
+}
+
+#define SET_COLL(coll)\
+    name = xbt_cfg_get_string("smpi/"#coll);\
+    if (name==nullptr || name[0] == '\0')\
+        name = selector_name;\
+    set_##coll(name);
 
 namespace simgrid{
 namespace smpi{
@@ -48,9 +64,9 @@ s_mpi_coll_description_t Colls::mpi_coll_reduce_description[] = {
 /** Displays the long description of all registered models, and quit */
 void Colls::coll_help(const char *category, s_mpi_coll_description_t * table)
 {
-  printf("Long description of the %s models accepted by this simulator:\n", category);
+  XBT_WARN("Long description of the %s models accepted by this simulator:\n", category);
   for (int i = 0; table[i].name; i++)
-    printf("  %s: %s\n", table[i].name, table[i].description);
+    XBT_WARN("  %s: %s\n", table[i].name, table[i].description);
 }
 
 int Colls::find_coll_description(s_mpi_coll_description_t * table, const char *name, const char *desc)
@@ -77,15 +93,6 @@ int Colls::find_coll_description(s_mpi_coll_description_t * table, const char *n
 
 
 
-#define COLL_SETTER(cat, ret, args, args2)\
-int (*Colls::cat ) args;\
-void Colls::set_##cat (const char * name){\
-    int id = find_coll_description(mpi_coll_## cat ##_description,\
-                                             name,#cat);\
-    cat = reinterpret_cast<ret (*) args>\
-        (mpi_coll_## cat ##_description[id].coll);\
-}
-
 COLL_APPLY(COLL_SETTER,COLL_GATHER_SIG,"");
 COLL_APPLY(COLL_SETTER,COLL_ALLGATHER_SIG,"");
 COLL_APPLY(COLL_SETTER,COLL_ALLGATHERV_SIG,"");
@@ -104,71 +111,19 @@ void Colls::set_collectives(){
     if (selector_name==nullptr || selector_name[0] == '\0')
         selector_name = "default";
 
-    const char* name = xbt_cfg_get_string("smpi/gather");
-    if (name==nullptr || name[0] == '\0')
-        name = selector_name;
-      
-    set_gather(name);
-
-    name = xbt_cfg_get_string("smpi/allgather");
-    if (name==nullptr || name[0] == '\0')
-        name = selector_name;
-
-    set_allgather(name);
-
-    name = xbt_cfg_get_string("smpi/allgatherv");
-    if (name==nullptr || name[0] == '\0')
-        name = selector_name;
-
-    set_allgatherv(name);
-
-    name = xbt_cfg_get_string("smpi/allreduce");
-    if (name==nullptr || name[0] == '\0')
-        name = selector_name;
-
-    set_allreduce(name);
-
-    name = xbt_cfg_get_string("smpi/alltoall");
-    if (name==nullptr || name[0] == '\0')
-        name = selector_name;
-
-    set_alltoall(name);
-
-    name = xbt_cfg_get_string("smpi/alltoallv");
-    if (name==nullptr || name[0] == '\0')
-        name = selector_name;
-
-    set_alltoallv(name);
-
-    name = xbt_cfg_get_string("smpi/reduce");
-    if (name==nullptr || name[0] == '\0')
-        name = selector_name;
-
-    set_reduce(name);
-
-    name = xbt_cfg_get_string("smpi/reduce-scatter");
-    if (name==nullptr || name[0] == '\0')
-        name = selector_name;
-
-    set_reduce_scatter(name);
-
-    name = xbt_cfg_get_string("smpi/scatter");
-    if (name==nullptr || name[0] == '\0')
-        name = selector_name;
-
-    set_scatter(name);
-
-    name = xbt_cfg_get_string("smpi/bcast");
-    if (name==nullptr || name[0] == '\0')
-        name = selector_name;
-
-    set_bcast(name);
-
-    name = xbt_cfg_get_string("smpi/barrier");
-    if (name==nullptr || name[0] == '\0')
-        name = selector_name;
-
-    set_barrier(name);
+    const char* name;
+
+    SET_COLL(gather);
+    SET_COLL(allgather);
+    SET_COLL(allgatherv);
+    SET_COLL(allreduce);
+    SET_COLL(alltoall);
+    SET_COLL(alltoallv);
+    SET_COLL(reduce);
+    SET_COLL(reduce_scatter);
+    SET_COLL(scatter);
+    SET_COLL(bcast);
+    SET_COLL(barrier);
 }
 
 
@@ -268,7 +223,7 @@ int Colls::scan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
   // Local copy from self
   Datatype::copy(sendbuf, count, datatype, recvbuf, count, datatype);
 
-  // Send/Recv buffers to/from others;
+  // Send/Recv buffers to/from others
   MPI_Request *requests = xbt_new(MPI_Request, size - 1);
   void **tmpbufs = xbt_new(void *, rank);
   int index = 0;
@@ -292,15 +247,15 @@ int Colls::scan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
       }
       if(index < rank) {
         // #Request is below rank: it's a irecv
-        if(op!=MPI_OP_NULL) op->apply( tmpbufs[index], recvbuf, &count, datatype);
+        op->apply( tmpbufs[index], recvbuf, &count, datatype);
       }
     }
   }else{
     //non commutative case, wait in order
     for (int other = 0; other < size - 1; other++) {
       Request::wait(&(requests[other]), MPI_STATUS_IGNORE);
-      if(index < rank) {
-        if(op!=MPI_OP_NULL) op->apply( tmpbufs[other], recvbuf, &count, datatype);
+      if(index < rank && op!=MPI_OP_NULL) {
+        op->apply( tmpbufs[other], recvbuf, &count, datatype);
       }
     }
   }
@@ -326,7 +281,7 @@ int Colls::exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype
 
   datatype->extent(&lb, &dataext);
 
-  // Send/Recv buffers to/from others;
+  // Send/Recv buffers to/from others
   MPI_Request *requests = xbt_new(MPI_Request, size - 1);
   void **tmpbufs = xbt_new(void *, rank);
   int index = 0;
@@ -354,7 +309,7 @@ int Colls::exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype
           recvbuf_is_empty=0;
         } else
           // #Request is below rank: it's a irecv
-          if(op!=MPI_OP_NULL) op->apply( tmpbufs[index], recvbuf, &count, datatype);
+          op->apply( tmpbufs[index], recvbuf, &count, datatype);
       }
     }
   }else{
@@ -366,7 +321,8 @@ int Colls::exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype
           Datatype::copy(tmpbufs[other], count, datatype, recvbuf, count, datatype);
           recvbuf_is_empty = 0;
         } else
-          if(op!=MPI_OP_NULL) op->apply( tmpbufs[other], recvbuf, &count, datatype);
+          if(op!=MPI_OP_NULL) 
+            op->apply( tmpbufs[other], recvbuf, &count, datatype);
       }
     }
   }
index 8d67a30..00f3e7b 100644 (file)
 
 /** \brief MPI collective description */
 
-struct mpi_coll_description {
-  const char *name;
-  const char *description;
-  void *coll;
+#define COLL_DEFS(cat, ret, args, args2)\
+    static void set_##cat(const char* name);\
+    static s_mpi_coll_description_t mpi_coll_##cat##_description[];\
+    static int (*cat ) args;
+
+#define COLL_SIG(cat, ret, args, args2)\
+    static int cat args;
+
+
+#define COLL_DESCRIPTION(cat, ret, args, name) \
+  {# name,\
+   # cat " " # name " collective",\
+   (void*) Coll_ ## cat ## _ ## name::cat }
+
+#define COLL_PROTO(cat, ret, args, name) \
+class Coll_ ## cat ## _ ## name : public Coll { \
+public: \
+static ret cat  (COLL_UNPAREN args); \
 };
-typedef struct mpi_coll_description  s_mpi_coll_description_t;
-typedef struct mpi_coll_description* mpi_coll_description_t;
 
+#define COLL_UNPAREN(...)  __VA_ARGS__
+
+#define COLL_APPLY(action, sig, name) action(sig, name)
+#define COLL_COMMA ,
+#define COLL_NOsep 
+#define COLL_NOTHING(...) 
+
+#define COLL_GATHER_SIG gather, int, \
+                      (void *send_buff, int send_count, MPI_Datatype send_type, \
+                       void *recv_buff, int recv_count, MPI_Datatype recv_type, \
+                           int root, MPI_Comm comm)
+#define COLL_ALLGATHER_SIG allgather, int, \
+                      (void *send_buff, int send_count, MPI_Datatype send_type, \
+                       void *recv_buff, int recv_count, MPI_Datatype recv_type, \
+                           MPI_Comm comm)
+#define COLL_ALLGATHERV_SIG allgatherv, int, \
+                      (void *send_buff, int send_count, MPI_Datatype send_type, \
+                       void *recv_buff, int *recv_count, int *recv_disps, \
+               MPI_Datatype recv_type, MPI_Comm comm)
+#define COLL_ALLTOALL_SIG alltoall, int, \
+                     (void *send_buff, int send_count, MPI_Datatype send_type, \
+                      void *recv_buff, int recv_count, MPI_Datatype recv_type, \
+                          MPI_Comm comm)
+#define COLL_ALLTOALLV_SIG alltoallv, int, \
+                     (void *send_buff, int *send_counts, int *send_disps, MPI_Datatype send_type, \
+                      void *recv_buff, int *recv_counts, int *recv_disps, MPI_Datatype recv_type, \
+                          MPI_Comm comm)
+#define COLL_BCAST_SIG bcast, int, \
+                  (void *buf, int count, MPI_Datatype datatype, \
+                   int root, MPI_Comm comm)
+#define COLL_REDUCE_SIG reduce, int, \
+                   (void *buf, void *rbuf, int count, MPI_Datatype datatype, \
+                        MPI_Op op, int root, MPI_Comm comm)
+#define COLL_ALLREDUCE_SIG allreduce, int, \
+                      (void *sbuf, void *rbuf, int rcount, \
+                           MPI_Datatype dtype, MPI_Op op, MPI_Comm comm)
+#define COLL_REDUCE_SCATTER_SIG reduce_scatter, int, \
+                      (void *sbuf, void *rbuf, int *rcounts,\
+                    MPI_Datatype dtype,MPI_Op  op,MPI_Comm  comm)
+#define COLL_SCATTER_SIG scatter, int, \
+                (void *sendbuf, int sendcount, MPI_Datatype sendtype,\
+                void *recvbuf, int recvcount, MPI_Datatype recvtype,\
+                int root, MPI_Comm comm)
+#define COLL_BARRIER_SIG barrier, int, \
+                (MPI_Comm comm)
 
 namespace simgrid{
 namespace smpi{
 
+struct mpi_coll_description {
+  const char *name;
+  const char *description;
+  void *coll;
+};
+typedef struct mpi_coll_description  s_mpi_coll_description_t;
 
 class Colls{
-  private:
   public:
-    static void set_gather(const char* name);
-    static void set_allgather(const char* name);
-    static void set_allgatherv(const char* name);
-    static void set_alltoall(const char* name);
-    static void set_alltoallv(const char* name);
-    static void set_allreduce(const char* name);
-    static void set_reduce(const char* name);
-    static void set_reduce_scatter(const char* name);
-    static void set_scatter(const char* name);
-    static void set_barrier(const char* name);
-    static void set_bcast(const char* name);
-
-    static s_mpi_coll_description_t mpi_coll_gather_description[];
-    static s_mpi_coll_description_t mpi_coll_allgather_description[];
-    static s_mpi_coll_description_t mpi_coll_allgatherv_description[];
-    static s_mpi_coll_description_t mpi_coll_allreduce_description[];
-    static s_mpi_coll_description_t mpi_coll_alltoall_description[];
-    static s_mpi_coll_description_t mpi_coll_alltoallv_description[];
-    static s_mpi_coll_description_t mpi_coll_bcast_description[];
-    static s_mpi_coll_description_t mpi_coll_reduce_description[];
-    static s_mpi_coll_description_t mpi_coll_reduce_scatter_description[];
-    static s_mpi_coll_description_t mpi_coll_scatter_description[];
-    static s_mpi_coll_description_t mpi_coll_barrier_description[];
-
 
     static XBT_PUBLIC(void) coll_help(const char *category, s_mpi_coll_description_t * table);
     static XBT_PUBLIC(int) find_coll_description(s_mpi_coll_description_t * table, const char *name, const char *desc);
     static void set_collectives();
 
-    static int (*gather)(void *, int, MPI_Datatype, void*, int, MPI_Datatype, int root, MPI_Comm);
-    static int (*allgather)(void *, int, MPI_Datatype, void*, int, MPI_Datatype, MPI_Comm);
-    static int (*allgatherv)(void *, int, MPI_Datatype, void*, int*, int*, MPI_Datatype, MPI_Comm);
-    static int (*allreduce)(void *sbuf, void *rbuf, int rcount, MPI_Datatype dtype, MPI_Op op, MPI_Comm comm);
-    static int (*alltoall)(void *, int, MPI_Datatype, void*, int, MPI_Datatype, MPI_Comm);
-    static int (*alltoallv)(void *, int*, int*, MPI_Datatype, void*, int*, int*, MPI_Datatype, MPI_Comm);
-    static int (*bcast)(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm com);
-    static int (*reduce)(void *buf, void *rbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm);
-    static int (*reduce_scatter)(void *sbuf, void *rbuf, int *rcounts,MPI_Datatype dtype,MPI_Op  op,MPI_Comm  comm);
-    static int (*scatter)(void *sendbuf, int sendcount, MPI_Datatype sendtype,void *recvbuf, int recvcount, MPI_Datatype recvtype,int root, MPI_Comm comm);
-    static int (*barrier)(MPI_Comm comm);
+    // for each collective type, create the set_* prototype, the description array
+    // and the function pointer
+    COLL_APPLY(COLL_DEFS,COLL_GATHER_SIG,"");
+    COLL_APPLY(COLL_DEFS,COLL_ALLGATHER_SIG,"");
+    COLL_APPLY(COLL_DEFS,COLL_ALLGATHERV_SIG,"");
+    COLL_APPLY(COLL_DEFS,COLL_REDUCE_SIG,"");
+    COLL_APPLY(COLL_DEFS,COLL_ALLREDUCE_SIG,"");
+    COLL_APPLY(COLL_DEFS,COLL_REDUCE_SCATTER_SIG,"");
+    COLL_APPLY(COLL_DEFS,COLL_SCATTER_SIG,"");
+    COLL_APPLY(COLL_DEFS,COLL_BARRIER_SIG,"");
+    COLL_APPLY(COLL_DEFS,COLL_BCAST_SIG,"");
+    COLL_APPLY(COLL_DEFS,COLL_ALLTOALL_SIG,"");
+    COLL_APPLY(COLL_DEFS,COLL_ALLTOALLV_SIG,"");
 
 //These fairly unused collectives only have one implementation in SMPI
 
@@ -83,48 +123,25 @@ class Colls{
 
 class Coll {
   public:
-    static int gather (void *, int, MPI_Datatype, void*, int, MPI_Datatype, int root, MPI_Comm);
-    static int allgather (void *, int, MPI_Datatype, void*, int, MPI_Datatype, MPI_Comm);
-    static int allgatherv (void *, int, MPI_Datatype, void*, int*, int*, MPI_Datatype, MPI_Comm);
-    static int allreduce (void *sbuf, void *rbuf, int rcount, MPI_Datatype dtype, MPI_Op op, MPI_Comm comm);
-    static int alltoall (void *, int, MPI_Datatype, void*, int, MPI_Datatype, MPI_Comm);
-    static int alltoallv (void *, int*, int*, MPI_Datatype, void*, int*, int*, MPI_Datatype, MPI_Comm);
-    static int bcast (void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm com);
-    static int reduce (void *buf, void *rbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm);
-    static int reduce_scatter (void *sbuf, void *rbuf, int *rcounts,MPI_Datatype dtype,MPI_Op  op,MPI_Comm  comm);
-    static int scatter (void *sendbuf, int sendcount, MPI_Datatype sendtype,void *recvbuf, int recvcount, MPI_Datatype recvtype,int root, MPI_Comm comm);
-    static int barrier (MPI_Comm);
-};
-
-
-
-#define COLL_DESCRIPTION(cat, ret, args, name) \
-  {# name,\
-   # cat " " # name " collective",\
-   (void*) Coll_ ## cat ## _ ## name::cat }
-
-#define COLL_PROTO(cat, ret, args, name) \
-class Coll_ ## cat ## _ ## name : public Coll { \
-public: \
-static ret cat  (COLL_UNPAREN args); \
+    // for each collective type, create a function member
+    COLL_APPLY(COLL_SIG,COLL_GATHER_SIG,"");
+    COLL_APPLY(COLL_SIG,COLL_ALLGATHER_SIG,"");
+    COLL_APPLY(COLL_SIG,COLL_ALLGATHERV_SIG,"");
+    COLL_APPLY(COLL_SIG,COLL_REDUCE_SIG,"");
+    COLL_APPLY(COLL_SIG,COLL_ALLREDUCE_SIG,"");
+    COLL_APPLY(COLL_SIG,COLL_REDUCE_SCATTER_SIG,"");
+    COLL_APPLY(COLL_SIG,COLL_SCATTER_SIG,"");
+    COLL_APPLY(COLL_SIG,COLL_BARRIER_SIG,"");
+    COLL_APPLY(COLL_SIG,COLL_BCAST_SIG,"");
+    COLL_APPLY(COLL_SIG,COLL_ALLTOALL_SIG,"");
+    COLL_APPLY(COLL_SIG,COLL_ALLTOALLV_SIG,"");
 };
 
-#define COLL_UNPAREN(...)  __VA_ARGS__
-
-#define COLL_APPLY(action, sig, name) action(sig, name)
-#define COLL_COMMA ,
-#define COLL_NOsep 
-#define COLL_NOTHING(...) 
 
 /*************
  * GATHER *
  *************/
 
-#define COLL_GATHER_SIG gather, int, \
-                         (void *send_buff, int send_count, MPI_Datatype send_type, \
-                          void *recv_buff, int recv_count, MPI_Datatype recv_type, \
-                           int root, MPI_Comm comm)
-
 #define COLL_GATHERS(action, COLL_sep) \
 COLL_APPLY(action, COLL_GATHER_SIG, default) COLL_sep \
 COLL_APPLY(action, COLL_GATHER_SIG, ompi) COLL_sep \
@@ -142,10 +159,6 @@ COLL_GATHERS(COLL_PROTO, COLL_NOsep)
 /*************
  * ALLGATHER *
  *************/
-#define COLL_ALLGATHER_SIG allgather, int, \
-                         (void *send_buff, int send_count, MPI_Datatype send_type, \
-                          void *recv_buff, int recv_count, MPI_Datatype recv_type, \
-                           MPI_Comm comm)
 
 #define COLL_ALLGATHERS(action, COLL_sep) \
 COLL_APPLY(action, COLL_ALLGATHER_SIG, default) COLL_sep \
@@ -176,10 +189,6 @@ COLL_ALLGATHERS(COLL_PROTO, COLL_NOsep)
 /**************
  * ALLGATHERV *
  **************/
-#define COLL_ALLGATHERV_SIG allgatherv, int, \
-                         (void *send_buff, int send_count, MPI_Datatype send_type, \
-                          void *recv_buff, int *recv_count, int *recv_disps, \
-                          MPI_Datatype recv_type, MPI_Comm comm)
 
 #define COLL_ALLGATHERVS(action, COLL_sep) \
 COLL_APPLY(action, COLL_ALLGATHERV_SIG, default) COLL_sep \
@@ -201,9 +210,6 @@ COLL_ALLGATHERVS(COLL_PROTO, COLL_NOsep)
 /*************
  * ALLREDUCE *
  *************/
-#define COLL_ALLREDUCE_SIG allreduce, int, \
-                         (void *sbuf, void *rbuf, int rcount, \
-                           MPI_Datatype dtype, MPI_Op op, MPI_Comm comm)
 
 #define COLL_ALLREDUCES(action, COLL_sep) \
 COLL_APPLY(action, COLL_ALLREDUCE_SIG, default) COLL_sep \
@@ -234,10 +240,7 @@ COLL_ALLREDUCES(COLL_PROTO, COLL_NOsep)
 /************
  * ALLTOALL *
  ************/
-#define COLL_ALLTOALL_SIG alltoall, int, \
-                        (void *send_buff, int send_count, MPI_Datatype send_type, \
-                         void *recv_buff, int recv_count, MPI_Datatype recv_type, \
-                          MPI_Comm comm)
+
 
 #define COLL_ALLTOALLS(action, COLL_sep) \
 COLL_APPLY(action, COLL_ALLTOALL_SIG, default) COLL_sep \
@@ -267,10 +270,6 @@ COLL_ALLTOALLS(COLL_PROTO, COLL_NOsep)
 /*************
  * ALLTOALLV *
  *************/
-#define COLL_ALLTOALLV_SIG alltoallv, int, \
-                        (void *send_buff, int *send_counts, int *send_disps, MPI_Datatype send_type, \
-                         void *recv_buff, int *recv_counts, int *recv_disps, MPI_Datatype recv_type, \
-                          MPI_Comm comm)
 
 #define COLL_ALLTOALLVS(action, COLL_sep) \
 COLL_APPLY(action, COLL_ALLTOALLV_SIG, default) COLL_sep \
@@ -295,9 +294,6 @@ COLL_ALLTOALLVS(COLL_PROTO, COLL_NOsep)
 /*********
  * BCAST *
  *********/
-#define COLL_BCAST_SIG bcast, int, \
-                     (void *buf, int count, MPI_Datatype datatype, \
-                      int root, MPI_Comm comm)
 
 #define COLL_BCASTS(action, COLL_sep) \
 COLL_APPLY(action, COLL_BCAST_SIG, default) COLL_sep \
@@ -332,9 +328,6 @@ COLL_BCASTS(COLL_PROTO, COLL_NOsep)
 /**********
  * REDUCE *
  **********/
-#define COLL_REDUCE_SIG reduce, int, \
-                      (void *buf, void *rbuf, int count, MPI_Datatype datatype, \
-                        MPI_Op op, int root, MPI_Comm comm)
 
 #define COLL_REDUCES(action, COLL_sep) \
 COLL_APPLY(action, COLL_REDUCE_SIG, default) COLL_sep \
@@ -363,9 +356,6 @@ COLL_REDUCES(COLL_PROTO, COLL_NOsep)
 /*************
  * REDUCE_SCATTER *
  *************/
-#define COLL_REDUCE_SCATTER_SIG reduce_scatter, int, \
-                         (void *sbuf, void *rbuf, int *rcounts,\
-                    MPI_Datatype dtype,MPI_Op  op,MPI_Comm  comm)
 
 #define COLL_REDUCE_SCATTERS(action, COLL_sep) \
 COLL_APPLY(action, COLL_REDUCE_SCATTER_SIG, default) COLL_sep \
@@ -388,10 +378,6 @@ COLL_REDUCE_SCATTERS(COLL_PROTO, COLL_NOsep)
 /*************
  * SCATTER *
  *************/
-#define COLL_SCATTER_SIG scatter, int, \
-                (void *sendbuf, int sendcount, MPI_Datatype sendtype,\
-                void *recvbuf, int recvcount, MPI_Datatype recvtype,\
-                int root, MPI_Comm comm)
 
 #define COLL_SCATTERS(action, COLL_sep) \
 COLL_APPLY(action, COLL_SCATTER_SIG, default) COLL_sep \
@@ -408,10 +394,8 @@ COLL_APPLY(action, COLL_SCATTER_SIG, automatic)
 COLL_SCATTERS(COLL_PROTO, COLL_NOsep)
 
 /*************
- * SCATTER *
+ * BARRIER *
  *************/
-#define COLL_BARRIER_SIG barrier, int, \
-                (MPI_Comm comm)
 
 #define COLL_BARRIERS(action, COLL_sep) \
 COLL_APPLY(action, COLL_BARRIER_SIG, default) COLL_sep \
index d5e043e..a92eb41 100644 (file)
@@ -80,13 +80,13 @@ int Comm::dup(MPI_Comm* newcomm){
   (*newcomm) = new  Comm(cp, this->topo());
   int ret = MPI_SUCCESS;
 
-  if(!attributes_.empty()){
+  if(!attributes()->empty()){
     int flag;
     void* value_out;
-    for(auto it = attributes_.begin(); it != attributes_.end(); it++){
-      smpi_key_elem elem = keyvals_.at((*it).first);
+    for(auto it : *attributes()){
+      smpi_key_elem elem = keyvals_.at(it.first);
       if (elem != nullptr && elem->copy_fn.comm_copy_fn != MPI_NULL_COPY_FN) {
-        ret = elem->copy_fn.comm_copy_fn(this, (*it).first, nullptr, (*it).second, &value_out, &flag);
+        ret = elem->copy_fn.comm_copy_fn(this, it.first, nullptr, it.second, &value_out, &flag);
         if (ret != MPI_SUCCESS) {
           Comm::destroy(*newcomm);
           *newcomm = MPI_COMM_NULL;
@@ -94,7 +94,7 @@ int Comm::dup(MPI_Comm* newcomm){
         }
         if (flag){
           elem->refcount++;
-          (*newcomm)->attributes_.insert({(*it).first, value_out});
+          (*newcomm)->attributes()->insert({it.first, value_out});
         }
       }
       }
@@ -250,10 +250,9 @@ MPI_Comm Comm::split(int color, int key)
             reqs++;
           }
         }
-        if(i != 0) {
-          if(group_out != MPI_COMM_WORLD->group() && group_out != MPI_GROUP_EMPTY)
-            Group::unref(group_out);
-        }
+        if(i != 0 && group_out != MPI_COMM_WORLD->group() && group_out != MPI_GROUP_EMPTY)
+          Group::unref(group_out);
+        
         Request::waitall(reqs, requests, MPI_STATUS_IGNORE);
         xbt_free(requests);
       }
@@ -481,9 +480,9 @@ MPI_Comm Comm::f2c(int id) {
     return MPI_COMM_SELF;
   } else if(id==0){
     return MPI_COMM_WORLD;
-  } else if(F2C::f2c_lookup_ != nullptr && id >= 0) {
+  } else if(F2C::f2c_lookup() != nullptr && id >= 0) {
       char key[KEY_SIZE];
-      MPI_Comm tmp =  static_cast<MPI_Comm>(xbt_dict_get_or_null(F2C::f2c_lookup_,get_key_id(key, id)));
+      MPI_Comm tmp =  static_cast<MPI_Comm>(xbt_dict_get_or_null(F2C::f2c_lookup(),get_key_id(key, id)));
       return tmp != nullptr ? tmp : MPI_COMM_NULL ;
   } else {
     return MPI_COMM_NULL;
@@ -492,17 +491,17 @@ MPI_Comm Comm::f2c(int id) {
 
 void Comm::free_f(int id) {
   char key[KEY_SIZE];
-  xbt_dict_remove(F2C::f2c_lookup_, id==0? get_key(key, id) : get_key_id(key, id));
+  xbt_dict_remove(F2C::f2c_lookup(), id==0? get_key(key, id) : get_key_id(key, id));
 }
 
 int Comm::add_f() {
-  if(F2C::f2c_lookup_==nullptr){
-    F2C::f2c_lookup_=xbt_dict_new_homogeneous(nullptr);
+  if(F2C::f2c_lookup()==nullptr){
+    F2C::set_f2c_lookup(xbt_dict_new_homogeneous(nullptr));
   }
   char key[KEY_SIZE];
-  xbt_dict_set(F2C::f2c_lookup_, this==MPI_COMM_WORLD? get_key(key, F2C::f2c_id_) : get_key_id(key,F2C::f2c_id_), this, nullptr);
-  F2C::f2c_id_++;
-  return F2C::f2c_id_-1;
+  xbt_dict_set(F2C::f2c_lookup(), this==MPI_COMM_WORLD? get_key(key, F2C::f2c_id()) : get_key_id(key,F2C::f2c_id()), this, nullptr);
+  f2c_id_increment();
+  return F2C::f2c_id()-1;
 }
 
 
index b98092f..c0b0c20 100644 (file)
 #include "private.h"
 
 
-typedef struct s_smpi_mpi_comm_key_elem {
-  MPI_Comm_copy_attr_function* copy_fn;
-  MPI_Comm_delete_attr_function* delete_fn;
-} s_smpi_mpi_comm_key_elem_t; 
-typedef struct s_smpi_mpi_comm_key_elem *smpi_comm_key_elem;
-
 namespace simgrid{
 namespace smpi{
 
@@ -40,7 +34,6 @@ class Comm : public F2C, public Keyval{
 
     Comm() = default;
     Comm(MPI_Group group, MPI_Topology topo);
-
     int dup(MPI_Comm* newcomm);
     MPI_Group group();
     MPI_Topology topo();
index d024277..da145d1 100644 (file)
@@ -127,10 +127,11 @@ Datatype::Datatype(Datatype *datatype, int* ret) : name_(nullptr), lb_(datatype-
   *ret = MPI_SUCCESS;
   if(datatype->name_)
     name_ = xbt_strdup(datatype->name_);
-  if(!(datatype->attributes_.empty())){
+  
+  if(!(datatype->attributes()->empty())){
     int flag;
     void* value_out;
-    for(auto it = datatype->attributes_.begin(); it != datatype->attributes_.end(); it++){
+    for(auto it = datatype->attributes()->begin(); it != datatype->attributes()->end(); it++){
       smpi_key_elem elem = keyvals_.at((*it).first);
       
       if (elem != nullptr && elem->copy_fn.type_copy_fn != MPI_NULL_COPY_FN) {
@@ -140,7 +141,7 @@ Datatype::Datatype(Datatype *datatype, int* ret) : name_(nullptr), lb_(datatype-
         }
         if (flag){
           elem->refcount++;
-          attributes_.insert({(*it).first, value_out});
+          attributes()->insert({(*it).first, value_out});
         }
       }
     }
@@ -207,6 +208,10 @@ int Datatype::flags(){
   return flags_;
 }
 
+int Datatype::refcount(){
+  return refcount_;
+}
+
 void Datatype::addflag(int flag){
   flags_ &= flag;
 }
@@ -254,7 +259,7 @@ int Datatype::pack(void* inbuf, int incount, void* outbuf, int outcount, int* po
 }
 
 int Datatype::unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount,MPI_Comm comm){
-  if (outcount*(int)size_> insize)
+  if (outcount*static_cast<int>(size_)> insize)
     return MPI_ERR_BUFFER;
   Datatype::copy(static_cast<char*>(inbuf) + *position, insize, MPI_CHAR, outbuf, outcount, this);
   *position += outcount * size_;
index c652695..30a406b 100644 (file)
@@ -79,7 +79,7 @@ namespace simgrid{
 namespace smpi{
 
 class Datatype : public F2C, public Keyval{
-  protected:
+  private:
     char* name_;
     size_t size_;
     MPI_Aint lb_;
@@ -95,18 +95,21 @@ class Datatype : public F2C, public Keyval{
     Datatype(char* name, int size,MPI_Aint lb, MPI_Aint ub, int flags);
     Datatype(Datatype *datatype, int* ret);
     virtual ~Datatype();
+
+    char* name();
+    size_t size();
+    MPI_Aint lb();
+    MPI_Aint ub();
+    int flags();
+    int refcount();
+
     void ref();
     static void unref(MPI_Datatype datatype);
     void commit();
     bool is_valid();
-    size_t size();
-    int flags();
     void addflag(int flag);
-    MPI_Aint lb();
-    MPI_Aint ub();
     int extent(MPI_Aint * lb, MPI_Aint * extent);
     MPI_Aint get_extent();
-    char* name();
     void get_name(char* name, int* length);
     void set_name(char* name);
     static int copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
index 7a8bc0f..01948ee 100644 (file)
@@ -28,20 +28,17 @@ Type_Contiguous::~Type_Contiguous(){
   Datatype::unref(old_type_);
 }
 
-void Type_Contiguous::ref(){
-  old_type_->ref();
-};
 
 void Type_Contiguous::serialize( void* noncontiguous_buf, void *contiguous_buf, 
                             int count){
   char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
-  char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf)+lb_;
+  char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf)+lb();
   memcpy(contiguous_buf_char, noncontiguous_buf_char, count * block_count_ * old_type_->size());
 }
 void Type_Contiguous::unserialize( void* contiguous_buf, void *noncontiguous_buf, 
                               int count, MPI_Op op){
   char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
-  char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf)+lb_;
+  char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf)+lb();
   int n= count*block_count_;
   if(op!=MPI_OP_NULL)
     op->apply( contiguous_buf_char, noncontiguous_buf_char, &n, old_type_);
@@ -56,10 +53,6 @@ Type_Vector::~Type_Vector(){
   Datatype::unref(old_type_);
 }
 
-void Type_Vector::ref(){
-  old_type_->ref();
-}
-
 
 void Type_Vector::serialize( void* noncontiguous_buf, void *contiguous_buf, 
                             int count){
@@ -109,9 +102,6 @@ Type_Hvector::Type_Hvector(int size,MPI_Aint lb, MPI_Aint ub, int flags, int cou
 Type_Hvector::~Type_Hvector(){
   Datatype::unref(old_type_);
 }
-void Type_Hvector::ref(){
-  old_type_->ref();
-}
 
 void Type_Hvector::serialize( void* noncontiguous_buf, void *contiguous_buf, 
                     int count){
@@ -166,15 +156,12 @@ Type_Indexed::Type_Indexed(int size,MPI_Aint lb, MPI_Aint ub, int flags, int cou
 
 Type_Indexed::~Type_Indexed(){
   Datatype::unref(old_type_);
-  if(refcount_==0){
+  if(refcount()==0){
     delete[] block_lengths_;
     delete[] block_indices_;
   }
 }
 
-void Type_Indexed::ref(){
-  old_type_->ref();
-}
 
 void Type_Indexed::serialize( void* noncontiguous_buf, void *contiguous_buf, 
                         int count){
@@ -238,15 +225,12 @@ Type_Hindexed::Type_Hindexed(int size,MPI_Aint lb, MPI_Aint ub, int flags, int c
 
     Type_Hindexed::~Type_Hindexed(){
   Datatype::unref(old_type_);
-  if(refcount_==0){
+  if(refcount()==0){
     delete[] block_lengths_;
     delete[] block_indices_;
   }
 }
 
-void Type_Hindexed::ref(){
-  old_type_->ref();
-}
 void Type_Hindexed::serialize( void* noncontiguous_buf, void *contiguous_buf, 
                 int count){
   char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
@@ -307,18 +291,13 @@ Type_Struct::~Type_Struct(){
   for (int i = 0; i < block_count_; i++) {
     Datatype::unref(old_types_[i]);
   }
-  if(refcount_==0){
+  if(refcount()==0){
     delete[] block_lengths_;
     delete[] block_indices_;
     delete[] old_types_;
   }
 }
 
-void Type_Struct::ref(){
-  for (int i = 0; i < block_count_; i++) {
-    old_types_[i]->ref();
-  }
-}
 
 void Type_Struct::serialize( void* noncontiguous_buf, void *contiguous_buf, 
                         int count){
@@ -360,7 +339,7 @@ void Type_Struct::unserialize( void* contiguous_buf, void *noncontiguous_buf,
       else
         noncontiguous_buf_char += block_lengths_[i]*old_types_[i]->get_extent();
     }
-    noncontiguous_buf=reinterpret_cast<void*>(noncontiguous_buf_char);
+    noncontiguous_buf=static_cast<void*>(noncontiguous_buf_char);
   }
 }
 
index 914f9d8..eb3b6cb 100644 (file)
@@ -21,7 +21,6 @@ class Type_Contiguous: public Datatype{
   public:
     Type_Contiguous(int size, MPI_Aint lb, MPI_Aint ub, int flags, int block_count, MPI_Datatype old_type);
     ~Type_Contiguous();
-    void ref();
     void serialize( void* noncontiguous, void *contiguous, 
                             int count);
     void unserialize( void* contiguous_vector, void *noncontiguous_vector, 
@@ -37,7 +36,6 @@ class Type_Vector: public Datatype{
   public:
     Type_Vector(int size,MPI_Aint lb, MPI_Aint ub, int flags, int count, int blocklen, int stride, MPI_Datatype old_type);
     ~Type_Vector();
-    void ref();
     void serialize( void* noncontiguous, void *contiguous, 
                             int count);
     void unserialize( void* contiguous_vector, void *noncontiguous_vector, 
@@ -53,7 +51,6 @@ class Type_Hvector: public Datatype{
   public:
     Type_Hvector(int size,MPI_Aint lb, MPI_Aint ub, int flags, int block_count, int block_length, MPI_Aint block_stride, MPI_Datatype old_type);
     ~Type_Hvector();
-    void ref();
     void serialize( void* noncontiguous, void *contiguous, 
                             int count);
     void unserialize( void* contiguous_vector, void *noncontiguous_vector, 
@@ -69,7 +66,6 @@ class Type_Indexed: public Datatype{
   public:
     Type_Indexed(int size,MPI_Aint lb, MPI_Aint ub, int flags, int block_count, int* block_lengths, int* block_indices, MPI_Datatype old_type);
     ~Type_Indexed();
-    void ref();
     void serialize( void* noncontiguous, void *contiguous, 
                             int count);
     void unserialize( void* contiguous_vector, void *noncontiguous_vector, 
@@ -85,7 +81,6 @@ class Type_Hindexed: public Datatype{
   public:
     Type_Hindexed(int size,MPI_Aint lb, MPI_Aint ub, int flags, int block_count, int* block_lengths, MPI_Aint* block_indices, MPI_Datatype old_type);
     ~Type_Hindexed();
-    void ref();
     void serialize( void* noncontiguous, void *contiguous, 
                             int count);
     void unserialize( void* contiguous_vector, void *noncontiguous_vector, 
@@ -101,7 +96,6 @@ class Type_Struct: public Datatype{
   public:
     Type_Struct(int size,MPI_Aint lb, MPI_Aint ub, int flags, int block_count, int* block_lengths, MPI_Aint* block_indices, MPI_Datatype* old_types);
     ~Type_Struct();
-    void ref();
     void serialize( void* noncontiguous, void *contiguous, 
                             int count);
     void unserialize( void* contiguous_vector, void *noncontiguous_vector, 
index 6088ab5..8f97e50 100644 (file)
@@ -73,10 +73,8 @@ double smpi_get_host_consumed_energy() {
 
 #if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
 typedef int integer;
-typedef unsigned int uinteger;
 #else
 typedef long int integer;
-typedef unsigned long int uinteger;
 #endif
 typedef char *address;
 typedef short int shortint;
index b7828d6..e1c05af 100644 (file)
@@ -14,6 +14,22 @@ namespace smpi{
 xbt_dict_t F2C::f2c_lookup_=nullptr;
 int F2C::f2c_id_=0;
 
+xbt_dict_t F2C::f2c_lookup(){
+  return f2c_lookup_;
+}
+
+void F2C::set_f2c_lookup(xbt_dict_t dict){
+  f2c_lookup_=dict;
+}
+
+void F2C::f2c_id_increment(){
+  f2c_id_++;
+};
+
+int F2C::f2c_id(){
+  return f2c_id_;
+};
+
 char* F2C::get_key(char* key, int id) {
   snprintf(key, KEY_SIZE, "%x",id);
   return key;
@@ -43,7 +59,7 @@ int F2C::add_f(){
   }
   char key[KEY_SIZE];
   xbt_dict_set(f2c_lookup_, get_key(key, f2c_id_), this, nullptr);
-  f2c_id_++;
+  f2c_id_increment();
   return f2c_id_-1;
 }
 
index a013e04..3623771 100644 (file)
@@ -18,11 +18,16 @@ namespace simgrid{
 namespace smpi{
 
 class F2C {
-  protected:
+  private:
     // We use a single lookup table for every type. 
     // Beware of collisions if id in mpif.h is not unique
     static xbt_dict_t f2c_lookup_;
     static int f2c_id_;
+  protected:
+    static xbt_dict_t f2c_lookup();
+    static void set_f2c_lookup(xbt_dict_t dict);
+    static int f2c_id();
+    static void f2c_id_increment();
   public:
     static char* get_key(char* key, int id);
     static char* get_key_id(char* key, int id);
@@ -37,7 +42,7 @@ class F2C {
     //This method should be overriden in all subclasses
     //to avoid casting the result when calling it.
     //For the default one, the MPI_*_NULL returned is assumed to be NULL.
-    static F2C* f2c(int);
+    static F2C* f2c(int id);
 };
 
 }
index 732c82f..cbf0e62 100644 (file)
@@ -13,10 +13,8 @@ static int running_processes = 0;
 
 #if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
 typedef int integer;
-typedef unsigned int uinteger;
 #else
 typedef long int integer;
-typedef unsigned long int uinteger;
 #endif
 
 /* Convert between Fortran and C */
@@ -490,7 +488,7 @@ void mpi_type_free_(int* datatype, int* ierr){
   MPI_Datatype tmp= Datatype::f2c(*datatype);
   *ierr= MPI_Type_free (&tmp);
   if(*ierr == MPI_SUCCESS) {
-    Datatype::free_f(*datatype);
+    F2C::free_f(*datatype);
   }
 }
 
@@ -519,7 +517,7 @@ void mpi_win_free_( int* win, int* ierr){
   MPI_Win tmp = Win::f2c(*win);
   *ierr =  MPI_Win_free(&tmp);
   if(*ierr == MPI_SUCCESS) {
-    Win::free_f(*win);
+    F2C::free_f(*win);
   }
 }
 
@@ -631,7 +629,7 @@ void mpi_info_free_(int* info, int* ierr){
   MPI_Info tmp = Info::f2c(*info);
   *ierr =  MPI_Info_free(&tmp);
   if(*ierr == MPI_SUCCESS) {
-    Info::free_f(*info);
+    F2C::free_f(*info);
   }
 }
 
@@ -759,7 +757,7 @@ void mpi_op_free_ (int* op, int* ierr){
   MPI_Op tmp=Op::f2c(*op);
   *ierr = MPI_Op_free(& tmp);
   if(*ierr == MPI_SUCCESS) {
-    Op::free_f(*op);
+    F2C::free_f(*op);
   }
 }
 
@@ -767,7 +765,7 @@ void mpi_group_free_ (int* group, int* ierr){
  MPI_Group tmp=Group::f2c(*group);
  *ierr = MPI_Group_free(&tmp);
  if(*ierr == MPI_SUCCESS) {
-   Group::free_f(*group);
+   F2C::free_f(*group);
  }
 }
 
index fd78c2c..adb199d 100644 (file)
@@ -382,9 +382,9 @@ int Group::range_excl(int n, int ranges[][3], MPI_Group * newgroup){
 MPI_Group Group::f2c(int id) {
   if(id == -2) {
     return MPI_GROUP_EMPTY;
-  } else if(F2C::f2c_lookup_ != nullptr && id >= 0) {
+  } else if(F2C::f2c_lookup() != nullptr && id >= 0) {
     char key[KEY_SIZE];
-    return static_cast<MPI_Group>(xbt_dict_get_or_null(F2C::f2c_lookup_, get_key(key, id)));
+    return static_cast<MPI_Group>(xbt_dict_get_or_null(F2C::f2c_lookup(), get_key(key, id)));
   } else {
     return static_cast<MPI_Group>(MPI_GROUP_NULL);
   }
index 8b9fb64..50b3f92 100644 (file)
@@ -91,7 +91,7 @@ int Info::get_nthkey(int n, char *key){
 
 int Info::get_valuelen(char *key, int *valuelen, int *flag){
   *flag=false;
-  char* tmpvalue=(char*)xbt_dict_get_or_null(dict_, key);
+  char* tmpvalue=static_cast<char*>(xbt_dict_get_or_null(dict_, key));
   if(tmpvalue){
     *valuelen=strlen(tmpvalue);
     *flag=true;
index 03019ad..a3a6235 100644 (file)
@@ -20,7 +20,7 @@ class Info : public F2C{
     int refcount_;
   public:
     explicit Info();
-    Info(Info* orig);
+    explicit Info(Info* orig);
     ~Info();
     void ref();
     static void unref(MPI_Info info);
index 9eb473f..3808b65 100644 (file)
 namespace simgrid{
 namespace smpi{
 
+std::unordered_map<int, void*>* Keyval::attributes(){
+  return &attributes_;
+};
+
 
 template <> int Keyval::call_deleter<Comm>(Comm* obj, smpi_key_elem elem, int keyval, void * value, int* flag){
   if(elem->delete_fn.comm_delete_fn!=MPI_NULL_DELETE_FN){
index 0ca8ffc..7f461ba 100644 (file)
@@ -15,13 +15,13 @@ namespace simgrid{
 namespace smpi{
 
 
-typedef union smpi_delete_fn{
+typedef struct smpi_delete_fn{
   MPI_Comm_delete_attr_function          *comm_delete_fn;
   MPI_Type_delete_attr_function          *type_delete_fn;
   MPI_Win_delete_attr_function           *win_delete_fn;
 } smpi_delete_fn;
 
-typedef union smpi_copy_fn{
+typedef struct smpi_copy_fn{
   MPI_Comm_copy_attr_function          *comm_copy_fn;
   MPI_Type_copy_attr_function          *type_copy_fn;
   MPI_Win_copy_attr_function           *win_copy_fn;
@@ -35,8 +35,10 @@ typedef struct s_smpi_key_elem {
 typedef struct s_smpi_key_elem *smpi_key_elem;
 
 class Keyval{
-  protected:
+  private:
     std::unordered_map<int, void*> attributes_;
+  protected:
+    std::unordered_map<int, void*>* attributes();
   public:
 // Each subclass should have two members, as we want to separate the ones for Win, Comm, and Datatypes :  
 //    static std::unordered_map<int, smpi_key_elem> keyvals_;
@@ -92,9 +94,9 @@ template <typename T> int Keyval::attr_delete(int keyval){
     if(ret!=MPI_SUCCESS)
         return ret;
   }
-  if(attributes_.empty())
+  if(attributes()->empty())
     return MPI_ERR_ARG;
-  attributes_.erase(keyval);
+  attributes()->erase(keyval);
   return MPI_SUCCESS;
 }
 
@@ -103,12 +105,12 @@ template <typename T> int Keyval::attr_get(int keyval, void* attr_value, int* fl
   smpi_key_elem elem = T::keyvals_.at(keyval);
   if(elem==nullptr)
     return MPI_ERR_ARG;
-  if(attributes_.empty()){
+  if(attributes()->empty()){
     *flag=0;
     return MPI_SUCCESS;
   }
   try {
-    *static_cast<void**>(attr_value) = attributes_.at(keyval);
+    *static_cast<void**>(attr_value) = attributes()->at(keyval);
     *flag=1;
   }
   catch (const std::out_of_range& oor) {
@@ -130,21 +132,22 @@ template <typename T> int Keyval::attr_put(int keyval, void* attr_value){
     if(ret!=MPI_SUCCESS)
         return ret;
   }
-  attributes_.insert({keyval, attr_value});
+  attributes()->insert({keyval, attr_value});
   return MPI_SUCCESS;
 }
 
 template <typename T> void Keyval::cleanup_attr(){
-  if(!attributes_.empty()){
+  if(!attributes()->empty()){
     int flag=0;
-    for(auto it = attributes_.begin(); it != attributes_.end(); it++){
+    for(auto it : attributes_){
       try{
-        smpi_key_elem elem = T::keyvals_.at((*it).first);
+        smpi_key_elem elem = T::keyvals_.at(it.first);
         if(elem != nullptr){
-          call_deleter<T>((T*)this, elem, (*it).first,(*it).second,&flag);
+          call_deleter<T>((T*)this, elem, it.first,it.second,&flag);
         }
       }catch(const std::out_of_range& oor) {
         //already deleted, not a problem;
+        flag=0;
       }
     }
   }
index 6e72855..7cedfd7 100644 (file)
@@ -2772,10 +2772,8 @@ MPI_Fint PMPI_Info_c2f(MPI_Info info){
 }
 
 int PMPI_Keyval_create(MPI_Copy_function* copy_fn, MPI_Delete_function* delete_fn, int* keyval, void* extra_state) {
-  smpi_copy_fn _copy_fn;
-  smpi_delete_fn _delete_fn;
-  _copy_fn.comm_copy_fn = copy_fn;
-  _delete_fn.comm_delete_fn = delete_fn;
+  smpi_copy_fn _copy_fn={copy_fn,nullptr,nullptr};
+  smpi_delete_fn _delete_fn={delete_fn,nullptr,nullptr};
   return Keyval::keyval_create<Comm>(_copy_fn, _delete_fn, keyval, extra_state);
 }
 
@@ -2894,10 +2892,8 @@ int PMPI_Type_delete_attr (MPI_Datatype type, int type_keyval)
 int PMPI_Type_create_keyval(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval,
                             void* extra_state)
 {
-  smpi_copy_fn _copy_fn;
-  smpi_delete_fn _delete_fn;
-  _copy_fn.type_copy_fn = copy_fn;
-  _delete_fn.type_delete_fn = delete_fn;
+  smpi_copy_fn _copy_fn={nullptr,copy_fn,nullptr};
+  smpi_delete_fn _delete_fn={nullptr,delete_fn,nullptr};
   return Keyval::keyval_create<Datatype>(_copy_fn, _delete_fn, keyval, extra_state);
 }
 
@@ -2953,10 +2949,8 @@ int PMPI_Win_delete_attr (MPI_Win win, int type_keyval)
 int PMPI_Win_create_keyval(MPI_Win_copy_attr_function* copy_fn, MPI_Win_delete_attr_function* delete_fn, int* keyval,
                             void* extra_state)
 {
-  smpi_copy_fn _copy_fn;
-  smpi_delete_fn _delete_fn;
-  _copy_fn.win_copy_fn = copy_fn;
-  _delete_fn.win_delete_fn = delete_fn;
+  smpi_copy_fn _copy_fn={nullptr, nullptr, copy_fn};
+  smpi_delete_fn _delete_fn={nullptr, nullptr, delete_fn};
   return Keyval::keyval_create<Win>(_copy_fn, _delete_fn, keyval, extra_state);
 }
 
index 85f55b6..b206d0a 100644 (file)
@@ -1004,23 +1004,23 @@ MPI_Request Request::f2c(int id) {
   char key[KEY_SIZE];
   if(id==MPI_FORTRAN_REQUEST_NULL)
     return static_cast<MPI_Request>(MPI_REQUEST_NULL);
-  return static_cast<MPI_Request>(xbt_dict_get(F2C::f2c_lookup_, get_key_id(key, id)));
+  return static_cast<MPI_Request>(xbt_dict_get(F2C::f2c_lookup(), get_key_id(key, id)));
 }
 
 int Request::add_f() {
-  if(F2C::f2c_lookup_==nullptr){
-    F2C::f2c_lookup_=xbt_dict_new_homogeneous(nullptr);
+  if(F2C::f2c_lookup()==nullptr){
+    F2C::set_f2c_lookup(xbt_dict_new_homogeneous(nullptr));
   }
   char key[KEY_SIZE];
-  xbt_dict_set(F2C::f2c_lookup_, get_key_id(key, F2C::f2c_id_), this, nullptr);
-  F2C::f2c_id_++;
-  return F2C::f2c_id_-1;
+  xbt_dict_set(F2C::f2c_lookup(), get_key_id(key, F2C::f2c_id()), this, nullptr);
+  F2C::f2c_id_increment();
+  return F2C::f2c_id()-1;
 }
 
 void Request::free_f(int id) {
   char key[KEY_SIZE];
   if(id!=MPI_FORTRAN_REQUEST_NULL)
-    xbt_dict_remove(F2C::f2c_lookup_, get_key_id(key, id));
+    xbt_dict_remove(F2C::f2c_lookup(), get_key_id(key, id));
 }
 
 
index be61448..7aa83d9 100755 (executable)
@@ -25,7 +25,7 @@ if (defined $options{f}) {
 }
 
 print "$commentChar This file has been automatically generated by the script\n";
-print "$commentChar in tools/smpi/" . __FILE__ ."\n";
+print "$commentChar in tools/smpi/generate_smpi_defines.pl\n";
 print "$commentChar DO NOT EDIT MANUALLY. ALL CHANGES WILL BE OVERWRITTEN!\n";
 
 # Formatting of the output