QMCPACK
DMCBatched.h
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 DMC.h
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #ifndef QMCPLUSPLUS_DMCBATCHED_H
14 #define QMCPLUSPLUS_DMCBATCHED_H
15 
20 #include "Particle/MCCoords.hpp"
21 
22 namespace qmcplusplus
23 {
24 class DriverModifierBase;
25 class WalkerControl;
26 class SFNBranch;
27 
28 namespace testing
29 {
30 class DMCBatchedTest;
31 }
32 /** @ingroup QMCDrivers ParticleByParticle
33  * @brief Implements a DMC using particle-by-particle threaded and batched moves.
34  */
35 class DMCBatched : public QMCDriverNew
36 {
37 public:
38  using Base = QMCDriverNew;
42  /** To avoid 10's of arguments to runDMCStep
43  *
44  * There should be a division between const input to runVMCStep
45  * And step to step state
46  */
48  {
54  const size_t steps_per_block;
57  bool is_recomputing_block = false;
58 
60  DriftModifierBase& drift_mod,
61  SFNBranch& branch_eng,
62  MCPopulation& pop,
63  const size_t steps_per_block)
64  : qmcdrv_input(qmci),
65  drift_modifier(drift_mod),
66  population(pop),
67  branch_engine(branch_eng),
69  {}
70  };
71 
72  class DMCTimers
73  {
74  public:
77  DMCTimers(const std::string& prefix)
78  : tmove_timer(createGlobalTimer(prefix + "Tmove", timer_level_medium)),
79  step_begin_recompute_timer(createGlobalTimer(prefix + "Step_begin_recompute", timer_level_medium))
80  {}
81  };
82 
83  /// Constructor.
84  DMCBatched(const ProjectData& project_data,
85  QMCDriverInput&& qmcdriver_input,
86  const std::optional<EstimatorManagerInput>& global_emi,
89  MCPopulation&& pop,
90  Communicate* comm);
91 
92  /// Copy Constructor (disabled)
93  DMCBatched(const DMCBatched&) = delete;
94  /// Copy operator (disabled).
95  DMCBatched& operator=(const DMCBatched&) = delete;
96 
97  DMCBatched(DMCBatched&&) = default;
98 
99  ~DMCBatched() override;
100 
101  /** DMCBatched driver will eventually ignore cur
102  *
103  * This is the shared entry point
104  * from QMCMain so cannot be updated yet
105  *
106  * Contains logic that sets walkers_per_rank_
107  * TargetWalkers trump walkers, if it is not set
108  * walkers which is by default per rank for the batched drivers
109  * from this or the previous section wins.
110  *
111  * walkers is still badly named.
112  */
113  void process(xmlNodePtr cur) override;
114 
115  bool run() override;
116 
117  // This is the task body executed at crowd scope
118  // it does not have access to object members by design
119  static void runDMCStep(int crowd_id,
120  const StateForThread& sft,
121  DriverTimers& timers,
122  DMCTimers& dmc_timers,
123  UPtrVector<ContextForSteps>& move_context,
124  UPtrVector<Crowd>& crowds);
125 
126 
128 
129  void setNonLocalMoveHandler(QMCHamiltonian& hamiltonian);
130 
131 private:
133 
134  /** I think its better if these have there own type and variable name
135  */
137  /// Interval between branching
139  ///branch engine
140  std::unique_ptr<SFNBranch> branch_engine_;
141  ///walker controller for load-balance
142  std::unique_ptr<WalkerControl> walker_controller_;
143 
144  template<CoordsType CT>
145  static void advanceWalkers(const StateForThread& sft,
146  Crowd& crowd,
147  DriverTimers& timers,
148  DMCTimers& dmc_timers,
149  ContextForSteps& move_context,
150  bool recompute,
151  bool accumulate_this_step);
152 
154 };
155 
156 } // namespace qmcplusplus
157 
158 #endif
bool run() override
Definition: DMCBatched.cpp:432
QMCDriverNew(const ProjectData &project_data, QMCDriverInput &&input, const std::optional< EstimatorManagerInput > &global_emi, WalkerConfigurations &wc, MCPopulation &&population, const std::string timer_prefix, Communicate *comm, const std::string &QMC_driver_type)
Constructor.
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
Manages the state of QMC sections and handles population control for DMCs.
Definition: SFNBranch.h:63
std::unique_ptr< WalkerControl > walker_controller_
walker controller for load-balance
Definition: DMCBatched.h:142
QMCDriverNew Base class for Unified Drivers.
Definition: QMCDriverNew.h:75
StateForThread(const QMCDriverInput &qmci, DriftModifierBase &drift_mod, SFNBranch &branch_eng, MCPopulation &pop, const size_t steps_per_block)
Definition: DMCBatched.h:59
Declaration of QMCDriverNew.
class ProjectData
Definition: ProjectData.h:36
Implements a DMC using particle-by-particle threaded and batched moves.
Definition: DMCBatched.h:35
A set of light weight walkers that are carried between driver sections and restart.
static void advanceWalkers(const StateForThread &sft, Crowd &crowd, DriverTimers &timers, DMCTimers &dmc_timers, ContextForSteps &move_context, bool recompute, bool accumulate_this_step)
Definition: DMCBatched.cpp:72
Collection of Local Energy Operators.
this class implements drift modification
To avoid 10&#39;s of arguments to runDMCStep.
Definition: DMCBatched.h:47
IndexType branch_interval_
Interval between branching.
Definition: DMCBatched.h:138
Timer accumulates time and call counts.
Definition: NewTimer.h:135
std::vector< std::unique_ptr< T > > UPtrVector
Driver synchronized step context.
Definition: Crowd.h:38
Attaches a unit to a Vector for IO.
The timers for the driver.
Definition: QMCDriverNew.h:338
DMCTimers dmc_timers_
I think its better if these have there own type and variable name.
Definition: DMCBatched.h:136
Input representation for DMC driver class runtime parameters.
Wrapping information on parallelism.
Definition: Communicate.h:68
DMCBatched & operator=(const DMCBatched &)=delete
Copy operator (disabled).
NewTimer & createGlobalTimer(const std::string &myname, timer_levels mylevel)
void setNonLocalMoveHandler(QMCHamiltonian &hamiltonian)
Definition: DMCBatched.cpp:65
Thread local context for moving walkers.
QMCTraits::FullPrecRealType FullPrecRealType
Definition: DMCBatched.h:39
DMCTimers(const std::string &prefix)
Definition: DMCBatched.h:77
QTBase::PosType PosType
Definition: Configuration.h:61
QMCTraits::IndexType IndexType
Definition: QMCDriverNew.h:79
const DMCDriverInput dmcdriver_input_
Definition: DMCBatched.h:132
DMCBatched(const ProjectData &project_data, QMCDriverInput &&qmcdriver_input, const std::optional< EstimatorManagerInput > &global_emi, DMCDriverInput &&input, WalkerConfigurations &wc, MCPopulation &&pop, Communicate *comm)
Constructor.
Definition: DMCBatched.cpp:44
const DriftModifierBase & drift_modifier
Definition: DMCBatched.h:50
std::unique_ptr< SFNBranch > branch_engine_
branch engine
Definition: DMCBatched.h:140
ParticleAttrib< SingleParticlePos > ParticlePos
Definition: Configuration.h:92
QTFull::RealType FullPrecRealType
Definition: Configuration.h:66
QMCRunType getRunType() override
Definition: DMCBatched.h:127
static void runDMCStep(int crowd_id, const StateForThread &sft, DriverTimers &timers, DMCTimers &dmc_timers, UPtrVector< ContextForSteps > &move_context, UPtrVector< Crowd > &crowds)
Definition: DMCBatched.cpp:347
const QMCDriverInput & qmcdrv_input
Definition: DMCBatched.h:49
void process(xmlNodePtr cur) override
DMCBatched driver will eventually ignore cur.
Definition: DMCBatched.cpp:375
Input representation for Driver base class runtime parameters.