Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Making sure resolve_localities does not hang during normal operation.
- This fixes #1804: register_with_basename causes hangs
- Loading branch information
Showing
5 changed files
with
140 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// Copyright (c) 2015 Andreas Schaefer | ||
// | ||
// 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) | ||
|
||
// This illustrates the issue as reported by #1804: register_with_basename | ||
// causes hangs | ||
|
||
#include <hpx/hpx.hpp> | ||
#include <hpx/hpx_init.hpp> | ||
|
||
#include <iostream> | ||
#include <vector> | ||
|
||
#include <boost/shared_ptr.hpp> | ||
|
||
static std::string itoa(int i) | ||
{ | ||
std::stringstream buf; | ||
buf << i; | ||
return buf.str(); | ||
} | ||
|
||
struct test_server | ||
: hpx::components::simple_component_base<test_server> | ||
{ | ||
test_server() | ||
{} | ||
|
||
hpx::id_type call() const | ||
{ | ||
return hpx::find_here(); | ||
} | ||
HPX_DEFINE_COMPONENT_ACTION(test_server, call, call_action); | ||
}; | ||
|
||
typedef hpx::components::simple_component<test_server> server_type; | ||
HPX_REGISTER_COMPONENT(server_type, test_server); | ||
|
||
typedef test_server::call_action call_action; | ||
HPX_REGISTER_ACTION(call_action); | ||
|
||
std::string genName(int source, int target) | ||
{ | ||
std::string basename = "/0/HPXSimulatorUpdateGroupSdfafafasdasd"; | ||
|
||
return basename + "/PatchLink/" + | ||
itoa(source) + "-" + | ||
itoa(target); | ||
} | ||
|
||
void testBar() | ||
{ | ||
int rank = hpx::get_locality_id(); | ||
|
||
std::vector<hpx::id_type> boundingBoxReceivers; | ||
std::vector<hpx::id_type> boundingBoxAccepters; | ||
for (int i = 0; i < 4; ++i) { | ||
if (i == rank) | ||
continue; | ||
|
||
std::string name = genName(i, rank); | ||
std::cout << "registration: " << name << "\n"; | ||
|
||
hpx::id_type id = hpx::new_<test_server>(hpx::find_here()).get(); | ||
hpx::register_with_basename(name, id, 0).get(); | ||
boundingBoxReceivers.push_back(id); | ||
} | ||
|
||
for (int i = 0; i < 4; ++i) { | ||
if (i == rank) | ||
continue; | ||
|
||
std::string name = genName(rank, i); | ||
std::cout << "lookup: " << name << "\n"; | ||
std::vector<hpx::future<hpx::id_type> > ids = | ||
hpx::find_all_from_basename(name, 1); | ||
boundingBoxAccepters.push_back(std::move(ids[0].get())); | ||
} | ||
|
||
std::cout << "all done " << rank << "\n"; | ||
} | ||
|
||
int hpx_main(int argc, char **argv) | ||
{ | ||
testBar(); | ||
return hpx::finalize(); | ||
} | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
// We want HPX to run hpx_main() on all localities to avoid the | ||
// initial overhead caused by broadcasting the work from one to | ||
// all other localities: | ||
std::vector<std::string> config(1, "hpx.run_hpx_main!=1"); | ||
|
||
return hpx::init(argc, argv, config); | ||
} |