NetMPI Class Reference

#include <netmpi.h>

Collaboration diagram for NetMPI:
Collaboration graph
[legend]

List of all members.

Static Public Member Functions

static int rank ()
static int nProcess ()
static bool isLastProcess ()
static void setTrace (bool b)
static std::ostream & getLog ()
static void setLog (std::ostream &out)
static void Isend (VecDouble &v, int dst, int tag, MPI_Request &req)
static void Barrier ()
static void Irecv (VecDouble &v, int src, int tag, MPI_Request &req)
static void exchangeDataRedBlack (VecIndex &vLSndMap, VecDouble &vLSnd, VecIndex &vLRcvMap, VecDouble &vLRcv, VecIndex &vRSndMap, VecDouble &vRSnd, VecIndex &vRRcvMap, VecDouble &vRRcv, VecDouble &data, int tag)
static void exchangeDataRedBlack (VecIndex &vLSndMap, VecDouble &vLSnd, VecDouble &vLRcv, VecIndex &vRSndMap, VecDouble &vRSnd, VecDouble &vRRcv, VecDouble &data, int tag, VecReq &req)
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)
static void trace (const char *format,...)
static void debugPoint ()
static double getMinValue (double localValue)

Static Public Attributes

static std::ostream * m_out = &(std::cout)

Static Protected Attributes

static int m_nP = -1
static int m_rank = -1

Static Private Attributes

static bool m_loop = false
static bool b1 = false
static bool b2 = false
static bool m_print = false

Detailed Description

Definition at line 44 of file netmpi.h.


Member Function Documentation

static void NetMPI::Barrier (  )  [inline, static]

Definition at line 66 of file netmpi.h.

00067   {
00068     MPI_Barrier(MPI_COMM_WORLD);
00069  }

void NetMPI::debugPoint (  )  [static]

Definition at line 174 of file netmpi.cpp.

00175 {
00176   m_loop=true;
00177   while(m_loop)
00178   {
00179     ;
00180   }
00181   
00182 }

void NetMPI::exchangeDataRedBlack ( VecIndex vLSndMap,
VecDouble vLSnd,
VecIndex vLRcvMap,
VecDouble vLRcv,
VecIndex vRSndMap,
VecDouble vRSnd,
VecIndex vRRcvMap,
VecDouble vRRcv,
VecDouble dataSnd,
VecDouble dataRcv,
int  tag 
) [static]

Definition at line 56 of file netmpi.cpp.

00057 {
00058   MPI_Request _req[4];
00059   MPI_Status _status[4];
00060   assert(vLSndMap.size() == vLSnd.size());
00061   assert(vRSndMap.size() == vRSnd.size());
00062   assert(vRRcvMap.size() == vRRcv.size());
00063   assert(vLRcvMap.size() == vLRcv.size());
00064   _req[0]=_req[1]=_req[2]=_req[3] = MPI_REQUEST_NULL;
00065   
00066   int next = NetMPI::rank()+1;
00067   int prev = NetMPI::rank()-1;
00068   if (NetMPI::rank()%2 == 0) //Red Node
00069   {
00070     for (unsigned i=0;i<vLSndMap.size();i++)
00071       vLSnd(i)=dataSnd(vLSndMap[i]);
00072     NetMPI::Isend(vLSnd,prev,tag,_req[0]);
00073 
00074     for (unsigned i=0;i<vRSndMap.size();i++)
00075       vRSnd(i)=dataSnd(vRSndMap[i]);
00076     NetMPI::Isend(vRSnd,next,tag,_req[1]);
00077 
00078     NetMPI::Irecv(vLRcv,prev,tag,_req[2]);
00079     NetMPI::Irecv(vRRcv,next,tag,_req[3]);
00080 
00081   }
00082   else if (NetMPI::rank()%2 == 1) //Black Node
00083   {
00084     NetMPI::Irecv(vRRcv,next,tag,_req[0]);
00085     NetMPI::Irecv(vLRcv,prev,tag,_req[1]);
00086 
00087     for (unsigned i=0;i<vRSndMap.size();i++)
00088       vRSnd(i)=dataSnd(vRSndMap[i]);
00089     NetMPI::Isend(vRSnd,next,tag,_req[2]);
00090 
00091 
00092     for (unsigned i=0;i<vLSndMap.size();i++)
00093       vLSnd(i)=dataSnd(vLSndMap[i]);
00094     NetMPI::Isend(vLSnd,prev,tag,_req[3]);
00095     
00096   }
00097   MPI_Waitall(4,_req,_status);
00098   for (unsigned i=0;i<vLRcv.size();i++)
00099   {
00100     dataRcv(vLRcvMap[i]) = vLRcv(i);
00101   }
00102   for (unsigned i=0;i<vRRcv.size();i++)
00103   {
00104     dataRcv(vRRcvMap[i]) = vRRcv(i);
00105   }
00106 
00107 
00108 }

void NetMPI::exchangeDataRedBlack ( VecIndex vLSndMap,
VecDouble vLSnd,
VecDouble vLRcv,
VecIndex vRSndMap,
VecDouble vRSnd,
VecDouble vRRcv,
VecDouble data,
int  tag,
VecReq req 
) [static]

Definition at line 117 of file netmpi.cpp.

