BrunoLevy / geogram

a programming library with geometric algorithms
Other
1.81k stars 122 forks source link

doubts in multithreaded compute_RVD #26

Open vcbsousa opened 1 year ago

vcbsousa commented 1 year ago

Could you please clarify some of my doubts regarding computing the restricted voronoi diagram in multithreaded mode?

In the documentation for the function "for_each_polyhedron()" there is a boolean parameter called "parallel" that, if true, tentatively parallelizes the computation.

1) First, how does it pick the number of threads to run the computation? I noticed that the parallel implementation of the Delaunay triangulation runs with 16 threads on my mac and the RVD computation is restricted to 2 threads if the parallel flag is active.

2) Is there a reason fro the choice of wording "tentatively" in the documentation? Are there restrictions to the parallelization of this operation?

3) I have noticed that the parallelization fails if the mesh that is used to restrict the voronoi diagram has a hole inside. One example of such a mesh would be one used for the computation of the flow around a sphere. Is there a workaround to use the parallel flag in such a case? I could provide the .stl that gives the error if that would be useful.

Thank you for your assistance.

BrunoLevy commented 1 year ago

Hi, would you create a minimal example with the problem and send it with the data file ? I'll take a look.

vcbsousa commented 1 year ago

Attachment available until Nov 2, 2022 Hello Bruno,

Thank you for offering your assistance with this issue.

I have attached to this email a folder containing a minimal example of the behavior I have experienced using the compute_RVD example code inside geogram’s git. It contains two boundary meshes in .stl format and 3 point clouds in .obj format. The two boundary meshes correspond to a solid cube and a cube with a hollow sphere inside.

I have noticed that, if I modify the for_each_polyhedron call to tentatively parallelize the computation, i.e. RVD->for_each_polyhedron(callback, true, true, true ), the following happens:

1) if the solid cube.stl is used to restrict the diagram, the computation is successful but the number of threads in the RVD section of the code seems to be limited to 2. In contrast, the parallel computation of the Delaunay graph is performed with 16 threads.

2) if the hollow cubeWithHollowSphere.stl is used, the parallel computation fails. It either says a segmentation fault happened or it displays the following message: compute_RVD(62326,0x700000b73000) malloc: error for object 0x7faa4b70417c: pointer being freed was not allocated compute_RVD(62326,0x700000b73000) malloc: set a breakpoint in malloc_error_break to debug

Thanks again for your help. Sincerely,

Victor Sousa

Click to Download https://www.icloud.com/attachment/?u=https%3A%2F%2Fcvws.icloud-content.com%2FB%2FARfw1q63ACjTRn8hqh0Fq5Lk-ZtCAQIgUVnbFmkFJ6ggmLLCQMvk-zFL%2F%24%7Bf%7D%3Fo%3DAn4pjFRzaRMxcBDFwTZ_gUdjMFUfHAXxDfq6_Bh6gAYm%26v%3D1%26x%3D3%26a%3DCAogUVPyLXSd0jBJIiKWWpX6GU9fgKUxf-GRJIz31RJvmdoSdhCQuOTzuTAYkMjfx8MwIgEAKgkC6AMA_zP47UxSBOT5m0JaBOT7MUtqJeZSmEicxYLOeZ0A8i_YPAa57s5TQB7QnRlr5cpZtXzUPZgBisdyJQCm64Wq7Lt3A6h7YSyKdI3-6P_6904XlujIxuCKJwAPtOJ3aSw%26e%3D1667403080%26fl%3D%26r%3D0E28F820-FB64-4D1E-A9CC-15C62109BB96-1%26k%3D%24%7Buk%7D%26ckc%3Dcom.apple.largeattachment%26ckz%3D8282CF17-64D3-4E39-88A6-2EC8821ABBC4%26p%3D68%26s%3DrxvgWkIqT27PUrBATARt92_w_E0&uk=wnaZDS5SP3YcralJsySpnQ&f=minimal_example.zip&sz=63484356minimal_example.zip 63.5 MB

On Oct 1, 2022, at 1:08 AM, Bruno Levy @. @.>> wrote:

Hi, would you create a minimal example with the problem and send it with the data file ? I'll take a look.

— Reply to this email directly, view it on GitHub https://github.com/BrunoLevy/geogram/issues/26#issuecomment-1264286821, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3LQBOHMIAXQUQKQL2PJ4N3WA7WPXANCNFSM6AAAAAAQZ2F6TE. You are receiving this because you authored the thread.

BrunoLevy commented 1 year ago

Hi, Thank you for your examples, I'd need also a minimal program that shows the bug Thank you in advance, -- Bruno

vcbsousa commented 1 year ago

Hello Bruno,

Here is the version of the main.cpp related to the compute_RVD example that shows the bug. Its only modifications from the are the use of the “RVD_cells" callback subroutine and and the activation of the parallel flag in the “for_each_polyhedron" call Let me know if you need anything else. Thank you for your assistance,

Sincerely,

Victor Sousa

On Oct 5, 2022, at 7:23 AM, Bruno Levy @.**@.>> wrote:

Hi, Thank you for your examples, I'd need also a minimal program that shows the bug Thank you in advance, -- Bruno

— Reply to this email directly, view it on GitHubhttps://github.com/BrunoLevy/geogram/issues/26#issuecomment-1268507604, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A3LQBOEEDGB4JX53CUS5FJDWBWFO7ANCNFSM6AAAAAAQZ2F6TE. You are receiving this because you authored the thread.Message ID: @.***>

BrunoLevy commented 1 year ago

Thanks Victor, I don't see the file, where is it ? -- B

vcbsousa commented 1 year ago

I apologize, I sent it as an email attachment and it seems it was not posted here. main.cpp.zip