Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions source/source_base/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ namespace ModuleBase
// 1024 Byte = 1 KB
// 1024 KB = 1 MB
// 1024 MB = 1 GB

const double memory_warning_threshold_mb = 20.0;

double Memory::total = 0.0;
int Memory::complex_matrix_memory = 2*sizeof(double); // 16 byte
int Memory::double_memory = sizeof(double); // 8 byte
Expand Down Expand Up @@ -149,9 +152,9 @@ double Memory::record

consume[find] = Memory::calculate_mem(n_in,type);

if(consume[find] > 5)
if(consume[find] > memory_warning_threshold_mb)
{
print(find);
print(name[find], consume[find]);
}
return consume[find];
}
Expand Down Expand Up @@ -211,9 +214,9 @@ void Memory::record
{
Memory::total += size_mb - consume[find];
consume[find] = size_mb;
if(consume[find] > 5)
if(consume[find] > memory_warning_threshold_mb)
{
print(find);
print(name[find], consume[find]);
}
}
}
Expand Down Expand Up @@ -268,9 +271,9 @@ double Memory::record_gpu

consume_gpu[find] = Memory::calculate_mem(n_in,type);

if(consume_gpu[find] > 5)
if(consume_gpu[find] > memory_warning_threshold_mb)
{
print(find);
print(name_gpu[find], consume_gpu[find]);
}
return consume_gpu[find];
}
Expand Down Expand Up @@ -330,9 +333,9 @@ void Memory::record_gpu
{
Memory::total_gpu += size_mb - consume_gpu[find];
consume_gpu[find] = size_mb;
if(consume_gpu[find] > 5)
if(consume_gpu[find] > memory_warning_threshold_mb)
{
print(find);
print(name_gpu[find], consume_gpu[find]);
}
}
}
Expand All @@ -341,10 +344,10 @@ void Memory::record_gpu

#endif

void Memory::print(const int find)
void Memory::print(const std::string& mem_name, double size_mb)
{
GlobalV::ofs_running <<"\n Warning_Memory_Consuming allocated: "
<<" "<<name[find]<<" "<<consume[find]<<" MB" << std::endl;
GlobalV::ofs_running <<"\n *** Memory Allocation Warning *** "
<<" "<< mem_name <<" "<< size_mb <<" MB" << std::endl;
return;
}

Expand Down
2 changes: 1 addition & 1 deletion source/source_base/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class Memory
*/
static void print_all(std::ofstream &ofs);

static void print(const int find_in);
static void print(const std::string& name, double size_mb);

/**
* @brief Calculate memory requirements for various
Expand Down
4 changes: 3 additions & 1 deletion source/source_cell/cal_atoms_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define CAL_ATOMS_INFO_H
#include "source_io/module_parameter/parameter.h"
#include "source_estate/cal_nelec_nband.h"
#include "source_base/global_function.h"
class CalAtomsInfo
{
public:
Expand All @@ -27,7 +28,8 @@ class CalAtomsInfo
para.input.nupdown += atoms[it].mag[ia];
}
}
GlobalV::ofs_running << " The readin total magnetization is " << para.inp.nupdown << std::endl;
GlobalV::ofs_running << std::endl;
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "The readin total magnetization", para.inp.nupdown);
}


Expand Down
2 changes: 1 addition & 1 deletion source/source_cell/setup_nonlocal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ void InfoNonlocal::Set_NonLocal(const int& it,

delete[] tmpBeta_lm;

log << " SET NONLOCAL PSEUDOPOTENTIAL PROJECTORS" << std::endl;
log << " SET NONLOCAL PSEUDOPOTENTIAL PROJECTORS FOR ELEMENT " << atom->label << std::endl;
return;
}

Expand Down
5 changes: 4 additions & 1 deletion source/source_estate/module_charge/charge_init.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <vector>
#include <algorithm>

#include "charge.h"
#include "source_base/global_function.h"
Expand Down Expand Up @@ -32,7 +33,9 @@ void Charge::init_rho(const UnitCell& ucell,
const int nspin = PARAM.inp.nspin;
assert(nspin>0);

std::cout << " START CHARGE : " << PARAM.inp.init_chg << std::endl;
std::string init_chg_upper = PARAM.inp.init_chg;
std::transform(init_chg_upper.begin(), init_chg_upper.end(), init_chg_upper.begin(), ::toupper);
std::cout << " START CHARGE : " << init_chg_upper << std::endl;

// we need to set the omega for the charge density
set_omega(&ucell.omega);
Expand Down
1 change: 1 addition & 0 deletions source/source_estate/read_pseudo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ void read_cell_pseudopots(const std::string& pp_dir, std::ofstream& log, UnitCel
{
upf.complete_default(ucell.atoms[i].ncpp);

log << std::endl;
ModuleBase::GlobalFunc::OUT(log, "Pseudopotential file", ucell.pseudo_fn[i]);
ModuleBase::GlobalFunc::OUT(log, "Pseudopotential type", ucell.atoms[i].ncpp.pp_type);
ModuleBase::GlobalFunc::OUT(log, "Exchange-correlation functional", ucell.atoms[i].ncpp.xc_func);
Expand Down
4 changes: 3 additions & 1 deletion source/source_io/module_output/print_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ void print_parameters(
}
else
{
std::cout << std::setw(16) << kv.get_nkstot();
const int nkstot = kv.get_nkstot();
const int nkpoints_real = (inp.nspin == 2) ? (nkstot / 2) : nkstot;
std::cout << std::setw(16) << nkpoints_real;
}

std::cout << std::setw(12) << GlobalV::NPROC
Expand Down
Loading