monolish  0.15.1
MONOlithic LInear equation Solvers for Highly-parallel architecture
monolish_mpi_core.hpp
Go to the documentation of this file.
1 // this source code is generated by include/mpi/gen_all.sh
2 #pragma once
3 
12 namespace monolish::mpi {
16 class comm {
17 private:
22  comm(){};
23  ~comm(){};
24 
25  std::vector<MPI_Request> requests;
26 
27 public:
28  comm(const comm &) = delete;
29  comm &operator=(const comm &) = delete;
30  comm(comm &&) = delete;
31  comm &operator=(comm &&) = delete;
32 
33  static comm &get_instance() {
34  static comm instance;
35  return instance;
36  }
37 
41  void Init();
42 
48  void Init(int argc, char **argv);
49 
54  bool Initialized() const;
55 
57 
62  [[nodiscard]] MPI_Comm get_comm() const { return my_comm; }
63 
67  void set_comm(MPI_Comm external_comm);
68 
72  void Finalize();
73 
78  [[nodiscard]] int get_rank();
79 
84  [[nodiscard]] int get_size();
85 
87 
92  void Barrier() const;
93 
100  void Send(double val, int dst, int tag) const;
101 
108  void Send(float val, int dst, int tag) const;
109 
116  void Send(int val, int dst, int tag) const;
117 
124  void Send(size_t val, int dst, int tag) const;
125 
132  void Send(std::vector<double> &vec, int dst, int tag) const;
133 
140  void Send(std::vector<float> &vec, int dst, int tag) const;
141 
148  void Send(std::vector<int> &vec, int dst, int tag) const;
149 
156  void Send(std::vector<size_t> &vec, int dst, int tag) const;
157 
168  void Send(monolish::vector<double> &vec, int dst, int tag) const;
169 
180  void Send(monolish::vector<float> &vec, int dst, int tag) const;
181 
189  MPI_Status Recv(double val, int src, int tag) const;
190 
198  MPI_Status Recv(float val, int src, int tag) const;
199 
207  MPI_Status Recv(int val, int src, int tag) const;
208 
216  MPI_Status Recv(size_t val, int src, int tag) const;
217 
225  MPI_Status Recv(std::vector<double> &vec, int src, int tag) const;
226 
234  MPI_Status Recv(std::vector<float> &vec, int src, int tag) const;
235 
243  MPI_Status Recv(std::vector<int> &vec, int src, int tag) const;
244 
252  MPI_Status Recv(std::vector<size_t> &vec, int src, int tag) const;
253 
265  MPI_Status Recv(monolish::vector<double> &vec, int src, int tag) const;
266 
278  MPI_Status Recv(monolish::vector<float> &vec, int src, int tag) const;
279 
292  void Isend(double val, int dst, int tag);
293 
306  void Isend(float val, int dst, int tag);
307 
320  void Isend(int val, int dst, int tag);
321 
334  void Isend(size_t val, int dst, int tag);
335 
348  void Isend(const std::vector<double> &vec, int dst, int tag);
349 
362  void Isend(const std::vector<float> &vec, int dst, int tag);
363 
376  void Isend(const std::vector<int> &vec, int dst, int tag);
377 
390  void Isend(const std::vector<size_t> &vec, int dst, int tag);
391 
406  void Isend(const monolish::vector<double> &vec, int dst, int tag);
407 
422  void Isend(const monolish::vector<float> &vec, int dst, int tag);
423 
435  void Irecv(double val, int src, int tag);
436 
448  void Irecv(float val, int src, int tag);
449 
461  void Irecv(int val, int src, int tag);
462 
474  void Irecv(size_t val, int src, int tag);
475 
487  void Irecv(std::vector<double> &vec, int src, int tag);
488 
500  void Irecv(std::vector<float> &vec, int src, int tag);
501 
513  void Irecv(std::vector<int> &vec, int src, int tag);
514 
526  void Irecv(std::vector<size_t> &vec, int src, int tag);
527 
541  void Irecv(monolish::vector<double> &vec, int src, int tag);
542 
556  void Irecv(monolish::vector<float> &vec, int src, int tag);
557 
561  void Waitall();
562 
568  [[nodiscard]] double Allreduce(double val) const;
569 
575  [[nodiscard]] float Allreduce(float val) const;
576 
582  [[nodiscard]] int Allreduce(int val) const;
583 
589  [[nodiscard]] size_t Allreduce(size_t val) const;
590 
596  [[nodiscard]] double Allreduce_sum(double val) const;
597 
603  [[nodiscard]] float Allreduce_sum(float val) const;
604 
610  [[nodiscard]] int Allreduce_sum(int val) const;
611 
617  [[nodiscard]] size_t Allreduce_sum(size_t val) const;
618 
624  [[nodiscard]] double Allreduce_prod(double val) const;
625 
631  [[nodiscard]] float Allreduce_prod(float val) const;
632 
638  [[nodiscard]] int Allreduce_prod(int val) const;
639 
645  [[nodiscard]] size_t Allreduce_prod(size_t val) const;
646 
652  [[nodiscard]] double Allreduce_max(double val) const;
653 
659  [[nodiscard]] float Allreduce_max(float val) const;
660 
666  [[nodiscard]] int Allreduce_max(int val) const;
667 
673  [[nodiscard]] size_t Allreduce_max(size_t val) const;
674 
680  [[nodiscard]] double Allreduce_min(double val) const;
681 
687  [[nodiscard]] float Allreduce_min(float val) const;
688 
694  [[nodiscard]] int Allreduce_min(int val) const;
695 
701  [[nodiscard]] size_t Allreduce_min(size_t val) const;
702 
709  void Bcast(double &val, int root) const;
710 
717  void Bcast(float &val, int root) const;
718 
725  void Bcast(int &val, int root) const;
726 
733  void Bcast(size_t &val, int root) const;
734 
741  void Bcast(monolish::vector<double> &vec, int root) const;
742 
749  void Bcast(monolish::vector<float> &vec, int root) const;
750 
757  void Bcast(std::vector<double> &vec, int root) const;
758 
765  void Bcast(std::vector<float> &vec, int root) const;
766 
773  void Bcast(std::vector<int> &vec, int root) const;
774 
781  void Bcast(std::vector<size_t> &vec, int root) const;
782 
794  void Gather(monolish::vector<double> &sendvec,
795  monolish::vector<double> &recvvec, int root) const;
796 
808  void Gather(monolish::vector<float> &sendvec,
809  monolish::vector<float> &recvvec, int root) const;
810 
818  void Gather(std::vector<double> &sendvec, std::vector<double> &recvvec,
819  int root) const;
820 
828  void Gather(std::vector<float> &sendvec, std::vector<float> &recvvec,
829  int root) const;
830 
838  void Gather(std::vector<int> &sendvec, std::vector<int> &recvvec,
839  int root) const;
840 
848  void Gather(std::vector<size_t> &sendvec, std::vector<size_t> &recvvec,
849  int root) const;
850 
862  void Scatter(monolish::vector<double> &sendvec,
863  monolish::vector<double> &recvvec, int root) const;
864 
876  void Scatter(monolish::vector<float> &sendvec,
877  monolish::vector<float> &recvvec, int root) const;
878 
886  void Scatter(std::vector<double> &sendvec, std::vector<double> &recvvec,
887  int root) const;
888 
896  void Scatter(std::vector<float> &sendvec, std::vector<float> &recvvec,
897  int root) const;
898 
906  void Scatter(std::vector<int> &sendvec, std::vector<int> &recvvec,
907  int root) const;
908 
916  void Scatter(std::vector<size_t> &sendvec, std::vector<size_t> &recvvec,
917  int root) const;
918 };
919 } // namespace monolish::mpi
monolish::mpi::comm::Barrier
void Barrier() const
Blocks until all processes in the communicator have reached this routine.
monolish::mpi::comm::get_size
int get_size()
get the number of processes
monolish::mpi::comm::Allreduce_prod
double Allreduce_prod(double val) const
MPI_Allreduce (MPI_PROD) for scalar. Combines values from all processes and distributes the result ba...
monolish::mpi::comm::Waitall
void Waitall()
Waits for all communications to complete.
monolish::mpi::comm::Gather
void Gather(monolish::vector< double > &sendvec, monolish::vector< double > &recvvec, int root) const
MPI_Gather, Gathers vector from all processes The data is evenly divided and transmitted to each proc...
monolish::mpi::comm::Irecv
void Irecv(double val, int src, int tag)
MPI_Irecv for scalar. Performs a nonblocking recv.
monolish::mpi::comm::comm
comm()
Definition: monolish_mpi_core.hpp:22
monolish::mpi::comm::my_comm
MPI_Comm my_comm
MPI communicator, MPI_COMM_WORLD.
Definition: monolish_mpi_core.hpp:21
MPI_Status
int MPI_Status
Definition: mpi_dummy.hpp:37
monolish::mpi::comm::~comm
~comm()
Definition: monolish_mpi_core.hpp:23
monolish::mpi::comm::Allreduce
double Allreduce(double val) const
MPI_Allreduce (MPI_SUM) for scalar. Combines values from all processes and distributes the result bac...
monolish::mpi::comm::Allreduce_min
double Allreduce_min(double val) const
MPI_Allreduce (MPI_MIN) for scalar. Combines values from all processes and distributes the result bac...
monolish::mpi::comm::Allreduce_max
double Allreduce_max(double val) const
MPI_Allreduce (MPI_MAX) for scalar. Combines values from all processes and distributes the result bac...
monolish::mpi::comm::Isend
void Isend(double val, int dst, int tag)
MPI_Isend for scalar. Performs a nonblocking send. Requests are stored internally....
MPI_Comm
struct ompi_communicator_t * MPI_Comm
Definition: mpi_dummy.hpp:40
monolish::mpi::comm::get_instance
static comm & get_instance()
Definition: monolish_mpi_core.hpp:33
monolish::mpi::comm::Initialized
bool Initialized() const
Indicates whether MPI_Init has been called.
monolish::mpi::comm
MPI class (singleton)
Definition: monolish_mpi_core.hpp:16
monolish::mpi
C++ template MPI class, Functions of this class do nothing when MPI is disabled. Functions in this cl...
Definition: monolish_mpi_core.hpp:12
monolish::mpi::comm::Send
void Send(double val, int dst, int tag) const
MPI_Send for scalar. Performs a blocking send.
monolish::vector< double >
monolish::mpi::comm::Bcast
void Bcast(double &val, int root) const
MPI_Bcast, Broadcasts a message from the process with rank root to all other processes.
monolish::mpi::comm::Allreduce_sum
double Allreduce_sum(double val) const
MPI_Allreduce (MPI_SUM) for scalar. Combines values from all processes and distributes the result bac...
monolish::mpi::comm::get_rank
int get_rank()
get my rank number
monolish::mpi::comm::get_comm
MPI_Comm get_comm() const
get communicator
Definition: monolish_mpi_core.hpp:62
monolish::mpi::comm::operator=
comm & operator=(const comm &)=delete
monolish::mpi::comm::set_comm
void set_comm(MPI_Comm external_comm)
set communicator
monolish::mpi::comm::Scatter
void Scatter(monolish::vector< double > &sendvec, monolish::vector< double > &recvvec, int root) const
MPI_Scatter, Sends data from one task to all tasks. The data is evenly divided and transmitted to eac...
monolish::mpi::comm::requests
std::vector< MPI_Request > requests
Definition: monolish_mpi_core.hpp:23
monolish::mpi::comm::Finalize
void Finalize()
Terminates MPI execution environment.
monolish::mpi::comm::Init
void Init()
Initialize the MPI execution environment.
monolish::mpi::comm::Recv
MPI_Status Recv(double val, int src, int tag) const
MPI_Recv for scalar. Performs a blocking recv.