Skip to content
Snippets Groups Projects

Saving counters result as monitoring histogram

Merged Valerii Kholoimov requested to merge dev_kholoimov_monitoring_counters_histogram into master
2 files
+ 22
29
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -35,8 +35,7 @@ namespace Allen::Monitoring {
struct CountersHistogram {
CountersHistogram() : m_bins(2, 0)
{}
CountersHistogram() : m_title("CountersHistogram"), m_bins(2, 0) {}
friend void reset(CountersHistogram& c)
{
@@ -51,36 +50,35 @@ namespace Allen::Monitoring {
{"dimension", 1},
{"empty", h.m_totNEntries == 0},
{"nEntries", h.m_totNEntries},
{"axis",
{{
{"nBins", h.m_bins.size() - 2},
{"minValue", h.m_minValue},
{"maxValue", h.m_maxValue},
{"title", ""},
{"labels", h.m_labels}
}}},
{"axis",
{{{"nBins", h.m_bins.size() - 2},
{"minValue", h.m_minValue},
{"maxValue", h.m_maxValue},
{"title", ""},
{"labels", h.m_labels}}}},
{"bins", h.m_bins}};
}
void registerHistogram()
{
// Register CountersHistogram for Gaudi
#ifndef ALLEN_STANDALONE
Gaudi::svcLocator()->monitoringHub().registerEntity("CountersHistogram", "CountersValues", "histogram:Histogram:d", *this);
#endif
// Register CountersHistogram for Gaudi
#ifndef ALLEN_STANDALONE
Gaudi::svcLocator()->monitoringHub().registerEntity(
"CountersHistogram", "CountersValues", "histogram:Histogram:d", *this);
#endif
}
void addCounter(std::string label)
void addCounter(std::string label)
{
m_labels.push_back(label);
m_maxValue++;
m_bins.push_back(0);
}
void increaseBin(int bin_index, double value)
void updateBin(int bin_index, double value)
{
m_bins[bin_index + 1] = m_bins[bin_index + 1] + static_cast<int>(value);
m_totNEntries = m_totNEntries + value;
m_bins[bin_index + 1] = static_cast<int>(value);
m_totNEntries = value;
}
std::string m_title;
@@ -88,7 +86,6 @@ namespace Allen::Monitoring {
int m_minValue = 0;
int m_maxValue = 0;
std::vector<std::string> m_labels;
std::string m_x_axis_label;
double m_totNEntries = 0.0;
};
@@ -100,7 +97,7 @@ namespace Allen::Monitoring {
}
void registerAccumulator(AccumulatorBase* acc);
void registerCounter(Counter<unsigned>* c) {m_counters.push_back(c);}
void registerCounter(Counter<unsigned>* c) { m_counters.push_back(c); }
void initAccumulators(unsigned number_of_streams);
void mergeAndReset(bool singlethreaded = false);
char* bufferForStream(unsigned stream_id) const { return m_dev_buffer_ptr[m_stream_current_buffer[stream_id]]; }
@@ -188,10 +185,9 @@ namespace Allen::Monitoring {
using type = T;
using DeviceType = DeviceCounter<T>;
Counter(const Allen::Algorithm* owner, std::string name) : AccumulatorBase(owner, name)
Counter(const Allen::Algorithm* owner, std::string name) : AccumulatorBase(owner, name)
{
if constexpr (std::is_same<T, unsigned>::value)
AccumulatorManager::get()->registerCounter(this);
if constexpr (std::is_same<T, unsigned>::value) AccumulatorManager::get()->registerCounter(this);
}
std::size_t size() const override { return 1; }
std::size_t elementSize() const override { return sizeof(T); }
@@ -535,7 +531,6 @@ namespace Allen::Monitoring {
{"nEntries", h.m_totNEntries},
{"axis", h.axisArray()},
{"bins", h.m_bins}};
}
void registerAccumulator() override
Loading