Skip to content

Commit 3a8b520

Browse files
committed
update timer
1 parent e79c1d0 commit 3a8b520

File tree

7 files changed

+30
-41
lines changed

7 files changed

+30
-41
lines changed

source/driver_run.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
void Driver::driver_run()
2727
{
2828
ModuleBase::TITLE("Driver", "driver_line");
29-
ModuleBase::timer::tick("Driver", "driver_line");
3029

3130
//! 1: setup cell and atom information
3231
// this warning should not be here, mohan 2024-05-22
@@ -93,6 +92,5 @@ void Driver::driver_run()
9392

9493
//! 6: output the json file
9594
Json::create_Json(&ucell, PARAM);
96-
ModuleBase::timer::tick("Driver", "driver_line");
9795
return;
9896
}

source/module_elecstate/potentials/pot_xc.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ namespace elecstate
1212

1313
void PotXC::cal_v_eff(const Charge*const chg, const UnitCell*const ucell, ModuleBase::matrix& v_eff)
1414
{
15-
ModuleBase::TITLE("PotXC", "cal_v_eff");
16-
ModuleBase::timer::tick("PotXC", "cal_v_eff");
15+
ModuleBase::TITLE("PotXC", "cal_veff");
16+
ModuleBase::timer::tick("PotXC", "cal_veff");
1717
const int nrxx_current = chg->nrxx;
1818

1919
//----------------------------------------------------------
@@ -41,7 +41,7 @@ void PotXC::cal_v_eff(const Charge*const chg, const UnitCell*const ucell, Module
4141
*(this->vtxc_) = std::get<1>(etxc_vtxc_v);
4242
v_eff += std::get<2>(etxc_vtxc_v);
4343
}
44-
ModuleBase::timer::tick("PotXC", "cal_v_eff");
44+
ModuleBase::timer::tick("PotXC", "cal_veff");
4545
}
4646

47-
} // namespace elecstate
47+
} // namespace elecstate

