CEPS  24.01
Cardiac ElectroPhysiology Simulator
CepsParallelTools.hpp
Go to the documentation of this file.
1 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2  This file is part of CEPS.
3 
4  CEPS is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  CEPS is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with CEPS (see file LICENSE at root of project).
16  If not, see <https://www.gnu.org/licenses/>.
17 
18 
19  Copyright 2019-2024 Inria, Universite de Bordeaux
20 
21  Authors, in alphabetical order:
22 
23  Pierre-Elliott BECUE, Florian CARO, Yves COUDIERE(*), Andjela DAVIDOVIC,
24  Charlie DOUANLA-LONTSI, Marc FUENTES, Mehdi JUHOOR, Michael LEGUEBE(*),
25  Pauline MIGERDITICHAN, Valentin PANNETIER(*), Nejib ZEMZEMI.
26  * : currently active authors
27 
28 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
31 #pragma once
32 
34 
35 // master rank default value
36 #define CEPS_MASTER_PROC 0
37 
39 namespace ceps
40 {
53  CepsUInt
54  initialize(int argc, char* argv[]);
55 
62  void
63  finalize();
64 
66  void
68 
70  CepsUInt
71  getRank();
72 
74  CepsUInt
75  getGridSize();
76 
78  CepsBool
79  isMaster();
80 
82  CepsBool
83  isLast();
84 
86  CepsBool
87  isParallel();
88 
90  void
91  barrier();
92 
105  void
106  beginSequential();
107 
116  void
117  endSequential();
118 
120  MPI_Comm
121  getCommunicator();
122 
124  MPI_Comm*
126 
131  CepsString
132  execute(CepsString command, CepsBool withErr = false, CepsBool abortOnErr = false);
133 
134 } // namespace ceps
std::basic_string< CepsChar > CepsString
C++ format string.
Definition: CepsTypes.hpp:128
bool CepsBool
Booleans.
Definition: CepsTypes.hpp:124
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
Definition: CepsTypes.hpp:109
A namespace for all utility methods.
CepsString execute(CepsString command, CepsBool withErr=false, CepsBool abortOnErr=false)
Not really a parallel thing. Calls system() and deals with return code.
CepsUInt getRank()
Returns current processor rank.
MPI_Comm getCommunicator()
Get the communicator.
CepsBool isLast()
Is calling process last in computing grid ?
CepsBool isParallel()
Is there more than 1 process currently working ?
CepsUInt getGridSize()
Returns the number of process on the computing grid.
CepsUInt initialize(int argc, char *argv[])
Initializes parallel environment.
void finalize()
Finalizes parallel environment.
void barrier()
Explicit barrier: wait for all processors before continuing.
void beginSequential()
Begins a sequential block.
CepsBool isMaster()
Is calling process the master ?
MPI_Comm * getPtrCommunicator()
Get pointer to the communicator.
void endSequential()
End a sequential block.
void finalizeWithError()
Calls MPI_Abort, function used instead of std::terminate()