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