Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PreconditionChebyshev: reduce number of writes by one #14242

Merged
merged 1 commit into from
Sep 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 9 additions & 10 deletions include/deal.II/lac/precondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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>
Expand Down