QMCPACK
QMCDriverInput.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) 2022 QMCPACK developers.
6 //
7 // File developed by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Laboratory
8 //
9 // File refactored from: QMCDriver.cpp
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 /** \file
13  *
14  */
15 
16 #include "OhmmsData/AttributeSet.h"
17 #include "QMCDriverInput.h"
19 #include "Concurrency/Info.hpp"
20 #include "ModernStringUtils.hpp"
21 
22 namespace qmcplusplus
23 {
24 /** Reads qmc section xml node parameters
25  *
26  * All shared parameters are read here
27  * attribute list
28  * - checkpoint="-1|0|n" default=-1
29  * -- 1 = do not write anything
30  * -- 0 = dump after the completion of a qmc section
31  * -- n = dump after n blocks
32  * - kdelay = "0|1|n" default=0
33  */
34 void QMCDriverInput::readXML(xmlNodePtr cur)
35 {
36  // ParameterSet has an dependency on the lifetime of the backing xmlNodePtr
37  // so its better it not live long
38 
39  std::string debug_checks_str;
40  std::string measure_imbalance_str;
41  int Period4CheckPoint{0};
42  int dummy_int = 0;
43 
44  ParameterSet parameter_set;
45  parameter_set.add(recalculate_properties_period_, "checkProperties");
46  parameter_set.add(recalculate_properties_period_, "checkproperties");
47  parameter_set.add(recalculate_properties_period_, "check_properties");
48  parameter_set.add(config_dump_period_.period, "recordconfigs");
49  parameter_set.add(config_dump_period_.period, "record_configs");
50  parameter_set.add(starting_step_, "current");
51  parameter_set.add(max_blocks_, "blocks");
52  parameter_set.add(requested_steps_, "steps");
53  parameter_set.add(sub_steps_, "substeps");
54  parameter_set.add(sub_steps_, "sub_steps");
55  parameter_set.add(warmup_steps_, "warmupsteps");
56  parameter_set.add(warmup_steps_, "warmup_steps");
57  parameter_set.add(num_crowds_, "crowds");
58  parameter_set.add(crowd_serialize_walkers_, "crowd_serialize_walkers", {false});
59  parameter_set.add(walkers_per_rank_, "walkers_per_rank");
60  parameter_set.add(dummy_int, "walkers", {}, TagStatus::UNSUPPORTED);
61  parameter_set.add(total_walkers_, "total_walkers");
62  parameter_set.add(dummy_int, "stepsbetweensamples", {}, TagStatus::UNSUPPORTED);
63  parameter_set.add(dummy_int, "samplesperthread", {}, TagStatus::UNSUPPORTED);
64  parameter_set.add(requested_samples_, "samples");
65  parameter_set.add(tau_, "timestep");
66  parameter_set.add(tau_, "time_step");
67  parameter_set.add(tau_, "tau");
68  parameter_set.add(spin_mass_, "spin_mass");
69  parameter_set.add(blocks_between_recompute_, "blocks_between_recompute");
70  parameter_set.add(drift_modifier_, "drift_modifier");
71  parameter_set.add(drift_modifier_unr_a_, "drift_UNR_a");
72  parameter_set.add(max_disp_sq_, "maxDisplSq");
73  parameter_set.add(debug_checks_str, "debug_checks",
74  {"no", "all", "checkGL_after_load", "checkGL_after_moves", "checkGL_after_tmove"});
75  parameter_set.add(measure_imbalance_, "measure_imbalance", {false});
76 
77  OhmmsAttributeSet aAttrib;
78  // first stage in from QMCDriverFactory
79  aAttrib.add(qmc_method_, "method");
80  aAttrib.add(update_mode_, "move");
81  aAttrib.add(scoped_profiling_, "profiling");
82  aAttrib.add(Period4CheckPoint, "checkpoint");
83  aAttrib.add(k_delay_, "kdelay");
84  // This does all the parameter parsing setup in the constructor
85  aAttrib.put(cur);
86 
87  //set default to match legacy QMCDriver
88  check_point_period_.stride = Period4CheckPoint;
89  check_point_period_.period = Period4CheckPoint;
90 
91  if (cur != NULL)
92  {
93  //initialize the parameter set
94  parameter_set.put(cur);
95 
96  xmlNodePtr tcur = cur->children;
97  //determine how often to print walkers to hdf5 file
98  while (tcur != NULL)
99  {
100  std::string cname{lowerCase(castXMLCharToChar(tcur->name))};
101  if (cname == "record")
102  {
103  //dump walkers for optimization
104  OhmmsAttributeSet rAttrib;
105  rAttrib.add(walker_dump_period_.stride, "stride");
106  rAttrib.add(walker_dump_period_.period, "period");
107  rAttrib.put(tcur);
108  }
109  else if (cname == "checkpoint")
110  {
111  OhmmsAttributeSet rAttrib;
112  rAttrib.add(check_point_period_.stride, "stride");
113  rAttrib.add(check_point_period_.period, "period");
114  rAttrib.put(tcur);
115  }
116  else if (cname == "dumpconfig")
117  {
118  OhmmsAttributeSet rAttrib;
119  rAttrib.add(config_dump_period_.stride, "stride");
120  rAttrib.add(config_dump_period_.period, "period");
121  rAttrib.put(tcur);
122  }
123  else if (cname == "random")
124  {
125  reset_random_ = true;
126  }
127  // These complications are due to the need to support bare <esimator> nodes
128  else if (cname == "estimators" || cname == "estimator")
129  {
131  estimator_manager_input_->readXML(tcur);
132  else
133  estimator_manager_input_ = std::optional<EstimatorManagerInput>(std::in_place, tcur);
134  }
135  tcur = tcur->next;
136  }
137  }
138 
140  app_summary() << " Batched operations are serialized over walkers." << std::endl;
141  if (scoped_profiling_)
142  app_summary() << " Profiler data collection is enabled in this driver scope." << std::endl;
143 
144  if (debug_checks_str == "no")
146  else
147  {
148  if (debug_checks_str == "all" || debug_checks_str == "checkGL_after_load")
150  if (debug_checks_str == "all" || debug_checks_str == "checkGL_after_moves")
152  if (debug_checks_str == "all" || debug_checks_str == "checkGL_after_tmove")
154  }
155 
156  if (check_point_period_.period < 1)
158 
159  dump_config_ = (Period4CheckPoint >= 0);
160 }
161 
162 } // namespace qmcplusplus
input::PeriodStride check_point_period_
Abstraction of information on executor environments.
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
std::optional< EstimatorManagerInput > estimator_manager_input_
The EstimatorManagerInput for batched version input.
std::ostream & app_summary()
Definition: OutputManager.h:63
bool put(xmlNodePtr cur)
assign attributes to the set
Definition: AttributeSet.h:55
DriverDebugChecks debug_checks_
determine additional checks for debugging purpose
bool put(std::istream &is) override
read from std::istream
Definition: ParameterSet.h:42
input::PeriodStride config_dump_period_
period of recording walker positions and IDs for forward walking afterwards
class to handle a set of parameters
Definition: ParameterSet.h:27
bool measure_imbalance_
measure load imbalance (add a barrier) before data aggregation (obvious synchronization) ...
Compilation units that construct QMCDriverInput need visibility to the actual input classes types in ...
class to handle a set of attributes of an xmlNode
Definition: AttributeSet.h:24
input::PeriodStride walker_dump_period_
std::string lowerCase(const std::string_view s)
++17
char * castXMLCharToChar(xmlChar *c)
assign a value from a node. Use specialization for classes.
Definition: libxmldefs.h:62
int recalculate_properties_period_
period to recalculate the walker properties from scratch.
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 readXML(xmlNodePtr cur)
Reads qmc section xml node parameters.
bool crowd_serialize_walkers_
All input determined variables should be here They are read only for Drivers Do not write out bloc...
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
Definition: AttributeSet.h:42