HEBench
benchmark.hpp
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_API_Bridge_Benchmark_H_7e5fa8c2415240ea93eff148ed73539b
6 #define _HEBench_API_Bridge_Benchmark_H_7e5fa8c2415240ea93eff148ed73539b
7 
8 #include <cstdint>
9 #include <memory>
10 #include <vector>
11 
12 #include "engine_object.hpp"
13 #include "error_handling.hpp"
15 #include "workload_params.hpp"
16 
17 namespace hebench {
18 namespace cpp {
19 
20 class BaseEngine;
21 class BaseBenchmark;
22 
36 {
37 public:
42  static constexpr std::int64_t tag = 0x1000000000000000; // bit 60
43 public:
44  BenchmarkDescription() = default;
45  virtual ~BenchmarkDescription() = default;
46 
64  const std::vector<std::vector<hebench::APIBridge::WorkloadParam>> &getWorkloadDefaultParameters() const { return m_default_params; }
75  virtual std::string getBenchmarkDescription(const hebench::APIBridge::WorkloadParams *p_w_params) const;
76 
84  std::size_t getWorkloadParameterCount() const;
94  const hebench::APIBridge::WorkloadParams *p_params) = 0;
100  virtual void destroyBenchmark(BaseBenchmark *p_bench) = 0;
101 
102  std::int64_t classTag() const override { return BenchmarkDescription::tag; }
103 
104 protected:
111 
121  void addDefaultParameters(const WorkloadParams::Common &default_params_set);
131  void addDefaultParameters(const std::vector<hebench::APIBridge::WorkloadParam> &default_params_set);
132 
133 private:
134  std::vector<std::vector<hebench::APIBridge::WorkloadParam>> m_default_params;
135 };
136 
143 {
144 private:
146 
147 public:
152  static constexpr std::int64_t tag = 0x4000000000000000; // bit 62
153 
161  BaseBenchmark(BaseEngine &engine,
162  const hebench::APIBridge::BenchmarkDescriptor &bench_desc,
163  const hebench::APIBridge::WorkloadParams &bench_params);
170  BaseBenchmark(BaseEngine &engine,
171  const hebench::APIBridge::BenchmarkDescriptor &bench_desc);
172  virtual ~BaseBenchmark() = default;
173 
183  virtual void initialize(const hebench::APIBridge::BenchmarkDescriptor &bench_desc_concrete);
188 
189  virtual hebench::APIBridge::Handle load(const hebench::APIBridge::Handle *p_local_data, std::uint64_t count) = 0;
190  virtual void store(hebench::APIBridge::Handle remote_data, hebench::APIBridge::Handle *p_local_data, std::uint64_t count) = 0;
191 
193  const hebench::APIBridge::ParameterIndexer *p_param_indexers,
194  std::uint64_t indexers_count) = 0;
195 
196  BaseEngine &getEngine() { return m_engine; }
197  const BaseEngine &getEngine() const { return m_engine; }
198 
199  std::int64_t classTag() const override { return BaseBenchmark::tag; }
200 
201  const hebench::APIBridge::BenchmarkDescriptor &getDescriptor() const { return m_bench_description; }
202  const std::vector<hebench::APIBridge::WorkloadParam> &getWorkloadParameters() const { return m_bench_params; }
203 
204 protected:
213  static std::uint64_t findDataPackIndex(const hebench::APIBridge::DataPackCollection &parameters,
214  std::uint64_t param_position);
225  std::uint64_t param_position);
236  std::uint64_t param_position);
237  void setDescriptor(const hebench::APIBridge::BenchmarkDescriptor &value) { m_bench_description = value; }
238 
239 private:
240  BaseEngine &m_engine;
241  hebench::APIBridge::BenchmarkDescriptor m_bench_description;
242  std::vector<hebench::APIBridge::WorkloadParam> m_bench_params;
243 };
244 
245 } // namespace cpp
246 } // namespace hebench
247 
248 #endif // defined _HEBench_API_Bridge_Benchmark_H_7e5fa8c2415240ea93eff148ed73539b
Top level opaque benchmark class.
Definition: benchmark.hpp:143
static const hebench::APIBridge::DataPack & findDataPack(const hebench::APIBridge::DataPackCollection &parameters, std::uint64_t param_position)
Searches the specified DataPackCollection for the DataPack in the corresponding position.
Definition: benchmark.cpp:94
virtual hebench::APIBridge::Handle load(const hebench::APIBridge::Handle *p_local_data, std::uint64_t count)=0
virtual hebench::APIBridge::Handle decrypt(hebench::APIBridge::Handle encrypted_data)=0
virtual void store(hebench::APIBridge::Handle remote_data, hebench::APIBridge::Handle *p_local_data, std::uint64_t count)=0
virtual hebench::APIBridge::Handle encode(const hebench::APIBridge::DataPackCollection *p_parameters)=0
const BaseEngine & getEngine() const
Definition: benchmark.hpp:197
std::int64_t classTag() const override
Retrieves the tag of the class to which this object belongs.
Definition: benchmark.hpp:199
const hebench::APIBridge::BenchmarkDescriptor & getDescriptor() const
Definition: benchmark.hpp:201
static std::uint64_t findDataPackIndex(const hebench::APIBridge::DataPackCollection &parameters, std::uint64_t param_position)
Searches the specified DataPackCollection for the DataPack in the corresponding position.
Definition: benchmark.cpp:73
virtual void initialize(const hebench::APIBridge::BenchmarkDescriptor &bench_desc_concrete)
Called by Test Harness with the concrete values for the benchmark description.
Definition: benchmark.cpp:68
virtual ~BaseBenchmark()=default
virtual hebench::APIBridge::Handle encrypt(hebench::APIBridge::Handle encoded_data)=0
const std::vector< hebench::APIBridge::WorkloadParam > & getWorkloadParameters() const
Definition: benchmark.hpp:202
virtual void decode(hebench::APIBridge::Handle encoded_data, hebench::APIBridge::DataPackCollection *p_native)=0
BaseBenchmark(BaseEngine &engine, const hebench::APIBridge::BenchmarkDescriptor &bench_desc, const hebench::APIBridge::WorkloadParams &bench_params)
Constructs a new BaseBenchmark object for benchmarking a workload with flexible parameters.
Definition: benchmark.cpp:59
static constexpr std::int64_t tag
Used to identify this class when returned as a handle to Test Harness.
Definition: benchmark.hpp:152
virtual hebench::APIBridge::Handle operate(hebench::APIBridge::Handle h_remote_packed, const hebench::APIBridge::ParameterIndexer *p_param_indexers, std::uint64_t indexers_count)=0
void setDescriptor(const hebench::APIBridge::BenchmarkDescriptor &value)
Definition: benchmark.hpp:237
Base class that encapsulates common behavior of backend engines.
Definition: engine.hpp:70
Base class for objects representing a specific benchmark based on an HEBench benchmark descriptor.
Definition: benchmark.hpp:36
virtual void destroyBenchmark(BaseBenchmark *p_bench)=0
Destroys and frees resources held by a BaseBenchmark (or derived) object previously created by create...
virtual ~BenchmarkDescription()=default
std::int64_t classTag() const override
Retrieves the tag of the class to which this object belongs.
Definition: benchmark.hpp:102
static constexpr std::int64_t tag
Used to identify this class when returned as a handle to Test Harness.
Definition: benchmark.hpp:42
void addDefaultParameters(const WorkloadParams::Common &default_params_set)
Adds a new set of default arguments for the parameters for this benchmark's workload.
Definition: benchmark.cpp:33
const std::vector< std::vector< hebench::APIBridge::WorkloadParam > > & getWorkloadDefaultParameters() const
Retrieves the sets of default arguments supported by this benchmark's workload.
Definition: benchmark.hpp:64
virtual BaseBenchmark * createBenchmark(BaseEngine &engine, const hebench::APIBridge::WorkloadParams *p_params)=0
Instantiates the represented benchmark.
const hebench::APIBridge::BenchmarkDescriptor & getBenchmarkDescriptor() const
Retrieves the HEBench benchmark descriptor represented by this BenchmarkDescription object.
Definition: benchmark.hpp:58
virtual std::string getBenchmarkDescription(const hebench::APIBridge::WorkloadParams *p_w_params) const
Retrieves human-readable description specific to the represented benchmark.
Definition: benchmark.cpp:17
std::size_t getWorkloadParameterCount() const
Retrieves the number of flexible parameters for this benchmark's workload.
Definition: benchmark.cpp:23
hebench::APIBridge::BenchmarkDescriptor m_descriptor
HEBench descriptor for this benchmark.
Definition: benchmark.hpp:110
Represents an object with a tag.
Base wrapper around the flexible workload parameters.
#define HEBERROR_DECLARE_CLASS_NAME(class_name)
Defines a benchmark test.
Definition: types.h:527
Defines a data package for an operation.
Definition: types.h:611
Defines a collection of data packs.
Definition: types.h:624
Specifies the parameters for a workload.
Definition: types.h:363
Structure to contain flexible data.
Definition: types.h:552