From bd8160ca9c05d3270ca67b7c58e6d0114a8dd7fa Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 29 Sep 2014 10:24:58 -0500 Subject: [PATCH] Add a bunch of missing tests for Utilities::MPI::max. --- tests/mpi/collective_03_array_in_place.cc | 66 ++++++++++++++++++ ...llective_03_array_in_place.mpirun=1.output | 2 + ...lective_03_array_in_place.mpirun=10.output | 2 + ...llective_03_array_in_place.mpirun=4.output | 2 + tests/mpi/collective_03_vector.cc | 68 +++++++++++++++++++ .../mpi/collective_03_vector.mpirun=1.output | 2 + .../mpi/collective_03_vector.mpirun=10.output | 2 + .../mpi/collective_03_vector.mpirun=4.output | 2 + tests/mpi/collective_03_vector_in_place.cc | 67 ++++++++++++++++++ ...lective_03_vector_in_place.mpirun=1.output | 2 + ...ective_03_vector_in_place.mpirun=10.output | 2 + ...lective_03_vector_in_place.mpirun=4.output | 2 + 12 files changed, 219 insertions(+) create mode 100644 tests/mpi/collective_03_array_in_place.cc create mode 100644 tests/mpi/collective_03_array_in_place.mpirun=1.output create mode 100644 tests/mpi/collective_03_array_in_place.mpirun=10.output create mode 100644 tests/mpi/collective_03_array_in_place.mpirun=4.output create mode 100644 tests/mpi/collective_03_vector.cc create mode 100644 tests/mpi/collective_03_vector.mpirun=1.output create mode 100644 tests/mpi/collective_03_vector.mpirun=10.output create mode 100644 tests/mpi/collective_03_vector.mpirun=4.output create mode 100644 tests/mpi/collective_03_vector_in_place.cc create mode 100644 tests/mpi/collective_03_vector_in_place.mpirun=1.output create mode 100644 tests/mpi/collective_03_vector_in_place.mpirun=10.output create mode 100644 tests/mpi/collective_03_vector_in_place.mpirun=4.output diff --git a/tests/mpi/collective_03_array_in_place.cc b/tests/mpi/collective_03_array_in_place.cc new file mode 100644 index 0000000000..9c61e2ee21 --- /dev/null +++ b/tests/mpi/collective_03_array_in_place.cc @@ -0,0 +1,66 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2009 - 2014 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 Utilities::MPI::max() for arrays, but with input=output + +#include "../tests.h" +#include +#include +#include + +void test() +{ + unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD); + const unsigned int numprocs = Utilities::MPI::n_mpi_processes (MPI_COMM_WORLD); + + unsigned int maxima[2] = { 1, 2 }; + Utilities::MPI::max (maxima, + MPI_COMM_WORLD, + maxima); + Assert (maxima[0] == 1, ExcInternalError()); + Assert (maxima[1] == 2, ExcInternalError()); + + if (myid==0) + deallog << maxima[0] << ' ' << maxima[1] << std::endl; +} + + +int main(int argc, char *argv[]) +{ +#ifdef DEAL_II_WITH_MPI + Utilities::MPI::MPI_InitFinalize mpi (argc, argv); +#else + (void)argc; + (void)argv; + compile_time_error; + +#endif + + if (Utilities::MPI::this_mpi_process (MPI_COMM_WORLD) == 0) + { + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + deallog.push("mpi"); + test(); + deallog.pop(); + } + else + test(); +} diff --git a/tests/mpi/collective_03_array_in_place.mpirun=1.output b/tests/mpi/collective_03_array_in_place.mpirun=1.output new file mode 100644 index 0000000000..6e10373d77 --- /dev/null +++ b/tests/mpi/collective_03_array_in_place.mpirun=1.output @@ -0,0 +1,2 @@ + +DEAL:mpi::1 2 diff --git a/tests/mpi/collective_03_array_in_place.mpirun=10.output b/tests/mpi/collective_03_array_in_place.mpirun=10.output new file mode 100644 index 0000000000..6e10373d77 --- /dev/null +++ b/tests/mpi/collective_03_array_in_place.mpirun=10.output @@ -0,0 +1,2 @@ + +DEAL:mpi::1 2 diff --git a/tests/mpi/collective_03_array_in_place.mpirun=4.output b/tests/mpi/collective_03_array_in_place.mpirun=4.output new file mode 100644 index 0000000000..6e10373d77 --- /dev/null +++ b/tests/mpi/collective_03_array_in_place.mpirun=4.output @@ -0,0 +1,2 @@ + +DEAL:mpi::1 2 diff --git a/tests/mpi/collective_03_vector.cc b/tests/mpi/collective_03_vector.cc new file mode 100644 index 0000000000..11da0bf745 --- /dev/null +++ b/tests/mpi/collective_03_vector.cc @@ -0,0 +1,68 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2009 - 2014 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 Utilities::MPI::max() for vectors + +#include "../tests.h" +#include +#include +#include + +void test() +{ + unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD); + const unsigned int numprocs = Utilities::MPI::n_mpi_processes (MPI_COMM_WORLD); + + unsigned int values_[2] = { 1, 2 }; + std::vector values(&values_[0], &values_[2]); + std::vector maxima(2); + Utilities::MPI::max (values, + MPI_COMM_WORLD, + maxima); + Assert (maxima[0] == 1, ExcInternalError()); + Assert (maxima[1] == 2, ExcInternalError()); + + if (myid==0) + deallog << maxima[0] << ' ' << maxima[1] << std::endl; +} + + +int main(int argc, char *argv[]) +{ +#ifdef DEAL_II_WITH_MPI + Utilities::MPI::MPI_InitFinalize mpi (argc, argv); +#else + (void)argc; + (void)argv; + compile_time_error; + +#endif + + if (Utilities::MPI::this_mpi_process (MPI_COMM_WORLD) == 0) + { + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + deallog.push("mpi"); + test(); + deallog.pop(); + } + else + test(); +} diff --git a/tests/mpi/collective_03_vector.mpirun=1.output b/tests/mpi/collective_03_vector.mpirun=1.output new file mode 100644 index 0000000000..6e10373d77 --- /dev/null +++ b/tests/mpi/collective_03_vector.mpirun=1.output @@ -0,0 +1,2 @@ + +DEAL:mpi::1 2 diff --git a/tests/mpi/collective_03_vector.mpirun=10.output b/tests/mpi/collective_03_vector.mpirun=10.output new file mode 100644 index 0000000000..6e10373d77 --- /dev/null +++ b/tests/mpi/collective_03_vector.mpirun=10.output @@ -0,0 +1,2 @@ + +DEAL:mpi::1 2 diff --git a/tests/mpi/collective_03_vector.mpirun=4.output b/tests/mpi/collective_03_vector.mpirun=4.output new file mode 100644 index 0000000000..6e10373d77 --- /dev/null +++ b/tests/mpi/collective_03_vector.mpirun=4.output @@ -0,0 +1,2 @@ + +DEAL:mpi::1 2 diff --git a/tests/mpi/collective_03_vector_in_place.cc b/tests/mpi/collective_03_vector_in_place.cc new file mode 100644 index 0000000000..716eb7f6df --- /dev/null +++ b/tests/mpi/collective_03_vector_in_place.cc @@ -0,0 +1,67 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2009 - 2014 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 Utilities::MPI::max() for vectors, but with input=output + +#include "../tests.h" +#include +#include +#include + +void test() +{ + unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD); + const unsigned int numprocs = Utilities::MPI::n_mpi_processes (MPI_COMM_WORLD); + + unsigned int values_[2] = { 1, 2 }; + std::vector maxima(&values_[0], &values_[2]); + Utilities::MPI::max (maxima, + MPI_COMM_WORLD, + maxima); + Assert (maxima[0] == 1, ExcInternalError()); + Assert (maxima[1] == 2, ExcInternalError()); + + if (myid==0) + deallog << maxima[0] << ' ' << maxima[1] << std::endl; +} + + +int main(int argc, char *argv[]) +{ +#ifdef DEAL_II_WITH_MPI + Utilities::MPI::MPI_InitFinalize mpi (argc, argv); +#else + (void)argc; + (void)argv; + compile_time_error; + +#endif + + if (Utilities::MPI::this_mpi_process (MPI_COMM_WORLD) == 0) + { + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + deallog.push("mpi"); + test(); + deallog.pop(); + } + else + test(); +} diff --git a/tests/mpi/collective_03_vector_in_place.mpirun=1.output b/tests/mpi/collective_03_vector_in_place.mpirun=1.output new file mode 100644 index 0000000000..6e10373d77 --- /dev/null +++ b/tests/mpi/collective_03_vector_in_place.mpirun=1.output @@ -0,0 +1,2 @@ + +DEAL:mpi::1 2 diff --git a/tests/mpi/collective_03_vector_in_place.mpirun=10.output b/tests/mpi/collective_03_vector_in_place.mpirun=10.output new file mode 100644 index 0000000000..6e10373d77 --- /dev/null +++ b/tests/mpi/collective_03_vector_in_place.mpirun=10.output @@ -0,0 +1,2 @@ + +DEAL:mpi::1 2 diff --git a/tests/mpi/collective_03_vector_in_place.mpirun=4.output b/tests/mpi/collective_03_vector_in_place.mpirun=4.output new file mode 100644 index 0000000000..6e10373d77 --- /dev/null +++ b/tests/mpi/collective_03_vector_in_place.mpirun=4.output @@ -0,0 +1,2 @@ + +DEAL:mpi::1 2 -- 2.39.5