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

Apply clangformat to gpu code #4719

Merged

Conversation

FabianSchuetze
Copy link
Contributor

As discussed with @kunaltyagi in PR #4677, we thought clang-formatting the GPU codebase in a batched commit might be helpful. This commit tries to do that. I applied clang-format with the following lines of code:

find . -name '*.h' -or -name '*.hpp' -or -name '*.cpp' | xargs /usr/bin/clang-format-10 -i -style=file

The command finds all files with h, hpp, or cpp ending recursively in the GPU folder and formats it according to the .clang-format file.

@kunaltyagi
Copy link
Member

Would it be possible to split this PR? 50k lines of diff to parse is not easy

@FabianSchuetze
Copy link
Contributor Author

Splitting the PR is a great idea! I will think of logical and manageable chunks and the commit again. Thanks for the comment!

@FabianSchuetze
Copy link
Contributor Author

I reverted the previous commit and formatted only the code in the container folder. Once we have discussed these changes, I can commit another folder and we can discuss it again. We can keep the discussion confined to one PR and do not have to create several different PRs. Do you think this is a viable strategy, @kunaltyagi ?

Copy link
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.

Can we also add gpu/containers to the format.sh file?

gpu/containers/include/pcl/gpu/containers/device_array.h Outdated Show resolved Hide resolved
gpu/containers/include/pcl/gpu/containers/device_array.h Outdated Show resolved Hide resolved
Copy link
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.

4/10 files reviewed

PS: your format CI is failing

{ DeviceMemory::operator=(other); return *this; }
template <class T>
inline DeviceArray<T>::DeviceArray()
{}
Copy link
Member

Choose a reason for hiding this comment

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

Let's separate these functions with newlines

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that is an excellent idea! I wonder why clang-format cannot do that automatically for us, but I couldn't find a corresponding setting. You don't know one either?

Copy link
Member

Choose a reason for hiding this comment

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

@kunaltyagi
Copy link
Member

You need to run clang-format 2-3 times till it settles on an equilibrium. See the functions offending the clang-format:
https://dev.azure.com/PointCloudLibrary/pcl/_build/results?buildId=18880&view=logs&j=84ba2080-ade3-55e3-f209-94ce73f9d406&t=9838d42f-a715-5615-242f-7e73bf03078b&l=1

@FabianSchuetze
Copy link
Contributor Author

Thanks for your comments and explanations! I hope I did address your concerns; the files look much better now!

Copy link
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.

The print statements in initiaization.cpp don't look pretty, but apart from that, LGTM.

I'll approve if we can't improve the visual feel of print statements (it's a minor issue that's all)

rows() const;

/** \brief Returns stride between two consecutive rows in bytes for internal buffer.
* Step is stored always and everywhere in bytes!!! */
Copy link
Member

Choose a reason for hiding this comment

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

I think the line regarding Step is stored... bytes!!! can be converted to a note or a warning. Not relevant to this PR

{ DeviceMemory::operator=(other); return *this; }
template <class T>
inline DeviceArray<T>::DeviceArray()
{}
Copy link
Member

Choose a reason for hiding this comment

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

gpu/containers/src/initialization.cpp Outdated Show resolved Hide resolved
@FabianSchuetze
Copy link
Contributor Author

Thanks for the review, @kunaltyagi! The print statements in initialization.cpp are indeed not pretty. Once std::format is supported by the compilers, we could rewrite the print functions with output streams and std::format.

Copy link
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.

minor comments aside, lgtm

gpu/containers/src/initialization.cpp Show resolved Hide resolved
gpu/containers/src/initialization.cpp Outdated Show resolved Hide resolved
@kunaltyagi
Copy link
Member

kunaltyagi commented Jun 12, 2021

This has been a long time coming 😆

@mvieth
Copy link
Member

mvieth commented Jun 13, 2021

@kunaltyagi Could you run the "Generate Documentation" CI to check if no doxygen warnings appear?

@kunaltyagi
Copy link
Member

Done. https://dev.azure.com/PointCloudLibrary/pcl/_build/results?buildId=19298&view=results

@FabianSchuetze
Copy link
Contributor Author

Thank you so much, Kunal and Markus, for guiding me through this!

@kunaltyagi kunaltyagi requested a review from mvieth June 14, 2021 15:31
Copy link
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.

Seems fine

@kunaltyagi kunaltyagi changed the title applied clangformat to gpu code Apply clangformat to gpu code Jun 15, 2021
@kunaltyagi kunaltyagi merged commit df4bd4a into PointCloudLibrary:master Jun 15, 2021
tin1254 pushed a commit to tin1254/pcl that referenced this pull request Aug 10, 2021
mvieth pushed a commit to mvieth/pcl that referenced this pull request Dec 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants