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

Add PCL_WARNINGS_ARE_ERRORS CMake option and enable it in Ubuntu 16.04 CI job #3478

Merged
merged 3 commits into from
Nov 21, 2019

Conversation

taketwo
Copy link
Member

@taketwo taketwo commented Nov 20, 2019

This enables -Wall flag in Ubuntu 16.04 job, which is currently warning-free. The other pipelines still produce warnings; ticket #3379 will continue to track the progress towards having -Wall in all jobs.

-DPCL_ONLY_CORE_POINT_TYPES=ON \
-DPCL_WARNINGS_ARE_ERROS=ON \
Copy link
Member

@SergioRAgostinho SergioRAgostinho Nov 20, 2019

Choose a reason for hiding this comment

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

ERRORS instead of ERROS. The error is only here, which means the flag was not activated for this build.

@SergioRAgostinho SergioRAgostinho merged commit a7fdb7e into PointCloudLibrary:master Nov 21, 2019
@taketwo taketwo deleted the wall branch November 21, 2019 09:21
@taketwo
Copy link
Member Author

taketwo commented Nov 21, 2019

Oh wait, I think we have a problem here. The job failed two times with the same unit test and it does not look like a random failure. I assume this is because I changed the compiler flags.

@SergioRAgostinho
Copy link
Member

SergioRAgostinho commented Nov 21, 2019

I'm not really sure what to do in this scenario. I think we'll both agree that changing optimization and warning flags should not produce changes in the outcome of runtime logic (which doesn't run in parallel). But I definitely don't want that unit test rendering CI "useless".

Revert the last commit? The question is also whether you can replicate the failure in your environment.

@taketwo
Copy link
Member Author

taketwo commented Nov 21, 2019

The question is also whether you can replicate the failure in your environment.

Let's start with this. Though even if I can, not sure how to fix. Just change the number?

@SergioRAgostinho
Copy link
Member

SergioRAgostinho commented Nov 21, 2019

My only idea would be to follow the execution path and try to identify when did both cases diverge and started to produce different results. In C++ this is an extremely time consuming task.

At this moment I prioritize more CI than the GASD feature (11 citations 3 years after publication), so I'm open to just switch numbers.

@SergioRAgostinho
Copy link
Member

The gasd test is failing in my environment prior to your commits.

@taketwo
Copy link
Member Author

taketwo commented Dec 3, 2019

I think I nailed down the problem. The following lines have a numerical issue:

const Eigen::Vector4f p (shape_samples_[i].x, shape_samples_[i].y, shape_samples_[i].z, 0.0f);
const float d = p.norm ();
const float shape_grid_step = distance_normalization_factor / shape_half_grid_size_;
const float dist_hist_start = ((int) (d / shape_grid_step)) * shape_grid_step;
const float dist_hist_val = (d - dist_hist_start) / shape_grid_step;
const float dbin = dist_hist_val * shape_hists_size_;
// add sample to shape histograms, optionally performing interpolation
addSampleToHistograms (p, max_coord_, shape_half_grid_size_, shape_interp_, dbin, hist_incr_, shape_hists);

With a very unlucky case we get to the following instance:

p =   -0.103523 -0.0401704  0.0485457          0
d = 0.121192
shape_grid_step = 0.0403972
dist_hist_start = 0.121192
dist_hist_val = -1.84433e-07
dbin = -1.84433e-07

The target bin is a tiny negative number instead of zero. Later on, it is rounded and ends up in the bin -1.

I think the fix is to change how dist_hist_val is computed. If you do the math, it's nothing else but the fractional part of d / shape_grid_step, i.e. there is no reason to compute intermediate dist_hist_start variable.

@jpsml

@kunaltyagi
Copy link
Member

The target bin is a tiny negative number instead of zero. Later on, it is rounded and ends up in the bin -1

That's a crazy find @taketwo ...

So the fix could be:

float placeholder = d / shape_grid_step;
// can also call modf, but this works if placeholder is within range of long (which it needs to to have a decimal part)
float dist_hist_val = placeholder - static_cast<long int>(placeholder);
// for extra safety incase placeholder > LONG_MAX, dist_hist_val = std::min(1, dist_hist_val);

@taketwo
Copy link
Member Author

taketwo commented Dec 4, 2019

That's a crazy find @taketwo ...

Took me quite a few iterations of cout-based debugging on CI to find the issue 😆

Could you explain in more detail why your fix is preferable to modf? I had the following in mind:

float integral;
const float dist_hist_val = std::modf(d / shape_grid_step, &integral);

taketwo added a commit to taketwo/pcl that referenced this pull request Dec 4, 2019
taketwo added a commit to taketwo/pcl that referenced this pull request Dec 4, 2019
@kunaltyagi
Copy link
Member

Just that modf does a lot of housekeeping and if you know the domain of the variables, a subtraction with long int cast is faster than modf. The checks can't be optimized by compiler because it doesn't know the data domain (in most cases). Analogous to how x*x*x is faster than std::pow(x, 3). Minor concern, but might matter in a tight loop. Your code is ideal in almost all situations though.

@taketwo
Copy link
Member Author

taketwo commented Dec 5, 2019

Thanks for the explanation. I kept modf though since it's certainly correct and should not degrade the runtime compared to the old code.

Offtopic: sometimes I wonder, Kunal, where did you get all this knowledge 🕵️‍♂️

@kunaltyagi
Copy link
Member

High Performance Computing with Real Time constraints requires every shortcut to reduce compute power, increase IPC. It's a weird combination

@taketwo taketwo changed the title Treat compiler warnings as errors in Ubuntu 16.04 CI job Add PCL_WARNINGS_ARE_ERRORS CMake option and enable it in Ubuntu 16.04 CI job Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants