Skip to content

Parallelhxt2gmsh

xiaoming requested to merge parallelhxt2gmsh into master

Hi ,dear gmsh developer!

In the previous discussion, I asked @geuzaine for advice on the optimization direction of HXT algorithm. He suggested that the Hxt2Gmshfunction seems take too much time, should be optimized.

I found that this function really takes up a lot of time, and most of time was spend on this for loop:

for(size_t i = 0; i < m->tetrahedra.num; i++)

I use OpenMP to parallelize it. Each thread pushes the object into the thread-local vector and finally merges.

At first it didn't work, multithreading took more time. This because the MVertex/ MTetrahedron's constructors were all wrapped in critical and could not be parallelized. I tried to narrow down the critical section by adding methods to the GModel class to guarantee the global numbering.

In my test, by parallelizing the for loop in this way, the Hxt2Gmsh function runtime can be reduced by approximately 70%.

And because atomic is used instead of critical, more code can run synchronously, creating objects in parallel becomes faster,even slightly accelerate the generation of 2D/3D mesh.

So, I think the result is not bad, can it be merged into the Master branch?

Merge request reports