Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of new arithmetic performance counter "Count" #3206

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/manual/existing_performance_counters.qbk
Expand Up @@ -1659,6 +1659,15 @@ system and application performance.
this counter is accessed. Any wildcards in the counter names will
be expanded.]
]
[ [`/arithmetics/count`]
[None]
[Returns the count value of all values queried from the
underlying counters (the ones specified as the parameters).]
[The parameter will be interpreted as a comma separated list of
full performance counter names which are queried whenever
this counter is accessed. Any wildcards in the counter names will
be expanded.]
]
]

[note The /arithmetics counters can consume an arbitrary number of other counters.
Expand Down
8 changes: 8 additions & 0 deletions src/performance_counters/registry.cpp
Expand Up @@ -986,6 +986,14 @@ namespace hpx { namespace performance_counters
> counter_t;
gid = components::server::construct<counter_t>(
complemented_info, base_counter_names);
}
else if (p.countername_ == "count") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation seems to be off here.

typedef hpx::components::component<
performance_counters::server::arithmetics_counter_extended<
boost::accumulators::tag::count>
> counter_t;
gid = components::server::construct<counter_t>(
complemented_info, base_counter_names);
}
else {
HPX_THROWS_IF(ec, bad_parameter,
Expand Down
Expand Up @@ -22,6 +22,7 @@
#include <boost/accumulators/statistics/variance.hpp>
#include <boost/accumulators/statistics/max.hpp>
#include <boost/accumulators/statistics/min.hpp>
#include <boost/accumulators/statistics/count.hpp>

#include <cstddef>
#include <cstdint>
Expand Down Expand Up @@ -103,6 +104,16 @@ namespace hpx { namespace performance_counters { namespace server
return (boost::accumulators::max)(accum);
}
};

template <>
struct statistic_get_value<boost::accumulators::tag::count>
{
template <typename Accumulator>
static double call(Accumulator const& accum)
{
return boost::accumulators::count(accum);
}
};
}

template <typename Statistic>
Expand Down Expand Up @@ -175,6 +186,9 @@ hpx::performance_counters::server::arithmetics_counter_extended<
template class HPX_EXPORT
hpx::performance_counters::server::arithmetics_counter_extended<
boost::accumulators::tag::max>;
template class HPX_EXPORT
hpx::performance_counters::server::arithmetics_counter_extended<
boost::accumulators::tag::count>;

///////////////////////////////////////////////////////////////////////////////
// /arithmetic/mean
Expand Down Expand Up @@ -235,6 +249,18 @@ HPX_REGISTER_DERIVED_COMPONENT_FACTORY(
max_arithmetics_counter_type, max_arithmetics_counter,
"base_performance_counter", hpx::components::factory_enabled)
HPX_DEFINE_GET_COMPONENT_TYPE(max_arithmetics_counter_type::wrapped_type)

///////////////////////////////////////////////////////////////////////////////
// /arithmetic/count
typedef hpx::components::component<
hpx::performance_counters::server::arithmetics_counter_extended<
boost::accumulators::tag::count>
> count_arithmetics_counter_type;

HPX_REGISTER_DERIVED_COMPONENT_FACTORY(
count_arithmetics_counter_type, count_arithmetics_counter,
"base_performance_counter", hpx::components::factory_enabled)
HPX_DEFINE_GET_COMPONENT_TYPE(count_arithmetics_counter_type::wrapped_type)

///////////////////////////////////////////////////////////////////////////////
namespace hpx { namespace performance_counters { namespace detail
Expand Down
10 changes: 10 additions & 0 deletions src/runtime.cpp
Expand Up @@ -645,6 +645,16 @@ namespace hpx
&performance_counters::default_counter_discoverer,
""
},
// arithmetics count counter
{ "/arithmetics/count", performance_counters::counter_aggregating,
"returns the count value of all values of the specified "
"base counters; pass the required base counters as the parameters: "
"/arithmetics/count@<base_counter_name1>,<base_counter_name2>",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the counter returns the number of values in the accumulator, wouldn't it always return the number of base-counters specified as its argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hkaiser Thanks for the review 😊 . Actually , Yes it will return the number of base-counters . Sorry for being little unclear . As mean, median and variance are done on the base counter values . Similarly count is also there to return the count of values .

HPX_PERFORMANCE_COUNTER_V1,
&performance_counters::detail::arithmetics_counter_extended_creator,
&performance_counters::default_counter_discoverer,
""
},
};
performance_counters::install_counter_types(
arithmetic_counter_types,
Expand Down