Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a valid communicator. #13471

Merged
merged 1 commit into from
Mar 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions tests/fullydistributed_grids/repartitioning_05.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ create_sub_comm(const MPI_Comm &comm, const unsigned int size)
{
ierr = MPI_Comm_free(&sub_comm);
AssertThrowMPI(ierr);
return MPI_COMM_NULL;
return MPI_COMM_SELF;
}
}

Expand All @@ -69,9 +69,9 @@ partition_distributed_triangulation(const Triangulation<dim, spacedim> &tria_in,
const auto comm_tria = tria_in.get_communicator();

const auto n_global_active_cells = Utilities::MPI::max(
comm_tria == MPI_COMM_NULL ? 0 : tria_in.n_global_active_cells(), comm);
comm_tria == MPI_COMM_SELF ? 0 : tria_in.n_global_active_cells(), comm);

if (comm_tria == MPI_COMM_NULL)
if (comm_tria == MPI_COMM_SELF)
{
LinearAlgebra::distributed::Vector<double> partition{
IndexSet(n_global_active_cells), IndexSet(n_global_active_cells), comm};
Expand Down Expand Up @@ -111,7 +111,7 @@ test(const MPI_Comm comm, const unsigned int n_partitions)

parallel::distributed::Triangulation<dim> tria(sub_comm);

if (sub_comm != MPI_COMM_NULL)
if (sub_comm != MPI_COMM_SELF)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this!

I am not sure if this is equivalent to the previous code: this only works if MPI_COMM_WORLD and MPI_COMM_SELF are not the same (and if a subcommunicator of size one is not equivalent to MPI_COMM_SELF) for a serial execution. Is this the case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, good question. In this particular case, the test is only ever run with 4 processors, so I think this should work. I didn't mean to suggest that this is a generally good approach. I think a better approach would be to just not create a p::d::T object on the unused processes. But that seemed like more work.

{
GridGenerator::subdivided_hyper_cube(tria, 4);
tria.refine_global(3);
Expand All @@ -136,7 +136,7 @@ test(const MPI_Comm comm, const unsigned int n_partitions)
print_statistics(tria_pft);
print_statistics(dof_handler);

if (sub_comm != MPI_COMM_NULL)
if (sub_comm != MPI_COMM_SELF)
{
const int ierr = MPI_Comm_free(&sub_comm);
AssertThrowMPI(ierr);
Expand Down