CGAL and Threadsafety

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

CGAL and Threadsafety

Thomas Zangl - Home
 
Hi!

I want to use CGAL´s Delaunay Triangulation inside multiple threads
where each thread can run on a different CPU. I use boost::thread and the
threadpool from threadpool.sf.net.

What do I need to obey if I want to use CGAL with multiple threads? How
threadsafe are the triangulatione etc.?

I get various signal 11 errors when I e.g. ask for the dual of a Delaunay
Triangulation face and so on. Errors like this:
*** glibc detected *** corrupted double-linked list: 0x0d1f81b8 ***

Core dump says:
#0  0x0819dbac in _int_malloc ()
#1  0x0819f7e6 in malloc ()
#2  0x08172af8 in operator new ()
#3  0x080d3e04 in CGAL::Lazy_construction<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::To_interval<CGAL::Gmpq> > >, CGAL::CommonKernelFunctors::Construct_segment_3<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::CommonKernelFunctors::Construct_segment_3<CGAL::Simple_cartesian<CGAL::Gmpq> > >::operator()<CGAL::Point_3<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::To_interval<CGAL::Gmpq> > > >, CGAL::Point_3<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<fals
 e> >, CGAL::To_interval<CGAL::Gmpq> > > > > ()
#4  0x080d7cb6 in CGAL::DT3<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::To_interval<CGAL::Gmpq> > >, CGAL::TDS3<CGAL::TH_vb3<CGAL::Triangulation_vertex_base_with_info_3<boost::shared_ptr<Isp>, CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::To_interval<CGAL::Gmpq> > >, CGAL::T_vb3<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::To_interval<CGAL::Gmpq> > >, CGAL::TDS_vb3<void> > > >, CGAL::Triangulation_cell_base_with_info_3<boost::shared_ptr<DCellPropert
 y>, CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::To_interval<CGAL::Gmpq> > >, CGAL::T_cb3<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::To_interval<CGAL::Gmpq> > >, CGAL::TDS_cb3<void> > > > >::dual ()
#5  0x080cafd0 in DFacetProperty::setDual ()
#6  0x080d9143 in DCellProperty::insertFacets ()
#7  0x080dd258 in CComponent::dtriangulate ()
#8  0x080ddafa in CComponent::doWork ()
#9  0x0805d4bc in boost::function0<void, std::allocator<boost::function_base> >::operator() ()
#10 0x0805d955 in boost::threadpool::detail::worker_thread<boost::threadpool::detail::pool_core<boost::function0<void, std::allocator<boost::function_base> >, boost::threadpool::fifo_scheduler, boost::threadpool::static_size, boost::threadpool::resize_controller, boost::threadpool::wait_for_all_tasks> >::run ()
#11 0x0805d4bc in boost::function0<void, std::allocator<boost::function_base> >::operator() ()
#12 0x080f94de in thread_proxy ()
#13 0x0817e8f4 in pthread_start_thread (arg=0x13966840) at manager.c:310
#14 0x081ae73a in clone ()

Any ideas what can be wrong? (It works very fine if the code runs with
multiple threads on ONE CPU, but it starts failing if the threads are
distributed among 2 or more CPUs)

Best regards,
--
,yours Thomas Zangl, Bakk.rer.soc.oec. - [hidden email] -
- Freelancer - IT Consulting & Software Development -
- Student of Software Development-Economy (Master) -
            - http://blog.tzis.net -
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss
Reply | Threaded
Open this post in threaded view
|

Bump: CGAL and Threadsafety

Thomas Zangl - Home
 
Am Sun, 8 Jun 2008 13:06:53 +0200, schrieb "Thomas Zangl - Home" <[hidden email]>:

Hi all!

I wrote the mail below on 8th June and did not receive any reply. Maybe
someone can comment on it? This would *greatly* help. Thank you!

>I want to use CGAL´s Delaunay Triangulation inside multiple threads
>where each thread can run on a different CPU. I use boost::thread and the
>threadpool from threadpool.sf.net.
>
>What do I need to obey if I want to use CGAL with multiple threads? How
>threadsafe are the triangulatione etc.?
>
>I get various signal 11 errors when I e.g. ask for the dual of a Delaunay
>Triangulation face and so on. Errors like this:
>*** glibc detected *** corrupted double-linked list: 0x0d1f81b8 ***
>
>Core dump says:
>#0  0x0819dbac in _int_malloc ()
>#1  0x0819f7e6 in malloc ()
>#2  0x08172af8 in operator new ()
>#3  0x080d3e04 in CGAL::Lazy_construction<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::To_interval<CGAL::Gmpq> > >, CGAL::CommonKernelFunctors::Construct_segment_3<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::CommonKernelFunctors::Construct_segment_3<CGAL::Simple_cartesian<CGAL::Gmpq> > >::operator()<CGAL::Point_3<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::To_interval<CGAL::Gmpq> > > >, CGAL::Point_3<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<fal
 s
