DgmOctree methods in QtParallelMap

Any question about the database & algorithms library 'CCLib'
Post Reply
allista
Posts: 3
Joined: Fri Dec 14, 2018 2:55 pm

DgmOctree methods in QtParallelMap

Post by allista »

Hi,
I'm writing a plugin for CC to calculate some local cloud parameters along a 3D surface.
For that I sample the surface, then query the octree at each sampled point to get cylindrical neighbourhood (using DgmOctree::getPointsInCylindricalNeighbourhood) along the normal of the surface at the point. Then calculate local parameters as a function of returned points.
The algorithm works as intended, but is expectedly slow. So I'm trying to reimplement it using QtConcurrent::mapped and getting very strange results: most of the getPointsInCylindricalNeighbourhood calls return 0 points.
From this I suspect that calls use some shared state inside the octree; but hard as I try (reading DgmOctree code), I cannot figure out what it is and how to circumvent it, if at all possible.

So my questions are:
1) why getPointsInCylindricalNeighbourhood works incorrectly in parallel execution?
2) is there any way to use it properly?
3) if not, would you suggest other means to parallelize such computation?

Thanks in advance!
daniel
Site Admin
Posts: 7707
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: DgmOctree methods in QtParallelMap

Post by daniel »

Hi,

I'm a bit surprised, getPointsInCylindricalNeighbourhood should be thread safe...

Have you tried to use OpenMP instead of QtConcurrent? (juste add

Code: Select all

#pragma omp parallel for
above the main loop over the surface points for instance).

Otherwise can you share the code with me maybe?
Daniel, CloudCompare admin
allista
Posts: 3
Joined: Fri Dec 14, 2018 2:55 pm

Re: DgmOctree methods in QtParallelMap

Post by allista »

Thanks for the quick reply!

Will try OpenMP. Though not sure why it could/should make a difference.

Anyway, at least now I know that I've messed something up and can concentrate on finding what. Not that I haven't checked it before asking here, but certainty always makes it easier.

And if I fail, I'll come to bore you with my code, yes)
allista
Posts: 3
Joined: Fri Dec 14, 2018 2:55 pm

Re: DgmOctree methods in QtParallelMap

Post by allista »

To close the issue: I've found my error (which was in lousy handling of temporary pointers) and testify that DgmOctree is not the culprit.

Thanks @daniel for the great work you do!
Post Reply