diff --git a/.github/workflows/linux_release_static.yml b/.github/workflows/linux_release_static.yml new file mode 100644 index 000000000000..6ff33a5fb9d3 --- /dev/null +++ b/.github/workflows/linux_release_static.yml @@ -0,0 +1,47 @@ +# Copyright (c) 2020 ETH Zurich +# Copyright (c) 2023 The STE||AR Group +# +# 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) + +name: Linux CI (Release, Static) + +on: [pull_request] + +jobs: + build: + runs-on: ubuntu-latest + container: stellargroup/build_env:16 + + steps: + - uses: actions/checkout@v3 + - name: Configure + shell: bash + run: | + cmake \ + . \ + -Bbuild \ + -GNinja \ + -DCMAKE_BUILD_TYPE=Release \ + -DHPX_WITH_STATIC_LINKING=ON \ + -DHPX_WITH_MALLOC=system \ + -DHPX_WITH_FETCH_ASIO=ON \ + -DHPX_WITH_EXAMPLES=ON \ + -DHPX_WITH_TESTS=ON \ + -DHPX_WITH_TESTS_MAX_THREADS_PER_LOCALITY=2 \ + -DHPX_WITH_CHECK_MODULE_DEPENDENCIES=On + - name: Build + shell: bash + run: | + cmake --build build --target all + cmake --build build --target examples + - name: Test + shell: bash + run: | + cd build + ctest \ + --output-on-failure \ + --tests-regex tests.examples \ + --exclude-regex tests.examples.transpose.transpose_block_numa \ + --exclude-regex tests.examples.quickstart.distributed.tcp.custom_serialization diff --git a/cmake/FindHwloc.cmake b/cmake/FindHwloc.cmake index cdede78fb68b..89dadf132013 100644 --- a/cmake/FindHwloc.cmake +++ b/cmake/FindHwloc.cmake @@ -26,7 +26,7 @@ if(NOT TARGET Hwloc::hwloc) find_library( HWLOC_LIBRARY - NAMES hwloc libhwloc + NAMES libhwloc.so hwloc HINTS ${HWLOC_ROOT} ENV HWLOC_ROOT @@ -70,7 +70,8 @@ if(NOT TARGET Hwloc::hwloc) add_library(Hwloc::hwloc INTERFACE IMPORTED) target_include_directories(Hwloc::hwloc SYSTEM INTERFACE ${HWLOC_INCLUDE_DIR}) - target_link_libraries(Hwloc::hwloc INTERFACE ${HWLOC_LIBRARIES}) + target_link_libraries(Hwloc::hwloc INTERFACE ${HWLOC_LIBRARIES}) mark_as_advanced(HWLOC_ROOT HWLOC_LIBRARY HWLOC_INCLUDE_DIR) + endif() diff --git a/cmake/HPX_AddModule.cmake b/cmake/HPX_AddModule.cmake index 3efec41ec1f1..22510e5117be 100644 --- a/cmake/HPX_AddModule.cmake +++ b/cmake/HPX_AddModule.cmake @@ -176,10 +176,9 @@ function(add_hpx_module libname modulename) endforeach() else() foreach(file_to_generate ${${modulename}_GENERATED_HEADERS}) - if(EXISTS ${file_to_generate}) - hpx_warn("Removing zombie generated header: ${file_to_generate}") - file(REMOVE ${file_to_generate}) - endif() + set(generated_headers ${generated_headers} + ${generated_file_base}/${file_to_generate} + ) endforeach() endif() endif() @@ -284,8 +283,8 @@ function(add_hpx_module libname modulename) list(FIND _hpx_${libname}_modules ${dep} dep_index) if(${dep_index} EQUAL -1) hpx_error( - "The module ${dep} should not be be listed in MODULE_DEPENDENCIES " - "for module hpx_${modulename}" + "The module hpx_${dep} should not be be listed in MODULE_DEPENDENCIES " + "for '${libname}' module hpx_${modulename}" ) endif() endif() diff --git a/cmake/HPX_ParcelPorts.cmake b/cmake/HPX_ParcelPorts.cmake index 0c7aab45bb31..8dbcafc6df1c 100644 --- a/cmake/HPX_ParcelPorts.cmake +++ b/cmake/HPX_ParcelPorts.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Hartmut Kaiser +# Copyright (c) 2021-2023 Hartmut Kaiser # # SPDX-License-Identifier: BSL-1.0 # Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -9,26 +9,6 @@ if(HPX_WITH_DISTRIBUTED_RUNTIME) ${HPX_STATIC_PARCELPORT_PLUGINS} ) - # add_subdirectory is called before to insure HPX_STATIC_PARCELPORT_PLUGINS - # cache variable is filled - set(_parcelport_export) - set(_parcelport_init) - - foreach(parcelport ${HPX_STATIC_PARCELPORT_PLUGINS}) - set(_parcelport_export - "${_parcelport_export}HPX_EXPORT hpx::plugins::parcelport_factory_base *${parcelport}_factory_init(\n" - ) - set(_parcelport_export - "${_parcelport_export} std::vector& factories);\n" - ) - set(_parcelport_init - "${_parcelport_init} ${parcelport}_factory_init(factories);\n" - ) - endforeach() - - configure_file( - "${PROJECT_SOURCE_DIR}/cmake/templates/static_parcelports.hpp.in" - "${PROJECT_BINARY_DIR}/libs/full/parcelset/include/hpx/parcelset/static_parcelports.hpp" - @ONLY - ) + # handle parcelports module to create proper dependencies + add_subdirectory(libs/full/parcelports) endif() diff --git a/cmake/HPX_SetupTarget.cmake b/cmake/HPX_SetupTarget.cmake index aec75f68959e..5b3f8c61950b 100644 --- a/cmake/HPX_SetupTarget.cmake +++ b/cmake/HPX_SetupTarget.cmake @@ -216,6 +216,8 @@ function(hpx_setup_target target) hpx_debug("setup_target.${target} UNITY_BUILD: OFF") endif() + set_target_properties(${target} PROPERTIES POSITION_INDEPENDENT_CODE ON) + get_target_property(target_EXCLUDE_FROM_ALL ${target} EXCLUDE_FROM_ALL) if(target_EXPORT AND NOT target_EXCLUDE_FROM_ALL) diff --git a/components/parcel_plugins/binary_filter/bzip2/CMakeLists.txt b/components/parcel_plugins/binary_filter/bzip2/CMakeLists.txt index cd0ed71697ec..33d173ab75af 100644 --- a/components/parcel_plugins/binary_filter/bzip2/CMakeLists.txt +++ b/components/parcel_plugins/binary_filter/bzip2/CMakeLists.txt @@ -30,14 +30,15 @@ add_hpx_library( "hpx/binary_filter/bzip2_serialization_filter.hpp" "hpx/binary_filter/bzip2_serialization_filter_registration.hpp" PREPEND_HEADER_ROOT INSTALL_HEADERS - FOLDER "Core/Plugins/Compression" - DEPENDENCIES ${BZIP2_LIBRARIES} ${HPX_WITH_UNITY_BUILD_OPTION} + FOLDER "Core/Plugins/Compression" ${HPX_WITH_UNITY_BUILD_OPTION} ) target_include_directories( compression_bzip2 SYSTEM PRIVATE ${BZIP2_INCLUDE_DIR} ) -target_link_libraries(compression_bzip2 PUBLIC Boost::iostreams) +target_link_libraries( + compression_bzip2 PUBLIC Boost::iostreams ${BZIP2_LIBRARIES} +) add_hpx_pseudo_dependencies( components.parcel_plugins.binary_filter.bzip2 compression_bzip2 diff --git a/components/parcel_plugins/binary_filter/snappy/CMakeLists.txt b/components/parcel_plugins/binary_filter/snappy/CMakeLists.txt index ebc41f37b119..6550e27e3ca1 100644 --- a/components/parcel_plugins/binary_filter/snappy/CMakeLists.txt +++ b/components/parcel_plugins/binary_filter/snappy/CMakeLists.txt @@ -30,8 +30,7 @@ add_hpx_library( "hpx/binary_filter/snappy_serialization_filter.hpp" "hpx/binary_filter/snappy_serialization_filter_registration.hpp" PREPEND_HEADER_ROOT INSTALL_HEADERS - FOLDER "Core/Plugins/Compression" - DEPENDENCIES ${SNAPPY_LIBRARY} ${HPX_WITH_UNITY_BUILD_OPTION} + FOLDER "Core/Plugins/Compression" ${HPX_WITH_UNITY_BUILD_OPTION} ) target_include_directories( @@ -39,7 +38,9 @@ target_include_directories( ) target_link_directories(compression_snappy PRIVATE ${SNAPPY_LIBRARY_DIR}) -target_link_libraries(compression_snappy PUBLIC Boost::iostreams) +target_link_libraries( + compression_snappy PUBLIC Boost::iostreams ${SNAPPY_LIBRARY} +) add_hpx_pseudo_dependencies( components.parcel_plugins.binary_filter.snappy compression_snappy diff --git a/components/parcel_plugins/binary_filter/zlib/CMakeLists.txt b/components/parcel_plugins/binary_filter/zlib/CMakeLists.txt index 1b324f17e1c7..6dba673e7225 100644 --- a/components/parcel_plugins/binary_filter/zlib/CMakeLists.txt +++ b/components/parcel_plugins/binary_filter/zlib/CMakeLists.txt @@ -30,12 +30,13 @@ add_hpx_library( "hpx/binary_filter/zlib_serialization_filter.hpp" "hpx/binary_filter/zlib_serialization_filter_registration.hpp" PREPEND_HEADER_ROOT INSTALL_HEADERS - FOLDER "Core/Plugins/Compression" - DEPENDENCIES ${ZLIB_LIBRARIES} ${HPX_WITH_UNITY_BUILD_OPTION} + FOLDER "Core/Plugins/Compression" ${HPX_WITH_UNITY_BUILD_OPTION} ) target_include_directories(compression_zlib SYSTEM PRIVATE ${ZLIB_INCLUDE_DIRS}) -target_link_libraries(compression_zlib PUBLIC Boost::iostreams) +target_link_libraries( + compression_zlib PUBLIC Boost::iostreams ${ZLIB_LIBRARIES} +) add_hpx_pseudo_dependencies( components.parcel_plugins.binary_filter.zlib compression_zlib diff --git a/examples/cancelable_action/cancelable_action/cancelable_action.cpp b/examples/cancelable_action/cancelable_action/cancelable_action.cpp index 189b352e556c..8c176f414cc2 100644 --- a/examples/cancelable_action/cancelable_action/cancelable_action.cpp +++ b/examples/cancelable_action/cancelable_action/cancelable_action.cpp @@ -1,14 +1,14 @@ -// Copyright (c) 2007-2012 Hartmut Kaiser +// Copyright (c) 2007-2023 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 -#include +#include #include "server/cancelable_action.hpp" @@ -17,8 +17,8 @@ HPX_REGISTER_COMPONENT_MODULE() /////////////////////////////////////////////////////////////////////////////// -typedef hpx::components::component - cancelable_action_component_type; +using cancelable_action_component_type = + hpx::components::component; HPX_REGISTER_COMPONENT(cancelable_action_component_type, cancelable_action) diff --git a/examples/cancelable_action/cancelable_action/cancelable_action.hpp b/examples/cancelable_action/cancelable_action/cancelable_action.hpp index cd660ff0e4ab..372ac05e1ebd 100644 --- a/examples/cancelable_action/cancelable_action/cancelable_action.hpp +++ b/examples/cancelable_action/cancelable_action/cancelable_action.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2011 Hartmut Kaiser +// Copyright (c) 2007-2023 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -11,21 +11,21 @@ #include #include -#include "stubs/cancelable_action.hpp" +#include "server/cancelable_action.hpp" #include namespace examples { + /////////////////////////////////////////////////////////////////////////// // Client side representation for for the \a server::cancelable_action // component. class cancelable_action : public hpx::components::client_base + server::cancelable_action> { - typedef hpx::components::client_base - base_type; + using base_type = hpx::components::client_base; public: // Default construct an empty client side representation (not @@ -45,16 +45,18 @@ namespace examples { } /////////////////////////////////////////////////////////////////////// - void do_it(hpx::error_code& ec = hpx::throws) + void do_it(hpx::error_code& ec = hpx::throws) const { + using action_type = server::cancelable_action::do_it_action; HPX_ASSERT(this->get_id()); - this->base_type::do_it(this->get_id(), ec); + hpx::async(this->get_id()).get(ec); } - void cancel_it() + void cancel_it() const { + using action_type = server::cancelable_action::cancel_it_action; HPX_ASSERT(this->get_id()); - this->base_type::cancel_it(this->get_id()); + hpx::post(this->get_id()); } }; } // namespace examples diff --git a/examples/cancelable_action/cancelable_action/server/cancelable_action.hpp b/examples/cancelable_action/cancelable_action/server/cancelable_action.hpp index b3b9de3e62f7..9c131d256650 100644 --- a/examples/cancelable_action/cancelable_action/server/cancelable_action.hpp +++ b/examples/cancelable_action/cancelable_action/server/cancelable_action.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2022 Hartmut Kaiser +// Copyright (c) 2007-2023 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -7,18 +7,22 @@ #pragma once #include + #if !defined(HPX_COMPUTE_DEVICE_CODE) -#include +#include + #include #include #include #include #include +#include #include /////////////////////////////////////////////////////////////////////////////// -namespace examples { namespace server { +namespace examples::server { + /////////////////////////////////////////////////////////////////////////// inline void delay(int c) { @@ -50,24 +54,29 @@ namespace examples { namespace server { explicit reset_id(cancelable_action& this_) : outer_(this_) { - std::lock_guard l(outer_.mtx_); - hpx::thread::id old_value = outer_.id_; + auto const mtx = outer_.mtx_; + std::lock_guard l(*mtx); + + [[maybe_unused]] hpx::thread::id const old_value = outer_.id_; outer_.id_ = hpx::this_thread::get_id(); HPX_ASSERT(old_value == hpx::thread::id()); - HPX_UNUSED(old_value); } ~reset_id() { - hpx::thread::id old_value = outer_.id_; + [[maybe_unused]] hpx::thread::id const old_value = outer_.id_; outer_.id_ = hpx::thread::id(); HPX_ASSERT(old_value != hpx::thread::id()); - HPX_UNUSED(old_value); } cancelable_action& outer_; }; public: + cancelable_action() + : mtx_(std::make_shared()) + { + } + // Do some lengthy work void do_it() { @@ -85,15 +94,17 @@ namespace examples { namespace server { } // Cancel the lengthy action above - void cancel_it() + void cancel_it() const { // Make sure id_ has been set hpx::util::yield_while([this]() { - std::lock_guard l(mtx_); + auto const mtx = mtx_; + std::lock_guard l(*mtx); return id_ == hpx::thread::id(); }); - std::lock_guard l(mtx_); + auto const mtx = mtx_; + std::lock_guard l(*mtx); HPX_ASSERT(id_ != hpx::thread::id()); hpx::thread::interrupt(id_); } @@ -103,10 +114,10 @@ namespace examples { namespace server { cancelable_action, cancel_it, cancel_it_action) private: - hpx::mutex mtx_; + std::shared_ptr mtx_; hpx::thread::id id_; }; -}} // namespace examples::server +} // namespace examples::server /////////////////////////////////////////////////////////////////////////////// HPX_REGISTER_ACTION_DECLARATION( diff --git a/examples/cancelable_action/cancelable_action/stubs/cancelable_action.hpp b/examples/cancelable_action/cancelable_action/stubs/cancelable_action.hpp deleted file mode 100644 index e7253a683c72..000000000000 --- a/examples/cancelable_action/cancelable_action/stubs/cancelable_action.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2007-2012 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) - -#pragma once - -#include -#if !defined(HPX_COMPUTE_DEVICE_CODE) -#include - -#include "../server/cancelable_action.hpp" - -/////////////////////////////////////////////////////////////////////////////// -namespace examples { namespace stubs { - /////////////////////////////////////////////////////////////////////////// - struct cancelable_action - : hpx::components::stub_base - { - // Do some lengthy work - static hpx::future do_it_async(hpx::id_type const& gid) - { - typedef server::cancelable_action::do_it_action action_type; - return hpx::async(gid); - } - - static void do_it( - hpx::id_type const& gid, hpx::error_code& ec = hpx::throws) - { - do_it_async(gid).get(ec); - } - - // Cancel the lengthy action above - static void cancel_it(hpx::id_type const& gid) - { - typedef server::cancelable_action::cancel_it_action action_type; - hpx::post(gid); - } - }; -}} // namespace examples::stubs - -#endif diff --git a/examples/cancelable_action/cancelable_action_client.cpp b/examples/cancelable_action/cancelable_action_client.cpp index 5d025fa10e2b..11e166230083 100644 --- a/examples/cancelable_action/cancelable_action_client.cpp +++ b/examples/cancelable_action/cancelable_action_client.cpp @@ -1,10 +1,11 @@ -// Copyright (c) 2007-2012 Hartmut Kaiser +// Copyright (c) 2007-2023 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 @@ -12,7 +13,7 @@ #include "cancelable_action/cancelable_action.hpp" /////////////////////////////////////////////////////////////////////////////// -void interrupt_do_it(examples::cancelable_action ca) +void interrupt_do_it(examples::cancelable_action const& ca) { // wait for one second before interrupting the (possibly remote) operation hpx::this_thread::sleep_for(std::chrono::seconds(1)); diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index 1791882be2e0..974c7592f239 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -100,13 +100,7 @@ target_include_directories( ) target_link_libraries(hpx_full PUBLIC hpx_base_libraries) - -if((NOT HPX_WITH_STATIC_LINKING) AND (("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - OR (APPLE)) -) - set_target_properties(hpx_full PROPERTIES POSITION_INDEPENDENT_CODE ON) -endif() - +set_target_properties(hpx_full PROPERTIES POSITION_INDEPENDENT_CODE ON) target_compile_definitions(hpx_full PRIVATE HPX_COMPONENT_NAME=hpx HPX_EXPORTS) # ############################################################################## @@ -340,6 +334,11 @@ foreach(lib ${HPX_LIBS}) endif() add_subdirectory(${lib}) + + set(_hpx_${lib}_modules + ${_hpx_${lib}_modules} + PARENT_SCOPE + ) endforeach() # add_hpx_module populates HPX_ENABLED_MODULES diff --git a/libs/core/CMakeLists.txt b/libs/core/CMakeLists.txt index ac374840ecfc..c7cb957f36e6 100644 --- a/libs/core/CMakeLists.txt +++ b/libs/core/CMakeLists.txt @@ -93,3 +93,8 @@ hpx_info(" Configuring libhpx_core modules:") foreach(module ${_hpx_core_modules}) add_subdirectory(${module}) endforeach() + +set(_hpx_core_modules + ${_hpx_core_modules} + PARENT_SCOPE +) diff --git a/libs/core/include_local/CMakeLists.txt b/libs/core/include_local/CMakeLists.txt index b95b536e1f4d..6bae183b3cfe 100644 --- a/libs/core/include_local/CMakeLists.txt +++ b/libs/core/include_local/CMakeLists.txt @@ -32,15 +32,17 @@ set(include_local_headers hpx/experimental/task_group.hpp ) -set(generated_include_local_headers - hpx/algorithm.hpp - hpx/barrier.hpp - hpx/channel.hpp - hpx/compute.hpp - hpx/future.hpp - hpx/latch.hpp - hpx/runtime.hpp -) +if(NOT HPX_WITH_DISTRIBUTED_RUNTIME) + set(generated_include_local_headers + hpx/algorithm.hpp + hpx/barrier.hpp + hpx/channel.hpp + hpx/compute.hpp + hpx/future.hpp + hpx/latch.hpp + hpx/runtime.hpp + ) +endif() # The headers in hpx/local/ were deprecated in HPX V1.9.1 # cmake-format: off diff --git a/libs/core/init_runtime_local/CMakeLists.txt b/libs/core/init_runtime_local/CMakeLists.txt index d2316469b18b..a122badfed8e 100644 --- a/libs/core/init_runtime_local/CMakeLists.txt +++ b/libs/core/init_runtime_local/CMakeLists.txt @@ -12,7 +12,9 @@ set(init_runtime_local_headers hpx/init_runtime_local/detail/init_logging.hpp hpx/init_runtime_local/init_runtime_local.hpp ) -set(generated_init_runtime_local_headers hpx/init.hpp) +if(NOT HPX_WITH_DISTRIBUTED_RUNTIME) + set(generated_init_runtime_local_headers hpx/init.hpp) +endif() set(init_runtime_local_sources init_logging.cpp init_runtime_local.cpp) diff --git a/libs/create_module_skeleton.py b/libs/create_module_skeleton.py index 9ca789c583f1..e254f101d4a1 100755 --- a/libs/create_module_skeleton.py +++ b/libs/create_module_skeleton.py @@ -2,6 +2,7 @@ ''' Copyright (c) 2019-2020 ETH Zurich Copyright (c) 2018 Thomas Heller +Copyright (c) 2022-2023 Hartmut Kaiser SPDX-License-Identifier: BSL-1.0 Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -24,14 +25,14 @@ header_str = '=' * len(module_name) -cmake_root_header = f'''# Copyright (c) 2019-2021 The STE||AR-Group +cmake_root_header = f'''# Copyright (c) 2019-2023 The STE||AR-Group # # 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) ''' -cmake_header = f'''# Copyright (c) 2020-2021 The STE||AR-Group +cmake_header = f'''# Copyright (c) 2020-2023 The STE||AR-Group # # SPDX-License-Identifier: BSL-1.0 # Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -40,7 +41,7 @@ readme_template = f''' .. - Copyright (c) 2020-2021 The STE||AR-Group + Copyright (c) 2020-2023 The STE||AR-Group SPDX-License-Identifier: BSL-1.0 Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -57,7 +58,7 @@ ''' index_rst = f'''.. - Copyright (c) 2020-2021 The STE||AR-Group + Copyright (c) 2020-2023 The STE||AR-Group SPDX-License-Identifier: BSL-1.0 Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -255,7 +256,7 @@ def mkdir(path): header_underline_str = '=' * len(header_name_str) modules_rst = f'''.. - Copyright (c) 2018-2021 The STE||AR-Group + Copyright (c) 2018-2023 The STE||AR-Group SPDX-License-Identifier: BSL-1.0 Distributed under the Boost Software License, Version 1.0. (See accompanying diff --git a/libs/full/CMakeLists.txt b/libs/full/CMakeLists.txt index d491915e7ba1..40d254f0d17b 100644 --- a/libs/full/CMakeLists.txt +++ b/libs/full/CMakeLists.txt @@ -35,6 +35,7 @@ set(_hpx_full_modules parcelport_libfabric parcelport_mpi parcelport_tcp + parcelports parcelset parcelset_base performance_counters @@ -51,5 +52,14 @@ hpx_info("") hpx_info(" Configuring libhpx modules:") foreach(module ${_hpx_full_modules}) - add_subdirectory(${module}) + # the parcelports module is handled explicitly after all other modules have + # been processed (see HPX_ParcelPorts.cmake) + if(NOT (${module} STREQUAL "parcelports")) + add_subdirectory(${module}) + endif() endforeach() + +set(_hpx_full_modules + ${_hpx_full_modules} + PARENT_SCOPE +) diff --git a/libs/full/agas/src/route.cpp b/libs/full/agas/src/route.cpp index 3fde16520a9f..a9e237b7fab6 100644 --- a/libs/full/agas/src/route.cpp +++ b/libs/full/agas/src/route.cpp @@ -10,6 +10,7 @@ #if defined(HPX_HAVE_NETWORKING) #include #include +#include #include #include #include @@ -41,32 +42,28 @@ HPX_PLAIN_ACTION_ID(hpx::detail::update_agas_cache, update_agas_cache_action, namespace hpx::agas::server { - void primary_namespace::route(parcelset::parcel&& p) + void route_impl(primary_namespace& server, parcelset::parcel&& p) { - LPT_(debug).format("primary_namespace::route: {}", p.parcel_id()); - - util::scoped_timer> update( - counter_data_.route_.time_, counter_data_.route_.enabled_); - counter_data_.increment_route_count(); + LPT_(debug).format("agas::server::route_impl: {}", p.parcel_id()); naming::gid_type const& gid = p.destination(); naming::address& addr = p.addr(); - resolved_type cache_address; + primary_namespace::resolved_type cache_address; // resolve destination addresses, we should be able to resolve all of // them, otherwise it's an error { - std::unique_lock l(mutex_); + std::unique_lock l(server.mutex()); error_code& ec = throws; // wait for any migration to be completed if (naming::detail::is_migratable(gid)) { - wait_for_migration_locked(l, gid, ec); + server.wait_for_migration_locked(l, gid, ec); } - cache_address = resolve_gid_locked(l, gid, ec); + cache_address = server.resolve_gid_locked(l, gid, ec); if (ec || hpx::get<0>(cache_address) == naming::invalid_gid) { @@ -133,6 +130,17 @@ namespace hpx::agas::server { } } } + + /////////////////////////////////////////////////////////////////////////// + struct init_route_function + { + init_route_function() + { + server::route = &route_impl; + } + }; + + init_route_function init; } // namespace hpx::agas::server #endif diff --git a/libs/full/agas_base/CMakeLists.txt b/libs/full/agas_base/CMakeLists.txt index 76288c7dbbb6..8fb09230926a 100644 --- a/libs/full/agas_base/CMakeLists.txt +++ b/libs/full/agas_base/CMakeLists.txt @@ -20,6 +20,7 @@ set(agas_base_headers hpx/agas_base/gva.hpp hpx/agas_base/locality_namespace.hpp hpx/agas_base/primary_namespace.hpp + hpx/agas_base/route.hpp hpx/agas_base/server/component_namespace.hpp hpx/agas_base/server/locality_namespace.hpp hpx/agas_base/server/primary_namespace.hpp diff --git a/libs/full/agas_base/include/hpx/agas_base/route.hpp b/libs/full/agas_base/include/hpx/agas_base/route.hpp new file mode 100644 index 000000000000..ec3b75eb42d6 --- /dev/null +++ b/libs/full/agas_base/include/hpx/agas_base/route.hpp @@ -0,0 +1,21 @@ +// Copyright (c) 2007-2023 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) + +#pragma once + +#include + +#if defined(HPX_HAVE_NETWORKING) +#include +#include + +namespace hpx::agas::server { + + extern HPX_EXPORT void (*route)( + primary_namespace& server, parcelset::parcel&& p); +} // namespace hpx::agas::server + +#endif 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 0c39dc21db0b..8d0489e131a2 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 @@ -126,6 +126,11 @@ namespace hpx::agas::server { using resolved_type = hpx::tuple; + mutex_type& mutex() + { + return mutex_; + } + private: // REVIEW: Separate mutexes might reduce contention here. This has to be // investigated carefully. @@ -241,6 +246,7 @@ namespace hpx::agas::server { char const* func_name); #endif + public: // helper function void wait_for_migration_locked(std::unique_lock& l, naming::gid_type const& id, error_code& ec); @@ -295,10 +301,10 @@ namespace hpx::agas::server { std::pair allocate( std::uint64_t count); - private: resolved_type resolve_gid_locked(std::unique_lock& l, naming::gid_type const& gid, error_code& ec); + private: resolved_type resolve_gid_locked_non_local( std::unique_lock& l, naming::gid_type const& gid, error_code& ec); 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 f91819e3917e..a0a56c2f2e39 100644 --- a/libs/full/agas_base/src/server/primary_namespace_server.cpp +++ b/libs/full/agas_base/src/server/primary_namespace_server.cpp @@ -7,6 +7,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include #include @@ -1119,6 +1120,19 @@ namespace hpx::agas::server { return resolved_type(naming::invalid_gid, gva(), naming::invalid_gid); } +#if defined(HPX_HAVE_NETWORKING) + void (*route)(primary_namespace& server, parcelset::parcel&& p) = nullptr; + + void primary_namespace::route(parcelset::parcel&& p) + { + util::scoped_timer> update( + counter_data_.route_.time_, counter_data_.route_.enabled_); + counter_data_.increment_route_count(); + + (*server::route)(*this, HPX_MOVE(p)); + } +#endif + // access current counter values std::int64_t primary_namespace::counter_data::get_bind_gid_count(bool reset) { diff --git a/libs/full/init_runtime/CMakeLists.txt b/libs/full/init_runtime/CMakeLists.txt index 7b3edd57771c..71307fbbc85f 100644 --- a/libs/full/init_runtime/CMakeLists.txt +++ b/libs/full/init_runtime/CMakeLists.txt @@ -31,8 +31,8 @@ if(HPX_WITH_DISTRIBUTED_RUNTIME) set(init_runtime_sources ${init_runtime_sources} pre_main.cpp) set(init_runtime_optional_module_dependencies - hpx_async_distributed hpx_collectives hpx_naming hpx_performance_counters - hpx_runtime_distributed + hpx_async_distributed hpx_collectives hpx_naming hpx_parcelports + hpx_performance_counters hpx_runtime_distributed ) endif() diff --git a/libs/full/init_runtime/src/hpx_init.cpp b/libs/full/init_runtime/src/hpx_init.cpp index e4c88961c70a..cb0fc1eab038 100644 --- a/libs/full/init_runtime/src/hpx_init.cpp +++ b/libs/full/init_runtime/src/hpx_init.cpp @@ -67,6 +67,7 @@ #include #include #if defined(HPX_HAVE_NETWORKING) +#include #include #include #endif @@ -124,6 +125,10 @@ namespace hpx::detail { // application apex::version(); #endif +#endif +#if defined(HPX_HAVE_NETWORKING) + // force linking parcelports + hpx::parcelset::init_all_parcelports(); #endif util::set_hpx_prefix(hpx_prefix); #if defined(__FreeBSD__) @@ -163,6 +168,10 @@ namespace hpx::detail { // application apex::version(); #endif +#endif +#if defined(HPX_HAVE_NETWORKING) + // force linking parcelports + hpx::parcelset::init_all_parcelports(); #endif util::set_hpx_prefix(hpx_prefix); #if defined(__FreeBSD__) diff --git a/libs/full/modules.rst b/libs/full/modules.rst index 7d41a956c030..0f025215b8a5 100644 --- a/libs/full/modules.rst +++ b/libs/full/modules.rst @@ -14,20 +14,36 @@ Main |hpx| modules .. toctree:: :maxdepth: 2 + /libs/full/actions/docs/index.rst + /libs/full/actions_base/docs/index.rst + /libs/full/agas/docs/index.rst /libs/full/agas_base/docs/index.rst + /libs/full/async_colocated/docs/index.rst /libs/full/async_distributed/docs/index.rst /libs/full/checkpoint/docs/index.rst /libs/full/checkpoint_base/docs/index.rst /libs/full/collectives/docs/index.rst /libs/full/command_line_handling/docs/index.rst + /libs/full/components/docs/index.rst + /libs/full/components_base/docs/index.rst /libs/full/compute/docs/index.rst + /libs/full/distribution_policies/docs/index.rst /libs/full/executors_distributed/docs/index.rst /libs/full/include/docs/index.rst - /libs/full/lci_base/docs/index.rst + /libs/full/init_runtime/docs/index.rst /libs/full/lcos_distributed/docs/index.rst + /libs/full/naming/docs/index.rst /libs/full/naming_base/docs/index.rst + /libs/full/parcelport_lci/docs/index.rst + /libs/full/parcelport_libfabric/docs/index.rst + /libs/full/parcelport_mpi/docs/index.rst + /libs/full/parcelport_tcp/docs/index.rst + /libs/full/parcelset/docs/index.rst + /libs/full/parcelset_base/docs/index.rst /libs/full/performance_counters/docs/index.rst + /libs/full/plugin_factories/docs/index.rst /libs/full/resiliency_distributed/docs/index.rst + /libs/full/runtime_components/docs/index.rst + /libs/full/runtime_distributed/docs/index.rst /libs/full/segmented_algorithms/docs/index.rst /libs/full/statistics/docs/index.rst - /libs/full/version/docs/index.rst diff --git a/libs/full/naming/include/hpx/naming/credit_handling.hpp b/libs/full/naming/include/hpx/naming/credit_handling.hpp index 45750c60b92b..b083861e9ad4 100644 --- a/libs/full/naming/include/hpx/naming/credit_handling.hpp +++ b/libs/full/naming/include/hpx/naming/credit_handling.hpp @@ -39,7 +39,8 @@ namespace hpx::naming { gid_type& id, std::int64_t debit); HPX_EXPORT std::int64_t fill_credit_for_gid(gid_type& id, - std::int64_t credits = std::int64_t(HPX_GLOBALCREDIT_INITIAL)); + std::int64_t credits = static_cast( + HPX_GLOBALCREDIT_INITIAL)); /////////////////////////////////////////////////////////////////////// HPX_EXPORT gid_type move_gid(gid_type& id); @@ -58,7 +59,7 @@ namespace hpx::naming { std::unique_lock& l, gid_type& id); /////////////////////////////////////////////////////////////////////// - HPX_EXPORT void decrement_refcnt(id_type_impl* gid) noexcept; + HPX_EXPORT void decrement_refcnt(id_type_impl const* gid) noexcept; /////////////////////////////////////////////////////////////////////// // credit management (called during serialization), this function diff --git a/libs/full/naming/src/credit_handling.cpp b/libs/full/naming/src/credit_handling.cpp index cceb6175de92..230faac199e8 100644 --- a/libs/full/naming/src/credit_handling.cpp +++ b/libs/full/naming/src/credit_handling.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2022 Hartmut Kaiser +// Copyright (c) 2007-2023 Hartmut Kaiser // Copyright (c) 2011 Bryce Lelbach // // SPDX-License-Identifier: BSL-1.0 @@ -114,7 +114,7 @@ namespace hpx::naming { /////////////////////////////////////////////////////////////////////////// namespace detail { - void decrement_refcnt(id_type_impl* p) noexcept + void decrement_refcnt(id_type_impl const* p) noexcept { // do nothing if it's too late in the game if (!get_runtime_ptr()) @@ -136,7 +136,7 @@ namespace hpx::naming { if (gid_was_split(*p) || !agas::resolve_cached(*p, addr)) { // decrement global reference count for the given gid, - std::int64_t credits = detail::get_credit_from_gid(*p); + std::int64_t const credits = get_credit_from_gid(*p); HPX_ASSERT(0 != credits); if (get_runtime_ptr()) // -V547 @@ -206,13 +206,13 @@ namespace hpx::naming { // Get the current credit for our gid. If no other concurrent // split has happened since we invoked incref below, the credit // of this gid is equal to 2, otherwise it is larger. - std::int64_t src_credit = get_credit_from_gid(gid); + std::int64_t const src_credit = get_credit_from_gid(gid); HPX_ASSERT(src_credit >= 2); - std::int64_t split_credit = + constexpr std::int64_t split_credit = static_cast(HPX_GLOBALCREDIT_INITIAL) - 2; std::int64_t new_credit = src_credit + split_credit; - std::int64_t overflow_credit = new_credit - + std::int64_t const overflow_credit = new_credit - static_cast(HPX_GLOBALCREDIT_INITIAL); HPX_ASSERT(overflow_credit >= 0); @@ -258,7 +258,8 @@ namespace hpx::naming { // credit is guaranteed to arrive only after we incremented the // credit successfully in agas. HPX_ASSERT(get_log2credit_from_gid(gid) > 0); - std::int16_t src_log2credits = get_log2credit_from_gid(gid); + std::int16_t const src_log2credits = + get_log2credit_from_gid(gid); // Credit exhaustion - we need to get more. if (src_log2credits == 1) @@ -279,11 +280,11 @@ namespace hpx::naming { // We add HPX_GLOBALCREDIT_INITIAL credits for the new gid // and HPX_GLOBALCREDIT_INITIAL - 2 for the old one. - std::int64_t new_credit = 2 * + constexpr std::int64_t new_credit = 2 * (static_cast(HPX_GLOBALCREDIT_INITIAL) - 1); - naming::gid_type new_gid = gid; // strips lock-bit + naming::gid_type const new_gid = gid; // strips lock-bit HPX_ASSERT(new_gid != invalid_gid); return agas::incref(new_gid, new_credit) .then(hpx::launch::sync, @@ -338,7 +339,7 @@ namespace hpx::naming { { HPX_ASSERT_OWNS_LOCK(l); - std::uint16_t log2credits = get_log2credit_from_gid(id); + std::int16_t const log2credits = get_log2credit_from_gid(id); HPX_ASSERT(log2credits > 0); gid_type newid = id; // strips lock-bit @@ -362,21 +363,19 @@ namespace hpx::naming { std::int64_t replenish_credits_locked( std::unique_lock& l, gid_type& gid) { - std::int64_t added_credit = 0; - HPX_ASSERT(0 == get_credit_from_gid(gid)); - added_credit = naming::detail::fill_credit_for_gid(gid); + std::int64_t const added_credit = + naming::detail::fill_credit_for_gid(gid); naming::detail::set_credit_split_mask_for_gid(gid); - gid_type unlocked_gid = gid; // strips lock-bit + gid_type const unlocked_gid = gid; // strips lock-bit - std::int64_t result = 0; + std::int64_t result; { hpx::unlock_guard> ul(l); result = agas::incref(launch::sync, unlocked_gid, added_credit); } - return result; } @@ -403,10 +402,10 @@ namespace hpx::naming { std::int64_t fill_credit_for_gid(gid_type& id, std::int64_t credits) { - std::int64_t c = get_credit_from_gid(id); + std::int64_t const c = get_credit_from_gid(id); HPX_ASSERT(c <= credits); - std::int64_t added = credits - c; + std::int64_t const added = credits - c; set_credit_for_gid(id, credits); return added; @@ -419,7 +418,7 @@ namespace hpx::naming { HPX_ASSERT(detail::gid_was_split(gid)); // decrement global reference count for the given gid, - std::int64_t credits = detail::get_credit_from_gid(gid); + std::int64_t const credits = detail::get_credit_from_gid(gid); HPX_ASSERT(0 != credits); // Fire-and-forget semantics. @@ -432,7 +431,7 @@ namespace hpx::naming { // custom deleter for managed gid_types, will be called when the last // copy of the corresponding hpx::id_type goes out of scope - void gid_managed_deleter(id_type_impl* p) noexcept + void gid_managed_deleter_impl(id_type_impl const* p) noexcept { // a credit of zero means the component is not (globally) reference // counted @@ -450,11 +449,23 @@ namespace hpx::naming { // custom deleter for unmanaged gid_types, will be called when the last // copy of the corresponding hpx::id_type goes out of scope - void gid_unmanaged_deleter(id_type_impl* p) noexcept + void gid_unmanaged_deleter_impl(id_type_impl const* p) noexcept { delete p; // delete local gid representation only } + // break cyclic dependency with naming_base + struct init_deleter_functions + { + init_deleter_functions() + { + gid_managed_deleter = &gid_managed_deleter_impl; + gid_unmanaged_deleter = &gid_unmanaged_deleter_impl; + } + }; + + init_deleter_functions init; + /////////////////////////////////////////////////////////////////////// // prepare the given id, note: this function modifies the passed id void handle_credit_splitting(serialization::output_archive& ar, @@ -551,7 +562,8 @@ namespace hpx::naming { { preprocess_gid(id_impl, ar); - gid_serialization_data data{id_impl, type}; + gid_serialization_data const data{ + static_cast(id_impl), type}; ar << data; return; } @@ -569,7 +581,7 @@ namespace hpx::naming { gid_type new_gid; if (hpx::id_type::management_type::unmanaged == type) { - new_gid = id_impl; + new_gid = static_cast(id_impl); } else if (hpx::id_type::management_type::managed_move_credit == type) { @@ -587,12 +599,12 @@ namespace hpx::naming { } #if defined(HPX_DEBUG) - auto* split_gids = ar.try_get_extra_data< + auto const* split_gids = ar.try_get_extra_data< serialization::detail::preprocess_gid_types>(); HPX_ASSERT(!split_gids || !split_gids->has_gid(id_impl)); #endif - gid_serialization_data data{new_gid, type}; + gid_serialization_data const data{new_gid, type}; ar << data; } diff --git a/libs/full/naming_base/include/hpx/naming_base/id_type.hpp b/libs/full/naming_base/include/hpx/naming_base/id_type.hpp index 08d956b5d087..cfeef69c6d83 100644 --- a/libs/full/naming_base/include/hpx/naming_base/id_type.hpp +++ b/libs/full/naming_base/include/hpx/naming_base/id_type.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2022 Hartmut Kaiser +// Copyright (c) 2007-2023 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -32,8 +32,10 @@ namespace hpx { HPX_EXPORT void intrusive_ptr_add_ref(id_type_impl* p) noexcept; HPX_EXPORT void intrusive_ptr_release(id_type_impl* p) noexcept; - HPX_EXPORT void gid_managed_deleter(id_type_impl* p) noexcept; - HPX_EXPORT void gid_unmanaged_deleter(id_type_impl* p) noexcept; + extern HPX_EXPORT void (*gid_managed_deleter)( + id_type_impl const* p) noexcept; + extern HPX_EXPORT void (*gid_unmanaged_deleter)( + id_type_impl const* p) noexcept; } // namespace naming::detail /////////////////////////////////////////////////////////////////////////// @@ -96,6 +98,8 @@ namespace hpx { id_type& operator=(id_type const& o) = default; id_type& operator=(id_type&& o) noexcept = default; + ~id_type() = default; + naming::gid_type& get_gid(); naming::gid_type const& get_gid() const; @@ -104,7 +108,7 @@ namespace hpx { management_type get_management_type() const noexcept; id_type& operator++(); - id_type operator++(int); + id_type operator++(int) const; explicit operator bool() const noexcept; @@ -121,11 +125,11 @@ namespace hpx { // access the internal parts of the gid std::uint64_t get_msb() const; - void set_msb(std::uint64_t msb); + void set_msb(std::uint64_t msb) const; std::uint64_t get_lsb() const; - void set_lsb(std::uint64_t lsb); - void set_lsb(void* lsb); + void set_lsb(std::uint64_t lsb) const; + void set_lsb(void* lsb) const; // Convert this id into an unmanaged one (in-place) - Use with maximum // care, or better, don't use this at all. @@ -164,14 +168,14 @@ namespace hpx { inline id_type get_id_from_locality_id( std::uint32_t locality_id) noexcept { - return id_type((std::uint64_t(locality_id) + 1) + return {(static_cast(locality_id) + 1) << naming::gid_type::locality_id_shift, - 0, id_type::management_type::unmanaged); + 0, id_type::management_type::unmanaged}; } inline std::uint32_t get_locality_id_from_id(id_type const& id) noexcept { - return std::uint32_t( + return static_cast( id.get_msb() >> naming::gid_type::locality_id_shift) - 1; } @@ -200,10 +204,13 @@ namespace hpx { struct id_type_impl : gid_type { public: - HPX_NON_COPYABLE(id_type_impl); + id_type_impl(id_type_impl const&) = delete; + id_type_impl(id_type_impl&&) = delete; + id_type_impl& operator=(id_type_impl const&) = delete; + id_type_impl& operator=(id_type_impl&&) = delete; private: - using deleter_type = void (*)(detail::id_type_impl*) noexcept; + using deleter_type = void (*)(detail::id_type_impl const*) noexcept; static deleter_type get_deleter( id_type::management_type t) noexcept; @@ -245,6 +252,8 @@ namespace hpx { { } + ~id_type_impl() = default; + constexpr id_type::management_type get_management_type() const noexcept { @@ -282,12 +291,6 @@ namespace hpx { } private: - // custom deleter for id_type_impl - friend HPX_EXPORT void gid_managed_deleter( - id_type_impl* p) noexcept; - friend HPX_EXPORT void gid_unmanaged_deleter( - id_type_impl* p) noexcept; - // reference counting friend HPX_EXPORT void intrusive_ptr_add_ref( id_type_impl* p) noexcept; @@ -389,7 +392,7 @@ namespace hpx { { return gid_->get_msb(); } - inline void id_type::set_msb(std::uint64_t msb) + inline void id_type::set_msb(std::uint64_t msb) const { gid_->set_msb(msb); } @@ -398,11 +401,11 @@ namespace hpx { { return gid_->get_lsb(); } - inline void id_type::set_lsb(std::uint64_t lsb) + inline void id_type::set_lsb(std::uint64_t lsb) const { gid_->set_lsb(lsb); } - inline void id_type::set_lsb(void* lsb) + inline void id_type::set_lsb(void* lsb) const { gid_->set_lsb(lsb); } diff --git a/libs/full/naming_base/src/id_type.cpp b/libs/full/naming_base/src/id_type.cpp index fa270c9428f8..94ef2ff94fa3 100644 --- a/libs/full/naming_base/src/id_type.cpp +++ b/libs/full/naming_base/src/id_type.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2022 Hartmut Kaiser +// Copyright (c) 2007-2023 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -18,6 +18,9 @@ namespace hpx { /////////////////////////////////////////////////////////////////////////// namespace naming::detail { + void (*gid_managed_deleter)(id_type_impl const* p) noexcept = nullptr; + void (*gid_unmanaged_deleter)(id_type_impl const* p) noexcept = nullptr; + util::internal_allocator id_type_impl::alloc_; id_type_impl::deleter_type id_type_impl::get_deleter( @@ -26,18 +29,18 @@ namespace hpx { switch (t) { case hpx::id_type::management_type::unmanaged: - return &detail::gid_unmanaged_deleter; + return gid_unmanaged_deleter; case hpx::id_type::management_type::managed: [[fallthrough]]; case hpx::id_type::management_type::managed_move_credit: - return &detail::gid_managed_deleter; + return gid_managed_deleter; default: HPX_ASSERT(false); // invalid management type - return &detail::gid_unmanaged_deleter; + break; } - return nullptr; + return gid_unmanaged_deleter; } // support functions for hpx::intrusive_ptr @@ -62,9 +65,10 @@ namespace hpx { return *this; } - id_type id_type::operator++(int) // post-increment + id_type id_type::operator++(int) const + // post-increment { - return id_type((*gid_)++, management_type::unmanaged); + return {(*gid_)++, management_type::unmanaged}; } // comparison is required as well @@ -138,10 +142,10 @@ namespace hpx::traits { hpx::id_type get_remote_result::call( naming::gid_type const& rhs) { - bool has_credits = naming::detail::has_credits(rhs); - return hpx::id_type(rhs, + bool const has_credits = naming::detail::has_credits(rhs); + return {rhs, has_credits ? hpx::id_type::management_type::managed : - hpx::id_type::management_type::unmanaged); + hpx::id_type::management_type::unmanaged}; } // we need to specialize this template to allow for automatic conversion of @@ -154,7 +158,7 @@ namespace hpx::traits { result.reserve(rhs.size()); for (naming::gid_type const& r : rhs) { - bool has_credits = naming::detail::has_credits(r); + bool const has_credits = naming::detail::has_credits(r); result.emplace_back(r, has_credits ? hpx::id_type::management_type::managed : hpx::id_type::management_type::unmanaged); diff --git a/libs/full/parcelports/CMakeLists.txt b/libs/full/parcelports/CMakeLists.txt new file mode 100644 index 000000000000..c775de66a0af --- /dev/null +++ b/libs/full/parcelports/CMakeLists.txt @@ -0,0 +1,58 @@ +# Copyright (c) 2019-2023 The STE||AR-Group +# +# 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) + +if(NOT HPX_WITH_DISTRIBUTED_RUNTIME) + return() +endif() + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + +set(parcelports_headers hpx/parcelports/init_all_parcelports.hpp) + +set(parcelports_sources static_parcelports.cpp) + +set(parcelports_generated_headers hpx/parcelports/static_parcelports.hpp) + +set(parcelport_module_dependencies) +set(parcelport_export_declarations) +set(parcelport_init_definitions) + +foreach(parcelport ${HPX_STATIC_PARCELPORT_PLUGINS}) + set(parcelport_module_dependencies ${parcelport_module_dependencies} + hpx_${parcelport} + ) + + # generate header defining initialization functions for parcelports + set(parcelport_export_declarations + "${parcelport_export_declarations}HPX_EXPORT hpx::plugins::parcelport_factory_base *\n" + ) + set(parcelport_export_declarations + "${parcelport_export_declarations} ${parcelport}_factory_init(\n" + ) + set(parcelport_export_declarations + "${parcelport_export_declarations} std::vector& factories);\n" + ) + set(parcelport_init_definitions + "${parcelport_init_definitions} ${parcelport}_factory_init(factories);\n" + ) +endforeach() + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/static_parcelports.hpp.in" + "${CMAKE_CURRENT_BINARY_DIR}/include/hpx/parcelports/static_parcelports.hpp" + @ONLY +) + +include(HPX_AddModule) +add_hpx_module( + full parcelports + GLOBAL_HEADER_GEN OFF + GENERATED_HEADERS ${parcelports_generated_headers} + SOURCES ${parcelports_sources} + HEADERS ${parcelports_headers} + DEPENDENCIES hpx_core + MODULE_DEPENDENCIES hpx_parcelset ${parcelport_module_dependencies} +) diff --git a/cmake/templates/static_parcelports.hpp.in b/libs/full/parcelports/cmake/templates/static_parcelports.hpp.in similarity index 62% rename from cmake/templates/static_parcelports.hpp.in rename to libs/full/parcelports/cmake/templates/static_parcelports.hpp.in index 4f068f446455..92c74024334b 100644 --- a/cmake/templates/static_parcelports.hpp.in +++ b/libs/full/parcelports/cmake/templates/static_parcelports.hpp.in @@ -1,5 +1,5 @@ // Copyright (c) 2012-2015 Thomas Heller -// Copyright (c) 2007-2021 Hartmut Kaiser +// Copyright (c) 2007-2023 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -9,16 +9,23 @@ #pragma once -#include +#include + +#if defined(HPX_HAVE_NETWORKING) #include #include -@_parcelport_export@ +@parcelport_export_declarations@ namespace hpx::parcelset { - void init_static_parcelport_factories( + // force linking with this module + HPX_EXPORT void init_parcel_ports(); + + inline void init_static_parcelport_factories_impl( std::vector& factories) { -@_parcelport_init@ } +@parcelport_init_definitions@ } } + +#endif diff --git a/libs/full/parcelports/include/hpx/parcelports/init_all_parcelports.hpp b/libs/full/parcelports/include/hpx/parcelports/init_all_parcelports.hpp new file mode 100644 index 000000000000..2c4c2eb190db --- /dev/null +++ b/libs/full/parcelports/include/hpx/parcelports/init_all_parcelports.hpp @@ -0,0 +1,19 @@ +// Copyright (c) 2023 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) + +#pragma once + +#include + +#if defined(HPX_HAVE_NETWORKING) + +namespace hpx::parcelset { + + // force linking with this module + HPX_EXPORT void init_all_parcelports(); +} // namespace hpx::parcelset + +#endif diff --git a/libs/full/parcelports/src/static_parcelports.cpp b/libs/full/parcelports/src/static_parcelports.cpp new file mode 100644 index 000000000000..7258b6171cd9 --- /dev/null +++ b/libs/full/parcelports/src/static_parcelports.cpp @@ -0,0 +1,35 @@ +// Copyright (c) 2023 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_HAVE_NETWORKING) +#include +#include +#include +#include + +#include + +namespace hpx::parcelset { + + void (*init_static_parcelport_factories)( + std::vector& factories) = nullptr; + + struct HPX_EXPORT init_parcelports + { + init_parcelports() + { + init_static_parcelport_factories = + init_static_parcelport_factories_impl; + } + } init; + + // force linking with this module + void init_all_parcelports() {} +} // namespace hpx::parcelset + +#endif diff --git a/libs/full/parcelset/CMakeLists.txt b/libs/full/parcelset/CMakeLists.txt index 3b331756c5a8..cc49c3f793aa 100644 --- a/libs/full/parcelset/CMakeLists.txt +++ b/libs/full/parcelset/CMakeLists.txt @@ -14,6 +14,7 @@ set(parcelset_headers hpx/parcelset/detail/parcel_await.hpp hpx/parcelset/detail/message_handler_interface_functions.hpp hpx/parcelset/encode_parcels.hpp + hpx/parcelset/init_parcelports.hpp hpx/parcelset/message_handler_fwd.hpp hpx/parcelset/parcel.hpp hpx/parcelset/parcelhandler.hpp diff --git a/libs/full/parcelset/include/hpx/parcelset/init_parcelports.hpp b/libs/full/parcelset/include/hpx/parcelset/init_parcelports.hpp new file mode 100644 index 000000000000..02420f7fe211 --- /dev/null +++ b/libs/full/parcelset/include/hpx/parcelset/init_parcelports.hpp @@ -0,0 +1,22 @@ +// Copyright (c) 2023 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) + +#pragma once + +#include + +#if defined(HPX_HAVE_NETWORKING) +#include + +#include + +namespace hpx::parcelset { + + extern HPX_EXPORT void (*init_static_parcelport_factories)( + std::vector& factories); +} + +#endif diff --git a/libs/full/parcelset/src/parcelhandler.cpp b/libs/full/parcelset/src/parcelhandler.cpp index 8e073b362af6..216bca8e52c4 100644 --- a/libs/full/parcelset/src/parcelhandler.cpp +++ b/libs/full/parcelset/src/parcelhandler.cpp @@ -33,9 +33,9 @@ #include #include +#include #include #include -#include #include #include #include diff --git a/libs/full/plugin_factories/include/hpx/plugin_factories/parcelport_factory.hpp b/libs/full/plugin_factories/include/hpx/plugin_factories/parcelport_factory.hpp index 763aab44c689..3e9922a46a2d 100644 --- a/libs/full/plugin_factories/include/hpx/plugin_factories/parcelport_factory.hpp +++ b/libs/full/plugin_factories/include/hpx/plugin_factories/parcelport_factory.hpp @@ -1,5 +1,5 @@ // Copyright (c) 2014 Thomas Heller -// Copyright (c) 2007-2022 Hartmut Kaiser +// Copyright (c) 2007-2023 Hartmut Kaiser // Copyright (c) 2020 Google // // SPDX-License-Identifier: BSL-1.0