-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
[PPF] different execution time on different platforms #6217
Comments
the following code is pretty slow on ubuntu20.04:
|
Usually yes, but if you want to make sure, I would recommend to completely remove the installed PCL files (the ones in I assume you set |
yes, both pcl and my project set CMAKE_BUILD_TYPE "Release" CMakeCache.txt
|
If you post the point clouds you used in the code above, I can test how long it takes on my computer. Also, you could try switching to a different compiler on Ubuntu. Either a newer version of the same compiler, or to a completely different compiler (clang if you use gcc now, or gcc if you use clang now). Either way, I think it is unlikely that this is caused by a bug in PCL. |
it took me 550s to finish ppf, including hash search and registration. |
by the way, the type of point cloud is |
For me it takes roughly 200s. Most of the time is spent in |
Hi, I simply changed the hash calculation(in
|
Interesting. Why did you choose |
First of all, it should be noted that I am not an expert in this field. I remember that the advantage of using prime multiplication to calculate hash is that it is fast to compute. Since the choice of primes is random, it can effectively avoid collisions and has a more uniform distribution. Another highly recommended approach is to use
The rewritten |
But that is for the case that I wrote a simple program to test for hash collisions (not an exhaustive test, of course): std::size_t hashfunc(int a, int b, int c, int d) {
const std::size_t h1 = std::hash<int>{}(a);
const std::size_t h2 = std::hash<int>{}(b);
const std::size_t h3 = std::hash<int>{}(c);
const std::size_t h4 = std::hash<int>{}(d);
std::size_t seed = 0;
hash_combine_impl(seed, h1);
hash_combine_impl(seed, h2);
hash_combine_impl(seed, h3);
hash_combine_impl(seed, h4);
return seed;
}
int main() {
std::map<std::size_t, std::tuple<int, int, int, int>> contains;
for(int d=-30; d<50; ++d) {
std::cout << "d=" << d << std::endl;
for(int c=-30; c<30; ++c) {
for(int b=-30; b<30; ++b) {
for(int a=-30; a<30; ++a) {
std::size_t hash = hashfunc(a, b, c, d);
if(contains.count(hash)==1) {
if(std::get<0>(contains[hash])!=a || std::get<1>(contains[hash])!=b || std::get<2>(contains[hash])!=c || std::get<3>(contains[hash])!=d) {
std::cout << "Hash collision! " << a << " " << b << " " << c << " " << d << " " << std::get<0>(contains[hash]) << " " << std::get<1>(contains[hash]) << " " << std::get<2>(contains[hash]) << " " << std::get<3>(contains[hash]) << " " << hashfunc(a, b, c, d) << " " << hashfunc(std::get<0>(contains[hash]), std::get<1>(contains[hash]), std::get<2>(contains[hash]), std::get<3>(contains[hash])) << std::endl;
}
} else {
contains[hash]={a, b, c, d};
}
}
}
}
}
} and it is displaying lots of collisions. However, this one seems to work nicely: std::size_t hashfunc(int a, int b, int c, int d) {
//RS hash function https://www.partow.net/programming/hashfunctions/index.html
std::size_t b_ = 378551;
std::size_t a_ = 63689;
std::size_t hash = 0;
hash = hash * a_ + a;
a_ = a_ * b_;
hash = hash * a_ + b;
a_ = a_ * b_;
hash = hash * a_ + c;
a_ = a_ * b_;
hash = hash * a_ + d;
return hash; Perhaps you can test how fast your program runs if you use this one. |
I tried different hash functions on the same data, here is the results.
2、RS-hash after std::hash:12.3736 seconds
3、boost hash after std::hash——12.2473 seconds
4、origin version——513.917 seconds
|
Great, thanks for testing! So approach 1. RS-hash seems to be best. If you like, feel free to open a pull request to change the PCL code to that one. If you do, maybe don't define a separate |
same ppf code, it took about 6-7s on windows, but 700s on ubuntu!
pcl on both platforms is "release", and the same version 1.14.0.
usually, code runs faster on ubuntu than windows.
if i make and install "debug" version first and then switch to "release"(make and install too), it would be "release" version running?
what should i check? any feedback or suggestions are greatly appreciated.
The text was updated successfully, but these errors were encountered: