Skip to content

Commit

Permalink
Merge pull request #6559 from STEllAR-GROUP/pp_counters
Browse files Browse the repository at this point in the history
Making sure that all parcelport counters are unavailable if no networking is needed or configured
  • Loading branch information
hkaiser authored Nov 8, 2024
2 parents a882efc + b2da0a3 commit 5356c52
Showing 1 changed file with 23 additions and 37 deletions.
60 changes: 23 additions & 37 deletions libs/full/performance_counters/src/parcelhandler_counter_types.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021-2023 Hartmut Kaiser
// Copyright (c) 2021-2024 Hartmut Kaiser
//
// SPDX-License-Identifier: BSL-1.0
// Distributed under the Boost Software License, Version 1.0. (See accompanying
Expand All @@ -20,22 +20,16 @@

namespace hpx::performance_counters {

#if defined(HPX_HAVE_PARCELPORT_COUNTERS)
///////////////////////////////////////////////////////////////////////////
void register_parcelhandler_counter_types(
static void register_parcelhandler_counter_types(
parcelset::parcelhandler& ph, std::string const& pp_type)
{
#if defined(HPX_HAVE_PARCELPORT_COUNTERS)
if (!ph.is_networking_enabled())
{
return;
}

using placeholders::_1;
using placeholders::_2;

using parcelset::parcelhandler;
#if defined(HPX_HAVE_PARCELPORT_COUNTERS) && \
defined(HPX_HAVE_PARCELPORT_ACTION_COUNTERS)
#if defined(HPX_HAVE_PARCELPORT_ACTION_COUNTERS)
hpx::function<std::int64_t(std::string const&, bool)> num_parcel_sends(
hpx::bind_front(
&parcelhandler::get_action_parcel_send_count, &ph, pp_type));
Expand All @@ -59,8 +53,7 @@ namespace hpx::performance_counters {
hpx::function<std::int64_t(bool)> receiving_time(
hpx::bind_front(&parcelhandler::get_receiving_time, &ph, pp_type));

#if defined(HPX_HAVE_PARCELPORT_COUNTERS) && \
defined(HPX_HAVE_PARCELPORT_ACTION_COUNTERS)
#if defined(HPX_HAVE_PARCELPORT_ACTION_COUNTERS)
hpx::function<std::int64_t(std::string const&, bool)>
sending_serialization_time(hpx::bind_front(
&parcelhandler::get_action_sending_serialization_time, &ph,
Expand All @@ -78,8 +71,7 @@ namespace hpx::performance_counters {
&ph, pp_type));
#endif

#if defined(HPX_HAVE_PARCELPORT_COUNTERS) && \
defined(HPX_HAVE_PARCELPORT_ACTION_COUNTERS)
#if defined(HPX_HAVE_PARCELPORT_ACTION_COUNTERS)
hpx::function<std::int64_t(std::string const&, bool)> data_sent(
hpx::bind_front(
&parcelhandler::get_action_data_sent, &ph, pp_type));
Expand Down Expand Up @@ -139,8 +131,7 @@ namespace hpx::performance_counters {
"connection type for the referenced locality",
pp_type),
HPX_PERFORMANCE_COUNTER_V1,
#if defined(HPX_HAVE_PARCELPORT_COUNTERS) && \
defined(HPX_HAVE_PARCELPORT_ACTION_COUNTERS)
#if defined(HPX_HAVE_PARCELPORT_ACTION_COUNTERS)
hpx::bind(
&performance_counters::per_action_data_counter_creator,
_1, HPX_MOVE(num_parcel_sends), _2),
Expand All @@ -160,8 +151,7 @@ namespace hpx::performance_counters {
"connection type for the referenced locality",
pp_type),
HPX_PERFORMANCE_COUNTER_V1,
#if defined(HPX_HAVE_PARCELPORT_COUNTERS) && \
defined(HPX_HAVE_PARCELPORT_ACTION_COUNTERS)
#if defined(HPX_HAVE_PARCELPORT_ACTION_COUNTERS)
hpx::bind(
&performance_counters::per_action_data_counter_creator,
_1, HPX_MOVE(num_parcel_receives), _2),
Expand Down Expand Up @@ -232,8 +222,7 @@ namespace hpx::performance_counters {
"referenced locality",
pp_type),
HPX_PERFORMANCE_COUNTER_V1,
#if defined(HPX_HAVE_PARCELPORT_COUNTERS) && \
defined(HPX_HAVE_PARCELPORT_ACTION_COUNTERS)
#if defined(HPX_HAVE_PARCELPORT_ACTION_COUNTERS)
hpx::bind(
&performance_counters::per_action_data_counter_creator,
_1, HPX_MOVE(sending_serialization_time), _2),
Expand All @@ -253,8 +242,7 @@ namespace hpx::performance_counters {
"referenced locality",
pp_type),
HPX_PERFORMANCE_COUNTER_V1,
#if defined(HPX_HAVE_PARCELPORT_COUNTERS) && \
defined(HPX_HAVE_PARCELPORT_ACTION_COUNTERS)
#if defined(HPX_HAVE_PARCELPORT_ACTION_COUNTERS)
hpx::bind(
&performance_counters::per_action_data_counter_creator,
_1, HPX_MOVE(receiving_serialization_time), _2),
Expand Down Expand Up @@ -304,8 +292,7 @@ namespace hpx::performance_counters {
"type by the referenced locality",
pp_type),
HPX_PERFORMANCE_COUNTER_V1,
#if defined(HPX_HAVE_PARCELPORT_COUNTERS) && \
defined(HPX_HAVE_PARCELPORT_ACTION_COUNTERS)
#if defined(HPX_HAVE_PARCELPORT_ACTION_COUNTERS)
hpx::bind(
&performance_counters::per_action_data_counter_creator,
_1, HPX_MOVE(data_sent), _2),
Expand All @@ -326,8 +313,7 @@ namespace hpx::performance_counters {
"type by the referenced locality",
pp_type),
HPX_PERFORMANCE_COUNTER_V1,
#if defined(HPX_HAVE_PARCELPORT_COUNTERS) && \
defined(HPX_HAVE_PARCELPORT_ACTION_COUNTERS)
#if defined(HPX_HAVE_PARCELPORT_ACTION_COUNTERS)
hpx::bind(
&performance_counters::per_action_data_counter_creator,
_1, HPX_MOVE(data_received), _2),
Expand Down Expand Up @@ -480,23 +466,14 @@ namespace hpx::performance_counters {

performance_counters::install_counter_types(
counter_types, std::size(counter_types));
#else
HPX_UNUSED(ph);
HPX_UNUSED(pp_type);
#endif
}

///////////////////////////////////////////////////////////////////////////
// register connection specific performance counters related to connection
// caches
void register_connection_cache_counter_types(
static void register_connection_cache_counter_types(
parcelset::parcelhandler& ph, std::string const& pp_type)
{
if (!ph.is_networking_enabled())
{
return;
}

using hpx::placeholders::_1;
using hpx::placeholders::_2;

Expand Down Expand Up @@ -589,10 +566,18 @@ namespace hpx::performance_counters {
performance_counters::install_counter_types(
connection_cache_types, std::size(connection_cache_types));
}
#endif

///////////////////////////////////////////////////////////////////////////
void register_parcelhandler_counter_types(parcelset::parcelhandler& ph)
void register_parcelhandler_counter_types(
[[maybe_unused]] parcelset::parcelhandler& ph)
{
#if defined(HPX_HAVE_PARCELPORT_COUNTERS)
if (!ph.is_networking_enabled())
{
return;
}

// register connection specific counters
ph.enum_parcelports([&](std::string const& type) -> bool {
register_parcelhandler_counter_types(ph, type);
Expand Down Expand Up @@ -644,6 +629,7 @@ namespace hpx::performance_counters {

performance_counters::install_counter_types(
counter_types, std::size(counter_types));
#endif
}
} // namespace hpx::performance_counters

Expand Down

0 comments on commit 5356c52

Please sign in to comment.