ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
para_mpi_func.h
Go to the documentation of this file.
1#ifndef PARA_MPI_FUNC_H
2#define PARA_MPI_FUNC_H
3
4#include "para_world.h"
5
6#include <complex>
7#include <string>
8
9namespace Parallel
10{
11
12// Domain-aware MPI communication functions.
13// Each function takes the target communication domain (const ParaWorld&)
14// explicitly instead of hardcoding MPI_COMM_WORLD/POOL_WORLD.
15// In serial builds broadcasts and reductions are no-ops; gathers copy locally;
16// invalid/empty domains are safely skipped.
17
18// ========== Broadcast ==========
19
20void bcast_bool(bool& v, const ParaWorld& world, int root = 0);
21void bcast_int(int& v, const ParaWorld& world, int root = 0);
22void bcast_double(double& v, const ParaWorld& world, int root = 0);
23void bcast_complex(std::complex<double>& v, const ParaWorld& world, int root = 0);
24void bcast_string(std::string& s, const ParaWorld& world, int root = 0);
25
26void bcast_int(int* v, int n, const ParaWorld& world, int root = 0);
27void bcast_double(double* v, int n, const ParaWorld& world, int root = 0);
28void bcast_complex(std::complex<double>* v, int n, const ParaWorld& world, int root = 0);
29void bcast_char(char* v, int n, const ParaWorld& world, int root = 0);
30void bcast_string(std::string* v, int n, const ParaWorld& world, int root = 0);
31
32// ========== Reduce (Allreduce, result on all ranks) ==========
33
34void reduce_all(double& v, const ParaWorld& world);
35void reduce_all(int& v, const ParaWorld& world);
36void reduce_all(double* v, int n, const ParaWorld& world);
37
38// ========== Reduce min/max ==========
39
40void reduce_min(double& v, const ParaWorld& world);
41void reduce_max(double& v, const ParaWorld& world);
42void reduce_min(int& v, const ParaWorld& world);
43void reduce_max(int& v, const ParaWorld& world);
44
45// ========== Barrier ==========
46
47void barrier(const ParaWorld& world);
48
49// ========== Gather ==========
50
51void allgather_int(int& v, int* all, const ParaWorld& world);
52
62void allgatherv_double(const double* send, int send_count, double* recv, const int* recv_counts, const int* displs, const ParaWorld& world);
63
64} // namespace Parallel
65
66#endif // PARA_MPI_FUNC_H
Value type describing one MPI communication domain.
Definition para_world.h:28
Definition para_band_output.cpp:11
void bcast_complex(std::complex< double > &v, const ParaWorld &world, int root)
Definition para_mpi_func.cpp:64
void reduce_all(double &v, const ParaWorld &world)
Definition para_mpi_func.cpp:155
void barrier(const ParaWorld &world)
Definition para_mpi_func.cpp:236
void reduce_max(double &v, const ParaWorld &world)
Definition para_mpi_func.cpp:201
void bcast_double(double &v, const ParaWorld &world, int root)
Definition para_mpi_func.cpp:53
void allgatherv_double(const double *send, const int send_count, double *recv, const int *recv_counts, const int *displs, const ParaWorld &world)
Gather variable-sized double buffers onto every rank in the domain.
Definition para_mpi_func.cpp:262
void bcast_char(char *v, int n, const ParaWorld &world, int root)
Definition para_mpi_func.cpp:128
void bcast_bool(bool &v, const ParaWorld &world, int root)
Definition para_mpi_func.cpp:29
void bcast_string(std::string &s, const ParaWorld &world, int root)
Definition para_mpi_func.cpp:75
void allgather_int(int &v, int *all, const ParaWorld &world)
Definition para_mpi_func.cpp:249
void bcast_int(int &v, const ParaWorld &world, int root)
Definition para_mpi_func.cpp:42
void reduce_min(double &v, const ParaWorld &world)
Definition para_mpi_func.cpp:190