> e> >, CGAL::To_interval<CGAL::Gmpq> > > > > ()
>#4  0x080d7cb6 in CGAL::DT3<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::To_interval<CGAL::Gmpq> > >, CGAL::TDS3<CGAL::TH_vb3<CGAL::Triangulation_vertex_base_with_info_3<boost::shared_ptr<Isp>, CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::To_interval<CGAL::Gmpq> > >, CGAL::T_vb3<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::To_interval<CGAL::Gmpq> > >, CGAL::TDS_vb3<void> > > >, CGAL::Triangulation_cell_base_with_info_3<boost::shared_ptr<DCellProper
 t

> y>, CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::To_interval<CGAL::Gmpq> > >, CGAL::T_cb3<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::To_interval<CGAL::Gmpq> > >, CGAL::TDS_cb3<void> > > > >::dual ()
>#5  0x080cafd0 in DFacetProperty::setDual ()
>#6  0x080d9143 in DCellProperty::insertFacets ()
>#7  0x080dd258 in CComponent::dtriangulate ()
>#8  0x080ddafa in CComponent::doWork ()
>#9  0x0805d4bc in boost::function0<void, std::allocator<boost::function_base> >::operator() ()
>#10 0x0805d955 in boost::threadpool::detail::worker_thread<boost::threadpool::detail::pool_core<boost::function0<void, std::allocator<boost::function_base> >, boost::threadpool::fifo_scheduler, boost::threadpool::static_size, boost::threadpool::resize_controller, boost::threadpool::wait_for_all_tasks> >::run ()
>#11 0x0805d4bc in boost::function0<void, std::allocator<boost::function_base> >::operator() ()
>#12 0x080f94de in thread_proxy ()
>#13 0x0817e8f4 in pthread_start_thread (arg=0x13966840) at manager.c:310
>#14 0x081ae73a in clone ()
>
>Any ideas what can be wrong? (It works very fine if the code runs with
>multiple threads on ONE CPU, but it starts failing if the threads are
>distributed among 2 or more CPUs)


Best regards,
--
,yours Thomas Zangl, Bakk.rer.soc.oec. - [hidden email] -
- Freelancer - IT Consulting & Software Development -
- Student of Software Development-Economy (Master) -
            - http://blog.tzis.net -
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Bump: CGAL and Threadsafety

Laurent Rineau (GeometryFactory)
On Thursday 26 June 2008 18:02:48 Thomas Zangl - Home wrote:
> Am Sun, 8 Jun 2008 13:06:53 +0200, schrieb "Thomas Zangl - Home"
> <[hidden email]>:
>
> Hi all!
>
> I wrote the mail below on 8th June and did not receive any reply. Maybe
> someone can comment on it? This would *greatly* help. Thank you!

You can assume that CGAL is not thread safe. As far as I know, CGAL developers
have not worked on that subject at all, at least for released versions (<
3.4).

--
Laurent Rineau, PhD
Engineer at GeometryFactory
http://www.geometryfactory.com/
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Bump: CGAL and Threadsafety

Sylvain Pion
Administrator
In reply to this post by Thomas Zangl - Home
Thomas Zangl - Home a écrit :
>  
> Am Sun, 8 Jun 2008 13:06:53 +0200, schrieb "Thomas Zangl - Home" <[hidden email]>:
>
> Hi all!
>
> I wrote the mail below on 8th June and did not receive any reply. Maybe
> someone can comment on it? This would *greatly* help. Thank you!

Sorry, your mail was on my stack, but I got not much time to process it.

>> I want to use CGAL´s Delaunay Triangulation inside multiple threads
>> where each thread can run on a different CPU. I use boost::thread and the
>> threadpool from threadpool.sf.net.
>>
>> What do I need to obey if I want to use CGAL with multiple threads? How
>> threadsafe are the triangulatione etc.?

As Laurent said, for CGAL 3.3, not much.  We hope to have something better
for 3.4 though (at least for Delaunay_3).

In 3.3, you cannot insert/remove in parallel, even in disconnected areas, since
the underlying container is not thread-safe.  You should be able to iterate
over the vertices/faces in parallel though.  You can dereference existing
handles in parallel as well.

>> I get various signal 11 errors when I e.g. ask for the dual of a Delaunay
>> Triangulation face and so on. Errors like this:
>> *** glibc detected *** corrupted double-linked list: 0x0d1f81b8 ***
>>
>> Core dump says:
>> #0  0x0819dbac in _int_malloc ()
>> #1  0x0819f7e6 in malloc ()
>> #2  0x08172af8 in operator new ()
>> #3  0x080d3e04 in CGAL::Lazy_construction<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::To_interval<CGAL::Gmpq> > >, CGAL::CommonKernelFunctors::Construct_segment_3<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::CommonKernelFunctors::Construct_segment_3<CGAL::Simple_cartesian<CGAL::Gmpq> > >::operator()<CGAL::Point_3<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::To_interval<CGAL::Gmpq> > > >, CGAL::Point_3<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<f
al
>  s
>> e> >, CGAL::To_interval<CGAL::Gmpq> > > > > ()
>> #4  0x080d7cb6 in CGAL::DT3<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::To_interval<CGAL::Gmpq> > >, CGAL::TDS3<CGAL::TH_vb3<CGAL::Triangulation_vertex_base_with_info_3<boost::shared_ptr<Isp>, CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::To_interval<CGAL::Gmpq> > >, CGAL::T_vb3<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::To_interval<CGAL::Gmpq> > >, CGAL::TDS_vb3<void> > > >, CGAL::Triangulation_cell_base_with_info_3<boost::shared_ptr<DCellProp
er

