mirror of https://github.com/CGAL/cgal
WIP replacing tbb deprecated includes.
This commit is contained in:
parent
7553c3dda2
commit
85712ba28c
|
|
@ -19,7 +19,7 @@
|
|||
#include <boost/make_shared.hpp>
|
||||
|
||||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
#include <tbb/mutex.h>
|
||||
#include <mutex>
|
||||
#include <tbb/task_group.h>
|
||||
#endif // CGAL_LINKED_WITH_TBB
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@
|
|||
#include <tbb/parallel_for.h>
|
||||
#include <tbb/blocked_range.h>
|
||||
#include <tbb/scalable_allocator.h>
|
||||
#include <tbb/mutex.h>
|
||||
#include <mutex>
|
||||
|
||||
#endif // CGAL_LINKED_WITH_TBB
|
||||
|
||||
namespace CGAL {
|
||||
|
|
@ -69,7 +70,7 @@ private:
|
|||
PointMap m_point_map;
|
||||
const NeighborQuery& m_neighbor_query;
|
||||
float& m_mean_range;
|
||||
tbb::mutex& m_mutex;
|
||||
std::mutex& m_mutex;
|
||||
|
||||
public:
|
||||
|
||||
|
|
@ -78,7 +79,7 @@ private:
|
|||
PointMap point_map,
|
||||
const NeighborQuery& neighbor_query,
|
||||
float& mean_range,
|
||||
tbb::mutex& mutex)
|
||||
std::mutex& mutex)
|
||||
: m_eigen (eigen), m_input (input), m_point_map (point_map),
|
||||
m_neighbor_query (neighbor_query), m_mean_range (mean_range), m_mutex (mutex)
|
||||
{ }
|
||||
|
|
@ -120,7 +121,7 @@ private:
|
|||
const FaceListGraph& m_input;
|
||||
const NeighborQuery& m_neighbor_query;
|
||||
float& m_mean_range;
|
||||
tbb::mutex& m_mutex;
|
||||
std::mutex& m_mutex;
|
||||
|
||||
public:
|
||||
|
||||
|
|
@ -128,7 +129,7 @@ private:
|
|||
const FaceListGraph& input,
|
||||
const NeighborQuery& neighbor_query,
|
||||
float& mean_range,
|
||||
tbb::mutex& mutex)
|
||||
std::mutex& mutex)
|
||||
: m_eigen (eigen), m_input (input),
|
||||
m_neighbor_query (neighbor_query), m_mean_range (mean_range), m_mutex (mutex)
|
||||
{ }
|
||||
|
|
@ -271,7 +272,7 @@ public:
|
|||
#else
|
||||
if (boost::is_convertible<ConcurrencyTag,Parallel_tag>::value)
|
||||
{
|
||||
tbb::mutex mutex;
|
||||
std::mutex mutex;
|
||||
Compute_eigen_values<PointRange, PointMap, NeighborQuery, DiagonalizeTraits>
|
||||
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);
|
||||
|
|
@ -361,7 +362,7 @@ public:
|
|||
#else
|
||||
if (boost::is_convertible<ConcurrencyTag,Parallel_tag>::value)
|
||||
{
|
||||
tbb::mutex mutex;
|
||||
std::mutex mutex;
|
||||
Compute_eigen_values_graph<FaceListGraph, NeighborQuery, DiagonalizeTraits>
|
||||
f(out, input, neighbor_query, out.m_content->mean_range, mutex);
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
#include <tbb/task_group.h>
|
||||
#include <tbb/mutex.h>
|
||||
#include <mutex>
|
||||
#endif // CGAL_LINKED_WITH_TBB
|
||||
|
||||
namespace CGAL {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
#include <tbb/parallel_for.h>
|
||||
#include <tbb/blocked_range.h>
|
||||
#include <tbb/scalable_allocator.h>
|
||||
#include <tbb/mutex.h>
|
||||
#include <mutex>
|
||||
#endif // CGAL_LINKED_WITH_TBB
|
||||
|
||||
#define CLASSIFICATION_TRAINING_QUICK_ESTIMATION
|
||||
|
|
@ -72,9 +72,9 @@ private:
|
|||
std::vector<std::size_t>& m_true_positives;
|
||||
std::vector<std::size_t>& m_false_positives;
|
||||
std::vector<std::size_t>& m_false_negatives;
|
||||
std::vector<tbb::mutex>& m_tp_mutex;
|
||||
std::vector<tbb::mutex>& m_fp_mutex;
|
||||
std::vector<tbb::mutex>& m_fn_mutex;
|
||||
std::vector<std::mutex>& m_tp_mutex;
|
||||
std::vector<std::mutex>& m_fp_mutex;
|
||||
std::vector<std::mutex>& m_fn_mutex;
|
||||
|
||||
|
||||
public:
|
||||
|
|
@ -85,9 +85,9 @@ private:
|
|||
std::vector<std::size_t>& true_positives,
|
||||
std::vector<std::size_t>& false_positives,
|
||||
std::vector<std::size_t>& false_negatives,
|
||||
std::vector<tbb::mutex>& tp_mutex,
|
||||
std::vector<tbb::mutex>& fp_mutex,
|
||||
std::vector<tbb::mutex>& fn_mutex)
|
||||
std::vector<std::mutex>& tp_mutex,
|
||||
std::vector<std::mutex>& fp_mutex,
|
||||
std::vector<std::mutex>& fn_mutex)
|
||||
: m_training_set (training_set)
|
||||
, m_classifier (classifier)
|
||||
, m_label (label)
|
||||
|
|
@ -901,9 +901,9 @@ private:
|
|||
#else
|
||||
if (boost::is_convertible<ConcurrencyTag,Parallel_tag>::value)
|
||||
{
|
||||
std::vector<tbb::mutex> tp_mutex (m_labels.size());
|
||||
std::vector<tbb::mutex> fp_mutex (m_labels.size());
|
||||
std::vector<tbb::mutex> fn_mutex (m_labels.size());
|
||||
std::vector<std::mutex> tp_mutex (m_labels.size());
|
||||
std::vector<std::mutex> fp_mutex (m_labels.size());
|
||||
std::vector<std::mutex> fn_mutex (m_labels.size());
|
||||
Compute_iou f(training_sets[j], *this, j,
|
||||
true_positives, false_positives, false_negatives,
|
||||
tp_mutex, fp_mutex, fn_mutex);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#include <tbb/parallel_for.h>
|
||||
#include <tbb/blocked_range.h>
|
||||
#include <tbb/scalable_allocator.h>
|
||||
#include <tbb/mutex.h>
|
||||
#include <mutex>
|
||||
#endif // CGAL_LINKED_WITH_TBB
|
||||
|
||||
namespace CGAL {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
|
||||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
# include <tbb/atomic.h>
|
||||
# include <atomic>
|
||||
#endif
|
||||
|
||||
namespace CGAL {
|
||||
|
|
@ -152,7 +152,8 @@ public:
|
|||
{
|
||||
CGAL_precondition(facet>=0 && facet<4);
|
||||
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_;
|
||||
}
|
||||
|
|
@ -165,7 +166,7 @@ public:
|
|||
char current_bits = bits_;
|
||||
char mask = char(15 & ~(1 << facet));
|
||||
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_;
|
||||
}
|
||||
|
|
@ -182,18 +183,19 @@ public:
|
|||
/// this function "deletes" cc
|
||||
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;
|
||||
}
|
||||
|
||||
private:
|
||||
typedef tbb::atomic<unsigned int> Erase_counter_type;
|
||||
typedef std::atomic<unsigned int> Erase_counter_type;
|
||||
Erase_counter_type m_erase_counter;
|
||||
/// Stores visited facets (4 first bits)
|
||||
tbb::atomic<char> bits_;
|
||||
std::atomic<char> bits_;
|
||||
|
||||
protected:
|
||||
mutable tbb::atomic<Point_3*> weighted_circumcenter_;
|
||||
mutable std::atomic<Point_3*> weighted_circumcenter_;
|
||||
};
|
||||
|
||||
#endif // CGAL_LINKED_WITH_TBB
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
|
||||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
# include <tbb/parallel_do.h>
|
||||
# include <tbb/mutex.h>
|
||||
# include <mutex>
|
||||
#endif
|
||||
|
||||
#include <functional>
|
||||
|
|
@ -595,7 +595,7 @@ public:
|
|||
protected:
|
||||
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_moving_vertices;
|
||||
mutable Mutex_type m_mut_vertex_to_proj;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
|
||||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
#include <tbb/atomic.h>
|
||||
#include <atomic>
|
||||
#include <tbb/concurrent_hash_map.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
|
@ -174,7 +174,7 @@ public:
|
|||
, manifold_info_initialized_(false) //TODO: parallel!
|
||||
{
|
||||
// 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_cells_ = 0;
|
||||
}
|
||||
|
|
@ -186,8 +186,9 @@ public:
|
|||
, edge_facet_counter_(rhs.edge_facet_counter_)
|
||||
, manifold_info_initialized_(rhs.manifold_info_initialized_)
|
||||
{
|
||||
number_of_facets_ = rhs.number_of_facets_;
|
||||
number_of_cells_ = rhs.number_of_cells_;
|
||||
Init_number_of_elements<Concurrency_tag> init;
|
||||
init(number_of_facets_, rhs.number_of_facets_);
|
||||
init(number_of_cells_, rhs.number_of_cells_);
|
||||
}
|
||||
|
||||
/// Destructor
|
||||
|
|
@ -505,9 +506,10 @@ public:
|
|||
/// Swaps this & 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_);
|
||||
std::swap(rhs.number_of_cells_, number_of_cells_);
|
||||
swapper(rhs.number_of_cells_, number_of_cells_);
|
||||
}
|
||||
|
||||
/// Returns bbox
|
||||
|
|
@ -850,12 +852,55 @@ private:
|
|||
{
|
||||
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
|
||||
// Parallel: atomic
|
||||
template<typename 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
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@
|
|||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
# include <tbb/atomic.h>
|
||||
# include <atomic>
|
||||
# include <mutex>
|
||||
# include <tbb/parallel_do.h>
|
||||
# include <tbb/concurrent_vector.h>
|
||||
#endif
|
||||
|
|
@ -122,7 +123,7 @@ protected:
|
|||
typedef typename Tr::Lock_data_structure Lock_data_structure;
|
||||
typedef tbb::concurrent_vector<std::tuple<typename Tr::Vertex_handle, Vector_3, FT> >
|
||||
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)
|
||||
: big_moves_size_(0)
|
||||
|
|
@ -136,7 +137,7 @@ protected:
|
|||
{
|
||||
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);
|
||||
|
||||
// New smallest move of all big moves?
|
||||
|
|
@ -149,7 +150,7 @@ protected:
|
|||
|
||||
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
|
||||
// thread in the meantime
|
||||
if( new_sq_move > big_moves_smallest_ )
|
||||
|
|
@ -185,11 +186,11 @@ protected:
|
|||
public:
|
||||
|
||||
protected:
|
||||
tbb::atomic<std::size_t> big_moves_current_size_;
|
||||
tbb::atomic<FT> big_moves_smallest_;
|
||||
std::atomic<std::size_t> big_moves_current_size_;
|
||||
std::atomic<FT> big_moves_smallest_;
|
||||
std::size_t big_moves_size_;
|
||||
std::multiset<FT> big_moves_;
|
||||
tbb::mutex m_big_moves_mutex;
|
||||
std::mutex m_big_moves_mutex;
|
||||
|
||||
/// Lock data structure
|
||||
Lock_data_structure m_lock_ds;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#include <CGAL/Mesh_3/io_signature.h>
|
||||
|
||||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
# include <tbb/atomic.h>
|
||||
# include <atomic>
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
|
@ -123,7 +123,7 @@ public:
|
|||
|
||||
protected:
|
||||
/// Stores visited facets (4 first bits)
|
||||
tbb::atomic<char> bits_;
|
||||
std::atomic<char> bits_;
|
||||
};
|
||||
#endif // CGAL_LINKED_WITH_TBB
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@
|
|||
#endif
|
||||
|
||||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
# include <tbb/task_scheduler_init.h>
|
||||
# include <thread>
|
||||
#endif
|
||||
|
||||
#include <boost/format.hpp>
|
||||
|
|
@ -659,7 +659,7 @@ initialize()
|
|||
# endif
|
||||
Random_points_on_sphere_3<Bare_point> random_point(radius);
|
||||
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);
|
||||
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()
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
#include <tbb/concurrent_vector.h>
|
||||
#include <tbb/scalable_allocator.h>
|
||||
|
||||
#include <tbb/atomic.h>
|
||||
#include <atomic>
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
|
@ -65,8 +65,8 @@ public:
|
|||
|
||||
m_num_cells =
|
||||
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_num_batches_grid = new tbb::atomic<int>[m_num_cells];
|
||||
m_occupation_grid = new std::atomic<int>[m_num_cells];
|
||||
m_num_batches_grid = new std::atomic<int>[m_num_cells];
|
||||
// Initialize grid
|
||||
for (int i = 0 ; i < m_num_cells ; ++i)
|
||||
{
|
||||
|
|
@ -106,15 +106,15 @@ public:
|
|||
|
||||
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)
|
||||
{
|
||||
m_occupation_grid[cell_index].fetch_and_add(to_add);
|
||||
m_occupation_grid[cell_index].fetch_add(to_add);
|
||||
|
||||
/*int new_occupation =
|
||||
(m_occupation_grid[cell_index].fetch_and_add(to_add))
|
||||
(m_occupation_grid[cell_index].fetch_add(to_add))
|
||||
+ to_add;
|
||||
//m_num_batches_grid[cell_index] = num_items_in_work_queue;
|
||||
|
||||
|
|
@ -221,7 +221,7 @@ public:
|
|||
|
||||
|
||||
// Rotate
|
||||
static tbb::atomic<int> last_cell_index;
|
||||
static std::atomic<int> last_cell_index;
|
||||
//std::cerr << "last=" << last_cell_index << std::endl;
|
||||
int i = (last_cell_index + 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_cells;
|
||||
tbb::atomic<int> * m_occupation_grid;
|
||||
tbb::atomic<int> * m_num_batches_grid;
|
||||
std::atomic<int> * m_occupation_grid;
|
||||
std::atomic<int> * m_num_batches_grid;
|
||||
|
||||
tbb::atomic<int> m_laziest_cell_index;
|
||||
tbb::atomic<int> m_laziest_cell_occupation;
|
||||
std::atomic<int> m_laziest_cell_index;
|
||||
std::atomic<int> m_laziest_cell_occupation;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -504,7 +504,7 @@ public:
|
|||
{
|
||||
m_tls_work_buffers = new TLS_WorkBuffer[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)
|
||||
m_num_batches[i] = 0;
|
||||
|
|
@ -673,7 +673,7 @@ protected:
|
|||
Work_statistics m_stats;
|
||||
TLS_WorkBuffer *m_tls_work_buffers;
|
||||
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;
|
||||
tbb::atomic<int> m_cache_number_of_tasks;
|
||||
std::atomic<int> m_cache_number_of_tasks;
|
||||
TLS_WorkBuffer m_tls_work_buffers;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
#include <CGAL/Timer.h>
|
||||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
#include <tbb/enumerable_thread_specific.h>
|
||||
#include <tbb/atomic.h>
|
||||
#include <atomic>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
@ -192,7 +192,7 @@ public:
|
|||
#endif
|
||||
{
|
||||
#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_time_ = 0;
|
||||
#endif
|
||||
|
|
@ -353,8 +353,8 @@ private:
|
|||
mutable int counter_;
|
||||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
mutable tbb::enumerable_thread_specific<CGAL::Timer> timer_;
|
||||
tbb::atomic<int> total_counter_;
|
||||
tbb::atomic<std::size_t> total_time_;
|
||||
std::atomic<int> total_counter_;
|
||||
std::atomic<std::size_t> total_time_;
|
||||
#else
|
||||
mutable CGAL::Timer timer_;
|
||||
int total_counter_;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
# include <tbb/atomic.h>
|
||||
# include <atomic>
|
||||
#endif
|
||||
|
||||
namespace CGAL {
|
||||
|
|
@ -87,7 +87,7 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
typedef tbb::atomic<unsigned int> Erase_counter_type;
|
||||
typedef std::atomic<unsigned int> Erase_counter_type;
|
||||
Erase_counter_type m_erase_counter;
|
||||
};
|
||||
#endif // CGAL_LINKED_WITH_TBB
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ if ( CGAL_FOUND )
|
|||
test_backward_compatibility
|
||||
test_meshing_polyhedron
|
||||
test_meshing_polyhedral_complex
|
||||
|
||||
)
|
||||
if(TBB_FOUND AND TARGET ${target})
|
||||
CGAL_target_use_TBB(${target})
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
//******************************************************************************
|
||||
// File Description :
|
||||
//***************************************************************************
|
||||
|
||||
#include "test_meshing_utilities.h"
|
||||
#include <CGAL/Image_3.h>
|
||||
#include <CGAL/Labeled_mesh_domain_3.h>
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@
|
|||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
# include <tbb/task_scheduler_init.h>
|
||||
#define TBB_PREVIEW_GLOBAL_CONTROL 1
|
||||
# include <tbb/global_control.h>
|
||||
#endif
|
||||
|
||||
// To avoid verbose function and named parameters call
|
||||
|
|
@ -119,7 +119,7 @@ int main(int, char*[])
|
|||
{
|
||||
test<CGAL::Sequential_tag>();
|
||||
#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>();
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,11 +38,12 @@
|
|||
#include <CGAL/property_map.h>
|
||||
|
||||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
|
||||
#include <CGAL/Point_set_processing_3/internal/Parallel_callback.h>
|
||||
#include <tbb/parallel_for.h>
|
||||
#include <tbb/blocked_range.h>
|
||||
#include <tbb/scalable_allocator.h>
|
||||
#include <tbb/atomic.h>
|
||||
#include <atomic>
|
||||
#endif // CGAL_LINKED_WITH_TBB
|
||||
|
||||
// Default allocator: use TBB allocators if available
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
#include <tbb/parallel_for.h>
|
||||
#include <tbb/blocked_range.h>
|
||||
#include <tbb/atomic.h>
|
||||
#include <atomic>
|
||||
#endif // CGAL_LINKED_WITH_TBB
|
||||
|
||||
#include <boost/unordered_set.hpp>
|
||||
|
|
@ -78,13 +78,13 @@ struct Distance_computation{
|
|||
const AABB_tree& tree;
|
||||
const PointRange& sample_points;
|
||||
Point_3 initial_hint;
|
||||
tbb::atomic<double>* distance;
|
||||
std::atomic<double>* distance;
|
||||
|
||||
Distance_computation(
|
||||
const AABB_tree& tree,
|
||||
const Point_3& p,
|
||||
const PointRange& sample_points,
|
||||
tbb::atomic<double>* d)
|
||||
std::atomic<double>* d)
|
||||
: tree(tree)
|
||||
, sample_points(sample_points)
|
||||
, initial_hint(p)
|
||||
|
|
@ -108,7 +108,8 @@ struct Distance_computation{
|
|||
double current_value = *distance;
|
||||
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
|
||||
if (boost::is_convertible<Concurrency_tag,Parallel_tag>::value)
|
||||
{
|
||||
tbb::atomic<double> distance;
|
||||
std::atomic<double> distance;
|
||||
distance=0;
|
||||
Distance_computation<AABBTree, PointRange> f(tree, hint, sample_points, &distance);
|
||||
tbb::parallel_for(tbb::blocked_range<std::size_t>(0, sample_points.size()), f);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
//#undef CGAL_LINKED_WITH_TBB
|
||||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
#include <tbb/parallel_for.h>
|
||||
#include <tbb/mutex.h>
|
||||
#include <mutex>
|
||||
#include <tbb/blocked_range.h>
|
||||
#include <tbb/scalable_allocator.h>
|
||||
#endif // CGAL_LINKED_WITH_TBB
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
#include <tbb/parallel_for.h>
|
||||
#include <tbb/blocked_range.h>
|
||||
#include <tbb/atomic.h>
|
||||
#include <atomic>
|
||||
#endif // CGAL_LINKED_WITH_TBB
|
||||
|
||||
#if defined(CGAL_LINKED_WITH_TBB)
|
||||
|
|
@ -31,13 +31,13 @@ struct Distance_computation{
|
|||
const AABB_tree& tree;
|
||||
const Point_set & point_set;
|
||||
Point_3 initial_hint;
|
||||
tbb::atomic<double>* distance;
|
||||
std::atomic<double>* distance;
|
||||
std::vector<double>& output;
|
||||
|
||||
Distance_computation(const AABB_tree& tree,
|
||||
const Point_3 p,
|
||||
const Point_set & point_set,
|
||||
tbb::atomic<double>* d,
|
||||
std::atomic<double>* d,
|
||||
std::vector<double>& out )
|
||||
: tree(tree)
|
||||
, point_set(point_set)
|
||||
|
|
@ -96,7 +96,7 @@ double compute_distances(const Mesh& m,
|
|||
}
|
||||
return hdist;
|
||||
#else
|
||||
tbb::atomic<double> distance;
|
||||
std::atomic<double> distance;
|
||||
distance.store(0);
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include <tbb/atomic.h>
|
||||
#include <atomic>
|
||||
#if TBB_IMPLEMENT_CPP0X
|
||||
# include <tbb/compat/thread>
|
||||
#else
|
||||
|
|
@ -452,12 +452,12 @@ class Spatial_lock_grid_3<Tag_non_blocking>
|
|||
public:
|
||||
// Constructors
|
||||
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 =
|
||||
num_grid_cells_per_axis*num_grid_cells_per_axis*num_grid_cells_per_axis;
|
||||
|
||||
m_grid.resize(num_cells);
|
||||
// Initialize grid (useless?)
|
||||
for (int i = 0 ; i < num_cells ; ++i)
|
||||
m_grid[i] = false;
|
||||
|
|
@ -475,7 +475,8 @@ public:
|
|||
template <bool no_spin>
|
||||
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;
|
||||
bool old_value = m_grid[cell_index].compare_exchange_strong(v1,v2);
|
||||
if (old_value == false)
|
||||
{
|
||||
get_thread_local_grid()[cell_index] = true;
|
||||
|
|
@ -492,7 +493,7 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
std::vector<tbb::atomic<bool> > m_grid;
|
||||
std::vector<std::atomic<bool> > m_grid;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -512,14 +513,14 @@ public:
|
|||
|
||||
Spatial_lock_grid_3(const Bbox_3 &bbox, int num_grid_cells_per_axis)
|
||||
: Base(bbox, num_grid_cells_per_axis),
|
||||
m_tls_thread_priorities(init_TLS_thread_priorities)
|
||||
m_tls_thread_priorities(init_TLS_thread_priorities),
|
||||
m_grid(num_grid_cells_per_axis*num_grid_cells_per_axis*num_grid_cells_per_axis)
|
||||
{
|
||||
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
|
||||
std::vector<tbb::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 = m_grid.begin();
|
||||
std::vector<std::atomic<unsigned int> >::iterator it_end = m_grid.end();
|
||||
for ( ; it != it_end ; ++it)
|
||||
*it = 0;
|
||||
}
|
||||
|
|
@ -542,9 +543,8 @@ public:
|
|||
// NO SPIN
|
||||
if (no_spin)
|
||||
{
|
||||
unsigned int old_value =
|
||||
m_grid[cell_index].compare_and_swap(this_thread_priority, 0);
|
||||
if (old_value == 0)
|
||||
unsigned int old_value = 0;
|
||||
if(!m_grid[cell_index].compare_exchange_strong(old_value, this_thread_priority))
|
||||
{
|
||||
get_thread_local_grid()[cell_index] = true;
|
||||
m_tls_locked_cells.local().push_back(cell_index);
|
||||
|
|
@ -556,9 +556,8 @@ public:
|
|||
{
|
||||
for(;;)
|
||||
{
|
||||
unsigned int old_value =
|
||||
m_grid[cell_index].compare_and_swap(this_thread_priority, 0);
|
||||
if (old_value == 0)
|
||||
unsigned int old_value =0;
|
||||
if(m_grid[cell_index].compare_exchange_weak(old_value, this_thread_priority))
|
||||
{
|
||||
get_thread_local_grid()[cell_index] = true;
|
||||
m_tls_locked_cells.local().push_back(cell_index);
|
||||
|
|
@ -587,7 +586,7 @@ public:
|
|||
private:
|
||||
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;
|
||||
// Ensure it is > 0
|
||||
return (1 + id%((std::numeric_limits<unsigned int>::max)()));
|
||||
|
|
@ -595,7 +594,7 @@ private:
|
|||
|
||||
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;
|
||||
TLS_thread_uint_ids m_tls_thread_priorities;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
# include <tbb/tbb_config.h>
|
||||
# if TBB_IMPLEMENT_CPP0X
|
||||
# include <tbb/compat/thread>
|
||||
# include <tbb/atomic.h>
|
||||
# include <atomic>
|
||||
# include <tbb/tick_count.h>
|
||||
# define CGAL_USE_TBB_THREADS 1
|
||||
# else
|
||||
|
|
@ -83,8 +83,8 @@ namespace cpp11 {
|
|||
|
||||
#if defined(CGAL_NO_ATOMIC) && defined(CGAL_LINKED_WITH_TBB)
|
||||
// If <CGAL/atomic.h> did not defined CGAL::cpp11::atomic, then use
|
||||
// tbb::atomic as a fallback.
|
||||
using tbb::atomic;
|
||||
// std::atomic as a fallback.
|
||||
using std::atomic;
|
||||
#endif
|
||||
|
||||
} // cpp11
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ int main()
|
|||
|
||||
# include <tbb/task_scheduler_init.h>
|
||||
# include <tbb/parallel_for.h>
|
||||
# include <tbb/atomic.h>
|
||||
# include <atomic>
|
||||
|
||||
#include <CGAL/disable_warnings.h>
|
||||
|
||||
|
|
@ -139,12 +139,12 @@ template <typename Values_vec, typename Cont>
|
|||
class Insert_and_erase_in_CCC_functor
|
||||
{
|
||||
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:
|
||||
Insert_and_erase_in_CCC_functor(
|
||||
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_free_elements(free_elements), m_num_erasures(num_erasures)
|
||||
{}
|
||||
|
|
@ -176,7 +176,7 @@ private:
|
|||
Cont & m_cont;
|
||||
Iterators_vec & m_iterators;
|
||||
Free_elts_vec & m_free_elements;
|
||||
tbb::atomic<unsigned int> & m_num_erasures;
|
||||
std::atomic<unsigned int> & m_num_erasures;
|
||||
};
|
||||
|
||||
template < class Cont >
|
||||
|
|
@ -372,14 +372,14 @@ void test(const Cont &)
|
|||
{
|
||||
Cont c12;
|
||||
Vect v12(1000000);
|
||||
std::vector<tbb::atomic<bool> > free_elements(v12.size());
|
||||
for(typename std::vector<tbb::atomic<bool> >::iterator
|
||||
std::vector<std::atomic<bool> > free_elements(v12.size());
|
||||
for(typename std::vector<std::atomic<bool> >::iterator
|
||||
it = free_elements.begin(), end = free_elements.end(); it != end; ++it)
|
||||
{
|
||||
*it = true;
|
||||
}
|
||||
|
||||
tbb::atomic<unsigned int> num_erasures;
|
||||
std::atomic<unsigned int> num_erasures;
|
||||
num_erasures = 0;
|
||||
std::vector<typename Cont::iterator> iterators(v12.size());
|
||||
tbb::parallel_for(
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
# include <CGAL/point_generators_3.h>
|
||||
# include <tbb/parallel_for.h>
|
||||
# include <tbb/task_scheduler_init.h>
|
||||
# include <thread>
|
||||
# include <tbb/enumerable_thread_specific.h>
|
||||
# include <tbb/concurrent_vector.h>
|
||||
#endif
|
||||
|
|
@ -289,7 +289,7 @@ private:
|
|||
bbox.zmin() + 0.5*zdelta);
|
||||
Random_points_on_sphere_3<Point> random_point(radius);
|
||||
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;
|
||||
|
||||
points_on_far_sphere.reserve(NUM_PSEUDO_INFINITE_VERTICES);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
# include <CGAL/point_generators_3.h>
|
||||
# include <tbb/parallel_for.h>
|
||||
# include <tbb/task_scheduler_init.h>
|
||||
# include <thread>
|
||||
# include <tbb/enumerable_thread_specific.h>
|
||||
# include <tbb/concurrent_vector.h>
|
||||
#endif
|
||||
|
|
@ -258,7 +258,7 @@ private:
|
|||
bbox.zmin() + 0.5*zdelta);
|
||||
Random_points_on_sphere_3<Bare_point> random_point(radius);
|
||||
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 =
|
||||
geom_traits().construct_weighted_point_3_object();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue