// 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__); })
#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__); })
#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__); })
! 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
#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
#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
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");
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{
/** 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)
-#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,"");
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);
}
// 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;
}
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);
}
}
}
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;
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{
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);
}
}
}
/** \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
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 \
/*************
* 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 \
/**************
* 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 \
/*************
* 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 \
/************
* 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 \
/*************
* 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 \
/*********
* 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 \
/**********
* 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 \
/*************
* 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 \
/*************
* 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 \
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 \
(*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;
}
if (flag){
elem->refcount++;
- (*newcomm)->attributes_.insert({(*it).first, value_out});
+ (*newcomm)->attributes()->insert({it.first, value_out});
}
}
}
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);
}
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;
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;
}
#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{
Comm() = default;
Comm(MPI_Group group, MPI_Topology topo);
-
int dup(MPI_Comm* newcomm);
MPI_Group group();
MPI_Topology topo();
*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) {
}
if (flag){
elem->refcount++;
- attributes_.insert({(*it).first, value_out});
+ attributes()->insert({(*it).first, value_out});
}
}
}
return flags_;
}
+int Datatype::refcount(){
+ return refcount_;
+}
+
void Datatype::addflag(int flag){
flags_ &= flag;
}
}
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_;
namespace smpi{
class Datatype : public F2C, public Keyval{
- protected:
+ private:
char* name_;
size_t size_;
MPI_Aint lb_;
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,
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_);
Datatype::unref(old_type_);
}
-void Type_Vector::ref(){
- old_type_->ref();
-}
-
void Type_Vector::serialize( void* noncontiguous_buf, void *contiguous_buf,
int count){
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){
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){
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);
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){
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);
}
}
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,
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,
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,
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,
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,
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,
#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;
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;
}
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;
}
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);
//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);
};
}
#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 */
MPI_Datatype tmp= Datatype::f2c(*datatype);
*ierr= MPI_Type_free (&tmp);
if(*ierr == MPI_SUCCESS) {
- Datatype::free_f(*datatype);
+ F2C::free_f(*datatype);
}
}
MPI_Win tmp = Win::f2c(*win);
*ierr = MPI_Win_free(&tmp);
if(*ierr == MPI_SUCCESS) {
- Win::free_f(*win);
+ F2C::free_f(*win);
}
}
MPI_Info tmp = Info::f2c(*info);
*ierr = MPI_Info_free(&tmp);
if(*ierr == MPI_SUCCESS) {
- Info::free_f(*info);
+ F2C::free_f(*info);
}
}
MPI_Op tmp=Op::f2c(*op);
*ierr = MPI_Op_free(& tmp);
if(*ierr == MPI_SUCCESS) {
- Op::free_f(*op);
+ F2C::free_f(*op);
}
}
MPI_Group tmp=Group::f2c(*group);
*ierr = MPI_Group_free(&tmp);
if(*ierr == MPI_SUCCESS) {
- Group::free_f(*group);
+ F2C::free_f(*group);
}
}
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);
}
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;
int refcount_;
public:
explicit Info();
- Info(Info* orig);
+ explicit Info(Info* orig);
~Info();
void ref();
static void unref(MPI_Info info);
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){
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;
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_;
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;
}
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) {
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;
}
}
}
}
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);
}
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);
}
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);
}
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));
}
}
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