From: Wolfgang Bangerth Date: Tue, 27 Apr 2021 22:50:52 +0000 (-0600) Subject: Adapt a test by Peter Munch. X-Git-Tag: v9.3.0-rc1~168^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ca4c638cc5371312993472cbabb6a084a275575;p=dealii.git Adapt a test by Peter Munch. --- diff --git a/tests/base/aligned_vector_replicate_03.cc b/tests/base/aligned_vector_replicate_03.cc new file mode 100644 index 0000000000..d993d66091 --- /dev/null +++ b/tests/base/aligned_vector_replicate_03.cc @@ -0,0 +1,69 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2012 - 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.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// Test AlignedVector::replicate_across_communicator(). Cycle through all +// possible root ranks. + +#include + +#include "../tests.h" + + +void +test(const unsigned int root) +{ + if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == root) + deallog << root << " of " << Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD) + << ": "; + + AlignedVector avec(1000); + if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == root) + { + unsigned int counter = 0; + for (auto &i : avec) + i = counter++; + } + + avec.replicate_across_communicator(MPI_COMM_WORLD, root); + + { + unsigned int counter = 0; + + for (auto &i : avec) + { + AssertDimension(i, counter); + ++counter; + } + } + + MPI_Barrier(MPI_COMM_WORLD); + + if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == root) + deallog << "OK!" << std::endl; +} + + + +int +main(int argc, char **argv) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + MPILogInitAll all; + + for (unsigned int i = 0; i < Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD); + ++i) + test(i); +} diff --git a/tests/base/aligned_vector_replicate_03.mpirun=3.output b/tests/base/aligned_vector_replicate_03.mpirun=3.output new file mode 100644 index 0000000000..db547dd7b7 --- /dev/null +++ b/tests/base/aligned_vector_replicate_03.mpirun=3.output @@ -0,0 +1,8 @@ + +DEAL:0::0 of 3: OK! + +DEAL:1::1 of 3: OK! + + +DEAL:2::2 of 3: OK! +