-
Notifications
You must be signed in to change notification settings - Fork 292
Mark restore_array const #4156
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
base: devel
Are you sure you want to change the base?
Mark restore_array const #4156
Conversation
Job Coverage, step Generate coverage on 944850d wanted to post the following: Coverage
Warnings
This comment will be updated on new commits. |
Ok, let's pump the brakes on this. @lindsayad pointed out that there may be issues with race conditions in threaded regions. |
A few thoughts:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's workout the discussion a bit
Could we maybe use a sentinel pattern for this? Two versions, one Read/Write one Read-only, the constructor calls the appropriate get method. The sentinel has a method to access the pointer, the destructor calls the appropriate restore method. I'd love to keep raw access available, if only for experimental code that allows for fast copies between compute devices. |
I think that's a nice idea |
IIRC Derek's changes were purely for performance. I'd agree that figuring out exactly how much performance would be nice. I like the idea of splitting our helper methods into const and non-const versions rather than letting read vs write be a parameter. I hate the idea of exposing these methods to the user. That would require users to add Petsc-specific calls for non-Petsc-specific code, and to manually manage more complication. I love the sentinel pattern idea in theory. It's kind of embarrassing that we still have pairs of C functions like this that don't yet have an RAII wrapper, now that I think about it. I guess the names are "Set/Restore" instead of the usual "Create/Destroy" and that was enough for it to slip past us? |
What are you referring to? The sentinel pattern idea? |
I'm sure Roy dislikes the idea of special treatment for PETSc vectors. I do understand that from his library developer standpoint, but from my side I wouldn't mind having an API for my 99-100% use-case. |
I'm referring to "eliminate these helper methods and put the code into the APIs". Or maybe I misunderstood you? We've got exposed |
Definitely not. I was suggesting that the non-const branch of |
Closes #4155