From: Daniel Arndt Date: Sat, 28 Apr 2018 17:48:17 +0000 (+0200) Subject: Add test X-Git-Tag: v9.0.0-rc1~65^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a34e2f08d2ed6ff430eab6e9e9227869d04176de;p=dealii.git Add test --- diff --git a/tests/mpi/create_group_01.cc b/tests/mpi/create_group_01.cc new file mode 100644 index 0000000000..15641517ea --- /dev/null +++ b/tests/mpi/create_group_01.cc @@ -0,0 +1,58 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2018 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +// check that Utilities::MPI::create_group is only collective over the group of +// processes that actually want to create the communicator. +// In p4est-2.0, sc_init() leads to a deadlock when MPI_Comm_create_group is +// called (see https://github.com/cburstedde/p4est/issues/30). Hence, this test +// also ensures that the treatment of sc_init() is appropriate. + +#include "../tests.h" + +int main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_init (argc, argv, 1); + MPILogInitAll log_all; + + const MPI_Comm global_comm = MPI_COMM_WORLD; + + const unsigned int my_id = Utilities::MPI::this_mpi_process(global_comm); + const unsigned int n_ranks = Utilities::MPI::n_mpi_processes(global_comm); + + // Get the group of processes in MPI_COMM_WORLD + MPI_Group world_group; + int ierr = MPI_Comm_group(MPI_COMM_WORLD, &world_group); + AssertThrowMPI(ierr); + + const int n = n_ranks/2; + std::vector ranks; + for (unsigned int i=0; i