From: Bruno Turcksin Date: Wed, 24 Feb 2016 20:10:59 +0000 (-0500) Subject: Fix a bug in make_trilinos_map() where different processors would call different... X-Git-Tag: v8.5.0-rc1~1282^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2242%2Fhead;p=dealii.git Fix a bug in make_trilinos_map() where different processors would call different Epetra_Map constructor. --- diff --git a/doc/news/changes.h b/doc/news/changes.h index 1f84ee4d2d..7d2f1790a2 100644 --- a/doc/news/changes.h +++ b/doc/news/changes.h @@ -63,6 +63,12 @@ inconvenience this causes.
    +
  1. Fixed: The function IndexSet::make_trilinos_map() now works if some + processors have a contiguous range of indices and others do not. +
    + (Bruno Turcksin, 2016/02/17) +
  2. +
  3. Updated: step-44 has been been expressed in a more dimension independent manner, and can be now run in both 2-d and 3-d.
    diff --git a/source/base/index_set.cc b/source/base/index_set.cc index 3cc560614b..5850d56eb0 100644 --- a/source/base/index_set.cc +++ b/source/base/index_set.cc @@ -510,7 +510,17 @@ IndexSet::make_trilinos_map (const MPI_Comm &communicator, } #endif + // Check that all the processors have a contiguous range of values. Otherwise, + // we risk to call different Epetra_Map on different processors and the code + // hangs. +#ifdef DEAL_II_WITH_MPI + bool all_contiguous = is_contiguous(); + MPI_Allreduce(MPI_IN_PLACE, &all_contiguous, 1, MPI_LOGICAL, MPI_LAND, + communicator); + if ((all_contiguous == true) && (!overlapping)) +#else if ((is_contiguous() == true) && (!overlapping)) +#endif return Epetra_Map (TrilinosWrappers::types::int_type(size()), TrilinosWrappers::types::int_type(n_elements()), 0, diff --git a/tests/trilinos/index_set_01.cc b/tests/trilinos/index_set_01.cc new file mode 100644 index 0000000000..574f3995a0 --- /dev/null +++ b/tests/trilinos/index_set_01.cc @@ -0,0 +1,66 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2016 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 make_trilinos_map always uses the same constructor all the +// processor. If we don't the code will hang like reported on the mailing list +// by Nicola Giuliani. + +#include "../tests.h" +#include +#include +#include +#include + + + +void test () +{ + IndexSet my_set; + my_set.set_size(654); + int this_mpi_process, n_mpi_processes; + n_mpi_processes = Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD); + this_mpi_process = Utilities::MPI::this_mpi_process(MPI_COMM_WORLD); + if (this_mpi_process == 0) + { + my_set.add_range(0,86); + } + else if (this_mpi_process == 1) + { + my_set.add_range(86,400); + my_set.add_range(529,654); + } + else + { + my_set.add_range(400,529); + } + my_set.compress(); + my_set.make_trilinos_map(MPI_COMM_WORLD,false); +} + + + +int main (int argc,char **argv) +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.threshold_double(1.e-10); + + Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv, testing_max_num_threads()); + test(); + + deallog << "OK" << std::endl; +} diff --git a/tests/trilinos/index_set_01.mpirun=3.output b/tests/trilinos/index_set_01.mpirun=3.output new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/trilinos/index_set_01.mpirun=3.output @@ -0,0 +1,2 @@ + +DEAL::OK