ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
parallel_kpoints.h
Go to the documentation of this file.
1
5#ifndef PARALLEL_KPOINTS_H
6#define PARALLEL_KPOINTS_H
7
11#include "source_base/vector3.h"
12
17{
18 public:
23
28
39 void kinfo(int& nkstot_in,
40 const int& kpar_in,
41 const int& my_pool_in,
42 const int& rank_in_pool_in,
43 const int& nproc_in,
44 const int& nspin_in);
45
53 void pool_collection(double& value, const double* wk, const int& ik);
54
64 void pool_collection(double* valuea,
65 double* valueb,
66 const ModuleBase::realArray& a,
67 const ModuleBase::realArray& b,
68 const int& ik);
69
77 void pool_collection(std::complex<double>* value, const ModuleBase::ComplexArray& w, const int& ik) const;
78
87 template <class T, class V>
88 void pool_collection_aux(T* value, const V& w, const int& dim, const int& ik) const;
89
90#ifdef __MPI
97 void gatherkvec(const std::vector<ModuleBase::Vector3<double>>& vec_local,
98 std::vector<ModuleBase::Vector3<double>>& vec_global) const;
99#endif
100
102 std::vector<int> nks_pool;
103 std::vector<int> startk_pool;
104 std::vector<int> whichpool;
105
106 int nkstot_np = 0;
107 int nks_np = 0;
108
115 int get_startpro_pool(const int& pool) const
116 {
117 return startpro_pool[pool];
118 }
119
125 {
126 return *std::max_element(nks_pool.begin(), nks_pool.end());
127 }
128
129 public:
130 int kpar = 0;
131 int my_pool = 0;
132 int rank_in_pool = 0;
133 int nproc = 1;
134 int nspin = 1;
135
136 private:
137 std::vector<int> startpro_pool;
138
139#ifdef __MPI
145 void get_nks_pool(const int& nkstot);
146
152 void get_startk_pool(const int& nkstot);
153
159 void get_whichpool(const int& nkstot);
160
164 void set_startpro_pool();
165#endif
166};
167
168#endif
A basic type of data for complex array.
Definition complexarray.h:15
3 elements vector
Definition vector3.h:21
double float array
Definition realarray.h:21
void get_whichpool(const int &nkstot)
Get which pool each k-point belongs to.
Definition parallel_kpoints.cpp:51
void get_nks_pool(const int &nkstot)
Get number of k-points in each pool.
Definition parallel_kpoints.cpp:67
Parallel_Kpoints()
Default constructor.
Definition parallel_kpoints.h:22
~Parallel_Kpoints()
Destructor.
Definition parallel_kpoints.h:27
void pool_collection(double &value, const double *wk, const int &ik)
Collect value from each pool to wk.
Definition parallel_kpoints.cpp:140
void set_startpro_pool()
Set first processor for each pool.
Definition parallel_kpoints.cpp:97
int nspin
number of spins
Definition parallel_kpoints.h:134
std::vector< int > whichpool
whichpool[k]: the pool which k belongs to, dim: nkstot_np
Definition parallel_kpoints.h:104
void kinfo(int &nkstot_in, const int &kpar_in, const int &my_pool_in, const int &rank_in_pool_in, const int &nproc_in, const int &nspin_in)
Initialize k-point parallelization information.
Definition parallel_kpoints.cpp:11
int nkstot_np
number of k-points without spin
Definition parallel_kpoints.h:106
std::vector< int > nks_pool
K-point information.
Definition parallel_kpoints.h:102
int get_startpro_pool(const int &pool) const
Get the first processor in the pool.
Definition parallel_kpoints.h:115
int nks_np
number of k-points without spin in the present pool
Definition parallel_kpoints.h:107
void pool_collection_aux(T *value, const V &w, const int &dim, const int &ik) const
Auxiliary template function for pool collection.
Definition parallel_kpoints.cpp:212
int nproc
number of processors
Definition parallel_kpoints.h:133
std::vector< int > startpro_pool
the first processor in each pool
Definition parallel_kpoints.h:137
int kpar
number of pools
Definition parallel_kpoints.h:130
std::vector< int > startk_pool
the first k-point in each pool (without spin)
Definition parallel_kpoints.h:103
void gatherkvec(const std::vector< ModuleBase::Vector3< double > > &vec_local, std::vector< ModuleBase::Vector3< double > > &vec_global) const
Gather k-points from all processors.
Definition parallel_kpoints.cpp:117
int get_max_nks_pool() const
Get the maximum number of k-points in all pools.
Definition parallel_kpoints.h:124
int my_pool
the pool index of the present processor
Definition parallel_kpoints.h:131
int rank_in_pool
the rank in the present pool
Definition parallel_kpoints.h:132
void get_startk_pool(const int &nkstot)
Get start k-point index for each pool.
Definition parallel_kpoints.cpp:85
#define T
Definition exp.cpp:237