17#include "sparta/utils/MathUtils.hpp"
22#include "sparta/statistics/Counter.hpp"
23#include "sparta/statistics/CycleCounter.hpp"
47MetaStruct::enable_if_t<not sparta::is_sparta_enum<U>::value and
50 typedef typename std::underlying_type<U>::type enum_type;
51 constexpr enum_type last_index =
static_cast<enum_type
>(U::__LAST);
52 enum_name_strings.reserve(last_index);
54 for(enum_type e = 0; e < last_index; ++e){
55 auto val =
static_cast<U
>(e);
57 enum_name_strings.emplace_back(ss.str());
70MetaStruct::enable_if_t<not sparta::is_sparta_enum<U>::value and
78MetaStruct::enable_if_t<sparta::is_sparta_enum<U>::value,
void>
80 U::populateNames(enum_name_strings);
96template<
typename EnumType>
153 template<
typename T = EnumType>
155 const std::string& histogram_name,
156 const std::string& description,
157 const T idle_value = T::__FIRST,
169 static_cast<uint64_t>(T::__LAST) - 1,
171 static_cast<uint64_t>(idle_value)),
174 static_assert(std::is_enum<T>::value,
"The template type must be a std::enum class type.");
177 std::vector<std::string> enum_name_strings;
179 getHumanReadableHistogramBinNames<T>(enum_name_strings);
180 initializeStats_ (&stats_, parent_treenode->
getClock(), std::string(),
181 description, stat_vis_general, stat_vis_detailed,
182 stat_vis_max, stat_vis_avg, enum_name_strings);
218 template<
typename T = EnumType>
220 const std::string& histogram_name,
221 const std::string& description,
222 const typename T::value_type idle_value = T::value_type::__FIRST,
234 static_cast<uint64_t>(T::value_type::__LAST) - 1,
236 static_cast<uint64_t>(idle_value)),
242 std::vector<std::string> enum_name_strings;
244 getHumanReadableHistogramBinNames<T>(enum_name_strings);
245 initializeStats_ (&stats_, parent_treenode->
getClock(), std::string(),
246 description, stat_vis_general, stat_vis_detailed,
247 stat_vis_max, stat_vis_avg, enum_name_strings);
262 template<
typename T = EnumType>
277 template<
typename T = EnumType>
285 return this->sparta::CycleHistogramBase::getHistogramUpperValue();
290 return this->sparta::CycleHistogramBase::getHistogramLowerValue();
295 return this->sparta::CycleHistogramBase::getNumBins();
300 return this->sparta::CycleHistogramBase::getNumValuesPerBin();
CycleHistogram implementation using sparta CycleCounter.
Compile-time SFINAE techniques to detect presence of operators, member-fields and methods by name in ...
File that defines the Resource class. Consider using sparta::Unit instead.
Set of macros for Sparta assertions. Caught by the framework.
#define sparta_assert(...)
Simple variadic assertion that will throw a sparta_exception if the condition fails.
Contains a statistic definition (some useful information which can be computed)
File that defines the StatisticSet class.
Basic Node framework in sparta device tree composite pattern.
CycleHistogramBase class for uint64_t values.
const uint64_t idle_value_
Value to capture when nothing is captured.
void stopCounting_(uint64_t val, uint64_t delay=0)
Stop counting and increment internal count, taking into account the specified delay.
void updateMaxValues_(uint64_t val)
void startCounting_(uint64_t val, uint64_t delay=0)
Start counting, taking into account the specified delay.
std::unique_ptr< sparta::CycleCounter > total_
Total values.
uint64_t last_value_
Last value updated.
EnumCycleHistogram class for C++ Enum values.
EnumCycleHistogram(TreeNode *parent_treenode, const std::string &histogram_name, const std::string &description, const T idle_value=T::__FIRST, const InstrumentationNode::visibility_t stat_vis_general=InstrumentationNode::AUTO_VISIBILITY, const InstrumentationNode::visibility_t stat_vis_detailed=InstrumentationNode::AUTO_VISIBILITY, InstrumentationNode::visibility_t stat_vis_max=InstrumentationNode::AUTO_VISIBILITY, InstrumentationNode::visibility_t stat_vis_avg=InstrumentationNode::AUTO_VISIBILITY, MetaStruct::enable_if_t< not sparta::is_sparta_enum< T >::value > *=0)
EnumCycleHistogram constructor.
EnumCycleHistogram(const EnumCycleHistogram &)=delete
Not copy-constructable.
uint64_t getHistogramUpperValue() const
Method to return the upper value of the histogram.
uint64_t getNumValuesPerBin() const
Method to return the number of values per bin of the histogram.
void stopCounting(const T enum_val, uint64_t delay=0)
Stop counting and increment internal count, taking into account the specified delay.
EnumCycleHistogram(TreeNode *parent_treenode, const std::string &histogram_name, const std::string &description, const typename T::value_type idle_value=T::value_type::__FIRST, const InstrumentationNode::visibility_t stat_vis_general=InstrumentationNode::AUTO_VISIBILITY, const InstrumentationNode::visibility_t stat_vis_detailed=InstrumentationNode::AUTO_VISIBILITY, InstrumentationNode::visibility_t stat_vis_max=InstrumentationNode::AUTO_VISIBILITY, InstrumentationNode::visibility_t stat_vis_avg=InstrumentationNode::AUTO_VISIBILITY, MetaStruct::enable_if_t< sparta::is_sparta_enum< T >::value > *=0)
EnumCycleHistogram constructor.
uint64_t getHistogramLowerValue() const
Method to return the lower value of the histogram.
EnumCycleHistogram(EnumCycleHistogram &&)=delete
Not move-constructable.
EnumCycleHistogram & operator=(const EnumCycleHistogram &)=delete
Not copy-assignable.
uint64_t getNumBins() const
Method to return the number of bins of the histogram.
void startCounting(const T enum_val, uint64_t delay=0)
Start counting, taking into account the specified delay.
EnumCycleHistogram()=delete
Not default constructable.
uint32_t visibility_t
Continuous visibility level. Several key points along continum are indicated within Visibility.
static constexpr visibility_t AUTO_VISIBILITY
The default sparta resource visibility value that should be used. This is an alias of VIS_MAX at the ...
Set of StatisticDef and CounterBase-derived objects for visiblility through a sparta Tree.
Node in a composite tree representing a sparta Tree item.
void addChild(TreeNode *child, bool inherit_phase=true)
Adds a TreeNode to this node as a child.
const Clock * getClock() override
Walks up parents (starting with self) until a parent with an associated local clock is found,...
void setExpectedParent_(const TreeNode *parent)
Tracks a node as an expected parent without actually adding this node as a child. This is used almost...
Class that wraps a C++ class enum and allows conversion between POD and the enum type....
Macros for handling exponential backoff.
MetaStruct::enable_if_t< not sparta::is_sparta_enum< U >::value and sparta::utils::has_ostream_operator< U >::value, void > getHumanReadableHistogramBinNames(std::vector< std::string > &enum_name_strings)
Given an enum class type, this method figures out the string.
Detect whether template parameter is sparta::utils::Enum type.