From: Martin Kronbichler Date: Fri, 1 May 2020 07:38:39 +0000 (+0200) Subject: Split up matrix-free compilation into more files X-Git-Tag: v9.2.0-rc1~150^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=145273cbd78c008b4c43a20e74ea0dcfb53666e3;p=dealii.git Split up matrix-free compilation into more files --- diff --git a/include/deal.II/matrix_free/dof_info.h b/include/deal.II/matrix_free/dof_info.h index 7da0f1bf1c..96d6286d1f 100644 --- a/include/deal.II/matrix_free/dof_info.h +++ b/include/deal.II/matrix_free/dof_info.h @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -42,11 +43,38 @@ namespace internal { namespace MatrixFreeFunctions { - // Forward declaration -#ifndef DOXYGEN + /** + * A struct that takes entries describing a constraint and puts them into + * a sorted list where duplicates are filtered out + */ template - struct ConstraintValues; -#endif + struct ConstraintValues + { + ConstraintValues(); + + /** + * This function inserts some constrained entries to the collection of + * all values. It stores the (reordered) numbering of the dofs + * (according to the ordering that matches with the function) in + * new_indices, and returns the storage position the double array for + * access later on. + */ + template + unsigned short + insert_entries( + const std::vector> + &entries); + + std::vector> + constraint_entries; + std::vector constraint_indices; + + std::pair, types::global_dof_index> next_constraint; + std::map, + types::global_dof_index, + FPArrayComparator> + constraints; + }; /** * The class that stores the indices of the degrees of freedom for all the diff --git a/include/deal.II/matrix_free/dof_info.templates.h b/include/deal.II/matrix_free/dof_info.templates.h index 724197e3c6..e2dd291510 100644 --- a/include/deal.II/matrix_free/dof_info.templates.h +++ b/include/deal.II/matrix_free/dof_info.templates.h @@ -37,55 +37,13 @@ namespace internal { namespace MatrixFreeFunctions { - struct ConstraintComparator - { - bool - operator()(const std::pair &p1, - const std::pair &p2) const - { - return p1.second < p2.second; - } - }; - - /** - * A struct that takes entries describing a constraint and puts them into - * a sorted list where duplicates are filtered out - */ - template - struct ConstraintValues - { - ConstraintValues(); - - /** - * This function inserts some constrained entries to the collection of - * all values. It stores the (reordered) numbering of the dofs - * (according to the ordering that matches with the function) in - * new_indices, and returns the storage position the double array for - * access later on. - */ - template - unsigned short - insert_entries( - const std::vector> - &entries); - - std::vector> - constraint_entries; - std::vector constraint_indices; - - std::pair, types::global_dof_index> next_constraint; - std::map, - types::global_dof_index, - FPArrayComparator> - constraints; - }; - - template ConstraintValues::ConstraintValues() - : constraints(FPArrayComparator(1.)) + : constraints(FPArrayComparator(1.)) {} + + template template unsigned short @@ -101,7 +59,10 @@ namespace internal constraint_entries.assign(entries.begin(), entries.end()); std::sort(constraint_entries.begin(), constraint_entries.end(), - ConstraintComparator()); + [](const std::pair &p1, + const std::pair &p2) { + return p1.second < p2.second; + }); for (types::global_dof_index j = 0; j < constraint_entries.size(); j++) { @@ -121,11 +82,7 @@ namespace internal // equal. this was quite lengthy and now we use a std::map with a // user-defined comparator to compare floating point arrays to a // tolerance 1e-13. - std::pair, - types::global_dof_index, - FPArrayComparator>::iterator, - bool> - it = constraints.insert(next_constraint); + const auto it = constraints.insert(next_constraint); types::global_dof_index insert_position = numbers::invalid_dof_index; if (it.second == false) diff --git a/include/deal.II/matrix_free/face_setup_internal.h b/include/deal.II/matrix_free/face_setup_internal.h index b019cd3cc4..c6cf4465d1 100644 --- a/include/deal.II/matrix_free/face_setup_internal.h +++ b/include/deal.II/matrix_free/face_setup_internal.h @@ -1010,7 +1010,7 @@ namespace internal * face number, subface index and orientation are the same. This is used * to batch similar faces together for vectorization. */ - bool + inline bool compare_faces_for_vectorization(const FaceToCellTopology<1> &face1, const FaceToCellTopology<1> &face2) { diff --git a/include/deal.II/matrix_free/matrix_free.templates.h b/include/deal.II/matrix_free/matrix_free.templates.h index 783378cdee..6912b215b9 100644 --- a/include/deal.II/matrix_free/matrix_free.templates.h +++ b/include/deal.II/matrix_free/matrix_free.templates.h @@ -29,15 +29,16 @@ #include +#include +#include #include +#include #include -#include #include #include #include -#include #ifdef DEAL_II_WITH_THREADS # include @@ -1248,19 +1249,14 @@ MatrixFree::initialize_indices( } // set constraint pool from the std::map and reorder the indices - typename std::map, - types::global_dof_index, - internal::MatrixFreeFunctions::FPArrayComparator>:: - iterator it = constraint_values.constraints.begin(), - end = constraint_values.constraints.end(); std::vector *> constraints( constraint_values.constraints.size()); unsigned int length = 0; - for (; it != end; ++it) + for (const auto &it : constraint_values.constraints) { - AssertIndexRange(it->second, constraints.size()); - constraints[it->second] = &it->first; - length += it->first.size(); + AssertIndexRange(it.second, constraints.size()); + constraints[it.second] = &it.first; + length += it.first.size(); } constraint_pool_data.clear(); constraint_pool_data.reserve(length); @@ -1813,7 +1809,7 @@ MatrixFree::clear() namespace internal { - void + inline void fill_index_subrange( const unsigned int begin, const unsigned int end, @@ -1832,7 +1828,7 @@ namespace internal } template - void + inline void fill_connectivity_subrange( const unsigned int begin, const unsigned int end, @@ -1875,7 +1871,7 @@ namespace internal } } - void + inline void fill_connectivity_indirect_subrange( const unsigned int begin, const unsigned int end, diff --git a/include/deal.II/matrix_free/task_info.h b/include/deal.II/matrix_free/task_info.h index 12ad101c93..cfc972ccd9 100644 --- a/include/deal.II/matrix_free/task_info.h +++ b/include/deal.II/matrix_free/task_info.h @@ -95,10 +95,6 @@ namespace internal namespace MatrixFreeFunctions { - // forward declaration of internal data structure - template - struct ConstraintValues; - /** * A struct that collects all information related to parallelization with * threads: The work is subdivided into tasks that can be done diff --git a/source/matrix_free/CMakeLists.txt b/source/matrix_free/CMakeLists.txt index fa27962bdc..8c1bb8aeac 100644 --- a/source/matrix_free/CMakeLists.txt +++ b/source/matrix_free/CMakeLists.txt @@ -16,11 +16,15 @@ INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) SET(_src + dof_info.cc evaluation_selector.cc mapping_info.cc mapping_info_inst2.cc mapping_info_inst3.cc matrix_free.cc + matrix_free_inst2.cc + matrix_free_inst3.cc + shape_info.cc task_info.cc ) @@ -28,6 +32,7 @@ SET(_inst evaluation_selector.inst.in mapping_info.inst.in matrix_free.inst.in + shape_info.inst.in ) FILE(GLOB _header diff --git a/source/matrix_free/dof_info.cc b/source/matrix_free/dof_info.cc new file mode 100644 index 0000000000..105b44d590 --- /dev/null +++ b/source/matrix_free/dof_info.cc @@ -0,0 +1,109 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2020 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. +// +// --------------------------------------------------------------------- + + +#include +#include +#include + +#include + +#include + +DEAL_II_NAMESPACE_OPEN + +namespace internal +{ + namespace MatrixFreeFunctions + { + template struct ConstraintValues; + template struct ConstraintValues; + + template void + DoFInfo::read_dof_indices( + const std::vector &, + const std::vector &, + const AffineConstraints &, + const unsigned int, + ConstraintValues &, + bool &); + + template void + DoFInfo::read_dof_indices( + const std::vector &, + const std::vector &, + const AffineConstraints &, + const unsigned int, + ConstraintValues &, + bool &); + + template void + DoFInfo::compute_face_index_compression<1>( + const std::vector> &); + template void + DoFInfo::compute_face_index_compression<2>( + const std::vector> &); + template void + DoFInfo::compute_face_index_compression<4>( + const std::vector> &); + template void + DoFInfo::compute_face_index_compression<8>( + const std::vector> &); + template void + DoFInfo::compute_face_index_compression<16>( + const std::vector> &); + + template void + DoFInfo::compute_vector_zero_access_pattern<1>( + const TaskInfo &, + const std::vector> &); + template void + DoFInfo::compute_vector_zero_access_pattern<2>( + const TaskInfo &, + const std::vector> &); + template void + DoFInfo::compute_vector_zero_access_pattern<4>( + const TaskInfo &, + const std::vector> &); + template void + DoFInfo::compute_vector_zero_access_pattern<8>( + const TaskInfo &, + const std::vector> &); + template void + DoFInfo::compute_vector_zero_access_pattern<16>( + const TaskInfo &, + const std::vector> &); + + template void + DoFInfo::print_memory_consumption(std::ostream &, + const TaskInfo &) const; + template void + DoFInfo::print_memory_consumption( + ConditionalOStream &, + const TaskInfo &) const; + + template void + DoFInfo::print(const std::vector &, + const std::vector &, + std::ostream &) const; + + template void + DoFInfo::print(const std::vector &, + const std::vector &, + std::ostream &) const; + } // namespace MatrixFreeFunctions +} // namespace internal + +DEAL_II_NAMESPACE_CLOSE diff --git a/source/matrix_free/matrix_free.cc b/source/matrix_free/matrix_free.cc index e73c54fd39..8f0e9a153a 100644 --- a/source/matrix_free/matrix_free.cc +++ b/source/matrix_free/matrix_free.cc @@ -24,9 +24,17 @@ DEAL_II_NAMESPACE_OPEN +#define SPLIT_INSTANTIATIONS_COUNT 3 +#ifndef SPLIT_INSTANTIATIONS_INDEX +# define SPLIT_INSTANTIATIONS_INDEX 0 +#endif #include "matrix_free.inst" +#if SPLIT_INSTANTIATIONS_INDEX == 0 + template struct internal::MatrixFreeFunctions::ShapeInfo; template struct internal::MatrixFreeFunctions::ShapeInfo; +#endif + DEAL_II_NAMESPACE_CLOSE diff --git a/source/matrix_free/matrix_free.inst.in b/source/matrix_free/matrix_free.inst.in index 22762c607e..53c7631a99 100644 --- a/source/matrix_free/matrix_free.inst.in +++ b/source/matrix_free/matrix_free.inst.in @@ -14,17 +14,6 @@ // --------------------------------------------------------------------- -for (deal_II_dimension : DIMENSIONS; deal_II_scalar : REAL_SCALARS) - { - template void internal::MatrixFreeFunctions::ShapeInfo:: - reinit( - const Quadrature<1> &, - const FiniteElement &, - const unsigned int); - } - - - for (deal_II_dimension : DIMENSIONS; deal_II_scalar_vectorized : REAL_SCALARS_VECTORIZED) { @@ -78,12 +67,6 @@ for (deal_II_dimension : DIMENSIONS; deal_II_scalar_vectorized>:: get_dof_handler>(const unsigned int) const; - - template void internal::MatrixFreeFunctions:: - ShapeInfo::reinit( - const Quadrature<1> &, - const FiniteElement &, - const unsigned int); } @@ -125,9 +108,3 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS; const FiniteElement &); #endif } - -for (deal_II_scalar_vectorized : REAL_SCALARS_VECTORIZED) - { - template struct internal::MatrixFreeFunctions::ShapeInfo< - deal_II_scalar_vectorized>; - } diff --git a/source/matrix_free/matrix_free_inst2.cc b/source/matrix_free/matrix_free_inst2.cc new file mode 100644 index 0000000000..998346dd19 --- /dev/null +++ b/source/matrix_free/matrix_free_inst2.cc @@ -0,0 +1,17 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2020 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. +// +// --------------------------------------------------------------------- + +#define SPLIT_INSTANTIATIONS_INDEX 1 +#include "matrix_free.cc" diff --git a/source/matrix_free/matrix_free_inst3.cc b/source/matrix_free/matrix_free_inst3.cc new file mode 100644 index 0000000000..8358b94d72 --- /dev/null +++ b/source/matrix_free/matrix_free_inst3.cc @@ -0,0 +1,17 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2020 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. +// +// --------------------------------------------------------------------- + +#define SPLIT_INSTANTIATIONS_INDEX 2 +#include "matrix_free.cc" diff --git a/source/matrix_free/shape_info.cc b/source/matrix_free/shape_info.cc new file mode 100644 index 0000000000..aed24a6b40 --- /dev/null +++ b/source/matrix_free/shape_info.cc @@ -0,0 +1,32 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2020 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. +// +// --------------------------------------------------------------------- + + +#include +#include +#include + +#include + +#include + +DEAL_II_NAMESPACE_OPEN + +#include "shape_info.inst" + +template struct internal::MatrixFreeFunctions::ShapeInfo; +template struct internal::MatrixFreeFunctions::ShapeInfo; + +DEAL_II_NAMESPACE_CLOSE diff --git a/source/matrix_free/shape_info.inst.in b/source/matrix_free/shape_info.inst.in new file mode 100644 index 0000000000..f2c859da1d --- /dev/null +++ b/source/matrix_free/shape_info.inst.in @@ -0,0 +1,42 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2020 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. +// +// --------------------------------------------------------------------- + + +for (deal_II_dimension : DIMENSIONS; deal_II_scalar : REAL_SCALARS) + { + template void internal::MatrixFreeFunctions::ShapeInfo:: + reinit( + const Quadrature<1> &, + const FiniteElement &, + const unsigned int); + } + + + +for (deal_II_dimension : DIMENSIONS; + deal_II_scalar_vectorized : REAL_SCALARS_VECTORIZED) + { + template void internal::MatrixFreeFunctions:: + ShapeInfo::reinit( + const Quadrature<1> &, + const FiniteElement &, + const unsigned int); + } + +for (deal_II_scalar_vectorized : REAL_SCALARS_VECTORIZED) + { + template struct internal::MatrixFreeFunctions::ShapeInfo< + deal_II_scalar_vectorized>; + }