Skip to content

Commit

Permalink
optimize LR log
Browse files Browse the repository at this point in the history
  • Loading branch information
maki49 committed Nov 8, 2024
1 parent 33f5bad commit 6225505
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 46 deletions.
67 changes: 24 additions & 43 deletions source/module_base/global_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,28 +153,18 @@ void ModuleBase::Global_File::make_dir_out(
#endif
}

std::stringstream ss,ss1;

// mohan add 2010-09-12
if(out_alllog)
{
ss << "running_" << calculation << "_" << rank + 1;
open_log(GlobalV::ofs_running, ss.str(), calculation, restart);
#if defined(__CUDA) || defined(__ROCM)
open_log(GlobalV::ofs_device, "device" + std::to_string(rank), calculation, restart);
#endif
}
else
{
if(rank==0)
{
ss << "running_" << calculation;
open_log(GlobalV::ofs_running, ss.str(), calculation, restart);
#if defined(__CUDA) || defined(__ROCM)
open_log(GlobalV::ofs_device, "device", calculation, restart);
#endif
}
}
auto open_running_log = [&](const std::string& keyword)
{
std::stringstream ss;
ss << "running_" << keyword;
if (out_alllog) { ss << "_" << rank + 1; }
open_log(GlobalV::ofs_running, ss.str(), keyword, restart);
#if defined(__CUDA) || defined(__ROCM)
open_log(GlobalV::ofs_device, "device" + std::to_string(rank), calculation, restart);
#endif
};
// if linear response solver only, open running_lr.log. else, open running_calculation.log
if (out_alllog || rank == 0) { open_running_log(PARAM.inp.esolver_type == "lr" ? "lr" : calculation); }

if(rank==0)
{
Expand Down Expand Up @@ -242,27 +232,18 @@ void ModuleBase::Global_File::close_all_log(const int rank, const bool out_alllo
// NAME : ofs_build
//----------------------------------------------------------

// mohan update 2011-01-13
std::stringstream ss;
if(out_alllog)
{
ss << "running_" << calculation << "_cpu" << rank << ".log";
close_log(GlobalV::ofs_running,ss.str());
#if defined(__CUDA) || defined(__ROCM)
close_log(GlobalV::ofs_device, "device" + std::to_string(rank));
#endif
}
else
{
if(rank==0)
{
ss << "running_" << calculation << ".log";
close_log(GlobalV::ofs_running,ss.str());
#if defined(__CUDA) || defined(__ROCM)
close_log(GlobalV::ofs_device, "device");
#endif
}
}
auto close_running_log = [&](const std::string& keyword)
{
std::stringstream ss;
ss << "running_" << keyword;
if (out_alllog) { ss << "_" << rank + 1; }
close_log(GlobalV::ofs_running, ss.str());
#if defined(__CUDA) || defined(__ROCM)
close_log(GlobalV::ofs_device, "device" + std::to_string(rank));
#endif
};
// mohan update 2011-01-13
if (out_alllog || rank == 0) { close_running_log(PARAM.inp.esolver_type == "lr" ? "lr" : calculation); }

if (rank==0)
{
Expand Down
5 changes: 2 additions & 3 deletions source/module_lr/esolver_lrtd_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ void LR::ESolver_LR<double>::move_exx_lri(std::shared_ptr<Exx_LRI<std::complex<d
template<>void LR::ESolver_LR<double>::set_gint() { this->gint_ = &this->gint_g_;this->gint_g_.gridt = &this->gt_; }
template<>void LR::ESolver_LR<std::complex<double>>::set_gint() { this->gint_ = &this->gint_k_; this->gint_k_.gridt = &this->gt_; }

inline double getreal(std::complex<double> x) { return x.real(); }
inline double getreal(double x) { return x; }

inline void redirect_log(const bool& out_alllog)
{
GlobalV::ofs_running.close();
Expand Down Expand Up @@ -431,6 +428,7 @@ template <typename T, typename TR>
void LR::ESolver_LR<T, TR>::runner(int istep, UnitCell& cell)
{
ModuleBase::TITLE("ESolver_LR", "runner");
ModuleBase::timer::tick("ESolver_LR", "runner");
//allocate 2-particle state and setup 2d division
this->setup_eigenvectors_X();
this->pelec->ekb.create(nspin, this->nstates);
Expand Down Expand Up @@ -494,6 +492,7 @@ void LR::ESolver_LR<T, TR>::runner(int istep, UnitCell& cell)
for (int is = 0;is < nspin;++is) { read_states(spin_types[is], this->pelec->ekb.c + is * nstates, this->X[is].template data<T>(), nloc_per_band, nstates); }
}
}
ModuleBase::timer::tick("ESolver_LR", "runner");
return;
}

Expand Down

0 comments on commit 6225505

Please sign in to comment.