75 using HistStatCalcFcn = double (*)(
const T*);
115 return function_manager;
135 MetaStruct::enable_if_t<
136 std::is_same<MetaStruct::decay_t<T>,
138 add(
const std::string& name, HistStatCalcFcn<T> fcn){
141 if(functions_cycle_.find(name) != functions_cycle_.end()){
143 "This method " + name +
" was already registered with the REGISTER_HISTOGRAM_STAT_CALC_FCN macro.");
145 functions_cycle_[name] = fcn;
157 MetaStruct::enable_if_t<
158 std::is_same<MetaStruct::decay_t<T>,
160 add(
const std::string& name, HistStatCalcFcn<T> fcn){
163 if(functions_normal_.find(name) != functions_normal_.end()){
165 "This method " + name +
"was already registered with the REGISTER_HISTOGRAM_STAT_CALC_FCN macro.");
167 functions_normal_[name] = fcn;
180 MetaStruct::enable_if_t<
181 std::is_same<MetaStruct::decay_t<T>,
185 const auto& iter = functions_cycle_.find(name);
188 if(iter == functions_cycle_.end()){
190 "This method " + name +
" was never registered with the REGISTER_HISTOGRAM_STAT_CALC_FCN macro.");
205 MetaStruct::enable_if_t<
206 std::is_same<MetaStruct::decay_t<T>,
210 const auto& iter = functions_normal_.find(name);
213 if(iter == functions_normal_.end()){
215 "This method " + name +
" was never registered with the REGISTER_HISTOGRAM_STAT_CALC_FCN macro.");
226 const std::string token_ =
"hist_def";
229 std::map<std::string, HistStatCalcFcn<CycleHistogramTreeNode>> functions_cycle_;
232 std::map<std::string, HistStatCalcFcn<HistogramTreeNode>> functions_normal_;
254#define REGISTER_HISTOGRAM_STAT_CALC_FCN(histogram_type, fcn_name) \
256 static_assert(MetaStruct::matches_any<sparta::histogram_type, \
257 sparta::HistogramTreeNode, \
258 sparta::CycleHistogramTreeNode>::value, \
259 "Invalid class type used for histogram stat calculation registration."); \
260 std::string key = #fcn_name; \
261 sparta::HistStatCalcFcn<sparta::histogram_type> callable = fcn_name; \
262 sparta::FunctionManager::get().add<sparta::histogram_type>(key, callable); \
CycleHistogram implementation using sparta CycleCounter.
Histogram implementation using sparta Counters.
CycleHistogramTreeNode class for uint64_t values.
Singleton Function Manager class. This class contains two maps and one constant string token....
MetaStruct::enable_if_t< std::is_same< MetaStruct::decay_t< T >, HistogramTreeNode >::value, void > add(const std::string &name, HistStatCalcFcn< T > fcn)
This method adds an entry to one of the internal maps. This method takes as parameters,...
static FunctionManager & get()
This method returns the singleton instance of Function Manager.
const std::string & getToken() const
This method returns the constant string "hist_def" which should be prefixed in the stat pathnames in ...
MetaStruct::enable_if_t< std::is_same< MetaStruct::decay_t< T >, HistogramTreeNode >::value, HistStatCalcFcn< T > & > find(const std::string &name)
This method finds the function pointer mapped to the name. This method takes as parameters,...
MetaStruct::enable_if_t< std::is_same< MetaStruct::decay_t< T >, CycleHistogramTreeNode >::value, HistStatCalcFcn< T > & > find(const std::string &name)
This method finds the function pointer mapped to the name. This method takes as parameters,...
MetaStruct::enable_if_t< std::is_same< MetaStruct::decay_t< T >, CycleHistogramTreeNode >::value, void > add(const std::string &name, HistStatCalcFcn< T > fcn)
This method adds an entry to one of the internal maps. This method takes as parameters,...
FunctionManager(const FunctionManager &)=delete
Not copy-constructable.
FunctionManager(FunctionManager &&)=delete
Not move-constructable.
FunctionManager & operator=(const FunctionManager &)=delete
Not copy-assignable.
Used to construct and throw a standard C++ exception. Inherits from std::exception.
Macros for handling exponential backoff.