5 #ifndef _HEBench_API_Bridge_WorkloadParamsCPP_H_7e5fa8c2415240ea93eff148ed73539b
6 #define _HEBench_API_Bridge_WorkloadParamsCPP_H_7e5fa8c2415240ea93eff148ed73539b
17 namespace WorkloadParams {
38 Common(
const std::vector<hebench::APIBridge::WorkloadParam> &w_params) :
43 m_w_params(w_params.params, w_params.params + w_params.count)
54 void add(
const T &value,
const std::string &name = std::string());
63 void set(std::size_t index,
const T &value,
const std::string &name);
71 void set(std::size_t index,
const T &value);
80 const T &
get(std::size_t index)
const;
86 std::vector<hebench::APIBridge::WorkloadParam>
m_w_params;
96 inline void Common::add<std::int64_t>(
const std::int64_t &value,
const std::string &name)
102 w_param.i_param = value;
107 inline void Common::set<std::int64_t>(std::size_t index,
const std::int64_t &value,
const std::string &name)
112 w_param.i_param = value;
117 inline void Common::set<std::int64_t>(std::size_t index,
const std::int64_t &value)
122 w_param.i_param = value;
126 inline const std::int64_t &Common::get<std::int64_t>(std::size_t index)
const
128 return m_w_params.at(index).i_param;
134 inline void Common::add<std::uint64_t>(
const std::uint64_t &value,
const std::string &name)
140 w_param.u_param = value;
145 inline void Common::set<std::uint64_t>(std::size_t index,
const std::uint64_t &value,
const std::string &name)
150 w_param.u_param = value;
155 inline void Common::set<std::uint64_t>(std::size_t index,
const std::uint64_t &value)
160 w_param.u_param = value;
164 inline const std::uint64_t &Common::get<std::uint64_t>(std::size_t index)
const
166 return m_w_params.at(index).u_param;
172 inline void Common::add<double>(
const double &value,
const std::string &name)
178 w_param.f_param = value;
183 inline void Common::set<double>(std::size_t index,
const double &value,
const std::string &name)
188 w_param.f_param = value;
193 inline void Common::set<double>(std::size_t index,
const double &value)
198 w_param.f_param = value;
202 inline const double &Common::get<double>(std::size_t index)
const
255 MatrixMultiply(std::uint64_t _rows_M0 = 0, std::uint64_t _cols_M0 = 0, std::uint64_t _cols_M1 = 0) :
258 this->set<std::uint64_t>(
Index_RowsM0, _rows_M0,
"rows_M0");
259 this->set<std::uint64_t>(
Index_ColsM0, _cols_M0,
"cols_M0");
260 this->set<std::uint64_t>(
Index_ColsM1, _cols_M1,
"cols_M1");
299 void validateParams()
const
305 throw std::logic_error(
"Data type for workload parameter " +
std::to_string(i) +
" must be WorkloadParamType::UInt64.");
321 std::uint64_t
n()
const {
return get<std::uint64_t>(
Index_N); }
336 this->set<std::uint64_t>(
Index_N, _n,
"n");
351 VectorSize(
const std::vector<hebench::APIBridge::WorkloadParam> &w_params) :
376 void validateParams()
const
382 throw std::logic_error(
"Data type for workload parameter " +
std::to_string(i) +
" must be WorkloadParamType::UInt64.");
402 const std::uint64_t &
n()
const {
return get<std::uint64_t>(
Index_N); }
406 const std::uint64_t &
m()
const {
return get<std::uint64_t>(
Index_M); }
414 throw std::out_of_range(std::string(__func__) +
": Index out of range; "
416 return get<std::uint64_t>(index + 2);
425 throw std::out_of_range(std::string(__func__) +
": Index out of range; "
436 throw std::out_of_range(std::string(__func__) +
": Index out of range; "
438 return get<std::uint64_t>(index +
n() + 2);
447 throw std::out_of_range(std::string(__func__) +
": Index out of range; "
466 Generic(std::uint64_t _n = 1, std::uint64_t _m = 1) :
469 this->set<std::uint64_t>(
Index_N, _n,
"n");
470 this->set<std::uint64_t>(
Index_M, _m,
"m");
471 for (std::size_t i = 0; i < _n; ++i)
472 set<std::uint64_t>(2 + i, 1,
"length_InputParam" +
std::to_string(i));
473 for (std::size_t i = 0; i < _m; ++i)
474 set<std::uint64_t>(2 + _n + i, 1,
"length_ResultComponent" +
std::to_string(i));
490 Generic(
const std::vector<hebench::APIBridge::WorkloadParam> &w_params) :
516 void validateParams()
const
518 const std::size_t MinRequiredParameters =
n() +
m() + 2;
519 if (
m_w_params.size() < MinRequiredParameters)
520 throw std::out_of_range(
"Workload requires, at least, " +
std::to_string(MinRequiredParameters) +
" parameters.");
521 for (std::size_t i = 0; i < MinRequiredParameters; ++i)
523 throw std::logic_error(
"Data type for workload parameter " +
std::to_string(i) +
" must be WorkloadParamType::UInt64.");
541 std::uint64_t
n()
const {
return get<std::uint64_t>(
Index_N); }
549 std::uint64_t
m()
const {
return get<std::uint64_t>(
Index_M); }
557 std::uint64_t
k()
const {
return get<std::uint64_t>(
Index_K); }
574 this->set<std::uint64_t>(
Index_N, _n,
"n");
575 this->set<std::uint64_t>(
Index_M, _m,
"m");
576 this->set<std::uint64_t>(
Index_K, _k,
"k");
615 void validateParams()
const
621 throw std::logic_error(
"Data type for workload parameter " +
std::to_string(i) +
" must be WorkloadParamType::UInt64.");
Base wrapper around the flexible workload parameters.
Common(const hebench::APIBridge::WorkloadParams &w_params)
std::vector< hebench::APIBridge::WorkloadParam > m_w_params
void set(std::size_t index, const T &value, const std::string &name)
Sets a new value for an existing workload parameter.
void add(const T &value, const std::string &name=std::string())
Adds a new workload parameter to the list.
Common(const std::vector< hebench::APIBridge::WorkloadParam > &w_params)
Common(std::size_t num_params=0)
const std::vector< hebench::APIBridge::WorkloadParam > & getParams() const
const T & get(std::size_t index) const
Retrieves the value for an existing workload parameter.
virtual ~Common()=default
const char * getName(std::size_t index) const
void set(std::size_t index, const T &value)
Sets a new value for an existing workload parameter.
Wraps around flexible workload parameters required for a generic workload.
std::uint64_t & length_ResultComponent(std::size_t index)
Number of elements in output vector at specified result index.
std::uint64_t & length_InputParam(std::size_t index)
Number of elements in input vector at specified input index.
Generic(const hebench::APIBridge::WorkloadParams &w_params)
Initializes workload parameters for a generic workload from a list of existing workload parameters.
const std::uint64_t & m() const
Number of outputs from the operation.
Generic(std::uint64_t _n=1, std::uint64_t _m=1)
Initializes a new object to represent workload parameters for a generic workload.
std::uint64_t length_ResultComponent(std::size_t index) const
Number of elements in output vector at specified result index.
std::uint64_t length_InputParam(std::size_t index) const
Number of components in input vector at specified input index.
const std::uint64_t & n() const
Number of inputs to the operation.
Generic(const std::vector< hebench::APIBridge::WorkloadParam > &w_params)
Initializes workload parameters for a generic workload from a list of existing workload parameters.
MatrixMultiply(const hebench::APIBridge::WorkloadParams &w_params)
Initializes workload parameters for matrix multiplication from a list of existing workload parameters...
std::uint64_t & cols_M0()
Number of columns in matrix M0 and rows in matrix M1.
std::uint64_t & cols_M1()
Number of columns in matrix M1.
MatrixMultiply(std::uint64_t _rows_M0=0, std::uint64_t _cols_M0=0, std::uint64_t _cols_M1=0)
Initializes a new object to represent workload parameters for matrix multiplication workload.
std::uint64_t & rows_M0()
Number of rows in matrix M0.
std::uint64_t cols_M0() const
Number of columns in matrix M0 and rows in matrix M1.
MatrixMultiply(const std::vector< hebench::APIBridge::WorkloadParam > &w_params)
Initializes workload parameters for matrix multiplication from a list of existing workload parameters...
std::uint64_t cols_M1() const
Number of columns in matrix M1.
std::uint64_t rows_M0() const
Number of rows in matrix M0.
SimpleSetIntersection(std::uint64_t _n=0, std::uint64_t _m=0, std::uint64_t _k=1)
Initializes a new object to represent workload parameters for simple set intersection.
std::uint64_t k() const
Number of items per element.
SimpleSetIntersection(const std::vector< hebench::APIBridge::WorkloadParam > &w_params)
Initializes workload parameters for simple set intersection from a list of existing workload paramete...
std::uint64_t m() const
Number of elements in set B.
std::uint64_t n() const
Number of elements in set A.
std::uint64_t & m()
Number of elements in set B.
std::uint64_t & n()
Number of elements in set A.
SimpleSetIntersection(const hebench::APIBridge::WorkloadParams &w_params)
Initializes workload parameters for simple set intersection from a list of existing workload paramete...
std::uint64_t & k()
Number of items per element.
VectorSize(std::uint64_t _n=0)
Initializes a new object to represent workload parameters for a workload requiring a vector size.
VectorSize(const std::vector< hebench::APIBridge::WorkloadParam > &w_params)
Initializes workload parameters for a workload requiring a vector size from a list of existing worklo...
std::uint64_t & n()
Number elements in a vector.
std::uint64_t n() const
Number elements in a vector.
VectorSize(const hebench::APIBridge::WorkloadParams &w_params)
Initializes workload parameters for a workload requiring a vector size from a list of existing worklo...
@ Float64
64 bits IEEE 754 standard floating point real numbers.
@ Int64
64 bits signed integers.
@ UInt64
64 bits unsigned integers.
char name[HEBENCH_MAX_BUFFER_SIZE]
Null-terminated string containing the name for the parameter.
WorkloadParamType::WorkloadParamType data_type
Type of the parameter data.
Defines a single workload parameter.
Specifies the parameters for a workload.
std::string to_string(const std::string_view &s)
std::uint64_t copyString(char *dst, std::uint64_t size, const std::string &src)
Copies a C++ string object into a C-style string.
VectorSize LogisticRegression
VectorSize EltwiseMultiply
#define HEBENCH_MAX_BUFFER_SIZE