collectives all gather hangs if rank 0 is not involved #5913
John98Zakaria
started this conversation in
General
Replies: 2 comments
-
Would it work if you rewrote this example as: #include <hpx/iostream.hpp>
#include <hpx/barrier.hpp>
#include <hpx/modules/collectives.hpp>
void func()
{
const auto my_rank = hpx::get_locality_id();
hpx::collectives::communicator communicator;
if (my_rank == 2){
// note: the communicator is 'created' if root_site == this_site
communicator = hpx::collectives::create_communicator(
"comm2",
hpx::collectives::num_sites_arg(2),
hpx::collectives::this_site_arg(0),
hpx::collectives::generation_arg(0),
hpx::collectives::root_site_arg(0));
hpx::cout<<"Comm on 2 was registered \n" << hpx::flush;
}
if (my_rank == 3){
// note: the communicator is 'connected' if root_site != this_site
communicator = hpx::collectives::create_communicator(
"comm2",
hpx::collectives::num_sites_arg(2),
hpx::collectives::this_site_arg(1),
hpx::collectives::generation_arg(0),
hpx::collectives::root_site_arg(0));
hpx::cout << "Rank3 connected \n" << hpx::flush;
}
if (my_rank == 2 || my_rank == 3) {
int value = my_rank;
auto res = hpx::collectives::all_gather(communicator, my_rank - 2, value);
auto gathered_value = res.get(); // should receive a vector<int>{2, 3};
hpx::cout << "Rank " << my_rank << "received its data \n" <<hpx::flush;
}
} Also, please never directly |
Beta Was this translation helpful? Give feedback.
0 replies
-
Worked perfectly For future readers : #include <hpx/iostream.hpp>
#include <hpx/hpx_main.hpp>
#include <hpx/modules/collectives.hpp>
#include <hpx/future.hpp>
void func()
{
const auto my_rank = hpx::get_locality_id();
hpx::collectives::communicator communicator;
if (my_rank == 2){
// note: the communicator is 'created' if root_site == this_site
communicator = hpx::collectives::create_communicator(
"comm2",
hpx::collectives::num_sites_arg(2),
hpx::collectives::this_site_arg(0),
hpx::collectives::generation_arg(0),
hpx::collectives::root_site_arg(0));
hpx::cout<<"Comm on 2 was registered \n" << hpx::flush;
}
if (my_rank == 3){
// note: the communicator is 'connected' if root_site != this_site
communicator = hpx::collectives::create_communicator(
"comm2",
hpx::collectives::num_sites_arg(2),
hpx::collectives::this_site_arg(1),
hpx::collectives::generation_arg(0),
hpx::collectives::root_site_arg(0));
hpx::cout << "Rank3 connected \n" << hpx::flush;
}
if (my_rank == 2 || my_rank == 3) {
int value = my_rank;
auto res = hpx::collectives::all_gather(communicator,value,hpx::collectives::this_site_arg(my_rank - 2));
auto gathered_value = res.get(); // should receive a vector<int>{2, 3};
hpx::cout << "Rank " << my_rank << "received its data \n" <<hpx::flush;
}
}
HPX_PLAIN_ACTION(func,func_action);
int main(int argc, char* argv[]){
auto localities = hpx::find_all_localities();
func_action act;
std::vector<hpx::future<void>> data;
for (const auto &locality: localities) {
data.emplace_back(hpx::async(act,locality));
}
hpx::wait_all(data);
hpx::cout << "DONE";
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Expected Behavior
When creating a communicator that doesn't communicate with all ranks.
I expect the communicator to be able to send data to anyone with the number of,hpx::collectives::num_sites_arg(2)
Actual Behavior
Only 2 ranks are able to communicate, in which one of them is rank 0.
Steps to Reproduce the Problem
... Please be as specific as possible while describing how to reproduce your problem.
Specifications
... Please describe your environment
Beta Was this translation helpful? Give feedback.
All reactions