monolish  0.16.0
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 
4 namespace monolish {
14 namespace mpi {
22 class comm {
23 private:
28  comm(){};
29  ~comm(){};
30 
31  std::vector<MPI_Request> requests;
32 
33 public:
34  comm(const comm &) = delete;
35  comm &operator=(const comm &) = delete;
36  comm(comm &&) = delete;
37  comm &operator=(comm &&) = delete;
38 
39  static comm &get_instance() {
40  static comm instance;
41  return instance;
42  }
43 
47  void Init();
48 
54  void Init(int argc, char **argv);
55 
60  bool Initialized() const;
61 
63 
68  [[nodiscard]] MPI_Comm get_comm() const { return my_comm; }
69 
73  void set_comm(MPI_Comm external_comm);
74 
78  void Finalize();
79 
84  [[nodiscard]] int get_rank();
85 
90  [[nodiscard]] int get_size();
91 
93 
98  void Barrier() const;
99 
106  void Send(double val, int dst, int tag) const;
107 
114  void Send(float val, int dst, int tag) const;
115 
122  void Send(int val, int dst, int tag) const;
123 
130  void Send(size_t val, int dst, int tag) const;
131 
138  void Send(std::vector<double> &vec, int dst, int tag) const;
139 
146  void Send(std::vector<float> &vec, int dst, int tag) const;
147 
154  void Send(std::vector<int> &vec, int dst, int tag) const;
155 
162  void Send(std::vector<size_t> &vec, int dst, int tag) const;
163 
174  void Send(monolish::vector<double> &vec, int dst, int tag) const;
175 
186  void Send(monolish::vector<float> &vec, int dst, int tag) const;
187 
195  MPI_Status Recv(double val, int src, int tag) const;
196 
204  MPI_Status Recv(float val, int src, int tag) const;
205 
213  MPI_Status Recv(int val, int src, int tag) const;
214 
222  MPI_Status Recv(size_t val, int src, int tag) const;
223 
231  MPI_Status Recv(std::vector<double> &vec, int src, int tag) const;
232 
240  MPI_Status Recv(std::vector<float> &vec, int src, int tag) const;
241 
249  MPI_Status Recv(std::vector<int> &vec, int src, int tag) const;
250 
258  MPI_Status Recv(std::vector<size_t> &vec, int src, int tag) const;
259 
271  MPI_Status Recv(monolish::vector<double> &vec, int src, int tag) const;
272 
284  MPI_Status Recv(monolish::vector<float> &vec, int src, int tag) const;
285 
298  void Isend(double val, int dst, int tag);
299 
312  void Isend(float val, int dst, int tag);
313 
326  void Isend(int val, int dst, int tag);
327 
340  void Isend(size_t val, int dst, int tag);
341 
354  void Isend(const std::vector<double> &vec, int dst, int tag);
355 
368  void Isend(const std::vector<float> &vec, int dst, int tag);
369 
382  void Isend(const std::vector<int> &vec, int dst, int tag);
383 
396  void Isend(const std::vector<size_t> &vec, int dst, int tag);
397 
412  void Isend(const monolish::vector<double> &vec, int dst, int tag);
413 
428  void Isend(const monolish::vector<float> &vec, int dst, int tag);
429 
441  void Irecv(double val, int src, int tag);
442 
454  void Irecv(float val, int src, int tag);
455 
467  void Irecv(int val, int src, int tag);
468 
480  void Irecv(size_t val, int src, int tag);
481 
493  void Irecv(std::vector<double> &vec, int src, int tag);
494 
506  void Irecv(std::vector<float> &vec, int src, int tag);
507 
519  void Irecv(std::vector<int> &vec, int src, int tag);
520 
532  void Irecv(std::vector<size_t> &vec, int src, int tag);
533 
547  void Irecv(monolish::vector<double> &vec, int src, int tag);
548 
562  void Irecv(monolish::vector<float> &vec, int src, int tag);
563 
567  void Waitall();
568 
574  [[nodiscard]] double Allreduce(double val) const;
575 
581  [[nodiscard]] float Allreduce(float val) const;
582 
588  [[nodiscard]] int Allreduce(int val) const;
589 
595  [[nodiscard]] size_t Allreduce(size_t val) const;
596 
602  [[nodiscard]] double Allreduce_sum(double val) const;
603 
609  [[nodiscard]] float Allreduce_sum(float val) const;
610 
616  [[nodiscard]] int Allreduce_sum(int val) const;
617 
623  [[nodiscard]] size_t Allreduce_sum(size_t val) const;
624 
630  [[nodiscard]] double Allreduce_prod(double val) const;
631 
637  [[nodiscard]] float Allreduce_prod(float val) const;
638 
644  [[nodiscard]] int Allreduce_prod(int val) const;
645 
651  [[nodiscard]] size_t Allreduce_prod(size_t val) const;
652 
658  [[nodiscard]] double Allreduce_max(double val) const;
659 
665  [[nodiscard]] float Allreduce_max(float val) const;
666 
672  [[nodiscard]] int Allreduce_max(int val) const;
673 
679  [[nodiscard]] size_t Allreduce_max(size_t val) const;
680 
686  [[nodiscard]] double Allreduce_min(double val) const;
687 
693  [[nodiscard]] float Allreduce_min(float val) const;
694 
700  [[nodiscard]] int Allreduce_min(int val) const;
701 
707  [[nodiscard]] size_t Allreduce_min(size_t val) const;
708 
715  void Bcast(double &val, int root) const;
716 
723  void Bcast(float &val, int root) const;
724 
731  void Bcast(int &val, int root) const;
732 
739  void Bcast(size_t &val, int root) const;
740 
747  void Bcast(monolish::vector<double> &vec, int root) const;
748 
755  void Bcast(monolish::vector<float> &vec, int root) const;
756 
763  void Bcast(std::vector<double> &vec, int root) const;
764 
771  void Bcast(std::vector<float> &vec, int root) const;
772 
779  void Bcast(std::vector<int> &vec, int root) const;
780 
787  void Bcast(std::vector<size_t> &vec, int root) const;
788 
800  void Gather(monolish::vector<double> &sendvec,
801  monolish::vector<double> &recvvec, int root) const;
802 
814  void Gather(monolish::vector<float> &sendvec,
815  monolish::vector<float> &recvvec, int root) const;
816 
824  void Gather(std::vector<double> &sendvec, std::vector<double> &recvvec,
825  int root) const;
826 
834  void Gather(std::vector<float> &sendvec, std::vector<float> &recvvec,
835  int root) const;
836 
844  void Gather(std::vector<int> &sendvec, std::vector<int> &recvvec,
845  int root) const;
846 
854  void Gather(std::vector<size_t> &sendvec, std::vector<size_t> &recvvec,
855  int root) const;
856 
868  void Scatter(monolish::vector<double> &sendvec,
869  monolish::vector<double> &recvvec, int root) const;
870 
882  void Scatter(monolish::vector<float> &sendvec,
883  monolish::vector<float> &recvvec, int root) const;
884 
892  void Scatter(std::vector<double> &sendvec, std::vector<double> &recvvec,
893  int root) const;
894 
902  void Scatter(std::vector<float> &sendvec, std::vector<float> &recvvec,
903  int root) const;
904 
912  void Scatter(std::vector<int> &sendvec, std::vector<int> &recvvec,
913  int root) const;
914 
922  void Scatter(std::vector<size_t> &sendvec, std::vector<size_t> &recvvec,
923  int root) const;
924 };
926 } // namespace mpi
927 } // namespace monolish
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:28
monolish::mpi::comm::my_comm
MPI_Comm my_comm
MPI communicator, MPI_COMM_WORLD.
Definition: monolish_mpi_core.hpp:27
MPI_Status
int MPI_Status
Definition: mpi_dummy.hpp:37
monolish::mpi::comm::~comm
~comm()
Definition: monolish_mpi_core.hpp:29
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....
monolish
monolish namespaces
Definition: monolish_matrix_blas.hpp:5
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:39
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:22
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:68
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:29
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.