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 /* _______ __ 00002 / ___/ / ___ __ _ / / ___ 00003 / /__/ _ \/ _ \/ ' \/ _ \/ _ \ 00004 \___/_//_/\___/_/_/_/_.__/\___/ 00005 */ 00006 // 00007 // This software is copyright (C) by the Lawrence Berkeley 00008 // National Laboratory. Permission is granted to reproduce 00009 // this software for non-commercial purposes provided that 00010 // this notice is left intact. 00011 // 00012 // It is acknowledged that the U.S. Government has rights to 00013 // this software under Contract DE-AC03-765F00098 between 00014 // the U.S. Department of Energy and the University of 00015 // California. 00016 // 00017 // This software is provided as a professional and academic 00018 // contribution for joint exchange. Thus it is experimental, 00019 // is provided ``as is'', with no warranties of any kind 00020 // whatsoever, no support, no promise of updates, or printed 00021 // documentation. By using this software, you acknowledge 00022 // that the Lawrence Berkeley National Laboratory and 00023 // Regents of the University of California shall have no 00024 // liability with respect to the infringement of other 00025 // copyrights by any part of this software. 00026 // 00027 00028 // 00029 // These are the inevitable functions that people 00030 // can't avoid using when writing a SPMD program. 00031 // It is a minimal set from which more elaborate 00032 // functionality can be generated. As always, a 00033 // user is free to utilize the entire MPI programming 00034 // on their own platform. The functions are 00035 // assured to work on all machines supported. 00036 // 00037 00038 #ifndef SPMD_H 00039 #define SPMD_H 00040 00041 #include "REAL.H" 00042 #include "Vector.H" 00043 #include "Box.H" 00044 #include "MayDay.H" 00045 #include "RealVect.H" 00046 class IntVectSet; 00047 00048 00050 00054 int procID(); 00055 00057 00060 unsigned int numProc(); 00061 00062 00063 template <class T> 00064 int linearSize(const T& inputT); 00065 00066 template <class T> 00067 void linearIn(T& a_outputT, const void* const inBuf); 00068 00069 template <class T> 00070 void linearOut(void* const a_outBuf, const T& inputT); 00071 00072 #ifdef CH_MPI 00073 00074 00088 template <class T> 00089 void gather(Vector<T>& a_outVec, const T& a_input, int a_dest); 00090 00091 // this has to be here so that linearSize<IntVectSet>, linearIn<IntVectSet>, 00092 // and linearOut<IntVectSet> are defined. 00093 // template < > 00094 // void gather(Vector<IntVectSet>& a_outVec, 00095 // const IntVectSet& a_input, 00096 // int a_dest); 00097 #endif 00098 00100 00109 template <class T> 00110 void broadcast(T& a_inAndOut, int a_src); 00111 00112 //integer specialization of linearSize 00113 template < > 00114 int linearSize(const int& a_input); 00115 00116 //integer specialization of linearIn 00117 template < > 00118 void linearIn(int& a_outputT, const void* const inBuf); 00119 00120 //integer specialization of linearOut 00121 template < > 00122 void linearOut(void* const a_outBuf, const int& a_inputT); 00123 00124 //Real specialization of linearSize 00125 template < > 00126 int linearSize(const Real& a_input); 00127 00128 //Real specialization of linearIn 00129 template < > 00130 void linearIn(Real& a_outputT, const void* const a_inBuf); 00131 00132 //Real specialization of linearOut 00133 template < > 00134 void linearOut(void* const a_outBuf, const Real& a_inputT); 00135 00136 //Box specialization of linearSize 00137 template < > 00138 int linearSize(const Box& a_input); 00139 00140 //Box specialization of linearIn 00141 template < > 00142 void linearIn(Box& a_outputT, const void* const a_inBuf); 00143 00144 //Box specialization of linearOut 00145 template < > 00146 void linearOut(void* const a_outBuf, const Box& a_inputT); 00147 00148 //Vector<int> specialization 00149 template < > 00150 int linearSize(const Vector<int>& a_input); 00151 template < > 00152 void linearIn(Vector<int>& a_outputT, const void* const inBuf); 00153 template < > 00154 void linearOut(void* const a_outBuf, const Vector<int>& a_inputT); 00155 00156 //Vector<Real> specialization 00157 template < > 00158 int linearSize(const Vector<Real>& a_input); 00159 template < > 00160 void linearIn(Vector<Real>& a_outputT, const void* const inBuf); 00161 template < > 00162 void linearOut(void* const a_outBuf, const Vector<Real>& a_inputT); 00163 00164 //Vector<Box> specialization 00165 template < > 00166 int linearSize(const Vector<Box>& a_input); 00167 template < > 00168 void linearIn(Vector<Box>& a_outputT, const void* const inBuf); 00169 template < > 00170 void linearOut(void* const a_outBuf, const Vector<Box>& a_inputT); 00171 00172 //Vector<Vector<Box> > specialization 00173 template < > 00174 int linearSize(const Vector<Vector<Box> >& a_input); 00175 template < > 00176 void linearIn(Vector<Vector<Box> >& a_outputT, const void* const inBuf); 00177 template < > 00178 void linearOut(void* const a_outBuf, const Vector<Vector<Box> >& a_inputT); 00179 00180 // RealVect spcializations of linearization 00181 template < > 00182 int linearSize(const RealVect& vindex); 00183 00184 //VolIndex specialization of linearIn 00185 template < > 00186 void linearIn(RealVect& a_outputT, const void* const inBuf); 00187 00188 //VolIndex specialization of linearOut 00189 template < > 00190 void linearOut(void* const a_outBuf, const RealVect& a_inputT); 00191 00192 00193 //Vector<Vector<int> > specialization 00194 template < > 00195 int linearSize(const Vector<Vector<int> >& a_input); 00196 template < > 00197 void linearIn(Vector<Vector<int> >& a_outputT, const void* const inBuf); 00198 template < > 00199 void linearOut(void* const a_outBuf, const Vector<Vector<int> >& a_inputT); 00200 00201 00202 //Vector<T> specialization of linearSize 00203 template <class T> 00204 int linearListSize(const Vector<T>& a_input); 00205 00206 //Vector<T> specialization of linearIn 00207 template <class T> 00208 void linearListIn(Vector<T>& a_outputT, const void* const a_inBuf); 00209 00210 //Vector<T> specialization of linearOut 00211 template <class T> 00212 void linearListOut(void* const a_outBuf, const Vector<T>& a_inputT); 00213 00214 class SerialTask 00215 { 00216 public: 00217 enum task { compute=0 }; 00218 }; 00219 00220 // return id of unique processor for special serial tasks 00221 int 00222 uniqueProc(const SerialTask::task& a_task); 00223 00224 #ifdef CH_MPI 00225 #include <mpi.h> 00226 struct Chombo_MPI{ static MPI_Comm comm;}; 00227 void setChomboMPIErrorHandler(); 00228 00229 #else 00230 // this can be changed for debugging parallel code in serial 00231 extern int num_procs ; 00232 #endif 00233 00234 #include "SPMDI.H" 00235 00236 #endif // SPMD.H 00237

Generated on Thu May 12 18:19:10 2005 for Chombo by doxygen 1.3.8