QMCPACK
ProjectData.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) 2022 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
8 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
9 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
10 // Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign
11 // Peter Doak, doakpw@ornl.gov, Oak Ridge National Laboratory
12 //
13 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
14 //////////////////////////////////////////////////////////////////////////////////////
15 
16 
17 #ifndef QMCPLUSPLUS_PROJECTDATA_H__
18 #define QMCPLUSPLUS_PROJECTDATA_H__
19 
20 #include <unordered_map>
21 #include "OhmmsData/libxmldefs.h"
22 #include "Message/Communicate.h"
24 
25 namespace qmcplusplus
26 {
27 /**class ProjectData
28  *\brief Encapsulate data for a project
29  *
30  * Default: title_ = getDateAndTime("%Y%m%dT%H%M")
31  *
32  * \todo This shouldn't contain MPI information it is only used to calculate the
33  * path information and the communication parameters should just be input params to that call.
34  * This reduce the internal state.
35  */
37 {
38 public:
39  /** Enum for global scope switch of design from legacy driver based to batch driver based.
40  * This effects more than just which drivers are used. Currently it just effects the meaning of
41  * qmc section vmc, dmc, linear name attributes.
42  */
43  enum class DriverVersion
44  {
45  LEGACY,
46  BATCH
47  };
48 
49 private:
50  inline static const std::unordered_map<std::string, DriverVersion> lookup_input_enum_value{{"legacy",
52  {"batch",
54  {"batched",
56 
57  };
58 
59 public:
60  /// constructor
61  ProjectData(const std::string& atitle = "", DriverVersion de = DriverVersion::LEGACY);
62 
63  bool get(std::ostream& os) const;
64  bool put(std::istream& is);
65  bool put(xmlNodePtr cur);
66  void reset();
67 
68  ///increment a series number and reset project_root_
69  void advance();
70 
71  ///roll-back a series number and reset project_root_ by one
72  void rewind();
73 
75 
76  /**
77  * @brief returns the title of the project
78  * <project id="det_qmc_short_sdbatch_vmcbatch_mwalkers" series="0">
79  * translate to title_ = "det_qmc_short_sdbatch_vmcbatch_mwalkers"
80  */
81  const std::string& getTitle() const noexcept;
82 
83  /**
84  * @brief returns the projectmain of the project, the series id is incremented at every QMC section
85  * <project id="det_qmc_short_sdbatch_vmcbatch_mwalkers" series="0">
86  * translate to project_main_ = "det_qmc_short_sdbatch_vmcbatch_mwalkers.s000"
87  */
88  const std::string& currentMainRoot() const noexcept;
89 
90  /**
91  * @brief returns the nextroot of the project, the series id is incremented at every QMC section
92  * <project id="det_qmc_short_sdbatch_vmcbatch_mwalkers" series="0">
93  * translate to project_main_ = "det_qmc_short_sdbatch_vmcbatch_mwalkers.s001"
94  */
95  const std::string& nextRoot() const noexcept;
96 
97  /**
98  * @brief return the root of the previous sequence
99  * @param oldroot is composed by the title_ and series_
100  */
101  bool previousRoot(std::string& oldroot) const;
102 
103  int getSeriesIndex() const noexcept;
104 
105  int getMaxCPUSeconds() const noexcept;
106 
107  DriverVersion getDriverVersion() const noexcept;
108 
109  bool isComplex() const noexcept;
110 
111  const RuntimeOptions& getRuntimeOptions() const noexcept;
112 
113 private:
114  static DriverVersion lookupDriverVersion(const std::string& enum_value);
115 
116  ///title of the project
117  std::string title_;
118 
119  ///name of the host where the job is running
120  std::string host_;
121 
122  ///date when the job is executed
123  std::string date_;
124 
125  ///main root for all the output engines
127 
128  ///processor-dependent root for all the output engines
130 
131  ///root for the next run
132  std::string next_root_;
133 
134  ///series index
135  int series_;
136 
137  ///communicator
139 
140  ///the xml node for <Project/>
141  xmlNodePtr cur_;
142 
143  ///max cpu seconds
145 
146  // The driver version of the project
148 
149  // tracks runtime options for the project: mixed precision, complex
151 };
152 } // namespace qmcplusplus
153 
154 #endif
const std::string & getTitle() const noexcept
returns the title of the project <project id="det_qmc_short_sdbatch_vmcbatch_mwalkers" series="0"> tr...
bool previousRoot(std::string &oldroot) const
return the root of the previous sequence
DriverVersion driver_version_
Definition: ProjectData.h:147
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
void setCommunicator(Communicate *c)
Definition: ProjectData.cpp:50
ProjectData(const std::string &atitle="", DriverVersion de=DriverVersion::LEGACY)
constructor
Definition: ProjectData.cpp:35
class ProjectData
Definition: ProjectData.h:36
bool isComplex() const noexcept
void advance()
increment a series number and reset project_root_
Definition: ProjectData.cpp:81
static const std::unordered_map< std::string, DriverVersion > lookup_input_enum_value
Definition: ProjectData.h:50
int series_
series index
Definition: ProjectData.h:135
A collection of put/get functions to read from or write to a xmlNode defined in libxml2.
const std::string & nextRoot() const noexcept
returns the nextroot of the project, the series id is incremented at every QMC section <project id="d...
const RuntimeOptions & getRuntimeOptions() const noexcept
std::string next_root_
root for the next run
Definition: ProjectData.h:132
Communicate * my_comm_
communicator
Definition: ProjectData.h:138
Wrapping information on parallelism.
Definition: Communicate.h:68
std::string date_
date when the job is executed
Definition: ProjectData.h:123
int getMaxCPUSeconds() const noexcept
DriverVersion getDriverVersion() const noexcept
bool put(std::istream &is)
Definition: ProjectData.cpp:60
std::string project_main_
main root for all the output engines
Definition: ProjectData.h:126
DriverVersion
Enum for global scope switch of design from legacy driver based to batch driver based.
Definition: ProjectData.h:43
std::string project_root_
processor-dependent root for all the output engines
Definition: ProjectData.h:129
int max_cpu_secs_
max cpu seconds
Definition: ProjectData.h:144
xmlNodePtr cur_
the xml node for <Project>
Definition: ProjectData.h:141
const std::string & currentMainRoot() const noexcept
returns the projectmain of the project, the series id is incremented at every QMC section <project id...
void rewind()
roll-back a series number and reset project_root_ by one
Definition: ProjectData.cpp:87
int getSeriesIndex() const noexcept
std::string host_
name of the host where the job is running
Definition: ProjectData.h:120
static DriverVersion lookupDriverVersion(const std::string &enum_value)
RuntimeOptions runtime_options_
Definition: ProjectData.h:150
std::string title_
title of the project
Definition: ProjectData.h:117
void reset()
Construct the root name with title_ and m_series.
Definition: ProjectData.cpp:97