STORMM Source Documentation
Loading...
Searching...
No Matches
nml_nice.h
1// -*-c++-*-
2#ifndef STORMM_NML_NICE_H
3#define STORMM_NML_NICE_H
4
5#include <sys/time.h>
6#include "copyright.h"
7#include "Parsing/textfile.h"
8#include "namelist_emulator.h"
9#include "namelist_enumerators.h"
10
11namespace stormm {
12namespace namelist {
13
14using parse::TextFile;
15using parse::WrapTextSearch;
16
19constexpr int default_workday_start_hour = 9;
20constexpr int default_workday_end_hour = 17;
21constexpr int default_workday_start_minute = 0;
22constexpr int default_workday_end_minute = 0;
24
28constexpr char default_workweek_start[] = "MON";
29constexpr char default_workweek_end[] = "FRI";
31
33constexpr double default_workday_gpu_effort = 0.50;
34
38constexpr double default_nice_running_check_interval = 10.0;
39constexpr double minimum_running_check_interval = 0.1;
40constexpr double maximum_running_check_interval = 60.0;
42
46constexpr double default_nice_resume_check_interval = 60.0;
47constexpr double maximum_resume_check_interval = 3600.0;
48constexpr double minimum_resume_check_interval = 60.0;
50
57public:
58
70 NiceControls(ExceptionResponse policy_in = ExceptionResponse::DIE);
71
72 NiceControls(const TextFile &tf, int *start_line, bool *found_nml,
73 ExceptionResponse policy_in = ExceptionResponse::DIE,
74 WrapTextSearch wrap = WrapTextSearch::NO);
76
80 NiceControls(const NiceControls &original) = default;
81 NiceControls(NiceControls &&original) = default;
82 NiceControls& operator=(const NiceControls &original) = default;
83 NiceControls& operator=(NiceControls &&original) = default;
85
87 // to the minute).
88 std::string getWorkdayStart() const;
89
91 std::string getWorkdayEnd() const;
92
94 std::string getWorkWeek() const;
95
97 bool isWorkTimeNow() const;
98
102 void setGpuEffortLevel(double workday_effort_level_in);
103
108 void setRunningCheckInterval(double running_check_interval_in);
109
114 void setResumeCheckInterval(double resume_check_interval_in);
115
119 void setWorkTimeStart(const std::string &work_time_start_in);
120
123 void setWorkTimeEnd(const std::string &work_time_end_in);
124
125private:
126
127 ExceptionResponse policy;
128 double workday_effort_level;
130 double running_check_interval;
133 double resume_check_interval;
136 bool stash_gpu_data;
140 int worktime_start;
142 int worktime_end;
144 std::vector<DayOfTheWeek> work_days;
145 std::vector<bool> working_day_mask;
146
148 NamelistEmulator nml_transcript;
149
153 bool validateGpuEffortLevel(const double workday_effort_level_in) const;
154
159 bool validateRunningCheckInterval(const double running_check_interval_in) const;
160
165 bool validateResumeCheckInterval(const double resume_check_interval_in) const;
166
171 int translateTimeString(const std::string &time_statement) const;
172
177 std::string translateTimeInteger(int time_value) const;
178};
179
194NamelistEmulator niceInput(const TextFile &tf, int *start_line, bool *found,
195 ExceptionResponse policy = ExceptionResponse::DIE,
196 WrapTextSearch wrap = WrapTextSearch::NO);
197
198} // namespace namelist
199} // namespace stormm
200
201#endif
Collection of variables to transcribe information contained within a namelist.
Definition namelist_emulator.h:30
void setWorkTimeStart(const std::string &work_time_start_in)
Set the start of the workday. The string will be interpreted first as an hour, or as an hour and a mi...
Definition nml_nice.cpp:127
void setWorkTimeEnd(const std::string &work_time_end_in)
Set the end of the workday. The string will be interpreted as it is in the function setWorkTimeStart(...
Definition nml_nice.cpp:132
NiceControls(const NiceControls &original)=default
As with other control objects, copy and move constructors, plus copy and move assignment operators,...
void setRunningCheckInterval(double running_check_interval_in)
Set the interval at which to check for competing processes while the STORMM process is in operation.
Definition nml_nice.cpp:113
std::string getWorkdayEnd() const
Get the workday end time as a real value in seconds after midnight.
Definition nml_nice.cpp:79
std::string getWorkdayStart() const
Get the workday start time as string recording hours:minutes:00 (workdays are rounded.
Definition nml_nice.cpp:74
bool isWorkTimeNow() const
Get a verdict on whether the workday is happening now.
Definition nml_nice.cpp:97
std::string getWorkWeek() const
Get a list of the working days of the week, codified into a string.
Definition nml_nice.cpp:84
void setResumeCheckInterval(double resume_check_interval_in)
Set the interval at which to check for competing processes after pausing the STORMM process....
Definition nml_nice.cpp:120
void setGpuEffortLevel(double workday_effort_level_in)
Set the GPU effort level to undertake during working hours.
Definition nml_nice.cpp:106
NiceControls(ExceptionResponse policy_in=ExceptionResponse::DIE)
The constructor can prepare an object with default settings or read the corresponding namelist to acc...
Definition nml_nice.cpp:17
Structure for translating a text file into a compact, rapidly parsable vector of characters in CPU RA...
Definition textfile.h:45