Page 1 of 1

DgmOctree methods in QtParallelMap

Posted: Fri Dec 14, 2018 3:45 pm
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!

Re: DgmOctree methods in QtParallelMap

Posted: Sat Dec 15, 2018 8:59 am
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?

Re: DgmOctree methods in QtParallelMap

Posted: Mon Dec 17, 2018 6:50 am
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)

Re: DgmOctree methods in QtParallelMap

Posted: Wed Dec 19, 2018 11:08 am
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!