14 #include "hebench/modules/timer/include/timer.h"
17 #include "hebench/modules/general/include/hebench_math_utils.h"
20 #include "../include/hebench_genericwl_l.h"
23 namespace TestHarness {
31 bool BenchmarkDescriptor::m_b_registered =
35 const std::vector<hebench::APIBridge::WorkloadParam> &w_params)
const
37 assert(m_b_registered);
59 const std::vector<std::uint64_t> &input_sizes = op_info.first;
60 const std::vector<std::uint64_t> &output_sizes = op_info.second;
69 std::uint64_t result_batch_size = 1;
70 for (std::size_t param_i = 0; param_i < batch_sizes.size(); ++param_i)
73 result_batch_size *= batch_sizes[param_i];
77 for (std::size_t i = 1; i < output_sizes.size(); ++i)
78 ss <<
"; C[" << i <<
"]";
80 for (std::size_t i = 1; i < input_sizes.size(); ++i)
81 ss <<
"; V[" << i <<
"]";
82 ss <<
")" << std::endl
83 <<
", , , Elements, Batch size" << std::endl;
86 ss <<
", , V[" << i <<
"], " << input_sizes[i] <<
", " << batch_sizes[i] << std::endl;
88 for (std::size_t i = 0; i < output_sizes.size(); ++i)
90 ss <<
", , C[" << i <<
"], " << output_sizes[i] <<
", " << result_batch_size << std::endl;
99 assert(m_b_registered);
104 retval =
new Benchmark(p_engine, description_token);
118 assert(m_b_registered);
127 Benchmark::Benchmark(std::shared_ptr<Engine> p_engine,
137 hebench::Common::EventTimer timer;
138 hebench::Common::TimingReportEvent::Ptr p_timing_event;
139 std::vector<std::uint64_t> batch_sizes;
140 std::stringstream ss;
142 const std::vector<std::uint64_t> &input_sizes = op_info.first;
143 const std::vector<std::uint64_t> &output_sizes = op_info.second;
145 m_op_input_count = input_sizes.size();
146 m_op_output_count = output_sizes.size();
147 batch_sizes.resize(m_op_input_count);
149 for (std::size_t param_i = 0; param_i < batch_sizes.size(); ++param_i)
152 std::cout <<
IOS_MSG_INFO << hebench::Logging::GlobalLogger::log(
"Preparing workload.") << std::endl;
156 throw std::invalid_argument(IL_LOG_MSG_CLASS(
"Dataset file is required for generic workload benchmarking, but none was provided."));
158 ss = std::stringstream();
159 ss <<
"Loading data from external dataset: " << std::endl
161 std::cout <<
IOS_MSG_INFO << hebench::Logging::GlobalLogger::log(ss.str()) << std::endl;
168 this->getBenchmarkConfiguration().dataset_filename);
169 p_timing_event = timer.stop<std::milli>();
171 ss = std::stringstream();
172 ss <<
"Total data loaded: " << m_data->getTotalDataLoaded() <<
" bytes";
173 std::cout <<
IOS_MSG_DONE << hebench::Logging::GlobalLogger::log(ss.str()) << std::endl;
174 ss = std::stringstream();
175 ss <<
"Elapsed wall time: " << p_timing_event->elapsedWallTime<std::milli>() <<
" ms";
176 std::cout <<
IOS_MSG_INFO << hebench::Logging::GlobalLogger::log(ss.str()) << std::endl;
177 ss = std::stringstream();
178 ss <<
"Elapsed CPU time: " << p_timing_event->elapsedCPUTime<std::milli>() <<
" ms";
179 std::cout <<
IOS_MSG_INFO << hebench::Logging::GlobalLogger::log(ss.str()) << std::endl;
183 const std::uint64_t *param_data_pack_indices,
184 const std::vector<hebench::APIBridge::NativeDataBuffer *> &outputs,
187 assert(dataset->getParameterCount() == m_op_input_count
188 && dataset->getResultCount() == m_op_output_count);
Specifies a benchmark configuration.
std::vector< hebench::APIBridge::WorkloadParam > w_params
Set of arguments for workload parameters.
std::string dataset_filename
File containing data for the benchmark. If empty string, benchmarks that can auto generate the datase...
static bool registerSupportedBenchmark(std::shared_ptr< IBenchmarkDescriptor > p_desc_obj)
Registers a benchmark description object that represents one of the supported workloads.
Base class for workload benchmarks in the latency category.
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::pair< std::vector< std::uint64_t >, std::vector< std::uint64_t > > fetchIOVectorSizes(const std::vector< hebench::APIBridge::WorkloadParam > &w_params)
Retrieves details about the input parameters and results of the generic operation based on the specif...
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 DataLoader::Ptr create(const std::vector< std::uint64_t > &input_sizes, const std::vector< std::uint64_t > &max_batch_sizes, const std::vector< std::uint64_t > &output_sizes, hebench::APIBridge::DataType data_type, const std::string &dataset_filename)
hebench::TestHarness::PartialBenchmark * createBenchmark(std::shared_ptr< Engine > p_engine, const DescriptionToken &description_token) override
Creates the represented IBenchmark object that can perform the workload specified by the HEBench benc...
static constexpr std::uint64_t DefaultBatchSize
void destroyBenchmark(hebench::TestHarness::PartialBenchmark *p_bench) override
Destroys an object returned by createBenchmark().
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.
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...
bool validateResult(IDataLoader::Ptr dataset, const std::uint64_t *param_data_pack_indices, const std::vector< hebench::APIBridge::NativeDataBuffer * > &p_outputs, hebench::APIBridge::DataType data_type) const override
Validates the result of an operation against the ground truth.
void init() override
Initializes the partial benchmark members.
Token returned by a successful call to IBenchmarkDescriptor::matchBenchmarkDescriptor().
std::shared_ptr< IDataLoader > Ptr
virtual bool validateResult(IDataLoader::Ptr dataset, const std::uint64_t *param_data_pack_indices, const std::vector< hebench::APIBridge::NativeDataBuffer * > &outputs, hebench::APIBridge::DataType data_type) const
Validates the result of an operation against the ground truth.
std::string workload_header
Workload specific information to be added to the report header.
std::size_t operation_params_count
Number of parameters for the represented workload operation.
Bundles values that need to be filled by a workload during completeWorkloadDescription().
Base class for benchmarks.
const BenchmarkDescription::Backend & getBackendDescription() const
Allows read-only access to this benchmark backend description.
const BenchmarkDescription::Configuration & getBenchmarkConfiguration() const
Allows read-only access to this benchmark configuration.
DataType
Defines data types for a workload.
Category category
Category for the benchmark.
Defines a benchmark test.