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

Conversation

peterrum
Copy link
Member

@peterrum peterrum commented Sep 6, 2022

At the moment, we are modifying temp_vector1 during pre and vmult:

std::memset(temp_vector1.begin() + start_range,
0,
sizeof(Number) * (end_range - start_range));

matrix.vmult(
temp_vector1,
solution,

and solution_old during post:

solution_old[i] =
factor1_plus_1 * solution[i] - factor1 * solution_old[i] +
factor2 * matrix_diagonal_inverse[i] * (rhs[i] - tmp_vector[i]);

Modifying temp_vector1 during post and appropriate swappings allow to reduce the write operations by one.

Copy link
Member

@kronbichler kronbichler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good improvement, thank you. I do not understand how this could be overlooked previously.

Comment on lines 2822 to 2823
// for efficiency reason, write back to temp_vector that is
// already read (avoid read-for-ownership)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment is wrong. It is not the read that gets avoid (as we read solution_old below), but we can avoid writing temp_vector back to memory by replacing its volatile content (only needed in the subsequent formulas) by over-writing it with the useful content that previously went into solution_old.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the comment.

@kronbichler
Copy link
Member

/rebuild

@drwells drwells merged commit 75eeea8 into dealii:master Sep 6, 2022
mkghadban pushed a commit to OpenFCST/dealii that referenced this pull request Sep 7, 2022
PreconditionChebyshev: reduce number of writes by one
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants