QMCPACK
WalkerControlFactory.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) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
8 // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
9 // Ye Luo, yeluo@anl.gov, Argonne National Laboratory
10 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
11 //
12 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
13 //////////////////////////////////////////////////////////////////////////////////////
14 
15 
16 #include "OhmmsData/ParameterSet.h"
17 #include "WalkerControlFactory.h"
20 #if defined(HAVE_MPI)
23 #endif
24 
25 namespace qmcplusplus
26 {
27 
28 WalkerControlBase* createWalkerController(int nwtot, Communicate* comm, xmlNodePtr cur, bool reconfig)
29 {
30  app_log() << " Creating WalkerController: target number of walkers = " << nwtot << std::endl;
31  ///set of parameters
32  int nmax = 0;
33  std::string reconfigopt("no");
34  ParameterSet m_param;
35  m_param.add(nwtot, "targetWalkers");
36  m_param.add(nwtot, "targetwalkers");
37  m_param.add(nmax, "max_walkers");
38  m_param.add(reconfigopt, "reconfiguration");
39  m_param.put(cur);
40  //if(nmax<0) nmax=2*nideal;
41  //if(nmin<0) nmin=nideal/2;
42  WalkerControlBase* wc = 0;
43  int ncontexts = comm->size();
44  if (reconfigopt != "no" && reconfigopt != "runwhileincorrect")
45  throw std::runtime_error("Reconfiguration is currently broken and gives incorrect results. Use dynamic "
46  "population control by setting reconfiguration=\"no\" or removing the reconfiguration "
47  "option from the DMC input section. If accessing the broken reconfiguration code path "
48  "is still desired, set reconfiguration to \"runwhileincorrect\" instead of \"yes\".");
49  //bool fixw = (reconfig || reconfigopt == "yes" || reconfigopt == "pure");
50  bool fixw = (reconfig || reconfigopt == "runwhileincorrect");
51  if (fixw)
52  {
53  int nwloc = std::max(omp_get_max_threads(), nwtot / ncontexts);
54  nwtot = nwloc * ncontexts;
55  }
56 #if defined(HAVE_MPI)
57  if (ncontexts > 1)
58  {
59  if (fixw)
60  {
61  app_log() << " Using WalkerReconfigurationMPI for population control." << std::endl;
63  }
64  else
65  {
66  app_log() << " Using WalkerControlMPI for dynamic population control." << std::endl;
67  wc = new WalkerControlMPI(comm);
68  }
69  }
70  else
71 #endif
72  {
73  if (fixw)
74  {
75  app_log() << " Using WalkerReconfiguration for population control." << std::endl;
76  wc = new WalkerReconfiguration(comm);
77  }
78  else
79  {
80  app_log() << " Using WalkerControlBase for dynamic population control." << std::endl;
81  wc = new WalkerControlBase(comm);
82  }
83  }
84  wc->set_method(fixw);
85  wc->setMinMax(nwtot, nmax);
86  return wc;
87 }
88 
89 
90 } // namespace qmcplusplus
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
Class to handle walker controls with simple global sum.
std::ostream & app_log()
Definition: OutputManager.h:65
int size() const
return the number of tasks
Definition: Communicate.h:118
bool put(std::istream &is) override
read from std::istream
Definition: ParameterSet.h:42
Wrapping information on parallelism.
Definition: Communicate.h:68
Class to handle walker controls with simple global sum.
class to handle a set of parameters
Definition: ParameterSet.h:27
omp_int_t omp_get_max_threads()
Definition: OpenMP.h:26
Class to handle walker controls with simple global sum.
void add(PDT &aparam, const std::string &aname_in, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new parameter corresponding to an xmlNode <parameter>
void setMinMax(int nw_in, int nmax_in)
Base class to control the walkers for DMC simulations.
WalkerControlBase * createWalkerController(int nwtot, Communicate *comm, xmlNodePtr cur, bool reconfig)
function to create WalkerControlBase or its derived class
void set_method(IndexType method)
Declaration of QMCHamiltonian.