Skip to content

Commit c2e6533

Browse files
mohanchenabacus_fixer
andauthored
fix output (deepmodeling#7317)
* change a long name 'transfer_dm_2d_to_gint' to 'transfer_dm2d' * print out the 'real' number of k points to screen * convert output START CHARGE to upper case * update memory warning information * update outputs * fix * fix * fix memory --------- Co-authored-by: abacus_fixer <mohanchen@pku.eud.cn>
1 parent 9ff7599 commit c2e6533

7 files changed

Lines changed: 27 additions & 16 deletions

File tree

source/source_base/memory.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ namespace ModuleBase
1313
// 1024 Byte = 1 KB
1414
// 1024 KB = 1 MB
1515
// 1024 MB = 1 GB
16+
17+
const double memory_warning_threshold_mb = 20.0;
18+
1619
double Memory::total = 0.0;
1720
int Memory::complex_matrix_memory = 2*sizeof(double); // 16 byte
1821
int Memory::double_memory = sizeof(double); // 8 byte
@@ -149,9 +152,9 @@ double Memory::record
149152

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

152-
if(consume[find] > 5)
155+
if(consume[find] > memory_warning_threshold_mb)
153156
{
154-
print(find);
157+
print(name[find], consume[find]);
155158
}
156159
return consume[find];
157160
}
@@ -211,9 +214,9 @@ void Memory::record
211214
{
212215
Memory::total += size_mb - consume[find];
213216
consume[find] = size_mb;
214-
if(consume[find] > 5)
217+
if(consume[find] > memory_warning_threshold_mb)
215218
{
216-
print(find);
219+
print(name[find], consume[find]);
217220
}
218221
}
219222
}
@@ -268,9 +271,9 @@ double Memory::record_gpu
268271

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

271-
if(consume_gpu[find] > 5)
274+
if(consume_gpu[find] > memory_warning_threshold_mb)
272275
{
273-
print(find);
276+
print(name_gpu[find], consume_gpu[find]);
274277
}
275278
return consume_gpu[find];
276279
}
@@ -330,9 +333,9 @@ void Memory::record_gpu
330333
{
331334
Memory::total_gpu += size_mb - consume_gpu[find];
332335
consume_gpu[find] = size_mb;
333-
if(consume_gpu[find] > 5)
336+
if(consume_gpu[find] > memory_warning_threshold_mb)
334337
{
335-
print(find);
338+
print(name_gpu[find], consume_gpu[find]);
336339
}
337340
}
338341
}
@@ -341,10 +344,10 @@ void Memory::record_gpu
341344

342345
#endif
343346

344-
void Memory::print(const int find)
347+
void Memory::print(const std::string& mem_name, double size_mb)
345348
{
346-
GlobalV::ofs_running <<"\n Warning_Memory_Consuming allocated: "
347-
<<" "<<name[find]<<" "<<consume[find]<<" MB" << std::endl;
349+
GlobalV::ofs_running <<"\n *** Memory Allocation Warning *** "
350+
<<" "<< mem_name <<" "<< size_mb <<" MB" << std::endl;
348351
return;
349352
}
350353

source/source_base/memory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class Memory
9696
*/
9797
static void print_all(std::ofstream &ofs);
9898

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

101101
/**
102102
* @brief Calculate memory requirements for various

source/source_cell/cal_atoms_info.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define CAL_ATOMS_INFO_H
33
#include "source_io/module_parameter/parameter.h"
44
#include "source_estate/cal_nelec_nband.h"
5+
#include "source_base/global_function.h"
56
class CalAtomsInfo
67
{
78
public:
@@ -27,7 +28,8 @@ class CalAtomsInfo
2728
para.input.nupdown += atoms[it].mag[ia];
2829
}
2930
}
30-
GlobalV::ofs_running << " The readin total magnetization is " << para.inp.nupdown << std::endl;
31+
GlobalV::ofs_running << std::endl;
32+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "The readin total magnetization", para.inp.nupdown);
3133
}
3234

3335

source/source_cell/setup_nonlocal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ void InfoNonlocal::Set_NonLocal(const int& it,
161161

162162
delete[] tmpBeta_lm;
163163

164-
log << " SET NONLOCAL PSEUDOPOTENTIAL PROJECTORS" << std::endl;
164+
log << " SET NONLOCAL PSEUDOPOTENTIAL PROJECTORS FOR ELEMENT " << atom->label << std::endl;
165165
return;
166166
}
167167

source/source_estate/module_charge/charge_init.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <vector>
2+
#include <algorithm>
23

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

35-
std::cout << " START CHARGE : " << PARAM.inp.init_chg << std::endl;
36+
std::string init_chg_upper = PARAM.inp.init_chg;
37+
std::transform(init_chg_upper.begin(), init_chg_upper.end(), init_chg_upper.begin(), ::toupper);
38+
std::cout << " START CHARGE : " << init_chg_upper << std::endl;
3639

3740
// we need to set the omega for the charge density
3841
set_omega(&ucell.omega);

source/source_estate/read_pseudo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ void read_cell_pseudopots(const std::string& pp_dir, std::ofstream& log, UnitCel
293293
{
294294
upf.complete_default(ucell.atoms[i].ncpp);
295295

296+
log << std::endl;
296297
ModuleBase::GlobalFunc::OUT(log, "Pseudopotential file", ucell.pseudo_fn[i]);
297298
ModuleBase::GlobalFunc::OUT(log, "Pseudopotential type", ucell.atoms[i].ncpp.pp_type);
298299
ModuleBase::GlobalFunc::OUT(log, "Exchange-correlation functional", ucell.atoms[i].ncpp.xc_func);

source/source_io/module_output/print_info.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ void print_parameters(
9696
}
9797
else
9898
{
99-
std::cout << std::setw(16) << kv.get_nkstot();
99+
const int nkstot = kv.get_nkstot();
100+
const int nkpoints_real = (inp.nspin == 2) ? (nkstot / 2) : nkstot;
101+
std::cout << std::setw(16) << nkpoints_real;
100102
}
101103

102104
std::cout << std::setw(12) << GlobalV::NPROC

0 commit comments

Comments
 (0)