QMCPACK
VMCBatched.cpp
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2020 QMCPACK developers.
6 //
7 // File developed by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Laboratory
8 //
9 // File refactored from: VMC.cpp
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 #include "VMCBatched.h"
15 #include "Concurrency/Info.hpp"
17 #include "Message/CommOperators.h"
20 #include "Particle/MCSample.h"
21 #include "MemoryUsage.h"
23 #include "TauParams.hpp"
24 #include "WalkerLogManager.h"
25 
26 namespace qmcplusplus
27 {
28 /** Constructor maintains proper ownership of input parameters
29  */
30 VMCBatched::VMCBatched(const ProjectData& project_data,
31  QMCDriverInput&& qmcdriver_input,
32  const std::optional<EstimatorManagerInput>& global_emi,
35  MCPopulation&& pop,
36  SampleStack& samples,
38  : QMCDriverNew(project_data,
39  std::move(qmcdriver_input),
40  global_emi,
41  wc,
42  std::move(pop),
43  "VMCBatched::",
44  comm,
45  "VMCBatched"),
46  vmcdriver_input_(input),
47  samples_(samples),
48  collect_samples_(false)
49 {}
50 
51 template<CoordsType CT>
53  Crowd& crowd,
55  ContextForSteps& step_context,
56  bool recompute,
57  bool accumulate_this_step)
58 {
59  if (crowd.size() == 0)
60  return;
61  auto& ps_dispatcher = crowd.dispatchers_.ps_dispatcher_;
62  auto& twf_dispatcher = crowd.dispatchers_.twf_dispatcher_;
63  auto& ham_dispatcher = crowd.dispatchers_.ham_dispatcher_;
64  auto& walkers = crowd.get_walkers();
65  const RefVectorWithLeader<ParticleSet> walker_elecs(crowd.get_walker_elecs()[0], crowd.get_walker_elecs());
66  const RefVectorWithLeader<TrialWaveFunction> walker_twfs(crowd.get_walker_twfs()[0], crowd.get_walker_twfs());
67 
68  // This is really a waste the resources can be acquired outside of the run steps loop in VMCD!
69  // I don't see an easy way to measure the release without putting the weight of tons of timer_manager calls in
70  // ResourceCollectionTeamLock's constructor.
71  timers.resource_timer.start();
72  ResourceCollectionTeamLock<ParticleSet> pset_res_lock(crowd.getSharedResource().pset_res, walker_elecs);
73  ResourceCollectionTeamLock<TrialWaveFunction> twfs_res_lock(crowd.getSharedResource().twf_res, walker_twfs);
74  timers.resource_timer.stop();
76  checkLogAndGL(crowd, "checkGL_after_load");
77 
78  {
79  ScopedTimer pbyp_local_timer(timers.movepbyp_timer);
80  const int num_walkers = crowd.size();
81  auto& walker_leader = walker_elecs.getLeader();
82  const int num_particles = walker_leader.getTotalNum();
83  // Note std::vector<bool> is not like the rest of stl.
84  std::vector<bool> moved(num_walkers, false);
85  constexpr RealType mhalf(-0.5);
86  const bool use_drift = sft.vmcdrv_input.get_use_drift();
87 
88  std::vector<TrialWaveFunction::PsiValue> ratios(num_walkers);
89  std::vector<RealType> log_gf(num_walkers);
90  std::vector<RealType> log_gb(num_walkers);
91  std::vector<RealType> prob(num_walkers);
92 
93  // local list to handle accept/reject
94  std::vector<bool> isAccepted;
95  std::vector<std::reference_wrapper<TrialWaveFunction>> twf_accept_list, twf_reject_list;
96  isAccepted.reserve(num_walkers);
97 
98  MCCoords<CT> drifts(num_walkers), drifts_reverse(num_walkers);
99  MCCoords<CT> walker_deltas(num_walkers * num_particles), deltas(num_walkers);
100  TWFGrads<CT> grads_now(num_walkers), grads_new(num_walkers);
101 
102  for (int sub_step = 0; sub_step < sft.qmcdrv_input.get_sub_steps(); sub_step++)
103  {
104  //This generates an entire steps worth of deltas.
105  makeGaussRandomWithEngine(walker_deltas, step_context.get_random_gen());
106 
107  // up and down electrons are "species" within qmpack
108  for (int ig = 0; ig < walker_leader.groups(); ++ig) //loop over species
109  {
112 
113  twf_dispatcher.flex_prepareGroup(walker_twfs, walker_elecs, ig);
114 
115  for (int iat = walker_leader.first(ig); iat < walker_leader.last(ig); ++iat)
116  {
117  //get deltas for this particle (iat) for all walkers
118  walker_deltas.getSubset(iat * num_walkers, num_walkers, deltas);
119  scaleBySqrtTau(taus, deltas);
120 
121  if (use_drift)
122  {
123  twf_dispatcher.flex_evalGrad(walker_twfs, walker_elecs, iat, grads_now);
124  sft.drift_modifier.getDrifts(taus, grads_now, drifts);
125  drifts += deltas;
126  }
127  else
128  drifts = deltas;
129 
130  ps_dispatcher.flex_makeMove(walker_elecs, iat, drifts);
131 
132  // This is inelegant
133  if (use_drift)
134  {
135  twf_dispatcher.flex_calcRatioGrad(walker_twfs, walker_elecs, iat, ratios, grads_new);
136 
137  computeLogGreensFunction(deltas, taus, log_gf);
138 
139  sft.drift_modifier.getDrifts(taus, grads_new, drifts_reverse);
140 
141  drifts_reverse += drifts;
142 
143  computeLogGreensFunction(drifts_reverse, taus, log_gb);
144  }
145  else
146  twf_dispatcher.flex_calcRatio(walker_twfs, walker_elecs, iat, ratios);
147 
148  std::transform(ratios.begin(), ratios.end(), prob.begin(), [](auto ratio) { return std::norm(ratio); });
149 
150  isAccepted.clear();
151 
152  for (int i_accept = 0; i_accept < num_walkers; ++i_accept)
153  if (prob[i_accept] >= std::numeric_limits<RealType>::epsilon() &&
154  step_context.get_random_gen()() < prob[i_accept] * std::exp(log_gb[i_accept] - log_gf[i_accept]))
155  {
156  crowd.incAccept();
157  isAccepted.push_back(true);
158  }
159  else
160  {
161  crowd.incReject();
162  isAccepted.push_back(false);
163  }
164 
165  twf_dispatcher.flex_accept_rejectMove(walker_twfs, walker_elecs, iat, isAccepted, true);
166 
167  ps_dispatcher.flex_accept_rejectMove<CT>(walker_elecs, iat, isAccepted);
168  }
169  }
170  twf_dispatcher.flex_completeUpdates(walker_twfs);
171  }
172 
173  ps_dispatcher.flex_donePbyP(walker_elecs);
174  }
175 
176  {
177  ScopedTimer buffer_local_timer(timers.buffer_timer);
178  twf_dispatcher.flex_evaluateGL(walker_twfs, walker_elecs, recompute);
180  checkLogAndGL(crowd, "checkGL_after_moves");
181  }
182 
183  const RefVectorWithLeader<QMCHamiltonian> walker_hamiltonians(crowd.get_walker_hamiltonians()[0],
184  crowd.get_walker_hamiltonians());
185  {
186  ScopedTimer hamiltonian_local_timer(timers.hamiltonian_timer);
187  ResourceCollectionTeamLock<QMCHamiltonian> hams_res_lock(crowd.getSharedResource().ham_res, walker_hamiltonians);
188  std::vector<QMCHamiltonian::FullPrecRealType> local_energies(
189  ham_dispatcher.flex_evaluate(walker_hamiltonians, walker_twfs, walker_elecs));
190 
191  auto resetSigNLocalEnergy = [](MCPWalker& walker, TrialWaveFunction& twf, auto& local_energy) {
192  walker.resetProperty(twf.getLogPsi(), twf.getPhase(), local_energy);
193  };
194  for (int iw = 0; iw < crowd.size(); ++iw)
195  resetSigNLocalEnergy(walkers[iw], walker_twfs[iw], local_energies[iw]);
196  }
197 
198  {
199  ScopedTimer collectables_local_timer(timers.collectables_timer);
200  auto evaluateNonPhysicalHamiltonianElements = [](QMCHamiltonian& ham, ParticleSet& pset, MCPWalker& walker) {
202  };
203  for (int iw = 0; iw < crowd.size(); ++iw)
204  evaluateNonPhysicalHamiltonianElements(walker_hamiltonians[iw], walker_elecs[iw], walkers[iw]);
205 
206  auto savePropertiesIntoWalker = [](QMCHamiltonian& ham, MCPWalker& walker) {
207  ham.saveProperty(walker.getPropertyBase());
208  };
209  for (int iw = 0; iw < crowd.size(); ++iw)
210  savePropertiesIntoWalker(walker_hamiltonians[iw], walkers[iw]);
211  }
212 
213  if (accumulate_this_step)
214  {
215  ScopedTimer est_timer(timers.estimators_timer);
216  crowd.accumulate(step_context.get_random_gen());
217  }
218 
219  // collect walker logs
220  crowd.collectStepWalkerLog(sft.global_step);
221 
222  // TODO:
223  // check if all moves failed
224 }
225 
226 template void VMCBatched::advanceWalkers<CoordsType::POS>(const StateForThread& sft,
227  Crowd& crowd,
229  ContextForSteps& step_context,
230  bool recompute,
231  bool accumulate_this_step);
232 
233 template void VMCBatched::advanceWalkers<CoordsType::POS_SPIN>(const StateForThread& sft,
234  Crowd& crowd,
236  ContextForSteps& step_context,
237  bool recompute,
238  bool accumulate_this_step);
239 
240 /** Thread body for VMC step
241  *
242  */
243 void VMCBatched::runVMCStep(int crowd_id,
244  const StateForThread& sft,
245  DriverTimers& timers,
246  UPtrVector<ContextForSteps>& context_for_steps,
247  UPtrVector<Crowd>& crowds)
248 {
249  Crowd& crowd = *(crowds[crowd_id]);
250  crowd.setRNGForHamiltonian(context_for_steps[crowd_id]->get_random_gen());
251  const IndexType step = sft.step;
252  // Are we entering the the last step of a block to recompute at?
253  const bool recompute_this_step = (sft.is_recomputing_block && (step + 1) == sft.steps_per_block);
254  // For VMC we don't call this method for warmup steps.
255  const bool accumulate_this_step = true;
256  const bool spin_move = sft.population.get_golden_electrons().isSpinor();
257  if (spin_move)
258  advanceWalkers<CoordsType::POS_SPIN>(sft, crowd, timers, *context_for_steps[crowd_id], recompute_this_step,
259  accumulate_this_step);
260  else
261  advanceWalkers<CoordsType::POS>(sft, crowd, timers, *context_for_steps[crowd_id], recompute_this_step,
262  accumulate_this_step);
263 }
264 
265 void VMCBatched::process(xmlNodePtr node)
266 {
267  print_mem("VMCBatched before initialization", app_log());
268  // \todo get total walkers should be coming from VMCDriverInpu
269  try
270  {
274 
278 
279  Base::initializeQMC(awc);
280  }
281  catch (const UniformCommunicateError& ue)
282  {
283  myComm->barrier_and_abort(ue.what());
284  }
285 }
286 
288  const size_t samples_per_block,
289  const size_t local_walkers)
290 {
291  return num_blocks * samples_per_block * local_walkers;
292 }
293 
294 
295 /** Runs the actual VMC section
296  *
297  * Dependent on base class state machine
298  * Assumes state already updated from the following calls:
299  * 1. QMCDriverNew::setStatus
300  * 2. QMCDriverNew::putWalkers
301  * 3. QMCDriverNew::process
302  *
303  * At the moment I don't care about 1st touch, prove it matters
304  * If does consider giving more to the thread by value that should
305  * end up thread local. (I think)
306  */
308 {
310  //start the main estimator
311  estimator_manager_->startDriverRun();
312 
313  //initialize WalkerLogManager and collectors
315  for (auto& crowd : crowds_)
316  crowd->setWalkerLogCollector(wlog_manager.makeCollector());
317  //register walker log collectors into the manager
319 
321 
322  LoopTimer<> vmc_loop;
324  myComm->rank() == 0);
325 
326  { // walker initialization
328  ParallelExecutor<> section_start_task;
329  section_start_task(crowds_.size(), initialLogEvaluation, std::ref(crowds_), std::ref(step_contexts_));
330  print_mem("VMCBatched after initialLogEvaluation", app_summary());
332  measureImbalance("InitialLogEvaluation");
333  }
334 
335  ScopedTimer local_timer(timers_.production_timer);
336  ParallelExecutor<> crowd_task;
337 
339  {
340  // Run warm-up steps
341  Timer warmup_timer;
342  auto runWarmupStep = [](int crowd_id, StateForThread& sft, DriverTimers& timers,
343  UPtrVector<ContextForSteps>& context_for_steps, UPtrVector<Crowd>& crowds) {
344  Crowd& crowd = *(crowds[crowd_id]);
345  const bool recompute = false;
346  const bool accumulate_this_step = false;
347  const bool spin_move = sft.population.get_golden_electrons().isSpinor();
348  if (spin_move)
349  advanceWalkers<CoordsType::POS_SPIN>(sft, crowd, timers, *context_for_steps[crowd_id], recompute,
350  accumulate_this_step);
351  else
352  advanceWalkers<CoordsType::POS>(sft, crowd, timers, *context_for_steps[crowd_id], recompute,
353  accumulate_this_step);
354  };
355 
356  for (int step = 0; step < qmcdriver_input_.get_warmup_steps(); ++step)
357  {
358  ScopedTimer local_timer(timers_.run_steps_timer);
359  crowd_task(crowds_.size(), runWarmupStep, vmc_state, std::ref(timers_), std::ref(step_contexts_),
360  std::ref(crowds_));
361  }
362 
363  app_log() << "VMC Warmup completed in " << std::setprecision(4) << warmup_timer.elapsed() << " secs" << std::endl;
364  print_mem("VMCBatched after Warmup", app_log());
366  measureImbalance("Warmup");
367  }
368 
369  // this barrier fences all previous load imbalance. Avoid block 0 timing pollution.
370  myComm->barrier();
371 
372  int global_step = 0;
373  for (int block = 0; block < num_blocks; ++block)
374  {
375  {
376  ScopeGuard<LoopTimer<>> vmc_local_timer(vmc_loop);
380  ? (1 + block) % qmcdriver_input_.get_blocks_between_recompute() == 0
381  : false;
382 
384 
385  for (auto& crowd : crowds_)
386  crowd->startBlock(steps_per_block_);
387 
388  for (int step = 0; step < steps_per_block_; ++step, ++global_step)
389  {
390  ScopedTimer local_timer(timers_.run_steps_timer);
391  vmc_state.step = step;
392  vmc_state.global_step = global_step;
393  crowd_task(crowds_.size(), runVMCStep, vmc_state, timers_, std::ref(step_contexts_), std::ref(crowds_));
394 
395  if (collect_samples_)
396  {
397  const auto& elec_psets = population_.get_elec_particle_sets();
398  for (const auto& walker : elec_psets)
399  {
401  }
402  }
403  }
404 
405  print_mem("VMCBatched after a block", app_debug_stream());
407  measureImbalance("Block " + std::to_string(block));
408  endBlock();
409  wlog_manager.writeBuffers();
410  recordBlock(block);
411  }
412 
413  bool stop_requested = false;
414  // Rank 0 decides whether the time limit was reached
415  if (!myComm->rank())
416  stop_requested = runtimeControl.checkStop(vmc_loop);
417  myComm->bcast(stop_requested);
418  // Progress messages before possibly stopping
419  if (!myComm->rank())
420  app_log() << runtimeControl.generateProgressMessage("VMCBatched", block, num_blocks);
421  if (stop_requested)
422  {
423  if (!myComm->rank())
424  app_log() << runtimeControl.generateStopMessage("VMCBatched", block);
425  run_time_manager.markStop();
426  break;
427  }
428  }
429  // This is confusing logic from VMC.cpp want this functionality write documentation of this
430  // and clean it up
431  // bool wrotesamples = qmcdriver_input_.get_dump_config();
432  // if (qmcdriver_input_.get_dump_config())
433  // {
434  //wrotesamples = W.dumpEnsemble(wClones, wOut, myComm->size(), nBlocks);
435  //if (wrotesamples)
436  // app_log() << " samples are written to the config.h5" << std::endl;
437  // }
438 
439  // second argument was !wrotesample so if W.dumpEnsemble returns false or
440  // dump_config is false from input then dump_walkers
441  {
442  std::ostringstream o;
443  FullPrecRealType ene, var;
444  estimator_manager_->getApproximateEnergyVariance(ene, var);
445  o << "====================================================";
446  o << "\n End of a VMC section";
447  o << "\n QMC counter = " << project_data_.getSeriesIndex();
448  o << "\n time step = " << qmcdriver_input_.get_tau();
449  o << "\n reference energy = " << ene;
450  o << "\n reference variance = " << var;
451  o << "\n====================================================";
452  app_log() << o.str() << std::endl;
453  }
454 
455  print_mem("VMCBatched ends", app_log());
456 
457  wlog_manager.stopRun();
458  estimator_manager_->stopDriverRun();
459 
460  return finalize(num_blocks, true);
461 }
462 
464 {
465  assert(steps_per_block_ > 0 && "VMCBatched::enable_sample_collection steps_per_block_ must be positive!");
469  collect_samples_ = true;
470 
471  auto total_samples = samples * population_.get_num_ranks();
472  app_log() << "VMCBatched Driver collecting samples, samples per rank = " << samples << std::endl
473  << " total samples = " << total_samples << std::endl
474  << std::endl;
475 }
476 
477 } // namespace qmcplusplus
RandomBase< FullPrecRealType > & get_random_gen()
const std::string & getTitle() const noexcept
returns the title of the project <project id="det_qmc_short_sdbatch_vmcbatch_mwalkers" series="0"> tr...
bool run() override
Runs the actual VMC section.
Definition: VMCBatched.cpp:307
size_t steps_per_block_
actual number of steps per block
Definition: QMCDriverNew.h:407
double elapsed() const
Definition: Timer.h:30
const QMCDriverInput & qmcdrv_input
Definition: VMCBatched.h:49
Stores particle configurations for later use in DMC and wavefunction optimization.
const ParticleSet & get_golden_electrons() const
Definition: MCPopulation.h:176
void barrier() const
void process(xmlNodePtr node) override
QMCDriverNew driver second (3rd, 4th...) stage of constructing a valid driver.
Definition: VMCBatched.cpp:265
Abstraction of information on executor environments.
MCPopulation population_
the entire (on node) walker population it serves VMCBatch and DMCBatch right now but will be polymorp...
Definition: QMCDriverNew.h:426
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
int rank() const
return the rank
Definition: Communicate.h:116
QMCTraits::FullPrecRealType FullPrecRealType
size_t getActiveWalkers() const
return the number of active walkers
if(!okay) throw std xmlNodePtr node
Input representation for VMC driver class runtime parameters.
Abstraction for running concurrent tasks in parallel by an executor executor workers can be OpenMP th...
This is a data structure strictly for QMCDriver and its derived classes.
Definition: QMCDriverNew.h:116
void recordBlock(int block) override
record the state of the block
IndexType get_requested_steps() const
WalkerLogInput walker_logs_input
walker logs input
Definition: QMCDriverNew.h:108
QMCDriverNew Base class for Unified Drivers.
Definition: QMCDriverNew.h:75
virtual void getDrifts(RealType tau, const std::vector< GradType > &qf, std::vector< PosType > &) const =0
std::ostream & app_log()
Definition: OutputManager.h:65
class ProjectData
Definition: ProjectData.h:36
void startRun(RefVector< WalkerLogCollector > &&collectors)
open the logs file and check consistency of the collectors at the start of a run
std::ostream & app_summary()
Definition: OutputManager.h:63
void saveProperty(IT first)
save the values of Hamiltonian elements to the Properties
A set of light weight walkers that are carried between driver sections and restart.
const char num_walkers[]
Definition: HDFVersion.h:37
RunTimeManager< ChronoClock > run_time_manager
const char num_blocks[]
Definition: HDFVersion.h:44
Collection of Local Energy Operators.
int get_num_ranks() const
The number of cases in which this and get_num_local_walkers is so few that I strongly suspect it is a...
Definition: MCPopulation.h:166
static void scaleBySqrtTau(const TauParams< RT, CT > &taus, MCCoords< CT > &coords)
Definition: QMCDriverNew.h:257
Object to encapsulate appropriate tau derived parameters for a particular CoordsType specialization...
Definition: TauParams.hpp:25
void stopRun()
close the logs file at the end of a run
std::vector< std::unique_ptr< T > > UPtrVector
const char walkers[]
Definition: HDFVersion.h:36
Driver synchronized step context.
Definition: Crowd.h:38
std::unique_ptr< EstimatorManagerNew > estimator_manager_
Observables manager Has very problematic owner ship and life cycle.
Definition: QMCDriverNew.h:443
void print_mem(const std::string &title, std::ostream &log)
Definition: MemoryUsage.cpp:30
IndexType get_sub_steps() const
The timers for the driver.
Definition: QMCDriverNew.h:338
DriverDebugChecks get_debug_checks() const
std::bitset< QMC_MODE_MAX > qmc_driver_mode_
bits to classify QMCDriver
Definition: QMCDriverNew.h:103
store minimum Walker data
Definition: MCSample.h:28
VMCBatched(const ProjectData &project_data, QMCDriverInput &&qmcdriver_input, const std::optional< EstimatorManagerInput > &global_emi, VMCDriverInput &&input, WalkerConfigurations &wc, MCPopulation &&pop, SampleStack &samples_, Communicate *comm)
Constructor.
Definition: VMCBatched.cpp:30
bool collect_samples_
Sample collection flag.
Definition: VMCBatched.h:135
Driver-level resource for walker log collection.
Wrapping information on parallelism.
Definition: Communicate.h:68
IndexType get_num_crowds() const
static size_t determineStepsPerBlock(IndexType global_walkers, IndexType requested_samples, IndexType requested_steps, IndexType blocks)
pure function calculating the actual number of steps per block
Specialized paritlce class for atomistic simulations.
Definition: ParticleSet.h:55
bool finalize(int block, bool dumpwalkers=true)
finalize a qmc section
IndexType get_total_walkers() const
int getMaxCPUSeconds() const noexcept
const std::string & get_root_name() const override
Definition: QMCDriverNew.h:331
To avoid 10&#39;s of arguments to runVMCStep.
Definition: VMCBatched.h:47
static RefVector< WalkerLogCollector > getWalkerLogCollectorRefs(const UPtrVector< Crowd > &crowds)
get refereces of active walker log collectors. If walker logging is disabled, the RefVector size can ...
Definition: Crowd.cpp:106
void writeBuffers()
collect min/max/median walker data and write buffered walker log data to file
double norm(const zVec &c)
Definition: VectorOps.h:118
static void initialLogEvaluation(int crowd_id, UPtrVector< Crowd > &crowds, UPtrVector< ContextForSteps > &step_context)
static void advanceWalkers(const StateForThread &sft, Crowd &crowd, DriverTimers &timers, ContextForSteps &move_context, bool recompute, bool accumulate_this_step)
Refactor of VMCUpdatePbyP in crowd context.
Definition: VMCBatched.cpp:52
IndexType get_walkers_per_rank() const
WalkerConfigurations & walker_configs_ref_
Definition: QMCDriverNew.h:481
Compilation units that construct QMCDriverInput need visibility to the actual input classes types in ...
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
void enable_sample_collection()
Enable collecting samples during the VMC run.
Definition: VMCBatched.cpp:463
This a subclass for runtime errors that will occur on all ranks.
RealType get_spin_mass() const
const VMCDriverInput & vmcdrv_input
Definition: VMCBatched.h:50
Thread local context for moving walkers.
static void computeLogGreensFunction(const MCCoords< CT > &coords, const TauParams< RT, CT > &taus, std::vector< QMCTraits::RealType > &log_gb)
calculates Green Function from displacements stored in MCCoords [param, out] log_g ...
Definition: QMCDriverNew.h:270
static QMCDriverNew::AdjustedWalkerCounts adjustGlobalWalkerCount(Communicate &comm, const IndexType current_configs, const IndexType requested_total_walkers, const IndexType requested_walkers_per_rank, const RealType reserve_walkers, int num_crowds)
}@
QMCTraits::IndexType IndexType
Definition: QMCDriverNew.h:79
UPtrVector< ContextForSteps > step_contexts_
Per crowd move contexts, this is where the DistanceTables etc.
Definition: QMCDriverNew.h:450
MakeReturn< UnaryNode< FnExp, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t exp(const Vector< T1, C1 > &l)
const std::vector< RealType > & get_ptclgrp_inv_mass() const
Definition: MCPopulation.h:224
std::unique_ptr< DriftModifierBase > drift_modifier_
drift modifer
Definition: QMCDriverNew.h:394
static void runVMCStep(int crowd_id, const StateForThread &sft, DriverTimers &timers, UPtrVector< ContextForSteps > &context_for_steps, UPtrVector< Crowd > &crowds)
Thread body for VMC step.
Definition: VMCBatched.cpp:243
void setMaxSamples(size_t n, size_t number_of_ranks=1)
set the number of max samples per rank.
Definition: SampleStack.cpp:23
bool allow_walker_logs
whether to allow walker logs
Definition: QMCDriverNew.h:106
static void checkLogAndGL(Crowd &crowd, const std::string_view location)
check logpsi and grad and lap against values computed from scratch
void auxHevaluate(ParticleSet &P)
Class for determining elapsed run time enabling simulations to adjust to time limits.
Class to represent a many-body trial wave function.
SampleStack & samples_
Storage for samples (later used in optimizer)
Definition: VMCBatched.h:133
void appendSample(MCSample &&sample)
Definition: SampleStack.cpp:33
handles acquire/release resource by the consumer (RefVectorWithLeader type).
IndexType get_warmup_steps() const
IndexType get_max_blocks() const
const ProjectData & project_data_
project info for accessing global fileroot and series id
Definition: QMCDriverNew.h:478
void bcast(T &)
int getSeriesIndex() const noexcept
QMCTraits::RealType RealType
Definition: QMCDriverNew.h:78
VMCDriverInput vmcdriver_input_
Definition: VMCBatched.h:124
IndexType get_blocks_between_recompute() const
UPtrVector< Crowd > crowds_
}@
Definition: QMCDriverNew.h:389
void barrier_and_abort(const std::string &msg) const
QMCDriverInput qmcdriver_input_
Definition: QMCDriverNew.h:372
IndexType get_requested_samples() const
void measureImbalance(const std::string &tag) const
inject additional barrier and measure load imbalance.
IndexType get_num_local_walkers() const
Definition: MCPopulation.h:169
DriverTimers timers_
period of dumping walker configurations and everything else for restart
Definition: QMCDriverNew.h:472
static size_t compute_samples_per_rank(const size_t num_blocks, const size_t samples_per_block, const size_t local_walkers)
function to calculate samples per MPI rank
Definition: VMCBatched.cpp:287
UPtrVector< ParticleSet > & get_elec_particle_sets()
Definition: MCPopulation.h:198
const DriftModifierBase & drift_modifier
Definition: VMCBatched.h:51
std::ostream & app_debug_stream()
Definition: OutputManager.h:71
A container class to represent a walker.
Definition: Walker.h:49
void initializeQMC(const AdjustedWalkerCounts &awc)
Do common section starting tasks for VMC and DMC.
std::unique_ptr< WalkerLogCollector > makeCollector() const
create a WalkerLogCollector
Input representation for Driver base class runtime parameters.
void endBlock()
end of a block operations. Aggregates statistics across all MPI ranks and write to disk...
int get_recalculate_properties_period() const
void makeGaussRandomWithEngine(ParticleAttrib< TinyVector< T, D >> &a, RG &rng)