From: Luca Heltai Date: Mon, 20 Nov 2017 13:36:40 +0000 (+0100) Subject: Added tests for serial, and one more complex test. X-Git-Tag: v9.0.0-rc1~748^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9feee7ea969f1f9899ec9824a46c807313113722;p=dealii.git Added tests for serial, and one more complex test. --- diff --git a/tests/base/mpi_all_gather_01.cc b/tests/base/mpi_all_gather_01.cc index 3e8cff82ea..803fe31f20 100644 --- a/tests/base/mpi_all_gather_01.cc +++ b/tests/base/mpi_all_gather_01.cc @@ -17,12 +17,8 @@ // collective communication #include "../tests.h" -#include "../../include/deal.II/base/mpi.templates.h" - -#include #include - -#include +#include #include int main(int argc, char *argv[]) diff --git a/tests/base/mpi_all_gather_01.output b/tests/base/mpi_all_gather_01.output new file mode 100644 index 0000000000..186b780267 --- /dev/null +++ b/tests/base/mpi_all_gather_01.output @@ -0,0 +1,2 @@ + +DEAL::Test: ok diff --git a/tests/base/mpi_some_to_some_01.cc b/tests/base/mpi_some_to_some_01.cc index 602c5f2248..f9319414ae 100644 --- a/tests/base/mpi_some_to_some_01.cc +++ b/tests/base/mpi_some_to_some_01.cc @@ -17,16 +17,12 @@ // collective communication #include "../tests.h" -#include "../../include/deal.II/base/mpi.templates.h" -#include #include +#include -#include #include - - int main(int argc, char *argv[]) { Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); diff --git a/tests/base/mpi_some_to_some_01.output b/tests/base/mpi_some_to_some_01.output new file mode 100644 index 0000000000..186b780267 --- /dev/null +++ b/tests/base/mpi_some_to_some_01.output @@ -0,0 +1,2 @@ + +DEAL::Test: ok diff --git a/tests/base/mpi_some_to_some_02.cc b/tests/base/mpi_some_to_some_02.cc new file mode 100644 index 0000000000..10b6a4a6c1 --- /dev/null +++ b/tests/base/mpi_some_to_some_02.cc @@ -0,0 +1,124 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 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. +// +// --------------------------------------------------------------------- + +// Test for the internal::send_and_receive function in the case of +// collective communication + +#include "../tests.h" + +#include +#include + +#include +#include + +#include + +using namespace Patterns::Tools; + +inline unsigned int random_index(const unsigned int &max_index) +{ + return Testing::rand()*(max_index-1)/RAND_MAX; +} + +template +inline Point random_point(const double &min=0.0, + const double &max=1.0) +{ + Assert(max >= min, ExcMessage("Make sure max>=min")); + Point p; + for (unsigned int i=0; i +std::string to_string(const T &object) +{ + return Convert::to_string(object); +} + +template +void test(const unsigned int max_particles, + const double shared_fraction, + const unsigned int max_cell_levels, + const unsigned int max_cell_index) +{ + + auto n_procs = Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD); + auto my_proc = Utilities::MPI::this_mpi_process(MPI_COMM_WORLD); + + // Test some fake structure, similar to particles + typedef typename std::pair > particle; + + + unsigned int n_local_particles=random_index(max_particles); + std::vector particles(n_local_particles); + + auto all_n_local_particles = Utilities::MPI::all_gather(MPI_COMM_WORLD, n_local_particles); + + AssertDimension(all_n_local_particles.size(), n_procs); + + // Compute the start of my global indices + unsigned int my_global_start=0; + for (unsigned int i=0; i()); + + std::set shared_indices; + std::set shared_procs_set; + std::map > shared_particles; + + for (unsigned int i=0; i shared_procs(shared_procs_set.begin(), shared_procs_set.end()); + + deallog << "Proc " << my_proc << "/" << n_procs + << ": sharing with " + << to_string(shared_procs_set) << std::endl; + for (unsigned int i=0; i(40,.3,5,10); +} diff --git a/tests/base/mpi_some_to_some_02.mpirun=4.output b/tests/base/mpi_some_to_some_02.mpirun=4.output new file mode 100644 index 0000000000..3e2980e125 --- /dev/null +++ b/tests/base/mpi_some_to_some_02.mpirun=4.output @@ -0,0 +1,15 @@ + +DEAL:0::Proc 0/4: sharing with 1 +DEAL:0::OK + +DEAL:1::Proc 1/4: sharing with 0 +DEAL:1::OK + + +DEAL:2::Proc 2/4: sharing with 0, 1 +DEAL:2::OK + + +DEAL:3::Proc 3/4: sharing with 0, 1 +DEAL:3::OK + diff --git a/tests/base/mpi_some_to_some_02.output b/tests/base/mpi_some_to_some_02.output new file mode 100644 index 0000000000..be8d055f86 --- /dev/null +++ b/tests/base/mpi_some_to_some_02.output @@ -0,0 +1,2 @@ + +DEAL:0::OK