Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Multithreading, Contribution

Subject: CGAL users discussion list

List archive

[cgal-discuss] Multithreading, Contribution


Chronological Thread 
  • From: Bernhard Kornberger <>
  • To:
  • Subject: [cgal-discuss] Multithreading, Contribution
  • Date: Wed, 21 Jan 2015 12:06:03 +0100

Hello!


Last year researches from the Distributed and Parallel Systems Group
of the University of Innsbruck have parallelized one of my programs.
To this end they needed to patch CGAL to achieve thread safety for
the Exact_predicates_exact_constructions_kernel. Now I'd like to
contribute this patch and possibly start a discussion about it:

http://www.geom.at/_downloads/patch.diff

The patch is not my work, so I paste their description here:



### Copy&Paste start ###

The handler classes implement reference counting mechanisms. A simple atomic increment
operation was added to the counter increment to avoid concurrent alteration. To provide portability,
the boost::atomic tools were used, instead of using compiler dependent built/in functions.
The current C++11 standard could have been used as well, std::atomic provides with the same functionality and portability.
The modified files are: CGAL/Handle_for.h and CGAL/Handle.h

In CGAL/Lazy.h the version of the approx() method that is not constant and do returns a reference to the inner
object was dropped. We want to avoid anyone from modify the state of the object so we can enforce thread
safety. It seems that this method is not used during compilation and can be safely deleted.
The Lazy_rep object keeps two objects that hold the approximate value: at, that holds the
original approximate value, and at_exact that holds the exact value that is recalculated inside
update_exact. In this way, a thread that calls approx and ta thread that calls update_exact operate on
different objects and we can ensure thread safety.
Instead of utilizing a mutex to check whenever the approximate value has being updated, the
check is done done via an atomic counter. This counter is initialized with value 0 to represent that
the value is an approximation. The last statement of the update_exact operation updates the value to
represent the fact that the value is no longer an approximation.

### Copy&Paste end ###


I hope that this contribution is useful.

Best regards
Bernhard Kornberger



--
Geom e.U. Softwareentwicklung Web: http://geom.at
DI Dr. Bernhard Kornberger Email:

Raiffeisenstraße 19 Firmenbuch-Nummer: 348784v
A-8010 Graz / Austria Landesgericht f. ZRS, Graz
Tel: +43 / (0) 699 / 81 300 122 UID: ATU65810848
Fax: +43 / (0) 316 / 83 32 27




Archive powered by MHonArc 2.6.18.

Top of Page