HEBench
hebench_eltwisemult.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_DataGenerator_EltwiseMult_H_0596d40a3cce4b108a81595c50eb286d
6 #define _HEBench_Harness_DataGenerator_EltwiseMult_H_0596d40a3cce4b108a81595c50eb286d
7 
8 #include <array>
9 #include <memory>
10 #include <random>
11 #include <utility>
12 #include <vector>
13 
14 #include "hebench/modules/general/include/nocopy.h"
15 #include "hebench/modules/logging/include/logging.h"
16 
18 
21 
22 namespace hebench {
23 namespace TestHarness {
24 namespace EltwiseMult {
25 
27 {
28 public:
29  DISABLE_COPY(BenchmarkDescriptorCategory)
30  DISABLE_MOVE(BenchmarkDescriptorCategory)
31 private:
32  IL_DECLARE_CLASS_NAME(EltwiseMult::BenchmarkDescriptorCategory)
33 public:
34  static constexpr const char *BaseWorkloadName = "Element-wise Multiplication";
35  static constexpr std::uint64_t WorkloadParameterCount = 1; // number of parameters for this workload
36  static constexpr std::uint64_t OpParameterCount = 2; // number of parameters for this operation
37  static constexpr std::uint64_t OpResultCount = 1; // number of outputs for this operation
39 
40  static std::uint64_t fetchVectorSize(const std::vector<hebench::APIBridge::WorkloadParam> &w_params);
41 
42 public:
44  ~BenchmarkDescriptorCategory() override = default;
45 
46 protected:
48  const std::vector<hebench::APIBridge::WorkloadParam> &w_params) const override;
50  const Engine &engine,
51  const BenchmarkDescription::Backend &backend_desc,
52  const BenchmarkDescription::Configuration &config) const override;
53 };
54 
56 {
57 public:
58  DISABLE_COPY(DataLoader)
59  DISABLE_MOVE(DataLoader)
60 private:
61  IL_DECLARE_CLASS_NAME(EltwiseMult::DataLoader)
62 
63 public:
64  typedef std::shared_ptr<DataLoader> Ptr;
65 
66  static DataLoader::Ptr create(std::uint64_t vector_size,
67  std::uint64_t batch_size_a,
68  std::uint64_t batch_size_b,
70  static DataLoader::Ptr create(std::uint64_t expected_vector_size,
71  std::uint64_t max_batch_size_a,
72  std::uint64_t max_batch_size_b,
74  const std::string &dataset_filename);
75 
76  ~DataLoader() override {}
77 
78 protected:
79  void computeResult(std::vector<hebench::APIBridge::NativeDataBuffer *> &result,
80  const std::uint64_t *param_data_pack_indices,
81  hebench::APIBridge::DataType data_type) override;
82 
83 private:
84  static constexpr std::size_t InputDim0 = 2;
85  static constexpr std::size_t OutputDim0 = 1;
86  std::uint64_t m_vector_size;
87 
88  DataLoader();
89  void init(std::uint64_t vector_size,
90  std::uint64_t batch_size_a,
91  std::uint64_t batch_size_b,
93  void init(std::uint64_t expected_vector_size,
94  std::uint64_t max_batch_size_a,
95  std::uint64_t max_batch_size_b,
97  const std::string &dataset_filename);
98 };
99 
100 } // namespace EltwiseMult
101 } // namespace TestHarness
102 } // namespace hebench
103 
104 #endif // defined _HEBench_Harness_DataGenerator_EltwiseMult_H_0596d40a3cce4b108a81595c50eb286d
static hebench::APIBridge::WorkloadParamType::WorkloadParamType WorkloadParameterType[WorkloadParameterCount]
bool matchBenchmarkDescriptor(const hebench::APIBridge::BenchmarkDescriptor &bench_desc, const std::vector< hebench::APIBridge::WorkloadParam > &w_params) const override
Determines if the represented benchmark can perform the workload described by a specified HEBench ben...
static std::uint64_t fetchVectorSize(const std::vector< hebench::APIBridge::WorkloadParam > &w_params)
void completeWorkloadDescription(WorkloadDescriptionOutput &output, const Engine &engine, const BenchmarkDescription::Backend &backend_desc, const BenchmarkDescription::Configuration &config) const override
Completes the description for the matched benchmark.
static DataLoader::Ptr create(std::uint64_t vector_size, std::uint64_t batch_size_a, std::uint64_t batch_size_b, hebench::APIBridge::DataType data_type)
void computeResult(std::vector< hebench::APIBridge::NativeDataBuffer * > &result, const std::uint64_t *param_data_pack_indices, hebench::APIBridge::DataType data_type) override
Computes result of the operation on the input data given the of the input sample.
Provides boilerplate implementation to common methods of interface IBenchmarkDescription and implemen...
Bundles values that need to be filled by a workload during completeWorkloadDescription().
WorkloadParamType
Defines the possible data types for a workload flexible parameter.
Definition: types.h:303
DataType
Defines data types for a workload.
Definition: types.h:379
Defines a benchmark test.
Definition: types.h:527