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

MGTwoLevelTransfer: Clean old vector content in prolongate_add #15288

Merged
merged 2 commits into from Jun 1, 2023

Conversation

kronbichler
Copy link
Member

This fixes a bug observed by @nfehn in exadg/exadg#453, where old content of a temporary vector would spoil the result. The reason is that we had a separate logic for DG elements that could set vector elements (rather than add-into) at some point, and forgot to clean that up. Our standard tests would not pick this up because we only check the transfer once, whereas it should run twice to expose this bug.

I could observe the bug in the test, returning vectors with entry 2 rather than 1 in some of the outputs, so this is a sensitive test for the bug I'm fixing.

@peterrum
Copy link
Member

@kronbichler Thank you for debugging this.

The reason is that we had a separate logic for DG elements that could set vector elements (rather than add-into) at some point, and forgot to clean that up.

We made the change here: eef0a63

What about reintroducing the logic? The right choice would be to use VectorSetter here

internal::VectorDistributorLocalToGlobal<Number, VectorizedArrayType>
writer;

for DG/inplace. What do you think? If you agree, I can make the modification.

Alternatively, I was thinking about keeping the internal vectors always clean, i.e., clearing after the usage them, similarly as we do with the ghost values. But I guess in total, we would do more work, since we sometimes simply copy the content of vectors, which does not require zeroing.

@kronbichler
Copy link
Member Author

You mean to use VectorSetter for the case !inplace, right? Because we do prolongate_add, so we need to do the other function.

Regarding clearing the vectors, I would prefer to minimize the work, which means clearing the vectors before use, rather than after. Another reason is that clearing before use is more stable if we start using the vectors in different functions and forget resetting them. The main goal should be to avoid using the temporary vectors and directly work with the dst vector of prolongate_add. We can't do that for all cases, though, so we need the other path.

@kronbichler
Copy link
Member Author

I think the setter would be a good approach.

@peterrum
Copy link
Member

!inplace, right?

Right. Let me know if I should implement that. After the recent refactoring, the information is not directly available anymore.

@kronbichler
Copy link
Member Author

I suggest we get this PR in to fix the error, and then look into the possible optimizations later.

@peterrum
Copy link
Member

peterrum commented Jun 1, 2023

@kronbichler I have fixed the failing test. Now CI should pass and we can merge.

@kronbichler
Copy link
Member Author

Thank you!

@kronbichler
Copy link
Member Author

I am confused why the PR is still shown as open, while https://github.com/dealii/dealii/commits/master shows that it has been merged. Any ideas? I guess we can simply close this one?

@kronbichler kronbichler merged commit e7e633e into dealii:master Jun 1, 2023
14 checks passed
@kronbichler kronbichler deleted the fix_mg_transfer branch August 10, 2023 16:39
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