Chi-Tech
mpi_info.cc
Go to the documentation of this file.
1#include "mpi_info.h"
2
4
5namespace chi
6{
7
8//###################################################################
9/**Access to the singleton*/
11{
12 static MPI_Info singleton;
13 return singleton;
14}
15
16/**Sets the active communicator*/
17void MPI_Info::SetCommunicator(MPI_Comm new_communicator)
18{
19 communicator_ = new_communicator;
20}
21
22/**Sets the rank.*/
23void MPI_Info::SetLocationID(int in_location_id)
24{
25 if (not location_id_set_)
26 location_id_ = in_location_id;
27 location_id_set_ = true;
28}
29
30/**Sets the number of processes in the communicator.*/
31void MPI_Info::SetProcessCount(int in_process_count)
32{
33 if (not process_count_set_)
34 process_count_ = in_process_count;
35 process_count_set_ = true;
36}
37
39{
40 MPI_Barrier(this->communicator_);
41}
42
43void MPI_Info::Call(int mpi_error_code)
44{
45 if (mpi_error_code == MPI_SUCCESS) return;
46 else
47 {
48 char estring[MPI_MAX_ERROR_STRING];
49 int resultlen;
50 MPI_Error_string(mpi_error_code, estring, &resultlen);
51
52 ChiLogicalError(estring);
53 }
54}
55
56}//namespace chi_objects
#define ChiLogicalError(message)
MPI_Comm communicator_
Definition: mpi_info.h:18
void Barrier() const
Definition: mpi_info.cc:38
static MPI_Info & GetInstance() noexcept
Definition: mpi_info.cc:10
void SetProcessCount(int in_process_count)
Definition: mpi_info.cc:31
void SetLocationID(int in_location_id)
Definition: mpi_info.cc:23
int location_id_
Definition: mpi_info.h:19
static void Call(int mpi_error_code)
Definition: mpi_info.cc:43
void SetCommunicator(MPI_Comm new_communicator)
Definition: mpi_info.cc:17
bool location_id_set_
Definition: mpi_info.h:22
int process_count_
Definition: mpi_info.h:20
bool process_count_set_
Definition: mpi_info.h:23