From ae3c9d35e66ac17c72c4cea93492222c8fe67000 Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Tue, 14 Nov 2023 10:25:30 -0600 Subject: [PATCH 1/2] Disable resolving hostnames if TCP is disabled --- .../batch_environments/batch_environment.hpp | 17 +++--- .../src/batch_environment.cpp | 53 +++++++++++++------ .../src/command_line_handling.cpp | 8 +-- 3 files changed, 51 insertions(+), 27 deletions(-) diff --git a/libs/core/batch_environments/include/hpx/batch_environments/batch_environment.hpp b/libs/core/batch_environments/include/hpx/batch_environments/batch_environment.hpp index 7300681daa14..f2ad0509594f 100644 --- a/libs/core/batch_environments/include/hpx/batch_environments/batch_environment.hpp +++ b/libs/core/batch_environments/include/hpx/batch_environments/batch_environment.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 @@ -31,13 +31,13 @@ namespace hpx::util { { // the constructor tries to read initial values from a batch // environment, filling our map of nodes and thread counts - batch_environment(std::vector& nodelist, + explicit batch_environment(std::vector& nodelist, bool have_mpi = false, bool debug = false, bool enable = true); // this function initializes the map of nodes from the given (space // separated) list of nodes std::string init_from_nodelist(std::vector const& nodes, - std::string const& agas_host); + std::string const& agas_host, bool have_tcp); // The number of threads is either one (if no PBS information was // found), or it is the same as the number of times this node has been @@ -71,17 +71,20 @@ namespace hpx::util { // Return a string containing the name of the batch system std::string get_batch_name() const; - using node_map_type = std::map>; - std::string agas_node_; std::size_t agas_node_num_; std::size_t node_num_; std::size_t num_threads_; - node_map_type nodes_; std::size_t num_localities_; std::string batch_name_; bool debug_; + +#if defined(HPX_HAVE_PARCELPORT_TCP) + using node_map_type = std::map>; + + node_map_type nodes_; +#endif }; } // namespace hpx::util diff --git a/libs/core/batch_environments/src/batch_environment.cpp b/libs/core/batch_environments/src/batch_environment.cpp index 51d338269f6b..49d008aaa973 100644 --- a/libs/core/batch_environments/src/batch_environment.cpp +++ b/libs/core/batch_environments/src/batch_environment.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2022 Hartmut Kaiser +// Copyright (c) 2007-2023 Hartmut Kaiser // Copyright (c) 2013 Thomas Heller // // SPDX-License-Identifier: BSL-1.0 @@ -120,7 +120,8 @@ namespace hpx::util { // this function initializes the map of nodes from the given a list of nodes std::string batch_environment::init_from_nodelist( - std::vector const& nodes, std::string const& agas_host) + std::vector const& nodes, std::string const& agas_host, + bool have_tcp) { if (debug_) std::cerr << "got node list" << std::endl; @@ -139,29 +140,41 @@ namespace hpx::util { if (debug_) std::cerr << "extracted: '" << s << "'" << std::endl; - asio::ip::tcp::endpoint ep = - util::resolve_hostname(s, 0, io_service); - +#if defined(HPX_HAVE_PARCELPORT_TCP) if (!found_agas_host && ((agas_host.empty() && nodes_.empty()) || s == agas_host)) { - agas_node_ = s; found_agas_host = true; + agas_node_ = s; agas_node_num_ = agas_node_num; } - if (0 == nodes_.count(ep)) + if (have_tcp) { - if (debug_) - std::cerr << "incrementing agas_node_num" << std::endl; - ++agas_node_num; + asio::ip::tcp::endpoint ep = + util::resolve_hostname(s, 0, io_service); + + if (0 == nodes_.count(ep)) + { + if (debug_) + std::cerr << "incrementing agas_node_num" + << std::endl; + ++agas_node_num; + } + + std::pair& data = nodes_[ep]; + if (data.first.empty()) + data.first = s; + ++data.second; } - - std::pair& data = nodes_[ep]; - if (data.first.empty()) - data.first = s; - ++data.second; - +#else + if (!found_agas_host && (agas_host.empty() || s == agas_host)) + { + found_agas_host = true; + agas_node_ = s; + agas_node_num_ = agas_node_num; + } +#endif nodes_list += s + ' '; } } @@ -184,6 +197,7 @@ namespace hpx::util { << std::endl; } +#if defined(HPX_HAVE_PARCELPORT_TCP) std::cerr << "Nodes from nodelist:" << std::endl; node_map_type::const_iterator const end = nodes_.end(); for (node_map_type::const_iterator it = nodes_.begin(); it != end; @@ -192,6 +206,7 @@ namespace hpx::util { std::cerr << (*it).second.first << ": " << (*it).second.second << " (" << (*it).first << ")" << std::endl; } +#endif } HPX_UNUSED(nodes); return nodes_list; @@ -199,7 +214,7 @@ namespace hpx::util { // The number of threads is either one (if no PBS/SLURM information was // found), or it is the same as the number of times this node has been - // listed in the node file. Additionally this takes into account the number + // listed in the node file. Additionally, this takes into account the number // of tasks run on this node. std::size_t batch_environment::retrieve_number_of_threads() const noexcept { @@ -233,7 +248,11 @@ namespace hpx::util { std::string batch_environment::host_name( std::string const& def_hpx_name) const { +#if defined(HPX_HAVE_PARCELPORT_TCP) std::string host = nodes_.empty() ? def_hpx_name : host_name(); +#else + std::string host = host_name(); +#endif if (debug_) std::cerr << "host_name: " << host << std::endl; return host; diff --git a/libs/full/command_line_handling/src/command_line_handling.cpp b/libs/full/command_line_handling/src/command_line_handling.cpp index 34437c3e8534..70beb1cbf444 100644 --- a/libs/full/command_line_handling/src/command_line_handling.cpp +++ b/libs/full/command_line_handling/src/command_line_handling.cpp @@ -493,8 +493,10 @@ namespace hpx::util { if (!nodelist.empty()) { using_nodelist = true; - ini_config.emplace_back( - "hpx.nodes!=" + env.init_from_nodelist(nodelist, agas_host)); + bool const have_tcp = + rtcfg_.get_entry("hpx.parcel.tcp.enable", "1") != "0"; + ini_config.emplace_back("hpx.nodes!=" + + env.init_from_nodelist(nodelist, agas_host, have_tcp)); } // let the batch environment decide about the AGAS host @@ -762,7 +764,7 @@ namespace hpx::util { } else if (env.found_batch_environment()) { - // in batch mode, if the network addresses are different and we + // in batch mode, if the network addresses are different, and we // should not run the AGAS server we assume to be in worker mode rtcfg_.mode_ = hpx::runtime_mode::worker; From b9ba56a8fcb99fa9c3e7545ae581de0c3ac7a745 Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Sat, 18 Nov 2023 19:39:19 -0600 Subject: [PATCH 2/2] Disable more IP handling --- .../src/command_line_handling.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libs/full/command_line_handling/src/command_line_handling.cpp b/libs/full/command_line_handling/src/command_line_handling.cpp index 70beb1cbf444..b8b7abbf5743 100644 --- a/libs/full/command_line_handling/src/command_line_handling.cpp +++ b/libs/full/command_line_handling/src/command_line_handling.cpp @@ -383,6 +383,8 @@ namespace hpx::util { node != static_cast(-1) && vm.count("hpx:debug-clp"); // create host name mapping + [[maybe_unused]] bool const have_tcp = + rtcfg_.get_entry("hpx.parcel.tcp.enable", "1") != "0"; util::map_hostnames mapnames(debug_clp); if (vm.count("hpx:ifsuffix")) @@ -493,8 +495,6 @@ namespace hpx::util { if (!nodelist.empty()) { using_nodelist = true; - bool const have_tcp = - rtcfg_.get_entry("hpx.parcel.tcp.enable", "1") != "0"; ini_config.emplace_back("hpx.nodes!=" + env.init_from_nodelist(nodelist, agas_host, have_tcp)); } @@ -505,8 +505,8 @@ namespace hpx::util { #endif bool run_agas_server = false; - std::string hpx_host; - std::uint16_t hpx_port = 0; + [[maybe_unused]] std::string hpx_host; + [[maybe_unused]] std::uint16_t hpx_port = 0; #if defined(HPX_HAVE_NETWORKING) bool expect_connections = false; @@ -726,9 +726,14 @@ namespace hpx::util { // handle high-priority threads handle_high_priority_threads(vm, ini_config); +#if defined(HPX_HAVE_PARCELPORT_TCP) // map host names to ip addresses, if requested - hpx_host = mapnames.map(hpx_host, hpx_port); - agas_host = mapnames.map(agas_host, agas_port); + if (have_tcp) + { + hpx_host = mapnames.map(hpx_host, hpx_port); + agas_host = mapnames.map(agas_host, agas_port); + } +#endif // sanity checks if (rtcfg_.mode_ != hpx::runtime_mode::local && num_localities_ == 1 &&