monolish  0.16.3
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 
801  monolish::vector<double> &recvvec, int root) const;
802 
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 
869  monolish::vector<double> &recvvec, int root) const;
870 
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
MPI class (singleton)
bool Initialized() const
Indicates whether MPI_Init has been called.
void Barrier() const
Blocks until all processes in the communicator have reached this routine.
void Irecv(std::vector< size_t > &vec, int src, int tag)
MPI_Irecv for std::vector. Performs a nonblocking recv.
void Gather(std::vector< size_t > &sendvec, std::vector< size_t > &recvvec, int root) const
MPI_Gather, Gathers vector from all processes The data is evenly divided and transmitted to each proc...
void Isend(const std::vector< size_t > &vec, int dst, int tag)
MPI_Isend for std::vector. Performs a nonblocking send. Requests are stored internally....
void Isend(const std::vector< int > &vec, int dst, int tag)
MPI_Isend for std::vector. Performs a nonblocking send. Requests are stored internally....
MPI_Status Recv(double val, int src, int tag) const
MPI_Recv for scalar. Performs a blocking recv.
void Gather(std::vector< double > &sendvec, std::vector< double > &recvvec, int root) const
MPI_Gather, Gathers vector from all processes The data is evenly divided and transmitted to each proc...
void Bcast(std::vector< float > &vec, int root) const
MPI_Bcast, Broadcasts a message from the process with rank root to all other processes.
void Gather(monolish::vector< float > &sendvec, monolish::vector< float > &recvvec, int root) const
MPI_Gather, Gathers vector from all processes The data is evenly divided and transmitted to each proc...
void set_comm(MPI_Comm external_comm)
set communicator
size_t Allreduce_prod(size_t val) const
MPI_Allreduce (MPI_PROD) for scalar. Combines values from all processes and distributes the result ba...
void Waitall()
Waits for all communications to complete.
void Isend(float val, int dst, int tag)
MPI_Isend for scalar. Performs a nonblocking send. Requests are stored internally....
void Irecv(double val, int src, int tag)
MPI_Irecv for scalar. Performs a nonblocking recv.
void Bcast(monolish::vector< double > &vec, int root) const
MPI_Bcast, Broadcasts a message from the process with rank root to all other processes.
void Bcast(double &val, int root) const
MPI_Bcast, Broadcasts a message from the process with rank root to all other processes.
double Allreduce_max(double val) const
MPI_Allreduce (MPI_MAX) for scalar. Combines values from all processes and distributes the result bac...
void Isend(size_t val, int dst, int tag)
MPI_Isend for scalar. Performs a nonblocking send. Requests are stored internally....
void Bcast(float &val, int root) const
MPI_Bcast, Broadcasts a message from the process with rank root to all other processes.
int Allreduce_prod(int val) const
MPI_Allreduce (MPI_PROD) for scalar. Combines values from all processes and distributes the result ba...
void Irecv(size_t val, int src, int tag)
MPI_Irecv for scalar. Performs a nonblocking recv.
void Scatter(std::vector< double > &sendvec, std::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...
void Isend(int val, int dst, int tag)
MPI_Isend for scalar. Performs a nonblocking send. Requests are stored internally....
float Allreduce_min(float val) const
MPI_Allreduce (MPI_MIN) for scalar. Combines values from all processes and distributes the result bac...
size_t Allreduce(size_t val) const
MPI_Allreduce (MPI_SUM) for scalar. Combines values from all processes and distributes the result bac...
float Allreduce(float val) const
MPI_Allreduce (MPI_SUM) for scalar. Combines values from all processes and distributes the result bac...
MPI_Status Recv(std::vector< int > &vec, int src, int tag) const
MPI_Recv for std::vector. Performs a blocking recv.
void Isend(const monolish::vector< float > &vec, int dst, int tag)
MPI_Isend for monolish::vector. Performs a nonblocking send. Requests are stored internally....
void Scatter(std::vector< size_t > &sendvec, std::vector< size_t > &recvvec, int root) const
MPI_Scatter, Sends data from one task to all tasks. The data is evenly divided and transmitted to eac...
void Isend(const monolish::vector< double > &vec, int dst, int tag)
MPI_Isend for monolish::vector. Performs a nonblocking send. Requests are stored internally....
static comm & get_instance()
void Send(size_t val, int dst, int tag) const
MPI_Send for scalar. Performs a blocking send.
MPI_Comm my_comm
MPI communicator, MPI_COMM_WORLD.
void Gather(std::vector< int > &sendvec, std::vector< int > &recvvec, int root) const
MPI_Gather, Gathers vector from all processes The data is evenly divided and transmitted to each proc...
void Send(std::vector< double > &vec, int dst, int tag) const
MPI_Send for std::vector. Performs a blocking send.
void Bcast(std::vector< double > &vec, int root) const
MPI_Bcast, Broadcasts a message from the process with rank root to all other processes.
size_t Allreduce_min(size_t val) const
MPI_Allreduce (MPI_MIN) for scalar. Combines values from all processes and distributes the result bac...
MPI_Status Recv(std::vector< size_t > &vec, int src, int tag) const
MPI_Recv for std::vector. Performs a blocking recv.
void Scatter(monolish::vector< float > &sendvec, monolish::vector< float > &recvvec, int root) const
MPI_Scatter, Sends data from one task to all tasks. The data is evenly divided and transmitted to eac...
void Irecv(std::vector< double > &vec, int src, int tag)
MPI_Irecv for std::vector. Performs a nonblocking recv.
void Irecv(int val, int src, int tag)
MPI_Irecv for scalar. Performs a nonblocking recv.
void Bcast(size_t &val, int root) const
MPI_Bcast, Broadcasts a message from the process with rank root to all other processes.
double Allreduce(double val) const
MPI_Allreduce (MPI_SUM) for scalar. Combines values from all processes and distributes the result bac...
void Init(int argc, char **argv)
Initialize the MPI execution environment.
int Allreduce_sum(int val) const
MPI_Allreduce (MPI_SUM) for scalar. Combines values from all processes and distributes the result bac...
void Send(std::vector< float > &vec, int dst, int tag) const
MPI_Send for std::vector. Performs a blocking send.
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...
void Bcast(monolish::vector< float > &vec, int root) const
MPI_Bcast, Broadcasts a message from the process with rank root to all other processes.
void Irecv(std::vector< float > &vec, int src, int tag)
MPI_Irecv for std::vector. Performs a nonblocking recv.
MPI_Status Recv(size_t val, int src, int tag) const
MPI_Recv for scalar. Performs a blocking recv.
double Allreduce_prod(double val) const
MPI_Allreduce (MPI_PROD) for scalar. Combines values from all processes and distributes the result ba...
void Isend(double val, int dst, int tag)
MPI_Isend for scalar. Performs a nonblocking send. Requests are stored internally....
void Send(std::vector< int > &vec, int dst, int tag) const
MPI_Send for std::vector. Performs a blocking send.
double Allreduce_min(double val) const
MPI_Allreduce (MPI_MIN) for scalar. Combines values from all processes and distributes the result bac...
MPI_Status Recv(float val, int src, int tag) const
MPI_Recv for scalar. Performs a blocking recv.
void Irecv(float val, int src, int tag)
MPI_Irecv for scalar. Performs a nonblocking recv.
int Allreduce_max(int val) const
MPI_Allreduce (MPI_MAX) for scalar. Combines values from all processes and distributes the result bac...
void Send(float val, int dst, int tag) const
MPI_Send for scalar. Performs a blocking send.
int Allreduce(int val) const
MPI_Allreduce (MPI_SUM) for scalar. Combines values from all processes and distributes the result bac...
void Bcast(std::vector< size_t > &vec, int root) const
MPI_Bcast, Broadcasts a message from the process with rank root to all other processes.
void Send(monolish::vector< double > &vec, int dst, int tag) const
MPI_Send for monolish::vector. Performs a blocking send.
void Send(int val, int dst, int tag) const
MPI_Send for scalar. Performs a blocking send.
comm(comm &&)=delete
MPI_Status Recv(monolish::vector< double > &vec, int src, int tag) const
MPI_Recv for monolish::vector. Performs a blocking recv.
float Allreduce_max(float val) const
MPI_Allreduce (MPI_MAX) for scalar. Combines values from all processes and distributes the result bac...
void Send(double val, int dst, int tag) const
MPI_Send for scalar. Performs a blocking send.
int get_size()
get the number of processes
void Send(monolish::vector< float > &vec, int dst, int tag) const
MPI_Send for monolish::vector. Performs a blocking send.
int Allreduce_min(int val) const
MPI_Allreduce (MPI_MIN) for scalar. Combines values from all processes and distributes the result bac...
comm(const comm &)=delete
MPI_Comm get_comm() const
get communicator
void Finalize()
Terminates MPI execution environment.
void Send(std::vector< size_t > &vec, int dst, int tag) const
MPI_Send for std::vector. Performs a blocking send.
void Isend(const std::vector< double > &vec, int dst, int tag)
MPI_Isend for std::vector. Performs a nonblocking send. Requests are stored internally....
void Bcast(int &val, int root) const
MPI_Bcast, Broadcasts a message from the process with rank root to all other processes.
size_t Allreduce_max(size_t val) const
MPI_Allreduce (MPI_MAX) for scalar. Combines values from all processes and distributes the result bac...
MPI_Status Recv(int val, int src, int tag) const
MPI_Recv for scalar. Performs a blocking recv.
MPI_Status Recv(std::vector< float > &vec, int src, int tag) const
MPI_Recv for std::vector. Performs a blocking recv.
float Allreduce_prod(float val) const
MPI_Allreduce (MPI_PROD) for scalar. Combines values from all processes and distributes the result ba...
size_t Allreduce_sum(size_t val) const
MPI_Allreduce (MPI_SUM) for scalar. Combines values from all processes and distributes the result bac...
void Scatter(std::vector< int > &sendvec, std::vector< int > &recvvec, int root) const
MPI_Scatter, Sends data from one task to all tasks. The data is evenly divided and transmitted to eac...
std::vector< MPI_Request > requests
double Allreduce_sum(double val) const
MPI_Allreduce (MPI_SUM) for scalar. Combines values from all processes and distributes the result bac...
void Init()
Initialize the MPI execution environment.
comm & operator=(comm &&)=delete
int get_rank()
get my rank number
void Irecv(monolish::vector< float > &vec, int src, int tag)
MPI_Irecv for monolish::vector. Performs a nonblocking recv.
MPI_Status Recv(monolish::vector< float > &vec, int src, int tag) const
MPI_Recv for monolish::vector. Performs a blocking recv.
void Irecv(std::vector< int > &vec, int src, int tag)
MPI_Irecv for std::vector. Performs a nonblocking recv.
void Scatter(std::vector< float > &sendvec, std::vector< float > &recvvec, int root) const
MPI_Scatter, Sends data from one task to all tasks. The data is evenly divided and transmitted to eac...
void Bcast(std::vector< int > &vec, int root) const
MPI_Bcast, Broadcasts a message from the process with rank root to all other processes.
void Gather(std::vector< float > &sendvec, std::vector< float > &recvvec, int root) const
MPI_Gather, Gathers vector from all processes The data is evenly divided and transmitted to each proc...
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...
comm & operator=(const comm &)=delete
MPI_Status Recv(std::vector< double > &vec, int src, int tag) const
MPI_Recv for std::vector. Performs a blocking recv.
float Allreduce_sum(float val) const
MPI_Allreduce (MPI_SUM) for scalar. Combines values from all processes and distributes the result bac...
void Isend(const std::vector< float > &vec, int dst, int tag)
MPI_Isend for std::vector. Performs a nonblocking send. Requests are stored internally....
void Irecv(monolish::vector< double > &vec, int src, int tag)
MPI_Irecv for monolish::vector. Performs a nonblocking recv.
int MPI_Status
Definition: mpi_dummy.hpp:37
struct ompi_communicator_t * MPI_Comm
Definition: mpi_dummy.hpp:40
monolish namespaces