QMCPACK
QMCDriverNewTestWrapper Class Reference
+ Inheritance diagram for QMCDriverNewTestWrapper:
+ Collaboration diagram for QMCDriverNewTestWrapper:

Classes

struct  TestNumCrowdsVsNumThreads
 

Public Types

using Base = QMCDriverNew
 
- Public Types inherited from QMCDriverNew
enum  { QMC_UPDATE_MODE, QMC_MULTIPLE, QMC_OPTIMIZE, QMC_WARMUP }
 separate but similar to QMCModeEnum More...
 
using RealType = QMCTraits::RealType
 
using IndexType = QMCTraits::IndexType
 
using FullPrecRealType = QMCTraits::FullPrecRealType
 
using MCPWalker = MCPopulation::MCPWalker
 
using WFBuffer = MCPopulation::WFBuffer
 
using SetNonLocalMoveHandler = std::function< void(QMCHamiltonian &)>
 
- Public Types inherited from QMCDriverInterface
using BranchEngineType = SimpleFixedNodeBranch
 
using FullPrecRealType = QMCTraits::FullPrecRealType
 
- Public Types inherited from MPIObjectBase
using mpi_comm_type = Communicate::mpi_comm_type
 

Public Member Functions

 QMCDriverNewTestWrapper (const ProjectData &test_project, QMCDriverInput &&input, WalkerConfigurations &wc, MCPopulation &&population, Communicate *comm)
 
 ~QMCDriverNewTestWrapper () override
 
QMCRunType getRunType () override
 
void process (xmlNodePtr node) override
 QMCDriverNew driver second (3rd, 4th...) stage of constructing a valid driver. More...
 
void testAdjustGlobalWalkerCount ()
 
bool run () override
 
int get_num_crowds ()
 
void testMeasureImbalance ()
 
void testDetermineStepsPerBlock ()
 
- Public Member Functions inherited from QMCDriverNew
 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. More...
 
 QMCDriverNew (QMCDriverNew &&)=default
 Move Constructor. More...
 
 QMCDriverNew (const QMCDriverNew &)=delete
 Copy Constructor (disabled). More...
 
QMCDriverNewoperator= (const QMCDriverNew &)=delete
 Copy operator (disabled). More...
 
 ~QMCDriverNew () override
 
bool putQMCInfo (xmlNodePtr cur)
 
void makeLocalWalkers (int nwalkers, RealType reserve)
 Adjust populations local walkers to this number. More...
 
DriftModifierBaseget_drift_modifier () const
 
void recordBlock (int block) override
 record the state of the block More...
 
bool finalize (int block, bool dumpwalkers=true)
 finalize a qmc section More...
 
IndexType current () const
 return current step More...
 
void setStatus (const std::string &aname, const std::string &h5name, bool append) override
 Set the status of the QMCDriver. More...
 
void add_H_and_Psi (QMCHamiltonian *h, TrialWaveFunction *psi) override
 
void createRngsStepContexts (int num_crowds)
 Creates Random Number generators for crowds and step contexts. More...
 
void putWalkers (std::vector< xmlNodePtr > &wset) override
 Read walker configurations from *.config.h5 files. More...
 
RefVector< RandomBase< FullPrecRealType > > getRngRefs () const
 
RandomBase< FullPrecRealType > & getRng (int i) override
 return the i-th random generator More...
 
std::string getEngineName () override
 intended for logging output and debugging you should base behavior on type preferably at compile time or if necessary at runtime using and protected by dynamic cast. More...
 
unsigned long getDriverMode () override
 
IndexType get_num_living_walkers () const
 
IndexType get_num_dead_walkers () const
 
const QMCDriverInputgetQMCDriverInput () const
 
bool put (xmlNodePtr cur) override
 
More...
 
void setUpdateMode (bool pbyp) override
 should be set in input don't see a reason to set individually More...
 
void putTraces (xmlNodePtr txml) override
 
void requestTraces (bool allow_traces) override
 
void putWalkerLogs (xmlNodePtr wlxml) override
 
void requestWalkerLogs (bool allow_walker_logs_) override
 
