00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _SPMD_H_
00022 #define _SPMD_H_
00023
00024 #include "REAL.H"
00025 #include <string>
00026 #include "Vector.H"
00027 #include "MayDay.H"
00028 #include "Misc.H"
00029
00030 #ifdef CH_MPI
00031 #include <mpi.h>
00032 #endif
00033
00034 #include "BaseNamespaceHeader.H"
00035
00036 #ifdef CH_MPI
00037 struct Chombo_MPI
00038 {
00039 static MPI_Comm comm;
00040 };
00041
00042 #else
00043
00044 extern int num_procs ;
00045 #endif
00046
00047 extern long long CH_MAX_MPI_MESSAGE_SIZE;
00048
00049 extern long long CH_MaxMPISendSize;
00050 extern long long CH_MaxMPIRecvSize;
00051
00052
00053 int reportMPIStats();
00054
00055
00056
00057
00058
00059
00060 int procID();
00061
00062 inline int CHprocID()
00063 {
00064 return procID();
00065 }
00066
00067
00068
00069
00070
00071 unsigned int numProc();
00072
00073
00074
00075
00076 void barrier(void);
00077
00078 template <class T>
00079 int linearSize(const T& inputT);
00080
00081 template <class T>
00082 void linearIn(T& a_outputT, const void* const inBuf);
00083
00084 template <class T>
00085 void linearOut(void* const a_outBuf, const T& inputT);
00086
00087 #ifdef CH_MPI
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 template <class T>
00104 void gather(Vector<T>& a_outVec, const T& a_input, int a_dest);
00105
00106
00107
00108
00109
00110
00111
00112 #endif
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 template <class T>
00125 void broadcast(T& a_inAndOut, int a_src);
00126
00127
00128 template < >
00129 int linearSize(const int& a_input);
00130
00131
00132
00133 template < >
00134 int linearSize(const unsigned long long& a_input);
00135
00136
00137 template < >
00138 void linearIn(int& a_outputT, const void* const inBuf);
00139
00140
00141
00142 template < >
00143 void linearIn(unsigned long long& a_outputT, const void* const inBuf);
00144
00145
00146 template < >
00147 void linearOut(void* const a_outBuf, const int& a_inputT);
00148
00149
00150
00151 template < >
00152 void linearOut(void* const a_outBuf, const unsigned long long& a_inputT);
00153
00154
00155 template < >
00156 int linearSize(const long& a_input);
00157
00158
00159 template < >
00160 void linearIn(long& a_outputT, const void* const inBuf);
00161
00162
00163 template < >
00164 void linearOut(void* const a_outBuf, const long& a_inputT);
00165
00166
00167 template < >
00168 int linearSize(const unsigned long& a_input);
00169
00170
00171 template < >
00172 void linearIn(unsigned long& a_outputT, const void* const inBuf);
00173
00174
00175 template < >
00176 void linearOut(void* const a_outBuf, const unsigned long& a_inputT);
00177
00178
00179 template < >
00180 int linearSize(const float& a_input);
00181
00182 template < >
00183 int linearSize(const double& a_input);
00184
00185
00186 template < >
00187 void linearIn(float& a_outputT, const void* const a_inBuf);
00188
00189 template < >
00190 void linearIn(double& a_outputT, const void* const a_inBuf);
00191
00192
00193 template < >
00194 void linearOut(void* const a_outBuf, const float& a_inputT);
00195
00196 template < >
00197 void linearOut(void* const a_outBuf, const double& a_inputT);
00198
00199
00200 template <>
00201 int linearSize(const std::string& a_input);
00202 template <>
00203 void linearIn(std::string& a_outputT, const void* const a_inBuf);
00204 template <>
00205 void linearOut(void* const a_outBuf, const std::string& a_inputT);
00206
00207
00208 template < >
00209 int linearSize(const Vector<int>& a_input);
00210 template < >
00211 void linearIn(Vector<int>& a_outputT, const void* const inBuf);
00212 template < >
00213 void linearOut(void* const a_outBuf, const Vector<int>& a_inputT);
00214
00215
00216 template < >
00217 int linearSize(const Vector<unsigned long long>& a_input);
00218 template < >
00219 void linearIn(Vector<unsigned long long>& a_outputT, const void* const inBuf);
00220 template < >
00221 void linearOut(void* const a_outBuf, const Vector<unsigned long long>& a_inputT);
00222
00223
00224 template < >
00225 int linearSize(const Vector<long>& a_input);
00226 template < >
00227 void linearIn(Vector<long>& a_outputT, const void* const inBuf);
00228 template < >
00229 void linearOut(void* const a_outBuf, const Vector<long>& a_inputT);
00230
00231
00232 template < >
00233 int linearSize(const Vector<float>& a_input);
00234 template < >
00235 void linearIn(Vector<float>& a_outputT, const void* const inBuf);
00236 template < >
00237 void linearOut(void* const a_outBuf, const Vector<float>& a_inputT);
00238
00239 template < >
00240 int linearSize(const Vector<double>& a_input);
00241 template < >
00242 void linearIn(Vector<double>& a_outputT, const void* const inBuf);
00243 template < >
00244 void linearOut(void* const a_outBuf, const Vector<double>& a_inputT);
00245
00246
00247 template < >
00248 int linearSize(const Vector<std::string>& a_input);
00249 template < >
00250 void linearIn(Vector<std::string>& a_outputT, const void* const inBuf);
00251 template < >
00252 void linearOut(void* const a_outBuf, const Vector<std::string>& a_inputT);
00253
00254
00255 template < >
00256 int linearSize(const Vector<Vector<int> >& a_input);
00257 template < >
00258 void linearIn(Vector<Vector<int> >& a_outputT, const void* const inBuf);
00259 template < >
00260 void linearOut(void* const a_outBuf, const Vector<Vector<int> >& a_inputT);
00261
00262
00263 template <class T>
00264 int linearListSize(const Vector<T>& a_input);
00265
00266
00267 template <class T>
00268 void linearListIn(Vector<T>& a_outputT, const void* const a_inBuf);
00269
00270
00271 template <class T>
00272 void linearListOut(void* const a_outBuf, const Vector<T>& a_inputT);
00273
00274 class SerialTask
00275 {
00276 public:
00277 enum task
00278 {
00279 compute=0
00280 };
00281 };
00282
00283 int GetPID(int rank);
00284 int GetRank(int pid);
00285
00286
00287 int
00288 uniqueProc(const SerialTask::task& a_task);
00289
00290 #include "BaseNamespaceFooter.H"
00291
00292 #include "SPMDI.H"
00293
00294 #endif