9 #include "../include/hebench_dotproduct.h"
10 #include "hebench/modules/general/include/hebench_math_utils.h"
13 namespace TestHarness {
37 <<
", but " << w_params.size() <<
"received.";
38 throw std::invalid_argument(IL_LOG_MSG_CLASS(ss.str()));
46 ss <<
"Invalid type for workload parameter " << i
47 <<
". Expected type ID " <<
WorkloadParameterType[i] <<
", but " << w_params[i].data_type <<
" received.";
48 throw std::invalid_argument(IL_LOG_MSG_CLASS(ss.str()));
50 else if (w_params[i].u_param <= 0)
53 ss <<
"Invalid number of elements for vector in workload parameter " << i
54 <<
". Expected positive integer, but " << w_params[i].u_param <<
" received.";
55 throw std::invalid_argument(IL_LOG_MSG_CLASS(ss.str()));
58 retval = w_params.at(0).u_param;
88 const std::vector<hebench::APIBridge::WorkloadParam> &w_params)
const
124 void *result,
const void *a,
const void *b,
125 std::uint64_t elem_count);
132 static void vectorDotProduct(T &result,
const T *a,
const T *b, std::uint64_t elem_count)
135 throw std::invalid_argument(IL_LOG_MSG_CLASS(
"Invalid null `a`"));
137 throw std::invalid_argument(IL_LOG_MSG_CLASS(
"Invalid null `b`"));
138 result = std::inner_product(a, a + elem_count, b, T());
143 void *result,
const void *a,
const void *b,
144 std::uint64_t elem_count)
147 throw std::invalid_argument(IL_LOG_MSG_CLASS(
"Invalid null 'p_result'."));
152 vectorDotProduct<std::int32_t>(*
reinterpret_cast<std::int32_t *
>(result),
153 reinterpret_cast<const std::int32_t *
>(a),
reinterpret_cast<const std::int32_t *
>(b),
158 vectorDotProduct<std::int64_t>(*
reinterpret_cast<std::int64_t *
>(result),
159 reinterpret_cast<const std::int64_t *
>(a),
reinterpret_cast<const std::int64_t *
>(b),
164 vectorDotProduct<float>(*
reinterpret_cast<float *
>(result),
165 reinterpret_cast<const float *
>(a),
reinterpret_cast<const float *
>(b),
170 vectorDotProduct<double>(*
reinterpret_cast<double *
>(result),
171 reinterpret_cast<const double *
>(a),
reinterpret_cast<const double *
>(b),
176 throw std::invalid_argument(IL_LOG_MSG_CLASS(
"Unknown data type."));
186 std::uint64_t batch_size_a,
187 std::uint64_t batch_size_b,
191 retval->init(vector_size, batch_size_a, batch_size_b, data_type);
196 std::uint64_t batch_size_a,
197 std::uint64_t batch_size_b,
199 const std::string &dataset_filename)
202 retval->init(vector_size, batch_size_a, batch_size_b, data_type, dataset_filename);
206 DataLoader::DataLoader() :
211 void DataLoader::init(std::uint64_t vector_size,
212 std::uint64_t batch_size_a,
213 std::uint64_t batch_size_b,
220 std::size_t batch_sizes[InputDim0 + OutputDim0] = {
223 batch_size_a * batch_size_b
226 m_vector_size = vector_size;
229 std::uint64_t sample_vector_sizes[InputDim0 + OutputDim0];
231 for (std::size_t i = 0; i < InputDim0; ++i)
233 sample_vector_sizes[i] = vector_size;
236 for (std::size_t i = InputDim0; i < InputDim0 + OutputDim0; ++i)
239 sample_vector_sizes[i] = 1;
244 InputDim0, batch_sizes, sample_vector_sizes,
245 OutputDim0, sample_vector_sizes + InputDim0,
253 for (std::size_t vector_i = 0; vector_i < InputDim0; ++vector_i)
255 for (std::uint64_t i = 0; i < batch_sizes[vector_i]; ++i)
260 vector_size, 0.0, 10.0);
266 for (std::uint64_t a_i = 0; a_i < batch_sizes[0]; ++a_i)
268 for (std::uint64_t b_i = 0; b_i < batch_sizes[1]; ++b_i)
271 std::uint64_t ppi[] = { a_i, b_i };
286 void DataLoader::init(std::uint64_t vector_size,
287 std::uint64_t batch_size_a,
288 std::uint64_t batch_size_b,
290 const std::string &dataset_filename)
296 std::size_t batch_sizes[InputDim0 + OutputDim0] = {
299 batch_size_a * batch_size_b
302 m_vector_size = vector_size;
305 std::uint64_t sample_vector_sizes[InputDim0 + OutputDim0];
307 for (std::size_t i = 0; i < InputDim0; ++i)
309 sample_vector_sizes[i] = vector_size;
312 for (std::size_t i = InputDim0; i < InputDim0 + OutputDim0; ++i)
315 sample_vector_sizes[i] = 1;
320 InputDim0, batch_sizes, sample_vector_sizes,
321 OutputDim0, sample_vector_sizes + InputDim0);
328 const std::uint64_t *param_data_pack_indices,
const hebench::APIBridge::BenchmarkDescriptor & descriptor
Benchmark backend descriptor, as retrieved by backend, corresponding to the registration handle h_des...
Specifies a benchmark configuration.
std::vector< hebench::APIBridge::WorkloadParam > w_params
Set of arguments for workload parameters.
Static helper class to generate vector data for all supported data types.
static void generateRandomVectorN(hebench::APIBridge::DataType data_type, void *result, std::uint64_t elem_count, double mean, double stddev)
Generates normally distributed random data of the specified type.
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 constexpr std::uint64_t OpResultCount
static constexpr std::uint64_t OpParameterCount
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
static std::uint64_t fetchVectorSize(const std::vector< hebench::APIBridge::WorkloadParam > &w_params)
static hebench::APIBridge::WorkloadParamType::WorkloadParamType WorkloadParameterType[WorkloadParameterCount]
Static helper class to generate vector data for all supported data types.
static void vectorDotProduct(hebench::APIBridge::DataType data_type, void *result, const void *a, const void *b, std::uint64_t elem_count)
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 vector_size, std::uint64_t batch_size_a, std::uint64_t batch_size_b, hebench::APIBridge::DataType data_type)
std::shared_ptr< DataLoader > Ptr
static void completeCategoryParams(hebench::APIBridge::BenchmarkDescriptor &out_descriptor, const hebench::APIBridge::BenchmarkDescriptor &in_descriptor, const BenchmarkDescription::Configuration &config, bool force_config)
Completes common elements of category parameters in a descriptor using the specified configuration.
static bool getForceConfigValues()
Specifies whether frontend will override backend descriptors using configuration data or not.
std::size_t operation_params_count
Number of parameters for the represented workload operation.
std::string workload_name
Human-readable friendly name for the represented workload to be used for its description on the repor...
hebench::APIBridge::BenchmarkDescriptor concrete_descriptor
Benchmark descriptor completed with concrete values assigned to configurable fields.
std::string workload_base_name
Human-readable friendly name for the represented workload to be used for its description on the repor...
Bundles values that need to be filled by a workload during completeWorkloadDescription().
const hebench::APIBridge::DataPack & getResultData(std::uint64_t param_position) const override
Data pack corresponding to the specified component of the result.
const hebench::APIBridge::DataPack & getParameterData(std::uint64_t param_position) const override
Data pack for specified operation parameter (operand).
void init(hebench::APIBridge::DataType data_type, std::size_t input_dim, const std::size_t *input_sample_count_per_dim, const std::uint64_t *input_count_per_dim, std::size_t output_dim, const std::uint64_t *output_count_per_dim, bool allocate_output)
Initializes dimensions of inputs and outputs. No allocation is performed.
std::uint64_t getResultIndex(const std::uint64_t *param_data_pack_indices) const override
Computes the index of the result NativeDataBuffer given the indices of the input data.
WorkloadParamType
Defines the possible data types for a workload flexible parameter.
@ Float64
64 bits IEEE 754 standard floating point real numbers.
@ Int64
64 bits signed integers.
@ UInt64
64 bits unsigned integers.
DataType
Defines data types for a workload.
@ Float32
32 bits IEEE 754 standard floating point real numbers.
@ Int32
32 bits signed integers.
Workload workload
Workload for the benchmark.
Defines a benchmark test.