From a005eeeb6a90b109d28e534afea8807755092077 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 5 Jun 2020 07:17:46 -0600 Subject: [PATCH] Make the AffineConstraints scratch storage object-local. --- include/deal.II/lac/affine_constraints.h | 4 +++ .../lac/affine_constraints.templates.h | 28 ++++++----------- source/lac/affine_constraints.cc | 31 ------------------- 3 files changed, 13 insertions(+), 50 deletions(-) diff --git a/include/deal.II/lac/affine_constraints.h b/include/deal.II/lac/affine_constraints.h index 7f22f9ccbe..f0b8167cff 100644 --- a/include/deal.II/lac/affine_constraints.h +++ b/include/deal.II/lac/affine_constraints.h @@ -1830,6 +1830,10 @@ private: */ bool sorted; + mutable Threads::ThreadLocalStorage< + internal::AffineConstraints::ScratchData> + scratch_data; + /** * Internal function to calculate the index of line @p line_n in the vector * lines_cache using local_lines. diff --git a/include/deal.II/lac/affine_constraints.templates.h b/include/deal.II/lac/affine_constraints.templates.h index 5c439dadaa..c2f4eed498 100644 --- a/include/deal.II/lac/affine_constraints.templates.h +++ b/include/deal.II/lac/affine_constraints.templates.h @@ -2796,11 +2796,6 @@ namespace internal private: ScratchData *my_scratch_data; }; - - /** - * The actual data object that contains a scratch data for each thread. - */ - static Threads::ThreadLocalStorage> scratch_data; }; @@ -3560,9 +3555,8 @@ AffineConstraints::distribute_local_to_global( const size_type n_local_dofs = local_dof_indices.size(); - typename internal::AffineConstraints::AffineConstraintsData:: - ScratchDataAccessor scratch_data( - internal::AffineConstraints::AffineConstraintsData::scratch_data); + typename internal::AffineConstraints::AffineConstraintsData< + number>::ScratchDataAccessor scratch_data(this->scratch_data); internal::AffineConstraints::GlobalRowsFromLocal &global_rows = scratch_data->global_rows; @@ -3712,9 +3706,8 @@ AffineConstraints::distribute_local_to_global( } Assert(sorted == true, ExcMatrixNotClosed()); - typename internal::AffineConstraints::AffineConstraintsData:: - ScratchDataAccessor scratch_data( - internal::AffineConstraints::AffineConstraintsData::scratch_data); + typename internal::AffineConstraints::AffineConstraintsData< + number>::ScratchDataAccessor scratch_data(this->scratch_data); const size_type n_local_dofs = local_dof_indices.size(); internal::AffineConstraints::GlobalRowsFromLocal &global_rows = @@ -3851,8 +3844,7 @@ AffineConstraints::distribute_local_to_global( typename internal::AffineConstraints::AffineConstraintsData< typename MatrixType::value_type>::ScratchDataAccessor - scratch_data( - internal::AffineConstraints::AffineConstraintsData::scratch_data); + scratch_data(this->scratch_data); internal::AffineConstraints::GlobalRowsFromLocal &global_rows = scratch_data->global_rows; @@ -3911,9 +3903,8 @@ AffineConstraints::add_entries_local_to_global( ExcNotQuadratic()); const size_type n_local_dofs = local_dof_indices.size(); - typename internal::AffineConstraints::AffineConstraintsData:: - ScratchDataAccessor scratch_data( - internal::AffineConstraints::AffineConstraintsData::scratch_data); + typename internal::AffineConstraints::AffineConstraintsData< + number>::ScratchDataAccessor scratch_data(this->scratch_data); const bool dof_mask_is_active = (dof_mask.n_rows() == n_local_dofs); if (dof_mask_is_active == true) @@ -4068,9 +4059,8 @@ AffineConstraints::add_entries_local_to_global( const size_type n_local_dofs = local_dof_indices.size(); const size_type num_blocks = sparsity_pattern.n_block_rows(); - typename internal::AffineConstraints::AffineConstraintsData:: - ScratchDataAccessor scratch_data( - internal::AffineConstraints::AffineConstraintsData::scratch_data); + typename internal::AffineConstraints::AffineConstraintsData< + number>::ScratchDataAccessor scratch_data(this->scratch_data); const bool dof_mask_is_active = (dof_mask.n_rows() == n_local_dofs); if (dof_mask_is_active == true) diff --git a/source/lac/affine_constraints.cc b/source/lac/affine_constraints.cc index 2ddddb5325..42ad4994f3 100644 --- a/source/lac/affine_constraints.cc +++ b/source/lac/affine_constraints.cc @@ -137,35 +137,4 @@ dealii::AffineConstraints::distribute< # endif #endif -/* - * Allocate scratch data. - * - * We cannot use the generic template instantiation because we need to - * provide an initializer object of type - * internals::AffineConstraintsData that can be passed to the - * constructor of scratch_data (it won't allow one to be constructed in - * place). - */ - -namespace internal -{ - namespace AffineConstraints - { -#define SCRATCH_INITIALIZER(number, Name) \ - ScratchData scratch_data_initializer_##Name; \ - template <> \ - Threads::ThreadLocalStorage> \ - AffineConstraintsData::scratch_data( \ - scratch_data_initializer_##Name) - - SCRATCH_INITIALIZER(double, d); - SCRATCH_INITIALIZER(float, f); -#ifdef DEAL_II_WITH_COMPLEX_VALUES - SCRATCH_INITIALIZER(std::complex, cd); - SCRATCH_INITIALIZER(std::complex, cf); -#endif -#undef SCRATCH_INITIALIZER - } // namespace AffineConstraints -} // namespace internal - DEAL_II_NAMESPACE_CLOSE -- 2.39.5