![]() |
QMCPACK
|
Class for controlling the walkers for DMC simulations. More...
Inheritance diagram for WalkerControl:
Collaboration diagram for WalkerControl:Public Types | |
| using | Walker_t = MCWalkerConfiguration::Walker_t |
| typedef of Walker_t More... | |
| using | MCPWalker = MCPopulation::MCPWalker |
| distinct type for "new" walker, currently same as Walker_t More... | |
| using | FullPrecRealType = QMCTraits::FullPrecRealType |
| typedef of FullPrecRealType More... | |
| using | IndexType = QMCTraits::IndexType |
| typedef of IndexType More... | |
Public Types inherited from MPIObjectBase | |
| using | mpi_comm_type = Communicate::mpi_comm_type |
Public Member Functions | |
| WalkerControl (Communicate *c, RandomBase< FullPrecRealType > &rng, bool use_fixed_pop=false) | |
| default constructor More... | |
| ~WalkerControl () | |
| empty destructor to clean up the derived classes More... | |
| void | start () |
| start a block More... | |
| void | writeDMCdat (int iter, const std::vector< FullPrecRealType > &curData) |
| take averages and writes to a file More... | |
| void | setTrialEnergy (FullPrecRealType et) |
| set the trial energy for writing to dmc.dat More... | |
| void | branch (int iter, MCPopulation &pop, bool do_not_branch) |
| unified: perform branch and swap walkers as required More... | |
| bool | put (xmlNodePtr cur) |
| void | setMinMax (int nw_in, int nmax_in) |
| int | get_n_max () const |
| int | get_n_min () const |
| MCDataType< FullPrecRealType > & | get_ensemble_property () |
| void | set_ensemble_property (MCDataType< FullPrecRealType > &ensemble_property) |
| IndexType | get_num_contexts () const |
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... | |
| Communicate * | getCommunicator () const |
| return myComm More... | |
| Communicate & | getCommRef () 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) |
Private Types | |
| enum | { ENERGY_INDEX = 0, ENERGY_SQ_INDEX, WALKERSIZE_INDEX, WEIGHT_INDEX, R2ACCEPTED_INDEX, R2PROPOSED_INDEX, FNSIZE_INDEX, SENTWALKERS_INDEX, LE_MAX } |
| An enum to access curData for reduction. More... | |
Private Member Functions | |
| void | computeCurData (const UPtrVector< MCPWalker > &walkers, std::vector< FullPrecRealType > &curData) |
| compute curData More... | |
Static Private Member Functions | |
| static void | killDeadWalkersOnRank (MCPopulation &pop) |
| kill dead walkers in the population More... | |
| static std::vector< IndexType > | syncFutureWalkersPerRank (Communicate *comm, IndexType n_walkers) |
| static void | determineNewWalkerPopulation (const std::vector< int > &num_per_rank, std::vector< int > &fair_offset, std::vector< int > &minus, std::vector< int > &plus) |
| creates the distribution plan More... | |
Private Attributes | |
| RandomBase< FullPrecRealType > & | rng_ |
| random number generator More... | |
| bool | use_fixed_pop_ |
| if true, use fixed population More... | |
| IndexType | n_min_ |
| minimum number of walkers More... | |
| IndexType | n_max_ |
| maximum number of walkers More... | |
| IndexType | max_copy_ |
| maximum copy per walker More... | |
| FullPrecRealType | trial_energy_ |
| trial energy energy More... | |
| std::vector< int > | num_per_rank_ |
| number of walkers on each MPI rank after branching before load balancing More... | |
| std::vector< int > | fair_offset_ |
| offset of the particle index for a fair distribution More... | |
| std::filesystem::path | dmcFname |
| filename for dmc.dat More... | |
| std::unique_ptr< std::ofstream > | dmcStream |
| file to save energy histogram More... | |
| const IndexType | rank_num_ |
| context id More... | |
| const IndexType | num_ranks_ |
| number of contexts More... | |
| IndexType | SwapMode |
| 0 is default More... | |
| std::vector< FullPrecRealType > | curData |
| any temporary data includes many ridiculous conversions of integral types to and from fp More... | |
| bool | use_nonblocking_ |
| Use non-blocking isend/irecv. More... | |
| bool | debug_disable_branching_ |
| disable branching for debugging More... | |
| MCDataType< FullPrecRealType > | ensemble_property_ |
| ensemble properties More... | |
| TimerList_t | my_timers_ |
| timers More... | |
| IndexType | saved_num_walkers_sent_ |
| Number of walkers sent during the exchange. More... | |
Additional Inherited Members | |
Protected Attributes inherited from MPIObjectBase | |
| Communicate * | myComm |
| pointer to Communicate More... | |
| std::string | ClassName |
| class Name More... | |
| std::string | myName |
| name of the object More... | |
Class for controlling the walkers for DMC simulations.
w and w/o MPI. Fixed and dynamic population in one place.
Definition at line 40 of file WalkerControl.h.
typedef of FullPrecRealType
Definition at line 48 of file WalkerControl.h.
| using IndexType = QMCTraits::IndexType |
typedef of IndexType
Definition at line 50 of file WalkerControl.h.
| using MCPWalker = MCPopulation::MCPWalker |
distinct type for "new" walker, currently same as Walker_t
Definition at line 46 of file WalkerControl.h.
typedef of Walker_t
Definition at line 44 of file WalkerControl.h.
|
private |
An enum to access curData for reduction.
curData is larger than this //LE_MAX + n_node * T
| Enumerator | |
|---|---|
| ENERGY_INDEX | |
| ENERGY_SQ_INDEX | |
| WALKERSIZE_INDEX | |
| WEIGHT_INDEX | |
| R2ACCEPTED_INDEX | |
| R2PROPOSED_INDEX | |
| FNSIZE_INDEX | |
| SENTWALKERS_INDEX | |
| LE_MAX | |
Definition at line 130 of file WalkerControl.h.
| WalkerControl | ( | Communicate * | c, |
| RandomBase< FullPrecRealType > & | rng, | ||
| bool | use_fixed_pop = false |
||
| ) |
default constructor
Set the SwapMode to zero so that instantiation can be done
Definition at line 57 of file WalkerControl.cpp.
References WalkerControl::fair_offset_, WalkerControl::num_per_rank_, WalkerControl::num_ranks_, and qmcplusplus::rank.
|
default |
empty destructor to clean up the derived classes
| void branch | ( | int | iter, |
| MCPopulation & | pop, | ||
| bool | do_not_branch | ||
| ) |
unified: perform branch and swap walkers as required
any temporary data includes many ridiculous conversions of integral types to and from fp
Definition at line 137 of file WalkerControl.cpp.
References MCPopulation::checkIntegrity(), WalkerControl::computeCurData(), WalkerControl::curData, WalkerControl::debug_disable_branching_, WalkerControl::ensemble_property_, MCPopulation::get_num_global_walkers(), MCPopulation::get_num_local_walkers(), MCPopulation::get_walkers(), WalkerControl::killDeadWalkersOnRank(), WalkerControl::LE_MAX, omptarget::min(), WalkerControl::my_timers_, MPIObjectBase::myComm, WalkerControl::num_per_rank_, WalkerControl::num_ranks_, WalkerControl::rng_, MCPopulation::set_ensemble_property(), MCPopulation::set_num_global_walkers(), MCPopulation::spawnWalker(), MCPopulation::syncWalkersPerRank(), WalkerControl::use_fixed_pop_, qmcplusplus::walker, WalkerElementsRef::walker, qmcplusplus::hdf::walkers, qmcplusplus::WC_branch, qmcplusplus::WC_copyWalkers, qmcplusplus::WC_loadbalance, qmcplusplus::WC_prebalance, and WalkerControl::writeDMCdat().
|
private |
compute curData
Definition at line 253 of file WalkerControl.cpp.
References Communicate::allreduce(), WalkerControl::curData, qmcplusplus::Units::charge::e, WalkerControl::ENERGY_INDEX, WalkerControl::ENERGY_SQ_INDEX, WalkerControl::FNSIZE_INDEX, WalkerControl::LE_MAX, WalkerControl::my_timers_, MPIObjectBase::myComm, WalkerControl::R2ACCEPTED_INDEX, WalkerControl::R2PROPOSED_INDEX, WalkerControl::rank_num_, WalkerControl::saved_num_walkers_sent_, WalkerControl::SENTWALKERS_INDEX, WalkerControl::use_fixed_pop_, qmcplusplus::walker, qmcplusplus::hdf::walkers, WalkerControl::WALKERSIZE_INDEX, qmcplusplus::WC_allreduce, and WalkerControl::WEIGHT_INDEX.
Referenced by WalkerControl::branch().
|
staticprivate |
creates the distribution plan
populates the minus and plus vectors they contain 1 copy of a partition index for each adjustment in population to the context.
| [in] | num_per_rank | as if all walkers were copied out to multiplicity |
| [out] | fair_offset | running population count at each partition boundary |
| [out] | minus | list of partition indexes one occurrence for each walker removed |
| [out] | plus | list of partition indexes one occurrence for each walker added |
Definition at line 294 of file WalkerControl.cpp.
References qmcplusplus::app_error(), and FairDivideLow().
Referenced by UnifiedDriverWalkerControlMPITest::testNewDistribution().
|
inline |
Definition at line 81 of file WalkerControl.h.
References WalkerControl::ensemble_property_.
|
inline |
Definition at line 79 of file WalkerControl.h.
References WalkerControl::n_max_.
|
inline |
Definition at line 80 of file WalkerControl.h.
References WalkerControl::n_min_.
|
inline |
Definition at line 86 of file WalkerControl.h.
References WalkerControl::num_ranks_.
|
staticprivate |
kill dead walkers in the population
Definition at line 525 of file WalkerControl.cpp.
References MCPopulation::checkIntegrity(), MCPopulation::get_walkers(), MCPopulation::killWalker(), qmcplusplus::walker, and qmcplusplus::hdf::walkers.
Referenced by WalkerControl::branch().
| bool put | ( | xmlNodePtr | cur | ) |
Definition at line 550 of file WalkerControl.cpp.
References ParameterSet::add(), qmcplusplus::app_log(), Communicate::barrier_and_abort(), WalkerControl::debug_disable_branching_, WalkerControl::max_copy_, MPIObjectBase::myComm, WalkerControl::n_max_, WalkerControl::n_min_, ParameterSet::put(), WalkerControl::setMinMax(), and WalkerControl::use_nonblocking_.
|
inline |
Definition at line 82 of file WalkerControl.h.
References WalkerControl::ensemble_property_.
| void setMinMax | ( | int | nw_in, |
| int | nmax_in | ||
| ) |
Definition at line 583 of file WalkerControl.cpp.
References WalkerControl::max_copy_, WalkerControl::n_max_, WalkerControl::n_min_, WalkerControl::num_ranks_, and WalkerControl::use_fixed_pop_.
Referenced by WalkerControl::put().
|
inline |
set the trial energy for writing to dmc.dat
Definition at line 69 of file WalkerControl.h.
References WalkerControl::trial_energy_.
| void start | ( | ) |
start a block
Definition at line 78 of file WalkerControl.cpp.
References WalkerControl::dmcFname, WalkerControl::dmcStream, Communicate::getName(), MPIObjectBase::myComm, and WalkerControl::rank_num_.
|
staticprivate |
Definition at line 541 of file WalkerControl.cpp.
References Communicate::allreduce(), qmcplusplus::comm, Communicate::rank(), and Communicate::size().
| void writeDMCdat | ( | int | iter, |
| const std::vector< FullPrecRealType > & | curData | ||
| ) |
take averages and writes to a file
Definition at line 100 of file WalkerControl.cpp.
References MCDataType< T >::AlternateEnergy, WalkerControl::curData, WalkerControl::dmcStream, MCDataType< T >::Energy, WalkerControl::ENERGY_INDEX, WalkerControl::ENERGY_SQ_INDEX, WalkerControl::ensemble_property_, WalkerControl::FNSIZE_INDEX, MCDataType< T >::LivingFraction, WalkerControl::num_ranks_, MCDataType< T >::NumSamples, MCDataType< T >::R2Accepted, WalkerControl::R2ACCEPTED_INDEX, MCDataType< T >::R2Proposed, WalkerControl::R2PROPOSED_INDEX, WalkerControl::SENTWALKERS_INDEX, WalkerControl::trial_energy_, MCDataType< T >::Variance, WalkerControl::WALKERSIZE_INDEX, MCDataType< T >::Weight, and WalkerControl::WEIGHT_INDEX.
Referenced by WalkerControl::branch().
|
private |
any temporary data includes many ridiculous conversions of integral types to and from fp
Definition at line 170 of file WalkerControl.h.
Referenced by WalkerControl::branch(), WalkerControl::computeCurData(), and WalkerControl::writeDMCdat().
|
private |
disable branching for debugging
Definition at line 174 of file WalkerControl.h.
Referenced by WalkerControl::branch(), and WalkerControl::put().
|
private |
filename for dmc.dat
Definition at line 160 of file WalkerControl.h.
Referenced by WalkerControl::start().
|
private |
file to save energy histogram
Definition at line 162 of file WalkerControl.h.
Referenced by WalkerControl::start(), and WalkerControl::writeDMCdat().
|
private |
ensemble properties
Definition at line 176 of file WalkerControl.h.
Referenced by WalkerControl::branch(), WalkerControl::get_ensemble_property(), WalkerControl::set_ensemble_property(), and WalkerControl::writeDMCdat().
|
private |
offset of the particle index for a fair distribution
Definition at line 158 of file WalkerControl.h.
Referenced by WalkerControl::WalkerControl().
|
private |
maximum copy per walker
Definition at line 152 of file WalkerControl.h.
Referenced by WalkerControl::put(), and WalkerControl::setMinMax().
|
private |
timers
Definition at line 178 of file WalkerControl.h.
Referenced by WalkerControl::branch(), and WalkerControl::computeCurData().
|
private |
maximum number of walkers
Definition at line 150 of file WalkerControl.h.
Referenced by WalkerControl::get_n_max(), WalkerControl::put(), and WalkerControl::setMinMax().
|
private |
minimum number of walkers
Definition at line 148 of file WalkerControl.h.
Referenced by WalkerControl::get_n_min(), WalkerControl::put(), and WalkerControl::setMinMax().
|
private |
number of walkers on each MPI rank after branching before load balancing
Definition at line 156 of file WalkerControl.h.
Referenced by WalkerControl::branch(), and WalkerControl::WalkerControl().
|
private |
number of contexts
Definition at line 166 of file WalkerControl.h.
Referenced by WalkerControl::branch(), WalkerControl::get_num_contexts(), WalkerControl::setMinMax(), WalkerControl::WalkerControl(), and WalkerControl::writeDMCdat().
|
private |
context id
Definition at line 164 of file WalkerControl.h.
Referenced by WalkerControl::computeCurData(), and WalkerControl::start().
|
private |
random number generator
Definition at line 144 of file WalkerControl.h.
Referenced by WalkerControl::branch().
|
private |
Number of walkers sent during the exchange.
Definition at line 180 of file WalkerControl.h.
Referenced by WalkerControl::computeCurData().
|
private |
0 is default
Definition at line 168 of file WalkerControl.h.
|
private |
trial energy energy
Definition at line 154 of file WalkerControl.h.
Referenced by WalkerControl::setTrialEnergy(), and WalkerControl::writeDMCdat().
|
private |
if true, use fixed population
Definition at line 146 of file WalkerControl.h.
Referenced by WalkerControl::branch(), WalkerControl::computeCurData(), and WalkerControl::setMinMax().
|
private |
Use non-blocking isend/irecv.
Definition at line 172 of file WalkerControl.h.
Referenced by WalkerControl::put().