dune-common
2.2.0
|
00001 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- 00002 // vi: set et ts=4 sw=2 sts=2: 00003 #ifndef DUNE_COLLECTIVECOMMUNICATION_HH 00004 #define DUNE_COLLECTIVECOMMUNICATION_HH 00005 00006 #include<iostream> 00007 #include<complex> 00008 #include<algorithm> 00009 00010 #include"exceptions.hh" 00011 00028 namespace Dune 00029 { 00030 00031 /* define some type that definitely differs from MPI_Comm */ 00032 struct No_Comm {}; 00033 00034 00061 template<typename C> 00062 class CollectiveCommunication 00063 { 00064 public: 00066 CollectiveCommunication() 00067 {} 00068 CollectiveCommunication (const C&) 00069 {} 00070 00072 int rank () const 00073 { 00074 return 0; 00075 } 00076 00078 int size () const 00079 { 00080 return 1; 00081 } 00082 00086 template<typename T> 00087 T sum (T& in) const // MPI does not know about const :-( 00088 { 00089 return in; 00090 } 00091 00095 template<typename T> 00096 int sum (T* inout, int len) const 00097 { 00098 return 0; 00099 } 00100 00104 template<typename T> 00105 T prod (T& in) const // MPI does not know about const :-( 00106 { 00107 return in; 00108 } 00109 00114 template<typename T> 00115 int prod (T* inout, int len) const 00116 { 00117 return 0; 00118 } 00119 00123 template<typename T> 00124 T min (T& in) const // MPI does not know about const :-( 00125 { 00126 return in; 00127 } 00128 00133 template<typename T> 00134 int min (T* inout, int len) const 00135 { 00136 return 0; 00137 } 00138 00142 template<typename T> 00143 T max (T& in) const // MPI does not know about const :-( 00144 { 00145 return in; 00146 } 00147 00152 template<typename T> 00153 int max (T* inout, int len) const 00154 { 00155 return 0; 00156 } 00157 00160 int barrier () const 00161 { 00162 return 0; 00163 } 00164 00167 template<typename T> 00168 int broadcast (T* inout, int len, int root) const 00169 { 00170 return 0; 00171 } 00172 00184 template<typename T> 00185 int gather (T* in, T* out, int len, int root) const // note out must have same size as in 00186 { 00187 for (int i=0; i<len; i++) 00188 out[i] = in[i]; 00189 return 0; 00190 } 00191 00204 template<typename T> 00205 int scatter (T* send, T* recv, int len, int root) const // note out must have same size as in 00206 { 00207 for (int i=0; i<len; i++) 00208 recv[i] = send[i]; 00209 return 0; 00210 } 00211 00224 template<typename T> 00225 int allgather(T* sbuf, int count, T* rbuf) const 00226 { 00227 for(T* end=sbuf+count; sbuf < end; ++sbuf, ++rbuf) 00228 *sbuf=*rbuf; 00229 return 0; 00230 } 00231 00243 template<typename BinaryFunction, typename Type> 00244 int allreduce(Type* inout, int len) const 00245 { 00246 return 0; 00247 } 00248 00261 template<typename BinaryFunction, typename Type> 00262 void allreduce(Type* in, Type* out, int len) const 00263 { 00264 std::copy(in, in+len, out); 00265 return; 00266 } 00267 00268 }; 00269 } 00270 00271 #endif