Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound 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 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 //Real specialization of linearSize
00153 template < >
00154 int linearSize(const float& a_input);
00155 
00156 template < >
00157 int linearSize(const double& a_input);
00158 
00159 //Real specialization of linearIn
00160 template < >
00161 void linearIn(float& a_outputT, const void* const a_inBuf);
00162 
00163 template < >
00164 void linearIn(double& a_outputT, const void* const a_inBuf);
00165 
00166 //Real specialization of linearOut
00167 template < >
00168 void linearOut(void* const a_outBuf, const float& a_inputT);
00169 
00170 template < >
00171 void linearOut(void* const a_outBuf, const double& a_inputT);
00172 
00173 //Box specialization of linearSize
00174 template < >
00175 int linearSize(const Box& a_input);
00176 
00177 //Box specialization of linearIn
00178 template < >
00179 void linearIn(Box& a_outputT, const void* const a_inBuf);
00180 
00181 //Box specialization of linearOut
00182 template < >
00183 void linearOut(void* const a_outBuf, const Box& a_inputT);
00184 
00185 //Vector<int>  specialization
00186 template < >
00187 int linearSize(const Vector<int>& a_input);
00188 template < >
00189 void linearIn(Vector<int>& a_outputT, const void* const inBuf);
00190 template < >
00191 void linearOut(void* const a_outBuf, const Vector<int>& a_inputT);
00192 
00193 //Vector<Real>  specialization
00194 template < >
00195 int linearSize(const Vector<float>& a_input);
00196 template < >
00197 void linearIn(Vector<float>& a_outputT, const void* const inBuf);
00198 template < >
00199 void linearOut(void* const a_outBuf, const Vector<float>& a_inputT);
00200 
00201 template < >
00202 int linearSize(const Vector<double>& a_input);
00203 template < >
00204 void linearIn(Vector<double>& a_outputT, const void* const inBuf);
00205 template < >
00206 void linearOut(void* const a_outBuf, const Vector<double>& a_inputT);
00207 
00208 //Vector<Box>  specialization
00209 template < >
00210 int linearSize(const Vector<Box>& a_input);
00211 template < >
00212 void linearIn(Vector<Box>& a_outputT, const void* const inBuf);
00213 template < >
00214 void linearOut(void* const a_outBuf, const Vector<Box>& a_inputT);
00215 
00216 //Vector<Vector<Box> > specialization
00217 template < >
00218 int linearSize(const Vector<Vector<Box> >& a_input);
00219 template < >
00220 void linearIn(Vector<Vector<Box> >& a_outputT, const void* const inBuf);
00221 template < >
00222 void linearOut(void* const a_outBuf, const Vector<Vector<Box> >& a_inputT);
00223 
00224 // RealVect spcializations of linearization
00225 template < >
00226 int linearSize(const RealVect& vindex);
00227 
00228 //VolIndex specialization of linearIn
00229 template < >
00230 void linearIn(RealVect& a_outputT, const void* const inBuf);
00231 
00232 //VolIndex specialization of linearOut
00233 template < >
00234 void linearOut(void* const a_outBuf, const RealVect& a_inputT);
00235 
00236 //Vector<Vector<int> > specialization
00237 template < >
00238 int linearSize(const Vector<Vector<int> >& a_input);
00239 template < >
00240 void linearIn(Vector<Vector<int> >& a_outputT, const void* const inBuf);
00241 template < >
00242 void linearOut(void* const a_outBuf, const Vector<Vector<int> >& a_inputT);
00243 
00244 //Vector<T> specialization of linearSize
00245 template <class T>
00246 int linearListSize(const Vector<T>& a_input);
00247 
00248 //Vector<T> specialization of linearIn
00249 template <class T>
00250 void linearListIn(Vector<T>& a_outputT, const void* const a_inBuf);
00251 
00252 //Vector<T> specialization of linearOut
00253 template <class T>
00254 void linearListOut(void* const a_outBuf, const Vector<T>& a_inputT);
00255 
00256 class SerialTask
00257 {
00258 public:
00259     enum task { compute=0 };
00260 };
00261 
00262 // return id of unique processor for special serial tasks
00263 int
00264 uniqueProc(const SerialTask::task& a_task);
00265 
00266 #ifdef MPI
00267 #include <mpi.h>
00268 struct Chombo_MPI{ static MPI_Comm comm;};
00269 void setChomboMPIErrorHandler();
00270 
00271 #else
00272 // this can be changed for debugging parallel code in serial
00273 extern int num_procs ;
00274 #endif
00275 
00276 #include "SPMDI.H"
00277 
00278 #endif

Generated on Wed Jan 19 17:51:27 2005 for Chombo&INSwithParticles by doxygen1.2.16