From 6b65ad71da960f2d413443b37db0c2885167fc52 Mon Sep 17 00:00:00 2001 From: Clement Jamin Date: Wed, 16 Oct 2013 12:17:56 +0200 Subject: [PATCH] Changes in the "lock data structure" concept and models The concept is now much more generic (SurjectiveLockDataStructure). The names have been changed accordingly. --- ...ta_structure_3.h => Spatial_lock_grid_3.h} | 21 +++--- .../Concepts/SpatialLockDataStructure3.h | 50 ------------- .../Concepts/SurjectiveLockDataStructure.h | 57 +++++++++++++++ ...ta_structure_3.h => Spatial_lock_grid_3.h} | 70 +++++++++---------- .../Triangulation_benchmark_3.cpp | 2 +- .../demo/Triangulation_3/typedefs.h | 2 +- .../CGAL/Delaunay_triangulation_3.h | 26 +++---- .../CGAL/Regular_triangulation_3.h | 26 +++---- .../Triangulation_3/CGAL/Triangulation_3.h | 35 ++++++---- .../Triangulation_3/PackageDescription.txt | 6 +- .../doc/Triangulation_3/Triangulation_3.txt | 10 +-- .../include/CGAL/Triangulation_3.h | 7 +- .../CGAL/Triangulation_data_structure_3.h | 5 +- 13 files changed, 167 insertions(+), 150 deletions(-) rename STL_Extension/doc/STL_Extension/CGAL/{Spatial_grid_lock_data_structure_3.h => Spatial_lock_grid_3.h} (58%) delete mode 100644 STL_Extension/doc/STL_Extension/Concepts/SpatialLockDataStructure3.h create mode 100644 STL_Extension/doc/STL_Extension/Concepts/SurjectiveLockDataStructure.h rename STL_Extension/include/CGAL/{Spatial_grid_lock_data_structure_3.h => Spatial_lock_grid_3.h} (89%) diff --git a/STL_Extension/doc/STL_Extension/CGAL/Spatial_grid_lock_data_structure_3.h b/STL_Extension/doc/STL_Extension/CGAL/Spatial_lock_grid_3.h similarity index 58% rename from STL_Extension/doc/STL_Extension/CGAL/Spatial_grid_lock_data_structure_3.h rename to STL_Extension/doc/STL_Extension/CGAL/Spatial_lock_grid_3.h index b963e385972..2543e6517ea 100644 --- a/STL_Extension/doc/STL_Extension/CGAL/Spatial_grid_lock_data_structure_3.h +++ b/STL_Extension/doc/STL_Extension/CGAL/Spatial_lock_grid_3.h @@ -4,9 +4,14 @@ namespace CGAL { /*! \ingroup PkgStlExtension -The class `Spatial_grid_lock_data_structure_3` allows to lock +The class `Spatial_lock_grid_3` allows to lock points with coordinates (x, y, z) in a 3D grid. For example, it can be used by concurrent algorithms to lock simplices. +It is a model of `SurjectiveLockDataStructure`, with `Object` being +`P3` and `S(point)` being the cell of the 3D grid containing `point`. +`P3` must provide x(), y() and z() functions, +returning the respective point coordinates as numbers whose type is a +model of the concept of `CGAL::RealEmbeddable`. \tparam Grid_lock_tag allows to choose the locking strategy used by the structure. The following tags are available: @@ -18,31 +23,31 @@ block (spin) if the thread owning the lock has a lower \"ID\" (each thread is given an arbitrary ID) or return immediately otherwise. It uses atomics to perform lock operations. -\cgalModels `SpatialLockDataStructure_3` +\cgalModels `SurjectiveLockDataStructure` */ template -class Spatial_grid_lock_data_structure_3 +class Spatial_lock_grid_3 { public: /// \name Creation /// @{ - /// Construct the lock grid of size `bbox`, with `num_grid_cells_per_axis` + /// Constructs the lock grid of size `bbox`, with `num_grid_cells_per_axis` /// cells per axis. - Spatial_grid_lock_data_structure_3(const Bbox_3 &bbox, - int num_grid_cells_per_axis); + Spatial_lock_grid_3(const Bbox_3 &bbox, + int num_grid_cells_per_axis); /// @} /// \name Operations /// @{ - /// Set the bounding box of the domain. + /// Sets the bounding box of the domain. void set_bbox(const CGAL::Bbox_3 &bbox); /// @} -}; /* end Spatial_grid_lock_data_structure_3 */ +}; /* end Spatial_lock_grid_3 */ } /* end namespace CGAL */ diff --git a/STL_Extension/doc/STL_Extension/Concepts/SpatialLockDataStructure3.h b/STL_Extension/doc/STL_Extension/Concepts/SpatialLockDataStructure3.h deleted file mode 100644 index 26e11d652fd..00000000000 --- a/STL_Extension/doc/STL_Extension/Concepts/SpatialLockDataStructure3.h +++ /dev/null @@ -1,50 +0,0 @@ - -/*! -\ingroup PkgStlExtensionConcepts -\cgalConcept - -The concept `SpatialLockDataStructure_3` is intended to be used by concurrent -algorithms. It allows to lock points with coordinates (x, y, z). -The template parameter type `P3` appearing in member functions -must provide x(), y() and z() functions, -returning the respective point coordinates as numbers whose type is a -model of the concept of `CGAL::RealEmbeddable`. - -Note that it is allowed to \"lock too much\". E.g., the data structure -may be a voxel grid and locking a point may be locking the voxel containing this point. -The only requirement is that when a thread owns the lock of a point, no other -thread can lock a point with the exact same coordinates. - -\cgalHasModel `CGAL::Spatial_grid_lock_data_structure_3` - -*/ -class SpatialLockDataStructure_3 { -public: - -/// \name Operations -/// @{ - /// Test if `point` is locked (by this thread or by any other thread). - template - bool is_locked(const P3 &point); - - /// Test if `point` is locked by this thread. - template - bool is_locked_by_this_thread(const P3 &point); - - /// Try to lock `point`. Returns `true` if the point is already locked by this thread or if the point could be locked. - template - bool try_lock(const P3 &point); - - /// Try to lock `point`. Returns `true` if the point is already locked by this thread or if the point could be locked. - /// \tparam no_spin If true, force non-blocking operation (never blocks). If false, use the default behavior (same as previous function). - template - bool try_lock(const P3 &point); - - /// Unlock all the locations locked by this thread. - void unlock_all_points_locked_by_this_thread(); - - /// Unlock all the locations locked by this thread except `point`. - template - void unlock_all_tls_locked_locations_but_one_point(const P3 &point); -/// @} -}; \ No newline at end of file diff --git a/STL_Extension/doc/STL_Extension/Concepts/SurjectiveLockDataStructure.h b/STL_Extension/doc/STL_Extension/Concepts/SurjectiveLockDataStructure.h new file mode 100644 index 00000000000..766c25fd0d0 --- /dev/null +++ b/STL_Extension/doc/STL_Extension/Concepts/SurjectiveLockDataStructure.h @@ -0,0 +1,57 @@ + +/*! +\ingroup PkgStlExtensionConcepts +\cgalConcept + +The concept `SurjectiveLockDataStructure` is intended to be used by concurrent +algorithms. It allows to lock objects in a multi-threaded environment. + +Note that it is allowed to \"lock too much\". E.g., the data structure +might be a voxel grid and locking a point might be locking the +voxel containing this point. +Thus, a point may also be locked because +another point in the same voxel has been locked. +The only requirement is that when a thread owns the lock of an object, no other +thread can lock the same object. + +We call `S` the surjective function such as `S(object)` +is the \"thing\" that is locked when one tries to lock `object`. +In the previous example, `S(point)` is the voxel containing `point`. + +\cgalHasModel `CGAL::Spatial_lock_grid_3` + +*/ +class SurjectiveLockDataStructure { +public: + +/// \name Operations +/// @{ + /// Test if `object` is locked (by this thread or by any other thread). + template + bool is_locked(const Object &object); + + /// Test if `object` is locked by this thread. + template + bool is_locked_by_this_thread(const Object &object); + + /// Try to lock `object`. Returns `true` if the object is already locked by this thread or if the object could be locked. + template + bool try_lock(const Object &object); + + /// Try to lock `object`. Returns `true` if the object is already locked + /// by this thread or if the object could be locked. + /// \tparam no_spin If `true`, force non-blocking operation (in any case, the + /// function will return immediately, i.e.\ it will not + /// wait for the ressource to be free). + /// If `false`, use the default behavior (same as previous function). + template + bool try_lock(const Object &object); + + /// Unlock everything that is locked by this thread. + void unlock_everything_locked_by_this_thread(); + + /// Unlock everything that is locked by this thread except `S(object)`. + template + void unlock_everything_locked_by_this_thread_but_one(const Object &object); +/// @} +}; \ No newline at end of file diff --git a/STL_Extension/include/CGAL/Spatial_grid_lock_data_structure_3.h b/STL_Extension/include/CGAL/Spatial_lock_grid_3.h similarity index 89% rename from STL_Extension/include/CGAL/Spatial_grid_lock_data_structure_3.h rename to STL_Extension/include/CGAL/Spatial_lock_grid_3.h index bd7ffdd8d69..5ff51b1e2f0 100644 --- a/STL_Extension/include/CGAL/Spatial_grid_lock_data_structure_3.h +++ b/STL_Extension/include/CGAL/Spatial_lock_grid_3.h @@ -17,8 +17,8 @@ // // Author(s) : Clement Jamin -#ifndef CGAL_MESH_3_LOCK_DATA_STRUCTURES_H -#define CGAL_MESH_3_LOCK_DATA_STRUCTURES_H +#ifndef CGAL_STL_EXTENSION_SPATIAL_LOCK_GRID_3_H +#define CGAL_STL_EXTENSION_SPATIAL_LOCK_GRID_3_H #ifdef CGAL_LINKED_WITH_TBB @@ -46,12 +46,12 @@ struct Tag_non_blocking_with_mutexes {}; struct Tag_priority_blocking {}; //***************************************************************************** -// class Spatial_grid_lock_data_structure_base_3 +// class Spatial_lock_grid_base_3 // (Uses Curiously recurring template pattern) //***************************************************************************** template -class Spatial_grid_lock_data_structure_base_3 +class Spatial_lock_grid_base_3 { #ifdef CGAL_DEBUG_GLOBAL_LOCK_DS @@ -364,7 +364,7 @@ public: protected: // Constructor - Spatial_grid_lock_data_structure_base_3(const Bbox_3 &bbox, + Spatial_lock_grid_base_3(const Bbox_3 &bbox, int num_grid_cells_per_axis) : m_num_grid_cells_per_axis(num_grid_cells_per_axis), m_tls_grids(boost::bind(init_TLS_grid, num_grid_cells_per_axis)) @@ -373,7 +373,7 @@ protected: } /// Destructor - ~Spatial_grid_lock_data_structure_base_3() + ~Spatial_lock_grid_base_3() { for( TLS_grid::iterator it_grid = m_tls_grids.begin() ; it_grid != m_tls_grids.end() ; @@ -465,27 +465,26 @@ protected: //***************************************************************************** -// class Spatial_grid_lock_data_structure_3 +// class Spatial_lock_grid_3 //***************************************************************************** template -class Spatial_grid_lock_data_structure_3; +class Spatial_lock_grid_3; //***************************************************************************** -// class Spatial_grid_lock_data_structure_3 +// class Spatial_lock_grid_3 //***************************************************************************** template <> -class Spatial_grid_lock_data_structure_3 - : public Spatial_grid_lock_data_structure_base_3< - Spatial_grid_lock_data_structure_3 > +class Spatial_lock_grid_3 + : public Spatial_lock_grid_base_3< + Spatial_lock_grid_3 > { - typedef Spatial_grid_lock_data_structure_base_3< - Spatial_grid_lock_data_structure_3 > Base; + typedef Spatial_lock_grid_base_3< + Spatial_lock_grid_3 > Base; public: // Constructors - Spatial_grid_lock_data_structure_3(const Bbox_3 &bbox, - int num_grid_cells_per_axis) + Spatial_lock_grid_3(const Bbox_3 &bbox, int num_grid_cells_per_axis) : Base(bbox, num_grid_cells_per_axis) { int num_cells = @@ -497,7 +496,7 @@ public: m_grid[i] = false; } - ~Spatial_grid_lock_data_structure_3() + ~Spatial_lock_grid_3() { } @@ -531,22 +530,20 @@ protected: //***************************************************************************** -// class Spatial_grid_lock_data_structure_3 +// class Spatial_lock_grid_3 //***************************************************************************** template <> -class Spatial_grid_lock_data_structure_3 - : public Spatial_grid_lock_data_structure_base_3< - Spatial_grid_lock_data_structure_3 > +class Spatial_lock_grid_3 + : public Spatial_lock_grid_base_3 > { - typedef Spatial_grid_lock_data_structure_base_3< - Spatial_grid_lock_data_structure_3 > Base; + typedef Spatial_lock_grid_base_3< + Spatial_lock_grid_3 > Base; public: // Constructors - Spatial_grid_lock_data_structure_3(const Bbox_3 &bbox, - int num_grid_cells_per_axis) + Spatial_lock_grid_3(const Bbox_3 &bbox, int num_grid_cells_per_axis) : Base(bbox, num_grid_cells_per_axis), m_tls_thread_ids(init_TLS_thread_ids) { @@ -556,7 +553,7 @@ public: } /// Destructor - ~Spatial_grid_lock_data_structure_3() + ~Spatial_lock_grid_3() { } @@ -633,22 +630,21 @@ protected: }; //***************************************************************************** -// class Spatial_grid_lock_data_structure_3 +// class Spatial_lock_grid_3 // Note: undocumented, for testing only... //***************************************************************************** template <> -class Spatial_grid_lock_data_structure_3 - : public Spatial_grid_lock_data_structure_base_3< - Spatial_grid_lock_data_structure_3 > +class Spatial_lock_grid_3 + : public Spatial_lock_grid_base_3< + Spatial_lock_grid_3 > { - typedef Spatial_grid_lock_data_structure_base_3< - Spatial_grid_lock_data_structure_3 > Base; + typedef Spatial_lock_grid_base_3< + Spatial_lock_grid_3 > Base; public: // Constructors - Spatial_grid_lock_data_structure_3(const Bbox_3 &bbox, - int num_grid_cells_per_axis) + Spatial_lock_grid_3(const Bbox_3 &bbox, int num_grid_cells_per_axis) : Base(bbox, num_grid_cells_per_axis) { int num_cells = @@ -657,7 +653,7 @@ public: } /// Destructor - ~Spatial_grid_lock_data_structure_3() + ~Spatial_lock_grid_3() { } @@ -698,7 +694,7 @@ protected: namespace CGAL { template -class Spatial_grid_lock_data_structure_3 +class Spatial_lock_grid_3 { }; @@ -706,4 +702,4 @@ class Spatial_grid_lock_data_structure_3 #endif // CGAL_LINKED_WITH_TBB -#endif // CGAL_MESH_3_LOCK_DATA_STRUCTURES_H +#endif // CGAL_STL_EXTENSION_SPATIAL_LOCK_GRID_3_H diff --git a/Triangulation_3/benchmark/Triangulation_3/Triangulation_benchmark_3.cpp b/Triangulation_3/benchmark/Triangulation_3/Triangulation_benchmark_3.cpp index da770b54cea..2135bc36534 100644 --- a/Triangulation_3/benchmark/Triangulation_3/Triangulation_benchmark_3.cpp +++ b/Triangulation_3/benchmark/Triangulation_3/Triangulation_benchmark_3.cpp @@ -82,7 +82,7 @@ typedef Regular_triangulation_euclidean_traits_3 WK; typedef K::Point_3 Point; #ifdef CONCURRENT_TRIANGULATION_3 - typedef CGAL::Spatial_grid_lock_data_structure_3< + typedef CGAL::Spatial_lock_grid_3< CGAL::Tag_priority_blocking> Lock_ds; // Delaunay T3 diff --git a/Triangulation_3/demo/Triangulation_3/typedefs.h b/Triangulation_3/demo/Triangulation_3/typedefs.h index 598b2ad3da8..69cbd513899 100644 --- a/Triangulation_3/demo/Triangulation_3/typedefs.h +++ b/Triangulation_3/demo/Triangulation_3/typedefs.h @@ -86,7 +86,7 @@ private: * and point location is then O(n^(1/3)) time */ #ifdef CONCURRENT_TRIANGULATION_3 -typedef CGAL::Spatial_grid_lock_data_structure_3< +typedef CGAL::Spatial_lock_grid_3< CGAL::Tag_priority_blocking> Lock_ds; typedef CGAL::Triangulation_data_structure_3< Vertex_base, diff --git a/Triangulation_3/doc/Triangulation_3/CGAL/Delaunay_triangulation_3.h b/Triangulation_3/doc/Triangulation_3/CGAL/Delaunay_triangulation_3.h index d9ddae947a7..87faa5896ed 100644 --- a/Triangulation_3/doc/Triangulation_3/CGAL/Delaunay_triangulation_3.h +++ b/Triangulation_3/doc/Triangulation_3/CGAL/Delaunay_triangulation_3.h @@ -32,14 +32,16 @@ provided before \cgal 3.6 by `Triangulation_hierarchy_3`. An example of use can be found in the user manual \ref Triangulation3exfastlocation. -\tparam SpatialLockDataStructure_3 is an optional parameter to specify the type of the spatial lock data structure. +\tparam SurjectiveLockDataStructure is an optional parameter to specify the type of the spatial lock data structure. It is only used if the triangulation data structure used is concurrency-safe (i.e.\ when TriangulationDataStructure_3::Concurrency_tag is Parallel_tag). - It must be a model of the `SpatialLockDataStructure_3` concept. - The default value is `Spatial_grid_lock_data_structure_3` if + It must be a model of the `SurjectiveLockDataStructure` concept, + with `Object` being a `Point`. + The default value is `Spatial_lock_grid_3` if the triangulation data structure is concurrency-safe, and `void` otherwise. - In order to use concurrent operations, the user must provide a reference to a `SpatialLockDataStructure_3` - instance via the constructor or `set_lock_data_structure`. + In order to use concurrent operations, the user must provide a + reference to a `SurjectiveLockDataStructure` + instance via the constructor or `Triangulation_3::set_lock_data_structure`. If `TriangulationDataStructure_3::Concurrency_tag` is `Parallel_tag`, some operations, such as insertion/removal of a range of points, are performed in parallel. See @@ -48,13 +50,13 @@ the documentation of the operations for more details. \sa `CGAL::Regular_triangulation_3` */ -template< typename DelaunayTriangulationTraits_3, typename TriangulationDataStructure_3, typename LocationPolicy, typename SpatialLockDataStructure_3 > +template< typename DelaunayTriangulationTraits_3, typename TriangulationDataStructure_3, typename LocationPolicy, typename SurjectiveLockDataStructure > class Delaunay_triangulation_3 : public Triangulation_3::Triangulation_data_structure, - SpatialLockDataStructure_3 + SurjectiveLockDataStructure > { @@ -72,7 +74,7 @@ typedef LocationPolicy Location_policy; /*! */ -typedef SpatialLockDataStructure_3 Lock_data_structure; +typedef SurjectiveLockDataStructure Lock_data_structure; /// @} @@ -114,12 +116,12 @@ must be provided if concurrency is enabled. */ Delaunay_triangulation_3 (const DelaunayTriangulationTraits_3& traits = DelaunayTriangulationTraits_3(), -SpatialLockDataStructure_3 *lock_ds = NULL); +Lock_data_structure *lock_ds = NULL); /*! Copy constructor. The pointer to the lock data structure is not copied. Thus, the copy won't be -concurrency-safe as long as the user has not called `set_lock_data_structure`. +concurrency-safe as long as the user has not called `Triangulation_3::set_lock_data_structure`. */ Delaunay_triangulation_3 (const Delaunay_triangulation_3 & dt1); @@ -130,14 +132,14 @@ traits class argument and calling `insert(first,last)`. template < class InputIterator > Delaunay_triangulation_3 (InputIterator first, InputIterator last, const DelaunayTriangulationTraits_3& traits = DelaunayTriangulationTraits_3(), -SpatialLockDataStructure_3 *lock_ds = NULL); +Lock_data_structure *lock_ds = NULL); /*! Same as before, with last two parameters in reverse order. */ template < class InputIterator > Delaunay_triangulation_3 (InputIterator first, InputIterator last, -SpatialLockDataStructure_3 *lock_ds, +Lock_data_structure *lock_ds, const DelaunayTriangulationTraits_3& traits = DelaunayTriangulationTraits_3()); /// @} diff --git a/Triangulation_3/doc/Triangulation_3/CGAL/Regular_triangulation_3.h b/Triangulation_3/doc/Triangulation_3/CGAL/Regular_triangulation_3.h index 0c28e328356..7a0d6d71af8 100644 --- a/Triangulation_3/doc/Triangulation_3/CGAL/Regular_triangulation_3.h +++ b/Triangulation_3/doc/Triangulation_3/CGAL/Regular_triangulation_3.h @@ -32,14 +32,16 @@ of all simplices are regular. \tparam TriangulationDataStructure_3 is the triangulation data structure. It has the default value `Triangulation_data_structure_3, Regular_triangulation_cell_base_3 >`. -\tparam SpatialLockDataStructure_3 is an optional parameter to specify the type of the spatial lock data structure. +\tparam SurjectiveLockDataStructure is an optional parameter to specify the type of the spatial lock data structure. It is only used if the triangulation data structure used is concurrency-safe (i.e.\ when TriangulationDataStructure_3::Concurrency_tag is Parallel_tag). - It must be a model of the `SpatialLockDataStructure_3` concept. - The default value is `Spatial_grid_lock_data_structure_3` if + It must be a model of the `SurjectiveLockDataStructure` concept, + with `Object` being a `Point`. + The default value is `Spatial_lock_grid_3` if the triangulation data structure is concurrency-safe, and `void` otherwise. - In order to use concurrent operations, the user must provide a reference to a `SpatialLockDataStructure_3` - instance via the constructor or `set_lock_data_structure`. + In order to use concurrent operations, the user must provide a + reference to a `SurjectiveLockDataStructure` + instance via the constructor or `Triangulation_3::set_lock_data_structure`. If `TriangulationDataStructure_3::Concurrency_tag` is `Parallel_tag`, some operations, such as insertion/removal of a range of points, are performed in parallel. See @@ -47,8 +49,8 @@ the documentation of the operations for more details. \sa `CGAL::Delaunay_triangulation_3` */ -template< typename RegularTriangulationTraits_3, typename TriangulationDataStructure_3, typename SpatialLockDataStructure_3 > -class Regular_triangulation_3 : public Triangulation_3 { +template< typename RegularTriangulationTraits_3, typename TriangulationDataStructure_3, typename SurjectiveLockDataStructure > +class Regular_triangulation_3 : public Triangulation_3 { public: /// \name Types @@ -68,7 +70,7 @@ typedef RegularTriangulationTraits_3::Weighted_point_3 Weighted_point; /*! */ -typedef SpatialLockDataStructure_3 Lock_data_structure; +typedef SurjectiveLockDataStructure Lock_data_structure; /// @} @@ -83,12 +85,12 @@ must be provided if concurrency is enabled. */ Regular_triangulation_3 (const RegularTriangulationTraits_3 & traits = RegularTriangulationTraits_3(), -SpatialLockDataStructure_3 *lock_ds = NULL); +Lock_data_structure *lock_ds = NULL); /*! Copy constructor. The pointer to the lock data structure is not copied. Thus, the copy won't be -concurrency-safe as long as the user has not called `set_lock_data_structure`. +concurrency-safe as long as the user has not called `Triangulation_3::set_lock_data_structure`. */ Regular_triangulation_3 (const Regular_triangulation_3 & rt1); @@ -101,14 +103,14 @@ traits class argument and calling `insert(first,last)`. template < class InputIterator > Regular_triangulation_3 (InputIterator first, InputIterator last, const RegularTriangulationTraits_3& traits = RegularTriangulationTraits_3(), -SpatialLockDataStructure_3 *lock_ds = NULL); +Lock_data_structure *lock_ds = NULL); /*! Same as before, with last two parameters in reverse order. */ template < class InputIterator > Regular_triangulation_3 (InputIterator first, InputIterator last, -SpatialLockDataStructure_3 *lock_ds, +Lock_data_structure *lock_ds, const RegularTriangulationTraits_3& traits = RegularTriangulationTraits_3()); /// @} diff --git a/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h b/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h index 830877439a8..5943ac93caa 100644 --- a/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h +++ b/Triangulation_3/doc/Triangulation_3/CGAL/Triangulation_3.h @@ -12,14 +12,16 @@ of points. \tparam TriangulationDataStructure_3 is the triangulation data structure. It has the default value `Triangulation_data_structure_3< Triangulation_vertex_base_3,Triangulation_cell_base_3 >`. -\tparam SpatialLockDataStructure_3 is an optional parameter to specify the type of the spatial lock data structure. -It is only used if the triangulation data structure used is concurrency-safe (i.e.\ when -TriangulationDataStructure_3::Concurrency_tag is Parallel_tag). -It must be a model of the `SpatialLockDataStructure_3` concept. -The default value is `Spatial_grid_lock_data_structure_3` if -the triangulation data structure is concurrency-safe, and `void` otherwise. -In order to use concurrent operations, the user must provide a reference to a `SpatialLockDataStructure_3` -instance via the constructor or `set_lock_data_structure`. +\tparam SurjectiveLockDataStructure is an optional parameter to specify the type of the spatial lock data structure. + It is only used if the triangulation data structure used is concurrency-safe (i.e.\ when + TriangulationDataStructure_3::Concurrency_tag is Parallel_tag). + It must be a model of the `SurjectiveLockDataStructure` concept, + with `Object` being a `Point`. + The default value is `Spatial_lock_grid_3` if + the triangulation data structure is concurrency-safe, and `void` otherwise. + In order to use concurrent operations, the user must provide a + reference to a `SurjectiveLockDataStructure` + instance via the constructor or `Triangulation_3::set_lock_data_structure`. \cgalHeading{Traversal of the Triangulation} @@ -31,7 +33,7 @@ that allow one to traverse it (completely or partially). */ template< typename TriangulationTraits_3, typename TriangulationDataStructure_3, - typename SpatialLockDataStructure_3 > + typename SurjectiveLockDataStructure > class Triangulation_3 : public Triangulation_utils_3 { public: @@ -54,6 +56,11 @@ typedef TriangulationDataStructure_3 Triangulation_data_structure; /*! +*/ +typedef SurjectiveLockDataStructure Lock_data_structure; + +/*! + */ typedef TriangulationTraits_3 Geom_traits; @@ -222,19 +229,19 @@ must be provided if concurrency is enabled. */ Triangulation_3 (const TriangulationTraits_3 & traits = TriangulationTraits_3(), - SpatialLockDataStructure_3 *lock_ds = NULL); + Lock_data_structure *lock_ds = NULL); /*! Same as the previous one, but with parameters in reverse order. */ Triangulation_3 -(SpatialLockDataStructure_3 *lock_ds = NULL, +(Lock_data_structure *lock_ds = NULL, const TriangulationTraits_3 & traits = TriangulationTraits_3()); /*! Copy constructor. All vertices and faces are duplicated. The pointer to the lock data structure is not copied. Thus, the copy won't be -concurrency-safe as long as the user has not call `set_lock_data_structure`. +concurrency-safe as long as the user has not call `Triangulation_3::set_lock_data_structure`. */ Triangulation_3 (const Triangulation_3 & tr); @@ -245,7 +252,7 @@ traits class argument and calling `insert(first,last)`. template < class InputIterator> Triangulation_3 (InputIterator first, InputIterator last, const TriangulationTraits_3 & traits = TriangulationTraits_3(), -SpatialLockDataStructure_3 *lock_ds = NULL); +Lock_data_structure *lock_ds = NULL); /// @} @@ -1406,7 +1413,7 @@ ostream& operator<< (ostream& os, const Triangulation_3 &t); /*! Set the pointer to the lock data structure. */ -void set_lock_data_structure(SpatialLockDataStructure_3 *lock_ds) const; +void set_lock_data_structure(Lock_data_structure *lock_ds) const; /// @} diff --git a/Triangulation_3/doc/Triangulation_3/PackageDescription.txt b/Triangulation_3/doc/Triangulation_3/PackageDescription.txt index 89488412820..15e98ab2e76 100644 --- a/Triangulation_3/doc/Triangulation_3/PackageDescription.txt +++ b/Triangulation_3/doc/Triangulation_3/PackageDescription.txt @@ -83,10 +83,10 @@ is opposite to the vertex with the same index. See ### Main Classes ### -- `CGAL::Triangulation_3` -- `CGAL::Delaunay_triangulation_3` +- `CGAL::Triangulation_3` +- `CGAL::Delaunay_triangulation_3` - `CGAL::Triangulation_hierarchy_3` -- `CGAL::Regular_triangulation_3` +- `CGAL::Regular_triangulation_3` - `CGAL::Triangulation_cell_base_3` - `CGAL::Triangulation_cell_base_with_info_3` - `CGAL::Triangulation_cell_base_with_circumcenter_3` diff --git a/Triangulation_3/doc/Triangulation_3/Triangulation_3.txt b/Triangulation_3/doc/Triangulation_3/Triangulation_3.txt index 6d909dbd675..5fbc2b72eb4 100644 --- a/Triangulation_3/doc/Triangulation_3/Triangulation_3.txt +++ b/Triangulation_3/doc/Triangulation_3/Triangulation_3.txt @@ -225,9 +225,9 @@ triangulation class, described in Section \ref Triangulation3seclocpol. Optionally, the main Delaunay and regular triangulations algorithms (insert, remove) support multi-core shared-memory architectures to take advantage of available parallelism. -For this purpose, a model of the concept `SpatialLockDataStructure_3` can be +For this purpose, a model of the concept `SurjectiveLockDataStructure` can be given as fourth template parameter; it defaults to -`Spatial_grid_lock_data_structure_3`. This data structure +`Spatial_lock_grid_3`. This data structure allows to lock points with coordinates (x, y, z) in a 3D domain. When a thread owns the lock on a point, no other thread can lock this point. Locking a facet (resp. a cell) boils down to locking all its 3 (resp. 4) incident vertices. @@ -417,14 +417,14 @@ Section \ref TDS3secdesign "Software Design" provides more detailed information. Parallel algorithms of `Delaunay_triangulation_3` and `Regular_triangulation_3` are enabled if the `TriangulationDataStructure_3::Concurrency_tag` type is `Parallel_tag` and a -reference to a `SpatialLockDataStructure_3` instance is provided via the constructor or -by using `set_lock_data_structure`. Note that the parallel Delaunay +reference to a lock data structure instance is provided via the constructor or +by using `Triangulation_3::set_lock_data_structure`. Note that the parallel Delaunay triangulation must use the default compact location policy (and not the fast one). Parallel algorithms require the program to be linked against the Intel TBB library. To control the number of threads used, the user may use the tbb::task_scheduler_init class. -See TBB documentation for more details. +See the TBB documentation for more details. \section Triangulation3secexamples Examples diff --git a/Triangulation_3/include/CGAL/Triangulation_3.h b/Triangulation_3/include/CGAL/Triangulation_3.h index e3821ea611a..21e888f8eaf 100644 --- a/Triangulation_3/include/CGAL/Triangulation_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_3.h @@ -51,7 +51,7 @@ #include #include -#include +#include #include #include @@ -192,10 +192,9 @@ template class Triangulation_3_base { public: - // If Lock_data_structure_ = Default => use Spatial_grid_lock_data_structure_3 + // If Lock_data_structure_ = Default => use Spatial_lock_grid_3 typedef typename Default::Get< - Lock_data_structure_, - Spatial_grid_lock_data_structure_3 > + Lock_data_structure_, Spatial_lock_grid_3 > ::type Lock_data_structure; protected: diff --git a/Triangulation_3/include/CGAL/Triangulation_data_structure_3.h b/Triangulation_3/include/CGAL/Triangulation_data_structure_3.h index 5bd25908d29..564c6565bda 100644 --- a/Triangulation_3/include/CGAL/Triangulation_data_structure_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_data_structure_3.h @@ -458,9 +458,8 @@ public: template bool is_cell_locked_by_this_thread(const Cell_handle &cell_handle) const { - CGAL::Spatial_grid_lock_data_structure_3< - Tag_priority_blocking> *lock_ds = - CGAL::Spatial_grid_lock_data_structure_3::get_global_lock_ds(); + CGAL::Spatial_lock_grid_3 *lock_ds = + CGAL::Spatial_lock_grid_3::get_global_lock_ds(); bool locked = true; if (lock_ds) {