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

Octree Precompile #1639

Merged

Conversation

stefanbuettner
Copy link
Contributor

Hey there,

based on the mailing list issue Defining Octree Containers it seemed that the PCL_NO_PRECOMPILE mechanism was not fully implemented in the octree module.

This PR should fix that and also tries to minimize the included headers by removing unnecessary ones and removing #include <pcl/octree/octree.h> throughout the library.

For a non-working example prior to this PR see https://gist.github.com/stefanbuettner/0dcde8c6593dbb667ef74c60662cfafb.

Cheers,
Stefan

@@ -247,9 +247,8 @@ namespace pcl

}

//#ifdef PCL_NO_PRECOMPILE
// Note: Don't precompile this octree type to speed up compilation. It's probably rarely used.
Copy link
Member

Choose a reason for hiding this comment

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

This octree type drives the Supervoxel Clustering algorithm, which is extremely popular according to my feelings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So it should be added to the precompilation unit?

Copy link
Member

Choose a reason for hiding this comment

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

It's being instantiated here. Not really where I would look for it normally. I would say for now leave it as it was, unless there's a solid reason to not precompile it.

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 comment should rather says something like:

Do not precompile this octree type because it is typically used with custom leaf containers.

@taketwo
Copy link
Member

taketwo commented Jun 21, 2016

LGTM

@@ -39,7 +39,7 @@
#ifndef PCL_OCTREE_CONTAINER_H
#define PCL_OCTREE_CONTAINER_H

#include <string.h>
//#include <string.h>
Copy link
Member

Choose a reason for hiding this comment

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

leftover?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, right. Thx

@SergioRAgostinho SergioRAgostinho added this to the pcl-1.8.1 milestone Jul 14, 2016
@SergioRAgostinho SergioRAgostinho added the needs: testing Specify why not closed/merged yet label Jul 14, 2016
@SergioRAgostinho
Copy link
Member

So, the final PR that I need to review. This is personally the most challenging PR to understand out of all selected for 1.8.1. Please bear with me if some of the comments/questions seem noobish.

@@ -39,6 +39,8 @@
#ifndef PCL_OCTREE_2BUF_BASE_HPP
#define PCL_OCTREE_2BUF_BASE_HPP

#include <pcl/octree/octree2buf_base.h>
Copy link
Member

Choose a reason for hiding this comment

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

Is this really necessary? I normally only see the corresponding *.hpp being included at the end of the *.h file and the *.hpp never includes the corresponding *.h .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, you might be right. Still compiles without including anything here.
I'll remove it.

Copy link
Member

Choose a reason for hiding this comment

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

So, remove this?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I've just realized that you remove it in a later commit.

@SergioRAgostinho SergioRAgostinho added needs: author reply Specify why not closed/merged yet and removed needs: testing Specify why not closed/merged yet labels Aug 20, 2016
@SergioRAgostinho
Copy link
Member

Ping @stefanbuettner. I was wanting to merge in the short future to give enough time to "explode".

@stefanbuettner
Copy link
Contributor Author

Hey Sergio,
sorry for the late reply. Hadn't much time lately. Hope I can have a look at it again over the weekend.

@SergioRAgostinho
Copy link
Member

SergioRAgostinho commented Jun 27, 2017

Hey @stefanbuettner. Do you mind rebasing this to the current HEAD? I'm a little out of context since the last time I checked this thoroughly but this should be good to merge.

Edit: Also if possible squash this into three commits:

  • One fixing the error linking (1)
  • Another aggregating all tweaks to include files and comments (2, 3, 4, 6, 7)
  • Setting the PCL_NO_PRECOMPILE definition in modules which need it (5)

@stefanbuettner
Copy link
Contributor Author

Done.

@taketwo taketwo removed the needs: author reply Specify why not closed/merged yet label Jun 27, 2017
The octree module didn't respect the PCL_NO_PRECOMPILE mechanism. This
commit fixes that by implementing it for percompiled classes and fixing
includes for non-precompiled classes.
* Remove unnecessary includes and fix compilation error in
  OctreePointcloudAdjacency.
* Add OctreePointCloudAdjacency to octree.h and add comment for instantiation.
* Replace general octree.h includes by specific ones.
  Only include what is necessary to minimize dependencies and reduce
  build times.
* Remove leftover string comment
…ners.

Using PCL_NO_PRECOMPILE in cpp files makes sense, since code has to be
generated anyway. The scope of the preprocessor definition is the cpp
file itself, so it doesn't pollute something.
And since all classes are instantiated with other template parameter
values, there is no duplicate code.
@stefanbuettner
Copy link
Contributor Author

Just changed the comment you suggested, @taketwo.

@taketwo
Copy link
Member

taketwo commented Jun 27, 2017

Thanks. The pipeline succeeded last time, so I cancelled this new build after changing comment.

@SergioRAgostinho SergioRAgostinho merged commit ca664ce into PointCloudLibrary:master Jun 27, 2017
template class pcl::SupervoxelClustering<pcl::PointXYZRGBA>;
template class PCL_EXPORTS pcl::SupervoxelClustering<pcl::PointXYZ>;
template class PCL_EXPORTS pcl::SupervoxelClustering<pcl::PointXYZRGB>;
template class PCL_EXPORTS pcl::SupervoxelClustering<pcl::PointXYZRGBA>;
Copy link
Member

Choose a reason for hiding this comment

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

@stefanbuettner Related #1909, why do we need to export these instantiation?

Copy link
Member

Choose a reason for hiding this comment

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

Just gave it a try and I can compile this without PCL_EXPORTS on linux, with both PCL_NO_PRECOMPILE=ON and OFF.

Copy link
Member

Choose a reason for hiding this comment

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

AFAIR PCL_EXPORTS is mostly relevant for Windows. Every time you forget to add it to class declaration Windows users come and report unresolved symbols :D. But in this case PCL_EXPORTS is already present in the declaration of SupervoxelClustering, so indeed I don't see why we need it here.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should consider applying the same mechanism to *nix. See https://gcc.gnu.org/wiki/Visibility

At least we would be able to identify problems in advance in linux.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe... do you want this to become a 236th issue in this repository? 😢

Copy link
Member

Choose a reason for hiding this comment

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

If I add it now it would only be 234 :) Nevertheless I think we should leave the idea there, so that "future people" remember it.

Copy link
Contributor Author

@stefanbuettner stefanbuettner Jun 29, 2017

Choose a reason for hiding this comment

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

I thought this should solve some unresolved symbols but from what I read while catching up on this issue, __declspec(dllexport) is only needed for template function specializations and not for template class specializations. So the PCL_EXPORTS probably shouldn't be there.

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.

3 participants