8 #include "../include/hebench_eltwisemult.h"
11 namespace TestHarness {
12 namespace EltwiseMult {
35 <<
", but " << w_params.size() <<
"received.";
36 throw std::invalid_argument(IL_LOG_MSG_CLASS(ss.str()));
43 ss <<
"Invalid type for workload parameter " << i
44 <<
". Expected type ID " <<
WorkloadParameterType[i] <<
", but " << w_params[i].data_type <<
" received.";
45 throw std::invalid_argument(IL_LOG_MSG_CLASS(ss.str()));
47 else if (w_params[i].u_param <= 0)
50 ss <<
"Invalid number of elements for vector in workload parameter " << i
51 <<
". Expected positive integer, but " << w_params[i].u_param <<
" received.";
52 throw std::invalid_argument(IL_LOG_MSG_CLASS(ss.str()));
55 retval = w_params.at(0).u_param;
85 const std::vector<hebench::APIBridge::WorkloadParam> &w_params)
const
121 void *result,
const void *a,
const void *b,
122 std::uint64_t elem_count);
129 static void vectorEltwiseMult(T *result,
const T *a,
const T *b, std::uint64_t elem_count)
132 throw std::invalid_argument(IL_LOG_MSG_CLASS(
"Invalid null `result`"));
134 throw std::invalid_argument(IL_LOG_MSG_CLASS(
"Invalid null `a`"));
136 throw std::invalid_argument(IL_LOG_MSG_CLASS(
"Invalid null `b`"));
137 std::transform(a, a + elem_count,
140 std::multiplies<T>());
145 void *result,
const void *a,
const void *b,
146 std::uint64_t elem_count)
151 vectorEltwiseMult<std::int32_t>(
reinterpret_cast<std::int32_t *
>(result),
152 reinterpret_cast<const std::int32_t *
>(a),
reinterpret_cast<const std::int32_t *
>(b),
157 vectorEltwiseMult<std::int64_t>(
reinterpret_cast<std::int64_t *
>(result),
158 reinterpret_cast<const std::int64_t *
>(a),
reinterpret_cast<const std::int64_t *
>(b),
163 vectorEltwiseMult<float>(
reinterpret_cast<float *
>(result),
164 reinterpret_cast<const float *
>(a),
reinterpret_cast<const float *
>(b),
169 vectorEltwiseMult<double>(
reinterpret_cast<double *
>(result),
170 reinterpret_cast<const double *
>(a),
reinterpret_cast<const double *
>(b),
175 throw std::invalid_argument(IL_LOG_MSG_CLASS(
"Unknown data type."));
185 std::uint64_t batch_size_a,
186 std::uint64_t batch_size_b,
190 retval->init(vector_size, batch_size_a, batch_size_b, data_type);
195 std::uint64_t batch_size_a,
196 std::uint64_t batch_size_b,
198 const std::string &dataset_filename)
201 retval->init(vector_size, batch_size_a, batch_size_b, data_type, dataset_filename);
205 DataLoader::DataLoader() :
210 void DataLoader::init(std::uint64_t vector_size,
211 std::uint64_t batch_size_a,
212 std::uint64_t batch_size_b,
219 std::size_t batch_sizes[InputDim0 + OutputDim0] = {
222 batch_size_a * batch_size_b
226 std::vector<std::uint64_t> sample_vector_sizes(InputDim0 + OutputDim0, vector_size);
227 m_vector_size = vector_size;
232 sample_vector_sizes.data(),
234 sample_vector_sizes.data() + InputDim0,
242 for (std::size_t vector_i = 0; vector_i < InputDim0; ++vector_i)
244 for (std::uint64_t i = 0; i < batch_sizes[vector_i]; ++i)
249 vector_size, -10.0, 10.0);
255 for (std::uint64_t a_i = 0; a_i < batch_sizes[0]; ++a_i)
257 for (std::uint64_t b_i = 0; b_i < batch_sizes[1]; ++b_i)
260 std::uint64_t ppi[] = { a_i, b_i };
275 void DataLoader::init(std::uint64_t expected_vector_size,
276 std::uint64_t max_batch_size_a,
277 std::uint64_t max_batch_size_b,
279 const std::string &dataset_filename)
285 std::size_t batch_sizes[InputDim0 + OutputDim0] = {
288 max_batch_size_a * max_batch_size_b
292 std::vector<std::uint64_t> sample_vector_sizes(InputDim0 + OutputDim0, expected_vector_size);
293 m_vector_size = expected_vector_size;
298 sample_vector_sizes.data(),
300 sample_vector_sizes.data() + InputDim0);
307 const std::uint64_t *param_data_pack_indices,
315 this->getParameterData(0).p_buffers[param_data_pack_indices[0]].p,
316 this->getParameterData(1).p_buffers[param_data_pack_indices[1]].p,
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 generateRandomVectorU(hebench::APIBridge::DataType data_type, void *result, std::uint64_t elem_count, double min_val, double max_val)
Generates uniform random data of the specified type.
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 constexpr const char * BaseWorkloadName
static constexpr std::uint64_t OpParameterCount
static std::uint64_t fetchVectorSize(const std::vector< hebench::APIBridge::WorkloadParam > &w_params)
static constexpr std::uint64_t WorkloadParameterCount
static constexpr std::uint64_t OpResultCount
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 helper class to generate vector data for all supported data types.
static void vectorEltwiseMult(hebench::APIBridge::DataType data_type, void *result, const void *a, const void *b, std::uint64_t elem_count)
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.
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.
VectorSize EltwiseMultiply