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 #include <mpi.h>
00035
00036 namespace sc {
00037
00040 class MPIMessageGrp: public MessageGrp {
00041 protected:
00042 void* buf;
00043 int bufsize;
00044
00045 int rnode;
00046 int rtag;
00047 int rlen;
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 public:
00061 MPIMessageGrp();
00064 MPIMessageGrp(MPI_Comm comm);
00068 MPIMessageGrp(int *argc, char ***argv);
00070 MPIMessageGrp(const Ref<KeyVal>&);
00071 ~MPIMessageGrp();
00072
00074 Ref<MessageGrp> clone(void);
00075
00076 void raw_send(int target, void* data, int nbyte);
00077 void raw_recv(int sender, void* data, int nbyte);
00078 void raw_sendt(int target, int type, void* data, int nbyte);
00079 void raw_recvt(int type, void* data, int nbyte);
00080
00081 int probet(int type);
00082
00083 void sync();
00084
00085 void reduce(double*, int n, GrpReduce<double>&,
00086 double*scratch = 0, int target = -1);
00087 void reduce(unsigned int*, int n, GrpReduce<unsigned int>&,
00088 unsigned int*scratch = 0, int target = -1);
00089 void reduce(int*, int n, GrpReduce<int>&,
00090 int*scratch = 0, int target = -1);
00091 void reduce(char*, int n, GrpReduce<char>&,
00092 char*scratch = 0, int target = -1);
00093 void reduce(unsigned char*, int n, GrpReduce<unsigned char>&,
00094 unsigned char*scratch = 0, int target = -1);
00095 void reduce(signed char*, int n, GrpReduce<signed char>&,
00096 signed char*scratch = 0, int target = -1);
00097 void reduce(short*, int n, GrpReduce<short>&,
00098 short*scratch = 0, int target = -1);
00099 void reduce(float*, int n, GrpReduce<float>&,
00100 float*scratch = 0, int target = -1);
00101 void reduce(long*, int n, GrpReduce<long>&,
00102 long*scratch = 0, int target = -1);
00103
00104 void raw_bcast(void* data, int nbyte, int from);
00105 };
00106
00107 }
00108
00109 #endif
00110
00111
00112
00113
00114