Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

SPMD.H

Go to the documentation of this file.
00001 #ifdef CH_LANG_CC
00002 /*
00003 *      _______              __
00004 *     / ___/ /  ___  __ _  / /  ___
00005 *    / /__/ _ \/ _ \/  V \/ _ \/ _ \
00006 *    \___/_//_/\___/_/_/_/_.__/\___/
00007 *    Please refer to Copyright.txt, in Chombo's root directory.
00008 */
00009 #endif
00010 
00011 //
00012 // These are the inevitable functions that people
00013 // can't avoid using when writing a SPMD program.
00014 // It is a minimal set from which more elaborate
00015 // functionality can be generated.  As always, a
00016 // user is free to utilize the entire MPI programming
00017 // on their own platform.  The functions are
00018 // assured to work on all machines supported.
00019 //
00020 
00021 #ifndef _SPMD_H_
00022 #define _SPMD_H_
00023 
00024 #include "REAL.H"
00025 #include "Vector.H"
00026 #include "Box.H"
00027 #include "MayDay.H"
00028 #include "RealVect.H"
00029 
00030 #ifdef CH_MPI
00031 #include <mpi.h>
00032 #endif
00033 
00034 #include "NamespaceHeader.H"
00035 
00036 #ifdef CH_MPI
00037 struct Chombo_MPI{ static MPI_Comm comm;};
00038 
00039 #else
00040 // this can be changed for debugging parallel code in serial
00041 extern int num_procs ;
00042 #endif
00043 
00044 class IntVectSet;
00045 
00046 extern long long CH_MAX_MPI_MESSAGE_SIZE;
00047 
00048 extern long long CH_MaxMPISendSize;
00049 extern long long CH_MaxMPIRecvSize;
00050 
00051 
00052 int reportMPIStats();
00053 
00055 
00059 int procID();
00060 
00062 
00065 unsigned int numProc();
00066 
00068 
00070 void barrier(void);
00071 
00072 template <class T>
00073 int linearSize(const T& inputT);
00074 
00075 template <class T>
00076 void linearIn(T& a_outputT, const void* const inBuf);
00077 
00078 template <class T>
00079 void linearOut(void* const a_outBuf, const T& inputT);
00080 
00081 #ifdef CH_MPI
00082 
00083 
00097 template <class T>
00098 void gather(Vector<T>& a_outVec, const T& a_input, int a_dest);
00099 
00100 // this has to be here so that linearSize<IntVectSet>, linearIn<IntVectSet>,
00101 //  and linearOut<IntVectSet> are defined.
00102 // template < >
00103 // void gather(Vector<IntVectSet>& a_outVec,
00104 //             const IntVectSet& a_input,
00105 //             int a_dest);
00106 #endif
00107 
00109 
00118 template <class T>
00119 void broadcast(T& a_inAndOut,  int a_src);
00120 
00121 //integer specialization of linearSize
00122 template < >
00123 int linearSize(const int& a_input);
00124 
00125 //integer specialization of linearIn
00126 template < >
00127 void linearIn(int& a_outputT, const void* const inBuf);
00128 
00129 //integer specialization of linearOut
00130 template < >
00131 void linearOut(void* const a_outBuf, const int& a_inputT);
00132 
00133 //long integer specialization of linearSize
00134 template < >
00135 int linearSize(const long& a_input);
00136 
00137 //long integer specialization of linearIn
00138 template < >
00139 void linearIn(long& a_outputT, const void* const inBuf);
00140 
00141 //long integer specialization of linearOut
00142 template < >
00143 void linearOut(void* const a_outBuf, const long& a_inputT);
00144 
00145 //unsigned long integer specialization of linearSize
00146 template < >
00147 int linearSize(const unsigned long& a_input);
00148 
00149 //unsigned long integer specialization of linearIn
00150 template < >
00151 void linearIn(unsigned long& a_outputT, const void* const inBuf);
00152 
00153 //unsigned long integer specialization of linearOut
00154 template < >
00155 void linearOut(void* const a_outBuf, const unsigned long& a_inputT);
00156 
00157 //Real specialization of linearSize
00158 template < >
00159 int linearSize(const float& a_input);
00160 
00161 template < >
00162 int linearSize(const double& a_input);
00163 
00164 //Real specialization of linearIn
00165 template < >
00166 void linearIn(float& a_outputT, const void* const a_inBuf);
00167 
00168 template < >
00169 void linearIn(double& a_outputT, const void* const a_inBuf);
00170 
00171 //Real specialization of linearOut
00172 template < >
00173 void linearOut(void* const a_outBuf, const float& a_inputT);
00174 
00175 template < >
00176 void linearOut(void* const a_outBuf, const double& a_inputT);
00177 
00178 //Box specialization of linearSize
00179 template < >
00180 int linearSize(const Box& a_input);
00181 
00182 //Box specialization of linearIn
00183 template < >
00184 void linearIn(Box& a_outputT, const void* const a_inBuf);
00185 
00186 //Box specialization of linearOut
00187 template < >
00188 void linearOut(void* const a_outBuf, const Box& a_inputT);
00189 
00190 //Vector<int>  specialization
00191 template < >
00192 int linearSize(const Vector<int>& a_input);
00193 template < >
00194 void linearIn(Vector<int>& a_outputT, const void* const inBuf);
00195 template < >
00196 void linearOut(void* const a_outBuf, const Vector<int>& a_inputT);
00197 
00198 //Vector<long>  specialization
00199 template < >
00200 int linearSize(const Vector<long>& a_input);
00201 template < >
00202 void linearIn(Vector<long>& a_outputT, const void* const inBuf);
00203 template < >
00204 void linearOut(void* const a_outBuf, const Vector<long>& a_inputT);
00205 
00206 //Vector<Real>  specialization
00207 template < >
00208 int linearSize(const Vector<float>& a_input);
00209 template < >
00210 void linearIn(Vector<float>& a_outputT, const void* const inBuf);
00211 template < >
00212 void linearOut(void* const a_outBuf, const Vector<float>& a_inputT);
00213 
00214 template < >
00215 int linearSize(const Vector<double>& a_input);
00216 template < >
00217 void linearIn(Vector<double>& a_outputT, const void* const inBuf);
00218 template < >
00219 void linearOut(void* const a_outBuf, const Vector<double>& a_inputT);
00220 
00221 //Vector<Box>  specialization
00222 template < >
00223 int linearSize(const Vector<Box>& a_input);
00224 template < >
00225 void linearIn(Vector<Box>& a_outputT, const void* const inBuf);
00226 template < >
00227 void linearOut(void* const a_outBuf, const Vector<Box>& a_inputT);
00228 
00229 //Vector<Vector<Box> > specialization
00230 template < >
00231 int linearSize(const Vector<Vector<Box> >& a_input);
00232 template < >
00233 void linearIn(Vector<Vector<Box> >& a_outputT, const void* const inBuf);
00234 template < >
00235 void linearOut(void* const a_outBuf, const Vector<Vector<Box> >& a_inputT);
00236 
00237 // RealVect spcializations of linearization
00238 template < >
00239 int linearSize(const RealVect& vindex);
00240 
00241 //VolIndex specialization of linearIn
00242 template < >
00243 void linearIn(RealVect& a_outputT, const void* const inBuf);
00244 
00245 //VolIndex specialization of linearOut
00246 template < >
00247 void linearOut(void* const a_outBuf, const RealVect& a_inputT);
00248 
00249 //Vector<Vector<int> > specialization
00250 template < >
00251 int linearSize(const Vector<Vector<int> >& a_input);
00252 template < >
00253 void linearIn(Vector<Vector<int> >& a_outputT, const void* const inBuf);
00254 template < >
00255 void linearOut(void* const a_outBuf, const Vector<Vector<int> >& a_inputT);
00256 
00257 //Vector<T> specialization of linearSize
00258 template <class T>
00259 int linearListSize(const Vector<T>& a_input);
00260 
00261 //Vector<T> specialization of linearIn
00262 template <class T>
00263 void linearListIn(Vector<T>& a_outputT, const void* const a_inBuf);
00264 
00265 //Vector<T> specialization of linearOut
00266 template <class T>
00267 void linearListOut(void* const a_outBuf, const Vector<T>& a_inputT);
00268 
00269 class SerialTask
00270 {
00271 public:
00272     enum task { compute=0 };
00273 };
00274 
00275 int GetPID(int rank);
00276 int GetRank(int pid);
00277 
00278 // return id of unique processor for special serial tasks
00279 int
00280 uniqueProc(const SerialTask::task& a_task);
00281 
00282 #include "NamespaceFooter.H"
00283 
00284 #include "SPMDI.H"
00285 
00286 #endif

Generated on Fri May 4 13:22:54 2007 for Chombo by doxygen 1.3.6