SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
PresetSettings.cpp
Go to the documentation of this file.
1 #include "PresetSettings.h"
2 
3 #include <benchmax/logging.h>
5 
9 
10 #include <cstdlib>
11 
12 namespace benchmax {
13 
14 namespace settings {
15 
16 /// Postprocess preset settings.
17 bool finalize_preset_settings(PresetSettings& s, boost::program_options::variables_map& values) {
18  if (s.rwth_slurm) {
19  auto work_cstr = std::getenv("WORK");
20  if (work_cstr == nullptr) {
21  BENCHMAX_LOG_WARN("benchmax.preset", "The preset rwth-slurm is selected but $WORK is not set. We use $WORK = \"work\" for now.");
22  }
23  std::string work(work_cstr != nullptr ? work_cstr : "WORK");
24  carl::settings::default_to(values, "backend", std::string("slurm"));
25  carl::settings::default_to(values, "output-xml", std::string("stats_" + s.rwth_slurm_name + ".xml"));
26  carl::settings::default_to(values, "slurm.keep-logs", true);
27  carl::settings::default_to(values, "slurm.archive-logs", std::string("logs-" + s.rwth_slurm_name));
28  carl::settings::default_to(values, "slurm.tmp-dir", std::string(work + "/" + s.rwth_slurm_name));
29  carl::settings::default_to(values, "slurm.sbatch-options", std::string("-C hpcwork"));
30  return true;
31  }
32  return false;
33 }
34 
36  namespace po = boost::program_options;
37  auto& settings = settings::Settings::getInstance();
38  auto& s = settings.get<settings::PresetSettings>("presets");
39 
40  parser->add_finalizer([&s](auto& values){
41  return finalize_preset_settings(s, values);
42  });
43  parser->add("Presets").add_options()
44  ("preset.rwth-slurm", po::bool_switch(&s.rwth_slurm), "Use SLURM on the RWTH HPC cluster")
45  ("preset.rwth-slurm-name", po::value<std::string>(&s.rwth_slurm_name), "Short name for file naming")
46  ;
47 }
48 }
49 
50 }
#define BENCHMAX_LOG_WARN(channel, msg)
Log warnings.
Definition: logging.h:51
Generic class to manage settings parsing using boost::program_options.
void registerPresetSettings(SettingsParser *parser)
Registers preset settings with the settings parser.
bool finalize_preset_settings(PresetSettings &s, boost::program_options::variables_map &values)
Postprocess preset settings.
std::string rwth_slurm_name
Name for this job.
bool rwth_slurm
Use slurm on the RWTH HPC cluster.