Skip to content

Commit b822832

Browse files
committed
add serial code
1 parent 6daf2de commit b822832

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

source/source_lcao/module_gint/temp_gint/gint_common.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ void merge_hr_part_to_hR(const std::vector<hamilt::HContainer<double>>& hRGint_t
8080
int ng = hR->get_paraV()->get_global_col_size()/2;
8181
int nb = hR->get_paraV()->get_block_size()/2;
8282
const UnitCell* ucell_in = gint_info.get_ucell();
83+
auto ijr_info = hR->get_ijr_info();
8384
#ifdef __MPI
8485
int blacs_ctxt = hR->get_paraV()->blacs_ctxt;
8586
std::vector<int> iat2iwt(ucell_in->nat);
@@ -89,10 +90,9 @@ void merge_hr_part_to_hR(const std::vector<hamilt::HContainer<double>>& hRGint_t
8990
Parallel_Orbitals *pv = new Parallel_Orbitals();
9091
pv->set(mg, ng, nb, blacs_ctxt);
9192
pv->set_atomic_trace(iat2iwt.data(), ucell_in->nat, mg);
92-
auto ijr_info = hR->get_ijr_info();
93-
9493
auto* hR_tmp = new hamilt::HContainer<std::complex<double>>(pv, nullptr, &ijr_info);
95-
94+
hR_tmp->set_zero();
95+
#endif
9696
//select hRGint_tmp
9797
std::vector<int> first = {0, 1, 1, 0};
9898
std::vector<int> second= {3, 2, 2, 3};
@@ -104,7 +104,6 @@ void merge_hr_part_to_hR(const std::vector<hamilt::HContainer<double>>& hRGint_t
104104
std::vector<int> clx_j = {0, 1, -1, 0};
105105
for (int is = 0; is < 4; is++){
106106
if(!PARAM.globalv.domag && (is==1 || is==2)) continue;
107-
hR_tmp->set_zero();
108107
hamilt::HContainer<std::complex<double>>* hRGint_tmpCd = new hamilt::HContainer<std::complex<double>>(ucell_in->nat);
109108
hRGint_tmpCd->insert_ijrs(&ijr_info, *ucell_in);
110109
hRGint_tmpCd->allocate(nullptr, true);
@@ -153,9 +152,12 @@ void merge_hr_part_to_hR(const std::vector<hamilt::HContainer<double>>& hRGint_t
153152
}
154153
}
155154
}
156-
155+
#ifdef __MPI
157156
// transfer hRGint_tmpCd to parallel hR_tmp
158157
hamilt::transferSerials2Parallels( *hRGint_tmpCd, hR_tmp);
158+
#else
159+
auto* hR_tmp = hRGint_tmpCd;
160+
#endif
159161
// merge hR_tmp to hR
160162
for (int iap = 0; iap < hR->size_atom_pairs(); iap++)
161163
{
@@ -181,9 +183,6 @@ void merge_hr_part_to_hR(const std::vector<hamilt::HContainer<double>>& hRGint_t
181183
}
182184
delete hRGint_tmpCd;
183185
}
184-
#else
185-
186-
#endif
187186
ModuleBase::timer::tick("Gint_k", "transfer_pvpR");
188187
return;
189188
}
@@ -216,13 +215,14 @@ void transfer_dm_2d_to_gint(
216215
}
217216
} else // NSPIN=4 case
218217
{
219-
#ifdef __MPI
218+
220219
// is=0:↑↑, 1:↑↓, 2:↓↑, 3:↓↓
221220
const int row_set[4] = {0, 0, 1, 1};
222221
const int col_set[4] = {0, 1, 0, 1};
223222
int mg = dm[0]->get_paraV()->get_global_row_size()/2;
224223
int ng = dm[0]->get_paraV()->get_global_col_size()/2;
225224
int nb = dm[0]->get_paraV()->get_block_size()/2;
225+
#ifdef __MPI
226226
int blacs_ctxt = dm[0]->get_paraV()->blacs_ctxt;
227227
const UnitCell* ucell = gint_info.get_ucell();
228228
std::vector<int> iat2iwt(ucell->nat);
@@ -234,6 +234,7 @@ void transfer_dm_2d_to_gint(
234234
pv->set_atomic_trace(iat2iwt.data(), ucell->nat, mg);
235235
auto ijr_info = dm[0]->get_ijr_info();
236236
HContainer<T>* dm2d_tmp = new hamilt::HContainer<T>(pv, nullptr, &ijr_info);
237+
#endif
237238
for (int is = 0; is < 4; is++){
238239
for (int iap = 0; iap < dm[0]->size_atom_pairs(); ++iap) {
239240
auto& ap = dm[0]->get_atom_pair(iap);
@@ -252,11 +253,14 @@ void transfer_dm_2d_to_gint(
252253
}
253254
}
254255
}
256+
#ifdef __MPI
255257
hamilt::transferParallels2Serials( *dm2d_tmp, &dm_gint[is]);
256-
}
257258
#else
258-
//HContainer<T>& dm_full = *(dm[0]);
259+
dm_gint[is].set_zero();
260+
dm_gint[is].add(*dm2d_tmp);
259261
#endif
262+
}
263+
260264
}
261265
ModuleBase::timer::tick("Gint", "transfer_dm_2d_to_gint");
262266
}

source/source_lcao/module_gint/temp_gint/gint_vl_nspin4_gpu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void Gint_vl_nspin4_gpu::cal_gint()
1313
ModuleBase::timer::tick("Gint", "cal_gint_vl");
1414
init_hr_gint_();
1515
cal_hr_gint_();
16-
merge_hr_part_to_hR(hr_gint_part_, *hR_, *gint_info_);
16+
merge_hr_part_to_hR(hr_gint_part_, hR_, *gint_info_);
1717
ModuleBase::timer::tick("Gint", "cal_gint_vl");
1818
}
1919

0 commit comments

Comments
 (0)