From: Wolfgang Bangerth Date: Wed, 25 Oct 2023 16:14:07 +0000 (-0600) Subject: Split a mutex into two that each guard one set of variables. X-Git-Tag: relicensing~354^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F16188%2Fhead;p=dealii.git Split a mutex into two that each guard one set of variables. --- diff --git a/include/deal.II/fe/fe_dgq.h b/include/deal.II/fe/fe_dgq.h index 25ae1700d1..3ff5f3b91c 100644 --- a/include/deal.II/fe/fe_dgq.h +++ b/include/deal.II/fe/fe_dgq.h @@ -367,10 +367,12 @@ private: rotate_indices(std::vector &indices, const char direction) const; - /* - * Mutex for protecting initialization of restriction and embedding matrix. + /** + * Mutex variables used for protecting the initialization of restriction + * and embedding matrices. */ - mutable Threads::Mutex mutex; + mutable Threads::Mutex restriction_matrix_mutex; + mutable Threads::Mutex prolongation_matrix_mutex; // Allow access from other dimensions. template diff --git a/include/deal.II/fe/fe_nedelec.h b/include/deal.II/fe/fe_nedelec.h index f508c432dc..e02f7a1e5a 100644 --- a/include/deal.II/fe/fe_nedelec.h +++ b/include/deal.II/fe/fe_nedelec.h @@ -636,9 +636,11 @@ private: Table<2, double> boundary_weights; /** - * Mutex for protecting initialization of restriction and embedding matrix. + * Mutex variables used for protecting the initialization of restriction + * and embedding matrices. */ - mutable Threads::Mutex mutex; + mutable Threads::Mutex restriction_matrix_mutex; + mutable Threads::Mutex prolongation_matrix_mutex; /** * Initialize the permutation pattern and the pattern of sign change. diff --git a/include/deal.II/fe/fe_q_base.h b/include/deal.II/fe/fe_q_base.h index 3ffe31978b..6eb213aa44 100644 --- a/include/deal.II/fe/fe_q_base.h +++ b/include/deal.II/fe/fe_q_base.h @@ -334,9 +334,11 @@ protected: private: /** - * Mutex for protecting initialization of restriction and embedding matrix. + * Mutex variables used for protecting the initialization of restriction + * and embedding matrices. */ - mutable Threads::Mutex mutex; + mutable Threads::Mutex restriction_matrix_mutex; + mutable Threads::Mutex prolongation_matrix_mutex; /** * The highest polynomial degree of the underlying tensor product space diff --git a/include/deal.II/fe/fe_raviart_thomas.h b/include/deal.II/fe/fe_raviart_thomas.h index f2b64679d5..1feb618951 100644 --- a/include/deal.II/fe/fe_raviart_thomas.h +++ b/include/deal.II/fe/fe_raviart_thomas.h @@ -417,10 +417,12 @@ private: void initialize_quad_dof_index_permutation_and_sign_change(); - /* - * Mutex for protecting initialization of restriction and embedding matrix. + /** + * Mutex variables used for protecting the initialization of restriction + * and embedding matrices. */ - mutable Threads::Mutex mutex; + mutable Threads::Mutex restriction_matrix_mutex; + mutable Threads::Mutex prolongation_matrix_mutex; }; /** @} */ diff --git a/include/deal.II/fe/fe_simplex_p.h b/include/deal.II/fe/fe_simplex_p.h index 8d92463cf8..8e2dbdfb2d 100644 --- a/include/deal.II/fe/fe_simplex_p.h +++ b/include/deal.II/fe/fe_simplex_p.h @@ -108,11 +108,13 @@ public: const std::vector> &support_point_values, std::vector &nodal_values) const override; -protected: +private: /** - * Mutex used to guard computation of some internal lookup tables. + * Mutex variables used for protecting the initialization of restriction + * and embedding matrices. */ - mutable Threads::Mutex mutex; + mutable Threads::Mutex restriction_matrix_mutex; + mutable Threads::Mutex prolongation_matrix_mutex; }; diff --git a/source/fe/fe_dgq.cc b/source/fe/fe_dgq.cc index ade082048e..d34e6b4c73 100644 --- a/source/fe/fe_dgq.cc +++ b/source/fe/fe_dgq.cc @@ -421,7 +421,7 @@ FE_DGQ::get_prolongation_matrix( // initialization upon first request if (this->prolongation[refinement_case - 1][child].n() == 0) { - std::lock_guard lock(this->mutex); + std::lock_guard lock(prolongation_matrix_mutex); // if matrix got updated while waiting for the lock if (this->prolongation[refinement_case - 1][child].n() == @@ -497,7 +497,7 @@ FE_DGQ::get_restriction_matrix( // initialization upon first request if (this->restriction[refinement_case - 1][child].n() == 0) { - std::lock_guard lock(this->mutex); + std::lock_guard lock(restriction_matrix_mutex); // if matrix got updated while waiting for the lock... if (this->restriction[refinement_case - 1][child].n() == diff --git a/source/fe/fe_nedelec.cc b/source/fe/fe_nedelec.cc index a1038ec5ee..674082578b 100644 --- a/source/fe/fe_nedelec.cc +++ b/source/fe/fe_nedelec.cc @@ -3041,7 +3041,7 @@ FE_Nedelec::get_prolongation_matrix( // initialization upon first request if (this->prolongation[refinement_case - 1][child].n() == 0) { - std::lock_guard lock(this->mutex); + std::lock_guard lock(prolongation_matrix_mutex); // if matrix got updated while waiting for the lock if (this->prolongation[refinement_case - 1][child].n() == @@ -3097,7 +3097,7 @@ FE_Nedelec::get_restriction_matrix( // initialization upon first request if (this->restriction[refinement_case - 1][child].n() == 0) { - std::lock_guard lock(this->mutex); + std::lock_guard lock(restriction_matrix_mutex); // if matrix got updated while waiting for the lock... if (this->restriction[refinement_case - 1][child].n() == diff --git a/source/fe/fe_q_base.cc b/source/fe/fe_q_base.cc index 09e453e41a..55e995a8ee 100644 --- a/source/fe/fe_q_base.cc +++ b/source/fe/fe_q_base.cc @@ -1266,7 +1266,7 @@ FE_Q_Base::get_prolongation_matrix( // initialization upon first request if (this->prolongation[refinement_case - 1][child].n() == 0) { - std::lock_guard lock(this->mutex); + std::lock_guard lock(prolongation_matrix_mutex); // if matrix got updated while waiting for the lock if (this->prolongation[refinement_case - 1][child].n() == @@ -1465,7 +1465,7 @@ FE_Q_Base::get_restriction_matrix( // initialization upon first request if (this->restriction[refinement_case - 1][child].n() == 0) { - std::lock_guard lock(this->mutex); + std::lock_guard lock(restriction_matrix_mutex); // if matrix got updated while waiting for the lock... if (this->restriction[refinement_case - 1][child].n() == diff --git a/source/fe/fe_raviart_thomas_nodal.cc b/source/fe/fe_raviart_thomas_nodal.cc index f00b69c395..4e616a2b02 100644 --- a/source/fe/fe_raviart_thomas_nodal.cc +++ b/source/fe/fe_raviart_thomas_nodal.cc @@ -683,7 +683,7 @@ FE_RaviartThomasNodal::get_prolongation_matrix( // initialization upon first request if (this->prolongation[refinement_case - 1][child].n() == 0) { - std::lock_guard lock(this->mutex); + std::lock_guard lock(prolongation_matrix_mutex); // if matrix got updated while waiting for the lock if (this->prolongation[refinement_case - 1][child].n() == @@ -741,7 +741,7 @@ FE_RaviartThomasNodal::get_restriction_matrix( // initialization upon first request if (this->restriction[refinement_case - 1][child].n() == 0) { - std::lock_guard lock(this->mutex); + std::lock_guard lock(restriction_matrix_mutex); // if matrix got updated while waiting for the lock... if (this->restriction[refinement_case - 1][child].n() == diff --git a/source/fe/fe_simplex_p.cc b/source/fe/fe_simplex_p.cc index 767d5b1ab5..54d9000af9 100644 --- a/source/fe/fe_simplex_p.cc +++ b/source/fe/fe_simplex_p.cc @@ -366,7 +366,7 @@ FE_SimplexPoly::get_prolongation_matrix( // initialization upon first request if (this->prolongation[refinement_case - 1][child].n() == 0) { - std::lock_guard lock(this->mutex); + std::lock_guard lock(prolongation_matrix_mutex); // if matrix got updated while waiting for the lock if (this->prolongation[refinement_case - 1][child].n() == @@ -408,7 +408,7 @@ FE_SimplexPoly::get_restriction_matrix( // initialization upon first request if (this->restriction[refinement_case - 1][child].n() == 0) { - std::lock_guard lock(this->mutex); + std::lock_guard lock(restriction_matrix_mutex); // if matrix got updated while waiting for the lock if (this->restriction[refinement_case - 1][child].n() ==