Several APIs in geogram are not thread safe. Internally Geogram uses threads in places, but the implementation assumes there is single user at time, making it difficult or impossible for applications to use those APIs from multiple threads concurrently.
My request: is to make geogram APIs usable concurrently from multiple application threads.
Below are couple of examples I've run into recently:
Progress tracking system is not thread safe
Currently GEO::mesh_make_atlas() does not appear to be thread safe. It uses progress tracking system, which apparently is global and not thread safe. I would like to use GEO::mesh_make_atlas() from multiple threads, and ideally, also would like to use progress tracking system. I guess, one option could be to make progress tracking system thread local or user supplied.
ParallelDelaunay3d cannot be used while other geogram threads are running
CellStatusArray::resize asserts !Process::is_running_threads().
What happened
My application (the erhe 3D editor) runs geogram-based geometry operations on a thread pool: mesh operations (subdivide, boolean, remesh, ...) execute on worker threads while the main thread stays interactive. Some of those code paths use GEO::parallel_for, and the main thread occasionally builds small convex hulls via GEO::Delaunay::create(3, "PDEL").
When the main thread entered ParallelDelaunay3d::set_vertices() while a worker thread had geogram threads running (a GEO::parallel_for inside a mesh build), this debug assertion fired:
geo_debug_assert(!Process::is_running_threads()); // delaunay_sync.h:220, CellStatusArray::resize
Call stack of the asserting (main) thread:
GEO::geo_abort geogram/basic/assert.cpp:80
GEO::geo_assertion_failed geogram/basic/assert.cpp:117
GEO::CellStatusArray::resize geogram/delaunay/delaunay_sync.h:220
GEO::CellStatusArray::resize geogram/delaunay/delaunay_sync.h:243
GEO::ParallelDelaunay3d::set_vertices geogram/delaunay/parallel_delaunay_3d.cpp:2661
erhe::geometry::make_convex_hull (application)
The precondition is documented ("no concurrent thread is currently running"), so this is arguably by design - but the design makes ParallelDelaunay3d (and, we suspect, other Process::run_threads-based algorithms) unusable in any application that runs geogram work on more than one thread, even when the two concurrent computations touch completely disjoint data.
Several APIs in geogram are not thread safe. Internally Geogram uses threads in places, but the implementation assumes there is single user at time, making it difficult or impossible for applications to use those APIs from multiple threads concurrently.
My request: is to make geogram APIs usable concurrently from multiple application threads.
Below are couple of examples I've run into recently:
Progress tracking system is not thread safe
Currently
GEO::mesh_make_atlas()does not appear to be thread safe. It uses progress tracking system, which apparently is global and not thread safe. I would like to useGEO::mesh_make_atlas()from multiple threads, and ideally, also would like to use progress tracking system. I guess, one option could be to make progress tracking system thread local or user supplied.ParallelDelaunay3d cannot be used while other geogram threads are running
CellStatusArray::resizeasserts!Process::is_running_threads().What happened
My application (the erhe 3D editor) runs geogram-based geometry operations on a thread pool: mesh operations (subdivide, boolean, remesh, ...) execute on worker threads while the main thread stays interactive. Some of those code paths use
GEO::parallel_for, and the main thread occasionally builds small convex hulls viaGEO::Delaunay::create(3, "PDEL").When the main thread entered
ParallelDelaunay3d::set_vertices()while a worker thread had geogram threads running (aGEO::parallel_forinside a mesh build), this debug assertion fired:Call stack of the asserting (main) thread:
The precondition is documented ("no concurrent thread is currently running"), so this is arguably by design - but the design makes
ParallelDelaunay3d(and, we suspect, otherProcess::run_threads-based algorithms) unusable in any application that runs geogram work on more than one thread, even when the two concurrent computations touch completely disjoint data.