/** \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
static void (*smpi_coll_cleanup_callback)();
};
-class Coll_algo{
- private:
- char* description_;
- public:
- char* description();
-};
-
-class Coll_gather : public Coll_algo {
- private:
- public:
- static int gather (void *, int, MPI_Datatype, void*, int, MPI_Datatype, int root, MPI_Comm);
-};
-
-class Coll_allgather : public Coll_algo {
- private:
- public:
- static int allgather (void *, int, MPI_Datatype, void*, int, MPI_Datatype, MPI_Comm);
-};
-
-class Coll_allgatherv : public Coll_algo {
- private:
- public:
- static int allgatherv (void *, int, MPI_Datatype, void*, int*, int*, MPI_Datatype, MPI_Comm);
-};
-
-class Coll_allreduce : public Coll_algo {
- private:
+class Coll {
public:
- static int allreduce (void *sbuf, void *rbuf, int rcount, MPI_Datatype dtype, MPI_Op op, MPI_Comm comm);
+ // 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,"");
};
-class Coll_alltoall : public Coll_algo {
- private:
- public:
- static int alltoall (void *, int, MPI_Datatype, void*, int, MPI_Datatype, MPI_Comm);
-};
-
-class Coll_alltoallv : public Coll_algo {
- private:
- public:
- static int alltoallv (void *, int*, int*, MPI_Datatype, void*, int*, int*, MPI_Datatype, MPI_Comm);
-};
-
-class Coll_bcast : public Coll_algo {
- private:
- public:
- static int bcast (void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm com);
-};
-
-class Coll_reduce : public Coll_algo {
- private:
- public:
- static int reduce (void *buf, void *rbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm);
-};
-
-class Coll_reduce_scatter : public Coll_algo {
- private:
- public:
- static int reduce_scatter (void *sbuf, void *rbuf, int *rcounts,MPI_Datatype dtype,MPI_Op op,MPI_Comm comm);
-};
-
-class Coll_scatter : public Coll_algo {
- private:
- public:
- static int scatter (void *sendbuf, int sendcount, MPI_Datatype sendtype,void *recvbuf, int recvcount, MPI_Datatype recvtype,int root, MPI_Comm comm);
-};
-
-class Coll_barrier : public Coll_algo {
- private:
- public:
- 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_ ## cat { \
-public: \
-static ret cat (COLL_UNPAREN args); \
-};
-
-#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 \