00118 {
00119   assert(_req.size() == 4);
00120   assert(vLSndMap.size() == vLSnd.size());
00121   assert(vRSndMap.size() == vRSnd.size());
00122 
00123   
00124   
00125   int next = NetMPI::rank()+1;
00126   int prev = NetMPI::rank()-1;
00127   if (NetMPI::rank()%2 == 0) //Red Node
00128   {
00129     for (unsigned i=0;i<vLSndMap.size();i++)
00130       vLSnd(i)=data(vLSndMap[i]);
00131     NetMPI::Isend(vLSnd,prev,tag,_req[0]);
00132 
00133     for (unsigned i=0;i<vRSndMap.size();i++)
00134       vRSnd(i)=data(vRSndMap[i]);
00135     NetMPI::Isend(vRSnd,next,tag,_req[1]);
00136 
00137     NetMPI::Irecv(vLRcv,prev,tag,_req[2]);
00138     NetMPI::Irecv(vRRcv,next,tag,_req[3]);
00139 
00140   }
00141   else if (NetMPI::rank()%2 == 1) //Black Node
00142   {
00143     NetMPI::Irecv(vRRcv,next,tag,_req[0]);
00144     NetMPI::Irecv(vLRcv,prev,tag,_req[1]);
00145 
00146     for (unsigned i=0;i<vRSndMap.size();i++)
00147       vRSnd(i)=data(vRSndMap[i]);
00148     NetMPI::Isend(vRSnd,next,tag,_req[2]);
00149 
00150 
00151     for (unsigned i=0;i<vLSndMap.size();i++)
00152       vLSnd(i)=data(vLSndMap[i]);
00153     NetMPI::Isend(vLSnd,prev,tag,_req[3]);
00154     
00155   }
00156 
00157 }

void NetMPI::exchangeDataRedBlack ( VecIndex vLSndMap,
VecDouble vLSnd,
VecIndex vLRcvMap,
VecDouble vLRcv,
VecIndex vRSndMap,
VecDouble vRSnd,
VecIndex vRRcvMap,
VecDouble vRRcv,
VecDouble data,
int  tag 
) [static]

Definition at line 111 of file netmpi.cpp.

00112 {
00113   exchangeDataRedBlack(vLSndMap,vLSnd,vLRcvMap,vLRcv,vRSndMap,vRSnd,vRRcvMap,vRRcv,data,data,tag); 
00114   
00115 }

std::ostream & NetMPI::getLog (  )  [static]

Definition at line 48 of file netmpi.cpp.

00049 {
00050   return *m_out;
00051 }

double NetMPI::getMinValue ( double  localValue  )  [static]

Definition at line 185 of file netmpi.cpp.

00186 {
00187   double dd;
00188   MPI_Allreduce(&localValue,&dd,1,MPI_DOUBLE,MPI_MIN,MPI_COMM_WORLD);
00189   return dd;
00190 }

static void NetMPI::Irecv ( VecDouble v,
int  src,
int  tag,
MPI_Request &  req 
) [inline, static]

Definition at line 70 of file netmpi.h.

00071   {
00072     if (src >= 0 && src < nProcess())
00073       MPI_Irecv(&(v(0)),v.size(),MPI_DOUBLE,src,tag,MPI_COMM_WORLD,&req);
00074   } 

static void NetMPI::Isend ( VecDouble v,
int  dst,
int  tag,
MPI_Request &  req 
) [inline, static]

Definition at line 60 of file netmpi.h.

00061   {
00062     if (dst >= 0 && dst < nProcess())
00063       MPI_Isend(&(v(0)),v.size(),MPI_DOUBLE,dst,tag,MPI_COMM_WORLD,&req);
00064     
00065   } 

bool NetMPI::isLastProcess (  )  [static]

Definition at line 43 of file netmpi.cpp.

00044 {
00045   return rank()==(nProcess()-1);
00046 }

int NetMPI::nProcess (  )  [static]

Definition at line 31 of file netmpi.cpp.

00032 {
00033   if (b2)
00034     return m_nP;
00035   else
00036   {
00037     b2=true;
00038     MPI_Comm_size(MPI_COMM_WORLD,&m_nP);
00039     return m_nP;
00040   }
00041 }

int NetMPI::rank (  )  [static]

Definition at line 19 of file netmpi.cpp.

00020 {
00021   if (b1)
00022     return m_rank;
00023   else
00024   {
00025     b1=true;
00026     MPI_Comm_rank(MPI_COMM_WORLD,&m_rank);
00027     return m_rank;
00028   }
00029 }

static void NetMPI::setLog ( std::ostream &  out  )  [inline, static]

Definition at line 58 of file netmpi.h.

00058 {m_out=&out;}

static void NetMPI::setTrace ( bool  b  )  [inline, static]

Definition at line 56 of file netmpi.h.

00056 {m_print=b;}

void NetMPI::trace ( const char *  format,
  ... 
) [static]

Definition at line 160 of file netmpi.cpp.

00161 {
00162   if (m_print)
00163   {
00164   char strOut[5000];
00165   va_list vl;
00166   va_start(vl,format);
00167   vsprintf(strOut,format,vl);
00168   va_end(vl);
00169   std::cout  << rank() << ") " << strOut << std::endl;
00170 
00171   }
00172 }


Member Data Documentation

bool NetMPI::b1 = false [static, private]

Definition at line 48 of file netmpi.h.

bool NetMPI::b2 = false [static, private]

Definition at line 48 of file netmpi.h.

bool NetMPI::m_loop = false [static, private]

Definition at line 47 of file netmpi.h.

int NetMPI::m_nP = -1 [static, protected]

Definition at line 50 of file netmpi.h.

std::ostream * NetMPI::m_out = &(std::cout) [static]

Definition at line 55 of file netmpi.h.

bool NetMPI::m_print = false [static, private]

Definition at line 48 of file netmpi.h.

int NetMPI::m_rank = -1 [static, protected]

Definition at line 50 of file netmpi.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Sun Apr 8 23:13:24 2012 for CO2INJECTION by  doxygen 1.6.3