Skip to content

[GPU] Use C++11 std::atomic instead of non-standard extensions#4807

Merged
mvieth merged 11 commits intoPointCloudLibrary:masterfrom
FabianSchuetze:atomics
Dec 22, 2021
Merged

[GPU] Use C++11 std::atomic instead of non-standard extensions#4807
mvieth merged 11 commits intoPointCloudLibrary:masterfrom
FabianSchuetze:atomics

Conversation

@FabianSchuetze
Copy link
Copy Markdown
Contributor

As mentioned in #3987 we can use the memory model of c++11 to replace (outdated) cv code. This PR tries to implement the suggestions in the issue. I always find the atomic reference counting a bit strange, but it is implemented the same way in the std::shared_ptr, and I think it's good to stick with it.

I am looking forward to any suggestions and comments!

Copy link
Copy Markdown
Member

@kunaltyagi kunaltyagi left a comment

Choose a reason for hiding this comment

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

We can also make the default value of refcount 0 to align more with shared_ptr, but not in this PR

Comment thread gpu/containers/src/device_memory.cpp Outdated
Comment thread gpu/containers/src/device_memory.cpp Outdated
Comment thread gpu/containers/src/device_memory.cpp
@kunaltyagi kunaltyagi changed the title use c++11 atomics [tries to address #3987] [GPU] Use C++11 std::atomic instead of non-standard extensions Jun 21, 2021
@kunaltyagi kunaltyagi added changelog: deprecation Meta-information for changelog generation module: gpu labels Jun 21, 2021
@FabianSchuetze
Copy link
Copy Markdown
Contributor Author

Thank you so much, Kunal, for the review! As always, all the comments are very helpful and I will incorporate them!

@mvieth
Copy link
Copy Markdown
Member

mvieth commented Sep 27, 2021

@FabianSchuetze What is the status here? Are you still working on this pull request?

@FabianSchuetze
Copy link
Copy Markdown
Contributor Author

I beg your pardon @mvieth for the radio silence & thank you for pinging me. I changed jobs and moved. That should not have prevented me from continuing to work on this but it did. I made another commit and look forward to the feedback!

Comment thread gpu/containers/src/device_memory.cpp Outdated
Comment thread gpu/containers/src/device_memory.cpp
Comment thread gpu/containers/src/device_memory.cpp Outdated
Comment thread gpu/containers/src/device_memory.cpp Outdated

#include <pcl/gpu/containers/device_memory.h>
#include <pcl/gpu/utils/safe_call.hpp>
#include <pcl/pcl_macros.h>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this included for PCL_DEPRECATED or something else? It is always nice to add an explanation like ...macros.h> // for PCL_DEPRECATED.
Is it okay to assume that HAVE_CUDA is somehow included or would it be safer to explicitly include pcl_config.h?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the comment, Markus! I have added the explanation and think this is a nice addition indeed - thanks. I am not sure whether to include pcl_config.h. Do you know what common practice for PCL is?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would say pcl_config.h should be included because HAVE_CUDA is used in line 45 and it is defined in pcl_config.h, so it should be best to include it directly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have tried to add the header, as you suggested, @mvieth . Thanks for pointing this out!

Copy link
Copy Markdown
Contributor

@larshg larshg left a comment

Choose a reason for hiding this comment

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

I have run the unit test we have enabled for GPUl, so hopefully they cover the device_memory usage 😄

Copy link
Copy Markdown
Member

@kunaltyagi kunaltyagi left a comment

Choose a reason for hiding this comment

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

I have run the unit test
Macro is in cpp file

  • Ci is green

No objections from my side

@mvieth mvieth added this to the pcl-1.13.0 milestone Dec 6, 2021
Copy link
Copy Markdown
Member

@mvieth mvieth left a comment

Choose a reason for hiding this comment

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

Thank you @FabianSchuetze

@mvieth mvieth merged commit cf58fb5 into PointCloudLibrary:master Dec 22, 2021
themightyoarfish pushed a commit to themightyoarfish/pcl that referenced this pull request Jan 5, 2022
…ntCloudLibrary#4807)

* use c++11 atomics

* missing linebreak

* address PR comments

* should compile now

* improved fetch_sub

* init

* address comments for PR

* address comments for PR, again

* fixed assignment operator and annotated include

* added include for HAVE_CUDA

* correct order
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: deprecation Meta-information for changelog generation module: gpu

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants