HEBench
hebench_matmult.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_MatrixMultiply_H_0596d40a3cce4b108a81595c50eb286d
6 #define _HEBench_Harness_DataGenerator_MatrixMultiply_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 MatrixMultiply {
25 
27 {
28 public:
29  DISABLE_COPY(BenchmarkDescriptorCategory)
30  DISABLE_MOVE(BenchmarkDescriptorCategory)
31 private:
32  IL_DECLARE_CLASS_NAME(MatrixMultiply::BenchmarkDescriptorCategory)
33 public:
34  static constexpr const char *BaseWorkloadName = "Matrix Multiplication";
35  static constexpr std::uint64_t WorkloadParameterCount = 3; // 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 
46  static std::array<std::pair<std::uint64_t, std::uint64_t>, OpParameterCount>
47  fetchMatrixSizes(const std::vector<hebench::APIBridge::WorkloadParam> &w_params);
48 
49 public:
51  ~BenchmarkDescriptorCategory() override = default;
52 
53 protected:
55  const std::vector<hebench::APIBridge::WorkloadParam> &w_params) const override;
57  const Engine &engine,
58  const BenchmarkDescription::Backend &backend_desc,
59  const BenchmarkDescription::Configuration &config) const override;
60 };
61 
63 {
64 public:
65  DISABLE_COPY(DataLoader)
66  DISABLE_MOVE(DataLoader)
67 private:
68  IL_DECLARE_CLASS_NAME(MatrixMultiply::DataLoader)
69 
70 public:
71  typedef std::shared_ptr<DataLoader> Ptr;
72 
73  static DataLoader::Ptr create(std::uint64_t rows_a, std::uint64_t cols_a, std::uint64_t cols_b,
74  std::uint64_t batch_size_mat_a,
75  std::uint64_t batch_size_mat_b,
77  static DataLoader::Ptr create(std::uint64_t rows_a, std::uint64_t cols_a, std::uint64_t cols_b,
78  std::uint64_t expected_sample_size_mat_a,
79  std::uint64_t expected_sample_size_mat_b,
81  const std::string &dataset_filename);
82 
83  ~DataLoader() override {}
84 
85 protected:
86  void computeResult(std::vector<hebench::APIBridge::NativeDataBuffer *> &result,
87  const std::uint64_t *param_data_pack_indices,
88  hebench::APIBridge::DataType data_type) override;
89 
90 private:
91  static constexpr std::size_t InputDim0 = 2;
92  static constexpr std::size_t OutputDim0 = 1;
93  std::uint64_t m_rows_a;
94  std::uint64_t m_cols_a;
95  std::uint64_t m_cols_b;
96 
97  DataLoader();
98  void init(std::uint64_t rows_a, std::uint64_t cols_a, std::uint64_t cols_b,
99  std::uint64_t batch_size_mat_a,
100  std::uint64_t batch_size_mat_b,
101  hebench::APIBridge::DataType data_type);
102  void init(std::uint64_t rows_a, std::uint64_t cols_a, std::uint64_t cols_b,
103  std::uint64_t expected_sample_size_mat_a,
104  std::uint64_t expected_sample_size_mat_b,
106  const std::string &dataset_filename);
107 };
108 
109 } // namespace MatrixMultiply
110 } // namespace TestHarness
111 } // namespace hebench
112 
113 #endif // defined _HEBench_Harness_DataGenerator_MatrixMultiply_H_0596d40a3cce4b108a81595c50eb286d
static std::array< std::pair< std::uint64_t, std::uint64_t >, OpParameterCount > fetchMatrixSizes(const std::vector< hebench::APIBridge::WorkloadParam > &w_params)
fetchMatrixSizes
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...
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 hebench::APIBridge::WorkloadParamType::WorkloadParamType WorkloadParameterType[WorkloadParameterCount]
static DataLoader::Ptr create(std::uint64_t rows_a, std::uint64_t cols_a, std::uint64_t cols_b, std::uint64_t batch_size_mat_a, std::uint64_t batch_size_mat_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