SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
Backends.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "CondorBackend.h"
4 #include "LocalBackend.h"
5 #include "SlurmBackend.h"
6 #include "SSHBackend.h"
7 
8 #include "Jobs.h"
9 
10 #include <benchmax/logging.h>
11 #include <benchmax/tools/Tools.h>
12 
13 namespace benchmax {
14 
15 template<typename Backend>
16 void execute_backend(const std::string& name, const Jobs& jobs) {
17  BENCHMAX_LOG_INFO("benchmax", "Using " << name << " backend.");
18  Backend backend;
19  if (settings_operation().mode == "both") {
20  backend.run(jobs, true);
21  backend.process_results(jobs, false);
22  } else {
23  if (!backend.suspendable()) {
24  BENCHMAX_LOG_ERROR("benchmax", "The selected backend cannot be suspended. You need to use mode=\"both\".");
25  return;
26  }
27  if (settings_operation().mode == "execute") {
28  backend.run(jobs, false);
29  } else if (settings_operation().mode == "collect") {
30  backend.process_results(jobs, true);
31  } else {
32  BENCHMAX_LOG_ERROR("benchmax", "Unsupported operation mode \"" << settings_operation().mode << "\". Use one of \"execute\", \"collect\", \"both\".");
33  return;
34  }
35  }
36 }
37 /**
38  * Runs a given backend on a list of tools and benchmarks.
39  * @param backend Backend name.
40  * @param tools List of tools.
41  * @param benchmarks List of benchmarks.
42  */
43 void run_backend(const std::string& backend, const Jobs& jobs) {
44  if (backend == "condor") {
45  execute_backend<CondorBackend>(backend, jobs);
46  } else if (backend == "local") {
47  execute_backend<LocalBackend>(backend, jobs);
48  } else if (backend == "slurm") {
49  execute_backend<SlurmBackend>(backend, jobs);
50  } else if (backend == "ssh") {
51  execute_backend<SSHBackend>(backend, jobs);
52  } else {
53  BENCHMAX_LOG_ERROR("benchmax", "Invalid backend \"" << settings_operation().backend << "\".");
54  }
55 }
56 
57 }
#define BENCHMAX_LOG_INFO(channel, msg)
Log informational messages.
Definition: logging.h:53
#define BENCHMAX_LOG_ERROR(channel, msg)
Log errors.
Definition: logging.h:49
Base class for all backends.
Definition: Backend.h:23
void run(const Jobs &jobs, bool wait_for_termination)
Run the list of tools against the list of benchmarks.
Definition: Backend.h:111
void process_results(const Jobs &jobs, bool check_finished)
Definition: Backend.h:88
bool suspendable() const
Definition: Backend.h:85
Represents a set of jobs, constructed as the cartesian product of a set of tools and a set of benchma...
Definition: Jobs.h:70
void execute_backend(const std::string &name, const Jobs &jobs)
Definition: Backends.h:16
void run_backend(const std::string &backend, const Jobs &jobs)
Runs a given backend on a list of tools and benchmarks.
Definition: Backends.h:43
const auto & settings_operation()
Retrieved operation settings.
Definition: Settings.h:85