HEBench
hebench_config.h
Go to the documentation of this file.
1 
2 // Copyright (C) 2021 Intel Corporation
3 // SPDX-License-Identifier: Apache-2.0
4 
5 #ifndef _HEBench_Harness_Config_H_0596d40a3cce4b108a81595c50eb286d
6 #define _HEBench_Harness_Config_H_0596d40a3cce4b108a81595c50eb286d
7 
8 #include <cstdint>
9 #include <memory>
10 #include <string>
11 #include <utility>
12 #include <vector>
13 
14 #include "hebench/modules/logging/include/logging.h"
17 
18 namespace hebench {
19 namespace TestHarness {
20 class Engine;
21 }
22 } // namespace hebench
23 
24 namespace hebench {
25 namespace Utilities {
26 
28 
30 {
31  std::size_t index;
33 };
34 
36 {
37  std::uint64_t random_seed;
38  std::vector<std::int8_t> data;
39  std::vector<BenchmarkRequest> benchmark_requests;
40 };
41 
43 {
44 private:
45  IL_DECLARE_CLASS_NAME(BenchmarkConfigLoader)
46 public:
47  class FriendKey
48  {
49  public:
50  friend class BenchmarkConfigBroker;
51 
52  private:
53  FriendKey() = default;
54  };
55 
58 
68  static std::shared_ptr<BenchmarkConfigLoader> create(const std::string &yaml_filename,
69  std::uint64_t fallback_random_seed);
70 
71  std::uint64_t getDefaultMinTestTimeMs() const { return m_default_min_test_time_ms; }
72  std::uint64_t getDefaultSampleSize() const { return m_default_sample_size; }
76  const std::string &getFilename() const { return m_filename; }
77  const std::vector<std::int8_t> &getInitData() const { return m_data; }
84  std::uint64_t getRandomSeed() const { return m_random_seed; }
85 
86  const void *getYAMLContent(const FriendKey &) const { return m_yaml_content.get(); }
87 
88 private:
89  BenchmarkConfigLoader(const std::string &yaml_filename, std::uint64_t fallback_random_seed);
90 
91  std::string m_filename;
92  std::uint64_t m_random_seed;
93  std::uint64_t m_default_min_test_time_ms;
94  std::uint64_t m_default_sample_size;
95  std::vector<std::int8_t> m_data;
96  std::shared_ptr<void> m_yaml_content;
97 };
98 
104 {
105 private:
106  IL_DECLARE_CLASS_NAME(BenchmarkConfigBroker)
107 
108 public:
109  BenchmarkConfigBroker(std::weak_ptr<hebench::TestHarness::Engine> wp_engine,
110  std::uint64_t random_seed = 0,
111  const std::string s_backend = std::string());
112 
113  void exportConfiguration(const std::string &yaml_filename,
114  const BenchmarkSession &bench_configs) const;
122  const BenchmarkSession &getDefaultConfiguration() const { return m_default_benchmarks; }
123 
124 private:
125  std::weak_ptr<hebench::TestHarness::Engine> m_wp_engine;
126  std::string m_s_backend;
127  BenchmarkSession m_default_benchmarks;
128 };
129 
130 } // namespace Utilities
131 } // namespace hebench
132 
133 #endif // defined _HEBench_Harness_Config_H_0596d40a3cce4b108a81595c50eb286d
Provides facilities to configure the selection of benchmarks to run based on the supported workloads ...
BenchmarkSession importConfiguration(const BenchmarkConfigLoader &loader) const
Imports a benchmark configuration from a configurator loader.
BenchmarkConfigBroker(std::weak_ptr< hebench::TestHarness::Engine > wp_engine, std::uint64_t random_seed=0, const std::string s_backend=std::string())
const BenchmarkSession & getDefaultConfiguration() const
void exportConfiguration(const std::string &yaml_filename, const BenchmarkSession &bench_configs) const
BenchmarkConfigLoader(const BenchmarkConfigLoader &&)=delete
const std::string & getFilename() const
Retrieves the file name used to load the yaml data.
static std::shared_ptr< BenchmarkConfigLoader > create(const std::string &yaml_filename, std::uint64_t fallback_random_seed)
Loads a benchmark configuration from yaml data contained in a file.
BenchmarkConfigLoader(const BenchmarkConfigLoader &)=delete
const void * getYAMLContent(const FriendKey &) const
std::uint64_t getRandomSeed() const
Retrieves the configuration random seed.
std::uint64_t getDefaultMinTestTimeMs() const
const std::vector< std::int8_t > & getInitData() const
std::vector< BenchmarkRequest > benchmark_requests
hebench::TestHarness::BenchmarkDescription::Configuration configuration
std::vector< std::int8_t > data