source/module_elecstate/potentials/potential_new.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ void Potential::allocate()
163163
void Potential::update_from_charge(const Charge*const chg, const UnitCell*const ucell)
164164
{
165165
ModuleBase::TITLE("Potential", "update_from_charge");
166-
ModuleBase::timer::tick("Potential", "update_from_charge");
166+
//ModuleBase::timer::tick("Potential", "update_from_charge");
167+
167168
if (!this->fixed_done)
168169
{
169170
this->cal_fixed_v(this->v_effective_fixed.data());
@@ -216,13 +217,14 @@ void Potential::update_from_charge(const Charge*const chg, const UnitCell*const
216217
}
217218
#endif
218219

219-
ModuleBase::timer::tick("Potential", "update_from_charge");
220+
//ModuleBase::timer::tick("Potential", "update_from_charge");
220221
}
221222

222223
void Potential::cal_fixed_v(double* vl_pseudo)
223224
{
224225
ModuleBase::TITLE("Potential", "cal_fixed_v");
225226
ModuleBase::timer::tick("Potential", "cal_fixed_v");
227+
226228
this->v_effective_fixed.assign(this->v_effective_fixed.size(), 0.0);
227229
for (size_t i = 0; i < this->components.size(); i++)
228230
{
@@ -237,10 +239,11 @@ void Potential::cal_fixed_v(double* vl_pseudo)
237239

238240
void Potential::cal_v_eff(const Charge*const chg, const UnitCell*const ucell, ModuleBase::matrix& v_eff)
239241
{
240-
ModuleBase::TITLE("Potential", "cal_v_eff");
242+
ModuleBase::TITLE("Potential", "cal_veff");
243+
ModuleBase::timer::tick("Potential", "cal_veff");
244+
241245
const int nspin_current = this->v_effective.nr;
242246
const int nrxx = this->v_effective.nc;
243-
ModuleBase::timer::tick("Potential", "cal_v_eff");
244247
// first of all, set v_effective to zero.
245248
this->v_effective.zero_out();
246249

@@ -264,7 +267,7 @@ void Potential::cal_v_eff(const Charge*const chg, const UnitCell*const ucell, Mo
264267
}
265268
}
266269

267-
ModuleBase::timer::tick("Potential", "cal_v_eff");
270+
ModuleBase::timer::tick("Potential", "cal_veff");
268271
}
269272

270273
void Potential::init_pot(int istep, const Charge*const chg)
@@ -278,8 +281,6 @@ void Potential::init_pot(int istep, const Charge*const chg)
278281

279282
this->update_from_charge(chg, this->ucell_);
280283

281-
// plots
282-
// figure::picture(this->vr_eff1,GlobalC::rhopw->nx,GlobalC::rhopw->ny,GlobalC::rhopw->nz);
283284
ModuleBase::timer::tick("Potential", "init_pot");
284285
return;
285286
}

source/module_hamilt_pw/hamilt_pwdft/operator_pw/nonlocal_pw.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ void Nonlocal<OperatorPW<T, Device>>::act(
216216
const int ngk_ik,
217217
const bool is_first_node)const
218218
{
219-
ModuleBase::timer::tick("Operator", "NonlocalPW");
219+
ModuleBase::timer::tick("Operator", "nonlocal_pw");
220220
if(is_first_node)
221221
{
222222
setmem_complex_op()(tmhpsi, 0, nbasis*nbands/npol);
@@ -232,9 +232,10 @@ void Nonlocal<OperatorPW<T, Device>>::act(
232232
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
233233
// qianrui optimize 2021-3-31
234234
int nkb = this->ppcell->nkb;
235-
if (this->nkb_m < nbands * nkb) {
236-
resmem_complex_op()(this->becp, nbands * nkb, "Nonlocal<PW>::becp");
237-
}
235+
if (this->nkb_m < nbands * nkb)
236+
{
237+
resmem_complex_op()(this->becp, nbands * nkb, "Nonlocal<PW>::becp");
238+
}
238239
// ModuleBase::ComplexMatrix becp(nbands, nkb, false);
239240
char transa = 'C';
240241
char transb = 'N';
@@ -302,7 +303,7 @@ void Nonlocal<OperatorPW<T, Device>>::act(
302303
delete[] vnlpsi;
303304
#endif
304305
}
305-
ModuleBase::timer::tick("Operator", "NonlocalPW");
306+
ModuleBase::timer::tick("Operator", "nonlocal_pw");
306307
}
307308

308309
template<typename T, typename Device>
@@ -338,4 +339,4 @@ template class Nonlocal<OperatorPW<std::complex<double>, base_device::DEVICE_GPU
338339
// Nonlocal<OperatorPW<std::complex<double>, base_device::DEVICE_GPU>>::Nonlocal(const
339340
// Nonlocal<OperatorPW<std::complex<double>, base_device::DEVICE_GPU>> *nonlocal);
340341
#endif
341-
} // namespace hamilt
342+
} // namespace hamilt

source/module_hamilt_pw/hamilt_pwdft/operator_pw/veff_pw.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void Veff<OperatorPW<T, Device>>::act(
4747
const int ngk_ik,
4848
const bool is_first_node)const
4949
{
50-
ModuleBase::timer::tick("Operator", "VeffPW");
50+
ModuleBase::timer::tick("Operator", "veff_pw");
5151
if(is_first_node)
5252
{
5353
setmem_complex_op()(tmhpsi, 0, nbasis*nbands/npol);
@@ -99,7 +99,7 @@ void Veff<OperatorPW<T, Device>>::act(
9999
#ifdef __DSP
100100
wfcpw->fft_bundle.resource_handler(0);
101101
#endif
102-
ModuleBase::timer::tick("Operator", "VeffPW");
102+
ModuleBase::timer::tick("Operator", "veff_pw");
103103
}
104104

105105
template<typename T, typename Device>

source/module_hsolver/diago_iter_assist.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ void DiagoIterAssist<T, Device>::diagH_subspace(const hamilt::Hamilt<T, Device>*
2828
// of evc, if set to 0, n_band = nstart, default 0
2929
)
3030
{
31-
ModuleBase::TITLE("DiagoIterAssist", "diagH_subspace");
32-
ModuleBase::timer::tick("DiagoIterAssist", "diagH_subspace");
31+
ModuleBase::TITLE("DiagoAssist", "diag_subspace");
32+
ModuleBase::timer::tick("DiagoAssist", "diag_subspace");
3333

3434
// two case:
3535
// 1. pw base: nstart = n_band, psi(nbands * npwx)
@@ -143,7 +143,7 @@ void DiagoIterAssist<T, Device>::diagH_subspace(const hamilt::Hamilt<T, Device>*
143143
delmem_complex_op()(scc);
144144
delmem_complex_op()(vcc);
145145

146-
ModuleBase::timer::tick("DiagoIterAssist", "diagH_subspace");
146+
ModuleBase::timer::tick("DiagoAssist", "diag_subspace");
147147
}
148148

149149
template <typename T, typename Device>
@@ -608,4 +608,4 @@ template class DiagoIterAssist<double, base_device::DEVICE_CPU>;
608608
template class DiagoIterAssist<double, base_device::DEVICE_GPU>;
609609
#endif
610610
#endif
611-
} // namespace hsolver
611+
} // namespace hsolver

source/module_hsolver/hsolver_pw.cpp

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ void HSolverPW<T, Device>::hamiltSolvePsiK(hamilt::Hamilt<T, Device>* hm,
375375
Real* eigenvalue,
376376
const int& nk_nums)
377377
{
378+
ModuleBase::timer::tick("HSolverPW", "solve_psik");
378379
#ifdef __MPI
379380
const diag_comm_info comm_info = {POOL_WORLD, this->rank_in_pool, this->nproc_in_pool};
380381
#else
@@ -421,7 +422,6 @@ void HSolverPW<T, Device>::hamiltSolvePsiK(hamilt::Hamilt<T, Device>* hm,
421422

422423
// wrap the hpsi_func and spsi_func into a lambda function
423424
auto hpsi_func = [hm, cur_nbasis](const ct::Tensor& psi_in, ct::Tensor& hpsi_out) {
424-
ModuleBase::timer::tick("DiagoCG_New", "hpsi_func");
425425
// psi_in should be a 2D tensor:
426426
// psi_in.shape() = [nbands, nbasis]
427427
const auto ndim = psi_in.shape().ndim();
@@ -436,10 +436,8 @@ void HSolverPW<T, Device>::hamiltSolvePsiK(hamilt::Hamilt<T, Device>* hm,
436436
using hpsi_info = typename hamilt::Operator<T, Device>::hpsi_info;
437437
hpsi_info info(&psi_wrapper, all_bands_range, hpsi_out.data<T>());
438438
hm->ops->hPsi(info);
439-
ModuleBase::timer::tick("DiagoCG_New", "hpsi_func");
440439
};
441440
auto spsi_func = [this, hm](const ct::Tensor& psi_in, ct::Tensor& spsi_out) {
442-
ModuleBase::timer::tick("DiagoCG_New", "spsi_func");
443441
// psi_in should be a 2D tensor:
444442
// psi_in.shape() = [nbands, nbasis]
445443
const auto ndim = psi_in.shape().ndim();
@@ -462,17 +460,18 @@ void HSolverPW<T, Device>::hamiltSolvePsiK(hamilt::Hamilt<T, Device>* hm,
462460
static_cast<size_t>((ndim == 1 ? 1 : psi_in.shape().dim_size(0))
463461
* (ndim == 1 ? psi_in.NumElements() : psi_in.shape().dim_size(1))));
464462
}
465-
466-
ModuleBase::timer::tick("DiagoCG_New", "spsi_func");
467463
};
464+
468465
auto psi_tensor = ct::TensorMap(psi.get_pointer(),
469466
ct::DataTypeToEnum<T>::value,
470467
ct::DeviceTypeToEnum<ct_Device>::value,
471468
ct::TensorShape({psi.get_nbands(), psi.get_nbasis()}));
469+
472470
auto eigen_tensor = ct::TensorMap(eigenvalue,
473471
ct::DataTypeToEnum<Real>::value,
474472
ct::DeviceTypeToEnum<ct::DEVICE_CPU>::value,
475473
ct::TensorShape({psi.get_nbands()}));
474+
476475
auto prec_tensor = ct::TensorMap(pre_condition.data(),
477476
ct::DataTypeToEnum<Real>::value,
478477
ct::DeviceTypeToEnum<ct::DEVICE_CPU>::value,
@@ -491,7 +490,6 @@ void HSolverPW<T, Device>::hamiltSolvePsiK(hamilt::Hamilt<T, Device>* hm,
491490
const int ndim = psi.get_current_ngk();
492491
// hpsi_func (X, HX, ld, nvec) -> HX = H(X), X and HX blockvectors of size ld x nvec
493492
auto hpsi_func = [hm, cur_nbasis](T* psi_in, T* hpsi_out, const int ld_psi, const int nvec) {
494-
ModuleBase::timer::tick("diago_bpcg", "hpsi_func");
495493

496494
// Convert "pointer data stucture" to a psi::Psi object
497495
auto psi_iter_wrapper = psi::Psi<T, Device>(psi_in, 1, nvec, ld_psi, cur_nbasis);
@@ -501,8 +499,6 @@ void HSolverPW<T, Device>::hamiltSolvePsiK(hamilt::Hamilt<T, Device>* hm,
501499
using hpsi_info = typename hamilt::Operator<T, Device>::hpsi_info;
502500
hpsi_info info(&psi_iter_wrapper, bands_range, hpsi_out);
503501
hm->ops->hPsi(info);
504-
505-
ModuleBase::timer::tick("diago_bpcg", "hpsi_func");
506502
};
507503
DiagoBPCG<T, Device> bpcg(pre_condition.data());
508504
bpcg.init_iter(PARAM.inp.nbands, nband_l, nbasis, ndim);
@@ -512,7 +508,6 @@ void HSolverPW<T, Device>::hamiltSolvePsiK(hamilt::Hamilt<T, Device>* hm,
512508
{
513509
// hpsi_func (X, HX, ld, nvec) -> HX = H(X), X and HX blockvectors of size ld x nvec
514510
auto hpsi_func = [hm, cur_nbasis](T* psi_in, T* hpsi_out, const int ld_psi, const int nvec) {
515-
ModuleBase::timer::tick("DavSubspace", "hpsi_func");
516511

517512
// Convert "pointer data stucture" to a psi::Psi object
518513
auto psi_iter_wrapper = psi::Psi<T, Device>(psi_in, 1, nvec, ld_psi, cur_nbasis);
@@ -522,8 +517,6 @@ void HSolverPW<T, Device>::hamiltSolvePsiK(hamilt::Hamilt<T, Device>* hm,
522517
using hpsi_info = typename hamilt::Operator<T, Device>::hpsi_info;
523518
hpsi_info info(&psi_iter_wrapper, bands_range, hpsi_out);
524519
hm->ops->hPsi(info);
525-
526-
ModuleBase::timer::tick("DavSubspace", "hpsi_func");
527520
};
528521
bool scf = this->calculation_type == "nscf" ? false : true;
529522

@@ -565,7 +558,6 @@ void HSolverPW<T, Device>::hamiltSolvePsiK(hamilt::Hamilt<T, Device>* hm,
565558
/// wrap hpsi into lambda function, Matrix \times blockvector
566559
// hpsi_func (X, HX, ld, nvec) -> HX = H(X), X and HX blockvectors of size ld x nvec
567560
auto hpsi_func = [hm, cur_nbasis](T* psi_in, T* hpsi_out, const int ld_psi, const int nvec) {
568-
ModuleBase::timer::tick("David", "hpsi_func");
569561

570562
// Convert pointer of psi_in to a psi::Psi object
571563
auto psi_iter_wrapper = psi::Psi<T, Device>(psi_in, 1, nvec, ld_psi, cur_nbasis);
@@ -575,8 +567,6 @@ void HSolverPW<T, Device>::hamiltSolvePsiK(hamilt::Hamilt<T, Device>* hm,
575567
using hpsi_info = typename hamilt::Operator<T, Device>::hpsi_info;
576568
hpsi_info info(&psi_iter_wrapper, bands_range, hpsi_out);
577569
hm->ops->hPsi(info);
578-
579-
ModuleBase::timer::tick("David", "hpsi_func");
580570
};
581571

582572
/// wrap spsi into lambda function, Matrix \times blockvector
@@ -587,11 +577,9 @@ void HSolverPW<T, Device>::hamiltSolvePsiK(hamilt::Hamilt<T, Device>* hm,
587577
const int ld_psi, // Leading dimension of psi and spsi.
588578
const int nvec // Number of vectors(bands)
589579
) {
590-
ModuleBase::timer::tick("David", "spsi_func");
591580
// sPsi determines S=I or not by PARAM.globalv.use_uspp inside
592581
// sPsi(psi, spsi, nrow, npw, nbands)
593582
hm->sPsi(psi_in, spsi_out, ld_psi, ld_psi, nvec);
594-
ModuleBase::timer::tick("David", "spsi_func");
595583
};
596584

597585
DiagoDavid<T, Device> david(pre_condition.data(), nband, dim, PARAM.inp.pw_diag_ndim, this->use_paw, comm_info);
@@ -606,6 +594,7 @@ void HSolverPW<T, Device>::hamiltSolvePsiK(hamilt::Hamilt<T, Device>* hm,
606594
ntry_max,
607595
notconv_max));
608596
}
597+
ModuleBase::timer::tick("HSolverPW", "solve_psik");
609598
return;
610599
}
611600

0 commit comments

Comments
 (0)