SAMRAI icon indicating copy to clipboard operation
SAMRAI copied to clipboard

hier::Patch should return shared_ptr by const reference

Open maikel opened this issue 7 years ago • 2 comments

Is there any reason why hier::Patch does return its class member of type std::shared_ptr's by value instead of by reference to const std::shared_ptr? Each time I want to access the hier::PatchGeometry or hier::PatchData members I have to take a lock to increase the reference count of std::shared_ptr. Returning references instead would allow having the freedom to decide for myself if I want to do this.

maikel avatar Oct 18 '18 10:10 maikel

Hey @maikel - I think this might just be a hangover from older implementations before we switched over to use std::shared_ptr.

We haven't noticed any performance implications in our applications due to returning the pointers by value. We would be happy to look through at a PR if you would like to make this change.

davidbeckingsale avatar Oct 18 '18 16:10 davidbeckingsale

Ok I will do a pull request soon for SAMRAI::hier::Patch. I wonder if one should sweep through the library and check this for consistency. To be honest, I haven't measured the difference. I just wondered about the generated assembly for (interfacing) our compute kernels.

maikel avatar Oct 19 '18 06:10 maikel