- Public Member Functions inherited from QMCDriverInterface
virtual ~QMCDriverInterface ()
 
virtual void setBranchEngine (std::unique_ptr< BranchEngineType > &&be)
 
virtual std::unique_ptr< BranchEngineTypegetBranchEngine ()
 
- Public Member Functions inherited from MPIObjectBase
 MPIObjectBase (Communicate *c)
 constructor with communicator More...
 
int rank () const
 return the rank of the communicator More...
 
int getGroupID () const
 return the group id of the communicator More...
 
CommunicategetCommunicator () const
 return myComm More...
 
CommunicategetCommRef () const
 return a TEMPORARY reference to Communicate More...
 
mpi_comm_type getMPI () const
 return MPI communicator if one wants to use MPI directly More...
 
bool is_manager () const
 return true if the rank == 0 More...
 
const std::string & getName () const
 return the name More...
 
void setName (const std::string &aname)
 

Additional Inherited Members

- Static Public Member Functions inherited from QMCDriverNew
static void initialLogEvaluation (int crowd_id, UPtrVector< Crowd > &crowds, UPtrVector< ContextForSteps > &step_context)
 
template<typename RT , CoordsType CT>
static void scaleBySqrtTau (const TauParams< RT, CT > &taus, MCCoords< CT > &coords)
 
template<typename RT , CoordsType CT>
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 More...
 
- Public Attributes inherited from QMCDriverNew
std::bitset< QMC_MODE_MAXqmc_driver_mode_
 bits to classify QMCDriver More...
 
bool allow_walker_logs
 whether to allow walker logs More...
 
WalkerLogInput walker_logs_input
 walker logs input More...
 
- Protected Member Functions inherited from QMCDriverNew
void initializeQMC (const AdjustedWalkerCounts &awc)
 Do common section starting tasks for VMC and DMC. More...
 
void measureImbalance (const std::string &tag) const
 inject additional barrier and measure load imbalance. More...
 
void endBlock ()
 end of a block operations. Aggregates statistics across all MPI ranks and write to disk. More...
 
const std::string & get_root_name () const override
 
- Static Protected Member Functions inherited from QMCDriverNew
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)
 }@ More...
 
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 More...
 
static void checkNumCrowdsLTNumThreads (const int num_crowds)
 
static void checkLogAndGL (Crowd &crowd, const std::string_view location)
 check logpsi and grad and lap against values computed from scratch More...
 
static void setWalkerOffsets (WalkerConfigurations &, Communicate *comm)
 update the global offsets of walker configurations after active walkers being touched. More...
 
- Protected Attributes inherited from QMCDriverNew
QMCDriverInput qmcdriver_input_
 
RealType max_disp_sq_
 
they should be limited to values that can be changed from input or are live state. More...
 
IndexType target_samples_
 the number of saved samples More...
 
IndexType nBlocksBetweenRecompute
 the number of blocks between recomptePsi More...
 
UPtrVector< Crowdcrowds_
 }@ More...
 
std::string h5_file_root_
 
std::unique_ptr< DriftModifierBasedrift_modifier_
 drift modifer More...
 
int k_delay
 the number to delay updates by More...
 
int walker_dump_period
 period of recording walker configurations More...
 
IndexType current_step_
 
size_t steps_per_block_ = 0
 actual number of steps per block More...
 
IndexType nAccept
 counter for number of moves accepted More...
 
IndexType nReject
 counter for number of moves /rejected More...
 
RealType m_oneover2tau
 Time-step factor $ 1/(2\tau)$. More...
 
RealType m_sqrttau
 Time-step factor $ \sqrt{\tau}$. More...
 
const std::string QMCType
 type of qmc: assigned by subclasses More...
 
MCPopulation population_
 the entire (on node) walker population it serves VMCBatch and DMCBatch right now but will be polymorphic More...
 
struct DriverWalkerResourceCollection golden_resource_
 the golden multi walker shared resource serves ParticleSet TrialWaveFunction right now but actually should be based on MCPopulation. More...
 