>  t
>> y>, CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::To_interval<CGAL::Gmpq> > >, CGAL::T_cb3<CGAL::Lazy_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::To_interval<CGAL::Gmpq> > >, CGAL::TDS_cb3<void> > > > >::dual ()
>> #5  0x080cafd0 in DFacetProperty::setDual ()
>> #6  0x080d9143 in DCellProperty::insertFacets ()
>> #7  0x080dd258 in CComponent::dtriangulate ()
>> #8  0x080ddafa in CComponent::doWork ()
>> #9  0x0805d4bc in boost::function0<void, std::allocator<boost::function_base> >::operator() ()
>> #10 0x0805d955 in boost::threadpool::detail::worker_thread<boost::threadpool::detail::pool_core<boost::function0<void, std::allocator<boost::function_base> >, boost::threadpool::fifo_scheduler, boost::threadpool::static_size, boost::threadpool::resize_controller, boost::threadpool::wait_for_all_tasks> >::run ()
>> #11 0x0805d4bc in boost::function0<void, std::allocator<boost::function_base> >::operator() ()
>> #12 0x080f94de in thread_proxy ()
>> #13 0x0817e8f4 in pthread_start_thread (arg=0x13966840) at manager.c:310
>> #14 0x081ae73a in clone ()
>>
>> Any ideas what can be wrong? (It works very fine if the code runs with
>> multiple threads on ONE CPU, but it starts failing if the threads are
>> distributed among 2 or more CPUs)

What kernel do you use, Exact_pred_exact_constructions it seems ?
This one would also have some thread-safety issues, e.g. copying
points between threads...  Even the default constructed Point (or other
objects from this kernel) has a shared ref-counter...



I would be interested in knowing more details about your needs in this area.
(and from other people as well, if some subscribers have thread-safety requirements)

--
Sylvain Pion
INRIA Sophia-Antipolis
Geometrica Project-Team
CGAL, http://cgal.org/
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss
Reply | Threaded
Open this post in threaded view
|

Re:Bump: CGAL and Threadsafety

Thomas Zangl - Home
 
Am Thu, 26 Jun 2008 21:21:42 +0200, schrieb "Sylvain Pion" <[hidden email]>:

Hi!

>What kernel do you use, Exact_pred_exact_constructions it seems ?

True :-) With GMP enabled.

>This one would also have some thread-safety issues, e.g. copying
>points between threads...  Even the default constructed Point (or other
>objects from this kernel) has a shared ref-counter...

I already suspected something in this area.
Just a short side-note:
I was reading your papers on arithmetic filtering a few days ago (for my
diploma thesis). I hope I got the big picture right, CGAL uses with
the Exact_pred_exact_constr. kernel a chain of filters (for the
predicates): Static -> Interval arithmetic -> Exact arithmetic. Is
that true?

>I would be interested in knowing more details about your needs in this area.

We basically require that READONLY sharing of CGAL data structures is
threadsafe. In our case we do the following:

-> Create a regular triangulation and label the facets of this reg.tr.
according to some criterias. Each reg.tr. facet ist now UNIQUELY
labeled (in paractice, it got an ID).

-> For each used label, spawn a thread and feed the reg.tr. facet
handels with the same label into the thread class' constructor.

-> The thread does now the following:
   -> at each reg.tr. facet is an info() object with some custom
properties. One property is of a point_3 type.
   -> Create a Delaunay_Triangulation_3
   -> Iterate over all reg.tr . facets and insert this point_3 property
      into the Delaunay Triangulation.
   -> Create the Voronoi Diagram of the Delaunay Triang. and output it
      (write to file)

So, we require:

-> Share a reg.tr. between the threads where we only do some read only
operations (like quering point locations or requesting the exact
coordinates of a vertex, iterating over the reg.tr., etc.)
-> Having geometric primitives threadsafe (predicates, constructions)
-> Having a Delaunay / Regular Triang. instance for each thread and
modifying it in any way (insert, remove, iterating, .dual(), etc.).

Thank you!

Best regards,
--
,yours Thomas Zangl, Bakk.rer.soc.oec. - [hidden email] -
- Freelancer - IT Consulting & Software Development -
- Student of Software Development-Economy (Master) -
            - http://blog.tzis.net -
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss