39 #include <unordered_map> 41 #include <sys/types.h> 86 typedef std::unordered_map <std::string, param *>
value_map;
94 inst_t get_type () {
return type; }
95 std::string get_key() {
return key; }
98 const std::string key;
110 int_val (
const std::string &k,
int v);
112 int get_val () {
return val; }
113 void update_val (
int v) { val = v; };
114 int *get_addr () {
return &val; }
123 dbl_val (
const std::string &k,
double v);
125 double get_val () {
return val; }
126 void update_val (
double v) { val = v; };
127 double *get_addr () {
return &val; }
136 str_val (
const std::string &k,
const std::string &v);
138 std::string get_val () {
return val; }
139 void update_val (std::string v) { val = v; };
140 std::string *get_addr () {
return &val; }
154 node (
const std::string &k);
158 void add_item (
param *p);
162 void add_items (std::vector<param *> items);
166 param *get_item(
const std::string &k);
170 void remove_item (
const std::string &k);
179 int getint(
const std::string &key);
181 double getdbl(
const std::string &key);
182 double getdbl(
int i);
183 std::string getstr(
const std::string &key);
184 std::string getstr(
int i);
198 T
get (node *n,
const std::string &k)
202 return static_cast<T
>(tmp);
206 #define GETINT(dest, src, key) \ 207 inst::int_val *dest = static_cast<inst::int_val *>((src)->get_item (key)) 209 #define GETDBL(dest, src, key) \ 210 inst::dbl_val *dest = static_cast<inst::dbl_val *>((src)->get_item (key)) 212 #define GETSTR(dest, src, key) \ 213 inst::str_val *dest = static_cast<inst::str_val *>((src)->get_item (key)) 215 #define GETNODE(dest, src, key) \ 216 inst::node *dest = static_cast<inst::node *>((src)->get_item (key)) 232 enum class pt: char {
312 const std::string m_name;
329 template <
typename T>
341 if (options->size() == 0)
342 throw std::invalid_argument(
"Empty value list is invalid");
343 m_options = *options;
355 if (options->size() == 0)
356 throw std::invalid_argument(
"Empty value list is invalid");
357 m_options = *options;
369 if (options->size() == 0)
370 throw std::invalid_argument(
"Empty value list is invalid");
371 m_options = *options;
386 return m_options.size();
397 get(
long unsigned int i)
399 if (i < 0 || i > m_options.size())
400 throw "Out of range";
410 return get(dist(generator));
421 generator = std::mt19937 (rd ());
422 uint u = m_options.size() - 1;
424 dist = std::uniform_int_distribution<int> (0, u);
427 std::vector<T> m_options;
430 std::random_device rd;
431 std::mt19937 generator;
432 std::uniform_int_distribution<int> dist;
453 choice (std::string n, sspace_t *options);
465 long unsigned int count ();
473 param_t *
get (
long unsigned int i);
496 randint (std::string n,
int lower,
int upper);
512 std::random_device rd;
513 std::mt19937 generator;
514 std::uniform_int_distribution<int> dist;
532 uniform (std::string n,
double lower,
double upper);
541 uniform (std::string n,
double lower,
double upper,
pt type);
552 virtual double sample();
558 std::random_device rd;
559 std::mt19937 generator;
560 std::uniform_real_distribution<double> dist;
582 quniform (std::string n,
double lower,
double upper,
double q);
619 loguniform (std::string n,
double lower,
double upper);
625 loguniform (std::string n,
double lower,
double upper,
pt t);
658 qloguniform (std::string n,
double lower,
double upper,
double q);
689 normal (std::string n,
double mu,
double sigma);
695 normal (std::string n,
double mu,
double sigma,
pt t);
705 virtual double sample ();
711 std::random_device rd;
712 std::mt19937 generator;
713 std::normal_distribution<double> dist;
730 qnormal (std::string n,
double mu,
double sigma,
double q);
756 lognormal (std::string n,
double mu,
double sigma);
761 lognormal (std::string n,
double mu,
double sigma,
pt t);
789 qlognormal (std::string n,
double mu,
double sigma,
double q);
virtual pt get_type()
Definition: types.hpp:296
int threads
Max number of iterations to run per benchmark.
Definition: types.hpp:50
Definition: types.hpp:134
std::vector< param_t * > sspace_t
Definition: types.hpp:318
Definition: types.hpp:150
value_map * get_values()
Definition: types.hpp:176
Definition: types.hpp:278
T sample()
Definition: types.hpp:408
Definition: types.hpp:274
pt
Definition: types.hpp:232
Definition: types.hpp:330
virtual ~param_t()
Definition: types.hpp:289
categorical(std::string n, std::vector< std::string > *options)
Definition: types.hpp:366
inst_t
Definition: types.hpp:63
void init_rand()
Definition: types.hpp:419
uint max_iters
The name of the output file.
Definition: types.hpp:49
int m_lower
Definition: types.hpp:509
value_map values
Definition: types.hpp:189
Definition: types.hpp:445
void free_ss(sspace_t *ss)
Definition: types.cpp:654
bool error
The number of threads to use.
Definition: types.hpp:51
categorical(std::string n, std::vector< double > *options)
Definition: types.hpp:352
virtual std::string get_name()
Definition: types.hpp:306
void validate_param_values(inst::value_map *vals, sspace::sspace_t *sspace)
Definition: types.cpp:604
void free_node(node *n)
Definition: types.cpp:122
sspace_t * m_options
Definition: types.hpp:478
std::vector< T > * values()
Definition: types.hpp:377
Definition: types.hpp:121
double m_mu
Definition: types.hpp:708
Definition: types.hpp:487
Definition: types.hpp:748
param * get_item(const std::string &k)
Definition: types.cpp:91
Definition: types.hpp:721
Definition: types.hpp:780
Definition: types.hpp:108
Definition: types.hpp:680
std::unordered_map< std::string, param * > value_map
Definition: types.hpp:86
long unsigned int count()
Definition: types.hpp:384
categorical(std::string n, std::vector< int > *options)
Definition: types.hpp:338