00001 #ifndef _MY_NetMPI_
00002 #define _MY_NetMPI_
00003 #include "globals.h"
00004 #include "vecdouble.h"
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
00030
00031
00032
00033
00034
00035 #pragma GCC diagnostic ignored "-Wunused-parameter"
00036 #include <mpi.h>
00037 #pragma GCC diagnostic warning "-Wunused-parameter"
00038 #include <iostream>
00039
00043 typedef std::vector<MPI_Request> VecReq;
00044 class NetMPI
00045 {
00046 private:
00047 static bool m_loop;
00048 static bool b1,b2,m_print;
00049 protected:
00050 static int m_nP,m_rank;
00051 public:
00052 static int rank();
00053 static int nProcess();
00054 static bool isLastProcess();
00055 static std::ostream *m_out;
00056 static void setTrace(bool b){m_print=b;}
00057 static std::ostream& getLog();
00058 static void setLog(std::ostream &out){m_out=&out;}
00059
00060 static void Isend(VecDouble &v,int dst,int tag,MPI_Request &req)
00061 {
00062 if (dst >= 0 && dst < nProcess())
00063 MPI_Isend(&(v(0)),v.size(),MPI_DOUBLE,dst,tag,MPI_COMM_WORLD,&req);
00064
00065 }
00066 static void Barrier()
00067 {
00068 MPI_Barrier(MPI_COMM_WORLD);
00069 }
00070 static void Irecv(VecDouble &v,int src,int tag,MPI_Request &req)
00071 {
00072 if (src >= 0 && src < nProcess())
00073 MPI_Irecv(&(v(0)),v.size(),MPI_DOUBLE,src,tag,MPI_COMM_WORLD,&req);
00074 }
00075 static void exchangeDataRedBlack(VecIndex &vLSndMap,VecDouble &vLSnd,VecIndex &vLRcvMap,VecDouble &vLRcv,VecIndex &vRSndMap,VecDouble &vRSnd,VecIndex &vRRcvMap,VecDouble &vRRcv,VecDouble &data,int tag);
00076 static void exchangeDataRedBlack(VecIndex &vLSndMap,VecDouble &vLSnd,VecDouble &vLRcv,VecIndex &vRSndMap,VecDouble &vRSnd,VecDouble &vRRcv,VecDouble &data,int tag,VecReq &req);
00077 static void exchangeDataRedBlack(VecIndex &vLSndMap,VecDouble &vLSnd,VecIndex &vLRcvMap,VecDouble &vLRcv,VecIndex &vRSndMap,VecDouble &vRSnd,VecIndex &vRRcvMap,VecDouble &vRRcv,VecDouble &dataSnd, VecDouble &dataRcv, int tag);
00078
00079 static void trace(const char *format,...);
00080 static void debugPoint();
00081 static double getMinValue(double localValue);
00082 };
00083
00084
00085
00086
00087 #endif