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

Fix #656 by making SSurface::SplitInHalf thread safe. #665

Merged
merged 1 commit into from Aug 1, 2020

Conversation

phkahler
Copy link
Member

@phkahler phkahler commented Aug 1, 2020

The surface was being modified in SSurfaceSplitInHalf. Make a local copy instead.

SSurface::SplitInHalf was modifying the surface and then restoring it at the end. Make temporary copy instead.
@phkahler phkahler linked an issue Aug 1, 2020 that may be closed by this pull request
@ruevs
Copy link
Member

ruevs commented Aug 1, 2020

Still on a phone - otherwise I would test it myself.

So which is faster? Putting a critical section around this or making an extra on the stack copy of each surface multiple times per boolean operation?

Obsuously this may depend on many things, CPU, compiler, RAM but if the difference is drastic on some "typycal" system it may help to choose.

@ruevs
Copy link
Member

ruevs commented Aug 1, 2020

A different question is which is cleaner...

@phkahler
Copy link
Member Author

phkahler commented Aug 1, 2020

@ruevs You had some model that showed significant performance change with OpenMP. You might try both methods with that. Just put a "omp crtical" with { } around most of this function from before WeightControlPoints() to after the last UnWeightControlPoints(). compare that to this PR. I'm in favor of this approach because it fixes the underlying problem, and also modifying a surface and putting it back just seems like a bad idea, and this doesn't pollute the code with an extra #pragma

If you want to do some tests you might also try using OMP in SShell::CopyCurvesSplitAgainst() I think the last 2 lines need to be inside a critical (or not the last one). I tried this once before and the problem with surfaces distorting was even worse but that will be fixed with this PR.

In the mean time I'm probably going to merge this one.

@phkahler phkahler merged commit fd2dfe8 into solvespace:master Aug 1, 2020
@ruevs
Copy link
Member

ruevs commented Aug 1, 2020

Yes, that model is attached here #613
With very small chord tolerance and large number of segments the difference was very noticeable. I will experiment when I get some time. Also have not forgotten about your triangulation changes.

@phkahler phkahler deleted the issue656 branch August 3, 2020 15:10
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.

OpenMP issue with complex NURBS
3 participants