Skip to content

Commit

Permalink
Formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
ye-luo committed Jun 13, 2024
1 parent 0cb3842 commit 2534ad4
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 33 deletions.
19 changes: 12 additions & 7 deletions src/QMCDrivers/Crowd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Crowd::Crowd(EstimatorManagerNew& emb,
const TrialWaveFunction& twf,
const QMCHamiltonian& ham,
const MultiWalkerDispatchers& dispatchers)
: dispatchers_(dispatchers), driverwalker_resource_collection_(driverwalker_res), estimator_manager_crowd_(emb)
: dispatchers_(dispatchers), driverwalker_resource_collection_(driverwalker_res), estimator_manager_crowd_(emb)
{
if (emb.areThereListeners())
{
Expand Down Expand Up @@ -82,27 +82,32 @@ void Crowd::startBlock(int num_steps)
// VMCBatched does no nonlocal moves
n_nonlocal_accept_ = 0;
estimator_manager_crowd_.startBlock(num_steps);
if(wlog_collector_)
if (wlog_collector_)
wlog_collector_->startBlock();
}

void Crowd::stopBlock() { estimator_manager_crowd_.stopBlock(); }

void Crowd::setWalkerLogCollector(std::unique_ptr<WalkerLogCollector>&& collector) { wlog_collector_ = std::move(collector); }
void Crowd::setWalkerLogCollector(std::unique_ptr<WalkerLogCollector>&& collector)
{
wlog_collector_ = std::move(collector);
}

void Crowd::collectStepWalkerLog(int current_step)
{
if(!wlog_collector_) return;
if (!wlog_collector_)
return;

for (int iw = 0; iw < size(); ++iw)
wlog_collector_->collect(mcp_walkers_[iw], walker_elecs_[iw], walker_twfs_[iw], walker_hamiltonians_[iw], current_step);
wlog_collector_->collect(mcp_walkers_[iw], walker_elecs_[iw], walker_twfs_[iw], walker_hamiltonians_[iw],
current_step);
}

RefVector<WalkerLogCollector> Crowd::getWalkerLogCollectorRefs(const UPtrVector<Crowd>& crowds)
{
RefVector<WalkerLogCollector> refs;
for(auto& crowd : crowds)
if(crowd && crowd->wlog_collector_)
for (auto& crowd : crowds)
if (crowd && crowd->wlog_collector_)
refs.push_back(*crowd->wlog_collector_);
return refs;
}
Expand Down
4 changes: 2 additions & 2 deletions src/QMCDrivers/Crowd.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ class Crowd
*/
Crowd(EstimatorManagerNew& emb,
const DriverWalkerResourceCollection& driverwalker_res,
const ParticleSet& pset,
const ParticleSet& pset,
const TrialWaveFunction& twf,
const QMCHamiltonian& hamiltonian_temp,
const QMCHamiltonian& hamiltonian_temp,
const MultiWalkerDispatchers& dispatchers);
~Crowd();
/** Because so many vectors allocate them upfront.
Expand Down
6 changes: 3 additions & 3 deletions src/QMCDrivers/DMC/DMCBatched.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ bool DMCBatched::run()

//register walker log collectors into the manager
if (wlog_manager_)
wlog_manager_->startRun(Crowd::getWalkerLogCollectorRefs(crowds_));
wlog_manager_->startRun(Crowd::getWalkerLogCollectorRefs(crowds_));

StateForThread dmc_state(qmcdriver_input_, *drift_modifier_, *branch_engine_, population_, steps_per_block_);

Expand Down Expand Up @@ -498,7 +498,7 @@ bool DMCBatched::run()
for (UPtr<QMCHamiltonian>& ham : population_.get_hamiltonians())
setNonLocalMoveHandler(*ham);

dmc_state.step = step;
dmc_state.step = step;
dmc_state.global_step = global_step;
crowd_task(crowds_.size(), runDMCStep, dmc_state, timers_, dmc_timers_, std::ref(step_contexts_),
std::ref(crowds_));
Expand All @@ -518,7 +518,7 @@ bool DMCBatched::run()
measureImbalance("Block " + std::to_string(block));
endBlock();
if (wlog_manager_)
wlog_manager_->writeBuffers();
wlog_manager_->writeBuffers();
recordBlock(block);
}

Expand Down
4 changes: 2 additions & 2 deletions src/QMCDrivers/DMC/DMCBatched.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class DMCBatched : public QMCDriverNew
SFNBranch& branch_engine;
IndexType recalculate_properties_period;
const size_t steps_per_block;
IndexType step = -1;
IndexType global_step = -1;
IndexType step = -1;
IndexType global_step = -1;
bool is_recomputing_block = false;

StateForThread(const QMCDriverInput& qmci,
Expand Down
6 changes: 3 additions & 3 deletions src/QMCDrivers/VMC/VMCBatched.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ bool VMCBatched::run()
for (int step = 0; step < steps_per_block_; ++step, ++global_step)
{
ScopedTimer local_timer(timers_.run_steps_timer);
vmc_state.step = step;
vmc_state.step = step;
vmc_state.global_step = global_step;
crowd_task(crowds_.size(), runVMCStep, vmc_state, timers_, std::ref(step_contexts_), std::ref(crowds_));

Expand All @@ -407,7 +407,7 @@ bool VMCBatched::run()
measureImbalance("Block " + std::to_string(block));
endBlock();
if (wlog_manager_)
wlog_manager_->writeBuffers();
wlog_manager_->writeBuffers();
recordBlock(block);
}

Expand Down Expand Up @@ -463,7 +463,7 @@ void VMCBatched::enable_sample_collection()
{
assert(steps_per_block_ > 0 && "VMCBatched::enable_sample_collection steps_per_block_ must be positive!");
auto samples = compute_samples_per_rank(qmcdriver_input_.get_max_blocks(), steps_per_block_,
population_.get_num_local_walkers());
population_.get_num_local_walkers());
samples_.setMaxSamples(samples, population_.get_num_ranks());
collect_samples_ = true;

Expand Down
2 changes: 1 addition & 1 deletion src/QMCDrivers/VMC/VMCBatched.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class VMCBatched : public QMCDriverNew
IndexType recalculate_properties_period;
const size_t steps_per_block;
IndexType step = -1;
IndexType global_step = -1;
IndexType global_step = -1;
bool is_recomputing_block = false;

StateForThread(const QMCDriverInput& qmci,
Expand Down
9 changes: 3 additions & 6 deletions src/QMCDrivers/WalkerLogCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,14 @@ namespace qmcplusplus

using MCPWalker = Walker<QMCTraits, PtclOnLatticeTraits>;

WalkerLogCollector::WalkerLogCollector(const WalkerLogState& state): state_(state)
{
init();
}
WalkerLogCollector::WalkerLogCollector(const WalkerLogState& state) : state_(state) { init(); }


void WalkerLogCollector::init()
{
properties_include = {"R2Accepted", "R2Proposed", "LocalEnergy", "LocalPotential", "Kinetic",
"ElecElec", "ElecIon", "LocalECP", "NonLocalECP"};
energy_index = -1;
"ElecElec", "ElecIon", "LocalECP", "NonLocalECP"};
energy_index = -1;
// empty walker steps and energy vectors for the MC block
steps.resize(0);
energies.resize(0);
Expand Down
12 changes: 6 additions & 6 deletions src/QMCDrivers/WalkerLogManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,26 +168,26 @@ void WalkerLogManager::writeBuffers()
size_t c, r;
if (write_min_data)
{ // cache data for minimum energy walker
c = std::get<2>(energy_order[nmin]);
r = std::get<3>(energy_order[nmin]);
c = std::get<2>(energy_order[nmin]);
r = std::get<3>(energy_order[nmin]);
WalkerLogCollector& tc = collectors[c];
wmin_property_int_buffer.addRow(tc.walker_property_int_buffer, r);
wmin_property_real_buffer.addRow(tc.walker_property_real_buffer, r);
wmin_particle_real_buffer.addRow(tc.walker_particle_real_buffer, r);
}
if (write_max_data)
{ // cache data for maximum energy walker
c = std::get<2>(energy_order[nmax]);
r = std::get<3>(energy_order[nmax]);
c = std::get<2>(energy_order[nmax]);
r = std::get<3>(energy_order[nmax]);
WalkerLogCollector& tc = collectors[c];
wmax_property_int_buffer.addRow(tc.walker_property_int_buffer, r);
wmax_property_real_buffer.addRow(tc.walker_property_real_buffer, r);
wmax_particle_real_buffer.addRow(tc.walker_particle_real_buffer, r);
}
if (write_med_data)
{ // cache data for median energy walker
c = std::get<2>(energy_order[nmed]);
r = std::get<3>(energy_order[nmed]);
c = std::get<2>(energy_order[nmed]);
r = std::get<3>(energy_order[nmed]);
WalkerLogCollector& tc = collectors[c];
wmed_property_int_buffer.addRow(tc.walker_property_int_buffer, r);
wmed_property_real_buffer.addRow(tc.walker_property_real_buffer, r);
Expand Down
5 changes: 2 additions & 3 deletions src/QMCDrivers/WalkerLogManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@ struct WalkerLogInput;
*/
class WalkerLogManager
{
public:
WalkerLogState state;

private:
/// file prefix for the current driver
std::string file_root;
Communicate* communicator;
/// output state
WalkerLogState state;
/// access to HDF file
std::unique_ptr<hdf_archive> hdf_file;
/// whether walker quantity data ("data_layout") has been recorded in HDF
Expand Down

0 comments on commit 2534ad4

Please sign in to comment.