mirror of https://github.com/CGAL/cgal
Merge pull request #4468 from maxGimeno/TBB-Fix_deprecation_warnings-5_0-maxGimeno
TBB deprecated code replacement
This commit is contained in:
commit
5fc7b97e32
|
|
@ -38,7 +38,7 @@
|
||||||
#include <tbb/parallel_for.h>
|
#include <tbb/parallel_for.h>
|
||||||
#include <tbb/blocked_range.h>
|
#include <tbb/blocked_range.h>
|
||||||
#include <tbb/scalable_allocator.h>
|
#include <tbb/scalable_allocator.h>
|
||||||
#include <tbb/mutex.h>
|
#include <mutex>
|
||||||
#endif // CGAL_LINKED_WITH_TBB
|
#endif // CGAL_LINKED_WITH_TBB
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
#include <boost/make_shared.hpp>
|
#include <boost/make_shared.hpp>
|
||||||
|
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
#include <tbb/mutex.h>
|
#include <mutex>
|
||||||
#include <tbb/task_group.h>
|
#include <tbb/task_group.h>
|
||||||
#endif // CGAL_LINKED_WITH_TBB
|
#endif // CGAL_LINKED_WITH_TBB
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,8 @@
|
||||||
#include <tbb/parallel_for.h>
|
#include <tbb/parallel_for.h>
|
||||||
#include <tbb/blocked_range.h>
|
#include <tbb/blocked_range.h>
|
||||||
#include <tbb/scalable_allocator.h>
|
#include <tbb/scalable_allocator.h>
|
||||||
#include <tbb/mutex.h>
|
#include <mutex>
|
||||||
|
|
||||||
#endif // CGAL_LINKED_WITH_TBB
|
#endif // CGAL_LINKED_WITH_TBB
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
@ -69,7 +70,7 @@ private:
|
||||||
PointMap m_point_map;
|
PointMap m_point_map;
|
||||||
const NeighborQuery& m_neighbor_query;
|
const NeighborQuery& m_neighbor_query;
|
||||||
float& m_mean_range;
|
float& m_mean_range;
|
||||||
tbb::mutex& m_mutex;
|
std::mutex& m_mutex;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
@ -78,7 +79,7 @@ private:
|
||||||
PointMap point_map,
|
PointMap point_map,
|
||||||
const NeighborQuery& neighbor_query,
|
const NeighborQuery& neighbor_query,
|
||||||
float& mean_range,
|
float& mean_range,
|
||||||
tbb::mutex& mutex)
|
std::mutex& mutex)
|
||||||
: m_eigen (eigen), m_input (input), m_point_map (point_map),
|
: m_eigen (eigen), m_input (input), m_point_map (point_map),
|
||||||
m_neighbor_query (neighbor_query), m_mean_range (mean_range), m_mutex (mutex)
|
m_neighbor_query (neighbor_query), m_mean_range (mean_range), m_mutex (mutex)
|
||||||
{ }
|
{ }
|
||||||
|
|
@ -120,7 +121,7 @@ private:
|
||||||
const FaceListGraph& m_input;
|
const FaceListGraph& m_input;
|
||||||
const NeighborQuery& m_neighbor_query;
|
const NeighborQuery& m_neighbor_query;
|
||||||
float& m_mean_range;
|
float& m_mean_range;
|
||||||
tbb::mutex& m_mutex;
|
std::mutex& m_mutex;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
@ -128,7 +129,7 @@ private:
|
||||||
const FaceListGraph& input,
|
const FaceListGraph& input,
|
||||||
const NeighborQuery& neighbor_query,
|
const NeighborQuery& neighbor_query,
|
||||||
float& mean_range,
|
float& mean_range,
|
||||||
tbb::mutex& mutex)
|
std::mutex& mutex)
|
||||||
: m_eigen (eigen), m_input (input),
|
: m_eigen (eigen), m_input (input),
|
||||||
m_neighbor_query (neighbor_query), m_mean_range (mean_range), m_mutex (mutex)
|
m_neighbor_query (neighbor_query), m_mean_range (mean_range), m_mutex (mutex)
|
||||||
{ }
|
{ }
|
||||||
|
|
@ -271,7 +272,7 @@ public:
|
||||||
#else
|
#else
|
||||||
if (boost::is_convertible<ConcurrencyTag,Parallel_tag>::value)
|
if (boost::is_convertible<ConcurrencyTag,Parallel_tag>::value)
|
||||||
{
|
{
|
||||||
tbb::mutex mutex;
|
std::mutex mutex;
|
||||||
Compute_eigen_values<PointRange, PointMap, NeighborQuery, DiagonalizeTraits>
|
Compute_eigen_values<PointRange, PointMap, NeighborQuery, DiagonalizeTraits>
|
||||||
f(out, input, point_map, neighbor_query, out.m_content->mean_range, mutex);
|
f(out, input, point_map, neighbor_query, out.m_content->mean_range, mutex);
|
||||||
tbb::parallel_for(tbb::blocked_range<size_t>(0, input.size ()), f);
|
tbb::parallel_for(tbb::blocked_range<size_t>(0, input.size ()), f);
|
||||||
|
|
@ -361,7 +362,7 @@ public:
|
||||||
#else
|
#else
|
||||||
if (boost::is_convertible<ConcurrencyTag,Parallel_tag>::value)
|
if (boost::is_convertible<ConcurrencyTag,Parallel_tag>::value)
|
||||||
{
|
{
|
||||||
tbb::mutex mutex;
|
std::mutex mutex;
|
||||||
Compute_eigen_values_graph<FaceListGraph, NeighborQuery, DiagonalizeTraits>
|
Compute_eigen_values_graph<FaceListGraph, NeighborQuery, DiagonalizeTraits>
|
||||||
f(out, input, neighbor_query, out.m_content->mean_range, mutex);
|
f(out, input, neighbor_query, out.m_content->mean_range, mutex);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
#include <tbb/task_group.h>
|
#include <tbb/task_group.h>
|
||||||
#include <tbb/mutex.h>
|
#include <mutex>
|
||||||
#endif // CGAL_LINKED_WITH_TBB
|
#endif // CGAL_LINKED_WITH_TBB
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
#include <tbb/parallel_for.h>
|
#include <tbb/parallel_for.h>
|
||||||
#include <tbb/blocked_range.h>
|
#include <tbb/blocked_range.h>
|
||||||
#include <tbb/scalable_allocator.h>
|
#include <tbb/scalable_allocator.h>
|
||||||
#include <tbb/mutex.h>
|
#include <mutex>
|
||||||
#endif // CGAL_LINKED_WITH_TBB
|
#endif // CGAL_LINKED_WITH_TBB
|
||||||
|
|
||||||
#define CLASSIFICATION_TRAINING_QUICK_ESTIMATION
|
#define CLASSIFICATION_TRAINING_QUICK_ESTIMATION
|
||||||
|
|
@ -72,9 +72,9 @@ private:
|
||||||
std::vector<std::size_t>& m_true_positives;
|
std::vector<std::size_t>& m_true_positives;
|
||||||
std::vector<std::size_t>& m_false_positives;
|
std::vector<std::size_t>& m_false_positives;
|
||||||
std::vector<std::size_t>& m_false_negatives;
|
std::vector<std::size_t>& m_false_negatives;
|
||||||
std::vector<tbb::mutex>& m_tp_mutex;
|
std::vector<std::mutex>& m_tp_mutex;
|
||||||
std::vector<tbb::mutex>& m_fp_mutex;
|
std::vector<std::mutex>& m_fp_mutex;
|
||||||
std::vector<tbb::mutex>& m_fn_mutex;
|
std::vector<std::mutex>& m_fn_mutex;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -85,9 +85,9 @@ private:
|
||||||
std::vector<std::size_t>& true_positives,
|
std::vector<std::size_t>& true_positives,
|
||||||
std::vector<std::size_t>& false_positives,
|
std::vector<std::size_t>& false_positives,
|
||||||
std::vector<std::size_t>& false_negatives,
|
std::vector<std::size_t>& false_negatives,
|
||||||
std::vector<tbb::mutex>& tp_mutex,
|
std::vector<std::mutex>& tp_mutex,
|
||||||
std::vector<tbb::mutex>& fp_mutex,
|
std::vector<std::mutex>& fp_mutex,
|
||||||
std::vector<tbb::mutex>& fn_mutex)
|
std::vector<std::mutex>& fn_mutex)
|
||||||
: m_training_set (training_set)
|
: m_training_set (training_set)
|
||||||
, m_classifier (classifier)
|
, m_classifier (classifier)
|
||||||
, m_label (label)
|
, m_label (label)
|
||||||
|
|
@ -901,9 +901,9 @@ private:
|
||||||
#else
|
#else
|
||||||
if (boost::is_convertible<ConcurrencyTag,Parallel_tag>::value)
|
if (boost::is_convertible<ConcurrencyTag,Parallel_tag>::value)
|
||||||
{
|
{
|
||||||
std::vector<tbb::mutex> tp_mutex (m_labels.size());
|
std::vector<std::mutex> tp_mutex (m_labels.size());
|
||||||
std::vector<tbb::mutex> fp_mutex (m_labels.size());
|
std::vector<std::mutex> fp_mutex (m_labels.size());
|
||||||
std::vector<tbb::mutex> fn_mutex (m_labels.size());
|
std::vector<std::mutex> fn_mutex (m_labels.size());
|
||||||
Compute_iou f(training_sets[j], *this, j,
|
Compute_iou f(training_sets[j], *this, j,
|
||||||
true_positives, false_positives, false_negatives,
|
true_positives, false_positives, false_negatives,
|
||||||
tp_mutex, fp_mutex, fn_mutex);
|
tp_mutex, fp_mutex, fn_mutex);
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
#include <tbb/parallel_for.h>
|
#include <tbb/parallel_for.h>
|
||||||
#include <tbb/blocked_range.h>
|
#include <tbb/blocked_range.h>
|
||||||
#include <tbb/scalable_allocator.h>
|
#include <tbb/scalable_allocator.h>
|
||||||
#include <tbb/mutex.h>
|
#include <mutex>
|
||||||
#endif // CGAL_LINKED_WITH_TBB
|
#endif // CGAL_LINKED_WITH_TBB
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,64 @@
|
||||||
|
|
||||||
|
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
# include <tbb/atomic.h>
|
# include <atomic>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace internal_tbb
|
||||||
|
{
|
||||||
|
//classic pointer{
|
||||||
|
//normal
|
||||||
|
template<typename T>
|
||||||
|
void set_weighted_circumcenter(T* &t, T* value)
|
||||||
|
{
|
||||||
|
t = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//overload for nullptr
|
||||||
|
template<typename T>
|
||||||
|
void set_weighted_circumcenter(T* &t, std::nullptr_t)
|
||||||
|
{
|
||||||
|
t = nullptr;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
bool compare_weighted_circumcenter(T* t)
|
||||||
|
{
|
||||||
|
return t == nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void delete_circumcenter(T* &t )
|
||||||
|
{
|
||||||
|
delete t;
|
||||||
|
}
|
||||||
|
//} atomic {
|
||||||
|
//normal
|
||||||
|
template<typename T>
|
||||||
|
void set_weighted_circumcenter(std::atomic<T*>& t, T* value)
|
||||||
|
{
|
||||||
|
t.load() = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//nullptr
|
||||||
|
template<typename T>
|
||||||
|
void set_weighted_circumcenter(std::atomic<T*>& t, std::nullptr_t)
|
||||||
|
{
|
||||||
|
t = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool compare_weighted_circumcenter(std::atomic<T*>& t)
|
||||||
|
{
|
||||||
|
return t.load() == nullptr;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
void delete_circumcenter(std::atomic<T*>& t)
|
||||||
|
{
|
||||||
|
delete t.load();
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
} //end internal_tbb
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
// Class Compact_mesh_cell_base_3_base
|
// Class Compact_mesh_cell_base_3_base
|
||||||
|
|
@ -52,8 +107,9 @@ class Compact_mesh_cell_base_3_base
|
||||||
protected:
|
protected:
|
||||||
Compact_mesh_cell_base_3_base()
|
Compact_mesh_cell_base_3_base()
|
||||||
: bits_(0)
|
: bits_(0)
|
||||||
, weighted_circumcenter_(nullptr)
|
{
|
||||||
{}
|
internal_tbb::set_weighted_circumcenter(weighted_circumcenter_, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#if defined(CGAL_MESH_3_USE_LAZY_SORTED_REFINEMENT_QUEUE) \
|
#if defined(CGAL_MESH_3_USE_LAZY_SORTED_REFINEMENT_QUEUE) \
|
||||||
|
|
@ -152,7 +208,8 @@ public:
|
||||||
{
|
{
|
||||||
CGAL_precondition(facet>=0 && facet<4);
|
CGAL_precondition(facet>=0 && facet<4);
|
||||||
char current_bits = bits_;
|
char current_bits = bits_;
|
||||||
while (bits_.compare_and_swap(current_bits | char(1 << facet), current_bits) != current_bits)
|
|
||||||
|
while (!bits_.compare_exchange_weak(current_bits, current_bits | char(1 << facet)))
|
||||||
{
|
{
|
||||||
current_bits = bits_;
|
current_bits = bits_;
|
||||||
}
|
}
|
||||||
|
|
@ -165,7 +222,7 @@ public:
|
||||||
char current_bits = bits_;
|
char current_bits = bits_;
|
||||||
char mask = char(15 & ~(1 << facet));
|
char mask = char(15 & ~(1 << facet));
|
||||||
char wanted_value = current_bits & mask;
|
char wanted_value = current_bits & mask;
|
||||||
while (bits_.compare_and_swap(wanted_value, current_bits) != current_bits)
|
while (!bits_.compare_exchange_weak(current_bits, wanted_value))
|
||||||
{
|
{
|
||||||
current_bits = bits_;
|
current_bits = bits_;
|
||||||
}
|
}
|
||||||
|
|
@ -182,18 +239,19 @@ public:
|
||||||
/// this function "deletes" cc
|
/// this function "deletes" cc
|
||||||
void try_to_set_circumcenter(Point_3 *cc) const
|
void try_to_set_circumcenter(Point_3 *cc) const
|
||||||
{
|
{
|
||||||
if (weighted_circumcenter_.compare_and_swap(cc, nullptr) != nullptr)
|
Point_3* base_test = nullptr;
|
||||||
|
if (!weighted_circumcenter_.compare_exchange_strong(base_test, cc))
|
||||||
delete cc;
|
delete cc;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef tbb::atomic<unsigned int> Erase_counter_type;
|
typedef std::atomic<unsigned int> Erase_counter_type;
|
||||||
Erase_counter_type m_erase_counter;
|
Erase_counter_type m_erase_counter;
|
||||||
/// Stores visited facets (4 first bits)
|
/// Stores visited facets (4 first bits)
|
||||||
tbb::atomic<char> bits_;
|
std::atomic<char> bits_;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
mutable tbb::atomic<Point_3*> weighted_circumcenter_;
|
mutable std::atomic<Point_3*> weighted_circumcenter_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CGAL_LINKED_WITH_TBB
|
#endif // CGAL_LINKED_WITH_TBB
|
||||||
|
|
@ -244,9 +302,9 @@ public:
|
||||||
public:
|
public:
|
||||||
void invalidate_weighted_circumcenter_cache() const
|
void invalidate_weighted_circumcenter_cache() const
|
||||||
{
|
{
|
||||||
if (weighted_circumcenter_) {
|
if (!internal_tbb::compare_weighted_circumcenter(weighted_circumcenter_)) {
|
||||||
delete weighted_circumcenter_;
|
internal_tbb::delete_circumcenter(weighted_circumcenter_);
|
||||||
weighted_circumcenter_ = nullptr;
|
internal_tbb::set_weighted_circumcenter(weighted_circumcenter_, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -328,8 +386,9 @@ public:
|
||||||
|
|
||||||
~Compact_mesh_cell_base_3()
|
~Compact_mesh_cell_base_3()
|
||||||
{
|
{
|
||||||
if(weighted_circumcenter_ != nullptr){
|
if(!internal_tbb::compare_weighted_circumcenter(weighted_circumcenter_)){
|
||||||
delete weighted_circumcenter_;
|
internal_tbb::delete_circumcenter(weighted_circumcenter_);
|
||||||
|
internal_tbb::set_weighted_circumcenter(weighted_circumcenter_, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
|
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
# include <tbb/parallel_do.h>
|
# include <tbb/parallel_do.h>
|
||||||
# include <tbb/mutex.h>
|
# include <mutex>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
@ -595,7 +595,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
Lock_data_structure *m_lock_ds;
|
Lock_data_structure *m_lock_ds;
|
||||||
|
|
||||||
typedef tbb::mutex Mutex_type;
|
typedef std::mutex Mutex_type;
|
||||||
mutable Mutex_type m_mut_outdated_cells;
|
mutable Mutex_type m_mut_outdated_cells;
|
||||||
mutable Mutex_type m_mut_moving_vertices;
|
mutable Mutex_type m_mut_moving_vertices;
|
||||||
mutable Mutex_type m_mut_vertex_to_proj;
|
mutable Mutex_type m_mut_vertex_to_proj;
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
|
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
#include <tbb/atomic.h>
|
#include <atomic>
|
||||||
#include <tbb/concurrent_hash_map.h>
|
#include <tbb/concurrent_hash_map.h>
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
@ -174,7 +174,7 @@ public:
|
||||||
, manifold_info_initialized_(false) //TODO: parallel!
|
, manifold_info_initialized_(false) //TODO: parallel!
|
||||||
{
|
{
|
||||||
// We don't put it in the initialization list because
|
// We don't put it in the initialization list because
|
||||||
// tbb::atomic has no contructors
|
// std::atomic has no contructors
|
||||||
number_of_facets_ = 0;
|
number_of_facets_ = 0;
|
||||||
number_of_cells_ = 0;
|
number_of_cells_ = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -186,8 +186,9 @@ public:
|
||||||
, edge_facet_counter_(rhs.edge_facet_counter_)
|
, edge_facet_counter_(rhs.edge_facet_counter_)
|
||||||
, manifold_info_initialized_(rhs.manifold_info_initialized_)
|
, manifold_info_initialized_(rhs.manifold_info_initialized_)
|
||||||
{
|
{
|
||||||
number_of_facets_ = rhs.number_of_facets_;
|
Init_number_of_elements<Concurrency_tag> init;
|
||||||
number_of_cells_ = rhs.number_of_cells_;
|
init(number_of_facets_, rhs.number_of_facets_);
|
||||||
|
init(number_of_cells_, rhs.number_of_cells_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
|
|
@ -505,9 +506,10 @@ public:
|
||||||
/// Swaps this & rhs
|
/// Swaps this & rhs
|
||||||
void swap(Self& rhs)
|
void swap(Self& rhs)
|
||||||
{
|
{
|
||||||
std::swap(rhs.number_of_facets_, number_of_facets_);
|
Swap_elements<Concurrency_tag> swapper;
|
||||||
|
swapper(rhs.number_of_facets_, number_of_facets_);
|
||||||
tr_.swap(rhs.tr_);
|
tr_.swap(rhs.tr_);
|
||||||
std::swap(rhs.number_of_cells_, number_of_cells_);
|
swapper(rhs.number_of_cells_, number_of_cells_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns bbox
|
/// Returns bbox
|
||||||
|
|
@ -850,12 +852,55 @@ private:
|
||||||
{
|
{
|
||||||
typedef size_type type;
|
typedef size_type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename Concurrency_tag2, typename dummy = void>
|
||||||
|
struct Init_number_of_elements
|
||||||
|
{
|
||||||
|
template<typename T>
|
||||||
|
void operator()(T& a, const T& b)
|
||||||
|
{
|
||||||
|
a = b;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Concurrency_tag2, typename dummy = void>
|
||||||
|
struct Swap_elements
|
||||||
|
{
|
||||||
|
template<typename T>
|
||||||
|
void operator()(T& a, T& b)
|
||||||
|
{
|
||||||
|
std::swap(a, b);
|
||||||
|
}
|
||||||
|
};
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
// Parallel: atomic
|
// Parallel: atomic
|
||||||
template<typename dummy>
|
template<typename dummy>
|
||||||
struct Number_of_elements<Parallel_tag, dummy>
|
struct Number_of_elements<Parallel_tag, dummy>
|
||||||
{
|
{
|
||||||
typedef tbb::atomic<size_type> type;
|
typedef std::atomic<size_type> type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename dummy>
|
||||||
|
struct Init_number_of_elements<Parallel_tag, dummy>
|
||||||
|
{
|
||||||
|
template<typename T>
|
||||||
|
void operator()(T& a, const T& b)
|
||||||
|
{
|
||||||
|
a = b.load();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename dummy>
|
||||||
|
struct Swap_elements<Parallel_tag, dummy>
|
||||||
|
{
|
||||||
|
template<typename T>
|
||||||
|
void operator()(T& a, T& b)
|
||||||
|
{
|
||||||
|
T tmp;
|
||||||
|
tmp.exchange(a);
|
||||||
|
a.exchange(b);
|
||||||
|
b.exchange(tmp);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
#endif // CGAL_LINKED_WITH_TBB
|
#endif // CGAL_LINKED_WITH_TBB
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,8 @@
|
||||||
#include <boost/type_traits/is_convertible.hpp>
|
#include <boost/type_traits/is_convertible.hpp>
|
||||||
|
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
# include <tbb/atomic.h>
|
# include <atomic>
|
||||||
|
# include <mutex>
|
||||||
# include <tbb/parallel_do.h>
|
# include <tbb/parallel_do.h>
|
||||||
# include <tbb/concurrent_vector.h>
|
# include <tbb/concurrent_vector.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -122,7 +123,7 @@ protected:
|
||||||
typedef typename Tr::Lock_data_structure Lock_data_structure;
|
typedef typename Tr::Lock_data_structure Lock_data_structure;
|
||||||
typedef tbb::concurrent_vector<std::tuple<typename Tr::Vertex_handle, Vector_3, FT> >
|
typedef tbb::concurrent_vector<std::tuple<typename Tr::Vertex_handle, Vector_3, FT> >
|
||||||
Moves_vector;
|
Moves_vector;
|
||||||
typedef tbb::atomic<unsigned int> Nb_frozen_points_type ;
|
typedef std::atomic<unsigned int> Nb_frozen_points_type ;
|
||||||
|
|
||||||
Mesh_global_optimizer_base(const Bbox_3 &bbox, int num_grid_cells_per_axis)
|
Mesh_global_optimizer_base(const Bbox_3 &bbox, int num_grid_cells_per_axis)
|
||||||
: big_moves_size_(0)
|
: big_moves_size_(0)
|
||||||
|
|
@ -136,7 +137,7 @@ protected:
|
||||||
{
|
{
|
||||||
if (++big_moves_current_size_ <= big_moves_size_ )
|
if (++big_moves_current_size_ <= big_moves_size_ )
|
||||||
{
|
{
|
||||||
tbb::mutex::scoped_lock lock(m_big_moves_mutex);
|
std::lock_guard<std::mutex> lock(m_big_moves_mutex);
|
||||||
typename std::multiset<FT>::const_iterator it = big_moves_.insert(new_sq_move);
|
typename std::multiset<FT>::const_iterator it = big_moves_.insert(new_sq_move);
|
||||||
|
|
||||||
// New smallest move of all big moves?
|
// New smallest move of all big moves?
|
||||||
|
|
@ -149,7 +150,7 @@ protected:
|
||||||
|
|
||||||
if( new_sq_move > big_moves_smallest_ )
|
if( new_sq_move > big_moves_smallest_ )
|
||||||
{
|
{
|
||||||
tbb::mutex::scoped_lock lock(m_big_moves_mutex);
|
std::lock_guard<std::mutex> lock(m_big_moves_mutex);
|
||||||
// Test it again since it may have been modified by another
|
// Test it again since it may have been modified by another
|
||||||
// thread in the meantime
|
// thread in the meantime
|
||||||
if( new_sq_move > big_moves_smallest_ )
|
if( new_sq_move > big_moves_smallest_ )
|
||||||
|
|
@ -185,11 +186,11 @@ protected:
|
||||||
public:
|
public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
tbb::atomic<std::size_t> big_moves_current_size_;
|
std::atomic<std::size_t> big_moves_current_size_;
|
||||||
tbb::atomic<FT> big_moves_smallest_;
|
std::atomic<FT> big_moves_smallest_;
|
||||||
std::size_t big_moves_size_;
|
std::size_t big_moves_size_;
|
||||||
std::multiset<FT> big_moves_;
|
std::multiset<FT> big_moves_;
|
||||||
tbb::mutex m_big_moves_mutex;
|
std::mutex m_big_moves_mutex;
|
||||||
|
|
||||||
/// Lock data structure
|
/// Lock data structure
|
||||||
Lock_data_structure m_lock_ds;
|
Lock_data_structure m_lock_ds;
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
#include <CGAL/Mesh_3/io_signature.h>
|
#include <CGAL/Mesh_3/io_signature.h>
|
||||||
|
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
# include <tbb/atomic.h>
|
# include <atomic>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
@ -123,7 +123,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Stores visited facets (4 first bits)
|
/// Stores visited facets (4 first bits)
|
||||||
tbb::atomic<char> bits_;
|
std::atomic<char> bits_;
|
||||||
};
|
};
|
||||||
#endif // CGAL_LINKED_WITH_TBB
|
#endif // CGAL_LINKED_WITH_TBB
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
# include <tbb/task_scheduler_init.h>
|
# include <thread>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
|
|
@ -659,7 +659,7 @@ initialize()
|
||||||
# endif
|
# endif
|
||||||
Random_points_on_sphere_3<Bare_point> random_point(radius);
|
Random_points_on_sphere_3<Bare_point> random_point(radius);
|
||||||
const int NUM_PSEUDO_INFINITE_VERTICES = static_cast<int>(
|
const int NUM_PSEUDO_INFINITE_VERTICES = static_cast<int>(
|
||||||
float(tbb::task_scheduler_init::default_num_threads())
|
float(std::thread::hardware_concurrency())
|
||||||
* Concurrent_mesher_config::get().num_pseudo_infinite_vertices_per_core);
|
* Concurrent_mesher_config::get().num_pseudo_infinite_vertices_per_core);
|
||||||
for (int i = 0 ; i < NUM_PSEUDO_INFINITE_VERTICES ; ++i, ++random_point)
|
for (int i = 0 ; i < NUM_PSEUDO_INFINITE_VERTICES ; ++i, ++random_point)
|
||||||
r_c3t3_.add_far_point(r_c3t3_.triangulation().geom_traits().construct_weighted_point_3_object()
|
r_c3t3_.add_far_point(r_c3t3_.triangulation().geom_traits().construct_weighted_point_3_object()
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
#include <tbb/concurrent_vector.h>
|
#include <tbb/concurrent_vector.h>
|
||||||
#include <tbb/scalable_allocator.h>
|
#include <tbb/scalable_allocator.h>
|
||||||
|
|
||||||
#include <tbb/atomic.h>
|
#include <atomic>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
@ -65,8 +65,8 @@ public:
|
||||||
|
|
||||||
m_num_cells =
|
m_num_cells =
|
||||||
num_grid_cells_per_axis*num_grid_cells_per_axis*num_grid_cells_per_axis;
|
num_grid_cells_per_axis*num_grid_cells_per_axis*num_grid_cells_per_axis;
|
||||||
m_occupation_grid = new tbb::atomic<int>[m_num_cells];
|
m_occupation_grid = new std::atomic<int>[m_num_cells];
|
||||||
m_num_batches_grid = new tbb::atomic<int>[m_num_cells];
|
m_num_batches_grid = new std::atomic<int>[m_num_cells];
|
||||||
// Initialize grid
|
// Initialize grid
|
||||||
for (int i = 0 ; i < m_num_cells ; ++i)
|
for (int i = 0 ; i < m_num_cells ; ++i)
|
||||||
{
|
{
|
||||||
|
|
@ -106,15 +106,15 @@ public:
|
||||||
|
|
||||||
void add_batch(int cell_index, int to_add)
|
void add_batch(int cell_index, int to_add)
|
||||||
{
|
{
|
||||||
m_num_batches_grid[cell_index].fetch_and_add(to_add);
|
m_num_batches_grid[cell_index].fetch_add(to_add);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_occupation(int cell_index, int to_add, int)
|
void add_occupation(int cell_index, int to_add, int)
|
||||||
{
|
{
|
||||||
m_occupation_grid[cell_index].fetch_and_add(to_add);
|
m_occupation_grid[cell_index].fetch_add(to_add);
|
||||||
|
|
||||||
/*int new_occupation =
|
/*int new_occupation =
|
||||||
(m_occupation_grid[cell_index].fetch_and_add(to_add))
|
(m_occupation_grid[cell_index].fetch_add(to_add))
|
||||||
+ to_add;
|
+ to_add;
|
||||||
//m_num_batches_grid[cell_index] = num_items_in_work_queue;
|
//m_num_batches_grid[cell_index] = num_items_in_work_queue;
|
||||||
|
|
||||||
|
|
@ -221,7 +221,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
// Rotate
|
// Rotate
|
||||||
static tbb::atomic<int> last_cell_index;
|
static std::atomic<int> last_cell_index;
|
||||||
//std::cerr << "last=" << last_cell_index << std::endl;
|
//std::cerr << "last=" << last_cell_index << std::endl;
|
||||||
int i = (last_cell_index + 1) % m_num_cells;
|
int i = (last_cell_index + 1) % m_num_cells;
|
||||||
for ( ; i != last_cell_index ; i = (i + 1) % m_num_cells)
|
for ( ; i != last_cell_index ; i = (i + 1) % m_num_cells)
|
||||||
|
|
@ -246,11 +246,11 @@ protected:
|
||||||
|
|
||||||
int m_num_grid_cells_per_axis;
|
int m_num_grid_cells_per_axis;
|
||||||
int m_num_cells;
|
int m_num_cells;
|
||||||
tbb::atomic<int> * m_occupation_grid;
|
std::atomic<int> * m_occupation_grid;
|
||||||
tbb::atomic<int> * m_num_batches_grid;
|
std::atomic<int> * m_num_batches_grid;
|
||||||
|
|
||||||
tbb::atomic<int> m_laziest_cell_index;
|
std::atomic<int> m_laziest_cell_index;
|
||||||
tbb::atomic<int> m_laziest_cell_occupation;
|
std::atomic<int> m_laziest_cell_occupation;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -504,7 +504,7 @@ public:
|
||||||
{
|
{
|
||||||
m_tls_work_buffers = new TLS_WorkBuffer[m_num_cells];
|
m_tls_work_buffers = new TLS_WorkBuffer[m_num_cells];
|
||||||
m_work_batches = new tbb::concurrent_queue<WorkBatch>[m_num_cells];
|
m_work_batches = new tbb::concurrent_queue<WorkBatch>[m_num_cells];
|
||||||
m_num_batches = new tbb::atomic<int>[m_num_cells];
|
m_num_batches = new std::atomic<int>[m_num_cells];
|
||||||
|
|
||||||
for (int i = 0 ; i < m_num_cells ; ++i)
|
for (int i = 0 ; i < m_num_cells ; ++i)
|
||||||
m_num_batches[i] = 0;
|
m_num_batches[i] = 0;
|
||||||
|
|
@ -673,7 +673,7 @@ protected:
|
||||||
Work_statistics m_stats;
|
Work_statistics m_stats;
|
||||||
TLS_WorkBuffer *m_tls_work_buffers;
|
TLS_WorkBuffer *m_tls_work_buffers;
|
||||||
tbb::concurrent_queue<WorkBatch> *m_work_batches;
|
tbb::concurrent_queue<WorkBatch> *m_work_batches;
|
||||||
tbb::atomic<int> *m_num_batches;
|
std::atomic<int> *m_num_batches;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -822,7 +822,7 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t NUM_WORK_ITEMS_PER_BATCH;
|
const size_t NUM_WORK_ITEMS_PER_BATCH;
|
||||||
tbb::atomic<int> m_cache_number_of_tasks;
|
std::atomic<int> m_cache_number_of_tasks;
|
||||||
TLS_WorkBuffer m_tls_work_buffers;
|
TLS_WorkBuffer m_tls_work_buffers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
#include <CGAL/Timer.h>
|
#include <CGAL/Timer.h>
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
#include <tbb/enumerable_thread_specific.h>
|
#include <tbb/enumerable_thread_specific.h>
|
||||||
#include <tbb/atomic.h>
|
#include <atomic>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -192,7 +192,7 @@ public:
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef CGAL_MESH_3_PERTURBER_VERBOSE
|
#ifdef CGAL_MESH_3_PERTURBER_VERBOSE
|
||||||
// Initialized here in case it's some tbb::atomic
|
// Initialized here in case it's some std::atomic
|
||||||
total_counter_ = 0;
|
total_counter_ = 0;
|
||||||
total_time_ = 0;
|
total_time_ = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -353,8 +353,8 @@ private:
|
||||||
mutable int counter_;
|
mutable int counter_;
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
mutable tbb::enumerable_thread_specific<CGAL::Timer> timer_;
|
mutable tbb::enumerable_thread_specific<CGAL::Timer> timer_;
|
||||||
tbb::atomic<int> total_counter_;
|
std::atomic<int> total_counter_;
|
||||||
tbb::atomic<std::size_t> total_time_;
|
std::atomic<std::size_t> total_time_;
|
||||||
#else
|
#else
|
||||||
mutable CGAL::Timer timer_;
|
mutable CGAL::Timer timer_;
|
||||||
int total_counter_;
|
int total_counter_;
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
#include <boost/type_traits/is_convertible.hpp>
|
#include <boost/type_traits/is_convertible.hpp>
|
||||||
|
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
# include <tbb/atomic.h>
|
# include <atomic>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
@ -87,7 +87,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef tbb::atomic<unsigned int> Erase_counter_type;
|
typedef std::atomic<unsigned int> Erase_counter_type;
|
||||||
Erase_counter_type m_erase_counter;
|
Erase_counter_type m_erase_counter;
|
||||||
};
|
};
|
||||||
#endif // CGAL_LINKED_WITH_TBB
|
#endif // CGAL_LINKED_WITH_TBB
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ if ( CGAL_FOUND )
|
||||||
test_backward_compatibility
|
test_backward_compatibility
|
||||||
test_meshing_polyhedron
|
test_meshing_polyhedron
|
||||||
test_meshing_polyhedral_complex
|
test_meshing_polyhedral_complex
|
||||||
|
test_mesh_3_issue_1554
|
||||||
)
|
)
|
||||||
if(TBB_FOUND AND TARGET ${target})
|
if(TBB_FOUND AND TARGET ${target})
|
||||||
CGAL_target_use_TBB(${target})
|
CGAL_target_use_TBB(${target})
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@
|
||||||
//******************************************************************************
|
//******************************************************************************
|
||||||
// File Description :
|
// File Description :
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
|
||||||
#include "test_meshing_utilities.h"
|
#include "test_meshing_utilities.h"
|
||||||
#include <CGAL/Image_3.h>
|
#include <CGAL/Image_3.h>
|
||||||
#include <CGAL/Labeled_mesh_domain_3.h>
|
#include <CGAL/Labeled_mesh_domain_3.h>
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
# include <tbb/task_scheduler_init.h>
|
#define TBB_PREVIEW_GLOBAL_CONTROL 1
|
||||||
|
# include <tbb/global_control.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// To avoid verbose function and named parameters call
|
// To avoid verbose function and named parameters call
|
||||||
|
|
@ -119,7 +119,7 @@ int main(int, char*[])
|
||||||
{
|
{
|
||||||
test<CGAL::Sequential_tag>();
|
test<CGAL::Sequential_tag>();
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
tbb::task_scheduler_init init(1);
|
tbb::global_control c(tbb::global_control::max_allowed_parallelism, 1);
|
||||||
test<CGAL::Parallel_tag>();
|
test<CGAL::Parallel_tag>();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,11 +38,12 @@
|
||||||
#include <CGAL/property_map.h>
|
#include <CGAL/property_map.h>
|
||||||
|
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
|
|
||||||
#include <CGAL/Point_set_processing_3/internal/Parallel_callback.h>
|
#include <CGAL/Point_set_processing_3/internal/Parallel_callback.h>
|
||||||
#include <tbb/parallel_for.h>
|
#include <tbb/parallel_for.h>
|
||||||
#include <tbb/blocked_range.h>
|
#include <tbb/blocked_range.h>
|
||||||
#include <tbb/scalable_allocator.h>
|
#include <tbb/scalable_allocator.h>
|
||||||
#include <tbb/atomic.h>
|
#include <atomic>
|
||||||
#endif // CGAL_LINKED_WITH_TBB
|
#endif // CGAL_LINKED_WITH_TBB
|
||||||
|
|
||||||
// Default allocator: use TBB allocators if available
|
// Default allocator: use TBB allocators if available
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
#include <tbb/parallel_for.h>
|
#include <tbb/parallel_for.h>
|
||||||
#include <tbb/blocked_range.h>
|
#include <tbb/blocked_range.h>
|
||||||
#include <tbb/atomic.h>
|
#include <atomic>
|
||||||
#endif // CGAL_LINKED_WITH_TBB
|
#endif // CGAL_LINKED_WITH_TBB
|
||||||
|
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
|
|
@ -78,13 +78,13 @@ struct Distance_computation{
|
||||||
const AABB_tree& tree;
|
const AABB_tree& tree;
|
||||||
const PointRange& sample_points;
|
const PointRange& sample_points;
|
||||||
Point_3 initial_hint;
|
Point_3 initial_hint;
|
||||||
tbb::atomic<double>* distance;
|
std::atomic<double>* distance;
|
||||||
|
|
||||||
Distance_computation(
|
Distance_computation(
|
||||||
const AABB_tree& tree,
|
const AABB_tree& tree,
|
||||||
const Point_3& p,
|
const Point_3& p,
|
||||||
const PointRange& sample_points,
|
const PointRange& sample_points,
|
||||||
tbb::atomic<double>* d)
|
std::atomic<double>* d)
|
||||||
: tree(tree)
|
: tree(tree)
|
||||||
, sample_points(sample_points)
|
, sample_points(sample_points)
|
||||||
, initial_hint(p)
|
, initial_hint(p)
|
||||||
|
|
@ -108,7 +108,8 @@ struct Distance_computation{
|
||||||
double current_value = *distance;
|
double current_value = *distance;
|
||||||
while( current_value < hdist )
|
while( current_value < hdist )
|
||||||
{
|
{
|
||||||
current_value = distance->compare_and_swap(hdist, current_value);
|
if(distance->compare_exchange_weak(current_value, hdist))
|
||||||
|
current_value = hdist;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -129,7 +130,7 @@ double approximate_Hausdorff_distance_impl(
|
||||||
#else
|
#else
|
||||||
if (boost::is_convertible<Concurrency_tag,Parallel_tag>::value)
|
if (boost::is_convertible<Concurrency_tag,Parallel_tag>::value)
|
||||||
{
|
{
|
||||||
tbb::atomic<double> distance;
|
std::atomic<double> distance;
|
||||||
distance=0;
|
distance=0;
|
||||||
Distance_computation<AABBTree, PointRange> f(tree, hint, sample_points, &distance);
|
Distance_computation<AABBTree, PointRange> f(tree, hint, sample_points, &distance);
|
||||||
tbb::parallel_for(tbb::blocked_range<std::size_t>(0, sample_points.size()), f);
|
tbb::parallel_for(tbb::blocked_range<std::size_t>(0, sample_points.size()), f);
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
//#undef CGAL_LINKED_WITH_TBB
|
//#undef CGAL_LINKED_WITH_TBB
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
#include <tbb/parallel_for.h>
|
#include <tbb/parallel_for.h>
|
||||||
#include <tbb/mutex.h>
|
#include <mutex>
|
||||||
#include <tbb/blocked_range.h>
|
#include <tbb/blocked_range.h>
|
||||||
#include <tbb/scalable_allocator.h>
|
#include <tbb/scalable_allocator.h>
|
||||||
#endif // CGAL_LINKED_WITH_TBB
|
#endif // CGAL_LINKED_WITH_TBB
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
#include <tbb/parallel_for.h>
|
#include <tbb/parallel_for.h>
|
||||||
#include <tbb/blocked_range.h>
|
#include <tbb/blocked_range.h>
|
||||||
#include <tbb/atomic.h>
|
#include <atomic>
|
||||||
#endif // CGAL_LINKED_WITH_TBB
|
#endif // CGAL_LINKED_WITH_TBB
|
||||||
|
|
||||||
#if defined(CGAL_LINKED_WITH_TBB)
|
#if defined(CGAL_LINKED_WITH_TBB)
|
||||||
|
|
@ -31,13 +31,13 @@ struct Distance_computation{
|
||||||
const AABB_tree& tree;
|
const AABB_tree& tree;
|
||||||
const Point_set & point_set;
|
const Point_set & point_set;
|
||||||
Point_3 initial_hint;
|
Point_3 initial_hint;
|
||||||
tbb::atomic<double>* distance;
|
std::atomic<double>* distance;
|
||||||
std::vector<double>& output;
|
std::vector<double>& output;
|
||||||
|
|
||||||
Distance_computation(const AABB_tree& tree,
|
Distance_computation(const AABB_tree& tree,
|
||||||
const Point_3 p,
|
const Point_3 p,
|
||||||
const Point_set & point_set,
|
const Point_set & point_set,
|
||||||
tbb::atomic<double>* d,
|
std::atomic<double>* d,
|
||||||
std::vector<double>& out )
|
std::vector<double>& out )
|
||||||
: tree(tree)
|
: tree(tree)
|
||||||
, point_set(point_set)
|
, point_set(point_set)
|
||||||
|
|
@ -96,7 +96,7 @@ double compute_distances(const Mesh& m,
|
||||||
}
|
}
|
||||||
return hdist;
|
return hdist;
|
||||||
#else
|
#else
|
||||||
tbb::atomic<double> distance;
|
std::atomic<double> distance;
|
||||||
distance.store(0);
|
distance.store(0);
|
||||||
Distance_computation<Tree, typename Traits::Point_3> f(tree, hint, point_set, &distance, out);
|
Distance_computation<Tree, typename Traits::Point_3> f(tree, hint, point_set, &distance, out);
|
||||||
tbb::parallel_for(tbb::blocked_range<Point_set::const_iterator>(point_set.begin(), point_set.end()), f);
|
tbb::parallel_for(tbb::blocked_range<Point_set::const_iterator>(point_set.begin(), point_set.end()), f);
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
#include <tbb/atomic.h>
|
#include <atomic>
|
||||||
#if TBB_IMPLEMENT_CPP0X
|
#if TBB_IMPLEMENT_CPP0X
|
||||||
# include <tbb/compat/thread>
|
# include <tbb/compat/thread>
|
||||||
#else
|
#else
|
||||||
|
|
@ -452,12 +452,12 @@ class Spatial_lock_grid_3<Tag_non_blocking>
|
||||||
public:
|
public:
|
||||||
// Constructors
|
// Constructors
|
||||||
Spatial_lock_grid_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)
|
: Base(bbox, num_grid_cells_per_axis),
|
||||||
|
m_grid(num_grid_cells_per_axis*num_grid_cells_per_axis*num_grid_cells_per_axis)
|
||||||
{
|
{
|
||||||
int num_cells =
|
int num_cells =
|
||||||
num_grid_cells_per_axis*num_grid_cells_per_axis*num_grid_cells_per_axis;
|
num_grid_cells_per_axis*num_grid_cells_per_axis*num_grid_cells_per_axis;
|
||||||
|
|
||||||
m_grid.resize(num_cells);
|
|
||||||
// Initialize grid (useless?)
|
// Initialize grid (useless?)
|
||||||
for (int i = 0 ; i < num_cells ; ++i)
|
for (int i = 0 ; i < num_cells ; ++i)
|
||||||
m_grid[i] = false;
|
m_grid[i] = false;
|
||||||
|
|
@ -475,8 +475,8 @@ public:
|
||||||
template <bool no_spin>
|
template <bool no_spin>
|
||||||
bool try_lock_cell_impl(int cell_index)
|
bool try_lock_cell_impl(int cell_index)
|
||||||
{
|
{
|
||||||
bool old_value = m_grid[cell_index].compare_and_swap(true, false);
|
bool v1 = true, v2 = false;
|
||||||
if (old_value == false)
|
if(m_grid[cell_index].compare_exchange_strong(v2,v1))
|
||||||
{
|
{
|
||||||
get_thread_local_grid()[cell_index] = true;
|
get_thread_local_grid()[cell_index] = true;
|
||||||
m_tls_locked_cells.local().push_back(cell_index);
|
m_tls_locked_cells.local().push_back(cell_index);
|
||||||
|
|
@ -492,7 +492,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
std::vector<tbb::atomic<bool> > m_grid;
|
std::vector<std::atomic<bool> > m_grid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -512,14 +512,12 @@ public:
|
||||||
|
|
||||||
Spatial_lock_grid_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),
|
: Base(bbox, num_grid_cells_per_axis),
|
||||||
|
m_grid(num_grid_cells_per_axis*num_grid_cells_per_axis*num_grid_cells_per_axis),
|
||||||
m_tls_thread_priorities(init_TLS_thread_priorities)
|
m_tls_thread_priorities(init_TLS_thread_priorities)
|
||||||
{
|
{
|
||||||
int num_cells =
|
|
||||||
num_grid_cells_per_axis*num_grid_cells_per_axis*num_grid_cells_per_axis;
|
|
||||||
m_grid.resize(num_cells);
|
|
||||||
// Explicitly initialize the atomics
|
// Explicitly initialize the atomics
|
||||||
std::vector<tbb::atomic<unsigned int> >::iterator it = m_grid.begin();
|
std::vector<std::atomic<unsigned int> >::iterator it = m_grid.begin();
|
||||||
std::vector<tbb::atomic<unsigned int> >::iterator it_end = m_grid.end();
|
std::vector<std::atomic<unsigned int> >::iterator it_end = m_grid.end();
|
||||||
for ( ; it != it_end ; ++it)
|
for ( ; it != it_end ; ++it)
|
||||||
*it = 0;
|
*it = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -542,9 +540,8 @@ public:
|
||||||
// NO SPIN
|
// NO SPIN
|
||||||
if (no_spin)
|
if (no_spin)
|
||||||
{
|
{
|
||||||
unsigned int old_value =
|
unsigned int old_value = 0;
|
||||||
m_grid[cell_index].compare_and_swap(this_thread_priority, 0);
|
if(m_grid[cell_index].compare_exchange_strong(old_value, this_thread_priority))
|
||||||
if (old_value == 0)
|
|
||||||
{
|
{
|
||||||
get_thread_local_grid()[cell_index] = true;
|
get_thread_local_grid()[cell_index] = true;
|
||||||
m_tls_locked_cells.local().push_back(cell_index);
|
m_tls_locked_cells.local().push_back(cell_index);
|
||||||
|
|
@ -556,9 +553,8 @@ public:
|
||||||
{
|
{
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
unsigned int old_value =
|
unsigned int old_value =0;
|
||||||
m_grid[cell_index].compare_and_swap(this_thread_priority, 0);
|
if(m_grid[cell_index].compare_exchange_weak(old_value, this_thread_priority))
|
||||||
if (old_value == 0)
|
|
||||||
{
|
{
|
||||||
get_thread_local_grid()[cell_index] = true;
|
get_thread_local_grid()[cell_index] = true;
|
||||||
m_tls_locked_cells.local().push_back(cell_index);
|
m_tls_locked_cells.local().push_back(cell_index);
|
||||||
|
|
@ -587,7 +583,7 @@ public:
|
||||||
private:
|
private:
|
||||||
static unsigned int init_TLS_thread_priorities()
|
static unsigned int init_TLS_thread_priorities()
|
||||||
{
|
{
|
||||||
static tbb::atomic<unsigned int> last_id;
|
static std::atomic<unsigned int> last_id;
|
||||||
unsigned int id = ++last_id;
|
unsigned int id = ++last_id;
|
||||||
// Ensure it is > 0
|
// Ensure it is > 0
|
||||||
return (1 + id%((std::numeric_limits<unsigned int>::max)()));
|
return (1 + id%((std::numeric_limits<unsigned int>::max)()));
|
||||||
|
|
@ -595,7 +591,7 @@ private:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
std::vector<tbb::atomic<unsigned int> > m_grid;
|
std::vector<std::atomic<unsigned int> > m_grid;
|
||||||
|
|
||||||
typedef tbb::enumerable_thread_specific<unsigned int> TLS_thread_uint_ids;
|
typedef tbb::enumerable_thread_specific<unsigned int> TLS_thread_uint_ids;
|
||||||
TLS_thread_uint_ids m_tls_thread_priorities;
|
TLS_thread_uint_ids m_tls_thread_priorities;
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
# include <tbb/tbb_config.h>
|
# include <tbb/tbb_config.h>
|
||||||
# if TBB_IMPLEMENT_CPP0X
|
# if TBB_IMPLEMENT_CPP0X
|
||||||
# include <tbb/compat/thread>
|
# include <tbb/compat/thread>
|
||||||
# include <tbb/atomic.h>
|
# include <atomic>
|
||||||
# include <tbb/tick_count.h>
|
# include <tbb/tick_count.h>
|
||||||
# define CGAL_USE_TBB_THREADS 1
|
# define CGAL_USE_TBB_THREADS 1
|
||||||
# else
|
# else
|
||||||
|
|
@ -83,8 +83,8 @@ namespace cpp11 {
|
||||||
|
|
||||||
#if defined(CGAL_NO_ATOMIC) && defined(CGAL_LINKED_WITH_TBB)
|
#if defined(CGAL_NO_ATOMIC) && defined(CGAL_LINKED_WITH_TBB)
|
||||||
// If <CGAL/atomic.h> did not defined CGAL::cpp11::atomic, then use
|
// If <CGAL/atomic.h> did not defined CGAL::cpp11::atomic, then use
|
||||||
// tbb::atomic as a fallback.
|
// std::atomic as a fallback.
|
||||||
using tbb::atomic;
|
using std::atomic;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // cpp11
|
} // cpp11
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ int main()
|
||||||
|
|
||||||
# include <tbb/task_scheduler_init.h>
|
# include <tbb/task_scheduler_init.h>
|
||||||
# include <tbb/parallel_for.h>
|
# include <tbb/parallel_for.h>
|
||||||
# include <tbb/atomic.h>
|
# include <atomic>
|
||||||
|
|
||||||
#include <CGAL/disable_warnings.h>
|
#include <CGAL/disable_warnings.h>
|
||||||
|
|
||||||
|
|
@ -139,12 +139,12 @@ template <typename Values_vec, typename Cont>
|
||||||
class Insert_and_erase_in_CCC_functor
|
class Insert_and_erase_in_CCC_functor
|
||||||
{
|
{
|
||||||
typedef std::vector<typename Cont::iterator> Iterators_vec;
|
typedef std::vector<typename Cont::iterator> Iterators_vec;
|
||||||
typedef std::vector<tbb::atomic<bool> > Free_elts_vec;
|
typedef std::vector<std::atomic<bool> > Free_elts_vec;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Insert_and_erase_in_CCC_functor(
|
Insert_and_erase_in_CCC_functor(
|
||||||
const Values_vec &values, Cont &cont, Iterators_vec &iterators,
|
const Values_vec &values, Cont &cont, Iterators_vec &iterators,
|
||||||
Free_elts_vec &free_elements, tbb::atomic<unsigned int> &num_erasures)
|
Free_elts_vec &free_elements, std::atomic<unsigned int> &num_erasures)
|
||||||
: m_values(values), m_cont(cont), m_iterators(iterators),
|
: m_values(values), m_cont(cont), m_iterators(iterators),
|
||||||
m_free_elements(free_elements), m_num_erasures(num_erasures)
|
m_free_elements(free_elements), m_num_erasures(num_erasures)
|
||||||
{}
|
{}
|
||||||
|
|
@ -163,7 +163,8 @@ public:
|
||||||
// Random-pick an element to erase
|
// Random-pick an element to erase
|
||||||
int index_to_erase = rand() % m_values.size();
|
int index_to_erase = rand() % m_values.size();
|
||||||
// If it exists
|
// If it exists
|
||||||
if (m_free_elements[index_to_erase].compare_and_swap(true, false) == false)
|
bool comparand = false;
|
||||||
|
if (m_free_elements[index_to_erase].compare_exchange_weak(comparand, true) )
|
||||||
{
|
{
|
||||||
m_cont.erase(m_iterators[index_to_erase]);
|
m_cont.erase(m_iterators[index_to_erase]);
|
||||||
++m_num_erasures;
|
++m_num_erasures;
|
||||||
|
|
@ -176,7 +177,7 @@ private:
|
||||||
Cont & m_cont;
|
Cont & m_cont;
|
||||||
Iterators_vec & m_iterators;
|
Iterators_vec & m_iterators;
|
||||||
Free_elts_vec & m_free_elements;
|
Free_elts_vec & m_free_elements;
|
||||||
tbb::atomic<unsigned int> & m_num_erasures;
|
std::atomic<unsigned int> & m_num_erasures;
|
||||||
};
|
};
|
||||||
|
|
||||||
template < class Cont >
|
template < class Cont >
|
||||||
|
|
@ -372,14 +373,14 @@ void test(const Cont &)
|
||||||
{
|
{
|
||||||
Cont c12;
|
Cont c12;
|
||||||
Vect v12(1000000);
|
Vect v12(1000000);
|
||||||
std::vector<tbb::atomic<bool> > free_elements(v12.size());
|
std::vector<std::atomic<bool> > free_elements(v12.size());
|
||||||
for(typename std::vector<tbb::atomic<bool> >::iterator
|
for(typename std::vector<std::atomic<bool> >::iterator
|
||||||
it = free_elements.begin(), end = free_elements.end(); it != end; ++it)
|
it = free_elements.begin(), end = free_elements.end(); it != end; ++it)
|
||||||
{
|
{
|
||||||
*it = true;
|
*it = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
tbb::atomic<unsigned int> num_erasures;
|
std::atomic<unsigned int> num_erasures;
|
||||||
num_erasures = 0;
|
num_erasures = 0;
|
||||||
std::vector<typename Cont::iterator> iterators(v12.size());
|
std::vector<typename Cont::iterator> iterators(v12.size());
|
||||||
tbb::parallel_for(
|
tbb::parallel_for(
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ int main()
|
||||||
ParallelTriangulation T(V.begin(), V.end(), &locking_ds);
|
ParallelTriangulation T(V.begin(), V.end(), &locking_ds);
|
||||||
t.stop();
|
t.stop();
|
||||||
std::cerr << "Parallel construction takes " << t.time() << " sec. with "
|
std::cerr << "Parallel construction takes " << t.time() << " sec. with "
|
||||||
<< tbb::task_scheduler_init::default_num_threads() << " threads" << std::endl;
|
<< std::thread::hardware_concurrency() << " threads" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
# include <CGAL/point_generators_3.h>
|
# include <CGAL/point_generators_3.h>
|
||||||
# include <tbb/parallel_for.h>
|
# include <tbb/parallel_for.h>
|
||||||
# include <tbb/task_scheduler_init.h>
|
# include <thread>
|
||||||
# include <tbb/enumerable_thread_specific.h>
|
# include <tbb/enumerable_thread_specific.h>
|
||||||
# include <tbb/concurrent_vector.h>
|
# include <tbb/concurrent_vector.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -289,7 +289,7 @@ private:
|
||||||
bbox.zmin() + 0.5*zdelta);
|
bbox.zmin() + 0.5*zdelta);
|
||||||
Random_points_on_sphere_3<Point> random_point(radius);
|
Random_points_on_sphere_3<Point> random_point(radius);
|
||||||
const int NUM_PSEUDO_INFINITE_VERTICES = static_cast<int>(
|
const int NUM_PSEUDO_INFINITE_VERTICES = static_cast<int>(
|
||||||
tbb::task_scheduler_init::default_num_threads() * 3.5);
|
std::thread::hardware_concurrency() * 3.5);
|
||||||
std::vector<Point> points_on_far_sphere;
|
std::vector<Point> points_on_far_sphere;
|
||||||
|
|
||||||
points_on_far_sphere.reserve(NUM_PSEUDO_INFINITE_VERTICES);
|
points_on_far_sphere.reserve(NUM_PSEUDO_INFINITE_VERTICES);
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
#ifdef CGAL_LINKED_WITH_TBB
|
#ifdef CGAL_LINKED_WITH_TBB
|
||||||
# include <CGAL/point_generators_3.h>
|
# include <CGAL/point_generators_3.h>
|
||||||
# include <tbb/parallel_for.h>
|
# include <tbb/parallel_for.h>
|
||||||
# include <tbb/task_scheduler_init.h>
|
# include <thread>
|
||||||
# include <tbb/enumerable_thread_specific.h>
|
# include <tbb/enumerable_thread_specific.h>
|
||||||
# include <tbb/concurrent_vector.h>
|
# include <tbb/concurrent_vector.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -258,7 +258,7 @@ private:
|
||||||
bbox.zmin() + 0.5*zdelta);
|
bbox.zmin() + 0.5*zdelta);
|
||||||
Random_points_on_sphere_3<Bare_point> random_point(radius);
|
Random_points_on_sphere_3<Bare_point> random_point(radius);
|
||||||
const int NUM_PSEUDO_INFINITE_VERTICES = static_cast<int>(
|
const int NUM_PSEUDO_INFINITE_VERTICES = static_cast<int>(
|
||||||
tbb::task_scheduler_init::default_num_threads() * 3.5);
|
std::thread::hardware_concurrency() * 3.5);
|
||||||
typename Gt::Construct_weighted_point_3 cwp =
|
typename Gt::Construct_weighted_point_3 cwp =
|
||||||
geom_traits().construct_weighted_point_3_object();
|
geom_traits().construct_weighted_point_3_object();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue