Skip to content

Use random generator from C++11 instead of from Boost in module filters #2964

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

Closed

Conversation

SunBlack
Copy link
Contributor

@SunBlack SunBlack commented Apr 3, 2019

Separation from #2956 due to the need to adapt tests.

@taketwo
Copy link
Member

taketwo commented Apr 5, 2019

From the CI output looks like metslib needs Boost random header to be included explicitly. I'd suggest to add it for now, even though we will probably get rid of it later (#2954).

@SunBlack
Copy link
Contributor Author

SunBlack commented Apr 5, 2019

Interesting that changes in module filters module affects recognition. As already mentioned in #2956 I suggest to first merge #2956 and after this all other PRs related to this. This would fix include error, too (see here)

@taketwo
Copy link
Member

taketwo commented Apr 14, 2019

#2956 was merged, could you please rebase this one?

@taketwo taketwo added the needs: author reply Specify why not closed/merged yet label Apr 14, 2019
@SunBlack SunBlack force-pushed the random_generator_filters branch from 77c99fd to 8531106 Compare April 15, 2019 10:09
@SunBlack SunBlack force-pushed the random_generator_filters branch from 8531106 to 1849da3 Compare April 23, 2019 14:41
@SergioRAgostinho SergioRAgostinho added changelog: ABI break Meta-information for changelog generation and removed needs: author reply Specify why not closed/merged yet labels Apr 27, 2019
Copy link
Member

@SergioRAgostinho SergioRAgostinho left a comment

Choose a reason for hiding this comment

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

This looks ok to me, so I assume it's time to have a look at the outputs from the unit tests just to confirm if updating values is the way to go.

@SergioRAgostinho SergioRAgostinho added needs: code review Specify why not closed/merged yet needs: author reply Specify why not closed/merged yet labels May 2, 2019
Co-Authored-By: SunBlack <SunBlack@users.noreply.github.com>
@SergioRAgostinho
Copy link
Member

Proposal to remove these useless lines.

EXPECT_EQ (1412, (*walls_indices)[0]);
EXPECT_EQ (1943, (*walls_indices)[walls_indices->size () / 4]);
EXPECT_EQ (2771, (*walls_indices)[walls_indices->size () / 2]);
EXPECT_EQ (3215, (*walls_indices)[walls_indices->size () * 3 / 4]);
EXPECT_EQ (2503, (*walls_indices)[walls_indices->size () - 1]);

@SergioRAgostinho SergioRAgostinho added status: needs decision and removed needs: code review Specify why not closed/merged yet needs: author reply Specify why not closed/merged yet labels May 3, 2019
@taketwo
Copy link
Member

taketwo commented May 3, 2019

Yep, these lines are not very helpful. But can we add at least some test for the output walls_indices? Otherwise we are not really testing anything. I will need to have a deeper look.

@SergioRAgostinho SergioRAgostinho mentioned this pull request May 28, 2019
11 tasks
@Neumann-A
Copy link

@kunaltyagi
Copy link
Member

MSVC is rather slow

But they could have just copied Boost 😛 IIRC, some instances have already undergone the transformation. Correct me if I'm wrong, but it seems that the code paths are performance critical.

@Neumann-A
Copy link

Neumann-A commented Jan 24, 2020

word of advice: Instead of depending directly on boost::random or std::random use/introduce pcl::random which is just an alias for either one of those which can be switched using a preprocessor definition like USE_BOOST_RANDOM. This way you can easily switch between implementations without changing a lot of code all in your codebase. Maybe there will be a std::random2 somewhere in the future

@kunaltyagi
Copy link
Member

Maybe there will be a std::random2 somewhere in the future

I wouldn't hold my breath. See std::regex for proof.

As for macro flags, that's sorta what I did with pcl::shared_ptr, but I fear compile times might increase if we put all these in a common file or have lots of files with just these compile-time switches if we use a different file for a different alias.

@Neumann-A
Copy link

but I fear compile times might increase

runtime is more important than compile time.......if your change introduces a 2.5x speed degredation on windows people will probably be not happy with it ;) And this applies to cl as well as clang-cl users if VS STL is used.

@kunaltyagi kunaltyagi mentioned this pull request Feb 21, 2020
2 tasks
@kunaltyagi kunaltyagi added kind: proposal Type of issue and removed modernization labels Feb 22, 2020
@kunaltyagi kunaltyagi added this to the pcl-1.12.0 milestone May 7, 2020
@stale
Copy link

stale bot commented Jun 6, 2020

Marking this as stale due to 30 days of inactivity. Commenting or adding a new commit to the pull request will revert this.

@stale stale bot added the status: stale label Jun 6, 2020
@kunaltyagi kunaltyagi modified the milestones: pcl-1.12.0, pcl-1.13.0 Jun 30, 2021
@stale stale bot removed the status: stale label Jun 30, 2021
@larshg larshg removed this from the pcl-1.13.0 milestone Oct 17, 2022
@mvieth mvieth added this to the pcl-1.14.0 milestone Oct 18, 2022
@mvieth
Copy link
Member

mvieth commented Nov 8, 2023

So, I just benchmarked VoxelGridCovariance::getDisplayCloud with gcc/libstdc++, and it takes 2.8 times longer if std::mt19937 and std::normal_distribution are used, and 1.6 times longer if only boost::mt19937 is replaced with std::mt19937. Boost uses the Ziggurat method while libstdc++ (gcc) and libc++ (llvm) and MSVC STL all three seem to use the Marsaglia method, which may explain the speed difference partially (but not completely).
So I would vote to leave boost::mt19937 and boost:normal_distribution untouched in voxel_grid_covariance.hpp for now, and close this pull request. normal_space.h[pp] has been adapted by #3862
@larshg What do you think?

@larshg
Copy link
Contributor

larshg commented Nov 9, 2023

Lets keep using boost for now.

@larshg larshg closed this Nov 9, 2023
@SunBlack SunBlack deleted the random_generator_filters branch January 5, 2024 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: ABI break Meta-information for changelog generation kind: proposal Type of issue module: filters
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants