Skip to content

Commit 6f7b540

Browse files
committed
change istot2ixy to istot2bigixy
1 parent 4bcbf5b commit 6f7b540

File tree

8 files changed

+55
-150
lines changed

8 files changed

+55
-150
lines changed

source/module_pw/pw_basis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace ModulePW
88
PW_Basis::PW_Basis()
99
{
1010
ig2isz = NULL;
11-
istot2ixy = NULL;
11+
istot2bigixy = NULL;
1212
ixy2istot = NULL;
1313
is2ixy = NULL;
1414
ixy2ip = NULL;
@@ -31,7 +31,7 @@ PW_Basis::PW_Basis()
3131
PW_Basis:: ~PW_Basis()
3232
{
3333
if(ig2isz != NULL) delete[] ig2isz;
34-
if(istot2ixy != NULL) delete[] istot2ixy;
34+
if(istot2bigixy != NULL) delete[] istot2bigixy;
3535
if(ixy2istot != NULL) delete[] ixy2istot;
3636
if(is2ixy != NULL) delete[] is2ixy;
3737
if(ixy2ip != NULL) delete[] ixy2ip;

source/module_pw/pw_basis.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class PW_Basis
5858
int *nst_per;// nst on each core
5959
// on all proc.
6060
int *ig2isz; // map ig to (is, iz).
61-
int *istot2ixy; // istot2ixy[is]: ix + iy * nx of is^th stick among all sticks.
61+
int *istot2bigixy; // istot2bigixy[is]: iy + ix * bigny of is^th stick among all sticks.
6262
int *ixy2istot; // ixy2istot[ix + iy * nx]: is of stick on (ix, iy) among all sticks.
6363
int *is2ixy; // is2ixy[is]: ix + iy * bignx of is^th stick among sticks on current proc.
6464
int *ixy2ip; // ixy2ip[ix + iy * nx]: ip of proc which contains stick on (ix, iy).
@@ -144,14 +144,12 @@ class PW_Basis
144144
int* st_length, // the stick on (x, y) consists of st_length[x*ny+y] planewaves.
145145
int* npw_per // number of planewaves on each core.
146146
);
147-
void get_istot2ixy(
147+
void get_istot2bigixy(
148148
int* st_i, // x or x + nx (if x < 0) of stick.
149149
int* st_j // y or y + ny (if y < 0) of stick.
150150
);
151151
// for distributeg_method2
152-
void divide_sticks2(
153-
int* nst_per // number of sticks on each core.
154-
);
152+
void divide_sticks2();
155153
void create_maps(
156154
int* st_length2D, // the number of planewaves that belong to the stick located on (x, y), stored in 2d x-y plane.
157155
int* npw_per // number of planewaves on each core.
@@ -196,8 +194,8 @@ class PW_Basis
196194

197195
void gatherp_scatters(std::complex<double> *in, std::complex<double> *out); //gather planes and scatter sticks of all processors
198196
void gathers_scatterp(std::complex<double> *in, std::complex<double> *out); //gather sticks of and scatter planes of all processors
199-
void gathers_scatterp2(std::complex<double> *in, std::complex<double> *out); //gather sticks of and scatter planes of all processors
200-
void gatherp_scatters2(std::complex<double> *in, std::complex<double> *out); //gather sticks of and scatter planes of all processors
197+
// void gathers_scatterp2(std::complex<double> *in, std::complex<double> *out); //gather sticks of and scatter planes of all processors
198+
// void gatherp_scatters2(std::complex<double> *in, std::complex<double> *out); //gather sticks of and scatter planes of all processors
201199
void gatherp_scatters_gamma(std::complex<double> *in, std::complex<double> *out); //gather planes and scatter sticks of all processors, used when gamma_only
202200
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
203201

source/module_pw/pw_distributeg_method1.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace ModulePW
2020
//
2121
// Secondly, distribute these sticks to coreors.
2222
//Known: G, GT, GGT, ny, nx, nz, poolnproc, poolrank, ggecut
23-
//output: ig2isz[ig], istot2ixy[is], ixy2istot[nxy], is2ixy[is], ixy2ip[ixy], startnsz_per[ip], nst_per[ip], nst
23+
//output: ig2isz[ig], istot2bigixy[is], ixy2istot[nxy], is2ixy[is], ixy2ip[ixy], startnsz_per[ip], nst_per[ip], nst
2424
//
2525
void PW_Basis::distribution_method1()
2626
{
@@ -95,7 +95,7 @@ void PW_Basis::distribution_method1()
9595
std::cout << std::endl;
9696
// --------------------------------------------------------------------------------------
9797

98-
this->get_istot2ixy(st_i, st_j);
98+
this->get_istot2bigixy(st_i, st_j);
9999
delete[] st_i;
100100
delete[] st_j;
101101
// for test -----------------------------------------------------------------------------
@@ -124,15 +124,15 @@ void PW_Basis::distribution_method1()
124124
this->startnsz_per[0] = 0;
125125

126126
this->ixy2istot = new int[nxy];
127-
this->istot2ixy = new int[this->nstot];
127+
this->istot2bigixy = new int[this->nstot];
128128
this->ixy2ip = new int[nxy]; // ip of core which contains stick on (x, y).
129129
int st_move = 0;
130130
for (int ixy = 0; ixy < nxy; ++ixy)
131131
{
132132
if (st_length2D[ixy] > 0)
133133
{
134134
this->ixy2istot[ixy] = st_move;
135-
this->istot2ixy[st_move] = ixy;
135+
this->istot2bigixy[st_move] = ixy / ny * bigny + ixy % ny;
136136
this->ixy2ip[ixy] = 0;
137137
st_move++;
138138
}
@@ -162,13 +162,13 @@ void PW_Basis::distribution_method1()
162162
st_length2D = new int[this->nxy]; // number of planewaves in stick.
163163
this->ixy2ip = new int[this->nxy]; // ip of core which contains stick on (x, y).
164164
this->ixy2istot = new int[this->nxy];
165-
this->istot2ixy = new int[this->nstot];
165+
this->istot2bigixy = new int[this->nstot];
166166
}
167167

168168
MPI_Bcast(st_length2D, this->nxy, MPI_INT, 0, POOL_WORLD);
169169
MPI_Bcast(st_bottom2D, this->nxy, MPI_INT, 0, POOL_WORLD);
170170
MPI_Bcast(this->ixy2ip, this->nxy, MPI_INT, 0, POOL_WORLD);
171-
MPI_Bcast(this->istot2ixy, this->nstot, MPI_INT, 0, POOL_WORLD);
171+
MPI_Bcast(this->istot2bigixy, this->nstot, MPI_INT, 0, POOL_WORLD);
172172
MPI_Bcast(this->ixy2istot, this->nxy, MPI_INT, 0, POOL_WORLD);
173173
MPI_Bcast(this->nst_per, this->poolnproc, MPI_INT, 0 , POOL_WORLD);
174174

@@ -362,33 +362,33 @@ void PW_Basis::divide_sticks(
362362
//
363363
// (3-2) Rearrange sticks in the order of the ip of core increasing, in each core, sticks are sorted in the order of ixy increasing.
364364
// (st_start + st_move) is the new index of sticks.
365-
// Then get istot2ixy (istot2ixy[is]: iy + ix * ny of is^th stick among all sticks) on the first core
365+
// Then get istot2bigixy (istot2bigixy[is]: iy + ix * ny of is^th stick among all sticks) on the first core
366366
// and ixy2istot (ixy2istot[iy + ix * ny]: is of stick on (iy, ix) among all sticks).
367367
// known: this->nstot, st_i, st_j, this->startnsz_per
368-
// output: istot2ixy, ixy2istot
368+
// output: istot2bigixy, ixy2istot
369369
//
370-
void PW_Basis::get_istot2ixy(
370+
void PW_Basis::get_istot2bigixy(
371371
int* st_i, // x or x + nx (if x < 0) of stick.
372372
int* st_j // y or y + ny (if y < 0) of stick.
373373
)
374374
{
375375
assert(this->poolrank == 0);
376376
this->ixy2istot = new int[this->nx * this->ny];
377-
this->istot2ixy = new int[this->nstot];
377+
this->istot2bigixy = new int[this->nstot];
378378
int* st_move = new int[this->poolnproc]; // st_move[ip]: this is the st_move^th stick on ip^th core.
379379
for (int ixy = 0; ixy < this->nx * this->ny; ++ixy)
380380
{
381381
this->ixy2istot[ixy] = -1;
382382
}
383-
ModuleBase::GlobalFunc::ZEROS(this->istot2ixy, this->nstot);
383+
ModuleBase::GlobalFunc::ZEROS(this->istot2bigixy, this->nstot);
384384
ModuleBase::GlobalFunc::ZEROS(st_move, this->poolnproc);
385385

386386
for (int ixy = 0; ixy < this->nxy; ++ixy)
387387
{
388388
int ip = this->ixy2ip[ixy];
389389
if (ip != -1)
390390
{
391-
this->istot2ixy[this->startnsz_per[ip] / this->nz + st_move[ip]] = ixy;
391+
this->istot2bigixy[this->startnsz_per[ip] / this->nz + st_move[ip]] = (ixy / ny)*bigny + ixy % ny;
392392
this->ixy2istot[ixy] = this->startnsz_per[ip] / this->nz + st_move[ip];
393393
st_move[ip]++;
394394
}

source/module_pw/pw_distributeg_method2.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace ModulePW
1919
// ip 0 1 ...
2020
//
2121
//Known: G, GT, GGT, ny, nx, nz, poolnproc, poolrank, ggecut
22-
//output: ig2isz[ig], istot2ixy[is], ixy2istot[nxy], is2ixy[is], ixy2ip[ixy], startnsz_per[ip], nst_per[ip], nst
22+
//output: ig2isz[ig], istot2bigixy[is], ixy2istot[nxy], is2ixy[is], ixy2ip[ixy], startnsz_per[ip], nst_per[ip], nst
2323
//
2424
void PW_Basis::distribution_method2()
2525
{
@@ -31,6 +31,7 @@ void PW_Basis::distribution_method2()
3131
int *st_bottom2D = NULL; // st_bottom2D[ixy], minimum z of stick on (x, y).
3232
int *st_length2D = NULL; // st_length2D[ixy], number of planewaves in stick on (x, y).
3333

34+
this->nst_per = new int[this->poolnproc]; // number of sticks on each core.
3435
if (poolrank == 0)
3536
{
3637
// (1) Count the total number of planewaves (tot_npw) and sticks (this->nstot).
@@ -60,9 +61,8 @@ void PW_Basis::distribution_method2()
6061

6162
// (2) Devide the sticks to each core, sticks are in the order of ixy increasing.
6263

63-
int *nst_per = new int[this->poolnproc]; // number of sticks on each core.
6464
ModuleBase::GlobalFunc::ZEROS(nst_per, this->poolnproc);
65-
this->divide_sticks2(nst_per);
65+
this->divide_sticks2();
6666
// for test ----------------------------------------------------------------------------
6767
std::cout << "nst_per ";
6868
for (int ip = 0; ip < this->poolnproc; ++ip) std::cout << nst_per[ip] << std::setw(4);
@@ -92,7 +92,6 @@ void PW_Basis::distribution_method2()
9292
}
9393
#endif
9494
delete[] npw_per;
95-
delete[] nst_per;
9695
}
9796
else
9897
{
@@ -106,19 +105,20 @@ void PW_Basis::distribution_method2()
106105
#ifdef __MPI
107106
MPI_Bcast(&tot_npw, 1, MPI_INT, 0, POOL_WORLD);
108107
MPI_Bcast(&this->nstot, 1, MPI_INT, 0, POOL_WORLD);
108+
MPI_Bcast(this->nst_per, this->poolnproc, MPI_INT, 0 , POOL_WORLD);
109109
if (this->poolrank != 0)
110110
{
111111
st_bottom2D = new int[this->nxy]; // minimum z of stick.
112112
st_length2D = new int[this->nxy]; // number of planewaves in stick.
113113
this->ixy2ip = new int[this->nxy]; // ip of core which contains stick on (x, y).
114114
this->ixy2istot = new int[this->nxy];
115-
this->istot2ixy = new int[this->nstot];
115+
this->istot2bigixy = new int[this->nstot];
116116
}
117117

118118
MPI_Bcast(st_length2D, this->nxy, MPI_INT, 0, POOL_WORLD);
119119
MPI_Bcast(st_bottom2D, this->nxy, MPI_INT, 0, POOL_WORLD);
120120
MPI_Bcast(this->ixy2ip, this->nxy, MPI_INT, 0, POOL_WORLD);
121-
MPI_Bcast(this->istot2ixy, this->nstot, MPI_INT, 0, POOL_WORLD);
121+
MPI_Bcast(this->istot2bigixy, this->nstot, MPI_INT, 0, POOL_WORLD);
122122
MPI_Bcast(this->ixy2istot, this->nxy, MPI_INT, 0, POOL_WORLD);
123123

124124
std::cout << "Bcast done\n";
@@ -142,9 +142,7 @@ void PW_Basis::distribution_method2()
142142
// known: this->nstot, this->poolnproc
143143
// output: nst_per, this->nstnz_per, this->startnsz_per
144144
//
145-
void PW_Basis::divide_sticks2(
146-
int* nst_per // number of sticks on each core.
147-
)
145+
void PW_Basis::divide_sticks2()
148146
{
149147
this->nstnz_per = new int[this->poolnproc]; // nz * nst(number of sticks) on each core.
150148
this->startnsz_per = new int[this->poolnproc];
@@ -165,7 +163,7 @@ void PW_Basis::divide_sticks2(
165163
//
166164
// (3) Create the maps from ixy to ip, istot, and from istot to ixy, and construt npw_per simultaneously.
167165
// known: st_length2D
168-
// output: this->ixy2ip, this->ixy2istot, this->istot2ixy, npw_per
166+
// output: this->ixy2ip, this->ixy2istot, this->istot2bigixy, npw_per
169167
//
170168
void PW_Basis::create_maps(
171169
int* st_length2D, // the number of planewaves that belong to the stick located on (x, y), stored in 2d x-y plane.
@@ -174,17 +172,17 @@ void PW_Basis::create_maps(
174172
{
175173
this->ixy2ip = new int[this->nxy];
176174
this->ixy2istot = new int[this->nxy];
177-
this->istot2ixy = new int[this->nstot];
175+
this->istot2bigixy = new int[this->nstot];
178176

179-
ModuleBase::GlobalFunc::ZEROS(this->istot2ixy, this->nstot);
177+
ModuleBase::GlobalFunc::ZEROS(this->istot2bigixy, this->nstot);
180178
int ip = 0;
181179
int st_move = 0; // the number of sticks that have been found.
182180
for (int ixy = 0; ixy < this->nxy; ++ixy)
183181
{
184182
if (st_length2D[ixy] > 0)
185183
{
186184
this->ixy2istot[ixy] = st_move;
187-
this->istot2ixy[st_move] = ixy;
185+
this->istot2bigixy[st_move] = ixy / ny * bigny + ixy % ny;
188186
this->ixy2ip[ixy] = ip;
189187
npw_per[ip] += st_length2D[ixy];
190188
st_move++;

0 commit comments

Comments
 (0)