From 991215c0090c3f3ca80269981d77d0aacf595139 Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Sun, 4 Feb 2024 08:57:52 -0600 Subject: [PATCH] Cleaning component modules --- .../src/component_module.cpp | 12 +- components/iostreams/src/component_module.cpp | 28 +- components/process/src/process.cpp | 7 +- examples/quickstart/data_actions.cpp | 2 +- .../sheneos/sheneos/server/partition3d.cpp | 14 +- .../host/numa_binding_allocator.hpp | 2 +- .../hpx/runtime_local/thread_stacktrace.hpp | 1 + .../performance/serialization_overhead.cpp | 3 +- .../tests/unit/zero_copy_serialization.cpp | 18 +- .../include/hpx/actions_base/plain_action.hpp | 74 ++--- .../include/hpx/agas/addressing_service.hpp | 19 +- libs/full/agas/src/addressing_service.cpp | 24 +- .../agas_base/include/hpx/agas_base/gva.hpp | 15 +- .../agas_base/server/component_namespace.hpp | 16 +- .../agas_base/server/primary_namespace.hpp | 6 +- .../agas_base/src/component_namespace.cpp | 6 +- .../detail/bootstrap_component_namespace.cpp | 7 +- .../detail/bootstrap_locality_namespace.cpp | 5 +- .../full/agas_base/src/locality_namespace.cpp | 9 +- libs/full/agas_base/src/primary_namespace.cpp | 9 +- .../src/server/component_namespace_server.cpp | 10 +- .../src/server/locality_namespace_server.cpp | 4 +- .../src/server/primary_namespace_server.cpp | 12 +- libs/full/agas_base/src/symbol_namespace.cpp | 11 +- .../async_distributed/base_lco_with_value.hpp | 6 +- .../hpx/async_distributed/detail/post.hpp | 3 +- .../async_distributed/detail/promise_lco.hpp | 30 +- .../hpx/async_distributed/trigger_lco.hpp | 14 +- .../hpx/async_distributed/trigger_lco_fwd.hpp | 32 +- libs/full/async_distributed/src/base_lco.cpp | 2 +- libs/full/async_distributed/src/promise.cpp | 8 +- .../components/action_move_semantics.cpp | 11 +- .../include/hpx/collectives/detail/latch.hpp | 8 +- .../collectives/src/detail/barrier_node.cpp | 8 +- libs/full/collectives/src/latch.cpp | 8 +- .../components_base/component_commandline.hpp | 18 +- .../component_startup_shutdown.hpp | 86 +++-- .../hpx/components_base/component_type.hpp | 307 +++++++++++------- .../components_base/components_base_fwd.hpp | 73 ++--- .../components_base/generate_unique_ids.hpp | 43 +-- .../server/abstract_component_base.hpp | 10 +- .../hpx/components_base/server/component.hpp | 6 +- .../components_base/server/component_base.hpp | 8 +- .../components_base/server/component_heap.hpp | 26 +- .../server/create_component.hpp | 21 +- .../server/create_component_fwd.hpp | 9 +- .../server/fixed_component_base.hpp | 9 +- .../components_base/server/locking_hook.hpp | 7 +- .../server/managed_component_base.hpp | 55 ++-- .../server/migration_support.hpp | 3 +- .../server/one_size_heap_list.hpp | 53 +-- .../components_base/server/wrapper_heap.hpp | 45 +-- .../server/wrapper_heap_base.hpp | 13 +- .../server/wrapper_heap_list.hpp | 13 +- .../include/hpx/components_base/stub_base.hpp | 6 +- .../traits/action_decorate_function.hpp | 8 +- .../traits/component_config_data.hpp | 8 +- .../traits/component_heap_type.hpp | 8 +- .../traits/component_pin_support.hpp | 3 +- .../traits/component_supports_migration.hpp | 4 +- .../traits/component_type_database.hpp | 12 +- .../traits/component_type_is_compatible.hpp | 7 +- .../components_base/traits/is_component.hpp | 8 +- .../traits/managed_component_policies.hpp | 8 +- .../components_base/src/component_type.cpp | 20 +- .../src/generate_unique_ids.cpp | 20 +- .../src/server/one_size_heap_list.cpp | 13 +- .../src/server/wrapper_heap.cpp | 35 +- .../detail/target_distribution_policy.hpp | 39 +-- .../host/target_distribution_policy.hpp | 62 ++-- .../include/hpx/parcelset/parcelhandler.hpp | 5 +- libs/full/parcelset/src/parcel.cpp | 14 +- .../server/elapsed_time_counter.hpp | 11 +- .../server/raw_counter.hpp | 8 +- .../server/raw_values_counter.hpp | 8 +- .../src/server/arithmetics_counter.cpp | 69 ++-- .../server/arithmetics_counter_extended.cpp | 64 ++-- .../src/server/component_instance_counter.cpp | 2 +- .../src/server/elapsed_time_counter.cpp | 22 +- .../src/server/raw_counter.cpp | 16 +- .../src/server/raw_values_counter.cpp | 14 +- .../src/server/statistics_counter.cpp | 163 +++++----- .../runtime_components/component_factory.hpp | 30 +- .../runtime_components/component_registry.hpp | 31 +- .../create_component_helpers.hpp | 28 +- .../derived_component_factory.hpp | 7 +- .../distributed_metadata_base.hpp | 23 +- .../src/component_registry.cpp | 15 +- .../hpx/runtime_distributed/applier.hpp | 14 +- libs/full/runtime_distributed/src/applier.cpp | 4 +- .../src/big_boot_barrier.cpp | 9 +- .../src/runtime_distributed.cpp | 12 +- .../src/server/runtime_support_server.cpp | 4 +- .../tests/unit/partitioned_vector_target.cpp | 24 +- .../performance/local/agas_cache_timings.cpp | 4 +- 95 files changed, 1035 insertions(+), 1076 deletions(-) diff --git a/components/component_storage/src/component_module.cpp b/components/component_storage/src/component_module.cpp index 2dbe7531a96e..a5d330b21c6f 100644 --- a/components/component_storage/src/component_module.cpp +++ b/components/component_storage/src/component_module.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Hartmut Kaiser +// Copyright (c) 2015-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -17,11 +17,10 @@ // Add factory registration functionality. HPX_REGISTER_COMPONENT_MODULE() -typedef hpx::components::server::component_storage component_storage_type; +using component_storage_type = hpx::components::server::component_storage; -HPX_REGISTER_COMPONENT( - hpx::components::component, - component_storage_factory, hpx::components::factory_enabled) +HPX_REGISTER_COMPONENT(hpx::components::component, + component_storage_factory, hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(component_storage_type) /////////////////////////////////////////////////////////////////////////////// @@ -31,6 +30,5 @@ HPX_REGISTER_ACTION( HPX_REGISTER_ACTION( hpx::components::server::component_storage::migrate_from_here_action, component_storage_migrate_component_from_here_action) -HPX_REGISTER_ACTION( - hpx::components::server::component_storage::size_action, +HPX_REGISTER_ACTION(hpx::components::server::component_storage::size_action, component_storage_size_action) diff --git a/components/iostreams/src/component_module.cpp b/components/iostreams/src/component_module.cpp index 023caa19e5e6..828ca8cddf75 100644 --- a/components/iostreams/src/component_module.cpp +++ b/components/iostreams/src/component_module.cpp @@ -16,8 +16,8 @@ #include #include -#include #include +#include #include /////////////////////////////////////////////////////////////////////////////// @@ -25,27 +25,23 @@ HPX_REGISTER_COMPONENT_MODULE() typedef hpx::iostreams::server::output_stream ostream_type; -HPX_REGISTER_COMPONENT( - hpx::components::component, - output_stream_factory, hpx::components::factory_enabled) +HPX_REGISTER_COMPONENT(hpx::components::component, + output_stream_factory, hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(ostream_type) /////////////////////////////////////////////////////////////////////////////// -HPX_REGISTER_ACTION_ID( - ostream_type::write_async_action, +HPX_REGISTER_ACTION_ID(ostream_type::write_async_action, output_stream_write_async_action, hpx::actions::output_stream_write_async_action_id) -HPX_REGISTER_ACTION_ID( - ostream_type::write_sync_action, +HPX_REGISTER_ACTION_ID(ostream_type::write_sync_action, output_stream_write_sync_action, hpx::actions::output_stream_write_sync_action_id) /////////////////////////////////////////////////////////////////////////////// // Register a startup function which will be called as a HPX-thread during // runtime startup. -namespace hpx { namespace iostreams { namespace detail -{ +namespace hpx { namespace iostreams { namespace detail { /////////////////////////////////////////////////////////////////////////// void register_ostreams() { @@ -65,21 +61,21 @@ namespace hpx { namespace iostreams { namespace detail bool get_startup(startup_function_type& startup_func, bool& pre_startup) { // return our startup-function - startup_func = register_ostreams; // function to run during startup - pre_startup = true; // run as pre-startup function + startup_func = register_ostreams; // function to run during startup + pre_startup = true; // run as pre-startup function return true; } bool get_shutdown(shutdown_function_type& shutdown_func, bool& pre_shutdown) { // return our startup-function - shutdown_func = unregister_ostreams; // function to run during startup - pre_shutdown = false; // run as pre-startup function + shutdown_func = + unregister_ostreams; // function to run during startup + pre_shutdown = false; // run as pre-startup function return true; } -}}} +}}} // namespace hpx::iostreams::detail // Note that this macro can be used not more than once in one module. HPX_REGISTER_STARTUP_SHUTDOWN_MODULE( hpx::iostreams::detail::get_startup, hpx::iostreams::detail::get_shutdown) - diff --git a/components/process/src/process.cpp b/components/process/src/process.cpp index 76a5e1bfabf8..e9120689943b 100644 --- a/components/process/src/process.cpp +++ b/components/process/src/process.cpp @@ -17,8 +17,7 @@ HPX_REGISTER_COMPONENT_MODULE() typedef hpx::components::process::server::child child_type; -HPX_REGISTER_COMPONENT( - hpx::components::component, - hpx_components_process_child_factory, hpx::components::factory_enabled) +HPX_REGISTER_COMPONENT(hpx::components::component, + hpx_components_process_child_factory, + hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(child_type) - diff --git a/examples/quickstart/data_actions.cpp b/examples/quickstart/data_actions.cpp index 43250b01a3cf..cb526ccbca19 100644 --- a/examples/quickstart/data_actions.cpp +++ b/examples/quickstart/data_actions.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2017 Hartmut Kaiser +// Copyright (c) 2014-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying diff --git a/examples/sheneos/sheneos/server/partition3d.cpp b/examples/sheneos/sheneos/server/partition3d.cpp index 20aa0f3ea58e..e1ca9edebde6 100644 --- a/examples/sheneos/sheneos/server/partition3d.cpp +++ b/examples/sheneos/sheneos/server/partition3d.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2017 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -393,13 +393,17 @@ namespace hpx { namespace serialization { void serialize( input_archive& ar, sheneos::sheneos_coord& coord, unsigned int const) { - ar& coord.ye_& coord.temp_& coord.rho_; + // clang-format off + ar & coord.ye_ & coord.temp_ & coord.rho_; + // clang-format on } void serialize( output_archive& ar, sheneos::sheneos_coord& coord, unsigned int const) { - ar& coord.ye_& coord.temp_& coord.rho_; + // clang-format off + ar & coord.ye_ & coord.temp_ & coord.rho_; + // clang-format on } }} // namespace hpx::serialization @@ -427,12 +431,12 @@ HPX_REGISTER_ACTION(hpx::lcos::base_lco_with_value< set_value_action_vector_vector_double) HPX_DEFINE_GET_COMPONENT_TYPE_STATIC( hpx::lcos::base_lco_with_value>>, - hpx::components::component_base_lco_with_value); + to_int(hpx::components::component_enum_type::base_lco_with_value)); HPX_REGISTER_ACTION( hpx::lcos::base_lco_with_value>::set_value_action, set_value_action_vector_double) HPX_DEFINE_GET_COMPONENT_TYPE_STATIC( hpx::lcos::base_lco_with_value>, - hpx::components::component_base_lco_with_value); + to_int(hpx::components::component_enum_type::base_lco_with_value)); #endif diff --git a/libs/core/compute_local/include/hpx/compute_local/host/numa_binding_allocator.hpp b/libs/core/compute_local/include/hpx/compute_local/host/numa_binding_allocator.hpp index bf1b37122454..45f3bcf67e5c 100644 --- a/libs/core/compute_local/include/hpx/compute_local/host/numa_binding_allocator.hpp +++ b/libs/core/compute_local/include/hpx/compute_local/host/numa_binding_allocator.hpp @@ -603,7 +603,7 @@ namespace hpx::compute::host { helper->operator()(p, page_ptr, pagesize, nodesets.size()); if (dom == numa_domain) { - HPX_ASSERT((static_cast(page_ptr) & + HPX_ASSERT((reinterpret_cast(page_ptr) & (threads::get_memory_page_size() - 1)) == 0); // trigger a memory read and rewrite without changing contents T volatile* vaddr = const_cast(page_ptr); diff --git a/libs/core/runtime_local/include/hpx/runtime_local/thread_stacktrace.hpp b/libs/core/runtime_local/include/hpx/runtime_local/thread_stacktrace.hpp index 7d36e88aefec..2336abe4089f 100644 --- a/libs/core/runtime_local/include/hpx/runtime_local/thread_stacktrace.hpp +++ b/libs/core/runtime_local/include/hpx/runtime_local/thread_stacktrace.hpp @@ -8,6 +8,7 @@ #include #include +#include #include #include diff --git a/libs/full/actions/tests/performance/serialization_overhead.cpp b/libs/full/actions/tests/performance/serialization_overhead.cpp index b54d23891fe0..db9d337b4d21 100644 --- a/libs/full/actions/tests/performance/serialization_overhead.cpp +++ b/libs/full/actions/tests/performance/serialization_overhead.cpp @@ -52,7 +52,8 @@ double benchmark_serialization(std::size_t data_size, std::size_t iterations, { hpx::id_type const here = hpx::find_here(); hpx::naming::address addr(hpx::get_locality(), - hpx::components::component_invalid, (void*) &test_function); + to_int(hpx::components::component_enum_type::invalid), + (void*) &test_function); // compose archive flags std::string endian_out = hpx::get_config_entry("hpx.parcel.endian_out", diff --git a/libs/full/actions/tests/unit/zero_copy_serialization.cpp b/libs/full/actions/tests/unit/zero_copy_serialization.cpp index f9423e227846..065b6a16b161 100644 --- a/libs/full/actions/tests/unit/zero_copy_serialization.cpp +++ b/libs/full/actions/tests/unit/zero_copy_serialization.cpp @@ -178,7 +178,8 @@ void test_normal_serialization(T& arg) { hpx::id_type const here = hpx::find_here(); hpx::naming::address addr(hpx::get_locality(), - hpx::components::component_invalid, (void*) &test_function1); + to_int(hpx::components::component_enum_type::invalid), + (void*) &test_function1); // compose archive flags auto out_archive_flags = static_cast( @@ -211,7 +212,8 @@ void test_normal_serialization(T1& arg1, T2& arg2) { hpx::id_type const here = hpx::find_here(); hpx::naming::address addr(hpx::get_locality(), - hpx::components::component_invalid, (void*) &test_function2); + to_int(hpx::components::component_enum_type::invalid), + (void*) &test_function2); // compose archive flags auto out_archive_flags = static_cast( @@ -245,7 +247,8 @@ void test_normal_serialization( { hpx::id_type const here = hpx::find_here(); hpx::naming::address addr(hpx::get_locality(), - hpx::components::component_invalid, (void*) &test_function2); + to_int(hpx::components::component_enum_type::invalid), + (void*) &test_function2); // compose archive flags auto out_archive_flags = static_cast( @@ -279,7 +282,8 @@ void test_zero_copy_serialization(T& arg) { hpx::id_type const here = hpx::find_here(); hpx::naming::address addr(hpx::get_locality(), - hpx::components::component_invalid, (void*) &test_function1); + to_int(hpx::components::component_enum_type::invalid), + (void*) &test_function1); // compose archive flags std::uint32_t out_archive_flags = 0U; @@ -311,7 +315,8 @@ void test_zero_copy_serialization(T1& arg1, T2& arg2) { hpx::id_type const here = hpx::find_here(); hpx::naming::address addr(hpx::get_locality(), - hpx::components::component_invalid, (void*) &test_function2); + to_int(hpx::components::component_enum_type::invalid), + (void*) &test_function2); // compose archive flags std::uint32_t out_archive_flags = 0U; @@ -344,7 +349,8 @@ void test_zero_copy_serialization( { hpx::id_type const here = hpx::find_here(); hpx::naming::address addr(hpx::get_locality(), - hpx::components::component_invalid, (void*) &test_function2); + to_int(hpx::components::component_enum_type::invalid), + (void*) &test_function2); // compose archive flags std::uint32_t out_archive_flags = 0U; diff --git a/libs/full/actions_base/include/hpx/actions_base/plain_action.hpp b/libs/full/actions_base/include/hpx/actions_base/plain_action.hpp index cf2f11026de2..a312015cdf86 100644 --- a/libs/full/actions_base/include/hpx/actions_base/plain_action.hpp +++ b/libs/full/actions_base/include/hpx/actions_base/plain_action.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2022 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // Copyright (c) 2011 Bryce Lelbach // // SPDX-License-Identifier: BSL-1.0 @@ -19,7 +19,6 @@ #include #include #include -#include #include #include @@ -122,7 +121,7 @@ namespace hpx::traits { HPX_ALWAYS_EXPORT inline components::component_type component_type_database< hpx::actions::detail::plain_function>::get() noexcept { - return hpx::components::component_plain_function; + return to_int(hpx::components::component_enum_type::plain_function); } // clang-format off @@ -237,23 +236,21 @@ namespace hpx::traits { /// \a func. It defines the action type \a name representing the given function. /// This macro additionally registers the newly define action type with HPX. /// -/// The parameter \p func is a global or free (non-member) function which -/// should be encapsulated into a plain action. The parameter \p name is the -/// name of the action type defined by this macro. +/// The parameter \p func is a global or free (non-member) function which should +/// be encapsulated into a plain action. The parameter \p name is the name of +/// the action type defined by this macro. /// /// \par Example: /// /// \code -/// namespace app -/// { -/// void some_global_function(double d) -/// { +/// namespace app { +/// void some_global_function(double d) { /// cout << d; /// } /// } /// -/// // This will define the action type 'some_global_action' which represents -/// // the function 'app::some_global_function'. +/// // This will define the action type 'some_global_action' which +/// // represents the function 'app::some_global_function'. /// HPX_PLAIN_ACTION(app::some_global_function, some_global_action) /// \endcode /// @@ -261,13 +258,14 @@ namespace hpx::traits { /// if the wrapped function is located in some other namespace. The newly /// defined action type is placed into the global namespace as well. /// -/// \note The macro \a HPX_PLAIN_ACTION_ID can be used with 1, 2, or 3 arguments. -/// The second and third arguments are optional. The default value for the -/// second argument (the typename of the defined action) is derived from the -/// name of the function (as passed as the first argument) by appending '_action'. -/// The second argument can be omitted only if the first argument with an -/// appended suffix '_action' resolves to a valid, unqualified C++ type name. -/// The default value for the third argument is \a hpx::components::factory_check. +/// \note The macro \a HPX_PLAIN_ACTION_ID can be used with 1, 2, or 3 +/// arguments. The second and third arguments are optional. The default +/// value for the second argument (the typename of the defined action) is +/// derived from the name of the function (as passed as the first +/// argument) by appending '_action'. The second argument can be omitted +/// only if the first argument with an appended suffix '_action' resolves +/// to a valid, unqualified C++ type name. The default value for the third +/// argument is \a hpx::components::factory_state::check. /// /// \note Only one of the forms of this macro \a HPX_PLAIN_ACTION or /// \a HPX_PLAIN_ACTION_ID should be used for a particular action, @@ -282,42 +280,40 @@ namespace hpx::traits { /// \brief Defines a plain action type based on the given function \a func and /// registers it with HPX. /// -/// The macro \a HPX_PLAIN_ACTION_ID can be used to define a plain action (e.g. an -/// action encapsulating a global or free function) based on the given function -/// \a func. It defines the action type \a actionname representing the given function. -/// The parameter \a actionid +/// The macro \a HPX_PLAIN_ACTION_ID can be used to define a plain action (e.g. +/// an action encapsulating a global or free function) based on the given +/// function \a func. It defines the action type \a actionname representing the +/// given function. /// -/// The parameter \a actionid specifies an unique integer value which will be +/// The parameter \a actionid specifies a unique integer value which will be /// used to represent the action during serialization. /// -/// The parameter \p func is a global or free (non-member) function which -/// should be encapsulated into a plain action. The parameter \p name is the -/// name of the action type defined by this macro. +/// The parameter \p func is a global or free (non-member) function which should +/// be encapsulated into a plain action. The parameter \p name is the name of +/// the action type defined by this macro. /// /// The second parameter has to be usable as a plain (non-qualified) C++ -/// identifier, it should not contain special characters which cannot be part -/// of a C++ identifier, such as '<', '>', or ':'. +/// identifier, it should not contain special characters which cannot be part of +/// a C++ identifier, such as '<', '>', or ':'. /// /// \par Example: /// /// \code -/// namespace app -/// { -/// void some_global_function(double d) -/// { +/// namespace app { +/// void some_global_function(double d) { /// cout << d; /// } /// } /// -/// // This will define the action type 'some_global_action' which represents -/// // the function 'app::some_global_function'. +/// // This will define the action type 'some_global_action' which +/// // represents the function 'app::some_global_function'. /// HPX_PLAIN_ACTION_ID(app::some_global_function, some_global_action, -/// some_unique_id); +/// some_unique_id); /// \endcode /// -/// \note The macro \a HPX_PLAIN_ACTION_ID has to be used at global namespace even -/// if the wrapped function is located in some other namespace. The newly -/// defined action type is placed into the global namespace as well. +/// \note The macro \a HPX_PLAIN_ACTION_ID has to be used at global namespace +/// even if the wrapped function is located in some other namespace. The +/// newly defined action type is placed into the global namespace as well. /// /// \note Only one of the forms of this macro \a HPX_PLAIN_ACTION or /// \a HPX_PLAIN_ACTION_ID should be used for a particular action, diff --git a/libs/full/agas/include/hpx/agas/addressing_service.hpp b/libs/full/agas/include/hpx/agas/addressing_service.hpp index 400d491ae522..4729b91fcf5b 100644 --- a/libs/full/agas/include/hpx/agas/addressing_service.hpp +++ b/libs/full/agas/include/hpx/agas/addressing_service.hpp @@ -323,7 +323,7 @@ namespace hpx { namespace agas { /// \param type [in] The component type will be used to determine /// the set of prefixes having a registered factory /// for this component. The default value for this - /// parameter is \a components#component_invalid, + /// parameter is \a components#component_enum_type#invalid, /// which will return prefixes of all localities. /// \param ec [in,out] this represents the error status on exit, /// if this is pre-initialized to \a hpx#throws @@ -332,7 +332,7 @@ namespace hpx { namespace agas { /// \note As long as \a ec is not pre-initialized to /// \a hpx#throws this function doesn't /// throw but returns the result code using the - /// parameter \a ec. Otherwise it throws an instance + /// parameter \a ec. Otherwise, it throws an instance /// of hpx#exception. bool get_localities(std::vector& locality_ids, components::component_type type, error_code& ec = throws) const; @@ -340,8 +340,8 @@ namespace hpx { namespace agas { bool get_localities(std::vector& locality_ids, error_code& ec = throws) const { - return get_localities( - locality_ids, components::component_invalid, ec); + return get_localities(locality_ids, + to_int(components::component_enum_type::invalid), ec); } /// \brief Query for the number of all known localities. @@ -353,7 +353,7 @@ namespace hpx { namespace agas { /// \param type [in] The component type will be used to determine /// the set of prefixes having a registered factory /// for this component. The default value for this - /// parameter is \a components#component_invalid, + /// parameter is \a components#component_type#invalid, /// which will return prefixes of all localities. /// \param ec [in,out] this represents the error status on exit, /// if this is pre-initialized to \a hpx#throws @@ -362,18 +362,19 @@ namespace hpx { namespace agas { /// \note As long as \a ec is not pre-initialized to /// \a hpx#throws this function doesn't /// throw but returns the result code using the - /// parameter \a ec. Otherwise it throws an instance + /// parameter \a ec. Otherwise, it throws an instance /// of hpx#exception. hpx::future get_num_localities_async( - components::component_type type = - components::component_invalid) const; + components::component_type type = to_int( + hpx::components::component_enum_type::invalid)) const; std::uint32_t get_num_localities( components::component_type type, error_code& ec = throws) const; std::uint32_t get_num_localities(error_code& ec = throws) const { - return get_num_localities(components::component_invalid, ec); + return get_num_localities( + to_int(hpx::components::component_enum_type::invalid), ec); } hpx::future get_num_overall_threads_async() const; diff --git a/libs/full/agas/src/addressing_service.cpp b/libs/full/agas/src/addressing_service.cpp index c36106c4884c..42d0ac1b0a50 100644 --- a/libs/full/agas/src/addressing_service.cpp +++ b/libs/full/agas/src/addressing_service.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2011 Bryce Adelstein-Lelbach -// Copyright (c) 2011-2023 Hartmut Kaiser +// Copyright (c) 2011-2024 Hartmut Kaiser // Copyright (c) 2016 Parsa Amini // Copyright (c) 2016 Thomas Heller // @@ -425,7 +425,7 @@ namespace hpx::agas { { try { - if (type != components::component_invalid) + if (type != to_int(hpx::components::component_enum_type::invalid)) { std::vector const p = component_ns_->resolve_id(type); @@ -468,7 +468,7 @@ namespace hpx::agas { { try { - if (type == components::component_invalid) + if (type == to_int(hpx::components::component_enum_type::invalid)) { return locality_ns_->get_num_localities(); } @@ -485,7 +485,7 @@ namespace hpx::agas { hpx::future addressing_service::get_num_localities_async( components::component_type type) const { - if (type == components::component_invalid) + if (type == to_int(hpx::components::component_enum_type::invalid)) { return locality_ns_->get_num_localities_async(); } @@ -546,7 +546,7 @@ namespace hpx::agas { catch (hpx::exception const& e) { HPX_RETHROWS_IF(ec, e, "addressing_service::get_component_id"); - return components::component_invalid; + return to_int(hpx::components::component_enum_type::invalid); } } @@ -587,7 +587,7 @@ namespace hpx::agas { catch (hpx::exception const& e) { HPX_RETHROWS_IF(ec, e, "addressing_service::register_factory"); - return components::component_invalid; + return to_int(hpx::components::component_enum_type::invalid); } } @@ -854,7 +854,8 @@ namespace hpx::agas { { HPX_ASSERT(rts_lva_); - addr.type_ = components::component_runtime_support; + addr.type_ = to_int( + hpx::components::component_enum_type::runtime_support); addr.address_ = reinterpret_cast(rts_lva_); return true; @@ -876,7 +877,8 @@ namespace hpx::agas { if (naming::is_locality(id)) { addr.locality_ = id; - addr.type_ = components::component_runtime_support; + addr.type_ = + to_int(hpx::components::component_enum_type::runtime_support); // addr.address_ will be supplied on the target locality return true; } @@ -905,7 +907,8 @@ namespace hpx::agas { else { addr.locality_ = dest; - addr.type_ = hpx::components::component_agas_primary_namespace; + addr.type_ = to_int( + components::component_enum_type::agas_primary_namespace); // addr.address_ will be supplied on the target locality } return true; @@ -922,7 +925,8 @@ namespace hpx::agas { else { addr.locality_ = dest; - addr.type_ = hpx::components::component_agas_symbol_namespace; + addr.type_ = to_int( + components::component_enum_type::agas_symbol_namespace); // addr.address_ will be supplied on the target locality } return true; diff --git a/libs/full/agas_base/include/hpx/agas_base/gva.hpp b/libs/full/agas_base/include/hpx/agas_base/gva.hpp index 599965f240b9..b1cf44baaee5 100644 --- a/libs/full/agas_base/include/hpx/agas_base/gva.hpp +++ b/libs/full/agas_base/include/hpx/agas_base/gva.hpp @@ -1,6 +1,6 @@ //////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2011 Bryce Adelstein-Lelbach -// Copyright (c) 2007-2020 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -18,7 +18,7 @@ #include #include -namespace hpx { namespace agas { +namespace hpx::agas { struct gva { @@ -28,7 +28,7 @@ namespace hpx { namespace agas { constexpr gva() noexcept = default; constexpr explicit gva(naming::gid_type const& p, - component_type t = components::component_invalid, + component_type t = to_int(components::component_enum_type::invalid), std::uint64_t c = 1, lva_type a = nullptr, std::uint64_t o = 0) noexcept : prefix(p) @@ -50,7 +50,7 @@ namespace hpx { namespace agas { } constexpr explicit gva(lva_type a) noexcept - : type(components::component_invalid) + : type(to_int(hpx::components::component_enum_type::invalid)) , lva_(a) { } @@ -58,7 +58,7 @@ namespace hpx { namespace agas { gva& operator=(lva_type a) { prefix = naming::gid_type(); - type = components::component_invalid; + type = to_int(hpx::components::component_enum_type::invalid); count = 0; lva_ = a; offset = 0; @@ -107,7 +107,8 @@ namespace hpx { namespace agas { } naming::gid_type prefix; - component_type type = components::component_invalid; + component_type type = + to_int(hpx::components::component_enum_type::invalid); std::uint64_t count = 0; private: @@ -129,4 +130,4 @@ namespace hpx { namespace agas { }; HPX_EXPORT std::ostream& operator<<(std::ostream& os, gva const& addr); -}} // namespace hpx::agas +} // namespace hpx::agas diff --git a/libs/full/agas_base/include/hpx/agas_base/server/component_namespace.hpp b/libs/full/agas_base/include/hpx/agas_base/server/component_namespace.hpp index f42e03404698..923ed47c3ce8 100644 --- a/libs/full/agas_base/include/hpx/agas_base/server/component_namespace.hpp +++ b/libs/full/agas_base/include/hpx/agas_base/server/component_namespace.hpp @@ -1,5 +1,5 @@ // Copyright (c) 2011 Bryce Adelstein-Lelbach -// Copyright (c) 2012-2021 Hartmut Kaiser +// Copyright (c) 2012-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -30,13 +30,13 @@ #include -namespace hpx { namespace agas { +namespace hpx::agas { HPX_EXPORT naming::gid_type bootstrap_component_namespace_gid(); HPX_EXPORT hpx::id_type bootstrap_component_namespace_id(); -}} // namespace hpx::agas +} // namespace hpx::agas -namespace hpx { namespace agas { namespace server { +namespace hpx::agas::server { // Base name used to register the component static constexpr char const* const component_namespace_service_name = @@ -67,7 +67,7 @@ namespace hpx { namespace agas { namespace server { std::string instance_name_; public: - // data structure holding all counters for the omponent_namespace + // data structure holding all counters for the component_namespace // component struct counter_data { @@ -136,10 +136,9 @@ namespace hpx { namespace agas { namespace server { counter_data counter_data_; - public: component_namespace() : base_type(agas::component_ns_msb, agas::component_ns_lsb) - , type_counter(components::component_first_dynamic) + , type_counter(to_int(components::component_enum_type::first_dynamic)) { } @@ -174,8 +173,7 @@ namespace hpx { namespace agas { namespace server { component_namespace, get_component_type_name) HPX_DEFINE_COMPONENT_ACTION(component_namespace, get_num_localities) }; - -}}} // namespace hpx::agas::server +} // namespace hpx::agas::server HPX_REGISTER_ACTION_DECLARATION( hpx::agas::server::component_namespace::bind_prefix_action, diff --git a/libs/full/agas_base/include/hpx/agas_base/server/primary_namespace.hpp b/libs/full/agas_base/include/hpx/agas_base/server/primary_namespace.hpp index c05c07408d11..c04cc98d4850 100644 --- a/libs/full/agas_base/include/hpx/agas_base/server/primary_namespace.hpp +++ b/libs/full/agas_base/include/hpx/agas_base/server/primary_namespace.hpp @@ -77,9 +77,9 @@ namespace hpx::agas { /// the underlying object. For all user-defined components, /// these bits contain a unique 88-bit number which is /// assigned sequentially for each locality. For -/// \a hpx#components#component_runtime_support the high 24 -/// bits are zeroed and the low 64 bits hold the LVA of the -/// component. +/// \a hpx#components#component_enum_type#runtime_support +/// the high 24 bits are zeroed and the low 64 bits hold the +/// LVA of the component. /// /// The following address ranges are reserved. Some are either explicitly or /// implicitly protected by AGAS. The letter x represents a single-byte diff --git a/libs/full/agas_base/src/component_namespace.cpp b/libs/full/agas_base/src/component_namespace.cpp index 0ba4224d629e..1b3094a02b76 100644 --- a/libs/full/agas_base/src/component_namespace.cpp +++ b/libs/full/agas_base/src/component_namespace.cpp @@ -15,13 +15,11 @@ #include -using hpx::components::component_agas_component_namespace; - using hpx::agas::server::component_namespace; HPX_DEFINE_COMPONENT_NAME(component_namespace, hpx_component_namespace) -HPX_DEFINE_GET_COMPONENT_TYPE_STATIC( - component_namespace, component_agas_component_namespace) +HPX_DEFINE_GET_COMPONENT_TYPE_STATIC(component_namespace, + to_int(components::component_enum_type::agas_component_namespace)) HPX_REGISTER_ACTION_ID( hpx::agas::server::component_namespace::bind_prefix_action, diff --git a/libs/full/agas_base/src/detail/bootstrap_component_namespace.cpp b/libs/full/agas_base/src/detail/bootstrap_component_namespace.cpp index 6c1c072497f2..e1951267b197 100644 --- a/libs/full/agas_base/src/detail/bootstrap_component_namespace.cpp +++ b/libs/full/agas_base/src/detail/bootstrap_component_namespace.cpp @@ -12,12 +12,13 @@ #include #include -namespace hpx { namespace agas { namespace detail { +namespace hpx::agas::detail { naming::address bootstrap_component_namespace::addr() const { return naming::address(agas::get_locality(), - components::component_agas_component_namespace, this->ptr()); + to_int(components::component_enum_type::agas_component_namespace), + this->ptr()); } hpx::id_type bootstrap_component_namespace::gid() const @@ -83,4 +84,4 @@ namespace hpx { namespace agas { namespace detail { { server_.unregister_server_instance(ec); } -}}} // namespace hpx::agas::detail +} // namespace hpx::agas::detail diff --git a/libs/full/agas_base/src/detail/bootstrap_locality_namespace.cpp b/libs/full/agas_base/src/detail/bootstrap_locality_namespace.cpp index 4c06c00231fc..0c27137b201f 100644 --- a/libs/full/agas_base/src/detail/bootstrap_locality_namespace.cpp +++ b/libs/full/agas_base/src/detail/bootstrap_locality_namespace.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2011 Bryce Lelbach -// Copyright (c) 2012-2021 Hartmut Kaiser +// Copyright (c) 2012-2024 Hartmut Kaiser // Copyright (c) 2016 Thomas Heller // // SPDX-License-Identifier: BSL-1.0 @@ -31,7 +31,8 @@ namespace hpx { namespace agas { namespace detail { naming::address bootstrap_locality_namespace::addr() const { return naming::address(agas::get_locality(), - components::component_agas_locality_namespace, this->ptr()); + to_int(components::component_enum_type::agas_locality_namespace), + this->ptr()); } hpx::id_type bootstrap_locality_namespace::gid() const diff --git a/libs/full/agas_base/src/locality_namespace.cpp b/libs/full/agas_base/src/locality_namespace.cpp index e96abe1d09a0..d6fd97791526 100644 --- a/libs/full/agas_base/src/locality_namespace.cpp +++ b/libs/full/agas_base/src/locality_namespace.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2011 Bryce Adelstein-Lelbach -// Copyright (c) 2011-2021 Hartmut Kaiser +// Copyright (c) 2011-2024 Hartmut Kaiser // Copyright (c) 2016 Thomas Heller // // SPDX-License-Identifier: BSL-1.0 @@ -11,16 +11,13 @@ #include #include #include -#include #include -using hpx::components::component_agas_locality_namespace; - using hpx::agas::server::locality_namespace; HPX_DEFINE_COMPONENT_NAME(locality_namespace, hpx_locality_namespace) -HPX_DEFINE_GET_COMPONENT_TYPE_STATIC( - locality_namespace, component_agas_locality_namespace) +HPX_DEFINE_GET_COMPONENT_TYPE_STATIC(locality_namespace, + to_int(hpx::components::component_enum_type::agas_locality_namespace)) HPX_REGISTER_BASE_LCO_WITH_VALUE_ID(hpx::parcelset::endpoints_type, parcelset_endpoints_type, diff --git a/libs/full/agas_base/src/primary_namespace.cpp b/libs/full/agas_base/src/primary_namespace.cpp index 3d5a3bfd7d89..a35e48136450 100644 --- a/libs/full/agas_base/src/primary_namespace.cpp +++ b/libs/full/agas_base/src/primary_namespace.cpp @@ -27,13 +27,11 @@ #include #include -using hpx::components::component_agas_primary_namespace; - using hpx::agas::server::primary_namespace; HPX_DEFINE_COMPONENT_NAME(primary_namespace, hpx_primary_namespace) -HPX_DEFINE_GET_COMPONENT_TYPE_STATIC( - primary_namespace, component_agas_primary_namespace) +HPX_DEFINE_GET_COMPONENT_TYPE_STATIC(primary_namespace, + to_int(components::component_enum_type::agas_primary_namespace)) HPX_REGISTER_ACTION_ID(primary_namespace::allocate_action, primary_namespace_allocate_action, @@ -143,7 +141,8 @@ namespace hpx { namespace agas { naming::address primary_namespace::addr() const { return naming::address(agas::get_locality(), - hpx::components::component_agas_primary_namespace, this->ptr()); + to_int(components::component_enum_type::agas_primary_namespace), + this->ptr()); } hpx::id_type primary_namespace::gid() const diff --git a/libs/full/agas_base/src/server/component_namespace_server.cpp b/libs/full/agas_base/src/server/component_namespace_server.cpp index 243f8ebd1a61..e4a4bda0d269 100644 --- a/libs/full/agas_base/src/server/component_namespace_server.cpp +++ b/libs/full/agas_base/src/server/component_namespace_server.cpp @@ -1,6 +1,6 @@ //////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2011 Bryce Adelstein-Lelbach -// Copyright (c) 2012-2017 Hartmut Kaiser +// Copyright (c) 2012-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -99,7 +99,6 @@ namespace hpx::agas::server { "component_namespace::bind_prefix", "component id table insertion failed due to a locking " "error or memory corruption"); - return components::component_invalid; } // If the insertion succeeded, we need to increment the type @@ -125,7 +124,6 @@ namespace hpx::agas::server { "component id is already registered for the given " "locality, key({1}), prefix({2}), ctype({3})", key, prefix, cit->second); - return components::component_invalid; } fit->second.insert(prefix); @@ -154,7 +152,6 @@ namespace hpx::agas::server { "component_namespace::bind_prefix", "factory table insertion failed due to a locking " "error or memory corruption"); - return components::component_invalid; } fit->second.insert(prefix); @@ -192,7 +189,6 @@ namespace hpx::agas::server { "component_namespace::bind_name", "component id table insertion failed due to a locking " "error or memory corruption"); - return components::component_invalid; } // If the insertion succeeded, we need to increment the type @@ -312,7 +308,7 @@ namespace hpx::agas::server { component_namespace::component_id_table_type const& m, components::component_type t) { - if (t < components::component_last) + if (t < to_int(components::component_enum_type::last)) return components::get_component_type_name(t); for (auto const& c : m) @@ -335,7 +331,7 @@ namespace hpx::agas::server { std::string result; - if (t == components::component_invalid) + if (t == to_int(hpx::components::component_enum_type::invalid)) { result = "component_invalid"; } diff --git a/libs/full/agas_base/src/server/locality_namespace_server.cpp b/libs/full/agas_base/src/server/locality_namespace_server.cpp index 3c1ff063eb8a..37924853dbd4 100644 --- a/libs/full/agas_base/src/server/locality_namespace_server.cpp +++ b/libs/full/agas_base/src/server/locality_namespace_server.cpp @@ -161,7 +161,9 @@ namespace hpx { namespace agas { namespace server { if (primary_) { naming::gid_type id(naming::get_gid_from_locality_id(prefix)); - gva const g(id, components::component_runtime_support, count); + gva const g(id, + to_int(hpx::components::component_enum_type::runtime_support), + count); if (!primary_->bind_gid(g, id, id)) { diff --git a/libs/full/agas_base/src/server/primary_namespace_server.cpp b/libs/full/agas_base/src/server/primary_namespace_server.cpp index a0a56c2f2e39..baa22de5ddad 100644 --- a/libs/full/agas_base/src/server/primary_namespace_server.cpp +++ b/libs/full/agas_base/src/server/primary_namespace_server.cpp @@ -242,7 +242,9 @@ namespace hpx::agas::server { "cannot change block size of existing binding"); } - if (HPX_UNLIKELY(components::component_invalid == g.type)) + if (HPX_UNLIKELY( + to_int(hpx::components::component_enum_type::invalid) == + g.type)) { l.unlock(); @@ -340,7 +342,9 @@ namespace hpx::agas::server { "MSBs of lower and upper range bound do not match"); } - if (HPX_UNLIKELY(components::component_invalid == g.type)) + if (HPX_UNLIKELY( + to_int(hpx::components::component_enum_type::invalid) == + g.type)) { l.unlock(); @@ -794,7 +798,9 @@ namespace hpx::agas::server { gva& g = get<1>(r); // REVIEW: Should we do more to make sure the GVA is valid? - if (HPX_UNLIKELY(components::component_invalid == g.type)) + if (HPX_UNLIKELY( + to_int(hpx::components::component_enum_type::invalid) == + g.type)) { l.unlock(); diff --git a/libs/full/agas_base/src/symbol_namespace.cpp b/libs/full/agas_base/src/symbol_namespace.cpp index 9e7795a05c4c..bf07bfd6f724 100644 --- a/libs/full/agas_base/src/symbol_namespace.cpp +++ b/libs/full/agas_base/src/symbol_namespace.cpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2011 Bryce Adelstein-Lelbach // Copyright (c) 2016 Thomas Heller -// Copyright (c) 2012-2023 Hartmut Kaiser +// Copyright (c) 2012-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -26,13 +26,11 @@ #include #include -using hpx::components::component_agas_symbol_namespace; - using hpx::agas::server::symbol_namespace; HPX_DEFINE_COMPONENT_NAME(symbol_namespace, hpx_symbol_namespace) -HPX_DEFINE_GET_COMPONENT_TYPE_STATIC( - symbol_namespace, component_agas_symbol_namespace) +HPX_DEFINE_GET_COMPONENT_TYPE_STATIC(symbol_namespace, + to_int(components::component_enum_type::agas_symbol_namespace)) HPX_REGISTER_ACTION_ID(symbol_namespace::bind_action, symbol_namespace_bind_action, hpx::actions::symbol_namespace_bind_action_id) @@ -132,7 +130,8 @@ namespace hpx::agas { naming::address symbol_namespace::addr() const { return {agas::get_locality(), - components::component_agas_symbol_namespace, this->ptr()}; + to_int(components::component_enum_type::agas_symbol_namespace), + this->ptr()}; } hpx::id_type symbol_namespace::gid() const diff --git a/libs/full/async_distributed/include/hpx/async_distributed/base_lco_with_value.hpp b/libs/full/async_distributed/include/hpx/async_distributed/base_lco_with_value.hpp index db0ffda3ae58..17bd1e538e8d 100644 --- a/libs/full/async_distributed/include/hpx/async_distributed/base_lco_with_value.hpp +++ b/libs/full/async_distributed/include/hpx/async_distributed/base_lco_with_value.hpp @@ -228,7 +228,8 @@ namespace hpx::traits { { static constexpr components::component_type get() noexcept { - return components::component_base_lco_with_value; + return to_int( + hpx::components::component_enum_type::base_lco_with_value); } static void set(components::component_type) @@ -245,7 +246,8 @@ namespace hpx::traits { { static constexpr components::component_type get() noexcept { - return components::component_base_lco_with_value_unmanaged; + return to_int(hpx::components::component_enum_type:: + base_lco_with_value_unmanaged); } static void set(components::component_type) diff --git a/libs/full/async_distributed/include/hpx/async_distributed/detail/post.hpp b/libs/full/async_distributed/include/hpx/async_distributed/detail/post.hpp index c2634bcd9819..7958e4057d79 100644 --- a/libs/full/async_distributed/include/hpx/async_distributed/detail/post.hpp +++ b/libs/full/async_distributed/include/hpx/async_distributed/detail/post.hpp @@ -50,7 +50,8 @@ namespace hpx { template inline naming::address&& complement_addr(naming::address& addr) { - if (components::component_invalid == addr.type_) + if (to_int(hpx::components::component_enum_type::invalid) == + addr.type_) { addr.type_ = components::get_component_type< typename Action::component_type>(); diff --git a/libs/full/async_distributed/include/hpx/async_distributed/detail/promise_lco.hpp b/libs/full/async_distributed/include/hpx/async_distributed/detail/promise_lco.hpp index 01076b638c41..8ec4d110e08a 100644 --- a/libs/full/async_distributed/include/hpx/async_distributed/detail/promise_lco.hpp +++ b/libs/full/async_distributed/include/hpx/async_distributed/detail/promise_lco.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // Copyright (c) 2016 Thomas Heller // Copyright (c) 2011 Bryce Adelstein-Lelbach // @@ -31,15 +31,12 @@ namespace hpx::lcos::detail { } /////////////////////////////////////////////////////////////////////////////// -namespace hpx::traits { - - template - struct managed_component_dtor_policy< - lcos::detail::promise_lco> - { - typedef managed_object_is_lifetime_controlled type; - }; -} // namespace hpx::traits +template +struct hpx::traits::managed_component_dtor_policy< + hpx::lcos::detail::promise_lco> +{ + using type = managed_object_is_lifetime_controlled; +}; // namespace hpx::traits /////////////////////////////////////////////////////////////////////////////// namespace hpx::lcos::detail { @@ -79,7 +76,7 @@ namespace hpx::lcos::detail { // implementation to associate this component with a given action. enum { - value = components::component_promise + value = to_int(hpx::components::component_enum_type::promise) }; protected: @@ -190,10 +187,13 @@ namespace hpx { // Promises are never created remotely, their factories are not // registered with AGAS, so we can assign the component types // locally. - if (value == components::component_invalid) + if (value == + to_int(hpx::components::component_enum_type::invalid)) { - value = derived_component_type(++detail::unique_type, - components::component_base_lco_with_value); + value = components::derived_component_type( + ++detail::unique_type, + to_int(hpx::components::component_enum_type:: + base_lco_with_value)); } return value; } @@ -207,7 +207,7 @@ namespace hpx { template components::component_type component_type_database< lcos::detail::promise_lco>::value = - components::component_invalid; + to_int(hpx::components::component_enum_type::invalid); } // namespace traits namespace components::detail { diff --git a/libs/full/async_distributed/include/hpx/async_distributed/trigger_lco.hpp b/libs/full/async_distributed/include/hpx/async_distributed/trigger_lco.hpp index c6722db8dd36..0177ae06e552 100644 --- a/libs/full/async_distributed/include/hpx/async_distributed/trigger_lco.hpp +++ b/libs/full/async_distributed/include/hpx/async_distributed/trigger_lco.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2023 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -166,7 +166,8 @@ namespace hpx { typename traits::promise_local_result::type; if (components::get_base_type(addr.type_) == - components::component_base_lco_with_value_unmanaged) + to_int( + components::component_enum_type::base_lco_with_value_unmanaged)) { using set_value_action = typename lcos::base_lco_with_value::type; if (components::get_base_type(addr.type_) == - components::component_base_lco_with_value_unmanaged) + to_int( + components::component_enum_type::base_lco_with_value_unmanaged)) { using set_value_action = typename lcos::base_lco_with_value - typename std::enable_if::type, - naming::address>::value>::type + std::enable_if_t, naming::address>> set_lco_value(hpx::id_type const& id, Result&& t, bool move_credits = true) { - naming::address addr( - nullptr, components::component_base_lco_with_value); + naming::address addr(nullptr, + to_int(components::component_enum_type::base_lco_with_value)); set_lco_value(id, HPX_MOVE(addr), HPX_FORWARD(Result, t), move_credits); } @@ -116,13 +115,13 @@ namespace hpx { /// send all credits in \a id along with the generated /// message. The default value is \a true. template - typename std::enable_if::type, - naming::address>::value>::type + std::enable_if_t, naming::address>> set_lco_value_unmanaged( hpx::id_type const& id, Result&& t, bool move_credits = true) { - naming::address addr( - nullptr, components::component_base_lco_with_value_unmanaged); + naming::address addr(nullptr, + to_int(components::component_enum_type:: + base_lco_with_value_unmanaged)); set_lco_value(id, HPX_MOVE(addr), HPX_FORWARD(Result, t), move_credits); } @@ -151,13 +150,12 @@ namespace hpx { /// send all credits in \a id along with the generated /// message. The default value is \a true. template - typename std::enable_if::type, - naming::address>::value>::type + std::enable_if_t, naming::address>> set_lco_value(hpx::id_type const& id, Result&& t, hpx::id_type const& cont, bool move_credits = true) { - naming::address addr( - nullptr, components::component_base_lco_with_value); + naming::address addr(nullptr, + to_int(components::component_enum_type::base_lco_with_value)); set_lco_value( id, HPX_MOVE(addr), HPX_FORWARD(Result, t), cont, move_credits); } @@ -172,13 +170,13 @@ namespace hpx { /// send all credits in \a id along with the generated /// message. The default value is \a true. template - typename std::enable_if::type, - naming::address>::value>::type + std::enable_if_t, naming::address>> set_lco_value_unmanaged(hpx::id_type const& id, Result&& t, hpx::id_type const& cont, bool move_credits = true) { - naming::address addr( - nullptr, components::component_base_lco_with_value_unmanaged); + naming::address addr(nullptr, + to_int(components::component_enum_type:: + base_lco_with_value_unmanaged)); set_lco_value( id, HPX_MOVE(addr), HPX_FORWARD(Result, t), cont, move_credits); } diff --git a/libs/full/async_distributed/src/base_lco.cpp b/libs/full/async_distributed/src/base_lco.cpp index 0fe0e48a2d44..38ba3b9d0f2c 100644 --- a/libs/full/async_distributed/src/base_lco.cpp +++ b/libs/full/async_distributed/src/base_lco.cpp @@ -85,4 +85,4 @@ HPX_REGISTER_COMPONENT_HEAP( /////////////////////////////////////////////////////////////////////////////// HPX_DEFINE_COMPONENT_NAME(hpx::lcos::base_lco, hpx_lcos_base_lco) HPX_DEFINE_GET_COMPONENT_TYPE_STATIC( - hpx::lcos::base_lco, hpx::components::component_base_lco) + hpx::lcos::base_lco, to_int(hpx::components::component_enum_type::base_lco)) diff --git a/libs/full/async_distributed/src/promise.cpp b/libs/full/async_distributed/src/promise.cpp index 2ca2c2cb3a39..cd0aaa28750a 100644 --- a/libs/full/async_distributed/src/promise.cpp +++ b/libs/full/async_distributed/src/promise.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -8,11 +8,11 @@ #include #include -namespace hpx { namespace traits { namespace detail { +namespace hpx::traits::detail { util::atomic_count unique_type( - static_cast(components::component_last)); -}}} // namespace hpx::traits::detail + to_int(components::component_enum_type::last)); +} // namespace hpx::traits::detail using promise_lco_void = hpx::components::managed_component< hpx::lcos::detail::promise_lco>; diff --git a/libs/full/async_distributed/tests/regressions/components/action_move_semantics.cpp b/libs/full/async_distributed/tests/regressions/components/action_move_semantics.cpp index ee6f9c368b4a..a2ef5f9ac236 100644 --- a/libs/full/async_distributed/tests/regressions/components/action_move_semantics.cpp +++ b/libs/full/async_distributed/tests/regressions/components/action_move_semantics.cpp @@ -1,10 +1,11 @@ -// Copyright (c) 2007-2012 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include + #if !defined(HPX_COMPUTE_DEVICE_CODE) #include #include @@ -15,16 +16,15 @@ HPX_REGISTER_COMPONENT_MODULE() using hpx::test::server::action_move_semantics; - -typedef hpx::components::component - action_move_semantics_type; +using action_move_semantics_type = + hpx::components::component; /////////////////////////////////////////////////////////////////////////////// // We use a special component registry for this component as it has to be // disabled by default. All tests requiring this component to be active will // enable it explicitly. HPX_REGISTER_COMPONENT(hpx::components::component, - action_move_semantics, hpx::components::factory_disabled) + action_move_semantics, hpx::components::factory_state::disabled) /////////////////////////////////////////////////////////////////////////////// HPX_REGISTER_ACTION( @@ -54,4 +54,5 @@ HPX_REGISTER_ACTION(hpx::test::server::action_move_semantics:: action_move_semantics_return_test_non_movable_direct_action) HPX_DEFINE_GET_COMPONENT_TYPE(action_move_semantics) + #endif diff --git a/libs/full/collectives/include/hpx/collectives/detail/latch.hpp b/libs/full/collectives/include/hpx/collectives/detail/latch.hpp index b7afaace33ab..b8ea3d081ddb 100644 --- a/libs/full/collectives/include/hpx/collectives/detail/latch.hpp +++ b/libs/full/collectives/include/hpx/collectives/detail/latch.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2022 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -46,7 +46,7 @@ namespace hpx { namespace lcos { namespace server { static components::component_type get_component_type() { - return components::component_latch; + return to_int(hpx::components::component_enum_type::latch); } static void set_component_type(components::component_type) {} @@ -64,7 +64,7 @@ namespace hpx { namespace lcos { namespace server { // implementation to associate this component with a given action. enum { - value = components::component_latch + value = to_int(hpx::components::component_enum_type::latch) }; latch() @@ -72,7 +72,7 @@ namespace hpx { namespace lcos { namespace server { { } - latch(std::ptrdiff_t number_of_threads) + explicit latch(std::ptrdiff_t number_of_threads) : latch_(number_of_threads) { } diff --git a/libs/full/collectives/src/detail/barrier_node.cpp b/libs/full/collectives/src/detail/barrier_node.cpp index 9a4bc286c2de..4a0f3b8c638a 100644 --- a/libs/full/collectives/src/detail/barrier_node.cpp +++ b/libs/full/collectives/src/detail/barrier_node.cpp @@ -31,13 +31,13 @@ HPX_REGISTER_COMPONENT_HEAP(barrier_type) HPX_DEFINE_COMPONENT_NAME( hpx::distributed::detail::barrier_node, hpx_lcos_barrier_node) -HPX_DEFINE_GET_COMPONENT_TYPE_STATIC( - hpx::distributed::detail::barrier_node, hpx::components::component_barrier) +HPX_DEFINE_GET_COMPONENT_TYPE_STATIC(hpx::distributed::detail::barrier_node, + to_int(hpx::components::component_enum_type::barrier)) HPX_REGISTER_ACTION(hpx::distributed::detail::barrier_node::gather_action, barrier_node_gather_action) -namespace hpx { namespace distributed { namespace detail { +namespace hpx::distributed::detail { barrier_node::barrier_node() : count_(0) @@ -352,4 +352,4 @@ namespace hpx { namespace distributed { namespace detail { HPX_ASSERT(false); #endif } -}}} // namespace hpx::distributed::detail +} // namespace hpx::distributed::detail diff --git a/libs/full/collectives/src/latch.cpp b/libs/full/collectives/src/latch.cpp index 126949766499..30d03b1c5be5 100644 --- a/libs/full/collectives/src/latch.cpp +++ b/libs/full/collectives/src/latch.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2022 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -94,10 +94,10 @@ namespace hpx::distributed { // latch typedef hpx::components::managed_component latch_type; -HPX_DEFINE_GET_COMPONENT_TYPE_STATIC( - hpx::lcos::server::latch, hpx::components::component_latch) +HPX_DEFINE_GET_COMPONENT_TYPE_STATIC(hpx::lcos::server::latch, + to_int(hpx::components::component_enum_type::latch)) HPX_REGISTER_DERIVED_COMPONENT_FACTORY(latch_type, hpx_lcos_server_latch, - "hpx::lcos::base_lco_with_value", hpx::components::factory_enabled) + "hpx::lcos::base_lco_with_value", hpx::components::factory_state::enabled) HPX_REGISTER_ACTION_ID(hpx::lcos::server::latch::create_component_action, hpx_lcos_server_latch_create_component_action, diff --git a/libs/full/components_base/include/hpx/components_base/component_commandline.hpp b/libs/full/components_base/include/hpx/components_base/component_commandline.hpp index 83dcaa7bb1ba..0fbaf9b3ab9d 100644 --- a/libs/full/components_base/include/hpx/components_base/component_commandline.hpp +++ b/libs/full/components_base/include/hpx/components_base/component_commandline.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -11,7 +11,7 @@ #include /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace components { +namespace hpx::components { /////////////////////////////////////////////////////////////////////////// namespace commandline_options_provider { @@ -40,18 +40,14 @@ namespace hpx { namespace components { return commandline_options_provider::add_commandline_options(); } }; -}} // namespace hpx::components +} // namespace hpx::components /////////////////////////////////////////////////////////////////////////////// #define HPX_DEFINE_COMPONENT_COMMANDLINE_OPTIONS(add_options_function) \ - namespace hpx { namespace components { \ - namespace commandline_options_provider { \ - hpx::program_options::options_description \ - add_commandline_options() \ - { \ - return add_options_function(); \ - } \ - } \ + namespace hpx::components::commandline_options_provider { \ + hpx::program_options::options_description add_commandline_options() \ + { \ + return add_options_function(); \ } \ } \ /***/ diff --git a/libs/full/components_base/include/hpx/components_base/component_startup_shutdown.hpp b/libs/full/components_base/include/hpx/components_base/component_startup_shutdown.hpp index 1796e6cd07a5..1e5916dc83b6 100644 --- a/libs/full/components_base/include/hpx/components_base/component_startup_shutdown.hpp +++ b/libs/full/components_base/include/hpx/components_base/component_startup_shutdown.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -11,7 +11,7 @@ #include /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace components { +namespace hpx::components { /////////////////////////////////////////////////////////////////////////// /// The \a component_startup_shutdown class provides a minimal @@ -26,6 +26,7 @@ namespace hpx { namespace components { /// function object with a reference to a startup /// function. This function will be executed by the /// runtime system during system startup. + /// \param pre_startup /// /// \return Returns \a true if the parameter \a startup has been /// successfully initialized with the startup function. @@ -41,6 +42,7 @@ namespace hpx { namespace components { /// function object with a reference to a startup /// function. This function will be executed by the /// runtime system during system startup. + /// \param pre_shutdown /// /// \return Returns \a true if the parameter \a shutdown has been /// successfully initialized with the shutdown function. @@ -50,39 +52,34 @@ namespace hpx { namespace components { return Shutdown(shutdown, pre_shutdown); } }; -}} // namespace hpx::components +} // namespace hpx::components /////////////////////////////////////////////////////////////////////////////// #define HPX_DEFINE_COMPONENT_STARTUP_SHUTDOWN(startup_, shutdown_) \ - namespace hpx { \ - namespace components { \ - namespace startup_shutdown_provider { \ - bool HPX_PP_CAT(HPX_PLUGIN_COMPONENT_PREFIX, _startup)( \ - startup_function_type & startup_func, bool& pre_startup) \ - { \ - hpx::function tmp = \ - static_cast( \ - startup_); \ - if (!!tmp) \ - { \ - return tmp(startup_func, pre_startup); \ - } \ - return false; \ - } \ - bool HPX_PP_CAT(HPX_PLUGIN_COMPONENT_PREFIX, _shutdown)( \ - shutdown_function_type & shutdown_func, \ - bool& pre_shutdown) \ - { \ - hpx::function tmp = \ - static_cast( \ - shutdown_); \ - if (!!tmp) \ - { \ - return tmp(shutdown_func, pre_shutdown); \ - } \ - return false; \ - } \ + namespace hpx::components::startup_shutdown_provider { \ + bool HPX_PP_CAT(HPX_PLUGIN_COMPONENT_PREFIX, _startup)( \ + startup_function_type & startup_func, bool& pre_startup) \ + { \ + hpx::function tmp = \ + static_cast( \ + startup_); \ + if (!!tmp) \ + { \ + return tmp(startup_func, pre_startup); \ } \ + return false; \ + } \ + bool HPX_PP_CAT(HPX_PLUGIN_COMPONENT_PREFIX, _shutdown)( \ + shutdown_function_type & shutdown_func, bool& pre_shutdown) \ + { \ + hpx::function tmp = \ + static_cast( \ + shutdown_); \ + if (!!tmp) \ + { \ + return tmp(shutdown_func, pre_shutdown); \ + } \ + return false; \ } \ } \ /***/ @@ -90,23 +87,18 @@ namespace hpx { namespace components { /////////////////////////////////////////////////////////////////////////////// #define HPX_REGISTER_STARTUP_SHUTDOWN_MODULE_(startup, shutdown) \ HPX_DEFINE_COMPONENT_STARTUP_SHUTDOWN(startup, shutdown) \ - namespace hpx { \ - namespace components { \ - namespace startup_shutdown_provider { \ - typedef component_startup_shutdown< \ - HPX_PP_CAT(HPX_PLUGIN_COMPONENT_PREFIX, _startup), \ - HPX_PP_CAT(HPX_PLUGIN_COMPONENT_PREFIX, _shutdown)> \ - HPX_PP_CAT(HPX_PLUGIN_COMPONENT_PREFIX, _provider); \ - } \ - } \ + namespace hpx::components::startup_shutdown_provider { \ + using HPX_PP_CAT(HPX_PLUGIN_COMPONENT_PREFIX, _provider) = \ + component_startup_shutdown; \ } \ - namespace hpx { namespace components { \ - template struct component_startup_shutdown< \ - startup_shutdown_provider::HPX_PP_CAT( \ - HPX_PLUGIN_COMPONENT_PREFIX, _startup), \ - startup_shutdown_provider::HPX_PP_CAT( \ - HPX_PLUGIN_COMPONENT_PREFIX, _shutdown)>; \ - } \ + namespace hpx::components { \ + template struct component_startup_shutdown< \ + startup_shutdown_provider::HPX_PP_CAT( \ + HPX_PLUGIN_COMPONENT_PREFIX, _startup), \ + startup_shutdown_provider::HPX_PP_CAT( \ + HPX_PLUGIN_COMPONENT_PREFIX, _shutdown)>; \ } \ /**/ diff --git a/libs/full/components_base/include/hpx/components_base/component_type.hpp b/libs/full/components_base/include/hpx/components_base/component_type.hpp index 4080de057949..001972c10540 100644 --- a/libs/full/components_base/include/hpx/components_base/component_type.hpp +++ b/libs/full/components_base/include/hpx/components_base/component_type.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2023 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // Copyright (c) 2017 Thomas Heller // Copyright (c) 2011 Bryce Lelbach // @@ -23,7 +23,7 @@ #include #include -#include +#include #include /////////////////////////////////////////////////////////////////////////////// @@ -32,62 +32,136 @@ namespace hpx::components { // declared in hpx/modules/naming.hpp // using component_type = std::int32_t; - enum component_enum_type + enum class component_enum_type : naming::component_type { - component_invalid = naming::address::component_invalid, + invalid = naming::address::component_invalid, // Runtime support component (provides system services such as // component creation, etc.). One per locality. - component_runtime_support = 0, + runtime_support = 0, // Pseudo-component to be used for plain actions - component_plain_function = 1, + plain_function = 1, // Base component for LCOs that do not produce a value. - component_base_lco = 2, + base_lco = 2, // Base component for LCOs that produce values. - component_base_lco_with_value_unmanaged = 3, + base_lco_with_value_unmanaged = 3, // (Managed) base component for LCOs that produce values. - component_base_lco_with_value = 4, + base_lco_with_value = 4, // Synchronization latch, barrier, and flex_barrier LCOs. - component_latch = ((5 << 10) | component_base_lco_with_value), - component_barrier = ((6 << 10) | component_base_lco), + latch = ((5 << 10) | base_lco_with_value), + barrier = ((6 << 10) | base_lco), // An LCO representing a value which may not have been computed yet. - component_promise = ((7 << 10) | component_base_lco_with_value), + promise = ((7 << 10) | base_lco_with_value), // AGAS locality services. - component_agas_locality_namespace = 8, + agas_locality_namespace = 8, // AGAS primary address resolution services. - component_agas_primary_namespace = 9, + agas_primary_namespace = 9, // AGAS global type system. - component_agas_component_namespace = 10, + agas_component_namespace = 10, // AGAS symbolic naming services. - component_agas_symbol_namespace = 11, + agas_symbol_namespace = 11, - component_last, - component_first_dynamic = component_last, - - // Force this enum type to be at least 20 bits. - component_upper_bound = 0xfffffL //-V112 + last, + first_dynamic = last, }; - enum factory_state_enum + constexpr naming::component_type to_int(component_enum_type t) noexcept + { + return static_cast(t); + } + +#define HPX_COMPONENT_ENUM_TYPE_ENUM_DEPRECATION_MSG \ + "The unscoped hpx::components::component_enum_type names are deprecated. " \ + "Please use hpx::components::component_enum_type:: instead." + + HPX_DEPRECATED_V(1, 10, HPX_COMPONENT_ENUM_TYPE_ENUM_DEPRECATION_MSG) + inline constexpr component_enum_type component_invalid = + component_enum_type::invalid; + HPX_DEPRECATED_V(1, 10, HPX_COMPONENT_ENUM_TYPE_ENUM_DEPRECATION_MSG) + inline constexpr component_enum_type component_runtime_support = + component_enum_type::runtime_support; + HPX_DEPRECATED_V(1, 10, HPX_COMPONENT_ENUM_TYPE_ENUM_DEPRECATION_MSG) + inline constexpr component_enum_type component_plain_function = + component_enum_type::plain_function; + HPX_DEPRECATED_V(1, 10, HPX_COMPONENT_ENUM_TYPE_ENUM_DEPRECATION_MSG) + inline constexpr component_enum_type component_base_lco = + component_enum_type::base_lco; + HPX_DEPRECATED_V(1, 10, HPX_COMPONENT_ENUM_TYPE_ENUM_DEPRECATION_MSG) + inline constexpr component_enum_type + component_base_lco_with_value_unmanaged = + component_enum_type::base_lco_with_value_unmanaged; + HPX_DEPRECATED_V(1, 10, HPX_COMPONENT_ENUM_TYPE_ENUM_DEPRECATION_MSG) + inline constexpr component_enum_type component_base_lco_with_value = + component_enum_type::base_lco_with_value; + HPX_DEPRECATED_V(1, 10, HPX_COMPONENT_ENUM_TYPE_ENUM_DEPRECATION_MSG) + inline constexpr component_enum_type component_latch = + component_enum_type::latch; + HPX_DEPRECATED_V(1, 10, HPX_COMPONENT_ENUM_TYPE_ENUM_DEPRECATION_MSG) + inline constexpr component_enum_type component_barrier = + component_enum_type::barrier; + HPX_DEPRECATED_V(1, 10, HPX_COMPONENT_ENUM_TYPE_ENUM_DEPRECATION_MSG) + inline constexpr component_enum_type component_promise = + component_enum_type::promise; + HPX_DEPRECATED_V(1, 10, HPX_COMPONENT_ENUM_TYPE_ENUM_DEPRECATION_MSG) + inline constexpr component_enum_type component_agas_locality_namespace = + component_enum_type::agas_locality_namespace; + HPX_DEPRECATED_V(1, 10, HPX_COMPONENT_ENUM_TYPE_ENUM_DEPRECATION_MSG) + inline constexpr component_enum_type component_agas_primary_namespace = + component_enum_type::agas_primary_namespace; + HPX_DEPRECATED_V(1, 10, HPX_COMPONENT_ENUM_TYPE_ENUM_DEPRECATION_MSG) + inline constexpr component_enum_type component_agas_component_namespace = + component_enum_type::agas_component_namespace; + HPX_DEPRECATED_V(1, 10, HPX_COMPONENT_ENUM_TYPE_ENUM_DEPRECATION_MSG) + inline constexpr component_enum_type component_agas_symbol_namespace = + component_enum_type::agas_symbol_namespace; + HPX_DEPRECATED_V(1, 10, HPX_COMPONENT_ENUM_TYPE_ENUM_DEPRECATION_MSG) + inline constexpr component_enum_type component_last = + component_enum_type::last; + HPX_DEPRECATED_V(1, 10, HPX_COMPONENT_ENUM_TYPE_ENUM_DEPRECATION_MSG) + inline constexpr component_enum_type component_first_dynamic = + component_enum_type::first_dynamic; + +#undef HPX_COMPONENT_ENUM_TYPE_ENUM_DEPRECATION_MSG + + enum class factory_state : std::uint8_t { - factory_enabled = 0, - factory_disabled = 1, - factory_check = 2 + enabled = 0, + disabled = 1, + check = 2 }; + constexpr int to_int(factory_state t) noexcept + { + return static_cast(t); + } + +#define HPX_FACTORY_STATE_ENUM_DEPRECATION_MSG \ + "The unscoped hpx::components::factory_state_enum names are deprecated. " \ + "Please use hpx::components::factory_state:: instead." + + HPX_DEPRECATED_V(1, 10, HPX_FACTORY_STATE_ENUM_DEPRECATION_MSG) + inline constexpr factory_state factory_enabled = factory_state::enabled; + HPX_DEPRECATED_V(1, 10, HPX_FACTORY_STATE_ENUM_DEPRECATION_MSG) + inline constexpr factory_state factory_disabled = factory_state::disabled; + HPX_DEPRECATED_V(1, 10, HPX_FACTORY_STATE_ENUM_DEPRECATION_MSG) + inline constexpr factory_state factory_check = factory_state::check; + +#undef HPX_FACTORY_STATE_ENUM_DEPRECATION_MSG + // access data related to component instance counts HPX_EXPORT bool& enabled(component_type type); HPX_EXPORT util::atomic_count& instance_count(component_type type); + using component_deleter_type = void (*)( hpx::naming::gid_type const&, hpx::naming::address const&); HPX_EXPORT component_deleter_type& deleter(component_type type); @@ -124,14 +198,15 @@ namespace hpx::components { component_type lhs, component_type rhs) noexcept { // don't compare types if one of them is unknown - if (component_invalid == rhs || component_invalid == lhs) + if (to_int(component_enum_type::invalid) == rhs || + to_int(component_enum_type::invalid) == lhs) { return true; // no way of telling, so we assume the best :-P } // don't compare types if one of them is component_runtime_support - if (component_runtime_support == rhs || - component_runtime_support == lhs) + if (to_int(component_enum_type::runtime_support) == rhs || + to_int(component_enum_type::runtime_support) == lhs) { return true; } @@ -145,28 +220,34 @@ namespace hpx::components { } // special case for lco's - if (lhs_base == component_base_lco && - (rhs_base == component_base_lco_with_value_unmanaged || - rhs_base == component_base_lco_with_value)) + if (lhs_base == to_int(component_enum_type::base_lco) && + (rhs_base == + to_int( + component_enum_type::base_lco_with_value_unmanaged) || + rhs_base == to_int(component_enum_type::base_lco_with_value))) { return true; } - if (rhs_base == component_base_lco && - (lhs_base == component_base_lco_with_value_unmanaged || - lhs_base == component_base_lco_with_value)) + if (rhs_base == to_int(component_enum_type::base_lco) && + (lhs_base == + to_int( + component_enum_type::base_lco_with_value_unmanaged) || + lhs_base == to_int(component_enum_type::base_lco_with_value))) { return true; } - if (lhs_base == component_base_lco_with_value_unmanaged && - rhs_base == component_base_lco_with_value) + if (lhs_base == + to_int(component_enum_type::base_lco_with_value_unmanaged) && + rhs_base == to_int(component_enum_type::base_lco_with_value)) { return true; } - if (lhs_base == component_base_lco_with_value && - rhs_base == component_base_lco_with_value_unmanaged) + if (lhs_base == to_int(component_enum_type::base_lco_with_value) && + rhs_base == + to_int(component_enum_type::base_lco_with_value_unmanaged)) { return true; } @@ -178,7 +259,7 @@ namespace hpx::components { // Resolve the type from AGAS HPX_EXPORT component_type get_agas_component_type( - const char* name, const char* base_name, component_type, bool); + char const* name, char const* base_name, component_type, bool); } // namespace detail // Returns the (unique) name for a given component @@ -188,7 +269,7 @@ namespace hpx::components { // Returns the (unique) name of the base component. If there is none, // nullptr is returned template - HPX_ALWAYS_EXPORT const char* get_component_base_name() noexcept; + HPX_ALWAYS_EXPORT char const* get_component_base_name() noexcept; template component_type get_component_type() noexcept @@ -203,74 +284,62 @@ namespace hpx::components { } } // namespace hpx::components -namespace hpx::naming { - - // this is defined in this module as its implementation relies on - // components::get_component_type_name() - HPX_EXPORT std::ostream& operator<<(std::ostream&, address const&); -} // namespace hpx::naming - /////////////////////////////////////////////////////////////////////////////// #define HPX_DEFINE_GET_COMPONENT_TYPE(component) \ - namespace hpx { namespace traits { \ - template <> \ - HPX_ALWAYS_EXPORT components::component_type \ - component_type_database::get() noexcept \ - { \ - return value; \ - } \ - template <> \ - HPX_ALWAYS_EXPORT void component_type_database::set( \ - components::component_type t) \ - { \ - value = t; \ - } \ + namespace hpx::traits { \ + template <> \ + HPX_ALWAYS_EXPORT components::component_type \ + component_type_database::get() noexcept \ + { \ + return value; \ + } \ + template <> \ + HPX_ALWAYS_EXPORT void component_type_database::set( \ + components::component_type t) \ + { \ + value = t; \ } \ } \ /**/ #define HPX_DEFINE_GET_COMPONENT_TYPE_TEMPLATE(template_, component) \ - namespace hpx { namespace traits { \ - HPX_PP_STRIP_PARENS(template_) \ - struct component_type_database \ - { \ - static components::component_type value; \ + namespace hpx::traits { \ + HPX_PP_STRIP_PARENS(template_) \ + struct component_type_database \ + { \ + static components::component_type value; \ \ - HPX_ALWAYS_EXPORT static components::component_type \ - get() noexcept \ - { \ - return value; \ - } \ - HPX_ALWAYS_EXPORT static void set( \ - components::component_type t) \ - { \ - value = t; \ - } \ - }; \ + HPX_ALWAYS_EXPORT static components::component_type get() noexcept \ + { \ + return value; \ + } \ + HPX_ALWAYS_EXPORT static void set(components::component_type t) \ + { \ + value = t; \ + } \ + }; \ \ - HPX_PP_STRIP_PARENS(template_) \ - components::component_type component_type_database< \ - HPX_PP_STRIP_PARENS(component)>::value = \ - components::component_invalid; \ - } \ + HPX_PP_STRIP_PARENS(template_) \ + components::component_type \ + component_type_database::value = \ + to_int(hpx::components::component_enum_type::invalid); \ } \ /**/ /////////////////////////////////////////////////////////////////////////////// #define HPX_DEFINE_GET_COMPONENT_TYPE_STATIC(component, type) \ - namespace hpx { namespace traits { \ - template <> \ - HPX_ALWAYS_EXPORT components::component_type \ - component_type_database::get() noexcept \ - { \ - return type; \ - } \ - template <> \ - HPX_ALWAYS_EXPORT void component_type_database::set( \ - components::component_type) \ - { \ - HPX_ASSERT(false); \ - } \ + namespace hpx::traits { \ + template <> \ + HPX_ALWAYS_EXPORT components::component_type \ + component_type_database::get() noexcept \ + { \ + return type; \ + } \ + template <> \ + HPX_ALWAYS_EXPORT void component_type_database::set( \ + components::component_type) \ + { \ + HPX_ASSERT(false); \ } \ } \ /**/ @@ -283,37 +352,35 @@ namespace hpx::naming { /**/ #define HPX_DEFINE_COMPONENT_NAME_2(Component, name) \ - namespace hpx { namespace components { \ - template <> \ - HPX_ALWAYS_EXPORT char const* \ - get_component_name() noexcept \ - { \ - return HPX_PP_STRINGIZE(name); \ - } \ - template <> \ - HPX_ALWAYS_EXPORT char const* \ - get_component_base_name() noexcept \ - { \ - return nullptr; \ - } \ + namespace hpx::components { \ + template <> \ + HPX_ALWAYS_EXPORT char const* \ + get_component_name() noexcept \ + { \ + return HPX_PP_STRINGIZE(name); \ + } \ + template <> \ + HPX_ALWAYS_EXPORT char const* \ + get_component_base_name() noexcept \ + { \ + return nullptr; \ } \ } \ /**/ #define HPX_DEFINE_COMPONENT_NAME_3(Component, name, base_name) \ - namespace hpx { namespace components { \ - template <> \ - HPX_ALWAYS_EXPORT char const* \ - get_component_name() noexcept \ - { \ - return HPX_PP_STRINGIZE(name); \ - } \ - template <> \ - HPX_ALWAYS_EXPORT char const* \ - get_component_base_name() noexcept \ - { \ - return base_name; \ - } \ + namespace hpx::components { \ + template <> \ + HPX_ALWAYS_EXPORT char const* \ + get_component_name() noexcept \ + { \ + return HPX_PP_STRINGIZE(name); \ + } \ + template <> \ + HPX_ALWAYS_EXPORT char const* \ + get_component_base_name() noexcept \ + { \ + return base_name; \ } \ } \ /**/ diff --git a/libs/full/components_base/include/hpx/components_base/components_base_fwd.hpp b/libs/full/components_base/include/hpx/components_base/components_base_fwd.hpp index 184415d55517..1ad0676706f9 100644 --- a/libs/full/components_base/include/hpx/components_base/components_base_fwd.hpp +++ b/libs/full/components_base/include/hpx/components_base/components_base_fwd.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2023 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // Copyright (c) 2011 Bryce Lelbach // // SPDX-License-Identifier: BSL-1.0 @@ -10,55 +10,42 @@ #include #include -namespace hpx { +namespace hpx::components { - /// \namespace components - namespace components { + /////////////////////////////////////////////////////////////////////// + class pinned_ptr; - /// \cond NODETAIL - namespace detail { - struct this_type - { - }; - } // namespace detail - /// \endcond + /////////////////////////////////////////////////////////////////////// + template + class fixed_component; - /////////////////////////////////////////////////////////////////////// - class pinned_ptr; + template + class component; - /////////////////////////////////////////////////////////////////////// - template - class fixed_component; + template + class managed_component; - template - class component; + /////////////////////////////////////////////////////////////////////// + template + class component_base; - template - class managed_component; + template + class fixed_component_base; - /////////////////////////////////////////////////////////////////////// - template - class component_base; + template + class abstract_component_base; - template - class fixed_component_base; + template + using abstract_simple_component_base HPX_DEPRECATED_V(1, 8, + "The type hpx::components::abstract_simple_component_base is " + "deprecated. Please use hpx::components::abstract_component_base " + "instead.") = abstract_component_base; - template - class abstract_component_base; + template + class abstract_managed_component_base; - template - using abstract_simple_component_base HPX_DEPRECATED_V(1, 8, - "The type hpx::components::abstract_simple_component_base is " - "deprecated. Please use hpx::components::abstract_component_base " - "instead.") = abstract_component_base; - - template - class abstract_managed_component_base; - - template - class managed_component_base; - - } // namespace components -} // namespace hpx + template + class managed_component_base; +} // namespace hpx::components diff --git a/libs/full/components_base/include/hpx/components_base/generate_unique_ids.hpp b/libs/full/components_base/include/hpx/components_base/generate_unique_ids.hpp index 0e878afc8790..d3cd855cdaad 100644 --- a/libs/full/components_base/include/hpx/components_base/generate_unique_ids.hpp +++ b/libs/full/components_base/include/hpx/components_base/generate_unique_ids.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // Copyright (c) 2011 Bryce Lelbach // // SPDX-License-Identifier: BSL-1.0 @@ -12,51 +12,32 @@ #include #include -#include #include -namespace hpx { namespace util { +namespace hpx::util { - /// The unique_id_ranges class is a type responsible for generating - /// unique ids for components, parcels, threads etc. + // The unique_id_ranges class is a type responsible for generating unique + // ids for components, parcels, threads etc. class HPX_EXPORT unique_id_ranges { - using mutex_type = hpx::util::spinlock; - - mutex_type mtx_; - - /// size of the id range returned by command_getidrange - /// FIXME: is this a policy? - enum - { - range_delta = 0x100000 - }; + // size of the id range returned by get_id + static constexpr std::size_t range_delta = 0x100000; public: - unique_id_ranges() - : mtx_() - , lower_(nullptr) - , upper_(nullptr) - { - } - - /// Generate next unique component id + // Generate next unique component id naming::gid_type get_id(std::size_t count = 1); void set_range( - naming::gid_type const& lower, naming::gid_type const& upper) - { - std::lock_guard l(mtx_); - lower_ = lower; - upper_ = upper; - } + naming::gid_type const& lower, naming::gid_type const& upper); private: - /// The range of available ids for components + hpx::util::spinlock mtx_; + + // The range of available ids for components naming::gid_type lower_; naming::gid_type upper_; }; -}} // namespace hpx::util +} // namespace hpx::util #include diff --git a/libs/full/components_base/include/hpx/components_base/server/abstract_component_base.hpp b/libs/full/components_base/include/hpx/components_base/server/abstract_component_base.hpp index 3665218a1d11..a962a5a62834 100644 --- a/libs/full/components_base/include/hpx/components_base/server/abstract_component_base.hpp +++ b/libs/full/components_base/include/hpx/components_base/server/abstract_component_base.hpp @@ -1,5 +1,5 @@ // Copyright (c) 2012 Bryce Adelstein-Lelbach -// Copyright (c) 2013-2021 Hartmut Kaiser +// Copyright (c) 2013-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -13,13 +13,11 @@ #include #include -#include - -namespace hpx { namespace components { +namespace hpx::components { /////////////////////////////////////////////////////////////////////////// template - class abstract_component_base : private traits::detail::component_tag + class abstract_component_base : traits::detail::component_tag { public: using wrapping_type = component; @@ -108,4 +106,4 @@ namespace hpx { namespace components { const_cast(static_cast(this))); } }; -}} // namespace hpx::components +} // namespace hpx::components diff --git a/libs/full/components_base/include/hpx/components_base/server/component.hpp b/libs/full/components_base/include/hpx/components_base/server/component.hpp index bbfbbf849278..88e5ad75216f 100644 --- a/libs/full/components_base/include/hpx/components_base/server/component.hpp +++ b/libs/full/components_base/include/hpx/components_base/server/component.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // Copyright (c) 2015-2017 Thomas Heller // Copyright (c) 2011 Bryce Lelbach // @@ -25,12 +25,12 @@ namespace hpx::components::detail { template struct simple_heap { - void* alloc(std::size_t count) + static void* alloc(std::size_t count) { HPX_ASSERT(1 == count); return alloc_.allocate(count); } - void free(void* p, std::size_t count) noexcept + static void free(void* p, std::size_t count) noexcept { HPX_ASSERT(1 == count); alloc_.deallocate(static_cast(p), count); diff --git a/libs/full/components_base/include/hpx/components_base/server/component_base.hpp b/libs/full/components_base/include/hpx/components_base/server/component_base.hpp index 2ad5123d0753..04e613233458 100644 --- a/libs/full/components_base/include/hpx/components_base/server/component_base.hpp +++ b/libs/full/components_base/include/hpx/components_base/server/component_base.hpp @@ -1,5 +1,5 @@ // Copyright (c) 2015 Thomas Heller -// Copyright (c) 2007-2023 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -84,9 +84,9 @@ namespace hpx::components { class component_base : public detail::base_component { protected: - using this_component_type = std::conditional_t< - std::is_same_v, - component_base, Component>; + using this_component_type = + std::conditional_t, component_base, + Component>; public: using wrapped_type = this_component_type; diff --git a/libs/full/components_base/include/hpx/components_base/server/component_heap.hpp b/libs/full/components_base/include/hpx/components_base/server/component_heap.hpp index 5bb8a266cf8d..5f85eb3ffacd 100644 --- a/libs/full/components_base/include/hpx/components_base/server/component_heap.hpp +++ b/libs/full/components_base/include/hpx/components_base/server/component_heap.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2011-2017 Thomas Heller +// Copyright (c) 2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -9,10 +10,11 @@ #include #include -namespace hpx { namespace components { +namespace hpx::components { - // This is a utility to ensure that there exists exactly one heap - // per component. + // This is a utility to ensure that there exists exactly one heap per + // component. + // // This is the customization point and will be defined by the registration // macros namespace detail { @@ -37,18 +39,16 @@ namespace hpx { namespace components { { return detail::component_heap_helper(nullptr); } -}} // namespace hpx::components +} // namespace hpx::components #define HPX_REGISTER_COMPONENT_HEAP(Component) \ - namespace hpx { namespace components { namespace detail { \ - template <> \ - HPX_ALWAYS_EXPORT Component::heap_type& \ - component_heap_helper(...) \ - { \ - util::reinitializable_static heap; \ - return heap.get(); \ - } \ - } \ + namespace hpx::components::detail { \ + template <> \ + HPX_ALWAYS_EXPORT Component::heap_type& \ + component_heap_helper(...) \ + { \ + util::reinitializable_static heap; \ + return heap.get(); \ } \ } \ /**/ diff --git a/libs/full/components_base/include/hpx/components_base/server/create_component.hpp b/libs/full/components_base/include/hpx/components_base/server/create_component.hpp index 8b8814d250d5..075a964a1e23 100644 --- a/libs/full/components_base/include/hpx/components_base/server/create_component.hpp +++ b/libs/full/components_base/include/hpx/components_base/server/create_component.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2022 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // Copyright (c) 2011-2017 Thomas Heller // // SPDX-License-Identifier: BSL-1.0 @@ -12,22 +12,20 @@ #include #include #include -#include #include -#include #include #include /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace components { namespace server { +namespace hpx::components::server { /////////////////////////////////////////////////////////////////////////// /// Create a component and forward the passed parameters template naming::gid_type create(Ts&&... ts) { - component_type type = + component_type const type = get_component_type(); if (!enabled(type)) { @@ -35,7 +33,6 @@ namespace hpx { namespace components { namespace server { "components::server::::create", "the component is disabled for this locality ({})", get_component_type_name(type)); - return naming::invalid_gid; } void* storage = component_heap().alloc(1); @@ -70,7 +67,7 @@ namespace hpx { namespace components { namespace server { naming::gid_type create_migrated( naming::gid_type const& gid, void** p, Ts&&... ts) { - component_type type = + component_type const type = get_component_type(); if (!enabled(type)) { @@ -78,7 +75,6 @@ namespace hpx { namespace components { namespace server { "components::server::create_migrated", "the component is disabled for this locality ({})", get_component_type_name(type)); - return naming::invalid_gid; } void* storage = component_heap().alloc(1); @@ -94,7 +90,7 @@ namespace hpx { namespace components { namespace server { throw; } - naming::gid_type assigned_gid = c->get_base_gid(gid); + naming::gid_type const assigned_gid = c->get_base_gid(gid); if (assigned_gid && assigned_gid == gid) { // everything is ok, return the new id @@ -115,8 +111,6 @@ namespace hpx { namespace components { namespace server { "the global id {} is already bound to a different component " "instance", gid); - - return naming::invalid_gid; } /////////////////////////////////////////////////////////////////////////// @@ -124,7 +118,7 @@ namespace hpx { namespace components { namespace server { template std::vector bulk_create(std::size_t count, Ts&&... ts) { - component_type type = + component_type const type = get_component_type(); std::vector gids; if (!enabled(type)) @@ -133,7 +127,6 @@ namespace hpx { namespace components { namespace server { "components::server::bulk_create", "the component is disabled for this locality ({})", get_component_type_name(type)); - return gids; } gids.reserve(count); @@ -178,4 +171,4 @@ namespace hpx { namespace components { namespace server { return gids; } -}}} // namespace hpx::components::server +} // namespace hpx::components::server diff --git a/libs/full/components_base/include/hpx/components_base/server/create_component_fwd.hpp b/libs/full/components_base/include/hpx/components_base/server/create_component_fwd.hpp index 23ae6381358c..1490a0e06902 100644 --- a/libs/full/components_base/include/hpx/components_base/server/create_component_fwd.hpp +++ b/libs/full/components_base/include/hpx/components_base/server/create_component_fwd.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // Copyright (c) 2011 Thomas Heller // Copyright (c) 2015 Hartmut Kaiser // @@ -12,12 +12,11 @@ #include #include -#include #include #include /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace components { namespace server { +namespace hpx::components::server { /////////////////////////////////////////////////////////////////////////// /// Create arrays of components using their default constructor @@ -32,8 +31,8 @@ namespace hpx { namespace components { namespace server { std::vector bulk_create(std::size_t count, Ts&&... ts); template - inline naming::gid_type construct(Ts&&... ts) + naming::gid_type construct(Ts&&... ts) { return create(HPX_FORWARD(Ts, ts)...); } -}}} // namespace hpx::components::server +} // namespace hpx::components::server diff --git a/libs/full/components_base/include/hpx/components_base/server/fixed_component_base.hpp b/libs/full/components_base/include/hpx/components_base/server/fixed_component_base.hpp index 7e8d696d647a..c09b5a5c2f82 100644 --- a/libs/full/components_base/include/hpx/components_base/server/fixed_component_base.hpp +++ b/libs/full/components_base/include/hpx/components_base/server/fixed_component_base.hpp @@ -1,5 +1,5 @@ // Copyright (c) 2011 Bryce Lelbach -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -28,10 +28,9 @@ namespace hpx::components { template class fixed_component_base : public traits::detail::fixed_component_tag { - private: using this_component_type = - std::conditional_t, - fixed_component_base, Component>; + std::conditional_t, fixed_component_base, + Component>; constexpr Component& derived() noexcept { @@ -72,7 +71,6 @@ namespace hpx::components { } } - public: // Return the component's fixed GID. naming::gid_type get_base_gid( naming::gid_type const& assign_gid = naming::invalid_gid) const @@ -108,7 +106,6 @@ namespace hpx::components { return gid_; } - public: hpx::id_type get_id() const { // fixed_address components are created without any credits diff --git a/libs/full/components_base/include/hpx/components_base/server/locking_hook.hpp b/libs/full/components_base/include/hpx/components_base/server/locking_hook.hpp index b3805ddbe822..a1ce2f9f8c88 100644 --- a/libs/full/components_base/include/hpx/components_base/server/locking_hook.hpp +++ b/libs/full/components_base/include/hpx/components_base/server/locking_hook.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2023 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -127,7 +127,8 @@ namespace hpx::components { // Execute the wrapped action. This locks the mutex ensuring a thread // safe action invocation. threads::thread_result_type thread_function( - threads::thread_function_type f, threads::thread_arg_type state) + threads::thread_function_type const& f, + threads::thread_arg_type state) { threads::thread_result_type result; @@ -179,7 +180,7 @@ namespace hpx::components { // The yield decorator unlocks the mutex and calls the system yield // which gives up control back to the thread manager. threads::thread_arg_type yield_function( - threads::thread_result_type state) + threads::thread_result_type const& state) { // We undecorate the yield function as the lock handling may // suspend, which causes an infinite recursion otherwise. diff --git a/libs/full/components_base/include/hpx/components_base/server/managed_component_base.hpp b/libs/full/components_base/include/hpx/components_base/server/managed_component_base.hpp index 282c5ecf259a..fdc02d6574de 100644 --- a/libs/full/components_base/include/hpx/components_base/server/managed_component_base.hpp +++ b/libs/full/components_base/include/hpx/components_base/server/managed_component_base.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2023 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // Copyright (c) 2011-2017 Thomas Heller // // SPDX-License-Identifier: BSL-1.0 @@ -159,25 +159,24 @@ namespace hpx::components { /////////////////////////////////////////////////////////////////////////// namespace detail { - struct base_managed_component - : public traits::detail::managed_component_tag + struct base_managed_component : traits::detail::managed_component_tag { // finalize() will be called just before the instance gets destructed static constexpr void finalize() noexcept {} static void mark_as_migrated() noexcept { - // If this assertion is triggered then this component instance is - // being migrated even if the component type has not been enabled - // to support migration. + // If this assertion is triggered then this component instance + // is being migrated even if the component type has not been + // enabled to support migration. HPX_ASSERT(false); } static void on_migrated() noexcept { - // If this assertion is triggered then this component instance is being - // migrated even if the component type has not been enabled to support - // migration. + // If this assertion is triggered then this component instance + // is being migrated even if the component type has not been + // enabled to support migration. HPX_ASSERT(false); } }; @@ -188,11 +187,14 @@ namespace hpx::components { class managed_component_base : public detail::base_managed_component { public: - HPX_NON_COPYABLE(managed_component_base); + managed_component_base(managed_component_base const&) = delete; + managed_component_base(managed_component_base&&) = delete; + managed_component_base& operator=( + managed_component_base const&) = delete; + managed_component_base& operator=(managed_component_base&&) = delete; - public: using this_component_type = - std::conditional_t, + std::conditional_t, managed_component_base, Component>; using wrapped_type = this_component_type; @@ -210,10 +212,7 @@ namespace hpx::components { "std::is_same_v || " "std::is_same_v"); - constexpr managed_component_base() noexcept - : back_ptr_(nullptr) - { - } + constexpr managed_component_base() noexcept = default; explicit managed_component_base( managed_component* back_ptr) noexcept @@ -241,7 +240,6 @@ namespace hpx::components { protected: naming::gid_type get_base_gid() const; - protected: template friend struct detail_adl_barrier::init; @@ -254,7 +252,7 @@ namespace hpx::components { } private: - managed_component* back_ptr_; + managed_component* back_ptr_ = nullptr; }; // reference counting @@ -282,11 +280,11 @@ namespace hpx::components { } /////////////////////////////////////////////////////////////////////////// - /// The managed_component template is used as a indirection layer + /// The managed_component template is used as an indirection layer /// for components allowing to gracefully handle the access to non-existing /// components. /// - /// Additionally it provides memory management capabilities for the + /// Additionally, it provides memory management capabilities for the /// wrapping instances, and it integrates the memory management with the /// AGAS service. Every instance of a managed_component gets assigned /// a global id. @@ -307,9 +305,8 @@ namespace hpx::components { managed_component& operator=(managed_component const&) = delete; managed_component& operator=(managed_component&&) = delete; - using derived_type = - std::conditional_t, - managed_component, Derived>; + using derived_type = std::conditional_t, + managed_component, Derived>; using wrapped_type = Component; using type_holder = Component; @@ -336,7 +333,6 @@ namespace hpx::components { // Construct a managed_component instance holding a new wrapped instance managed_component() - : component_(nullptr) { detail_adl_barrier::init>::call_new(component_, this); @@ -347,7 +343,6 @@ namespace hpx::components { typename Enable = std::enable_if_t< !std::is_same_v, managed_component>>> explicit managed_component(T&& t, Ts&&... ts) - : component_(nullptr) { detail_adl_barrier::init>::call_new(component_, this, HPX_FORWARD(T, t), @@ -459,13 +454,13 @@ namespace hpx::components { friend void intrusive_ptr_release(managed_component* p) noexcept; protected: - Component* component_; + Component* component_ = nullptr; }; /////////////////////////////////////////////////////////////////////////// template - inline hpx::id_type managed_component_base::get_unmanaged_id() const { HPX_ASSERT(back_ptr_); @@ -474,7 +469,7 @@ namespace hpx::components { template - inline hpx::id_type managed_component_base::get_id() const { // all credits should have been taken already @@ -493,8 +488,8 @@ namespace hpx::components { template - inline naming::gid_type managed_component_base::get_base_gid() const + naming::gid_type managed_component_base::get_base_gid() const { HPX_ASSERT(back_ptr_); return back_ptr_->get_base_gid(); diff --git a/libs/full/components_base/include/hpx/components_base/server/migration_support.hpp b/libs/full/components_base/include/hpx/components_base/server/migration_support.hpp index 2a1a0fb6b29a..7f47dfd21a40 100644 --- a/libs/full/components_base/include/hpx/components_base/server/migration_support.hpp +++ b/libs/full/components_base/include/hpx/components_base/server/migration_support.hpp @@ -84,7 +84,7 @@ namespace hpx::components { using this_component_type = typename base_type::this_component_type; public: - migration_support() noexcept + migration_support() : data_(new detail::migration_support_data(), false) { } @@ -145,7 +145,6 @@ namespace hpx::components { } } - public: bool unpin() { // pin() acquired an additional reference count that needs to be diff --git a/libs/full/components_base/include/hpx/components_base/server/one_size_heap_list.hpp b/libs/full/components_base/include/hpx/components_base/server/one_size_heap_list.hpp index 2ea37a40956e..4ef536e72baf 100644 --- a/libs/full/components_base/include/hpx/components_base/server/one_size_heap_list.hpp +++ b/libs/full/components_base/include/hpx/components_base/server/one_size_heap_list.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 1998-2023 Hartmut Kaiser +// Copyright (c) 1998-2024 Hartmut Kaiser // Copyright (c) 2011 Bryce Lelbach // // SPDX-License-Identifier: BSL-1.0 @@ -8,28 +8,25 @@ #pragma once #include -#include #include #include -#include #include #include #include -#include #include #include /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace util { +namespace hpx::util { class HPX_EXPORT one_size_heap_list { public: using list_type = std::list>; - using iterator = typename list_type::iterator; - using const_iterator = typename list_type::const_iterator; + using iterator = list_type::iterator; + using const_iterator = list_type::const_iterator; using mutex_type = hpx::shared_mutex; @@ -38,41 +35,23 @@ namespace hpx { namespace util { private: template static std::shared_ptr create_heap( - char const* name, std::size_t counter, heap_parameters parameters) + char const* name, [[maybe_unused]] std::size_t counter, + heap_parameters parameters) { #if defined(HPX_DEBUG) return std::make_shared(name, counter, parameters); #else - (void) counter; return std::make_shared(name, 0, parameters); #endif } public: - one_size_heap_list() - : class_name_() -#if defined(HPX_DEBUG) - , alloc_count_(0) - , free_count_(0) - , heap_count_(0) - , max_alloc_count_(0) -#endif - , create_heap_(nullptr) - , parameters_({0, 0, 0}) - { - HPX_ASSERT(false); // shouldn't ever be called - } + one_size_heap_list(); template explicit one_size_heap_list( char const* class_name, heap_parameters parameters, Heap* = nullptr) : class_name_(class_name) -#if defined(HPX_DEBUG) - , alloc_count_(0L) - , free_count_(0L) - , heap_count_(0L) - , max_alloc_count_(0L) -#endif , create_heap_(&one_size_heap_list::create_heap) , parameters_(parameters) { @@ -82,12 +61,6 @@ namespace hpx { namespace util { explicit one_size_heap_list(std::string const& class_name, heap_parameters parameters, Heap* = nullptr) : class_name_(class_name) -#if defined(HPX_DEBUG) - , alloc_count_(0L) - , free_count_(0L) - , heap_count_(0L) - , max_alloc_count_(0L) -#endif , create_heap_(&one_size_heap_list::create_heap) , parameters_(parameters) { @@ -116,16 +89,16 @@ namespace hpx { namespace util { public: #if defined(HPX_DEBUG) - std::size_t alloc_count_; - std::size_t free_count_; - std::size_t heap_count_; - std::size_t max_alloc_count_; + std::size_t alloc_count_ = 0; + std::size_t free_count_ = 0; + std::size_t heap_count_ = 0; + std::size_t max_alloc_count_ = 0; #endif std::shared_ptr (*create_heap_)( - char const*, std::size_t, heap_parameters); + char const*, std::size_t, heap_parameters) = nullptr; heap_parameters const parameters_; }; -}} // namespace hpx::util +} // namespace hpx::util #include diff --git a/libs/full/components_base/include/hpx/components_base/server/wrapper_heap.hpp b/libs/full/components_base/include/hpx/components_base/server/wrapper_heap.hpp index da178ca5c8e7..4a012852685f 100644 --- a/libs/full/components_base/include/hpx/components_base/server/wrapper_heap.hpp +++ b/libs/full/components_base/include/hpx/components_base/server/wrapper_heap.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 1998-2023 Hartmut Kaiser +// Copyright (c) 1998-2024 Hartmut Kaiser // Copyright (c) 2011 Bryce Lelbach // // SPDX-License-Identifier: BSL-1.0 @@ -18,12 +18,8 @@ #include #include -#include #include -#include -#include #include -#include #include @@ -48,7 +44,7 @@ namespace hpx::components::detail { { alloc_.deallocate(static_cast(p), count); } - static void* realloc(std::size_t&, void*) noexcept + static constexpr void* realloc(std::size_t&, void*) noexcept { // normally this should return ::realloc(p, size), but we are // not interested in growing the allocated heaps, so we just @@ -63,26 +59,29 @@ namespace hpx::components::detail { /////////////////////////////////////////////////////////////////////////// class HPX_EXPORT wrapper_heap : public util::wrapper_heap_base { - public: - HPX_NON_COPYABLE(wrapper_heap); - public: using allocator_type = one_size_heap_allocators::fixed_mallocator; using mutex_type = hpx::spinlock; using heap_parameters = wrapper_heap_base::heap_parameters; #if HPX_DEBUG_WRAPPER_HEAP != 0 - enum guard_value{ + enum guard_value + { initial_value = 0xcc, // memory has been initialized freed_value = 0xdd, // memory has been freed }; #endif - public: explicit wrapper_heap(char const* class_name, std::size_t count, heap_parameters const& parameters); wrapper_heap(); + + wrapper_heap(wrapper_heap const&) = delete; + wrapper_heap(wrapper_heap&&) = delete; + wrapper_heap& operator=(wrapper_heap const&) = delete; + wrapper_heap& operator=(wrapper_heap&&) = delete; + ~wrapper_heap() override; std::size_t size() const override; @@ -111,11 +110,11 @@ namespace hpx::components::detail { bool init_pool(); void tidy(); - protected: - char* pool_; + char* pool_ = nullptr; heap_parameters const parameters_; util::cache_aligned_data_derived> first_free_; util::cache_aligned_data_derived> free_size_; + // these values are used for AGAS registration of all elements of this // managed_component heap mutable util::cache_aligned_data_derived mtx_; @@ -124,23 +123,12 @@ namespace hpx::components::detail { public: std::string const class_name_; #if defined(HPX_DEBUG) - std::size_t alloc_count_; - std::size_t free_count_; - std::size_t heap_count_; + std::size_t alloc_count_ = 0; + std::size_t free_count_ = 0; + std::size_t heap_count_ = 0; #endif - // make sure the ABI of this is stable across configurations -#if defined(HPX_DEBUG) - std::size_t heap_count() const override - { - return heap_count_; - } -#else - std::size_t heap_count() const override - { - return 0; - } -#endif + std::size_t heap_count() const override; private: HPX_NO_UNIQUE_ADDRESS util::itt::heap_function heap_alloc_function_; @@ -152,7 +140,6 @@ namespace hpx::components::detail { template class fixed_wrapper_heap : public wrapper_heap { - private: using base_type = wrapper_heap; using heap_parameters = base_type::heap_parameters; diff --git a/libs/full/components_base/include/hpx/components_base/server/wrapper_heap_base.hpp b/libs/full/components_base/include/hpx/components_base/server/wrapper_heap_base.hpp index 32d3de87c42c..557182b98b3b 100644 --- a/libs/full/components_base/include/hpx/components_base/server/wrapper_heap_base.hpp +++ b/libs/full/components_base/include/hpx/components_base/server/wrapper_heap_base.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 1998-2023 Hartmut Kaiser +// Copyright (c) 1998-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -6,20 +6,19 @@ #pragma once -#include #include #include -namespace hpx { namespace util { +namespace hpx::util { struct wrapper_heap_base { struct heap_parameters { - std::size_t capacity; - std::size_t element_alignment; - std::size_t element_size; + std::size_t capacity = 0; + std::size_t element_alignment = 0; + std::size_t element_size = 0; }; virtual ~wrapper_heap_base() = default; @@ -35,4 +34,4 @@ namespace hpx { namespace util { virtual std::size_t size() const = 0; virtual std::size_t free_size() const = 0; }; -}} // namespace hpx::util +} // namespace hpx::util diff --git a/libs/full/components_base/include/hpx/components_base/server/wrapper_heap_list.hpp b/libs/full/components_base/include/hpx/components_base/server/wrapper_heap_list.hpp index e83037233b33..42a7d7b34926 100644 --- a/libs/full/components_base/include/hpx/components_base/server/wrapper_heap_list.hpp +++ b/libs/full/components_base/include/hpx/components_base/server/wrapper_heap_list.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 1998-2023 Hartmut Kaiser +// Copyright (c) 1998-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -10,7 +10,6 @@ #include #include #include -#include #include #include @@ -52,16 +51,14 @@ namespace hpx::components::detail { { } - naming::gid_type get_gid(void* p) + naming::gid_type get_gid(void* p) const { std::shared_lock sl(rwlock_); - - auto const end = heap_list_.end(); - for (auto it = heap_list_.begin(); it != end; ++it) + for (auto const& e : heap_list_) { - if ((*it)->did_alloc(p)) + if (e->did_alloc(p)) { - return (*it)->get_gid(p, type_); + return e->get_gid(p, type_); } } return naming::invalid_gid; diff --git a/libs/full/components_base/include/hpx/components_base/stub_base.hpp b/libs/full/components_base/include/hpx/components_base/stub_base.hpp index 77a0743582fd..d8ccefb889b5 100644 --- a/libs/full/components_base/include/hpx/components_base/stub_base.hpp +++ b/libs/full/components_base/include/hpx/components_base/stub_base.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // Copyright (c) 2011 Bryce Lelbach // // SPDX-License-Identifier: BSL-1.0 @@ -11,7 +11,7 @@ #include /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace components { +namespace hpx::components { /////////////////////////////////////////////////////////////////////////// template @@ -26,4 +26,4 @@ namespace hpx { namespace components { return components::get_component_type(); } }; -}} // namespace hpx::components +} // namespace hpx::components diff --git a/libs/full/components_base/include/hpx/components_base/traits/action_decorate_function.hpp b/libs/full/components_base/include/hpx/components_base/traits/action_decorate_function.hpp index b66a74047dc5..e8e10d81b4fa 100644 --- a/libs/full/components_base/include/hpx/components_base/traits/action_decorate_function.hpp +++ b/libs/full/components_base/include/hpx/components_base/traits/action_decorate_function.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -13,13 +13,13 @@ #include -namespace hpx { namespace traits { +namespace hpx::traits { /////////////////////////////////////////////////////////////////////////// // Customization point for action capabilities namespace detail { - // by default we return the unchanged function + // by default, we return the unchanged function template F&& decorate_function(wrap_int, naming::address_type, F&& f) noexcept { @@ -82,4 +82,4 @@ namespace hpx { namespace traits { 0, lva, HPX_FORWARD(F, f)); } }; -}} // namespace hpx::traits +} // namespace hpx::traits diff --git a/libs/full/components_base/include/hpx/components_base/traits/component_config_data.hpp b/libs/full/components_base/include/hpx/components_base/traits/component_config_data.hpp index 5358bbbe05a3..8d1547e550b2 100644 --- a/libs/full/components_base/include/hpx/components_base/traits/component_config_data.hpp +++ b/libs/full/components_base/include/hpx/components_base/traits/component_config_data.hpp @@ -6,9 +6,7 @@ #pragma once -#include - -namespace hpx { namespace traits { +namespace hpx::traits { /////////////////////////////////////////////////////////////////////////// // Customization point for component config data injection @@ -16,9 +14,9 @@ namespace hpx { namespace traits { struct component_config_data { // by default no additional config data is injected into the factory - static char const* call() noexcept + static constexpr char const* call() noexcept { return nullptr; } }; -}} // namespace hpx::traits +} // namespace hpx::traits diff --git a/libs/full/components_base/include/hpx/components_base/traits/component_heap_type.hpp b/libs/full/components_base/include/hpx/components_base/traits/component_heap_type.hpp index ada89353f6be..76c0e8283c36 100644 --- a/libs/full/components_base/include/hpx/components_base/traits/component_heap_type.hpp +++ b/libs/full/components_base/include/hpx/components_base/traits/component_heap_type.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019 Hartmut Kaiser +// Copyright (c) 2019-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -6,11 +6,9 @@ #pragma once -#include - -namespace hpx { namespace traits { +namespace hpx::traits { /////////////////////////////////////////////////////////////////////////// template struct component_heap_type; -}} // namespace hpx::traits +} // namespace hpx::traits diff --git a/libs/full/components_base/include/hpx/components_base/traits/component_pin_support.hpp b/libs/full/components_base/include/hpx/components_base/traits/component_pin_support.hpp index 855d18f3f545..35f788a93bce 100644 --- a/libs/full/components_base/include/hpx/components_base/traits/component_pin_support.hpp +++ b/libs/full/components_base/include/hpx/components_base/traits/component_pin_support.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Hartmut Kaiser +// Copyright (c) 2018-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -16,6 +16,7 @@ namespace hpx::traits { /////////////////////////////////////////////////////////////////////////// // Customization point for component pinning namespace detail { + struct pin_helper { template diff --git a/libs/full/components_base/include/hpx/components_base/traits/component_supports_migration.hpp b/libs/full/components_base/include/hpx/components_base/traits/component_supports_migration.hpp index a0816bde6418..8c9adce0b0ad 100644 --- a/libs/full/components_base/include/hpx/components_base/traits/component_supports_migration.hpp +++ b/libs/full/components_base/include/hpx/components_base/traits/component_supports_migration.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2023 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -16,7 +16,7 @@ namespace hpx::traits { struct supports_migration_helper { - // by default we return 'false' (component does not support + // by default, we return 'false' (component does not support // migration) template static constexpr bool call(wrap_int) noexcept diff --git a/libs/full/components_base/include/hpx/components_base/traits/component_type_database.hpp b/libs/full/components_base/include/hpx/components_base/traits/component_type_database.hpp index 6ce647c7b3da..cf45052f96ac 100644 --- a/libs/full/components_base/include/hpx/components_base/traits/component_type_database.hpp +++ b/libs/full/components_base/include/hpx/components_base/traits/component_type_database.hpp @@ -10,12 +10,12 @@ #include -namespace hpx { namespace components { +namespace hpx::components { using component_type = std::int32_t; -}} // namespace hpx::components +} // namespace hpx::components -namespace hpx { namespace traits { +namespace hpx::traits { /////////////////////////////////////////////////////////////////////////// template @@ -27,14 +27,14 @@ namespace hpx { namespace traits { HPX_ALWAYS_EXPORT static void set(components::component_type); }; + // components::component_invalid; template components::component_type - component_type_database::value = - components::component_type(-1); // components::component_invalid; + component_type_database::value = -1; template struct component_type_database : component_type_database { }; -}} // namespace hpx::traits +} // namespace hpx::traits diff --git a/libs/full/components_base/include/hpx/components_base/traits/component_type_is_compatible.hpp b/libs/full/components_base/include/hpx/components_base/traits/component_type_is_compatible.hpp index ed24cd976b05..acc1692ca2df 100644 --- a/libs/full/components_base/include/hpx/components_base/traits/component_type_is_compatible.hpp +++ b/libs/full/components_base/include/hpx/components_base/traits/component_type_is_compatible.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -6,11 +6,10 @@ #pragma once -#include #include #include -namespace hpx { namespace traits { +namespace hpx::traits { /////////////////////////////////////////////////////////////////////////// template @@ -22,4 +21,4 @@ namespace hpx { namespace traits { addr.type_, components::get_component_type()); } }; -}} // namespace hpx::traits +} // namespace hpx::traits diff --git a/libs/full/components_base/include/hpx/components_base/traits/is_component.hpp b/libs/full/components_base/include/hpx/components_base/traits/is_component.hpp index dd1386566b0f..700d662ad4ce 100644 --- a/libs/full/components_base/include/hpx/components_base/traits/is_component.hpp +++ b/libs/full/components_base/include/hpx/components_base/traits/is_component.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -6,12 +6,10 @@ #pragma once -#include - #include #include -namespace hpx { namespace traits { +namespace hpx::traits { /////////////////////////////////////////////////////////////////////////// namespace detail { @@ -125,4 +123,4 @@ namespace hpx { namespace traits { inline constexpr bool is_managed_component_v = is_managed_component::value; -}} // namespace hpx::traits +} // namespace hpx::traits diff --git a/libs/full/components_base/include/hpx/components_base/traits/managed_component_policies.hpp b/libs/full/components_base/include/hpx/components_base/traits/managed_component_policies.hpp index ca485ff01ff1..ea543cc61a18 100644 --- a/libs/full/components_base/include/hpx/components_base/traits/managed_component_policies.hpp +++ b/libs/full/components_base/include/hpx/components_base/traits/managed_component_policies.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2021 Hartmut Kaiser +// Copyright (c) 2016-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -6,12 +6,10 @@ #pragma once -#include - #include /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace traits { +namespace hpx::traits { /////////////////////////////////////////////////////////////////////////// // control the way managed_components are constructed @@ -66,4 +64,4 @@ namespace hpx { namespace traits { template using managed_component_dtor_policy_t = typename managed_component_dtor_policy::type; -}} // namespace hpx::traits +} // namespace hpx::traits diff --git a/libs/full/components_base/src/component_type.cpp b/libs/full/components_base/src/component_type.cpp index 17cca6e3b8b9..48f6819f0476 100644 --- a/libs/full/components_base/src/component_type.cpp +++ b/libs/full/components_base/src/component_type.cpp @@ -158,15 +158,17 @@ namespace hpx::components { { std::string result; - if (type == component_invalid) + if (type == to_int(hpx::components::component_enum_type::invalid)) { result = "component_invalid"; } - else if ((type < component_last) && (get_derived_type(type) == 0)) + else if ((type < to_int(hpx::components::component_enum_type::last)) && + (get_derived_type(type) == 0)) { result = components::detail::names[type]; } - else if (get_derived_type(type) < component_last && + else if (get_derived_type(type) < + to_int(hpx::components::component_enum_type::last) && (get_derived_type(type) != 0)) { result = components::detail::names[get_derived_type(type)]; @@ -180,7 +182,8 @@ namespace hpx::components { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wrestrict" #endif - if (type == get_base_type(type) || component_invalid == type) + if (type == get_base_type(type) || + to_int(hpx::components::component_enum_type::invalid) == type) { result += "[" + std::to_string(type) + "]"; } @@ -201,11 +204,13 @@ namespace hpx::components { component_type get_agas_component_type(char const* name, char const* base_name, component_type base_type, bool enabled) { - component_type type = component_invalid; + component_type type = + to_int(hpx::components::component_enum_type::invalid); if (enabled) { type = agas::register_factory(agas::get_locality_id(), name); - if (component_invalid == type) + if (to_int(hpx::components::component_enum_type::invalid) == + type) { HPX_THROW_EXCEPTION(hpx::error::duplicate_component_id, "get_agas_component_type", @@ -220,7 +225,8 @@ namespace hpx::components { if (base_name) { // NOTE: This assumes that the derived component is loaded. - if (base_type == component_invalid) + if (base_type == + to_int(hpx::components::component_enum_type::invalid)) { base_type = agas::get_component_id(base_name); } diff --git a/libs/full/components_base/src/generate_unique_ids.cpp b/libs/full/components_base/src/generate_unique_ids.cpp index 4ed611cfe503..6cf5209a99e5 100644 --- a/libs/full/components_base/src/generate_unique_ids.cpp +++ b/libs/full/components_base/src/generate_unique_ids.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // Copyright (c) 2011 Bryce Lelbach // // SPDX-License-Identifier: BSL-1.0 @@ -14,7 +14,7 @@ #include #include -namespace hpx { namespace util { +namespace hpx::util { naming::gid_type unique_id_ranges::get_id(std::size_t count) { @@ -27,15 +27,15 @@ namespace hpx { namespace util { lower_ = naming::invalid_gid; naming::gid_type lower; - std::size_t count_ = (std::max)(std::size_t(range_delta), count); + std::size_t const count_ = (std::max)(range_delta, count); { hpx::unlock_guard ul(l); lower = hpx::agas::get_next_id(count_); } - // we ignore the result if some other thread has already set the - // new lower range + // we ignore the result if some other thread has already set the new + // lower range if (!lower_) { lower_ = lower; @@ -47,4 +47,12 @@ namespace hpx { namespace util { lower_ += count; return result; } -}} // namespace hpx::util + + void unique_id_ranges::set_range( + naming::gid_type const& lower, naming::gid_type const& upper) + { + std::lock_guard l(mtx_); + lower_ = lower; + upper_ = upper; + } +} // namespace hpx::util diff --git a/libs/full/components_base/src/server/one_size_heap_list.cpp b/libs/full/components_base/src/server/one_size_heap_list.cpp index bcf5ab5dc3eb..30ed91e74504 100644 --- a/libs/full/components_base/src/server/one_size_heap_list.cpp +++ b/libs/full/components_base/src/server/one_size_heap_list.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 1998-2023 Hartmut Kaiser +// Copyright (c) 1998-2024 Hartmut Kaiser // Copyright (c) 2011 Bryce Lelbach // // SPDX-License-Identifier: BSL-1.0 @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #if defined(HPX_DEBUG) @@ -22,13 +21,17 @@ #endif #include -#include #include #include #include #include -namespace hpx { namespace util { +namespace hpx::util { + + one_size_heap_list::one_size_heap_list() + { + HPX_ASSERT(false); // shouldn't ever be called + } one_size_heap_list::~one_size_heap_list() noexcept { @@ -190,4 +193,4 @@ namespace hpx { namespace util { } return std::string("one_size_heap_list(") + class_name_ + ")"; } -}} // namespace hpx::util +} // namespace hpx::util diff --git a/libs/full/components_base/src/server/wrapper_heap.cpp b/libs/full/components_base/src/server/wrapper_heap.cpp index e3f2185fa7fe..910ef6fa0d1a 100644 --- a/libs/full/components_base/src/server/wrapper_heap.cpp +++ b/libs/full/components_base/src/server/wrapper_heap.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 1998-2023 Hartmut Kaiser +// Copyright (c) 1998-2024 Hartmut Kaiser // Copyright (c) 2011 Bryce Lelbach // // SPDX-License-Identifier: BSL-1.0 @@ -68,15 +68,12 @@ namespace hpx::components::detail { /////////////////////////////////////////////////////////////////////////// wrapper_heap::wrapper_heap(char const* class_name, [[maybe_unused]] std::size_t count, heap_parameters const& parameters) - : pool_(nullptr) - , parameters_(parameters) + : parameters_(parameters) , first_free_(nullptr) , free_size_(0) , base_gid_(naming::invalid_gid) , class_name_(class_name) #if defined(HPX_DEBUG) - , alloc_count_(0) - , free_count_(0) , heap_count_(count) #endif , heap_alloc_function_("wrapper_heap::alloc", class_name) @@ -100,16 +97,9 @@ namespace hpx::components::detail { } wrapper_heap::wrapper_heap() - : pool_(nullptr) - , parameters_({0, 0, 0}) - , first_free_(nullptr) + : first_free_(nullptr) , free_size_(0) , base_gid_(naming::invalid_gid) -#if defined(HPX_DEBUG) - , alloc_count_(0) - , free_count_(0) - , heap_count_(0) -#endif , heap_alloc_function_("wrapper_heap::alloc", "") , heap_free_function_("wrapper_heap::free", "") { @@ -155,8 +145,8 @@ namespace hpx::components::detail { bool wrapper_heap::alloc(void** result, std::size_t count) { - util::itt::heap_allocate heap_allocate(heap_alloc_function_, result, - count * parameters_.element_size, + [[maybe_unused]] util::itt::heap_allocate heap_allocate( + heap_alloc_function_, result, count * parameters_.element_size, HPX_WRAPPER_HEAP_INITIALIZED_MEMORY); if (nullptr == pool_) @@ -197,7 +187,7 @@ namespace hpx::components::detail { void wrapper_heap::free([[maybe_unused]] void* p, std::size_t count) { - util::itt::heap_free heap_free(heap_free_function_, p); + [[maybe_unused]] util::itt::heap_free heap_free(heap_free_function_, p); #if HPX_DEBUG_WRAPPER_HEAP != 0 HPX_ASSERT(did_alloc(p)); @@ -367,4 +357,17 @@ namespace hpx::components::detail { free_size_.store(0, std::memory_order_release); } } + + // make sure the ABI of this is stable across configurations +#if defined(HPX_DEBUG) + std::size_t wrapper_heap::heap_count() const + { + return heap_count_; + } +#else + std::size_t wrapper_heap::heap_count() const + { + return 0; + } +#endif } // namespace hpx::components::detail diff --git a/libs/full/compute/include/hpx/compute/detail/target_distribution_policy.hpp b/libs/full/compute/include/hpx/compute/detail/target_distribution_policy.hpp index 494790015a89..fe97695ea05c 100644 --- a/libs/full/compute/include/hpx/compute/detail/target_distribution_policy.hpp +++ b/libs/full/compute/include/hpx/compute/detail/target_distribution_policy.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2022 Hartmut Kaiser +// Copyright (c) 2014-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -18,7 +18,7 @@ #include #include -namespace hpx { namespace compute { namespace detail { +namespace hpx::compute::detail { /// This class specifies the parameters for a simple distribution policy /// to use for creating (and evenly distributing) a given number of items @@ -27,31 +27,28 @@ namespace hpx { namespace compute { namespace detail { struct target_distribution_policy { private: - typedef hpx::spinlock mutex_type; + using mutex_type = hpx::spinlock; public: - typedef Target target_type; + using target_type = Target; /// Default-construct a new instance of a \a target_distribution_policy. target_distribution_policy() - : mtx_() - , targets_() + : targets_() , num_partitions_(1) , next_target_(0) { } target_distribution_policy(target_distribution_policy const& rhs) - : mtx_() - , targets_(rhs.targets_) + : targets_(rhs.targets_) , num_partitions_(rhs.num_partitions_) , next_target_(0) { } - target_distribution_policy(target_distribution_policy&& rhs) - : mtx_() - , targets_(HPX_MOVE(rhs.targets_)) + target_distribution_policy(target_distribution_policy&& rhs) noexcept + : targets_(HPX_MOVE(rhs.targets_)) , num_partitions_(rhs.num_partitions_) , next_target_(0) { @@ -69,7 +66,8 @@ namespace hpx { namespace compute { namespace detail { return *this; } - target_distribution_policy& operator=(target_distribution_policy&& rhs) + target_distribution_policy& operator=( + target_distribution_policy&& rhs) noexcept { if (this != &rhs) { @@ -100,10 +98,11 @@ namespace hpx { namespace compute { namespace detail { Target::get_local_targets()); } - std::size_t num_parts = (num_partitions_ == std::size_t(-1)) ? + std::size_t const num_parts = + (num_partitions_ == static_cast(-1)) ? targets_.size() : num_partitions_; - return (std::max)(num_parts, std::size_t(1)); + return (std::max)(num_parts, static_cast(1)); } protected: @@ -126,18 +125,19 @@ namespace hpx { namespace compute { namespace detail { // this distribution policy places an equal number of items onto // each target - std::size_t sites = (std::max)(std::size_t(1), targets_.size()); + std::size_t const sites = + (std::max)(static_cast(1), targets_.size()); // the overall number of items to create is smaller than the number // of sites if (items < sites) { auto it = std::find(targets_.begin(), targets_.end(), t); - std::size_t num_loc = std::distance(targets_.begin(), it); + std::size_t const num_loc = std::distance(targets_.begin(), it); return (items < num_loc) ? 1 : 0; } - // the last locality might get less items + // the last locality might get fewer items if (!targets_.empty() && t == targets_.back()) { return items - round_to_multiple(items, sites, sites - 1); @@ -146,10 +146,7 @@ namespace hpx { namespace compute { namespace detail { // otherwise just distribute evenly return (items + sites - 1) / sites; } - /// \endcond - protected: - /// \cond NOINTERNAL target_distribution_policy( std::vector const& targets, std::size_t num_partitions) : targets_(targets) @@ -182,4 +179,4 @@ namespace hpx { namespace compute { namespace detail { mutable std::size_t next_target_; /// \endcond }; -}}} // namespace hpx::compute::detail +} // namespace hpx::compute::detail diff --git a/libs/full/compute/include/hpx/compute/host/target_distribution_policy.hpp b/libs/full/compute/include/hpx/compute/host/target_distribution_policy.hpp index 4847032bd903..3d7502668453 100644 --- a/libs/full/compute/include/hpx/compute/host/target_distribution_policy.hpp +++ b/libs/full/compute/include/hpx/compute/host/target_distribution_policy.hpp @@ -30,7 +30,7 @@ #include #include -namespace hpx { namespace compute { namespace host { +namespace hpx::compute::host { /// A target_distribution_policy used for CPU bound localities. struct target_distribution_policy @@ -145,15 +145,10 @@ namespace hpx { namespace compute { namespace host { /// template hpx::future> bulk_create( - std::size_t count, - Ts&&... -#if !defined(HPX_COMPUTE_DEVICE_CODE) - ts -#endif - ) const + [[maybe_unused]] std::size_t count, + [[maybe_unused]] Ts&&... ts) const { #if defined(HPX_COMPUTE_DEVICE_CODE) - HPX_UNUSED(count); HPX_ASSERT(false); return hpx::future>(); #else @@ -170,7 +165,7 @@ namespace hpx { namespace compute { namespace host { std::vector>> objs; objs.reserve(m.size()); - auto end = m.end(); + auto const end = m.end(); for (auto it = m.begin(); it != end; ++it) { localities.push_back(HPX_MOVE(it->first)); @@ -181,17 +176,17 @@ namespace hpx { namespace compute { namespace host { num_partitions += this->get_num_items(count, t); } - std::vector local_targets; - local_targets.reserve(it->second.size()); - for (auto&& dt : HPX_MOVE(it->second)) - { - local_targets.push_back( - hpx::compute::host::target(HPX_MOVE(dt))); - } + // std::vector local_targets; + // local_targets.reserve(it->second.size()); + // for (auto&& dt : HPX_MOVE(it->second)) + // { + // local_targets.push_back( + // hpx::compute::host::target(HPX_MOVE(dt))); + // } objs.push_back( components::bulk_create_async(localities.back(), - num_partitions, ts..., HPX_MOVE(local_targets))); + num_partitions, ts... /*, HPX_MOVE(local_targets)*/)); } return hpx::dataflow( @@ -244,26 +239,25 @@ namespace hpx { namespace compute { namespace host { /// localities. It will represent all NUMA domains of the given locality /// and will place all items to create here. static target_distribution_policy const target_layout; -}}} // namespace hpx::compute::host +} // namespace hpx::compute::host /// \cond NOINTERNAL -namespace hpx { namespace traits { - template <> - struct is_distribution_policy - : std::true_type - { - }; - - template <> - struct num_container_partitions +template <> +struct hpx::traits::is_distribution_policy< + hpx::compute::host::target_distribution_policy> : std::true_type +{ +}; + +template <> +struct hpx::traits::num_container_partitions< + hpx::compute::host::target_distribution_policy> +{ + static std::size_t call( + hpx::compute::host::target_distribution_policy const& policy) { - static std::size_t call( - compute::host::target_distribution_policy const& policy) - { - return policy.get_num_partitions(); - } - }; -}} // namespace hpx::traits + return policy.get_num_partitions(); + } +}; /// \endcond #endif diff --git a/libs/full/parcelset/include/hpx/parcelset/parcelhandler.hpp b/libs/full/parcelset/include/hpx/parcelset/parcelhandler.hpp index 9f4971089b8b..939a42fce1b3 100644 --- a/libs/full/parcelset/include/hpx/parcelset/parcelhandler.hpp +++ b/libs/full/parcelset/include/hpx/parcelset/parcelhandler.hpp @@ -93,7 +93,7 @@ namespace hpx::parcelset { /// \returns Whether any work has been performed bool do_background_work(std::size_t num_thread = 0, bool stop_buffering = false, - parcelport_background_mode mode = parcelport_background_mode_all); + parcelport_background_mode mode = parcelport_background_mode::all); /// Return the list of all remote localities supporting the given /// component type @@ -109,7 +109,8 @@ namespace hpx::parcelset { /// (!prefixes.empty()). bool get_raw_remote_localities( std::vector& locality_ids, - components::component_type type = components::component_invalid, + components::component_type type = to_int( + hpx::components::component_enum_type::invalid), error_code& ec = throws) const; /// Return the list of all localities supporting the given diff --git a/libs/full/parcelset/src/parcel.cpp b/libs/full/parcelset/src/parcel.cpp index 5dff726b9cca..5985fd26e687 100644 --- a/libs/full/parcelset/src/parcel.cpp +++ b/libs/full/parcelset/src/parcel.cpp @@ -158,7 +158,9 @@ namespace hpx::parcelset::detail { } // verify that the action targets the correct type - if (action_ && data_.addr_.type_ != components::component_invalid) + if (action_ && + data_.addr_.type_ != + to_int(hpx::components::component_enum_type::invalid)) { int const type = action_->get_component_type(); if (!components::types_are_compatible(type, data_.addr_.type_)) @@ -399,21 +401,21 @@ namespace hpx::parcelset::detail { // runtime support component or one of the AGAS components if (nullptr == lva) { - switch (comptype) + switch (static_cast(comptype)) { - case components::component_runtime_support: + case components::component_enum_type::runtime_support: lva = agas::get_runtime_support_lva(); break; - case components::component_agas_primary_namespace: + case components::component_enum_type::agas_primary_namespace: lva = agas::get_primary_ns_lva(); break; - case components::component_agas_symbol_namespace: + case components::component_enum_type::agas_symbol_namespace: lva = agas::get_symbol_ns_lva(); break; - case components::component_plain_function: + case components::component_enum_type::plain_function: break; default: diff --git a/libs/full/performance_counters/include/hpx/performance_counters/server/elapsed_time_counter.hpp b/libs/full/performance_counters/include/hpx/performance_counters/server/elapsed_time_counter.hpp index fd0007e31f21..c00882cefb13 100644 --- a/libs/full/performance_counters/include/hpx/performance_counters/server/elapsed_time_counter.hpp +++ b/libs/full/performance_counters/include/hpx/performance_counters/server/elapsed_time_counter.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -9,10 +9,9 @@ #include #include #include -#include /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace performance_counters { namespace server { +namespace hpx::performance_counters::server { class HPX_EXPORT elapsed_time_counter : public base_performance_counter @@ -25,7 +24,7 @@ namespace hpx { namespace performance_counters { namespace server { using base_type_holder = base_performance_counter; elapsed_time_counter(); - elapsed_time_counter(counter_info const& info); + explicit elapsed_time_counter(counter_info const& info); hpx::performance_counters::counter_value get_counter_value( bool reset) override; @@ -35,8 +34,8 @@ namespace hpx { namespace performance_counters { namespace server { bool stop() override; // finalize() will be called just before the instance gets destructed - void finalize(); + static void finalize(); naming::address get_current_address() const; }; -}}} // namespace hpx::performance_counters::server +} // namespace hpx::performance_counters::server diff --git a/libs/full/performance_counters/include/hpx/performance_counters/server/raw_counter.hpp b/libs/full/performance_counters/include/hpx/performance_counters/server/raw_counter.hpp index ef570fd98e95..43ab5768e010 100644 --- a/libs/full/performance_counters/include/hpx/performance_counters/server/raw_counter.hpp +++ b/libs/full/performance_counters/include/hpx/performance_counters/server/raw_counter.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2012 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -14,7 +14,7 @@ #include /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace performance_counters { namespace server { +namespace hpx::performance_counters::server { class HPX_EXPORT raw_counter : public base_performance_counter @@ -36,7 +36,7 @@ namespace hpx { namespace performance_counters { namespace server { void reset_counter_value() override; // finalize() will be called just before the instance gets destructed - void finalize(); + static void finalize(); naming::address get_current_address() const; @@ -44,4 +44,4 @@ namespace hpx { namespace performance_counters { namespace server { hpx::function f_; bool reset_; }; -}}} // namespace hpx::performance_counters::server +} // namespace hpx::performance_counters::server diff --git a/libs/full/performance_counters/include/hpx/performance_counters/server/raw_values_counter.hpp b/libs/full/performance_counters/include/hpx/performance_counters/server/raw_values_counter.hpp index db9a2638d6cb..38a1843e55ed 100644 --- a/libs/full/performance_counters/include/hpx/performance_counters/server/raw_values_counter.hpp +++ b/libs/full/performance_counters/include/hpx/performance_counters/server/raw_values_counter.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2016 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -15,7 +15,7 @@ #include /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace performance_counters { namespace server { +namespace hpx::performance_counters::server { class HPX_EXPORT raw_values_counter : public base_performance_counter @@ -38,7 +38,7 @@ namespace hpx { namespace performance_counters { namespace server { void reset_counter_value() override; // finalize() will be called just before the instance gets destructed - void finalize(); + static void finalize(); naming::address get_current_address() const; @@ -46,4 +46,4 @@ namespace hpx { namespace performance_counters { namespace server { hpx::function(bool)> f_; bool reset_; }; -}}} // namespace hpx::performance_counters::server +} // namespace hpx::performance_counters::server diff --git a/libs/full/performance_counters/src/server/arithmetics_counter.cpp b/libs/full/performance_counters/src/server/arithmetics_counter.cpp index c43ccd7f8cbc..d5ec5894d8b0 100644 --- a/libs/full/performance_counters/src/server/arithmetics_counter.cpp +++ b/libs/full/performance_counters/src/server/arithmetics_counter.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -15,7 +15,6 @@ #include #include #include -#include #include #include @@ -25,16 +24,18 @@ #include /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace performance_counters { namespace server { +namespace hpx::performance_counters::server { + /////////////////////////////////////////////////////////////////////////// namespace detail { + template struct init_value; template <> struct init_value> { - static double call() + static constexpr double call() noexcept { return 0.0; } @@ -43,7 +44,7 @@ namespace hpx { namespace performance_counters { namespace server { template <> struct init_value> { - static double call() + static constexpr double call() noexcept { return 0.0; } @@ -52,7 +53,7 @@ namespace hpx { namespace performance_counters { namespace server { template <> struct init_value> { - static double call() + static constexpr double call() noexcept { return 1.0; } @@ -61,7 +62,7 @@ namespace hpx { namespace performance_counters { namespace server { template <> struct init_value> { - static double call() + static constexpr double call() noexcept { return 1.0; } @@ -169,7 +170,7 @@ namespace hpx { namespace performance_counters { namespace server { components::get_component_type(), const_cast(this)); } -}}} // namespace hpx::performance_counters::server +} // namespace hpx::performance_counters::server /////////////////////////////////////////////////////////////////////////////// template class HPX_EXPORT @@ -183,48 +184,47 @@ template class HPX_EXPORT hpx::performance_counters::server:: /////////////////////////////////////////////////////////////////////////////// // Addition -typedef hpx::components::component< - hpx::performance_counters::server::arithmetics_counter>> - adding_counter_type; +using adding_counter_type = hpx::components::component< + hpx::performance_counters::server::arithmetics_counter>>; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(adding_counter_type, adding_counter, - "base_performance_counter", hpx::components::factory_enabled) + "base_performance_counter", hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(adding_counter_type::wrapped_type) /////////////////////////////////////////////////////////////////////////////// // Subtraction -typedef hpx::components::component< - hpx::performance_counters::server::arithmetics_counter>> - subtracting_counter_type; +using subtracting_counter_type = hpx::components::component< + hpx::performance_counters::server::arithmetics_counter>>; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(subtracting_counter_type, subtracting_counter, "base_performance_counter", - hpx::components::factory_enabled) + hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(subtracting_counter_type::wrapped_type) /////////////////////////////////////////////////////////////////////////////// // Multiply -typedef hpx::components::component>> - multiplying_counter_type; +using multiplying_counter_type = + hpx::components::component>>; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(multiplying_counter_type, multiplying_counter, "base_performance_counter", - hpx::components::factory_enabled) + hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(multiplying_counter_type::wrapped_type) /////////////////////////////////////////////////////////////////////////////// // Division -typedef hpx::components::component>> - dividing_counter_type; +using dividing_counter_type = + hpx::components::component>>; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(dividing_counter_type, dividing_counter, - "base_performance_counter", hpx::components::factory_enabled) + "base_performance_counter", hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(dividing_counter_type::wrapped_type) /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace performance_counters { namespace detail { +namespace hpx::performance_counters::detail { + /// Creation function for aggregating performance counters to be registered /// with the counter types. naming::gid_type arithmetics_counter_creator( @@ -259,7 +259,6 @@ namespace hpx { namespace performance_counters { namespace detail { for (std::string const& name : names) { - counter_path_elements paths; if (counter_status::valid_data != get_counter_path_elements(name, paths, ec) || ec) @@ -275,15 +274,13 @@ namespace hpx { namespace performance_counters { namespace detail { return create_arithmetics_counter(info, names, ec); } - else - { - HPX_THROWS_IF(ec, hpx::error::bad_parameter, - "arithmetics_counter_creator", - "the parameter specification for an arithmetic counter " - "has to be a comma separated list of performance " - "counter names, none is given: {}", - remove_counter_prefix(info.fullname_)); - } + + HPX_THROWS_IF(ec, hpx::error::bad_parameter, + "arithmetics_counter_creator", + "the parameter specification for an arithmetic counter " + "has to be a comma separated list of performance " + "counter names, none is given: {}", + remove_counter_prefix(info.fullname_)); } break; @@ -295,4 +292,4 @@ namespace hpx { namespace performance_counters { namespace detail { } return naming::invalid_gid; } -}}} // namespace hpx::performance_counters::detail +} // namespace hpx::performance_counters::detail diff --git a/libs/full/performance_counters/src/server/arithmetics_counter_extended.cpp b/libs/full/performance_counters/src/server/arithmetics_counter_extended.cpp index 7376c408c25d..c04ca8b7b67d 100644 --- a/libs/full/performance_counters/src/server/arithmetics_counter_extended.cpp +++ b/libs/full/performance_counters/src/server/arithmetics_counter_extended.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -31,7 +31,7 @@ #include /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace performance_counters { namespace server { +namespace hpx::performance_counters::server { /////////////////////////////////////////////////////////////////////////// template @@ -127,9 +127,8 @@ namespace hpx { namespace performance_counters { namespace server { counters_.get_counter_values(hpx::launch::sync); // apply arithmetic Statistic - typedef boost::accumulators::accumulator_set> - accumulator_type; + using accumulator_type = boost::accumulators::accumulator_set>; accumulator_type accum; for (counter_value const& base_value : base_values) @@ -191,7 +190,7 @@ namespace hpx { namespace performance_counters { namespace server { components::get_component_type(), const_cast(this)); } -}}} // namespace hpx::performance_counters::server +} // namespace hpx::performance_counters::server /////////////////////////////////////////////////////////////////////////////// template class HPX_EXPORT hpx::performance_counters::server:: @@ -209,72 +208,73 @@ template class HPX_EXPORT hpx::performance_counters::server:: /////////////////////////////////////////////////////////////////////////////// // /arithmetic/mean -typedef hpx::components::component> - mean_arithmetics_counter_type; +using mean_arithmetics_counter_type = + hpx::components::component>; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(mean_arithmetics_counter_type, mean_arithmetics_counter, "base_performance_counter", - hpx::components::factory_enabled) + hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(mean_arithmetics_counter_type::wrapped_type) /////////////////////////////////////////////////////////////////////////////// // /arithmetic/variance -typedef hpx::components::component> - variance_arithmetics_counter_type; +using variance_arithmetics_counter_type = + hpx::components::component>; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(variance_arithmetics_counter_type, variance_arithmetics_counter, "base_performance_counter", - hpx::components::factory_enabled) + hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(variance_arithmetics_counter_type::wrapped_type) /////////////////////////////////////////////////////////////////////////////// // /arithmetic/median -typedef hpx::components::component> - median_arithmetics_counter_type; +using median_arithmetics_counter_type = + hpx::components::component>; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(median_arithmetics_counter_type, median_arithmetics_counter, "base_performance_counter", - hpx::components::factory_enabled) + hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(median_arithmetics_counter_type::wrapped_type) /////////////////////////////////////////////////////////////////////////////// // /arithmetic/min -typedef hpx::components::component> - min_arithmetics_counter_type; +using min_arithmetics_counter_type = + hpx::components::component>; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(min_arithmetics_counter_type, min_arithmetics_counter, "base_performance_counter", - hpx::components::factory_enabled) + hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(min_arithmetics_counter_type::wrapped_type) /////////////////////////////////////////////////////////////////////////////// // /arithmetic/max -typedef hpx::components::component> - max_arithmetics_counter_type; +using max_arithmetics_counter_type = + hpx::components::component>; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(max_arithmetics_counter_type, max_arithmetics_counter, "base_performance_counter", - hpx::components::factory_enabled) + hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(max_arithmetics_counter_type::wrapped_type) /////////////////////////////////////////////////////////////////////////////// // /arithmetic/count -typedef hpx::components::component> - count_arithmetics_counter_type; +using count_arithmetics_counter_type = + hpx::components::component>; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(count_arithmetics_counter_type, count_arithmetics_counter, "base_performance_counter", - hpx::components::factory_enabled) + hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(count_arithmetics_counter_type::wrapped_type) /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace performance_counters { namespace detail { +namespace hpx::performance_counters::detail { + /// Creation function for aggregating performance counters to be registered /// with the counter types. naming::gid_type arithmetics_counter_extended_creator( @@ -345,4 +345,4 @@ namespace hpx { namespace performance_counters { namespace detail { } return naming::invalid_gid; } -}}} // namespace hpx::performance_counters::detail +} // namespace hpx::performance_counters::detail diff --git a/libs/full/performance_counters/src/server/component_instance_counter.cpp b/libs/full/performance_counters/src/server/component_instance_counter.cpp index 786b1c67671d..1f03c02da41d 100644 --- a/libs/full/performance_counters/src/server/component_instance_counter.cpp +++ b/libs/full/performance_counters/src/server/component_instance_counter.cpp @@ -73,7 +73,7 @@ namespace hpx { namespace performance_counters { namespace detail { components::component_type type = agas::get_component_id(paths.parameters_); - if (type == components::component_invalid) + if (type == to_int(hpx::components::component_enum_type::invalid)) { HPX_THROWS_IF(ec, hpx::error::bad_parameter, "component_instance_counter_creator", diff --git a/libs/full/performance_counters/src/server/elapsed_time_counter.cpp b/libs/full/performance_counters/src/server/elapsed_time_counter.cpp index a1eff43d4f09..5396ac712032 100644 --- a/libs/full/performance_counters/src/server/elapsed_time_counter.cpp +++ b/libs/full/performance_counters/src/server/elapsed_time_counter.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -11,23 +11,21 @@ #include #include #include -#include #include /////////////////////////////////////////////////////////////////////////////// -typedef hpx::components::component< - hpx::performance_counters::server::elapsed_time_counter> - elapsed_time_counter_type; +using elapsed_time_counter_type = hpx::components::component< + hpx::performance_counters::server::elapsed_time_counter>; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(elapsed_time_counter_type, elapsed_time_counter, "base_performance_counter", - hpx::components::factory_enabled) + hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE( hpx::performance_counters::server::elapsed_time_counter) /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace performance_counters { namespace server { +namespace hpx::performance_counters::server { elapsed_time_counter::elapsed_time_counter() = default; @@ -53,7 +51,8 @@ namespace hpx { namespace performance_counters { namespace server { } // gather the current value - std::int64_t now = static_cast(hpx::get_system_uptime()); + std::int64_t const now = + static_cast(hpx::get_system_uptime()); hpx::performance_counters::counter_value value; value.value_ = now; value.scaling_ = 1000000000LL; // coefficient to get seconds @@ -93,10 +92,11 @@ namespace hpx { namespace performance_counters { namespace server { components::get_component_type(), const_cast(this)); } -}}} // namespace hpx::performance_counters::server +} // namespace hpx::performance_counters::server /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace performance_counters { namespace detail { +namespace hpx::performance_counters::detail { + /// Creation function for uptime counters. naming::gid_type uptime_counter_creator( counter_info const& info, error_code& ec) @@ -131,4 +131,4 @@ namespace hpx { namespace performance_counters { namespace detail { return naming::invalid_gid; } } -}}} // namespace hpx::performance_counters::detail +} // namespace hpx::performance_counters::detail diff --git a/libs/full/performance_counters/src/server/raw_counter.cpp b/libs/full/performance_counters/src/server/raw_counter.cpp index 7dc53d392142..e10595df541f 100644 --- a/libs/full/performance_counters/src/server/raw_counter.cpp +++ b/libs/full/performance_counters/src/server/raw_counter.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -11,22 +11,20 @@ #include #include #include -#include #include #include /////////////////////////////////////////////////////////////////////////////// -typedef hpx::components::component< - hpx::performance_counters::server::raw_counter> - raw_counter_type; +using raw_counter_type = + hpx::components::component; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(raw_counter_type, raw_counter, - "base_performance_counter", hpx::components::factory_enabled) + "base_performance_counter", hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(hpx::performance_counters::server::raw_counter) /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace performance_counters { namespace server { +namespace hpx::performance_counters::server { raw_counter::raw_counter() : reset_(false) @@ -68,7 +66,7 @@ namespace hpx { namespace performance_counters { namespace server { void raw_counter::reset_counter_value() { - f_(true); + [[maybe_unused]] auto _ = f_(true); } void raw_counter::finalize() @@ -84,4 +82,4 @@ namespace hpx { namespace performance_counters { namespace server { components::get_component_type(), const_cast(this)); } -}}} // namespace hpx::performance_counters::server +} // namespace hpx::performance_counters::server diff --git a/libs/full/performance_counters/src/server/raw_values_counter.cpp b/libs/full/performance_counters/src/server/raw_values_counter.cpp index 5843ba79b354..b1dd50262e8d 100644 --- a/libs/full/performance_counters/src/server/raw_values_counter.cpp +++ b/libs/full/performance_counters/src/server/raw_values_counter.cpp @@ -11,25 +11,23 @@ #include #include #include -#include #include #include #include /////////////////////////////////////////////////////////////////////////////// -typedef hpx::components::component< - hpx::performance_counters::server::raw_values_counter> - raw_values_counter_type; +using raw_values_counter_type = hpx::components::component< + hpx::performance_counters::server::raw_values_counter>; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(raw_values_counter_type, raw_values_counter, "base_performance_counter", - hpx::components::factory_enabled) + hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE( hpx::performance_counters::server::raw_values_counter) /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace performance_counters { namespace server { +namespace hpx::performance_counters::server { raw_values_counter::raw_values_counter() : reset_(false) @@ -69,7 +67,7 @@ namespace hpx { namespace performance_counters { namespace server { void raw_values_counter::reset_counter_value() { - f_(true); + [[maybe_unused]] auto _ = f_(true); } void raw_values_counter::finalize() @@ -85,4 +83,4 @@ namespace hpx { namespace performance_counters { namespace server { components::get_component_type(), const_cast(this)); } -}}} // namespace hpx::performance_counters::server +} // namespace hpx::performance_counters::server diff --git a/libs/full/performance_counters/src/server/statistics_counter.cpp b/libs/full/performance_counters/src/server/statistics_counter.cpp index 4e529e850fc9..b965875bf5f9 100644 --- a/libs/full/performance_counters/src/server/statistics_counter.cpp +++ b/libs/full/performance_counters/src/server/statistics_counter.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -16,7 +16,6 @@ #include #include #include -#include #include #include @@ -53,7 +52,8 @@ #include /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace performance_counters { namespace server { +namespace hpx::performance_counters::server { + /////////////////////////////////////////////////////////////////////////// namespace detail { template @@ -63,10 +63,10 @@ namespace hpx { namespace performance_counters { namespace server { struct counter_type_from_statistic : counter_type_from_statistic_base { - typedef boost::accumulators::tag::mean aggregating_tag; - typedef boost::accumulators::accumulator_set> - accumulator_type; + using aggregating_tag = boost::accumulators::tag::mean; + using accumulator_type = + boost::accumulators::accumulator_set>; counter_type_from_statistic(std::size_t /*parameter2*/) {} @@ -93,10 +93,10 @@ namespace hpx { namespace performance_counters { namespace server { struct counter_type_from_statistic : counter_type_from_statistic_base { - typedef boost::accumulators::tag::variance aggregating_tag; - typedef boost::accumulators::accumulator_set> - accumulator_type; + using aggregating_tag = boost::accumulators::tag::variance; + using accumulator_type = + boost::accumulators::accumulator_set>; counter_type_from_statistic(std::size_t /*parameter2*/) {} @@ -123,13 +123,13 @@ namespace hpx { namespace performance_counters { namespace server { struct counter_type_from_statistic : counter_type_from_statistic_base { - typedef boost::accumulators::tag::median aggregating_tag; - typedef boost::accumulators::with_p_square_quantile - aggregating_type_tag; - typedef boost::accumulators::accumulator_set> - accumulator_type; + using aggregating_tag = boost::accumulators::tag::median; + using aggregating_type_tag = + boost::accumulators::with_p_square_quantile; + using accumulator_type = + boost::accumulators::accumulator_set>; counter_type_from_statistic(std::size_t /*parameter2*/) {} @@ -157,10 +157,10 @@ namespace hpx { namespace performance_counters { namespace server { boost::accumulators::tag::rolling_mean> : counter_type_from_statistic_base { - typedef boost::accumulators::tag::rolling_mean aggregating_tag; - typedef boost::accumulators::accumulator_set> - accumulator_type; + using aggregating_tag = boost::accumulators::tag::rolling_mean; + using accumulator_type = + boost::accumulators::accumulator_set>; counter_type_from_statistic(std::size_t parameter2) : accum_(boost::accumulators::tag::rolling_window::window_size = @@ -198,10 +198,10 @@ namespace hpx { namespace performance_counters { namespace server { boost::accumulators::tag::rolling_variance> : counter_type_from_statistic_base { - typedef boost::accumulators::tag::rolling_variance aggregating_tag; - typedef boost::accumulators::accumulator_set> - accumulator_type; + using aggregating_tag = boost::accumulators::tag::rolling_variance; + using accumulator_type = + boost::accumulators::accumulator_set>; counter_type_from_statistic(std::size_t parameter2) : accum_(boost::accumulators::tag::rolling_window::window_size = @@ -238,10 +238,10 @@ namespace hpx { namespace performance_counters { namespace server { struct counter_type_from_statistic : counter_type_from_statistic_base { - typedef boost::accumulators::tag::max aggregating_tag; - typedef boost::accumulators::accumulator_set> - accumulator_type; + using aggregating_tag = boost::accumulators::tag::max; + using accumulator_type = + boost::accumulators::accumulator_set>; counter_type_from_statistic(std::size_t /*parameter2*/) {} @@ -268,10 +268,10 @@ namespace hpx { namespace performance_counters { namespace server { struct counter_type_from_statistic : counter_type_from_statistic_base { - typedef boost::accumulators::tag::min aggregating_tag; - typedef boost::accumulators::accumulator_set> - accumulator_type; + using aggregating_tag = boost::accumulators::tag::min; + using accumulator_type = + boost::accumulators::accumulator_set>; counter_type_from_statistic(std::size_t /*parameter2*/) {} @@ -298,10 +298,10 @@ namespace hpx { namespace performance_counters { namespace server { struct counter_type_from_statistic : counter_type_from_statistic_base { - typedef hpx::util::tag::rolling_min aggregating_tag; - typedef boost::accumulators::accumulator_set> - accumulator_type; + using aggregating_tag = hpx::util::tag::rolling_min; + using accumulator_type = + boost::accumulators::accumulator_set>; counter_type_from_statistic(std::size_t parameter2) : accum_(boost::accumulators::tag::rolling_window::window_size = @@ -338,10 +338,10 @@ namespace hpx { namespace performance_counters { namespace server { struct counter_type_from_statistic : counter_type_from_statistic_base { - typedef hpx::util::tag::rolling_max aggregating_tag; - typedef boost::accumulators::accumulator_set> - accumulator_type; + using aggregating_tag = hpx::util::tag::rolling_max; + using accumulator_type = + boost::accumulators::accumulator_set>; counter_type_from_statistic(std::size_t parameter2) : accum_(boost::accumulators::tag::rolling_window::window_size = @@ -626,7 +626,7 @@ namespace hpx { namespace performance_counters { namespace server { components::get_component_type(), const_cast(this)); } -}}} // namespace hpx::performance_counters::server +} // namespace hpx::performance_counters::server /////////////////////////////////////////////////////////////////////////////// template class HPX_EXPORT hpx::performance_counters::server::statistics_counter< @@ -650,105 +650,106 @@ template class HPX_EXPORT hpx::performance_counters::server::statistics_counter< /////////////////////////////////////////////////////////////////////////////// // Average -typedef hpx::components::component> - average_count_counter_type; +using average_count_counter_type = + hpx::components::component>; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(average_count_counter_type, average_count_counter, "base_performance_counter", - hpx::components::factory_enabled) + hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(average_count_counter_type::wrapped_type) /////////////////////////////////////////////////////////////////////////////// // Rolling variance -typedef hpx::components::component> - rolling_variance_count_counter_type; +using rolling_variance_count_counter_type = + hpx::components::component>; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(rolling_variance_count_counter_type, rolling_variance_count_counter, "base_performance_counter", - hpx::components::factory_enabled) + hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(rolling_variance_count_counter_type::wrapped_type) /////////////////////////////////////////////////////////////////////////////// // Variance -typedef hpx::components::component> - variance_count_counter_type; +using variance_count_counter_type = + hpx::components::component>; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(variance_count_counter_type, variance_count_counter, "base_performance_counter", - hpx::components::factory_enabled) + hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(variance_count_counter_type::wrapped_type) /////////////////////////////////////////////////////////////////////////////// // Rolling average -typedef hpx::components::component> - rolling_mean_count_counter_type; +using rolling_mean_count_counter_type = + hpx::components::component>; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(rolling_mean_count_counter_type, rolling_mean_count_counter, "base_performance_counter", - hpx::components::factory_enabled) + hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(rolling_mean_count_counter_type::wrapped_type) /////////////////////////////////////////////////////////////////////////////// // Median -typedef hpx::components::component> - median_count_counter_type; +using median_count_counter_type = + hpx::components::component>; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(median_count_counter_type, median_count_counter, "base_performance_counter", - hpx::components::factory_enabled) + hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(median_count_counter_type::wrapped_type) /////////////////////////////////////////////////////////////////////////////// // Max -typedef hpx::components::component> - max_count_counter_type; +using max_count_counter_type = + hpx::components::component>; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(max_count_counter_type, max_count_counter, "base_performance_counter", - hpx::components::factory_enabled) + hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(max_count_counter_type::wrapped_type) /////////////////////////////////////////////////////////////////////////////// // Min -typedef hpx::components::component> - min_count_counter_type; +using min_count_counter_type = + hpx::components::component>; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(min_count_counter_type, min_count_counter, "base_performance_counter", - hpx::components::factory_enabled) + hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(min_count_counter_type::wrapped_type) /////////////////////////////////////////////////////////////////////////////// // Rolling min -typedef hpx::components::component> - rolling_min_count_counter_type; +using rolling_min_count_counter_type = + hpx::components::component>; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(rolling_min_count_counter_type, rolling_min_count_counter, "base_performance_counter", - hpx::components::factory_enabled) + hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(rolling_min_count_counter_type::wrapped_type) /////////////////////////////////////////////////////////////////////////////// // Rolling max -typedef hpx::components::component> - rolling_max_count_counter_type; +using rolling_max_count_counter_type = + hpx::components::component>; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(rolling_max_count_counter_type, rolling_max_count_counter, "base_performance_counter", - hpx::components::factory_enabled) + hpx::components::factory_state::enabled) HPX_DEFINE_GET_COMPONENT_TYPE(rolling_max_count_counter_type::wrapped_type) /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace performance_counters { namespace detail { +namespace hpx::performance_counters::detail { + /// Creation function for aggregating performance counters to be registered /// with the counter types. naming::gid_type statistics_counter_creator( @@ -835,4 +836,4 @@ namespace hpx { namespace performance_counters { namespace detail { return naming::invalid_gid; } } -}}} // namespace hpx::performance_counters::detail +} // namespace hpx::performance_counters::detail diff --git a/libs/full/runtime_components/include/hpx/runtime_components/component_factory.hpp b/libs/full/runtime_components/include/hpx/runtime_components/component_factory.hpp index cef7dcf19f3f..80c72f35396b 100644 --- a/libs/full/runtime_components/include/hpx/runtime_components/component_factory.hpp +++ b/libs/full/runtime_components/include/hpx/runtime_components/component_factory.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // Copyright (c) 2011 Bryce Lelbach // // SPDX-License-Identifier: BSL-1.0 @@ -30,9 +30,9 @@ /// If this parameter is not given, the first parameter is used. /// /// \param mode The \a mode parameter has to be one of the defined enumeration -/// values of the enumeration \a hpx::components::factory_state_enum. +/// values of the enumeration \a hpx::components::factory_state. /// The default for this parameter is -/// \a hpx::components::factory_enabled. +/// \a hpx::components::factory_state::enabled. /// #define HPX_REGISTER_COMPONENT(type, name, mode) @@ -59,14 +59,14 @@ /**/ #define HPX_REGISTER_ENABLED_COMPONENT_FACTORY(ComponentType, componentname) \ - HPX_REGISTER_MINIMAL_COMPONENT_FACTORY_3( \ - ComponentType, componentname, ::hpx::components::factory_enabled) \ + HPX_REGISTER_MINIMAL_COMPONENT_FACTORY_3(ComponentType, componentname, \ + ::hpx::components::factory_state::enabled) \ HPX_DEFINE_GET_COMPONENT_TYPE(ComponentType::wrapped_type) \ /**/ #define HPX_REGISTER_DISABLED_COMPONENT_FACTORY(ComponentType, componentname) \ - HPX_REGISTER_MINIMAL_COMPONENT_FACTORY_3( \ - ComponentType, componentname, ::hpx::components::factory_disabled) \ + HPX_REGISTER_MINIMAL_COMPONENT_FACTORY_3(ComponentType, componentname, \ + ::hpx::components::factory_state::disabled) \ HPX_DEFINE_GET_COMPONENT_TYPE(ComponentType::wrapped_type) \ /**/ @@ -77,12 +77,12 @@ /**/ #define HPX_REGISTER_MINIMAL_COMPONENT_FACTORY_1(ComponentType) \ HPX_REGISTER_MINIMAL_COMPONENT_FACTORY_3( \ - ComponentType, ComponentType, ::hpx::components::factory_check) \ + ComponentType, ComponentType, ::hpx::components::factory_state::check) \ HPX_DEFINE_GET_COMPONENT_TYPE(ComponentType::wrapped_type) \ /**/ #define HPX_REGISTER_MINIMAL_COMPONENT_FACTORY_2(ComponentType, componentname) \ HPX_REGISTER_MINIMAL_COMPONENT_FACTORY_3( \ - ComponentType, componentname, ::hpx::components::factory_check) \ + ComponentType, componentname, ::hpx::components::factory_state::check) \ HPX_DEFINE_GET_COMPONENT_TYPE(ComponentType::wrapped_type) \ /**/ #define HPX_REGISTER_MINIMAL_COMPONENT_FACTORY_3( \ @@ -111,15 +111,15 @@ #define HPX_REGISTER_ENABLED_COMPONENT_FACTORY_DYNAMIC( \ ComponentType, componentname) \ - HPX_REGISTER_MINIMAL_COMPONENT_FACTORY_DYNAMIC_3( \ - ComponentType, componentname, ::hpx::components::factory_enabled) \ + HPX_REGISTER_MINIMAL_COMPONENT_FACTORY_DYNAMIC_3(ComponentType, \ + componentname, ::hpx::components::factory_state::enabled) \ HPX_DEFINE_GET_COMPONENT_TYPE(ComponentType::wrapped_type) \ /**/ #define HPX_REGISTER_DISABLED_COMPONENT_FACTORY_DYNAMIC( \ ComponentType, componentname) \ - HPX_REGISTER_MINIMAL_COMPONENT_FACTORY_DYNAMIC_3( \ - ComponentType, componentname, ::hpx::components::factory_disabled) \ + HPX_REGISTER_MINIMAL_COMPONENT_FACTORY_DYNAMIC_3(ComponentType, \ + componentname, ::hpx::components::factory_state::disabled) \ HPX_DEFINE_GET_COMPONENT_TYPE(ComponentType::wrapped_type) \ /**/ @@ -129,13 +129,13 @@ /**/ #define HPX_REGISTER_MINIMAL_COMPONENT_FACTORY_DYNAMIC_1(ComponentType) \ HPX_REGISTER_MINIMAL_COMPONENT_FACTORY_DYNAMIC_3( \ - ComponentType, ComponentType, ::hpx::components::factory_check) \ + ComponentType, ComponentType, ::hpx::components::factory_state::check) \ HPX_DEFINE_GET_COMPONENT_TYPE(ComponentType::wrapped_type) \ /**/ #define HPX_REGISTER_MINIMAL_COMPONENT_FACTORY_DYNAMIC_2( \ ComponentType, componentname) \ HPX_REGISTER_MINIMAL_COMPONENT_FACTORY_DYNAMIC_3( \ - ComponentType, componentname, ::hpx::components::factory_check) \ + ComponentType, componentname, ::hpx::components::factory_state::check) \ HPX_DEFINE_GET_COMPONENT_TYPE(ComponentType::wrapped_type) \ /**/ #define HPX_REGISTER_MINIMAL_COMPONENT_FACTORY_DYNAMIC_3( \ diff --git a/libs/full/runtime_components/include/hpx/runtime_components/component_registry.hpp b/libs/full/runtime_components/include/hpx/runtime_components/component_registry.hpp index aa4dbf6d2a1f..2e2ab2ae439c 100644 --- a/libs/full/runtime_components/include/hpx/runtime_components/component_registry.hpp +++ b/libs/full/runtime_components/include/hpx/runtime_components/component_registry.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // Copyright (c) 2017 Thomas Heller // Copyright (c) 2011 Bryce Lelbach // @@ -15,20 +15,19 @@ #include #include #include -#include #include #include #include /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace components { +namespace hpx::components { namespace detail { HPX_EXPORT void get_component_info(std::vector& fillini, std::string const& filepath, bool is_static, char const* name, - char const* component_string, factory_state_enum state, + char const* component_string, factory_state state, char const* more); HPX_EXPORT bool is_component_enabled(char const* name); @@ -42,7 +41,7 @@ namespace hpx { namespace components { /// /// \tparam Component The component type this registry should be /// responsible for. - template + template struct component_registry : component_registry_base { /// \brief Return the ini-information for all contained components @@ -51,6 +50,8 @@ namespace hpx { namespace components { /// with the ini-information (one line per vector /// element) for all components implemented in this /// module. + /// \param filepath + /// \param is_static /// /// \return Returns \a true if the parameter \a fillini has been /// successfully initialized with the registry data of all @@ -84,12 +85,12 @@ namespace hpx { namespace components { using base_type_holder = typename Component::base_type_holder; char const* name = get_component_name(); - bool enabled = detail::is_component_enabled(name); + bool const enabled = detail::is_component_enabled(name); component_type type = components::get_component_type(); - component_type base_type = + component_type const base_type = components::get_component_type(); - if (component_invalid == type) + if (to_int(hpx::components::component_enum_type::invalid) == type) { // First call to get_component_type, ask AGAS for a unique id. type = detail::get_agas_component_type(name, @@ -101,7 +102,7 @@ namespace hpx { namespace components { components::deleter(type) = &server::destroy; } }; -}} // namespace hpx::components +} // namespace hpx::components /////////////////////////////////////////////////////////////////////////////// /// This macro is used create and to register a minimal component registry with @@ -119,12 +120,12 @@ namespace hpx { namespace components { #define HPX_REGISTER_MINIMAL_COMPONENT_REGISTRY_2( \ ComponentType, componentname) \ HPX_REGISTER_MINIMAL_COMPONENT_REGISTRY_3( \ - ComponentType, componentname, ::hpx::components::factory_check) \ + ComponentType, componentname, ::hpx::components::factory_state::check) \ /**/ #define HPX_REGISTER_MINIMAL_COMPONENT_REGISTRY_3( \ ComponentType, componentname, state) \ - typedef hpx::components::component_registry \ - componentname##_component_registry_type; \ + using componentname##_component_registry_type = \ + hpx::components::component_registry; \ HPX_REGISTER_COMPONENT_REGISTRY( \ componentname##_component_registry_type, componentname) \ template struct hpx::components::component_registry; \ @@ -143,12 +144,12 @@ namespace hpx { namespace components { #define HPX_REGISTER_MINIMAL_COMPONENT_REGISTRY_DYNAMIC_2( \ ComponentType, componentname) \ HPX_REGISTER_MINIMAL_COMPONENT_REGISTRY_DYNAMIC_3( \ - ComponentType, componentname, ::hpx::components::factory_check) \ + ComponentType, componentname, ::hpx::components::factory_state::check) \ /**/ #define HPX_REGISTER_MINIMAL_COMPONENT_REGISTRY_DYNAMIC_3( \ ComponentType, componentname, state) \ - typedef hpx::components::component_registry \ - componentname##_component_registry_type; \ + using componentname##_component_registry_type = \ + hpx::components::component_registry; \ HPX_REGISTER_COMPONENT_REGISTRY_DYNAMIC( \ componentname##_component_registry_type, componentname) \ template struct hpx::components::component_registry; \ diff --git a/libs/full/runtime_components/include/hpx/runtime_components/create_component_helpers.hpp b/libs/full/runtime_components/include/hpx/runtime_components/create_component_helpers.hpp index 3e673d206cef..dfc46a5fcc62 100644 --- a/libs/full/runtime_components/include/hpx/runtime_components/create_component_helpers.hpp +++ b/libs/full/runtime_components/include/hpx/runtime_components/create_component_helpers.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Hartmut Kaiser +// Copyright (c) 2020-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -20,7 +20,7 @@ #include /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace components { +namespace hpx::components { namespace server { @@ -40,13 +40,12 @@ namespace hpx { namespace components { { HPX_THROW_EXCEPTION(hpx::error::bad_parameter, "stubs::runtime_support::create_component_async", - "The id passed as the first argument is not representing" - " a locality"); - return make_ready_future(hpx::invalid_id); + "The id passed as the first argument is not representing " + "a locality"); } - using action_type = server::create_component_action::type...>; + using action_type = + server::create_component_action...>; return hpx::async(gid, HPX_FORWARD(Ts, vs)...); } @@ -59,13 +58,12 @@ namespace hpx { namespace components { { HPX_THROW_EXCEPTION(hpx::error::bad_parameter, "stubs::runtime_support::bulk_create_component_async", - "The id passed as the first argument is not representing" - " a locality"); - return make_ready_future(std::vector()); + "The id passed as the first argument is not representing " + "a locality"); } using action_type = server::bulk_create_component_action::type...>; + std::decay_t...>; return hpx::async(gid, count, HPX_FORWARD(Ts, vs)...); } @@ -88,8 +86,8 @@ namespace hpx { namespace components { future create_colocated_async( hpx::id_type const& gid, Ts&&... vs) { - using action_type = server::create_component_action::type...>; + using action_type = + server::create_component_action...>; return hpx::detail::async_colocated( gid, HPX_FORWARD(Ts, vs)...); @@ -106,7 +104,7 @@ namespace hpx { namespace components { hpx::id_type const& gid, std::size_t count, Ts&&... vs) { using action_type = server::bulk_create_component_action::type...>; + std::decay_t...>; return hpx::detail::async_colocated( gid, count, HPX_FORWARD(Ts, vs)...); @@ -120,4 +118,4 @@ namespace hpx { namespace components { id, count, HPX_FORWARD(Ts, vs)...) .get(); } -}} // namespace hpx::components +} // namespace hpx::components diff --git a/libs/full/runtime_components/include/hpx/runtime_components/derived_component_factory.hpp b/libs/full/runtime_components/include/hpx/runtime_components/derived_component_factory.hpp index 8b16c6940aed..40644f06b2a4 100644 --- a/libs/full/runtime_components/include/hpx/runtime_components/derived_component_factory.hpp +++ b/libs/full/runtime_components/include/hpx/runtime_components/derived_component_factory.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // Copyright (c) 2017 Thomas Heller // Copyright (c) 2011 Bryce Lelbach // @@ -34,7 +34,7 @@ #define HPX_REGISTER_DERIVED_COMPONENT_FACTORY_3( \ ComponentType, componentname, basecomponentname) \ HPX_REGISTER_DERIVED_COMPONENT_FACTORY_4(ComponentType, componentname, \ - basecomponentname, ::hpx::components::factory_check) \ + basecomponentname, ::hpx::components::factory_state::check) \ HPX_DEFINE_GET_COMPONENT_TYPE(ComponentType::wrapped_type) \ /**/ @@ -61,7 +61,8 @@ #define HPX_REGISTER_DERIVED_COMPONENT_FACTORY_DYNAMIC_3( \ ComponentType, componentname, basecomponentname) \ HPX_REGISTER_DERIVED_COMPONENT_FACTORY_DYNAMIC_4(ComponentType, \ - componentname, basecomponentname, ::hpx::components::factory_check) \ + componentname, basecomponentname, \ + ::hpx::components::factory_state::check) \ HPX_DEFINE_GET_COMPONENT_TYPE(ComponentType::wrapped_type) \ /**/ diff --git a/libs/full/runtime_components/include/hpx/runtime_components/distributed_metadata_base.hpp b/libs/full/runtime_components/include/hpx/runtime_components/distributed_metadata_base.hpp index 3be05800a4b5..0a1838cfdeb7 100644 --- a/libs/full/runtime_components/include/hpx/runtime_components/distributed_metadata_base.hpp +++ b/libs/full/runtime_components/include/hpx/runtime_components/distributed_metadata_base.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -14,29 +14,20 @@ #include #include #include -#include -#include #include #include #include #include -namespace hpx { namespace components { namespace server { - - namespace detail { - - struct this_type - { - }; - } // namespace detail +namespace hpx::components::server { /////////////////////////////////////////////////////////////////////////// - template + template class distributed_metadata_base - : public hpx::components::component_base::value, - distributed_metadata_base, Derived>::type> + : public hpx::components::component_base< + std::conditional_t, + distributed_metadata_base, Derived>> { public: distributed_metadata_base() @@ -60,7 +51,7 @@ namespace hpx { namespace components { namespace server { private: ConfigData data_; }; -}}} // namespace hpx::components::server +} // namespace hpx::components::server #define HPX_DISTRIBUTED_METADATA_DECLARATION(...) \ HPX_DISTRIBUTED_METADATA_DECLARATION_(__VA_ARGS__) \ diff --git a/libs/full/runtime_components/src/component_registry.cpp b/libs/full/runtime_components/src/component_registry.cpp index fcf5c27373b9..9489316bedfa 100644 --- a/libs/full/runtime_components/src/component_registry.cpp +++ b/libs/full/runtime_components/src/component_registry.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // Copyright (c) 2017 Thomas Heller // Copyright (c) 2011 Bryce Lelbach // @@ -20,12 +20,11 @@ #include /////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace components { namespace detail { +namespace hpx::components::detail { void get_component_info(std::vector& fillini, std::string const& filepath, bool is_static, char const* name, - char const* component_string, factory_state_enum state, - char const* more) + char const* component_string, factory_state state, char const* more) { fillini.emplace_back(std::string("[hpx.components.") + name + "]"); fillini.emplace_back(std::string("name = ") + component_string); @@ -45,13 +44,13 @@ namespace hpx { namespace components { namespace detail { switch (state) { - case factory_enabled: + case hpx::components::factory_state::enabled: fillini.emplace_back("enabled = 1"); break; - case factory_disabled: + case hpx::components::factory_state::disabled: fillini.emplace_back("enabled = 0"); break; - case factory_check: + case hpx::components::factory_state::check: fillini.emplace_back("enabled = $[hpx.components.load_external]"); break; } @@ -87,4 +86,4 @@ namespace hpx { namespace components { namespace detail { } return true; } -}}} // namespace hpx::components::detail +} // namespace hpx::components::detail diff --git a/libs/full/runtime_distributed/include/hpx/runtime_distributed/applier.hpp b/libs/full/runtime_distributed/include/hpx/runtime_distributed/applier.hpp index 588459838e1f..4c8fa8d34144 100644 --- a/libs/full/runtime_distributed/include/hpx/runtime_distributed/applier.hpp +++ b/libs/full/runtime_distributed/include/hpx/runtime_distributed/applier.hpp @@ -94,15 +94,17 @@ namespace hpx { namespace applier { /// on the returned localities. /// /// \returns The function returns \a true if there is at least one - /// remote locality known to the AGASservice + /// remote locality known to the AGAS service /// (!prefixes.empty()). bool get_raw_remote_localities( std::vector& locality_ids, - components::component_type type = components::component_invalid, + components::component_type type = to_int( + hpx::components::component_enum_type::invalid), error_code& ec = throws) const; bool get_remote_localities(std::vector& locality_ids, - components::component_type type = components::component_invalid, + components::component_type type = to_int( + hpx::components::component_enum_type::invalid), error_code& ec = throws) const; /// \brief Return list of locality_ids of all localities @@ -119,11 +121,11 @@ namespace hpx { namespace applier { /// on the returned localities. /// /// \returns The function returns \a true if there is at least one - /// remote locality known to the AGASservice + /// remote locality known to the AGAS service /// (!prefixes.empty()). bool get_raw_localities(std::vector& locality_ids, - components::component_type type = - components::component_invalid) const; + components::component_type type = to_int( + hpx::components::component_enum_type::invalid)) const; bool get_localities(std::vector& locality_ids, error_code& ec = throws) const; diff --git a/libs/full/runtime_distributed/src/applier.cpp b/libs/full/runtime_distributed/src/applier.cpp index b2fd0fd414d7..ac78e03d9f62 100644 --- a/libs/full/runtime_distributed/src/applier.cpp +++ b/libs/full/runtime_distributed/src/applier.cpp @@ -141,8 +141,8 @@ namespace hpx { namespace applier { { std::vector raw_prefixes; #if defined(HPX_HAVE_NETWORKING) - if (!parcel_handler_->get_raw_localities( - raw_prefixes, components::component_invalid, ec)) + if (!parcel_handler_->get_raw_localities(raw_prefixes, + to_int(hpx::components::component_enum_type::invalid), ec)) return false; for (naming::gid_type& gid : raw_prefixes) diff --git a/libs/full/runtime_distributed/src/big_boot_barrier.cpp b/libs/full/runtime_distributed/src/big_boot_barrier.cpp index 0ba63e1ad67a..aade84edc5fe 100644 --- a/libs/full/runtime_distributed/src/big_boot_barrier.cpp +++ b/libs/full/runtime_distributed/src/big_boot_barrier.cpp @@ -487,20 +487,19 @@ namespace hpx::agas { "agas::register_worker", "attempt to register locality {} more than once", header.endpoints); - return; } naming::address locality_addr(agas::get_locality(), - hpx::components::component_agas_locality_namespace, + to_int(components::component_enum_type::agas_locality_namespace), agas_client.locality_ns_->ptr()); naming::address primary_addr(agas::get_locality(), - hpx::components::component_agas_primary_namespace, + to_int(components::component_enum_type::agas_primary_namespace), agas_client.primary_ns_.ptr()); naming::address component_addr(agas::get_locality(), - hpx::components::component_agas_component_namespace, + to_int(components::component_enum_type::agas_component_namespace), agas_client.component_ns_->ptr()); naming::address symbol_addr(agas::get_locality(), - hpx::components::component_agas_symbol_namespace, + to_int(components::component_enum_type::agas_symbol_namespace), agas_client.symbol_ns_.ptr()); // assign cores to the new locality diff --git a/libs/full/runtime_distributed/src/runtime_distributed.cpp b/libs/full/runtime_distributed/src/runtime_distributed.cpp index d6528e219515..e68af9ecc61e 100644 --- a/libs/full/runtime_distributed/src/runtime_distributed.cpp +++ b/libs/full/runtime_distributed/src/runtime_distributed.cpp @@ -131,7 +131,7 @@ namespace hpx { bg_send_duration); if (rt->get_parcel_handler().do_background_work(num_thread, - false, parcelset::parcelport_background_mode_send)) + false, parcelset::parcelport_background_mode::send)) { result = true; } @@ -144,7 +144,7 @@ namespace hpx { bg_receive_duration); if (rt->get_parcel_handler().do_background_work(num_thread, - false, parcelset::parcelport_background_mode_receive)) + false, parcelset::parcelport_background_mode::receive)) { result = true; } @@ -165,7 +165,7 @@ namespace hpx { #if defined(HPX_HAVE_NETWORKING) if (rt->get_parcel_handler().do_background_work(num_thread, false, - parcelset::parcelport_background_mode_all)) + parcelset::parcelport_background_mode::all)) { result = true; } @@ -607,7 +607,7 @@ namespace hpx { LRT_(warning).format("runtime_distributed: about to stop services"); // flush all parcel buffers, stop buffering parcels at this point - //parcel_handler_.do_background_work(true, parcelport_background_mode_all); + //parcel_handler_.do_background_work(true, parcelport_background_mode::all); // execute all on_exit functions whenever the first thread calls this this->runtime::stopping(); @@ -1819,8 +1819,8 @@ namespace hpx { return locality_ids; } - hpx::applier::get_applier().get_remote_localities( - locality_ids, components::component_invalid, ec); + hpx::applier::get_applier().get_remote_localities(locality_ids, + to_int(hpx::components::component_enum_type::invalid), ec); return locality_ids; } diff --git a/libs/full/runtime_distributed/src/server/runtime_support_server.cpp b/libs/full/runtime_distributed/src/server/runtime_support_server.cpp index 4ccadffedef9..42e272add1fb 100644 --- a/libs/full/runtime_distributed/src/server/runtime_support_server.cpp +++ b/libs/full/runtime_distributed/src/server/runtime_support_server.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2016 Hartmut Kaiser +// Copyright (c) 2007-2024 Hartmut Kaiser // Copyright (c) 2011 Bryce Lelbach // // SPDX-License-Identifier: BSL-1.0 @@ -123,7 +123,7 @@ HPX_REGISTER_ACTION_ID( HPX_DEFINE_COMPONENT_NAME( hpx::components::server::runtime_support, hpx_runtime_support) HPX_DEFINE_GET_COMPONENT_TYPE_STATIC(hpx::components::server::runtime_support, - hpx::components::component_runtime_support) + to_int(hpx::components::component_enum_type::runtime_support)) namespace hpx { // helper function to stop evaluating counters during shutdown diff --git a/libs/full/segmented_algorithms/tests/unit/partitioned_vector_target.cpp b/libs/full/segmented_algorithms/tests/unit/partitioned_vector_target.cpp index 8868874e89d3..ba315679880a 100644 --- a/libs/full/segmented_algorithms/tests/unit/partitioned_vector_target.cpp +++ b/libs/full/segmented_algorithms/tests/unit/partitioned_vector_target.cpp @@ -13,18 +13,19 @@ #include #include +#include #include /////////////////////////////////////////////////////////////////////////////// // Define the vector types to be used. -typedef hpx::compute::host::block_allocator target_allocator_int; -typedef hpx::compute::vector target_vector_int; +using target_allocator_int = hpx::compute::host::block_allocator; +using target_vector_int = hpx::compute::vector; HPX_REGISTER_PARTITIONED_VECTOR_DECLARATION(int, target_vector_int) HPX_REGISTER_PARTITIONED_VECTOR(int, target_vector_int) -typedef hpx::compute::host::block_allocator target_allocator_double; -typedef hpx::compute::vector - target_vector_double; +using target_allocator_double = hpx::compute::host::block_allocator; +using target_vector_double = + hpx::compute::vector; HPX_REGISTER_PARTITIONED_VECTOR_DECLARATION(double, target_vector_double) HPX_REGISTER_PARTITIONED_VECTOR(double, target_vector_double) @@ -32,20 +33,17 @@ HPX_REGISTER_PARTITIONED_VECTOR(double, target_vector_double) template void allocation_tests() { - std::size_t const length = 12; - - typedef hpx::compute::host::block_allocator target_allocator; - typedef hpx::compute::vector target_vector; + using target_allocator = hpx::compute::host::block_allocator; + using target_vector = hpx::compute::vector; for (hpx::id_type const& locality : hpx::find_all_localities()) { std::vector targets = hpx::compute::host::distributed::get_targets(locality).get(); - { - hpx::partitioned_vector v( - length, T(42), hpx::compute::host::target_layout); - } + constexpr std::size_t length = 12; + hpx::partitioned_vector v(length, T(42), + hpx::compute::host::target_layout(std::move(targets))); } //{ diff --git a/tests/performance/local/agas_cache_timings.cpp b/tests/performance/local/agas_cache_timings.cpp index 41fc152c99b5..70f7996956b9 100644 --- a/tests/performance/local/agas_cache_timings.cpp +++ b/tests/performance/local/agas_cache_timings.cpp @@ -166,7 +166,7 @@ void calculate_histogram( void test_insert(gva_cache_type& cache, std::size_t num_entries) { hpx::naming::gid_type locality = hpx::get_locality(); - std::int32_t ct = hpx::components::component_invalid; + std::int32_t ct = to_int(hpx::components::component_enum_type::invalid); std::vector timings; timings.reserve(num_entries); @@ -210,7 +210,7 @@ void test_get(gva_cache_type& cache, hpx::naming::gid_type first_key) void test_update(gva_cache_type& cache, hpx::naming::gid_type first_key) { hpx::naming::gid_type locality = hpx::get_locality(); - std::int32_t ct = hpx::components::component_invalid; + std::int32_t ct = to_int(hpx::components::component_enum_type::invalid); std::vector timings; timings.reserve(cache.size());