Rheolef
7.2
an efficient C++ finite element environment
Loading...
Searching...
No Matches
communicator.h
Go to the documentation of this file.
1
# ifndef _RHEO_COMMUNICATOR_H
2
# define _RHEO_COMMUNICATOR_H
3
//
4
// This file is part of Rheolef.
5
//
6
// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
7
//
8
// Rheolef is free software; you can redistribute it and/or modify
9
// it under the terms of the GNU General Public License as published by
10
// the Free Software Foundation; either version 2 of the License, or
11
// (at your option) any later version.
12
//
13
// Rheolef is distributed in the hope that it will be useful,
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
// GNU General Public License for more details.
17
//
18
// You should have received a copy of the GNU General Public License
19
// along with Rheolef; if not, write to the Free Software
20
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
//
22
// =========================================================================
23
// AUTHOR: Pierre.Saramito@imag.fr
24
// DATE: 27 november 1998
25
26
namespace
rheolef
{
56
}
// namespace rheolef
57
#include "rheolef/compiler_mpi.h"
58
59
namespace
rheolef
{
60
61
struct
undefined_memory_model
{};
62
struct
sequential
{};
63
64
// compile-time predicate: is_sequential, is_distributed
65
template
<
class
M>
66
struct
is_sequential
{
67
static
const
bool
value
=
false
;
68
};
69
template
<
class
M>
70
struct
is_distributed
{
71
static
const
bool
value
=
false
;
72
};
73
template
<>
74
struct
is_sequential
<
sequential
> {
75
static
const
bool
value
=
true
;
76
};
77
template
<>
78
struct
is_distributed
<
sequential
> {
79
static
const
bool
value
=
false
;
80
};
81
82
// useful in expressions of type mixing fields and class-functions:
83
// promote memory_type to the field one
84
template
<
class
M1,
class
M2>
85
struct
promote_memory
{
86
typedef
undefined_memory_model
type
;
87
};
88
template
<>
89
struct
promote_memory
<
undefined_memory_model
,
sequential
> {
90
typedef
sequential
type
;
91
};
92
template
<>
93
struct
promote_memory
<
sequential
,
undefined_memory_model
> {
94
typedef
sequential
type
;
95
};
96
template
<>
97
struct
promote_memory
<
sequential
,
sequential
> {
98
typedef
sequential
type
;
99
};
100
101
}
// namespace rheolef
102
103
#ifndef _RHEOLEF_HAVE_MPI
104
// -----------------------------------------------------------------------
105
// distributed code & library should compile even without mpi
106
// -----------------------------------------------------------------------
107
# ifndef rheo_default_memory_model
108
# define rheo_default_memory_model sequential
109
# endif
110
namespace
rheolef
{
111
// [verbatim_communicator]
112
struct
communicator
{
113
typedef
std::vector<int>::size_type
size_type
;
114
int
size()
const
;
115
int
rank()
const
;
116
};
117
// [verbatim_communicator]
118
inline
int
communicator
size()
const
{
return
1; }
119
inline
int
communicator
rank()
const
{
return
0; }
120
}
// namespace rheolef
121
#else
122
// -----------------------------------------------------------------------
123
// distributed code here
124
// -----------------------------------------------------------------------
125
namespace
rheolef
{
126
using
mpi::communicator;
127
128
struct
distributed
{};
129
130
template
<>
131
struct
is_sequential
<
distributed
> {
132
static
const
bool
value
=
false
;
133
};
134
template
<>
135
struct
is_distributed
<
distributed
> {
136
static
const
bool
value
=
true
;
137
};
138
template
<>
139
struct
promote_memory
<
undefined_memory_model
,
distributed
> {
140
typedef
distributed
type
;
141
};
142
template
<>
143
struct
promote_memory
<
distributed
,
undefined_memory_model
> {
144
typedef
distributed
type
;
145
};
146
template
<>
147
struct
promote_memory
<
distributed
,
distributed
> {
148
typedef
distributed
type
;
149
};
150
}
// namespace rheolef
151
152
# ifndef rheo_default_memory_model
153
# define rheo_default_memory_model distributed
154
# endif
155
#endif
// _RHEOLEF_HAVE_MPI
156
157
#endif
// _RHEO_COMMUNICATOR_H
size_type
field::size_type size_type
Definition
branch.cc:430
communicator
see the communicator page for the full documentation
rheolef
This file is part of Rheolef.
Definition
compiler_eigen.h:39
rheolef::distributed
Definition
communicator.h:128
rheolef::is_distributed
Definition
communicator.h:70
rheolef::is_distributed::value
static const bool value
Definition
communicator.h:71
rheolef::is_sequential
Definition
communicator.h:66
rheolef::is_sequential::value
static const bool value
Definition
communicator.h:67
rheolef::promote_memory< distributed, distributed >::type
distributed type
Definition
communicator.h:148
rheolef::promote_memory< distributed, undefined_memory_model >::type
distributed type
Definition
communicator.h:144
rheolef::promote_memory< sequential, sequential >::type
sequential type
Definition
communicator.h:98
rheolef::promote_memory< sequential, undefined_memory_model >::type
sequential type
Definition
communicator.h:94
rheolef::promote_memory< undefined_memory_model, distributed >::type
distributed type
Definition
communicator.h:140
rheolef::promote_memory< undefined_memory_model, sequential >::type
sequential type
Definition
communicator.h:90
rheolef::promote_memory
Definition
communicator.h:85
rheolef::promote_memory::type
undefined_memory_model type
Definition
communicator.h:86
rheolef::sequential
Definition
communicator.h:62
rheolef::undefined_memory_model
Definition
communicator.h:61