You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
int poolnproc_in, // Number of processors in this pool
42
+
int poolrank_in // Rank in this pool
39
43
);
40
44
41
45
//Init some parameters
42
46
voidinitparameters(
43
47
bool gamma_only_in,
44
48
double pwecut_in, //unit in Ry, ecut to decides plane waves
45
-
int poolnproc_in, // Number of processors in this pool
46
-
int poolrank_in, // Rank in this pool
47
49
int distribution_type_in
48
50
);
49
51
@@ -53,15 +55,15 @@ class PW_Basis
53
55
public:
54
56
//reciprocal-space
55
57
// only on first proc.
56
-
int *startnsz_per; // startnsz_per[ip]: starting is * nz stick in the ip^th proc.
57
-
int *nstnz_per; // nz * nst(number of sticks) on each core.
58
+
int *startnsz_per;//useless // startnsz_per[ip]: starting is * nz stick in the ip^th proc.
59
+
int *nstnz_per;//useless // nz * nst(number of sticks) on each core.
58
60
int *nst_per;// nst on each core
59
61
// on all proc.
60
62
int *ig2isz; // map ig to (is, iz).
61
63
int *istot2bigixy; // istot2bigixy[is]: iy + ix * bigny of is^th stick among all sticks.
62
-
int *ixy2istot; //ixy2istot[ix + iy * nx]: is of stick on (ix, iy) among all sticks.
63
-
int *is2ixy; // is2ixy[is]: ix + iy * bignx of is^th stick among sticks on current proc.
64
-
int *ixy2ip; // ixy2ip[ix + iy * nx]: ip of proc which contains stick on (ix, iy).
64
+
int *ixy2istot; //useless // ixy2istot[iy + ix * ny]: is of stick on (ix, iy) among all sticks.
65
+
int *is2ixy; // is2ixy[is]: iy + ix * bigny of is^th stick among sticks on current proc.
66
+
int *ixy2ip; //useless// ixy2ip[iy + ix * ny]: ip of proc which contains stick on (ix, iy).
65
67
int nst; //num. of sticks in current proc.
66
68
int nstnz; // nst * nz
67
69
int nstot; //num. of sticks in total.
@@ -91,13 +93,12 @@ class PW_Basis
91
93
//distribute real-space grids to different processors
92
94
voiddistribute_r();
93
95
96
+
//prepare for MPI_Alltoall
94
97
voidgetstartgr();
95
98
96
-
//distribute plane waves to different processors
97
-
voiddistribution_method1(); // x varies fast
98
-
voiddistribution_method2(); // sticks sorted according to ixy
99
-
// void distribution_method3(); // y varies fast
100
99
100
+
101
+
//prepare for transforms between real and reciprocal spaces
101
102
voidcollect_local_pw();
102
103
103
104
// void collect_tot_pw(
@@ -118,64 +119,56 @@ class PW_Basis
118
119
int distribution_type;
119
120
int poolnproc;
120
121
int poolrank;
121
-
122
+
//distribute plane waves to different processors
123
+
124
+
//method 1: first consider number of plane waves
125
+
voiddistribution_method1();
126
+
// Distribute sticks to cores in method 1.
127
+
voiddivide_sticks_1(
128
+
int* st_i, // x or x + nx (if x < 0) of stick.
129
+
int* st_j, // y or y + ny (if y < 0) of stick.
130
+
int* st_length, // the stick on (ix, iy) consists of st_length[ix*ny+iy] planewaves.
131
+
int* npw_per // number of planewaves on each core.
132
+
);
122
133
123
-
// for both distributeg_method1 and distributeg_method2
134
+
//method 2: first consider number of sticks
135
+
voiddistribution_method2();
136
+
// Distribute sticks to cores in method 2.
137
+
voiddivide_sticks_2();
138
+
139
+
//Count the total number of planewaves (tot_npw) and sticks (this->nstot) (in distributeg method1 and method2)
124
140
voidcount_pw_st(
125
141
int &tot_npw, // total number of planewaves.
126
142
int* st_length2D, // the number of planewaves that belong to the stick located on (x, y).
127
143
int* st_bottom2D // the z-coordinate of the bottom of stick on (x, y).
128
144
);
145
+
146
+
//get ig2isz and is2ixy
129
147
voidget_ig2isz_is2ixy(
130
148
int* st_bottom, // minimum z of stick, stored in 1d array with tot_nst elements.
131
149
int* st_length // the stick on (x, y) consists of st_length[x*ny+y] planewaves.
132
150
);
133
-
// for distributeg_method1
151
+
152
+
//Collect the x, y indexs, length of the sticks (in distributeg method1)
134
153
voidcollect_st(
135
154
int* st_length2D, // the number of planewaves that belong to the stick located on (x, y), stored in 2d x-y plane.
136
155
int* st_bottom2D, // the z-coordinate of the bottom of stick on (x, y), stored in 2d x-y plane.
137
156
int* st_i, // x or x + nx (if x < 0) of stick.
138
157
int* st_j, // y or y + ny (if y < 0) of stick.
139
158
int* st_length // number of planewaves in stick, stored in 1d array with tot_nst elements.
140
159
);
141
-
voiddivide_sticks(
142
-
int* st_i, // x or x + nx (if x < 0) of stick.
143
-
int* st_j, // y or y + ny (if y < 0) of stick.
144
-
int* st_length, // the stick on (x, y) consists of st_length[x*ny+y] planewaves.
145
-
int* npw_per // number of planewaves on each core.
146
-
);
160
+
161
+
//get istot2bigixy
147
162
voidget_istot2bigixy(
148
163
int* st_i, // x or x + nx (if x < 0) of stick.
149
164
int* st_j // y or y + ny (if y < 0) of stick.
150
165
);
151
-
// for distributeg_method2
152
-
voiddivide_sticks2();
166
+
167
+
//Create the maps from ixy to (in method 2)
153
168
voidcreate_maps(
154
169
int* st_length2D, // the number of planewaves that belong to the stick located on (x, y), stored in 2d x-y plane.
155
170
int* npw_per // number of planewaves on each core.
156
171
);
157
-
// for distributeg_method3
158
-
// void divide_sticks2(
159
-
// const int tot_npw, // total number of planewaves.
160
-
// int* st_i, // x or x + nx (if x < 0) of stick.
161
-
// int* st_j, // y or y + ny (if y < 0) of stick.
162
-
// int* st_length, // the stick on (x, y) consists of st_length[x*ny+y] planewaves.
163
-
// int* npw_per, // number of planewaves on each core.
164
-
// int* nst_per, // number of sticks on each core.
165
-
// int* is2ip // ip of core containing is^th stick, map is to ip.
166
-
// );
167
-
// void get_istot2ixy2(
168
-
// int* st_i, // x or x + nx (if x < 0) of stick.
169
-
// int* st_j, // y or y + ny (if y < 0) of stick.
170
-
// int* is2ip // ip of core containing is^th stick, map is to ip.
171
-
// );
172
-
// void get_ig2isz_is2ixy2(
173
-
// int* st_i, // x or x + nx (if x < 0) of stick.
174
-
// int* st_j, // y or y + ny (if y < 0) of stick.
175
-
// int* st_bottom, // minimum z of stick, stored in 1d array with tot_nst elements.
176
-
// int* st_length, // the stick on (x, y) consists of st_length[x*ny+y] planewaves.
177
-
// int* is2ip // ip of core containing is^th stick, map is to ip.
178
-
// );
179
172
180
173
//===============================================
181
174
// FFT
@@ -199,16 +192,14 @@ class PW_Basis
199
192
voidrecip2real(std::complex<float> * in, float *out); //in:(nz, ns) ; out(nplane,nx*ny)
200
193
voidrecip2real(std::complex<float> * in, std::complex<float> * out); //in:(nz, ns) ; out(nplane,nx*ny)
201
194
#endif
195
+
//gather planes and scatter sticks of all processors
202
196
template<typename T>
203
-
voidgatherp_scatters(std::complex<T> *in, std::complex<T> *out); //gather planes and scatter sticks of all processors
204
-
template<typename T>
205
-
voidgathers_scatterp(std::complex<T> *in, std::complex<T> *out); //gather sticks of and scatter planes of all processors
206
-
// void gathers_scatterp2(std::complex<double> *in, std::complex<double> *out); //gather sticks of and scatter planes of all processors
207
-
// void gatherp_scatters2(std::complex<double> *in, std::complex<double> *out); //gather sticks of and scatter planes of all processors
208
-
// void gatherp_scatters_gamma(std::complex<double> *in, std::complex<double> *out); //gather planes and scatter sticks of all processors, used when gamma_only
209
-
// void gathers_scatterp_gamma(std::complex<double> *in, std::complex<double> *out); //gather sticks of and scatter planes of all processors, used when gamma only
0 commit comments