const MultiWalkerDispatchers dispatchers_
 multi walker dispatchers More...
 
std::unique_ptr< EstimatorManagerNewestimator_manager_
 Observables manager Has very problematic owner ship and life cycle. More...
 
std::unique_ptr< HDFWalkerOutputwOut
 record engine for walkers More...
 
UPtrVector< ContextForStepsstep_contexts_
 Per crowd move contexts, this is where the DistanceTables etc. More...
 
UPtrVector< RandomBase< FullPrecRealType > > Rng
 Random number generators. More...
 
std::vector< xmlNodePtr > mcwalkerNodePtr
 a list of mcwalkerset element More...
 
DriverTimers timers_
 period of dumping walker configurations and everything else for restart More...
 
ScopedProfiler driver_scope_profiler_
 profile the driver lifetime More...
 
const ProjectDataproject_data_
 project info for accessing global fileroot and series id More...
 
WalkerConfigurationswalker_configs_ref_
 
- Protected Attributes inherited from MPIObjectBase
CommunicatemyComm
 pointer to Communicate More...
 
std::string ClassName
 class Name More...
 
std::string myName
 name of the object More...
 

Detailed Description

Definition at line 28 of file QMCDriverNewTestWrapper.h.

Member Typedef Documentation

◆ Base

using Base = QMCDriverNew

Definition at line 31 of file QMCDriverNewTestWrapper.h.

Constructor & Destructor Documentation

◆ QMCDriverNewTestWrapper()

QMCDriverNewTestWrapper ( const ProjectData test_project,
QMCDriverInput &&  input,
WalkerConfigurations wc,
MCPopulation &&  population,
Communicate comm 
)
inline

Definition at line 32 of file QMCDriverNewTestWrapper.h.

38  std::move(input),
39  std::nullopt,
40  wc,
41  std::move(population),
42  "QMCDriverTestWrapper::",
43  comm,
44  "QMCDriverNewTestWrapper")
45  {}
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.
ProjectData test_project("test", ProjectData::DriverVersion::BATCH)
testing::ValidSpinDensityInput input

◆ ~QMCDriverNewTestWrapper()

~QMCDriverNewTestWrapper ( )
inlineoverride

Definition at line 47 of file QMCDriverNewTestWrapper.h.

47 {}

Member Function Documentation

◆ get_num_crowds()

int get_num_crowds ( )
inline

Definition at line 170 of file QMCDriverNewTestWrapper.h.

References QMCDriverNew::crowds_.

170 { return crowds_.size(); }
UPtrVector< Crowd > crowds_
}@
Definition: QMCDriverNew.h:389

◆ getRunType()

QMCRunType getRunType ( )
inlineoverridevirtual

Implements QMCDriverInterface.

Definition at line 49 of file QMCDriverNewTestWrapper.h.

References qmcplusplus::DUMMY.

◆ process()

void process ( xmlNodePtr  cur)
inlineoverridevirtual

QMCDriverNew driver second (3rd, 4th...) stage of constructing a valid driver.

This is the shared entry point with legacy, from QMCMain so the API cannot be updated yet

Todo:
remove cur, the driver and all its child nodes should be completely processed before this stage of driver initialization is hit.

Implements QMCDriverNew.

Definition at line 51 of file QMCDriverNewTestWrapper.h.

References QMCDriverNew::adjustGlobalWalkerCount(), QMCDriverInput::get_num_crowds(), QMCDriverInput::get_total_walkers(), QMCDriverInput::get_walkers_per_rank(), QMCDriverNew::initializeQMC(), MPIObjectBase::myComm, and QMCDriverNew::qmcdriver_input_.

Referenced by qmcplusplus::TEST_CASE().

52  {
53  // We want to test the reserve ability as well
54  AdjustedWalkerCounts awc =
57 
59  }
IndexType get_num_crowds() const
IndexType get_total_walkers() const
IndexType get_walkers_per_rank() const
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
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)
}@
QMCDriverInput qmcdriver_input_
Definition: QMCDriverNew.h:372
void initializeQMC(const AdjustedWalkerCounts &awc)
Do common section starting tasks for VMC and DMC.

