From: Daniel Arndt Date: Tue, 29 Aug 2023 17:12:28 +0000 (-0400) Subject: Adddress review comments X-Git-Tag: relicensing~507^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F15930%2Fhead;p=dealii.git Adddress review comments Co-authored-by: Wolfgang Bangerth --- diff --git a/include/deal.II/fe/fe_values_base.h b/include/deal.II/fe/fe_values_base.h index 70375e33a4..979b19e74d 100644 --- a/include/deal.II/fe/fe_values_base.h +++ b/include/deal.II/fe/fe_values_base.h @@ -227,13 +227,23 @@ public: * The detection of simple geometries with CellSimilarity is sensitive to the * first cell detected. When using multiple threads, each thread might get a * thread local copy of the FEValues object that is initialized to the first - * cell the thread sees. As this cell might be differ between runs and number - * of threads used, this slight deviation leads to difference in roundoff - * errors that propagate through the program. Therefore, the CellSimilarity - * check is disabled by default in case more than one thread is used. + * cell the thread sees. As this cell might be different between runs and + * number of threads used, this slight deviation leads to difference in + * roundoff errors that propagate through the program. Therefore, deal.II + * disables the CellSimilarity check by default in programs that use more than + * one thread. This function can be used to disable this behavior: When + * called, FEValues objects will always do the similarity check, even in cases + * where the program uses multiple threads. This substantially accelerates the + * operations of FEValues because many operations can be avoided if a cell is, + * for example, just a translation of the previous cell. On the other hand, + * you might get results that differ by an amount proportional to round-off + * between the case of using or not using cell similarity information, and + * because the order of cells assigned to individual threads may differ from + * run to run, when you call this function you may end up with results that + * differ by round-off between runs of the same program. */ void - allow_check_for_cell_similarity(bool allow); + always_allow_check_for_cell_similarity(const bool allow); /// @name Access to shape function values /// diff --git a/include/deal.II/matrix_free/cuda_matrix_free.templates.h b/include/deal.II/matrix_free/cuda_matrix_free.templates.h index c72b6f090b..3709471ae3 100644 --- a/include/deal.II/matrix_free/cuda_matrix_free.templates.h +++ b/include/deal.II/matrix_free/cuda_matrix_free.templates.h @@ -118,7 +118,7 @@ namespace CUDAWrappers { local_dof_indices.resize(data->dofs_per_cell); lexicographic_dof_indices.resize(dofs_per_cell); - fe_values.allow_check_for_cell_similarity(true); + fe_values.always_allow_check_for_cell_similarity(true); } diff --git a/source/fe/fe_values_base.cc b/source/fe/fe_values_base.cc index cb932cdb1b..1976ced627 100644 --- a/source/fe/fe_values_base.cc +++ b/source/fe/fe_values_base.cc @@ -249,7 +249,8 @@ FEValuesBase::~FEValuesBase() template void -FEValuesBase::allow_check_for_cell_similarity(bool allow) +FEValuesBase::always_allow_check_for_cell_similarity( + const bool allow) { check_for_cell_similarity_allowed = allow; } @@ -1416,19 +1417,7 @@ inline void FEValuesBase::check_cell_similarity( const typename Triangulation::cell_iterator &cell) { - // Unfortunately, the detection of simple geometries with CellSimilarity is - // sensitive to the first cell detected. When doing this with multiple - // threads, each thread will get its own scratch data object with an - // FEValues object in the implementation framework from late 2013, which is - // initialized to the first cell the thread sees. As this number might - // different between different runs (after all, the tasks are scheduled - // dynamically onto threads), this slight deviation leads to difference in - // roundoff errors that propagate through the program. Therefore, we - // disable CellSimilarity by default in case there is more than one thread in - // the problem. This will likely not affect many MPI test cases as there - // multithreading is disabled on default, but in many other situations - // because we rarely explicitly set the number of threads. - if (!check_for_cell_similarity_allowed) + if (check_for_cell_similarity_allowed == false) { cell_similarity = CellSimilarity::none; return;