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!
DgmOctree methods in QtParallelMap
Re: DgmOctree methods in QtParallelMap
Hi,
I'm a bit surprised, getPointsInCylindricalNeighbourhood should be thread safe...
Have you tried to use OpenMP instead of QtConcurrent? (juste add above the main loop over the surface points for instance).
Otherwise can you share the code with me maybe?
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
Otherwise can you share the code with me maybe?
Daniel, CloudCompare admin
Re: DgmOctree methods in QtParallelMap
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)
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
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!
Thanks @daniel for the great work you do!