#ifndef PARAMS_H_ #define PARAMS_H_ #include #include "config.h" /* * Holder of all parameter-related stuff for a benchmark. */ class BenchParams { friend class Benchmark; public: /******************************************************************/ /* PUBLIC METHODS */ /******************************************************************/ /* * Default constructor */ BenchParams(); /* * Default destructor */ ~BenchParams(); /* * Initializes parameter values (ranges) from rib.ini */ void initialize (std::map & params, bool plot); /* * Resume current parameter values from rib.resume */ void resume (const std::map & params); /* * Get order of parameter by its name, -1 if not found * (former get_param_depth) */ int getOrder (const std::string param_name); /* * Get current string parameter value by its name * (former get_string_param_current) */ inline std::string currentString (const std::string & param_name) { return ((BenchParameterString *) currentParam(param_name, orderMapString))->value; }; /* * Get current numeric parameter value by its name * (former get_numeric_param_current) */ inline size_t currentNumeric (const std::string & param_name) { return ((BenchParameterNumeric *) currentParam(param_name, orderMapNumeric))->current; }; /* * Get current values of all benchmarks, delimited by delimiter, * with or without units, optionally skipping one or two params of given orders. * (former string print_params(int skip_depth1, int skip_depth2, bool units)) */ std::string currentValues (const std::string & delim, bool units, int skipOrder1 = -1, int skipOrder2 = -1); /* * Get table subtitle using current values. */ std::string tableSubtitle (int skipOrder1, int skipOrder2 = -1); /* * Reset parameter of given order * (former reset_param) */ void resetOne (int order); /* * Reset all parameters * (former reset_params) */ void resetAll (); /* * Set orderCurrent * (former set_param_dept) */ void setCurrentOrder (int order); /* * Check if parameter of given order can be advanced * (former advance_param_possible) */ bool advanceOneCheck (int order); /* * Advance param of given order, return if it succeeded * (former advance_param) */ bool advanceOne (int order); /* * Advance the next possible param, return if it succeeded * skip one or two params of given orders * (former advance_params) */ bool advance (int skipOrder1, int skipOrder2 = -1); /* * Get name of parameter of given order */ inline std::string getName (int order) { return defs[order].name; }; /* * Returns number of parameters defined by the benchmark. */ inline int countAll () { return allDefs.size(); }; /* * Returns number of parameters defined in rib.ini. */ inline int count () { return defs.size(); }; /* * Get pointer to instance of current param with given order * (former get_run_param) */ inline BenchParameter * getCurrentParam (int order) { return current[order]; }; /* * Get pointer to an unmanaged parameter specified by name. */ inline BenchParameter * getUnmanagedParam (const std::string & param_name) { std::map::iterator it = unmanagedParams.find(param_name); if (it == unmanagedParams.end()) { return NULL; } else { return it->second; } }; /******************************************************************/ /* PRINTING METHODS */ /******************************************************************/ /* * Print parameter names delimited by given delimiter * (former print_param_names) */ void printNames (std::ostream & s, const std::string & delim); /* * Print current value of param specified by order * (former print_param) */ void printCurrentValue (std::ostream & s, int i, bool units); /* * Print current param values separated by given delimiter * except for the parameter with order specified by skipOrder * (former print_param_values) */ void printValues (std::ostream & s, const std::string & delim, bool units = false, int skipOrder1 = -1, int skipOrder2 = -1); /* * Print names and current values of all params with given delimiter * between names and values, endline after each pair * (former print_params) */ void printNamesValues (std::ostream & s, const std::string & delim, bool units); /* * Return current parameter instance by name and the orderMap to search in. */ BenchParameter * currentParam (const std::string & param_name, std::map & orderMap); /******************************************************************/ /* PUBLIC ATTRIBUTES */ /******************************************************************/ // vector of names of parameters to multiply results with when plotting std::vector multParams; // vector of names of parameters to divide results with when plotting std::vector divParams; private: /******************************************************************/ /* PRIVATE METHODS */ /******************************************************************/ /******************************************************************/ /* PRIVATE ATTRIBUTES */ /******************************************************************/ // vector of initial (all specified by benchmark) parameter definitions std::vector allDefs; // vector of parameter definitions of only parameters present in rib.ini std::vector defs; // parameters as defined in the rib.ini (former init_params) std::vector iniDefs; // current parameter values as iterator (former current_params) std::vector currentIt; // current parameter values as pointer to BenchParameter (former run_params) std::vector current; // instances of unmanaged parameters, mapped by their names std::map unmanagedParams; // map parameter names to their order std::map orderMapString; std::map orderMapNumeric; std::map orderMapAll; // order (position in the vector) of current (when iterating over all) parameter (former param_depth) int orderCurrent; // not sure yet (formed advanced_params) bool advanced; }; #endif /* PARAMS_H_ */