From: Peter Munch Date: Tue, 20 Sep 2022 18:42:05 +0000 (+0200) Subject: Remove template parameter from FPArrayComparator X-Git-Tag: v9.5.0-rc1~942^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F14294%2Fhead;p=dealii.git Remove template parameter from FPArrayComparator --- diff --git a/include/deal.II/matrix_free/dof_info.h b/include/deal.II/matrix_free/dof_info.h index 52f40f3071..1ea1adec85 100644 --- a/include/deal.II/matrix_free/dof_info.h +++ b/include/deal.II/matrix_free/dof_info.h @@ -44,7 +44,7 @@ namespace internal template class HangingNodes; - template + template struct FPArrayComparator; struct TaskInfo; @@ -111,7 +111,7 @@ namespace internal std::pair, types::global_dof_index> next_constraint; std::map, types::global_dof_index, - FPArrayComparator>> + FPArrayComparator>> constraints; }; diff --git a/include/deal.II/matrix_free/dof_info.templates.h b/include/deal.II/matrix_free/dof_info.templates.h index 5f984132ff..8c3693d66a 100644 --- a/include/deal.II/matrix_free/dof_info.templates.h +++ b/include/deal.II/matrix_free/dof_info.templates.h @@ -41,7 +41,7 @@ namespace internal { template ConstraintValues::ConstraintValues() - : constraints(FPArrayComparator(1.)) + : constraints(FPArrayComparator>(1.)) {} diff --git a/include/deal.II/matrix_free/mapping_info.h b/include/deal.II/matrix_free/mapping_info.h index b96f03b561..8efa107154 100644 --- a/include/deal.II/matrix_free/mapping_info.h +++ b/include/deal.II/matrix_free/mapping_info.h @@ -310,10 +310,14 @@ namespace internal * satisfied). This is not a problem in the use cases for this class, but be * careful when using it in other contexts. */ - template > + template struct FPArrayComparator { + using Number = typename dealii::internal::VectorizedArrayTrait< + VectorizedArrayType>::value_type; + static constexpr std::size_t width = + dealii::internal::VectorizedArrayTrait::width; + FPArrayComparator(const Number scaling); /** @@ -328,9 +332,8 @@ namespace internal * issues). */ bool - operator()( - const Tensor<1, VectorizedArrayType::size(), Number> &t1, - const Tensor<1, VectorizedArrayType::size(), Number> &t2) const; + operator()(const Tensor<1, width, Number> &t1, + const Tensor<1, width, Number> &t2) const; /** * Compare two rank-1 tensors of vectorized arrays (stored as tensors to @@ -338,11 +341,8 @@ namespace internal */ template bool - operator()( - const Tensor<1, dim, Tensor<1, VectorizedArrayType::size(), Number>> - &t1, - const Tensor<1, dim, Tensor<1, VectorizedArrayType::size(), Number>> - &t2) const; + operator()(const Tensor<1, dim, Tensor<1, width, Number>> &t1, + const Tensor<1, dim, Tensor<1, width, Number>> &t2) const; /** * Compare two rank-2 tensors of vectorized arrays (stored as tensors to @@ -350,11 +350,8 @@ namespace internal */ template bool - operator()( - const Tensor<2, dim, Tensor<1, VectorizedArrayType::size(), Number>> - &t1, - const Tensor<2, dim, Tensor<1, VectorizedArrayType::size(), Number>> - &t2) const; + operator()(const Tensor<2, dim, Tensor<1, width, Number>> &t1, + const Tensor<2, dim, Tensor<1, width, Number>> &t2) const; /** * Compare two arrays of tensors. diff --git a/include/deal.II/matrix_free/mapping_info.templates.h b/include/deal.II/matrix_free/mapping_info.templates.h index 29df78d371..57e777008f 100644 --- a/include/deal.II/matrix_free/mapping_info.templates.h +++ b/include/deal.II/matrix_free/mapping_info.templates.h @@ -347,12 +347,12 @@ namespace internal struct CompressedCellData { CompressedCellData(const double expected_size) - : data(FPArrayComparator(expected_size)) + : data(FPArrayComparator(expected_size)) {} std::map>, unsigned int, - FPArrayComparator> + FPArrayComparator> data; }; @@ -1077,10 +1077,11 @@ namespace internal // first quadrature point on the cell - we use a relatively coarse // tolerance to account for some inaccuracies in the manifold // evaluation - const FPArrayComparator comparator(1e4 * jacobian_size); + const FPArrayComparator> comparator( + 1e4 * jacobian_size); std::map, dim + 1>, unsigned int, - FPArrayComparator> + FPArrayComparator>> compressed_jacobians(comparator); unsigned int n_data_buckets = 0; @@ -1503,8 +1504,7 @@ namespace internal // CompressedCellData) and add another factor of 512 to account for // some roundoff effects. CompressedFaceData(const Number jacobian_size) - : data(FPArrayComparator(512. / - jacobian_size)) + : data(FPArrayComparator(512. / jacobian_size)) , jacobian_size(jacobian_size) {} @@ -1518,7 +1518,7 @@ namespace internal 2 * dim * dim + dim + 1, Tensor<1, VectorizedArrayType::size(), Number>>, unsigned int, - FPArrayComparator> + FPArrayComparator> data; // Store the scaling factor @@ -3351,17 +3351,17 @@ namespace internal /* ------------------------------------------------------------------ */ - template - FPArrayComparator::FPArrayComparator( + template + FPArrayComparator::FPArrayComparator( const Number scaling) : tolerance(scaling * std::numeric_limits::epsilon() * 1024.) {} - template + template bool - FPArrayComparator::operator()( + FPArrayComparator::operator()( const std::vector &v1, const std::vector &v2) const { @@ -3381,13 +3381,13 @@ namespace internal - template + template bool - FPArrayComparator::operator()( - const Tensor<1, VectorizedArrayType::size(), Number> &t1, - const Tensor<1, VectorizedArrayType::size(), Number> &t2) const + FPArrayComparator::operator()( + const Tensor<1, width, Number> &t1, + const Tensor<1, width, Number> &t2) const { - for (unsigned int k = 0; k < VectorizedArrayType::size(); ++k) + for (unsigned int k = 0; k < width; ++k) if (t1[k] < t2[k] - tolerance) return true; else if (t1[k] > t2[k] + tolerance) @@ -3397,16 +3397,15 @@ namespace internal - template + template template bool - FPArrayComparator::operator()( - const Tensor<1, dim, Tensor<1, VectorizedArrayType::size(), Number>> &t1, - const Tensor<1, dim, Tensor<1, VectorizedArrayType::size(), Number>> &t2) - const + FPArrayComparator::operator()( + const Tensor<1, dim, Tensor<1, width, Number>> &t1, + const Tensor<1, dim, Tensor<1, width, Number>> &t2) const { for (unsigned int d = 0; d < dim; ++d) - for (unsigned int k = 0; k < VectorizedArrayType::size(); ++k) + for (unsigned int k = 0; k < width; ++k) if (t1[d][k] < t2[d][k] - tolerance) return true; else if (t1[d][k] > t2[d][k] + tolerance) @@ -3416,17 +3415,16 @@ namespace internal - template + template template bool - FPArrayComparator::operator()( - const Tensor<2, dim, Tensor<1, VectorizedArrayType::size(), Number>> &t1, - const Tensor<2, dim, Tensor<1, VectorizedArrayType::size(), Number>> &t2) - const + FPArrayComparator::operator()( + const Tensor<2, dim, Tensor<1, width, Number>> &t1, + const Tensor<2, dim, Tensor<1, width, Number>> &t2) const { for (unsigned int d = 0; d < dim; ++d) for (unsigned int e = 0; e < dim; ++e) - for (unsigned int k = 0; k < VectorizedArrayType::size(); ++k) + for (unsigned int k = 0; k < width; ++k) if (t1[d][e][k] < t2[d][e][k] - tolerance) return true; else if (t1[d][e][k] > t2[d][e][k] + tolerance) @@ -3436,10 +3434,10 @@ namespace internal - template + template template bool - FPArrayComparator::operator()( + FPArrayComparator::operator()( const std::array, dim + 1> &t1, const std::array, dim + 1> &t2) const { diff --git a/source/matrix_free/mapping_info.cc b/source/matrix_free/mapping_info.cc index 35fafd4f92..666353c281 100644 --- a/source/matrix_free/mapping_info.cc +++ b/source/matrix_free/mapping_info.cc @@ -31,31 +31,34 @@ DEAL_II_NAMESPACE_OPEN #if SPLIT_INSTANTIATIONS_INDEX == 0 -template struct internal::MatrixFreeFunctions:: - FPArrayComparator>; -template struct internal::MatrixFreeFunctions:: - FPArrayComparator>; +template struct internal::MatrixFreeFunctions::FPArrayComparator; +template struct internal::MatrixFreeFunctions::FPArrayComparator; + +template struct internal::MatrixFreeFunctions::FPArrayComparator< + VectorizedArray>; +template struct internal::MatrixFreeFunctions::FPArrayComparator< + VectorizedArray>; # if (DEAL_II_VECTORIZATION_WIDTH_IN_BITS >= 128 && defined(__SSE2__)) || \ (DEAL_II_VECTORIZATION_WIDTH_IN_BITS >= 128 && defined(__ALTIVEC__)) -template struct internal::MatrixFreeFunctions:: - FPArrayComparator>; -template struct internal::MatrixFreeFunctions:: - FPArrayComparator>; +template struct internal::MatrixFreeFunctions::FPArrayComparator< + VectorizedArray>; +template struct internal::MatrixFreeFunctions::FPArrayComparator< + VectorizedArray>; # endif # if DEAL_II_VECTORIZATION_WIDTH_IN_BITS >= 256 && defined(__AVX__) -template struct internal::MatrixFreeFunctions:: - FPArrayComparator>; -template struct internal::MatrixFreeFunctions:: - FPArrayComparator>; +template struct internal::MatrixFreeFunctions::FPArrayComparator< + VectorizedArray>; +template struct internal::MatrixFreeFunctions::FPArrayComparator< + VectorizedArray>; # endif # if DEAL_II_VECTORIZATION_WIDTH_IN_BITS >= 512 && defined(__AVX512F__) -template struct internal::MatrixFreeFunctions:: - FPArrayComparator>; -template struct internal::MatrixFreeFunctions:: - FPArrayComparator>; +template struct internal::MatrixFreeFunctions::FPArrayComparator< + VectorizedArray>; +template struct internal::MatrixFreeFunctions::FPArrayComparator< + VectorizedArray>; # endif #endif