00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _util_group_messmpi_h
00029 #define _util_group_messmpi_h
00030
00031 #include <util/group/message.h>
00032 #include <util/group/thread.h>
00033
00034 #define MPICH_SKIP_MPICXX
00035 #include <mpi.h>
00036
00037 namespace sc {
00038
00041 class MPIMessageGrp: public MessageGrp {
00042 protected:
00043 void* buf;
00044 int bufsize;
00045
00047 bool use_messagegrp_collectives_;
00048
00050 static int nmpi_grps;
00052 static Ref<ThreadLock> grplock;
00053
00054 Ref<ThreadGrp> threadgrp;
00056 MPI_Comm commgrp;
00057
00059 void init(MPI_Comm comm, int *argc=0, char ***argv=0);
00060
00061 class MessageHandleData {
00062 public:
00063 MPI_Request req;
00064 size_t nbyte;
00065 MessageHandleData(size_t n): nbyte(n) {}
00066 };
00067 public:
00068 MPIMessageGrp();
00071 MPIMessageGrp(MPI_Comm comm);
00075 MPIMessageGrp(int *argc, char ***argv);
00077 MPIMessageGrp(const Ref<KeyVal>&);
00078 ~MPIMessageGrp();
00079
00081 Ref<MessageGrp> clone(void);
00082
00083 void raw_send(int target, const void* data, int nbyte);
00084 void raw_recv(int sender, void* data, int nbyte,
00085 MessageInfo *info=0);
00086 void raw_sendt(int target, int type, const void* data, int nbyte,
00087 bool rcvrdy=false);
00088 void raw_recvt(int sender, int type, void* data, int nbyte,
00089 MessageInfo *info=0);
00090
00091 int probet(int sender, int type, MessageInfo *info=0);
00092
00093 void sync();
00094
00095 void sum(double*, int n, double*scratch = 0, int target = -1);
00096 void sum(int*, int n, int*scratch = 0, int target = -1);
00097
00098 void reduce(double*, int n, GrpReduce<double>&,
00099 double*scratch = 0, int target = -1);
00100 void reduce(unsigned int*, int n, GrpReduce<unsigned int>&,
00101 unsigned int*scratch = 0, int target = -1);
00102 void reduce(int*, int n, GrpReduce<int>&,
00103 int*scratch = 0, int target = -1);
00104 void reduce(char*, int n, GrpReduce<char>&,
00105 char*scratch = 0, int target = -1);
00106 void reduce(unsigned char*, int n, GrpReduce<unsigned char>&,
00107 unsigned char*scratch = 0, int target = -1);
00108 void reduce(signed char*, int n, GrpReduce<signed char>&,
00109 signed char*scratch = 0, int target = -1);
00110 void reduce(short*, int n, GrpReduce<short>&,
00111 short*scratch = 0, int target = -1);
00112 void reduce(float*, int n, GrpReduce<float>&,
00113 float*scratch = 0, int target = -1);
00114 void reduce(long*, int n, GrpReduce<long>&,
00115 long*scratch = 0, int target = -1);
00116
00117 void raw_nb_sendt(int sender, int type,
00118 const void* data, int nbyte,
00119 MessageHandle&,
00120 bool rcvrdy=false);
00121 void raw_nb_recvt(int sender, int type,
00122 void* data, int nbyte,
00123 MessageHandle&);
00124 void wait(const MessageHandle&,
00125 MessageInfo *info=0);
00126
00127 void raw_bcast(void* data, int nbyte, int from);
00128 };
00129
00130 }
00131
00132 #endif
00133
00134
00135
00136
00137