Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] BUG: Multi-threaded Delaunay_Triangulation_2 crashing...

Subject: CGAL users discussion list

List archive

[cgal-discuss] BUG: Multi-threaded Delaunay_Triangulation_2 crashing...


Chronological Thread 
  • From: Jan Rüegg <>
  • To:
  • Subject: [cgal-discuss] BUG: Multi-threaded Delaunay_Triangulation_2 crashing...
  • Date: Mon, 12 Dec 2011 12:49:05 -0800 (PST)

I tried using a Delaunay_Triangulation_2 in a multithreaded environment. I'm
using arch linux, 64-bit, and CGAL 3.9-2, boost 1.48.0-2

My code is something like this:

---------------------------------------------------------------------------------------

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/Triangulation_vertex_base_with_info_2.h>
#include <CGAL/Triangulation_face_base_with_info_2.h>

typedef CGAL::Triangulation_vertex_base_with_info_2<voronoi_data, K> Vb;
typedef CGAL::Triangulation_face_base_with_info_2<face_data, K> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Tds;
typedef CGAL::Delaunay_triangulation_2<K, Tds> Triangulation;

...

void GetColor(Triangulation *t, ...) {
...
Vertex new_v = t->insert(current_point);
t->remove(new_v);
...
}

...

void main() {

#pragma omp parallel for
// Reconstruct image
for (int y = 0; y < height_; y++) {
for (int x = 0; x < width_; x++) {
GetColor(&(ts_[omp_get_thread_num()]), ...);
}
}

...
}

---------------------------------------------------------------------------------------

Here, ts_ is a vector of "Triangulation", where each triangulation is
independently set up. That means, each thread has its OWN cgal objects!

When I run this, I get a segmentation fault. However, using:
#pragma omp critical
t->remove(new_v);

instead, makes it work! That means, the remove function must do something
that is not thread-safe, though every thread operates on its own
triangulation...

Regards
Jan Rüegg



--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/BUG-Multi-threaded-Delaunay-Triangulation-2-crashing-tp4187557p4187557.html
Sent from the cgal-discuss mailing list archive at Nabble.com.



Archive powered by MHonArc 2.6.16.

Top of Page