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
00029 #ifdef __GNUC__
00030 #pragma interface
00031 #endif
00032
00033 #ifndef _util_group_memmtmpi_h
00034 #define _util_group_memmtmpi_h
00035
00036 #include <fstream>
00037 #define MPICH_SKIP_MPICXX
00038 #include <mpi.h>
00039
00040 #include <util/group/message.h>
00041 #include <util/group/memamsg.h>
00042 #include <util/group/thread.h>
00043
00044 namespace sc {
00045
00046 class MTMPIThread;
00047
00052 class MTMPIMemoryGrp: public ActiveMsgMemoryGrp {
00053 private:
00054 Ref<ThreadGrp> th_;
00055
00056 Ref<ThreadLock> serial_lock_;
00057 int serial_;
00058 int serial(int node);
00059
00060 MPI_Comm comp_comm_;
00061 MPI_Comm comm_comm_;
00062 int req_tag_;
00063
00064 int active_;
00065
00066 unsigned int *nreq_sent_;
00067 unsigned int *nreq_sent_buf_;
00068
00069 MTMPIThread **thread_;
00070 Ref<ThreadLock> print_lock_;
00071 std::ofstream hout;
00072 std::ofstream mout;
00073
00074 void init_mtmpimg(MPI_Comm comm, int nthreads);
00075
00076
00077 void retrieve_data(void *, int node, int offset, int size, int lock);
00078 void replace_data(void *, int node, int offset, int size, int unlock);
00079 void sum_data(double *data, int node, int doffset, int dsize);
00080
00081 friend class MTMPIThread;
00082 public:
00087 MTMPIMemoryGrp(const Ref<MessageGrp>& msg, const Ref<ThreadGrp> &th,
00088 MPI_Comm comm = MPI_COMM_WORLD);
00091 MTMPIMemoryGrp(const Ref<KeyVal> &);
00092 ~MTMPIMemoryGrp();
00093
00094 void activate();
00095 void deactivate();
00096
00097 void sync();
00098 };
00099
00100 }
00101
00102 #endif
00103
00104
00105
00106
00107