5 #ifndef _HEBench_Harness_DataGenerator_DotProduct_H_0596d40a3cce4b108a81595c50eb286d
6 #define _HEBench_Harness_DataGenerator_DotProduct_H_0596d40a3cce4b108a81595c50eb286d
15 #include "hebench/modules/general/include/hebench_math_utils.h"
16 #include "hebench/modules/general/include/nocopy.h"
17 #include "hebench/modules/logging/include/logging.h"
25 namespace TestHarness {
42 static std::array<std::uint64_t, BenchmarkDescriptorCategory::WorkloadParameterCount>
fetchSetSize(
const std::vector<hebench::APIBridge::WorkloadParam> &w_params);
50 const std::vector<hebench::APIBridge::WorkloadParam> &w_params)
const override;
66 typedef std::shared_ptr<DataLoader>
Ptr;
69 std::uint64_t set_size_y,
70 std::uint64_t batch_size_x,
71 std::uint64_t batch_size_y,
72 std::uint64_t element_size_k,
75 std::uint64_t set_size_y,
76 std::uint64_t batch_size_x,
77 std::uint64_t batch_size_y,
78 std::uint64_t element_size_k,
80 const std::string &dataset_filename);
85 void computeResult(std::vector<hebench::APIBridge::NativeDataBuffer *> &result,
86 const std::uint64_t *param_data_pack_indices,
92 std::uint64_t m_set_size_x;
93 std::uint64_t m_set_size_y;
94 std::uint64_t m_element_size_k;
97 void init(std::uint64_t set_size_x,
98 std::uint64_t set_size_y,
99 std::uint64_t batch_size_x,
100 std::uint64_t batch_size_y,
101 std::uint64_t element_size_k,
103 void init(std::uint64_t set_size_x,
104 std::uint64_t set_size_y,
105 std::uint64_t batch_size_x,
106 std::uint64_t batch_size_y,
107 std::uint64_t element_size_k,
109 const std::string &dataset_filename);
112 template <
typename T>
124 typename std::enable_if<std::is_integral<T>::value
125 || std::is_floating_point<T>::value,
126 std::vector<std::pair<bool, std::uint64_t>>>::type
128 std::uint64_t n, std::uint64_t m, std::uint64_t k,
131 template <
typename T>
142 typename std::enable_if<std::is_integral<T>::value
143 || std::is_floating_point<T>::value,
145 isMemberOf(
const T *dataset,
const T *value, std::size_t n, std::size_t k,
149 const std::uint64_t *param_data_pack_indices,
150 const std::vector<hebench::APIBridge::NativeDataBuffer *> &p_outputs,
151 std::uint64_t k_count,
156 template <
typename T>
157 typename std::enable_if<std::is_integral<T>::value
158 || std::is_floating_point<T>::value,
160 isMemberOf(
const T *dataset,
const T *value, std::size_t n, std::size_t k,
164 for (
size_t i = 0; !retval && i < n; ++i)
166 std::uint64_t members = 0;
168 for (
size_t j = 0; flag && j < k; ++j)
170 flag = hebench::Utilities::Math::almostEqual(dataset[(i * k) + j], value[j], pct);
176 retval = members == k;
181 template <
typename T>
182 typename std::enable_if<std::is_integral<T>::value
183 || std::is_floating_point<T>::value,
184 std::vector<std::pair<bool, std::uint64_t>>>::type
186 std::uint64_t n, std::uint64_t m, std::uint64_t k,
189 std::vector<std::pair<bool, std::uint64_t>> retval;
190 retval.reserve(n + m);
196 for (std::uint64_t i = 0; i < m; ++i)
197 retval.push_back(std::pair(
false, i));
202 for (std::uint64_t i = 0; i < n; ++i)
203 retval.push_back(std::pair(
true, i));
208 for (std::uint64_t i = 0; i < n; ++i)
211 retval.push_back(std::pair(
true, i));
214 for (std::uint64_t i = 0; i < m; ++i)
217 retval.push_back(std::pair(
false, i));
Specifies a benchmark configuration.
std::shared_ptr< IDataLoader > Ptr
Provides boilerplate implementation to common methods of interface IBenchmarkDescription and implemen...
Bundles values that need to be filled by a workload during completeWorkloadDescription().
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 std::array< std::uint64_t, BenchmarkDescriptorCategory::WorkloadParameterCount > fetchSetSize(const std::vector< hebench::APIBridge::WorkloadParam > &w_params)
static constexpr std::uint64_t OpResultCount
static hebench::APIBridge::WorkloadParamType::WorkloadParamType WorkloadParameterType[WorkloadParameterCount]
static constexpr std::uint64_t 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 constexpr const char * BaseWorkloadName
BenchmarkDescriptorCategory()=default
~BenchmarkDescriptorCategory() override=default
static constexpr std::uint64_t OpParameterCount
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.
static DataLoader::Ptr create(std::uint64_t set_size_x, std::uint64_t set_size_y, std::uint64_t batch_size_x, std::uint64_t batch_size_y, std::uint64_t element_size_k, hebench::APIBridge::DataType data_type)
std::shared_ptr< DataLoader > Ptr
WorkloadParamType
Defines the possible data types for a workload flexible parameter.
DataType
Defines data types for a workload.
Defines a benchmark test.
std::enable_if< std::is_integral< T >::value||std::is_floating_point< T >::value, bool >::type isMemberOf(const T *dataset, const T *value, std::size_t n, std::size_t k, double pct=0.05)
Finds whether values in two arrays are within a certain percentage of each other.
bool validateResult(IDataLoader::Ptr dataset, const std::uint64_t *param_data_pack_indices, const std::vector< hebench::APIBridge::NativeDataBuffer * > &p_outputs, std::uint64_t k_count, hebench::APIBridge::DataType data_type)
std::enable_if< std::is_integral< T >::value||std::is_floating_point< T >::value, std::vector< std::pair< bool, std::uint64_t > > >::type almostEqualSet(const T *X, const T *Y, std::uint64_t n, std::uint64_t m, std::uint64_t k, double pct=0.05)
Finds whether values in two arrays are within a certain percentage of each other.