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
00046 int rnode;
00047 int rtag;
00048 int rlen;
00049
00051 static int nmpi_grps;
00053 static Ref<ThreadLock> grplock;
00054
00055 Ref<ThreadGrp> threadgrp;
00057 MPI_Comm commgrp;
00058
00060 void init(MPI_Comm comm, int *argc=0, char ***argv=0);
00061 public:
00062 MPIMessageGrp();
00065 MPIMessageGrp(MPI_Comm comm);
00069 MPIMessageGrp(int *argc, char ***argv);
00071 MPIMessageGrp(const Ref<KeyVal>&);
00072 ~MPIMessageGrp();
00073
00075 Ref<MessageGrp> clone(void);
00076
00077 void raw_send(int target, void* data, int nbyte);
00078 void raw_recv(int sender, void* data, int nbyte);
00079 void raw_sendt(int target, int type, void* data, int nbyte);
00080 void raw_recvt(int type, void* data, int nbyte);
00081
00082 int probet(int type);
00083
00084 void sync();
00085
00086 void reduce(double*, int n, GrpReduce<double>&,
00087 double*scratch = 0, int target = -1);
00088 void reduce(unsigned int*, int n, GrpReduce<unsigned int>&,
00089 unsigned int*scratch = 0, int target = -1);
00090 void reduce(int*, int n, GrpReduce<int>&,
00091 int*scratch = 0, int target = -1);
00092 void reduce(char*, int n, GrpReduce<char>&,
00093 char*scratch = 0, int target = -1);
00094 void reduce(unsigned char*, int n, GrpReduce<unsigned char>&,
00095 unsigned char*scratch = 0, int target = -1);
00096 void reduce(signed char*, int n, GrpReduce<signed char>&,
00097 signed char*scratch = 0, int target = -1);
00098 void reduce(short*, int n, GrpReduce<short>&,
00099 short*scratch = 0, int target = -1);
00100 void reduce(float*, int n, GrpReduce<float>&,
00101 float*scratch = 0, int target = -1);
00102 void reduce(long*, int n, GrpReduce<long>&,
00103 long*scratch = 0, int target = -1);
00104
00105 void raw_bcast(void* data, int nbyte, int from);
00106 };
00107
00108 }
00109
00110 #endif
00111
00112
00113
00114
00115