-
Notifications
You must be signed in to change notification settings - Fork 708
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
Fix poor attempt at thread safety #331
Comments
From kronbich...@gmail.com on August 22, 2014 12:20:58 Since this code was written by me (and is in FE_Q_Base, FE_DGQ, FESystem and now also FE_Nedelec), let me add a few comments (in particular since I had thought about a similar solution back then):
So from what I can judge correctness and performance in the current implementation is the same and it boils down to decide on whether we want simple data structures (current design) or to avoid assumptions on implementation details. I preferred the simplicity back then but really do not insist on that variant. |
From bange...@gmail.com on August 22, 2014 13:38:58 Fair enough, thanks for the explanation. I didn't mean to imply that the design in completely broken. I think it works in practice but relies on assumptions that may not be completely sound -- like you suggest, it depends on knowledge of how exactly the swap operation works. For the Nedelec element, there is also the issue that (if I read the code correctly, I don't have it here right now) we don't actually swap in the matrix but first resize it and later fill it. That's definitely fishy. My goal with this report was just to have it recorded somewhere that it is something we may want to look at at one point. Your explanations are definitely appreciated! |
From bange...@gmail.com on August 22, 2014 14:29:52
FE_DGQ and FE_Nedelec use a scheme whereby they defer construction of embedding and/or restriction matrices until they are in fact needed. The guard code looks like this:
The problem with this code is that the swap operation is not atomic: the first or second "if" may see a matrix that already has its size set but not the content yet. Or, worse, that doesn't have the size set yet, but has the elements already -- in which case it will be recomputed and the first thread to use the matrix may see temporary values while the second one recomputes the matrices.
The only way out is storing a boolean for each matrix indicating whether it is computed already, testing the boolean at the beginning and setting it at the very end.
Original issue: http://code.google.com/p/dealii/issues/detail?id=248
The text was updated successfully, but these errors were encountered: