Skip to content

Commit 67d93e7

Browse files
committed
improve the serial code
1 parent 0af862e commit 67d93e7

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

source/module_hamilt_lcao/module_gint/gint.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,15 @@ void Gint::transfer_DM2DtoGrid(std::vector<hamilt::HContainer<double>*> DM2D) {
247247
}
248248
} else // NSPIN=4 case
249249
{
250-
#ifdef __MPI
250+
251251
// is=0:↑↑, 1:↑↓, 2:↓↑, 3:↓↓
252252
const int row_set[4] = {0, 0, 1, 1};
253253
const int col_set[4] = {0, 1, 0, 1};
254254
int mg = DM2D[0]->get_paraV()->get_global_row_size()/2;
255255
int ng = DM2D[0]->get_paraV()->get_global_col_size()/2;
256256
int nb = DM2D[0]->get_paraV()->get_block_size()/2;
257+
#ifdef __MPI
257258
int blacs_ctxt = DM2D[0]->get_paraV()->blacs_ctxt;
258-
259259
std::vector<int> iat2iwt(ucell->nat);
260260
for (int iat = 0; iat < ucell->nat; iat++) {
261261
iat2iwt[iat] = ucell->get_iat2iwt()[iat]/2;
@@ -266,6 +266,7 @@ void Gint::transfer_DM2DtoGrid(std::vector<hamilt::HContainer<double>*> DM2D) {
266266
auto ijr_info = DM2D[0]->get_ijr_info();
267267
this-> DM2D_tmp = new hamilt::HContainer<double>(pv, nullptr, &ijr_info);
268268
this-> DM2D_tmp->set_zero();
269+
#endif
269270
ModuleBase::Memory::record("Gint::DM2D_tmp", this->DM2D_tmp->get_memory_size());
270271
for (int is = 0; is < 4; is++){
271272
for (int iap = 0; iap < DM2D[0]->size_atom_pairs(); ++iap) {
@@ -285,11 +286,14 @@ void Gint::transfer_DM2DtoGrid(std::vector<hamilt::HContainer<double>*> DM2D) {
285286
}
286287
}
287288
}
289+
#ifdef __MPI
288290
hamilt::transferParallels2Serials( *(this->DM2D_tmp), this->DMRGint[is]);
289-
}
290291
#else
291-
//this->DMRGint_full = DM2D[0];
292+
this->DMRGint[is]->set_zero();
293+
this->DMRGint[is]->add(*(this->DM2D_tmp));
292294
#endif
295+
}
296+
293297
}
294298
ModuleBase::timer::tick("Gint", "transfer_DMR");
295299
}

source/module_hamilt_lcao/module_gint/gint_k_pvpr.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,12 @@ void Gint_k::transfer_pvpR(hamilt::HContainer<std::complex<double>>* hR,
7878
ModuleBase::TITLE("Gint_k", "transfer_pvpR");
7979
ModuleBase::timer::tick("Gint_k", "transfer_pvpR");
8080

81+
auto ijr_info = hR->get_ijr_info();
82+
83+
#ifdef __MPI
8184
int mg = hR->get_paraV()->get_global_row_size()/2;
8285
int ng = hR->get_paraV()->get_global_col_size()/2;
8386
int nb = hR->get_paraV()->get_block_size()/2;
84-
#ifdef __MPI
8587
int blacs_ctxt = hR->get_paraV()->blacs_ctxt;
8688
std::vector<int> iat2iwt(ucell_in->nat);
8789
for (int iat = 0; iat < ucell_in->nat; iat++) {
@@ -90,9 +92,9 @@ void Gint_k::transfer_pvpR(hamilt::HContainer<std::complex<double>>* hR,
9092
Parallel_Orbitals *pv = new Parallel_Orbitals();
9193
pv->set(mg, ng, nb, blacs_ctxt);
9294
pv->set_atomic_trace(iat2iwt.data(), ucell_in->nat, mg);
93-
auto ijr_info = hR->get_ijr_info();
94-
9595
this->hR_tmp = new hamilt::HContainer<std::complex<double>>(pv, nullptr, &ijr_info);
96+
#endif
97+
9698
ModuleBase::Memory::record("Gint::hRGintCd", this->hR_tmp->get_memory_size());
9799

98100
//select hRGint_tmp
@@ -155,8 +157,12 @@ void Gint_k::transfer_pvpR(hamilt::HContainer<std::complex<double>>* hR,
155157
}
156158
}
157159
}
160+
#ifdef __MPI
158161
// transfer hRGint_tmpCd to parallel hR_tmp
159162
hamilt::transferSerials2Parallels( *hRGint_tmpCd, this->hR_tmp);
163+
#else
164+
this->hR_tmp = hRGint_tmpCd;
165+
#endif
160166
// merge hR_tmp to hR
161167
for (int iap = 0; iap < hR->size_atom_pairs(); iap++)
162168
{
@@ -182,10 +188,6 @@ void Gint_k::transfer_pvpR(hamilt::HContainer<std::complex<double>>* hR,
182188
}
183189
delete hRGint_tmpCd;
184190
}
185-
delete[] iat2iwt;
186-
#else
187-
188-
#endif
189191
ModuleBase::timer::tick("Gint_k", "transfer_pvpR");
190192
return;
191193
}

0 commit comments

Comments
 (0)