◆ run()

bool run ( )
inlineoverridevirtual

Implements QMCDriverInterface.

Definition at line 168 of file QMCDriverNewTestWrapper.h.

168 { return false; }

◆ testAdjustGlobalWalkerCount()

void testAdjustGlobalWalkerCount ( )
inline

Definition at line 61 of file QMCDriverNewTestWrapper.h.

References QMCDriverNew::adjustGlobalWalkerCount(), qmcplusplus::CHECK(), QMCDriverNew::AdjustedWalkerCounts::global_walkers, qmcplusplus::Concurrency::maxCapacity(), MPIObjectBase::myComm, Communicate::rank(), Communicate::size(), QMCDriverNew::AdjustedWalkerCounts::walkers_per_crowd, and QMCDriverNew::AdjustedWalkerCounts::walkers_per_rank.

62  {
63  AdjustedWalkerCounts awc;
64  if (myComm->size() == 4)
65  {
66  awc = adjustGlobalWalkerCount(*myComm, 0, 64, 0, 1.0, 0);
67  if (myComm->rank() == 1)
68  {
69  CHECK(awc.global_walkers == 64);
70  CHECK(awc.walkers_per_crowd.size() == 8);
71  CHECK(awc.walkers_per_rank[0] == 16);
72  CHECK(awc.walkers_per_rank[3] == 16);
73  CHECK(awc.walkers_per_crowd[4] == 2);
74  CHECK(awc.walkers_per_crowd[7] == 2);
75  }
76 
77  awc = adjustGlobalWalkerCount(*myComm, 4, 0, 0, 1.0, 0);
78  if (myComm->rank() == 1)
79  {
80  CHECK(awc.global_walkers == 16);
81  CHECK(awc.walkers_per_crowd.size() == 8);
82  CHECK(awc.walkers_per_rank[0] == 4);
83  CHECK(awc.walkers_per_rank[3] == 4);
84  CHECK(awc.walkers_per_crowd[3] == 1);
85  CHECK(awc.walkers_per_crowd[7] == 0);
86  }
87 
88  awc = adjustGlobalWalkerCount(*myComm, 0, 63, 0, 1.0, 4);
89  if (myComm->rank() == 1)
90  {
91  CHECK(awc.global_walkers == 63);
92  CHECK(awc.walkers_per_crowd.size() == 4);
93  CHECK(awc.walkers_per_rank[0] == 16);
94  CHECK(awc.walkers_per_rank[3] == 15);
95  CHECK(awc.walkers_per_crowd[0] == 4);
96  CHECK(awc.walkers_per_crowd[3] == 4);
97  }
98  awc = adjustGlobalWalkerCount(*myComm, 0, 63, 0, 1.0, 4);
99  if (myComm->rank() == 3)
100  {
101  CHECK(awc.global_walkers == 63);
102  CHECK(awc.walkers_per_crowd.size() == 4);
103  CHECK(awc.walkers_per_rank[0] == 16);
104  CHECK(awc.walkers_per_rank[3] == 15);
105  CHECK(awc.walkers_per_crowd[0] == 4);
106  CHECK(awc.walkers_per_crowd[3] == 3);
107  }
108 
109  awc = adjustGlobalWalkerCount(*myComm, 0, 0, 32, 1.0, 4);
110  if (myComm->rank() == 3)
111  {
112  CHECK(awc.global_walkers == 128);
113  CHECK(awc.walkers_per_crowd.size() == 4);
114  CHECK(awc.walkers_per_rank[0] == 32);
115  CHECK(awc.walkers_per_rank[3] == 32);
116  CHECK(awc.walkers_per_crowd[0] == 8);
117  CHECK(awc.walkers_per_crowd[3] == 8);
118  }
119  }
120  if (myComm->size() == 1)
121  {
122  awc = adjustGlobalWalkerCount(*myComm, 0, 7, 0, 1.0, 8);
123  CHECK(awc.global_walkers == 7);
124  CHECK(awc.walkers_per_crowd.size() == 8);
125  CHECK(awc.walkers_per_rank.size() == 1);
126  CHECK(awc.walkers_per_rank[0] == 7);
127  CHECK(awc.walkers_per_crowd[0] == 1);
128  CHECK(awc.walkers_per_crowd[7] == 0);
129  }
130 
131  if (myComm->size() == 2)
132  {
133  awc = adjustGlobalWalkerCount(*myComm, 0, 28, 0, 1.0, 0);
134  if (myComm->rank() == 0)
135  {
136  CHECK(awc.global_walkers == 28);
137  CHECK(awc.walkers_per_crowd.size() == Concurrency::maxCapacity());
138  CHECK(awc.walkers_per_rank.size() == 2);
139  CHECK(awc.walkers_per_rank[0] == 14);
140  // \todo for std::thread these will be ones
141  CHECK(awc.walkers_per_crowd[0] == 2);
142  CHECK(awc.walkers_per_crowd[7] == 1);
143  }
144  awc = adjustGlobalWalkerCount(*myComm, 0, 27, 0, 1.0, 4);
145  if (myComm->rank() == 1)
146  {
147  CHECK(awc.global_walkers == 27);
148  CHECK(awc.walkers_per_crowd.size() == 4);
149  CHECK(awc.walkers_per_rank.size() == 2);
150  CHECK(awc.walkers_per_rank[0] == 14);
151  CHECK(awc.walkers_per_rank[1] == 13);
152  CHECK(awc.walkers_per_crowd[0] == 4);
153  CHECK(awc.walkers_per_crowd[3] == 3);
154  }
155  // Ask for 27 total walkers on 2 ranks of 11 walkers (inconsistent input)
156  // results in fatal exception on all ranks.
157  CHECK_THROWS_AS(adjustGlobalWalkerCount(*myComm, 0, 27, 11, 1.0, 4), UniformCommunicateError);
158  }
159 
160  if (myComm->size() == 16)
161  {
162  // Ask for 14 total walkers on 16 ranks (inconsistent input)
163  // results in fatal exception on all ranks.
164  CHECK_THROWS_AS(adjustGlobalWalkerCount(*myComm, 0, 14, 0, 0, 0), UniformCommunicateError);
165  }
166  }
int rank() const
return the rank
Definition: Communicate.h:116
int size() const
return the number of tasks
Definition: Communicate.h:118
Communicate * myComm
pointer to Communicate
Definition: MPIObjectBase.h:62
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)
}@
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
unsigned int maxCapacity()

