]> https://gitweb.dealii.org/ - dealii.git/commitdiff
PreconditionChebyshev: reduce number of writes by one 14242/head
authorPeter Munch <peterrmuench@gmail.com>
Tue, 6 Sep 2022 11:46:01 +0000 (13:46 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Tue, 6 Sep 2022 14:31:00 +0000 (16:31 +0200)
include/deal.II/lac/precondition.h

index 680c03b6ca1fb4eb1db380fd6c6ceceb5994e38a..2972ddc408cd1242b509de2bffddd18835593b89 100644 (file)
@@ -2819,7 +2819,12 @@ namespace internal
             //           + f_2 * P^{-1} * (b-A*x^{n})
             DEAL_II_OPENMP_SIMD_PRAGMA
             for (std::size_t i = begin; i < end; ++i)
-              solution_old[i] =
+              // for efficiency reason, write back to temp_vector, which is
+              // already modified during vmult (in best case, the modified
+              // values are not written back to main memory yet so that
+              // we do not have to pay additional costs for writing and
+              // read-for-ownershop)
+              tmp_vector[i] =
                 factor1_plus_1 * solution[i] - factor1 * solution_old[i] +
                 factor2 * matrix_diagonal_inverse[i] * (rhs[i] - tmp_vector[i]);
           }
@@ -2892,13 +2897,11 @@ namespace internal
           // nothing to do here because we can immediately write into the
           // solution vector without remembering any of the other vectors
         }
-      else if (iteration_index == 1)
+      else
         {
           solution.swap(temp_vector1);
           solution_old.swap(temp_vector1);
         }
-      else
-        solution.swap(solution_old);
     }
 
     // selection for diagonal matrix around parallel deal.II vector
@@ -2934,13 +2937,11 @@ namespace internal
           // nothing to do here because we can immediately write into the
           // solution vector without remembering any of the other vectors
         }
-      else if (iteration_index == 1)
+      else
         {
           solution.swap(temp_vector1);
           solution_old.swap(temp_vector1);
         }
-      else
-        solution.swap(solution_old);
     }
 
     // We need to have a separate declaration for static const members
@@ -3031,13 +3032,11 @@ namespace internal
           // nothing to do here because we can immediately write into the
           // solution vector without remembering any of the other vectors
         }
-      else if (iteration_index == 1)
+      else
         {
           solution.swap(temp_vector1);
           solution_old.swap(temp_vector1);
         }
-      else
-        solution.swap(solution_old);
     }
 
     template <typename MatrixType, typename PreconditionerType>

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.