Skip to content

Commit

Permalink
control printing hash sum from the environment
Browse files Browse the repository at this point in the history
  • Loading branch information
toxa81 committed Jul 20, 2023
1 parent 3c2f4e8 commit 37e667d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 29 deletions.
12 changes: 0 additions & 12 deletions src/context/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,18 +799,6 @@ class config_t
}
dict_["/control/num_bands_to_print"_json_pointer] = num_bands_to_print__;
}
/// If true then the hash sums of some arrays will be printed.
inline auto print_hash() const
{
return dict_.at("/control/print_hash"_json_pointer).get<bool>();
}
inline void print_hash(bool print_hash__)
{
if (dict_.contains("locked")) {
throw std::runtime_error(locked_msg);
}
dict_["/control/print_hash"_json_pointer] = print_hash__;
}
/// If true then the stress tensor components are printed at the end of SCF run.
inline auto print_stress() const
{
Expand Down
5 changes: 0 additions & 5 deletions src/context/input_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,6 @@
"default" : 10,
"title" : "Number of eigen-values that are printed to the standard output."
},
"print_hash" : {
"type" : "boolean",
"default" : false,
"title" : "If true then the hash sums of some arrays will be printed."
},
"print_stress" : {
"type" : "boolean",
"default" : false,
Expand Down
8 changes: 4 additions & 4 deletions src/density/density.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ Density::initial_density_pseudo()
}
std::copy(v.begin(), v.end(), &rho().rg().f_pw_local(0));

if (ctx_.cfg().control().print_hash() && ctx_.comm().rank() == 0) {
if (env::print_hash() && ctx_.comm().rank() == 0) {
auto h = sddk::mdarray<std::complex<double>, 1>(&v[0], ctx_.gvec().count()).hash();
utils::print_hash("rho_pw_init", h);
}
Expand All @@ -205,7 +205,7 @@ Density::initial_density_pseudo()
}
}
rho().rg().fft_transform(1);
if (ctx_.cfg().control().print_hash() && ctx_.comm().rank() == 0) {
if (env::print_hash() && ctx_.comm().rank() == 0) {
auto h = rho().rg().values().hash();
utils::print_hash("rho_rg_init", h);
}
Expand Down Expand Up @@ -1342,7 +1342,7 @@ Density::generate_valence(K_point_set const& ks__)
rho().rg().f_pw_local(0) += ctx_.cfg().parameters().extra_charge() / ctx_.unit_cell().omega();
}

if (ctx_.cfg().control().print_hash() && ctx_.comm().rank() == 0) {
if (env::print_hash() && ctx_.comm().rank() == 0) {
auto h = sddk::mdarray<std::complex<double>, 1>(&rho().rg().f_pw_local(0), ctx_.gvec().count()).hash();
utils::print_hash("rho", h);
}
Expand Down Expand Up @@ -1524,7 +1524,7 @@ Density::generate_rho_aug()
utils::print_checksum("rho_aug", cs, ctx_.out());
}

if (ctx_.cfg().control().print_hash()) {
if (env::print_hash()) {
auto h = rho_aug.hash();
if (ctx_.comm().rank() == 0) {
utils::print_hash("rho_aug", h);
Expand Down
6 changes: 3 additions & 3 deletions src/potential/potential.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ void Potential::generate(Density const& density__, bool use_symmetry__, bool tra
/* add Hartree potential to the total potential */
effective_potential() += hartree_potential();

if (ctx_.cfg().control().print_hash()) {
if (env::print_hash()) {
auto h = effective_potential().rg().hash_f_rg();
if (ctx_.comm().rank() == 0) {
utils::print_hash("Vha", h);
Expand All @@ -270,7 +270,7 @@ void Potential::generate(Density const& density__, bool use_symmetry__, bool tra
/* add XC potential to the effective potential */
effective_potential() += xc_potential();

if (ctx_.cfg().control().print_hash()) {
if (env::print_hash()) {
auto h = effective_potential().rg().hash_f_rg();
if (ctx_.comm().rank() == 0) {
utils::print_hash("Vha+Vxc", h);
Expand Down Expand Up @@ -308,7 +308,7 @@ void Potential::generate(Density const& density__, bool use_symmetry__, bool tra
}
}

if (ctx_.cfg().control().print_hash()) {
if (env::print_hash()) {
auto h = effective_potential().rg().hash_f_pw();
if (ctx_.comm().rank() == 0) {
utils::print_hash("V(G)", h);
Expand Down
10 changes: 5 additions & 5 deletions src/potential/xc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void Potential::xc_rg_nonmagnetic(Density const& density__)
WARNING(s);
}

if (ctx_.cfg().control().print_hash()) {
if (env::print_hash()) {
auto h = rho.hash_f_rg();
if (ctx_.comm().rank() == 0) {
utils::print_hash("rho", h);
Expand Down Expand Up @@ -114,7 +114,7 @@ void Potential::xc_rg_nonmagnetic(Density const& density__)
/* product of gradients */
grad_rho_grad_rho = dot(grad_rho, grad_rho);

if (ctx_.cfg().control().print_hash()) {
if (env::print_hash()) {
//auto h1 = lapl_rho.hash_f_rg();
auto h2 = grad_rho_grad_rho.hash_f_rg();
if (ctx_.comm().rank() == 0) {
Expand Down Expand Up @@ -261,7 +261,7 @@ void Potential::xc_rg_magnetic(Density const& density__)
auto& rho_up = *result[0];
auto& rho_dn = *result[1];

if (ctx_.cfg().control().print_hash()) {
if (env::print_hash()) {
auto h1 = rho_up.hash_f_rg();
auto h2 = rho_dn.hash_f_rg();
if (ctx_.comm().rank() == 0) {
Expand Down Expand Up @@ -297,7 +297,7 @@ void Potential::xc_rg_magnetic(Density const& density__)
grad_rho_up_grad_rho_dn = dot(grad_rho_up, grad_rho_dn);
grad_rho_dn_grad_rho_dn = dot(grad_rho_dn, grad_rho_dn);

if (ctx_.cfg().control().print_hash()) {
if (env::print_hash()) {
auto h3 = grad_rho_up_grad_rho_up.hash_f_rg();
auto h4 = grad_rho_up_grad_rho_dn.hash_f_rg();
auto h5 = grad_rho_dn_grad_rho_dn.hash_f_rg();
Expand Down Expand Up @@ -465,7 +465,7 @@ void Potential::xc(Density const& density__)
xc_rg_magnetic<add_pseudo_core__>(density__);
}

if (ctx_.cfg().control().print_hash()) {
if (env::print_hash()) {
auto h = xc_energy_density_->rg().hash_f_rg();
if (ctx_.comm().rank() == 0) {
utils::print_hash("Exc", h);
Expand Down
7 changes: 7 additions & 0 deletions src/utils/env.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ print_checksum()
return val && *val;
}

inline bool
print_hash()
{
auto val = get_value_ptr<int>("SIRIUS_PRINT_HASH");
return val && *val;
}

inline bool
print_mpi_layout()
{
Expand Down

0 comments on commit 37e667d

Please sign in to comment.