From: Peter Munch Date: Tue, 6 Sep 2022 11:46:01 +0000 (+0200) Subject: PreconditionChebyshev: reduce number of writes by one X-Git-Tag: v9.5.0-rc1~988^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F14242%2Fhead;p=dealii.git PreconditionChebyshev: reduce number of writes by one --- diff --git a/include/deal.II/lac/precondition.h b/include/deal.II/lac/precondition.h index 680c03b6ca..2972ddc408 100644 --- a/include/deal.II/lac/precondition.h +++ b/include/deal.II/lac/precondition.h @@ -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