Schnek
mpisubdivision.hpp
1
/*
2
* mpisubdivision.hpp
3
*
4
* Created on: 27 Sep 2012
5
* Author: Holger Schmitz
6
* Email: holger@notjustphysics.com
7
*
8
* Copyright 2012 Holger Schmitz
9
*
10
* This file is part of Schnek.
11
*
12
* Schnek is free software: you can redistribute it and/or modify
13
* it under the terms of the GNU General Public License as published by
14
* the Free Software Foundation, either version 3 of the License, or
15
* (at your option) any later version.
16
*
17
* Schnek is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
* GNU General Public License for more details.
21
*
22
* You should have received a copy of the GNU General Public License
23
* along with Schnek. If not, see <http://www.gnu.org/licenses/>.
24
*
25
*/
26
27
#ifndef SCHNEK_MPISUBDIVISION_HPP
28
#define SCHNEK_MPISUBDIVISION_HPP
29
30
#include "
domainsubdivision.hpp
"
31
#include "../schnek_config.hpp"
32
33
#ifdef SCHNEK_HAVE_MPI
34
35
#include <mpi.h>
36
37
namespace
schnek
{
38
44
template
<
class
Gr
id
Type>
45
class
MPICartSubdivision :
public
DomainSubdivision<GridType>
46
{
47
public
:
48
typedef
typename
DomainSubdivision<GridType>::LimitType LimitType;
49
typedef
typename
GridType::value_type value_type;
50
typedef
typename
DomainSubdivision<GridType>::DomainType DomainType;
51
typedef
typename
DomainSubdivision<GridType>::BoundaryType BoundaryType;
52
typedef
typename
DomainSubdivision<GridType>::BufferType BufferType;
53
54
enum
{Rank = GridType::Rank};
55
protected
:
57
int
ComSize;
58
60
int
ComRank;
61
63
MPI_Comm comm;
64
65
LimitType prevcoord;
66
LimitType nextcoord;
67
69
int
dims[Rank];
71
int
mycoord[Rank];
72
76
int
exchSize[Rank];
77
78
value_type *sendarr[Rank];
79
value_type *recvarr[Rank];
80
82
int
scalarSize;
83
84
DomainType globalDomain;
85
public
:
86
using
DomainSubdivision<GridType>::init
;
87
using
DomainSubdivision<GridType>::exchange
;
89
MPICartSubdivision();
90
92
~MPICartSubdivision();
93
95
void
init(
const
LimitType &low,
const
LimitType &high,
int
delta);
96
98
const
DomainType &getGlobalDomain()
const
{
return
globalDomain; }
99
105
void
exchange(GridType &field,
int
dim);
106
110
void
accumulate(GridType &grid,
int
dim);
111
118
void
exchangeData(
int
dim,
int
orientation, BufferType &in, BufferType &out);
119
121
double
avgReduce(
double
val)
const
;
122
124
int
avgReduce(
int
val)
const
;
125
127
double
maxReduce(
double
val)
const
;
128
130
int
maxReduce(
int
val)
const
;
131
133
double
minReduce(
double
val)
const
;
134
136
int
minReduce(
int
val)
const
;
137
139
double
sumReduce(
double
val)
const
;
140
142
int
sumReduce(
int
val)
const
;
143
145
bool
master()
const
{
return
ComRank==0; }
146
148
int
procnum()
const
{
return
ComRank; }
149
151
int
procCount()
const
{
return
ComSize; }
152
154
int
getUniqueId()
const
;
155
166
bool
isBoundLo(
int
dim) {
return
mycoord[dim]==0; }
167
178
bool
isBoundHi(
int
dim) {
return
mycoord[dim]==dims[dim]-1; }
179
};
180
181
template
<
typename
value_type>
182
struct
MpiValueType
183
{
184
static
const
MPI_Datatype value;
185
};
186
187
}
// namespace schnek
188
189
190
#include "mpisubdivision.t"
191
192
#endif // HAVE_MPI
193
194
#endif // SCHNEK_MPISUBDIVISION_HPP
195
196
domainsubdivision.hpp
Interface for wrapping and exchanging boundaries.
schnek::DomainSubdivision::init
virtual void init(const LimitType &low, const LimitType &high, int delta)=0
schnek
Definition:
algo.hpp:30
schnek::DomainSubdivision::exchange
virtual void exchange(GridType &grid, int dim)=0
Exchange the boundaries of a field function in the direction given by dim.
src
grid
mpisubdivision.hpp
Generated by
1.8.13