dune-common
2.2.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
dune
common
collectivecommunication.hh
Go to the documentation of this file.
1
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
// vi: set et ts=4 sw=2 sts=2:
3
#ifndef DUNE_COLLECTIVECOMMUNICATION_HH
4
#define DUNE_COLLECTIVECOMMUNICATION_HH
5
6
#include<iostream>
7
#include<complex>
8
#include<algorithm>
9
10
#include"
exceptions.hh
"
11
28
namespace
Dune
29
{
30
31
/* define some type that definitely differs from MPI_Comm */
32
struct
No_Comm
{};
33
34
61
template
<
typename
C>
62
class
CollectiveCommunication
63
{
64
public
:
66
CollectiveCommunication
()
67
{}
68
CollectiveCommunication
(
const
C&)
69
{}
70
72
int
rank
()
const
73
{
74
return
0;
75
}
76
78
int
size
()
const
79
{
80
return
1;
81
}
82
86
template
<
typename
T>
87
T
sum
(T& in)
const
// MPI does not know about const :-(
88
{
89
return
in;
90
}
91
95
template
<
typename
T>
96
int
sum
(T* inout,
int
len)
const
97
{
98
return
0;
99
}
100
104
template
<
typename
T>
105
T
prod
(T& in)
const
// MPI does not know about const :-(
106
{
107
return
in;
108
}
109
114
template
<
typename
T>
115
int
prod
(T* inout,
int
len)
const
116
{
117
return
0;
118
}
119
123
template
<
typename
T>
124
T
min
(T& in)
const
// MPI does not know about const :-(
125
{
126
return
in;
127
}
128
133
template
<
typename
T>
134
int
min
(T* inout,
int
len)
const
135
{
136
return
0;
137
}
138
142
template
<
typename
T>
143
T
max
(T& in)
const
// MPI does not know about const :-(
144
{
145
return
in;
146
}
147
152
template
<
typename
T>
153
int
max
(T* inout,
int
len)
const
154
{
155
return
0;
156
}
157
160
int
barrier
()
const
161
{
162
return
0;
163
}
164
167
template
<
typename
T>
168
int
broadcast
(T* inout,
int
len,
int
root)
const
169
{
170
return
0;
171
}
172
184
template
<
typename
T>
185
int
gather
(T* in, T* out,
int
len,
int
root)
const
// note out must have same size as in
186
{
187
for
(
int
i=0; i<len; i++)
188
out[i] = in[i];
189
return
0;
190
}
191
204
template
<
typename
T>
205
int
scatter
(T* send, T* recv,
int
len,
int
root)
const
// note out must have same size as in
206
{
207
for
(
int
i=0; i<len; i++)
208
recv[i] = send[i];
209
return
0;
210
}
211
224
template
<
typename
T>
225
int
allgather
(T* sbuf,
int
count, T* rbuf)
const
226
{
227
for
(T* end=sbuf+count; sbuf < end; ++sbuf, ++rbuf)
228
*sbuf=*rbuf;
229
return
0;
230
}
231
243
template
<
typename
BinaryFunction,
typename
Type>
244
int
allreduce
(Type* inout,
int
len)
const
245
{
246
return
0;
247
}
248
261
template
<
typename
BinaryFunction,
typename
Type>
262
void
allreduce
(Type* in, Type* out,
int
len)
const
263
{
264
std::copy(in, in+len, out);
265
return
;
266
}
267
268
};
269
}
270
271
#endif
Generated on Tue Jun 5 2012 08:23:36 for dune-common by
1.8.1