BELFEM
0.9.0
Berkeley Lab Finite Element Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
commtypes.hpp
Go to the documentation of this file.
1
/*
2
* BELFEM -- The Berkeley Lab Finite Element Framework
3
* Copyright (c) 2026, The Regents of the University of California,
4
* through Lawrence Berkeley National Laboratory (subject to receipt of any required
5
* approvals from the U.S. Dept. of Energy). All rights reserved.
6
*
7
* Developers: Christian Messe, Gregory Giard
8
*
9
* See the top-level LICENSE file for the complete license and disclaimer.
10
*/
11
12
#ifndef COMMTYPES_HPP
13
#define COMMTYPES_HPP
14
15
#include <complex>
16
17
#ifdef BELFEM_MPI
18
#include <mpi.h>
19
#endif
20
21
namespace
belfem
22
{
23
#ifdef BELFEM_MPI
24
typedef
MPI_Datatype
comm_t
;
25
#else
26
// define fake type if there is no MPI
27
typedef
int
comm_t
;
28
#endif
29
typedef
int
proc_t
;
30
31
//------------------------------------------------------------------------------
32
36
template
<
typename
T>
comm_t
37
comm_type
()
38
{
39
#ifdef BELFEM_MPI
40
BELFEM_ERROR
(
false
,
"Unknown datatype"
);
41
return
MPI_DATATYPE_NULL;
42
#else
43
return
0 ;
44
#endif
45
}
46
47
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
48
#ifdef BELFEM_MPI
49
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
50
51
template
<>
inline
comm_t
52
comm_type< char >
()
53
{
54
return
MPI_CHAR;
55
}
56
57
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
58
59
template
<>
inline
comm_t
60
comm_type< int >
()
61
{
62
return
MPI_INT;
63
}
64
65
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
66
67
template
<>
inline
comm_t
68
comm_type< long int >
()
69
{
70
return
MPI_LONG;
71
}
72
73
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
74
75
template
<>
inline
comm_t
76
comm_type< short unsigned int >
()
77
{
78
return
MPI_UNSIGNED_SHORT;
79
}
80
81
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
82
83
template
<>
inline
comm_t
84
comm_type< unsigned int >
()
85
{
86
return
MPI_UNSIGNED;
87
}
88
89
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
90
91
template
<>
inline
comm_t
92
comm_type< long unsigned int >
()
93
{
94
return
MPI_UNSIGNED_LONG;
95
}
96
97
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
98
99
template
<>
inline
comm_t
100
comm_type< double >
()
101
{
102
return
MPI_DOUBLE ;
103
}
104
105
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
106
107
template
<>
inline
comm_t
108
comm_type< long double >
()
109
{
110
return
MPI_LONG_DOUBLE ;
111
}
112
113
114
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
115
116
template
<>
inline
comm_t
117
comm_type< signed char >
()
118
{
119
return
MPI_SIGNED_CHAR;
120
}
121
122
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
123
124
template
<>
inline
comm_t
125
comm_type< unsigned char >
()
126
{
127
return
MPI_UNSIGNED_CHAR;
128
}
129
130
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
131
132
template
<>
inline
comm_t
133
comm_type< short int >
()
134
{
135
return
MPI_SHORT;
136
}
137
138
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
139
140
template
<>
inline
comm_t
141
comm_type< long long int >
()
142
{
143
return
MPI_LONG_LONG;
144
}
145
146
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
147
148
template
<>
inline
comm_t
149
comm_type< unsigned long long int >
()
150
{
151
return
MPI_UNSIGNED_LONG_LONG;
152
}
153
154
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
155
156
template
<>
inline
comm_t
157
comm_type< float >
()
158
{
159
return
MPI_FLOAT;
160
}
161
162
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
163
164
template
<>
inline
comm_t
165
comm_type< bool >
()
166
{
167
return
MPI_CXX_BOOL;
168
}
169
170
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
171
172
#ifdef MPI_CXX_FLOAT_COMPLEX
173
template
<>
inline
comm_t
174
comm_type< std::complex< float >
> ()
175
{
176
return
MPI_CXX_FLOAT_COMPLEX;
177
}
178
#endif
179
180
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
181
182
#ifdef MPI_CXX_DOUBLE_COMPLEX
183
template
<>
inline
comm_t
184
comm_type< std::complex< double >
> ()
185
{
186
return
MPI_CXX_DOUBLE_COMPLEX ;
187
}
188
#endif
189
190
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
191
192
#ifdef MPI_CXX_LONG_DOUBLE_COMPLEX
193
template
<>
inline
comm_t
194
comm_type< std::complex< long double >
> ()
195
{
196
return
MPI_CXX_LONG_DOUBLE_COMPLEX ;
197
}
198
#endif
199
200
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
201
202
#endif
// BELFEM_MPI
203
//------------------------------------------------------------------------------
204
}
205
206
#endif
//COMMTYPES_HPP
BELFEM_ERROR
#define BELFEM_ERROR(aCheck,...)
Definition
assert.hpp:264
belfem
USER GUIDES:
Definition
cl_Capacitor.cpp:16
belfem::comm_type
comm_t comm_type()
returns the MPI datatype handle for T
Definition
commtypes.hpp:37
belfem::comm_t
int comm_t
Definition
commtypes.hpp:27
belfem::proc_t
int proc_t
Definition
commtypes.hpp:29
src
comm
commtypes.hpp
Generated by
1.18.0