Chi-Tech
mpi_info.h
Go to the documentation of this file.
1#ifndef CHITECH_MPI_INFO_H
2#define CHITECH_MPI_INFO_H
3
4#include <mpi.h>
5#include <set>
6
7class Chi;
8
9namespace chi
10{
11
12//################################################################### Class def
13/**An object for storing various MPI states.*/
15{
16 friend class ::Chi;
17private:
18 MPI_Comm communicator_ = MPI_COMM_WORLD;
19 int location_id_ = 0;
21
22 bool location_id_set_ = false;
23 bool process_count_set_ = false;
24
25public:
26 const int& location_id = location_id_; ///< Current process rank.
27 const int& process_count = process_count_; ///< Total number of processes.
28 const MPI_Comm& comm = communicator_; ///< MPI communicator
29
30private:
31 MPI_Info() = default;
32
33public:
34 static MPI_Info& GetInstance() noexcept;
35
36public:
37 MPI_Info(const MPI_Info&) = delete; //Deleted copy constructor
38 MPI_Info operator=(const MPI_Info&) = delete; //Deleted assigment operator
39
40protected:
41 /**Sets the active communicator*/
42 void SetCommunicator(MPI_Comm new_communicator);
43 /**Sets the rank.*/
44 void SetLocationID(int in_location_id);
45 /**Sets the number of processes in the communicator.*/
46 void SetProcessCount(int in_process_count);
47
48public:
49 /**Calls the generic `MPI_Barrier` with the current communicator.*/
50 void Barrier() const;
51 static void Call(int mpi_error_code);
52
53};
54
55}//namespace chi_objects
56
57#endif //CHITECH_MPI_INFO_H
MPI_Info()=default
const MPI_Comm & comm
MPI communicator.
Definition: mpi_info.h:28
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
const int & process_count
Total number of processes.
Definition: mpi_info.h:27
bool process_count_set_
Definition: mpi_info.h:23
const int & location_id
Current process rank.
Definition: mpi_info.h:26