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

SPMD.H

Go to the documentation of this file.
00001 /*   _______              __
00002     / ___/ /  ___  __ _  / /  ___
00003    / /__/ _ \/ _ \/  V \/ _ \/ _ \
00004    \___/_//_/\___/_/_/_/_.__/\___/
00005 */
00006 // CHOMBO Copyright (c) 2000-2004, The Regents of the University of
00007 // California, through Lawrence Berkeley National Laboratory (subject to
00008 // receipt of any required approvals from U.S. Dept. of Energy).  All
00009 // rights reserved.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are met:
00013 //
00014 // (1) Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 // (2) Redistributions in binary form must reproduce the above copyright
00017 // notice, this list of conditions and the following disclaimer in the
00018 // documentation and/or other materials provided with the distribution.
00019 // (3) Neither the name of Lawrence Berkeley National Laboratory, U.S.
00020 // Dept. of Energy nor the names of its contributors may be used to endorse
00021 // or promote products derived from this software without specific prior
00022 // written permission.
00023 //
00024 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00025 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
00026 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00027 // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
00028 // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00029 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00030 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00031 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00032 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00033 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00034 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00035 //
00036 // You are under no obligation whatsoever to provide any bug fixes,
00037 // patches, or upgrades to the features, functionality or performance of
00038 // the source code ("Enhancements") to anyone; however, if you choose to
00039 // make your Enhancements available either publicly, or directly to
00040 // Lawrence Berkeley National Laboratory, without imposing a separate
00041 // written license agreement for such Enhancements, then you hereby grant
00042 // the following license: a non-exclusive, royalty-free perpetual license
00043 // to install, use, modify, prepare derivative works, incorporate into
00044 // other computer software, distribute, and sublicense such Enhancements or
00045 // derivative works thereof, in binary and source code form.
00046 //
00047 // TRADEMARKS. Product and company names mentioned herein may be the
00048 // trademarks of their respective owners.  Any rights not expressly granted
00049 // herein are reserved.
00050 //
00051 
00052 //
00053 // These are the inevitable functions that people
00054 // can't avoid using when writing a SPMD program.
00055 // It is a minimal set from which more elaborate
00056 // functionality can be generated.  As always, a
00057 // user is free to utilize the entire MPI programming
00058 // on their own platform.  The functions are
00059 // assured to work on all machines supported.
00060 //
00061 
00062 #ifndef _SPMD_H_
00063 #define _SPMD_H_
00064 
00065 #include "REAL.H"
00066 #include "Vector.H"
00067 #include "Box.H"
00068 #include "MayDay.H"
00069 #include "RealVect.H"
00070 
00071 class IntVectSet;
00072 
00074 
00078 int procID();
00079 
00081 
00084 unsigned int numProc();
00085 
00087 
00089 void barrier(void);
00090 
00091 template <class T>
00092 int linearSize(const T& inputT);
00093 
00094 template <class T>
00095 void linearIn(T& a_outputT, const void* const inBuf);
00096 
00097 template <class T>
00098 void linearOut(void* const a_outBuf, const T& inputT);
00099 
00100 #ifdef CH_MPI
00101 
00102 
00116 template <class T>
00117 void gather(Vector<T>& a_outVec, const T& a_input, int a_dest);
00118 
00119 // this has to be here so that linearSize<IntVectSet>, linearIn<IntVectSet>,
00120 //  and linearOut<IntVectSet> are defined.
00121 // template < >
00122 // void gather(Vector<IntVectSet>& a_outVec,
00123 //             const IntVectSet& a_input,
00124 //             int a_dest);
00125 #endif
00126 
00128 
00137 template <class T>
00138 void broadcast(T& a_inAndOut,  int a_src);
00139 
00140 //integer specialization of linearSize
00141 template < >
00142 int linearSize(const int& a_input);
00143 
00144 //integer specialization of linearIn
00145 template < >
00146 void linearIn(int& a_outputT, const void* const inBuf);
00147 
00148 //integer specialization of linearOut
00149 template < >
00150 void linearOut(void* const a_outBuf, const int& a_inputT);
00151 
00152 //long integer specialization of linearSize
00153 template < >
00154 int linearSize(const long& a_input);
00155 
00156 //long integer specialization of linearIn
00157 template < >
00158 void linearIn(long& a_outputT, const void* const inBuf);
00159 
00160 //long integer specialization of linearOut
00161 template < >
00162 void linearOut(void* const a_outBuf, const long& a_inputT);
00163 
00164 //unsigned long integer specialization of linearSize
00165 template < >
00166 int linearSize(const unsigned long& a_input);
00167 
00168 //unsigned long integer specialization of linearIn
00169 template < >
00170 void linearIn(unsigned long& a_outputT, const void* const inBuf);
00171 
00172 //unsigned long integer specialization of linearOut
00173 template < >
00174 void linearOut(void* const a_outBuf, const unsigned long& a_inputT);
00175 
00176 //Real specialization of linearSize
00177 template < >
00178 int linearSize(const float& a_input);
00179 
00180 template < >
00181 int linearSize(const double& a_input);
00182 
00183 //Real specialization of linearIn
00184 template < >
00185 void linearIn(float& a_outputT, const void* const a_inBuf);
00186 
00187 template < >
00188 void linearIn(double& a_outputT, const void* const a_inBuf);
00189 
00190 //Real specialization of linearOut
00191 template < >
00192 void linearOut(void* const a_outBuf, const float& a_inputT);
00193 
00194 template < >
00195 void linearOut(void* const a_outBuf, const double& a_inputT);
00196 
00197 //Box specialization of linearSize
00198 template < >
00199 int linearSize(const Box& a_input);
00200 
00201 //Box specialization of linearIn
00202 template < >
00203 void linearIn(Box& a_outputT, const void* const a_inBuf);
00204 
00205 //Box specialization of linearOut
00206 template < >
00207 void linearOut(void* const a_outBuf, const Box& a_inputT);
00208 
00209 //Vector<int>  specialization
00210 template < >
00211 int linearSize(const Vector<int>& a_input);
00212 template < >
00213 void linearIn(Vector<int>& a_outputT, const void* const inBuf);
00214 template < >
00215 void linearOut(void* const a_outBuf, const Vector<int>& a_inputT);
00216 
00217 //Vector<long>  specialization
00218 template < >
00219 int linearSize(const Vector<long>& a_input);
00220 template < >
00221 void linearIn(Vector<long>& a_outputT, const void* const inBuf);
00222 template < >
00223 void linearOut(void* const a_outBuf, const Vector<long>& a_inputT);
00224 
00225 //Vector<Real>  specialization
00226 template < >
00227 int linearSize(const Vector<float>& a_input);
00228 template < >
00229 void linearIn(Vector<float>& a_outputT, const void* const inBuf);
00230 template < >
00231 void linearOut(void* const a_outBuf, const Vector<float>& a_inputT);
00232 
00233 template < >
00234 int linearSize(const Vector<double>& a_input);
00235 template < >
00236 void linearIn(Vector<double>& a_outputT, const void* const inBuf);
00237 template < >
00238 void linearOut(void* const a_outBuf, const Vector<double>& a_inputT);
00239 
00240 //Vector<Box>  specialization
00241 template < >
00242 int linearSize(const Vector<Box>& a_input);
00243 template < >
00244 void linearIn(Vector<Box>& a_outputT, const void* const inBuf);
00245 template < >
00246 void linearOut(void* const a_outBuf, const Vector<Box>& a_inputT);
00247 
00248 //Vector<Vector<Box> > specialization
00249 template < >
00250 int linearSize(const Vector<Vector<Box> >& a_input);
00251 template < >
00252 void linearIn(Vector<Vector<Box> >& a_outputT, const void* const inBuf);
00253 template < >
00254 void linearOut(void* const a_outBuf, const Vector<Vector<Box> >& a_inputT);
00255 
00256 // RealVect spcializations of linearization
00257 template < >
00258 int linearSize(const RealVect& vindex);
00259 
00260 //VolIndex specialization of linearIn
00261 template < >
00262 void linearIn(RealVect& a_outputT, const void* const inBuf);
00263 
00264 //VolIndex specialization of linearOut
00265 template < >
00266 void linearOut(void* const a_outBuf, const RealVect& a_inputT);
00267 
00268 //Vector<Vector<int> > specialization
00269 template < >
00270 int linearSize(const Vector<Vector<int> >& a_input);
00271 template < >
00272 void linearIn(Vector<Vector<int> >& a_outputT, const void* const inBuf);
00273 template < >
00274 void linearOut(void* const a_outBuf, const Vector<Vector<int> >& a_inputT);
00275 
00276 //Vector<T> specialization of linearSize
00277 template <class T>
00278 int linearListSize(const Vector<T>& a_input);
00279 
00280 //Vector<T> specialization of linearIn
00281 template <class T>
00282 void linearListIn(Vector<T>& a_outputT, const void* const a_inBuf);
00283 
00284 //Vector<T> specialization of linearOut
00285 template <class T>
00286 void linearListOut(void* const a_outBuf, const Vector<T>& a_inputT);
00287 
00288 class SerialTask
00289 {
00290 public:
00291     enum task { compute=0 };
00292 };
00293 
00294 // return id of unique processor for special serial tasks
00295 int
00296 uniqueProc(const SerialTask::task& a_task);
00297 
00298 #ifdef CH_MPI
00299 #include <mpi.h>
00300 struct Chombo_MPI{ static MPI_Comm comm;};
00301 void setChomboMPIErrorHandler();
00302 
00303 #else
00304 // this can be changed for debugging parallel code in serial
00305 extern int num_procs ;
00306 #endif
00307 
00308 #include "SPMDI.H"
00309 
00310 #endif

Generated on Wed Oct 5 13:52:09 2005 for Chombo&AMRSelfGravity by  doxygen 1.4.1