collectivecommunication.hh

00001 #ifndef DUNE_COLLECTIVECOMMUNICATION_HH
00002 #define DUNE_COLLECTIVECOMMUNICATION_HH
00003 
00004 #include<iostream>
00005 #include<complex>
00006 #include<algorithm>
00007 
00008 #include"exceptions.hh"
00009 
00019 namespace Dune
00020 {
00047   template<typename C>
00048   class CollectiveCommunication
00049   {
00050   public:
00052     CollectiveCommunication()
00053     {}
00054         CollectiveCommunication (const C&)
00055         {}
00056 
00058         int rank () const
00059         {
00060           return 0;
00061         }
00062 
00064         int size () const
00065         {
00066           return 1;
00067         }
00068 
00072         template<typename T>
00073         T sum (T& in) const // MPI does not know about const :-(
00074         {
00075           return in;
00076         }
00077 
00081         template<typename T>
00082         int sum (T* inout, int len) const
00083         {
00084           return 0;
00085         }
00086 
00090         template<typename T>
00091         T prod (T& in) const // MPI does not know about const :-(
00092         {
00093           return in;
00094         }
00095 
00100         template<typename T>
00101         int prod (T* inout, int len) const
00102         {
00103           return 0;
00104         }
00105 
00109         template<typename T>
00110         T min (T& in) const // MPI does not know about const :-(
00111         {
00112           return in;
00113         }
00114 
00119         template<typename T>
00120         int min (T* inout, int len) const
00121         {
00122           return 0;
00123         }
00124 
00128         template<typename T>
00129         T max (T& in) const // MPI does not know about const :-(
00130         {
00131           return in;
00132         }
00133 
00138         template<typename T>
00139         int max (T* inout, int len) const
00140         {
00141           return 0;
00142         }
00143 
00146         int barrier () const
00147         {
00148           return 0;
00149         }
00150 
00153         template<typename T>
00154         int broadcast (T* inout, int len, int root) const
00155         {
00156           return 0;
00157         }
00158 
00163         template<typename T>
00164         int gather (T* in, T* out, int len, int root) const // note out must have same size as in
00165         {
00166           for (int i=0; i<len; i++)
00167                 out[i] = in[i];
00168           return 0;
00169         }
00170 
00182     template<typename BinaryFunction, typename Type>
00183     int allreduce(Type* inout, int len) const
00184     {
00185       return 0;
00186     }
00187     
00200     template<typename BinaryFunction, typename Type>
00201     void allreduce(Type* in, Type* out, int len) const
00202     {
00203       std::copy(in, in+len, out);
00204       return 0;
00205     }
00206     
00207   };
00208 }
00209 
00210 #endif

Generated on Thu Apr 2 10:39:53 2009 for dune-common by  doxygen 1.5.6