Skip to content

Commit

Permalink
Simplify JSON schema
Browse files Browse the repository at this point in the history
  • Loading branch information
toxa81 committed Jul 20, 2023
1 parent 34ae93a commit 3c2f4e8
Show file tree
Hide file tree
Showing 17 changed files with 52 additions and 124 deletions.
4 changes: 2 additions & 2 deletions src/band/band.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class Band // TODO: Band class is lightweight and in principle can be converted
}
}

if (ctx_.print_checksum()) {
if (env::print_checksum()) {
auto cs = mtrx__.checksum(N__ - num_locked__, N__ - num_locked__);
if (ctx_.comm_band().rank() == 0) {
utils::print_checksum("subspace_mtrx_old", cs, RTE_OUT(std::cout));
Expand Down Expand Up @@ -136,7 +136,7 @@ class Band // TODO: Band class is lightweight and in principle can be converted
}
}

if (ctx_.print_checksum()) {
if (env::print_checksum()) {
sddk::splindex_block_cyclic<> spl_row(N__ + n__ - num_locked__,
n_blocks(mtrx__.blacs_grid().num_ranks_row()), block_id(mtrx__.blacs_grid().rank_row()),
mtrx__.bs_row());
Expand Down
2 changes: 1 addition & 1 deletion src/beta_projectors/beta_projectors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Beta_projectors : public Beta_projectors_base<T>
}
}

if (this->ctx_.cfg().control().print_checksum()) {
if (env::print_checksum()) {
auto c1 = this->pw_coeffs_t_.checksum();
comm.allreduce(&c1, 1);
if (comm.rank() == 0) {
Expand Down
69 changes: 12 additions & 57 deletions src/context/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ class config_t
}
/// Scaling parameters of the iterative solver tolerance.
/**
First number is the scaling of density RMS, that gives the estimate of the new
tolerance. Second number is the scaling of the old tolerance. New tolerance is then the minimum
between the two. This is how it is done in the code:
First number is the scaling of density RMS, that gives the estimate of the new
tolerance. Second number is the scaling of the old tolerance. New tolerance is then the minimum
between the two. This is how it is done in the code:
\code{.cpp}
double old_tol = ctx_.iterative_solver_tolerance();
// estimate new tolerance of iterative solver
Expand Down Expand Up @@ -799,42 +799,6 @@ class config_t
}
dict_["/control/num_bands_to_print"_json_pointer] = num_bands_to_print__;
}
/// If true then performance of some compute-intensive kernels will be printed to the standard output.
inline auto print_performance() const
{
return dict_.at("/control/print_performance"_json_pointer).get<bool>();
}
inline void print_performance(bool print_performance__)
{
if (dict_.contains("locked")) {
throw std::runtime_error(locked_msg);
}
dict_["/control/print_performance"_json_pointer] = print_performance__;
}
/// If true then memory usage will be printed to the standard output.
inline auto print_memory_usage() const
{
return dict_.at("/control/print_memory_usage"_json_pointer).get<bool>();
}
inline void print_memory_usage(bool print_memory_usage__)
{
if (dict_.contains("locked")) {
throw std::runtime_error(locked_msg);
}
dict_["/control/print_memory_usage"_json_pointer] = print_memory_usage__;
}
/// If true then the checksums of some arrays will be printed (useful during debug).
inline auto print_checksum() const
{
return dict_.at("/control/print_checksum"_json_pointer).get<bool>();
}
inline void print_checksum(bool print_checksum__)
{
if (dict_.contains("locked")) {
throw std::runtime_error(locked_msg);
}
dict_["/control/print_checksum"_json_pointer] = print_checksum__;
}
/// If true then the hash sums of some arrays will be printed.
inline auto print_hash() const
{
Expand Down Expand Up @@ -871,18 +835,6 @@ class config_t
}
dict_["/control/print_forces"_json_pointer] = print_forces__;
}
/// If true then the timer statistics is printed at the end of SCF run.
inline auto print_timers() const
{
return dict_.at("/control/print_timers"_json_pointer).get<bool>();
}
inline void print_timers(bool print_timers__)
{
if (dict_.contains("locked")) {
throw std::runtime_error(locked_msg);
}
dict_["/control/print_timers"_json_pointer] = print_timers__;
}
/// If true then the list of nearest neighbours for each atom is printed to the standard output.
inline auto print_neighbors() const
{
Expand Down Expand Up @@ -1498,15 +1450,18 @@ class config_t
}
dict_["/nlcg/tol"_json_pointer] = tol__;
}
/// nlcg processing unit
inline auto processing_unit() const
/// NLCG processing unit
inline auto procssing_unit() const
{
return dict_.at("/nlcg/procssing_unit"_json_pointer).get<std::string>();
}
inline void procssing_unit(std::string procssing_unit__)
{
if (dict_.contains("/nlcg/processing_unit")) {
return dict_.at("/nlcg/processing_unit"_json_pointer).get<std::string>();
if (dict_.contains("locked")) {
throw std::runtime_error(locked_msg);
}
return dict_.at("/control/processing_unit"_json_pointer).get<std::string>();
dict_["/nlcg/procssing_unit"_json_pointer] = procssing_unit__;
}

private:
nlohmann::json& dict_;
};
Expand Down
20 changes: 0 additions & 20 deletions src/context/input_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -382,21 +382,6 @@
"default" : 10,
"title" : "Number of eigen-values that are printed to the standard output."
},
"print_performance" : {
"type" : "boolean",
"default" : false,
"title" : " If true then performance of some compute-intensive kernels will be printed to the standard output."
},
"print_memory_usage" : {
"type" : "boolean",
"default" : false,
"title" : "If true then memory usage will be printed to the standard output."
},
"print_checksum" : {
"type" : "boolean",
"default" : false,
"title" : "If true then the checksums of some arrays will be printed (useful during debug)."
},
"print_hash" : {
"type" : "boolean",
"default" : false,
Expand All @@ -412,11 +397,6 @@
"default" : false,
"title" : "If true then the atomic forces are printed at the end of SCF run."
},
"print_timers" : {
"type" : "boolean",
"default" : true,
"title" : "If true then the timer statistics is printed at the end of SCF run."
},
"print_neighbors" : {
"type" : "boolean",
"default" : false,
Expand Down
5 changes: 0 additions & 5 deletions src/context/simulation_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,6 @@ Simulation_context::initialize()
print_info(this->out());
}

auto pcs = env::print_checksum();
if (pcs) {
this->cfg().control().print_checksum(true);
}

auto print_mpi_layout = env::print_mpi_layout();

if (verbosity() >= 3 || print_mpi_layout) {
Expand Down
5 changes: 0 additions & 5 deletions src/context/simulation_parameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,6 @@ class Simulation_parameters
return level__;
}

auto print_checksum() const
{
return cfg().control().print_checksum();
}

inline int lmax_rho() const
{
return cfg().parameters().lmax_rho();
Expand Down
2 changes: 1 addition & 1 deletion src/density/augmentation_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void Augmentation_operator::generate_pw_coeffs()
/* broadcast from rank#0 */
gvec_.comm().bcast(&q_mtrx_(0, 0), nbf * nbf, 0);

if (atom_type_.parameters().cfg().control().print_checksum()) {
if (env::print_checksum()) {
auto cs = q_pw_.checksum();
auto cs1 = q_mtrx_.checksum();
gvec_.comm().allreduce(&cs, 1);
Expand Down
16 changes: 8 additions & 8 deletions src/density/density.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Density::initial_density_pseudo()
auto v = make_periodic_function<sddk::index_domain_t::local>(ctx_.unit_cell(), ctx_.gvec(),
ctx_.phase_factors_t(), ff);

if (ctx_.cfg().control().print_checksum()) {
if (env::print_checksum()) {
auto z1 = sddk::mdarray<std::complex<double>, 1>(&v[0], ctx_.gvec().count()).checksum();
ctx_.comm().allreduce(&z1, 1);
utils::print_checksum("rho_pw_init", z1, ctx_.out());
Expand Down Expand Up @@ -217,7 +217,7 @@ Density::initial_density_pseudo()
/* renormalize charge */
normalize();

if (ctx_.cfg().control().print_checksum()) {
if (env::print_checksum()) {
auto cs = rho().rg().checksum_rg();
utils::print_checksum("rho_rg_init", cs, ctx_.out());
}
Expand Down Expand Up @@ -252,7 +252,7 @@ Density::initial_density_pseudo()
}
this->fft_transform(-1);

if (ctx_.cfg().control().print_checksum()) {
if (env::print_checksum()) {
for (int i = 0; i < ctx_.num_mag_dims() + 1; i++) {
auto cs = component(i).rg().checksum_rg();
auto cs1 = component(i).rg().checksum_pw();
Expand Down Expand Up @@ -286,7 +286,7 @@ Density::initial_density_full_pot()
unit_cell_.atom_type(iat).init_free_atom_density(false);
}

if (ctx_.cfg().control().print_checksum()) {
if (env::print_checksum()) {
auto z = sddk::mdarray<std::complex<double>, 1>(&v[0], ctx_.gvec().count()).checksum();
ctx_.comm().allreduce(&z, 1);
utils::print_checksum("rho_pw", z, ctx_.out());
Expand All @@ -297,7 +297,7 @@ Density::initial_density_full_pot()
/* convert charge density to real space mesh */
rho().rg().fft_transform(1);

if (ctx_.cfg().control().print_checksum()) {
if (env::print_checksum()) {
auto cs = rho().rg().checksum_rg();
utils::print_checksum("rho_rg", cs, ctx_.out());
}
Expand Down Expand Up @@ -1321,7 +1321,7 @@ Density::generate_valence(K_point_set const& ks__)
/* comm_ortho_fft is identical to a product of column communicator inside k-point with k-point communicator */
comm.allreduce(ptr, ctx_.spfft_coarse<double>().local_slice_size());
/* print checksum if needed */
if (ctx_.cfg().control().print_checksum()) {
if (env::print_checksum()) {
auto cs = sddk::mdarray<double, 1>(ptr, ctx_.spfft_coarse<double>().local_slice_size()).checksum();
mpi::Communicator(ctx_.spfft_coarse<double>().communicator()).allreduce(&cs, 1);
utils::print_checksum("rho_mag_coarse_rg", cs, ctx_.out());
Expand Down Expand Up @@ -1407,7 +1407,7 @@ Density::generate_rho_aug()
/* convert to real matrix */
auto dm = density_matrix_aux(atom_type);

if (ctx_.cfg().control().print_checksum()) {
if (env::print_checksum()) {
auto cs = dm.checksum();
utils::print_checksum("density_matrix_aux", cs, ctx_.out());
}
Expand Down Expand Up @@ -1518,7 +1518,7 @@ Density::generate_rho_aug()
rho_aug.copy_to(sddk::memory_t::host);
}

if (ctx_.cfg().control().print_checksum()) {
if (env::print_checksum()) {
auto cs = rho_aug.checksum();
ctx_.comm().allreduce(&cs, 1);
utils::print_checksum("rho_aug", cs, ctx_.out());
Expand Down
4 changes: 2 additions & 2 deletions src/hamiltonian/hamiltonian_k.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ Hamiltonian_k<T>::set_fv_h_o(la::dmatrix<std::complex<T>>& h__, la::dmatrix<std:
int s = (pu == sddk::device_t::GPU) ? (iblk % 2) : 0;
s = 0;

if (H0_.ctx().cfg().control().print_checksum()) {
if (env::print_checksum()) {
alm_row.zero();
alm_col.zero();
halm_col.zero();
Expand Down Expand Up @@ -481,7 +481,7 @@ Hamiltonian_k<T>::set_fv_h_o(la::dmatrix<std::complex<T>>& h__, la::dmatrix<std:
}
// acc::sync_stream(stream_id(omp_get_max_threads()));

if (H0_.ctx().cfg().control().print_checksum()) {
if (env::print_checksum()) {
auto z1 = alm_row.checksum();
auto z2 = alm_col.checksum();
auto z3 = halm_col.checksum();
Expand Down
4 changes: 2 additions & 2 deletions src/hamiltonian/local_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Local_operator<T>::Local_operator(Simulation_context const& ctx__, fft::spfft_tr
.allocate(get_memory_pool(sddk::memory_t::device))
.copy_to(sddk::memory_t::device);
}
if (ctx_.print_checksum()) {
if (env::print_checksum()) {
auto cs1 = veff_vec_[v_local_index_t::theta]->checksum_pw();
auto cs2 = veff_vec_[v_local_index_t::theta]->checksum_rg();
utils::print_checksum("theta_pw", cs1, ctx_.out());
Expand Down Expand Up @@ -151,7 +151,7 @@ Local_operator<T>::Local_operator(Simulation_context const& ctx__, fft::spfft_tr
}
}

if (ctx_.print_checksum()) {
if (env::print_checksum()) {
for (int j = 0; j < ctx_.num_mag_dims() + 1; j++) {
auto cs1 = veff_vec_[j]->checksum_pw();
auto cs2 = veff_vec_[j]->checksum_rg();
Expand Down
4 changes: 2 additions & 2 deletions src/hamiltonian/non_local_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ D_operator<T>::initialize()
}
}

if (this->ctx_.print_checksum()) {
if (env::print_checksum()) {
auto cs = this->op_.checksum();
utils::print_checksum("D_operator", cs, this->ctx_.out());
}
Expand Down Expand Up @@ -315,7 +315,7 @@ Q_operator<T>::initialize()
}
}
}
if (this->ctx_.print_checksum()) {
if (env::print_checksum()) {
auto cs = this->op_.checksum();
utils::print_checksum("Q_operator", cs, this->ctx_.out());
}
Expand Down
2 changes: 1 addition & 1 deletion src/hamiltonian/s_u_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ U_operator<T>::U_operator(Simulation_context const& ctx__, Hubbard_matrix const&
if (diff > 1e-10) {
RTE_THROW("um is not Hermitian");
}
if (ctx_.print_checksum()) {
if (env::print_checksum()) {
utils::print_checksum("um" + std::to_string(is), um_[is].checksum(r.first, r.first), RTE_OUT(ctx_.out()));
}
if (ctx_.processing_unit() == sddk::device_t::GPU) {
Expand Down
6 changes: 3 additions & 3 deletions src/potential/poisson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,14 @@ void Potential::poisson(Periodic_function<double> const& rho)
/* true multipole moments */
auto qmt = poisson_vmt(rho);

if (ctx_.cfg().control().print_checksum()) {
if (env::print_checksum()) {
utils::print_checksum("qmt", qmt.checksum(), ctx_.out());
}

/* compute multipoles of interstitial density in MT region */
auto qit = sum_fg_fl_yg(ctx_, ctx_.lmax_rho(), &rho.rg().f_pw_local(0), sbessel_mom_, gvec_ylm_);

if (ctx_.cfg().control().print_checksum()) {
if (env::print_checksum()) {
utils::print_checksum("qit", qit.checksum(), ctx_.out());
}

Expand Down Expand Up @@ -277,7 +277,7 @@ void Potential::poisson(Periodic_function<double> const& rho)
/* transform Hartree potential to real space */
hartree_potential_->rg().fft_transform(1);

if (ctx_.cfg().control().print_checksum()) {
if (env::print_checksum()) {
auto cs = hartree_potential_->rg().checksum_rg();
auto cs1 = hartree_potential_->rg().checksum_pw();
utils::print_checksum("vha_rg", cs, ctx_.out());
Expand Down
2 changes: 1 addition & 1 deletion src/potential/potential.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ class Potential : public Field4D

local_potential_->fft_transform(1);

if (ctx_.cfg().control().print_checksum()) {
if (env::print_checksum()) {
auto cs = local_potential_->checksum_pw();
auto cs1 = local_potential_->checksum_rg();
utils::print_checksum("local_potential_pw", cs, ctx_.out());
Expand Down
4 changes: 2 additions & 2 deletions src/potential/xc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void Potential::xc_rg_nonmagnetic(Density const& density__)
}
}

if (ctx_.cfg().control().print_checksum()) {
if (env::print_checksum()) {
auto cs = density__.rho().rg().checksum_rg();
utils::print_checksum("rho_rg", cs, ctx_.out());
}
Expand Down Expand Up @@ -241,7 +241,7 @@ void Potential::xc_rg_nonmagnetic(Density const& density__)
}
} // for loop over xc functionals

if (ctx_.cfg().control().print_checksum()) {
if (env::print_checksum()) {
auto cs = xc_potential_->rg().checksum_rg();
utils::print_checksum("exc", cs, ctx_.out());
}
Expand Down
Loading

0 comments on commit 3c2f4e8

Please sign in to comment.