◆ testDetermineStepsPerBlock()

void testDetermineStepsPerBlock ( )
inline

Definition at line 179 of file QMCDriverNewTestWrapper.h.

References qmcplusplus::CHECK(), and QMCDriverNew::determineStepsPerBlock().

Referenced by qmcplusplus::TEST_CASE().

180  {
181  CHECK(QMCDriverNew::determineStepsPerBlock(6, 36, 2, 3) == 2);
182  CHECK(QMCDriverNew::determineStepsPerBlock(6, 36, 1, 6) == 1);
183  CHECK(QMCDriverNew::determineStepsPerBlock(6, 33, 3, 2) == 3);
184  CHECK(QMCDriverNew::determineStepsPerBlock(6, 33, 0, 2) == 3);
185  CHECK(QMCDriverNew::determineStepsPerBlock(6, 25, 0, 2) == 3);
186  CHECK(QMCDriverNew::determineStepsPerBlock(6, 24, 0, 2) == 2);
189 
190  CHECK_THROWS_WITH(QMCDriverNew::determineStepsPerBlock(6, 13, 1, 2),
191  Catch::Contains("more than the total number of walkers"));
192  }
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
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))

◆ testMeasureImbalance()

void testMeasureImbalance ( )
inline

Definition at line 178 of file QMCDriverNewTestWrapper.h.

References QMCDriverNew::measureImbalance().

Referenced by qmcplusplus::TEST_CASE().

178 { measureImbalance("Test"); }
void measureImbalance(const std::string &tag) const
inject additional barrier and measure load imbalance.

The documentation for this class was generated from the following file: