ExaDG
Toggle main menu visibility
Loading...
Searching...
No Matches
include
exadg
utilities
mpi.h
1
/* ______________________________________________________________________
2
*
3
* ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4
*
5
* Copyright (C) 2021 by the ExaDG authors
6
*
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19
* ______________________________________________________________________
20
*/
21
22
#ifndef EXADG_UTILITIES_MPI_H_
23
#define EXADG_UTILITIES_MPI_H_
24
25
namespace
ExaDG
26
{
27
/*
28
* Return whether the current MPI process is the first on a compute node,
29
* defined as the ranks which share the same memory
30
* (`MPI_COMM_TYPE_SHARED`). The second argument returns the number of
31
* processes per node, in case it is needed in the algorithm.
32
*/
33
std::tuple<bool, unsigned int>
34
identify_first_process_on_node(MPI_Comm
const
& mpi_comm)
35
{
36
int
rank;
37
MPI_Comm_rank(mpi_comm, &rank);
38
39
MPI_Comm comm_shared;
40
MPI_Comm_split_type(mpi_comm, MPI_COMM_TYPE_SHARED, rank, MPI_INFO_NULL, &comm_shared);
41
42
int
size_shared;
43
MPI_Comm_size(comm_shared, &size_shared);
44
MPI_Comm_free(&comm_shared);
45
46
AssertThrow(size_shared == dealii::Utilities::MPI::max(size_shared, mpi_comm),
47
dealii::ExcMessage(
48
"The identification of MPI process groups in terms of compute nodes only "
49
"works if all nodes are populated with the same number of MPI ranks!"
));
50
return
{rank % size_shared == 0, size_shared};
51
}
52
53
}
// namespace ExaDG
54
55
#endif
/* EXADG_UTILITIES_MPI_H_ */
ExaDG
Definition
driver.cpp:33
Generated by
1.17.0