From 89db4d6ac155aa042d9b79727b7faaf94ee34064 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Mon, 21 Oct 2013 09:37:10 +0000 Subject: [PATCH] Move matrix-free tests into matrix_free directory git-svn-id: https://svn.dealii.org/trunk@31372 0785d39b-7218-0410-832d-ea1e28bc413d --- .../matrix_vector_10.cc} | 75 ++---------------- ..._mpi=true.with_p4est=true.mpirun=1.output} | 0 ...mpi=true.with_p4est=true.mpirun=10.output} | 0 ..._mpi=true.with_p4est=true.mpirun=4.output} | 0 .../matrix_vector_11.cc} | 66 +--------------- ...mpi=true.with_p4est=true.mpirun=10.output} | 0 ..._mpi=true.with_p4est=true.mpirun=4.output} | 0 .../matrix_vector_12.cc} | 2 +- ..._mpi=true.with_p4est=true.mpirun=1.output} | 0 ...mpi=true.with_p4est=true.mpirun=10.output} | 0 ..._mpi=true.with_p4est=true.mpirun=3.output} | 0 .../matrix_vector_13.cc} | 0 ..._mpi=true.with_p4est=true.mpirun=1.output} | 0 ..._mpi=true.with_p4est=true.mpirun=2.output} | 0 tests/matrix_free/matrix_vector_common.h | 62 +-------------- tests/matrix_free/matrix_vector_hp.cc | 14 ++-- tests/matrix_free/matrix_vector_mf.h | 78 +++++++++++++++++++ tests/{mpi => matrix_free}/step-48.cc | 10 +++ .../step-48.mpirun=1.output | 0 .../step-48.mpirun=10.output | 0 .../step-48.mpirun=4.output | 0 tests/matrix_free/thread_correctness_hp.cc | 14 ++-- 22 files changed, 117 insertions(+), 204 deletions(-) rename tests/{mpi/matrix_free_01.cc => matrix_free/matrix_vector_10.cc} (74%) rename tests/{mpi/matrix_free_01.with_trilinos=true.mpirun=1.output => matrix_free/matrix_vector_10.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=1.output} (100%) rename tests/{mpi/matrix_free_01.with_trilinos=true.mpirun=10.output => matrix_free/matrix_vector_10.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=10.output} (100%) rename tests/{mpi/matrix_free_01.with_trilinos=true.mpirun=4.output => matrix_free/matrix_vector_10.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=4.output} (100%) rename tests/{mpi/matrix_free_02.cc => matrix_free/matrix_vector_11.cc} (74%) rename tests/{mpi/matrix_free_02.mpirun=10.output => matrix_free/matrix_vector_11.with_mpi=true.with_p4est=true.mpirun=10.output} (100%) rename tests/{mpi/matrix_free_02.mpirun=4.output => matrix_free/matrix_vector_11.with_mpi=true.with_p4est=true.mpirun=4.output} (100%) rename tests/{mpi/matrix_free_03.cc => matrix_free/matrix_vector_12.cc} (99%) rename tests/{mpi/matrix_free_03.with_trilinos=true.mpirun=1.output => matrix_free/matrix_vector_12.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=1.output} (100%) rename tests/{mpi/matrix_free_03.with_trilinos=true.mpirun=10.output => matrix_free/matrix_vector_12.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=10.output} (100%) rename tests/{mpi/matrix_free_03.with_trilinos=true.mpirun=3.output => matrix_free/matrix_vector_12.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=3.output} (100%) rename tests/{mpi/matrix_free_04.cc => matrix_free/matrix_vector_13.cc} (100%) rename tests/{mpi/matrix_free_04.with_trilinos=true.mpirun=1.output => matrix_free/matrix_vector_13.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=1.output} (100%) rename tests/{mpi/matrix_free_04.with_trilinos=true.mpirun=2.output => matrix_free/matrix_vector_13.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=2.output} (100%) create mode 100644 tests/matrix_free/matrix_vector_mf.h rename tests/{mpi => matrix_free}/step-48.cc (98%) rename tests/{mpi => matrix_free}/step-48.mpirun=1.output (100%) rename tests/{mpi => matrix_free}/step-48.mpirun=10.output (100%) rename tests/{mpi => matrix_free}/step-48.mpirun=4.output (100%) diff --git a/tests/mpi/matrix_free_01.cc b/tests/matrix_free/matrix_vector_10.cc similarity index 74% rename from tests/mpi/matrix_free_01.cc rename to tests/matrix_free/matrix_vector_10.cc index c6398623d0..cd920535ae 100644 --- a/tests/mpi/matrix_free_01.cc +++ b/tests/matrix_free/matrix_vector_10.cc @@ -16,24 +16,22 @@ -// this tests the correctness of matrix free matrix-vector products by -// comparing the result with a Trilinos sparse matrix assembled in the usual -// way. The mesh is distributed among processors (hypercube) and has both -// hanging nodes (by randomly refining some cells, so the mesh is going to be -// different when run with different numbers of processors) and Dirichlet -// boundary conditions +// this tests the correctness of MPI-parallel matrix free matrix-vector +// products by comparing the result with a Trilinos sparse matrix assembled in +// the usual way. The mesh is distributed among processors (hypercube) and has +// both hanging nodes (by randomly refining some cells, so the mesh is going +// to be different when run with different numbers of processors) and +// Dirichlet boundary conditions // // this test does not use multithreading within the MPI nodes. #include "../tests.h" -#include -#include +#include "matrix_vector_mf.h" #include #include #include -#include #include #include #include @@ -49,63 +47,6 @@ #include -template -void -helmholtz_operator (const MatrixFree &data, - parallel::distributed::Vector &dst, - const parallel::distributed::Vector &src, - const std::pair &cell_range) -{ - FEEvaluation fe_eval (data); - const unsigned int n_q_points = fe_eval.n_q_points; - - for (unsigned int cell=cell_range.first; cell -class MatrixFreeTest -{ -public: - typedef VectorizedArray vector_t; - static const std::size_t n_vectors = VectorizedArray::n_array_elements; - - MatrixFreeTest(const MatrixFree &data_in): - data (data_in) - {}; - - void vmult (parallel::distributed::Vector &dst, - const parallel::distributed::Vector &src) const - { - dst = 0; - const std_cxx1x::function &, - parallel::distributed::Vector &, - const parallel::distributed::Vector &, - const std::pair &)> - wrap = helmholtz_operator; - data.cell_loop (wrap, dst, src); - }; - -private: - const MatrixFree &data; -}; - - - template @@ -176,7 +117,7 @@ void test () mf_data.reinit (dof, constraints, quad, data); } - MatrixFreeTest mf (mf_data); + MatrixFreeTest > mf (mf_data); parallel::distributed::Vector in, out, ref; mf_data.initialize_dof_vector (in); out.reinit (in); diff --git a/tests/mpi/matrix_free_01.with_trilinos=true.mpirun=1.output b/tests/matrix_free/matrix_vector_10.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=1.output similarity index 100% rename from tests/mpi/matrix_free_01.with_trilinos=true.mpirun=1.output rename to tests/matrix_free/matrix_vector_10.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=1.output diff --git a/tests/mpi/matrix_free_01.with_trilinos=true.mpirun=10.output b/tests/matrix_free/matrix_vector_10.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=10.output similarity index 100% rename from tests/mpi/matrix_free_01.with_trilinos=true.mpirun=10.output rename to tests/matrix_free/matrix_vector_10.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=10.output diff --git a/tests/mpi/matrix_free_01.with_trilinos=true.mpirun=4.output b/tests/matrix_free/matrix_vector_10.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=4.output similarity index 100% rename from tests/mpi/matrix_free_01.with_trilinos=true.mpirun=4.output rename to tests/matrix_free/matrix_vector_10.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=4.output diff --git a/tests/mpi/matrix_free_02.cc b/tests/matrix_free/matrix_vector_11.cc similarity index 74% rename from tests/mpi/matrix_free_02.cc rename to tests/matrix_free/matrix_vector_11.cc index 39fcb9fbdc..4b32389011 100644 --- a/tests/mpi/matrix_free_02.cc +++ b/tests/matrix_free/matrix_vector_11.cc @@ -18,12 +18,11 @@ // this tests the correctness of matrix free matrix-vector products when // threads are additionally used to MPI by comparing the result with a -// non-parallel version. Otherwise same problem as matrix_free_01.cc +// non-parallel version. Otherwise same problem as matrix_vector_10.cc #include "../tests.h" -#include -#include +#include "matrix_vector_mf.h" #include #include @@ -41,63 +40,6 @@ #include -template -void -helmholtz_operator (const MatrixFree &data, - parallel::distributed::Vector &dst, - const parallel::distributed::Vector &src, - const std::pair &cell_range) -{ - FEEvaluation fe_eval (data); - const unsigned int n_q_points = fe_eval.n_q_points; - - for (unsigned int cell=cell_range.first; cell -class MatrixFreeTest -{ -public: - typedef VectorizedArray vector_t; - static const std::size_t n_vectors = VectorizedArray::n_array_elements; - - MatrixFreeTest(const MatrixFree &data_in): - data (data_in) - {}; - - void vmult (parallel::distributed::Vector &dst, - const parallel::distributed::Vector &src) const - { - dst = 0; - const std_cxx1x::function &, - parallel::distributed::Vector &, - const parallel::distributed::Vector &, - const std::pair &)> - wrap = helmholtz_operator; - data.cell_loop (wrap, dst, src); - }; - -private: - const MatrixFree &data; -}; - - - template @@ -168,7 +110,7 @@ void test () mf_data.reinit (dof, constraints, quad, data); } - MatrixFreeTest mf (mf_data); + MatrixFreeTest > mf (mf_data); parallel::distributed::Vector in, out, ref; mf_data.initialize_dof_vector (in); out.reinit (in); @@ -211,7 +153,7 @@ void test () data.tasks_block_size = 3; mf_data.reinit (dof, constraints, quad, data); - MatrixFreeTest mf (mf_data); + MatrixFreeTest > mf (mf_data); deallog << "Norm of difference:"; // run 10 times to make a possible error more diff --git a/tests/mpi/matrix_free_02.mpirun=10.output b/tests/matrix_free/matrix_vector_11.with_mpi=true.with_p4est=true.mpirun=10.output similarity index 100% rename from tests/mpi/matrix_free_02.mpirun=10.output rename to tests/matrix_free/matrix_vector_11.with_mpi=true.with_p4est=true.mpirun=10.output diff --git a/tests/mpi/matrix_free_02.mpirun=4.output b/tests/matrix_free/matrix_vector_11.with_mpi=true.with_p4est=true.mpirun=4.output similarity index 100% rename from tests/mpi/matrix_free_02.mpirun=4.output rename to tests/matrix_free/matrix_vector_11.with_mpi=true.with_p4est=true.mpirun=4.output diff --git a/tests/mpi/matrix_free_03.cc b/tests/matrix_free/matrix_vector_12.cc similarity index 99% rename from tests/mpi/matrix_free_03.cc rename to tests/matrix_free/matrix_vector_12.cc index 16971b03d4..b159c5c35a 100644 --- a/tests/mpi/matrix_free_03.cc +++ b/tests/matrix_free/matrix_vector_12.cc @@ -17,7 +17,7 @@ // this tests the correctness of matrix free matrix-vector products for two -// vectors on the same DoFHandler. Otherwise the same as matrix_free_01 +// vectors on the same DoFHandler. Otherwise the same as matrix_vector_10.cc #include "../tests.h" diff --git a/tests/mpi/matrix_free_03.with_trilinos=true.mpirun=1.output b/tests/matrix_free/matrix_vector_12.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=1.output similarity index 100% rename from tests/mpi/matrix_free_03.with_trilinos=true.mpirun=1.output rename to tests/matrix_free/matrix_vector_12.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=1.output diff --git a/tests/mpi/matrix_free_03.with_trilinos=true.mpirun=10.output b/tests/matrix_free/matrix_vector_12.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=10.output similarity index 100% rename from tests/mpi/matrix_free_03.with_trilinos=true.mpirun=10.output rename to tests/matrix_free/matrix_vector_12.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=10.output diff --git a/tests/mpi/matrix_free_03.with_trilinos=true.mpirun=3.output b/tests/matrix_free/matrix_vector_12.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=3.output similarity index 100% rename from tests/mpi/matrix_free_03.with_trilinos=true.mpirun=3.output rename to tests/matrix_free/matrix_vector_12.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=3.output diff --git a/tests/mpi/matrix_free_04.cc b/tests/matrix_free/matrix_vector_13.cc similarity index 100% rename from tests/mpi/matrix_free_04.cc rename to tests/matrix_free/matrix_vector_13.cc diff --git a/tests/mpi/matrix_free_04.with_trilinos=true.mpirun=1.output b/tests/matrix_free/matrix_vector_13.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=1.output similarity index 100% rename from tests/mpi/matrix_free_04.with_trilinos=true.mpirun=1.output rename to tests/matrix_free/matrix_vector_13.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=1.output diff --git a/tests/mpi/matrix_free_04.with_trilinos=true.mpirun=2.output b/tests/matrix_free/matrix_vector_13.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=2.output similarity index 100% rename from tests/mpi/matrix_free_04.with_trilinos=true.mpirun=2.output rename to tests/matrix_free/matrix_vector_13.with_trilinos=true.with_mpi=true.with_p4est=true.mpirun=2.output diff --git a/tests/matrix_free/matrix_vector_common.h b/tests/matrix_free/matrix_vector_common.h index a6182654cc..f1c5b3b796 100644 --- a/tests/matrix_free/matrix_vector_common.h +++ b/tests/matrix_free/matrix_vector_common.h @@ -12,8 +12,7 @@ #include "../tests.h" -#include -#include +#include "matrix_vector_mf.h" #include #include @@ -39,62 +38,6 @@ void test (); -template -void -helmholtz_operator (const MatrixFree &data, - Vector &dst, - const Vector &src, - const std::pair &cell_range) -{ - FEEvaluation fe_eval (data); - const unsigned int n_q_points = fe_eval.n_q_points; - - for (unsigned int cell=cell_range.first; cell -class MatrixFreeTest -{ -public: - typedef VectorizedArray vector_t; - - MatrixFreeTest(const MatrixFree &data_in): - data (data_in) - {}; - - void vmult (Vector &dst, - const Vector &src) const - { - dst = 0; - const std_cxx1x::function &, - Vector &, - const Vector &, - const std::pair &)> - wrap = helmholtz_operator; - data.cell_loop (wrap, dst, src); - }; - -private: - const MatrixFree &data; -}; - - - - template void do_test (const DoFHandler &dof, @@ -147,8 +90,7 @@ void do_test (const DoFHandler &dof, mf.vmult (out_dist, in_dist); - // assemble sparse matrix with (\nabla v, - // \nabla u) + (v, 10 * u) + // assemble sparse matrix with (\nabla v, \nabla u) + (v, 10 * u) SparsityPattern sparsity; { CompressedSimpleSparsityPattern csp(dof.n_dofs(), dof.n_dofs()); diff --git a/tests/matrix_free/matrix_vector_hp.cc b/tests/matrix_free/matrix_vector_hp.cc index bf092966ea..a56cfd84b5 100644 --- a/tests/matrix_free/matrix_vector_hp.cc +++ b/tests/matrix_free/matrix_vector_hp.cc @@ -49,31 +49,31 @@ public: std::pair subrange_deg = data.create_cell_subrange_hp (cell_range, 1); if (subrange_deg.second > subrange_deg.first) - helmholtz_operator (data, dst, src, + helmholtz_operator > (data, dst, src, subrange_deg); subrange_deg = data.create_cell_subrange_hp (cell_range, 2); if (subrange_deg.second > subrange_deg.first) - helmholtz_operator (data, dst, src, + helmholtz_operator > (data, dst, src, subrange_deg); subrange_deg = data.create_cell_subrange_hp (cell_range, 3); if (subrange_deg.second > subrange_deg.first) - helmholtz_operator (data, dst, src, + helmholtz_operator > (data, dst, src, subrange_deg); subrange_deg = data.create_cell_subrange_hp (cell_range, 4); if (subrange_deg.second > subrange_deg.first) - helmholtz_operator (data, dst, src, + helmholtz_operator > (data, dst, src, subrange_deg); subrange_deg = data.create_cell_subrange_hp (cell_range, 5); if (subrange_deg.second > subrange_deg.first) - helmholtz_operator (data, dst, src, + helmholtz_operator > (data, dst, src, subrange_deg); subrange_deg = data.create_cell_subrange_hp (cell_range, 6); if (subrange_deg.second > subrange_deg.first) - helmholtz_operator (data, dst, src, + helmholtz_operator > (data, dst, src, subrange_deg); subrange_deg = data.create_cell_subrange_hp (cell_range, 7); if (subrange_deg.second > subrange_deg.first) - helmholtz_operator (data, dst, src, + helmholtz_operator > (data, dst, src, subrange_deg); } diff --git a/tests/matrix_free/matrix_vector_mf.h b/tests/matrix_free/matrix_vector_mf.h new file mode 100644 index 0000000000..6b3fe20a0e --- /dev/null +++ b/tests/matrix_free/matrix_vector_mf.h @@ -0,0 +1,78 @@ +//------------------ matrix_vector_common.h ------------------------ +// $Id$ +// Version: $Name$ +// +//------------------ matrix_vector_common.h ------------------------ + + +// this is a template for matrix-vector products with the Helmholtz equation +// (zero and first derivatives) on different kinds of meshes (Cartesian, +// general, with and without hanging nodes). It also tests the multithreading +// in case it was enabled + +#include "../tests.h" + +#include +#include + +#include +#include + + +template +void +helmholtz_operator (const MatrixFree &data, + VECTOR &dst, + const VECTOR &src, + const std::pair &cell_range) +{ + typedef typename VECTOR::value_type Number; + FEEvaluation fe_eval (data); + const unsigned int n_q_points = fe_eval.n_q_points; + + for (unsigned int cell=cell_range.first; cell > +class MatrixFreeTest +{ +public: + typedef VectorizedArray vector_t; + + MatrixFreeTest(const MatrixFree &data_in): + data (data_in) + {}; + + void vmult (VECTOR &dst, + const VECTOR &src) const + { + dst = 0; + const std_cxx1x::function &, + VECTOR &, + const VECTOR &, + const std::pair &)> + wrap = helmholtz_operator; + data.cell_loop (wrap, dst, src); + }; + +private: + const MatrixFree &data; +}; + + + + diff --git a/tests/mpi/step-48.cc b/tests/matrix_free/step-48.cc similarity index 98% rename from tests/mpi/step-48.cc rename to tests/matrix_free/step-48.cc index 701cd04217..3add3fe5d9 100644 --- a/tests/mpi/step-48.cc +++ b/tests/matrix_free/step-48.cc @@ -211,7 +211,11 @@ namespace Step48 void assemble_system (); void output_results (const unsigned int timestep_number); +#ifdef DEAL_II_WITH_P4EST parallel::distributed::Triangulation triangulation; +#else + Triangulation triangulation; +#endif FE_Q fe; DoFHandler dof_handler; ConstraintMatrix constraints; @@ -233,7 +237,9 @@ namespace Step48 template SineGordonProblem::SineGordonProblem () : +#ifdef DEAL_II_WITH_P4EST triangulation (MPI_COMM_WORLD), +#endif fe (QGaussLobatto<1>(fe_degree+1)), dof_handler (triangulation), n_global_refinements (8-2*dim), @@ -269,7 +275,11 @@ namespace Step48 } deallog << " Number of global active cells: " +#ifdef DEAL_II_WITH_P4EST << triangulation.n_global_active_cells() +#else + << triangulation.n_active_cells() +#endif << std::endl; dof_handler.distribute_dofs (fe); diff --git a/tests/mpi/step-48.mpirun=1.output b/tests/matrix_free/step-48.mpirun=1.output similarity index 100% rename from tests/mpi/step-48.mpirun=1.output rename to tests/matrix_free/step-48.mpirun=1.output diff --git a/tests/mpi/step-48.mpirun=10.output b/tests/matrix_free/step-48.mpirun=10.output similarity index 100% rename from tests/mpi/step-48.mpirun=10.output rename to tests/matrix_free/step-48.mpirun=10.output diff --git a/tests/mpi/step-48.mpirun=4.output b/tests/matrix_free/step-48.mpirun=4.output similarity index 100% rename from tests/mpi/step-48.mpirun=4.output rename to tests/matrix_free/step-48.mpirun=4.output diff --git a/tests/matrix_free/thread_correctness_hp.cc b/tests/matrix_free/thread_correctness_hp.cc index 03c3f1df8d..1cd2e405b3 100644 --- a/tests/matrix_free/thread_correctness_hp.cc +++ b/tests/matrix_free/thread_correctness_hp.cc @@ -52,31 +52,31 @@ public: std::pair subrange_deg = data.create_cell_subrange_hp (cell_range, 1); if (subrange_deg.second > subrange_deg.first) - helmholtz_operator (data, dst, src, + helmholtz_operator > (data, dst, src, subrange_deg); subrange_deg = data.create_cell_subrange_hp (cell_range, 2); if (subrange_deg.second > subrange_deg.first) - helmholtz_operator (data, dst, src, + helmholtz_operator > (data, dst, src, subrange_deg); subrange_deg = data.create_cell_subrange_hp (cell_range, 3); if (subrange_deg.second > subrange_deg.first) - helmholtz_operator (data, dst, src, + helmholtz_operator > (data, dst, src, subrange_deg); subrange_deg = data.create_cell_subrange_hp (cell_range, 4); if (subrange_deg.second > subrange_deg.first) - helmholtz_operator (data, dst, src, + helmholtz_operator > (data, dst, src, subrange_deg); subrange_deg = data.create_cell_subrange_hp (cell_range, 5); if (subrange_deg.second > subrange_deg.first) - helmholtz_operator (data, dst, src, + helmholtz_operator > (data, dst, src, subrange_deg); subrange_deg = data.create_cell_subrange_hp (cell_range, 6); if (subrange_deg.second > subrange_deg.first) - helmholtz_operator (data, dst, src, + helmholtz_operator > (data, dst, src, subrange_deg); subrange_deg = data.create_cell_subrange_hp (cell_range, 7); if (subrange_deg.second > subrange_deg.first) - helmholtz_operator (data, dst, src, + helmholtz_operator > (data, dst, src, subrange_deg); } -- 2.39.5