]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Need to disable CellSimilarity when the number of threads is greater than one because...
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Mon, 9 Dec 2013 11:35:24 +0000 (11:35 +0000)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Mon, 9 Dec 2013 11:35:24 +0000 (11:35 +0000)
git-svn-id: https://svn.dealii.org/trunk@31950 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/8.0.0-vs-8.1.0.h
deal.II/source/fe/fe_values.cc

index acaaa648e33ce77d0f1a82e2ddbf4d1070e615ed..4afef43f2f5c0348ee47a27d39407623c7b69ddc 100644 (file)
@@ -259,6 +259,17 @@ inconvenience this causes.
 <h3>Specific improvements</h3>
 
 <ol>
+  <li> Fixed: Since the introduction of ThreadLocalStorage in version 8.0, the
+  way in which FEValues objects visit cells in a parallel assembly loop is no
+  longer deterministic. Therefore, the detection of CellSimilarity that can
+  speed up computations of certain geometric quantities (shape gradients) on
+  cells that are translations is disabled when the number of threads is
+  greater than one. This produces somewhat slower code (usually not more than
+  a few percent) but ensures exact reproducibility of results.
+  <br>
+  (Martin Kronbichler, Wolfgang Bangerth, 2013/12/09)
+  </li>
+
   <li> Fixed: Several functions in namespace GridTools were not instantiated
   for parallel::distributed::Triangulation objects. This is now fixed.
   <br>
index a0279383206c15433ad48d0a6b3680c308a0e03a..639d937fd924a9f7e8522b7266b5e3cabe606321 100644 (file)
@@ -15,6 +15,7 @@
 // ---------------------------------------------------------------------
 
 #include <deal.II/base/memory_consumption.h>
+#include <deal.II/base/multithread_info.h>
 #include <deal.II/base/quadrature.h>
 #include <deal.II/lac/vector.h>
 #include <deal.II/lac/block_vector.h>
@@ -3256,15 +3257,33 @@ void
 FEValuesBase<dim,spacedim>::check_cell_similarity
 (const typename Triangulation<dim,spacedim>::cell_iterator &cell)
 {
-  // case that there has not been any cell
-  // before
+  // 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 need to
+  // disable CellSimilarity 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.
+  //
+  // TODO: Is it reasonable to introduce a flag "unsafe" in the constructor of
+  // FEValues to re-enable this feature?
+  if (multithread_info.n_threads() > 1)
+    {
+      cell_similarity = CellSimilarity::none;
+      return;
+    }
+
+  // case that there has not been any cell before
   if (this->present_cell.get() == 0)
     cell_similarity = CellSimilarity::none;
   else
-    // in MappingQ, data can have been
-    // modified during the last call. Then,
-    // we can't use that data on the new
-    // cell.
+    // in MappingQ, data can have been modified during the last call. Then, we
+    // can't use that data on the new cell.
     if (cell_similarity == CellSimilarity::invalid_next_cell)
       cell_similarity = CellSimilarity::none;
     else
@@ -3282,8 +3301,7 @@ FEValuesBase<dim,spacedim>::check_cell_similarity
           != cell->direction_flag() )
         cell_similarity =  CellSimilarity::inverted_translation;
     }
-  // TODO: here, one could implement other
-  // checks for similarity, e.g. for
+  // TODO: here, one could implement other checks for similarity, e.g. for
   // children of a parallelogram.
 }
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.