Merge pull request #1646 from afabri/Apollonius_graph-static-GF

Apollonius_graph: make variables atomic
This commit is contained in:
Laurent Rineau 2016-11-18 10:56:28 +01:00 committed by GitHub
commit e51c4418c9
7 changed files with 65 additions and 55 deletions

View File

@ -24,6 +24,7 @@
#define CGAL_COMPARATOR_PROFILER_H
#include <CGAL/Apollonius_graph_2/basic.h>
#include <CGAL/atomic.h>
namespace CGAL {
@ -32,23 +33,31 @@ namespace ApolloniusGraph_2 {
class comparator_profiler
{
public:
static bool count_cases;
static unsigned long case_1_counter;
static unsigned long case_2_counter;
static unsigned long case_3a_Jpos_counter;
static unsigned long case_3a_Jneg_counter;
static unsigned long case_3b_Jpos_counter;
static unsigned long case_3b_Jneg_counter;
static unsigned long case_4_counter;
static unsigned long case_5_counter;
static unsigned long case_degenerate_counter;
#ifdef CGAL_NO_ATOMIC
typedef bool bool_;
typedef unsigned long long_;
#else
typedef CGAL::cpp11::atomic<bool> bool_;
typedef CGAL::cpp11::atomic<unsigned long> long_;
#endif
static bool_ count_cases;
static long_ case_1_counter;
static long_ case_2_counter;
static long_ case_3a_Jpos_counter;
static long_ case_3a_Jneg_counter;
static long_ case_3b_Jpos_counter;
static long_ case_3b_Jneg_counter;
static long_ case_4_counter;
static long_ case_5_counter;
static long_ case_degenerate_counter;
public:
static unsigned long counter_rr;
static unsigned long counter_rr_p3inf;
static unsigned long counter_rr_p4;
static unsigned long counter_rr_e;
static unsigned long counter_rr_r0;
// static unsigned long counter_rr_jneg;
static long_ counter_rr;
static long_ counter_rr_p3inf;
static long_ counter_rr_p4;
static long_ counter_rr_e;
static long_ counter_rr_r0;
static void reset()
{
@ -68,7 +77,6 @@ public:
counter_rr_p4 = 0;
counter_rr_e = 0;
counter_rr_r0 = 0;
// counter_rr_jneg = 0;
}
template< class FT >
@ -141,6 +149,8 @@ public:
}
};
#ifdef CGAL_NO_ATOMIC
bool comparator_profiler::count_cases = false;
unsigned long comparator_profiler::case_1_counter = 0;
unsigned long comparator_profiler::case_2_counter = 0;
@ -157,7 +167,9 @@ unsigned long comparator_profiler::counter_rr_p3inf = 0;
unsigned long comparator_profiler::counter_rr_p4 = 0;
unsigned long comparator_profiler::counter_rr_e = 0;
unsigned long comparator_profiler::counter_rr_r0 = 0;
//unsigned long comparator_profiler::counter_rr_jneg = 0;
#endif
} //namespace ApolloniusGraph_2

View File

@ -24,6 +24,7 @@
#define CGAL_APOLLONIUS_GRAPH_2_PREDICATE_PROFILER 1
#include <CGAL/Apollonius_graph_2/basic.h>
#include <CGAL/atomic.h>
#define AG2_PROFILE_PREDICATES
@ -34,18 +35,24 @@ namespace ApolloniusGraph_2 {
class ag2_predicate_profiler
{
public:
#ifdef CGAL_NO_ATOMIC
typedef unsigned long long_;
#else
typedef CGAL::cpp11::atomic<unsigned long> long_;
#endif
// high level predicates
static unsigned long side_of_bisector_counter;
static unsigned long is_trivial_counter;
static unsigned long infinite_edge_conflict_type_counter;
static unsigned long finite_edge_conflict_type_counter;
static long_ side_of_bisector_counter;
static long_ is_trivial_counter;
static long_ infinite_edge_conflict_type_counter;
static long_ finite_edge_conflict_type_counter;
// subpredicates
static unsigned long inside_circular_arc_counter;
static unsigned long distance_from_bitangent_counter;
static unsigned long shadow_region_type_counter;
static unsigned long incircle_counter;
static unsigned long order_on_bisector_counter;
static long_ inside_circular_arc_counter;
static long_ distance_from_bitangent_counter;
static long_ shadow_region_type_counter;
static long_ incircle_counter;
static long_ order_on_bisector_counter;
static void reset() {
side_of_bisector_counter = 0;
@ -61,6 +68,9 @@ public:
}
};
#ifdef CGAL_NO_ATOMIC
unsigned long ag2_predicate_profiler::side_of_bisector_counter = 0;
unsigned long ag2_predicate_profiler::is_trivial_counter = 0;
unsigned long ag2_predicate_profiler::infinite_edge_conflict_type_counter = 0;
@ -72,6 +82,8 @@ unsigned long ag2_predicate_profiler::shadow_region_type_counter = 0;
unsigned long ag2_predicate_profiler::incircle_counter = 0;
unsigned long ag2_predicate_profiler::order_on_bisector_counter = 0;
#endif
} //namespace ApolloniusGraph_2
} //namespace CGAL

View File

@ -47,7 +47,7 @@ private:
inline
Uncertain<bool> is_less (const Site_2 &p0, const Site_2 &p1) const
{
static Uncertain<bool> uncertain_bool =
static const Uncertain<bool> uncertain_bool =
Uncertain<bool>::indeterminate();
Uncertain<Comparison_result> cr;

View File

@ -59,7 +59,7 @@ protected:
#else
static const FT& OFFSET()
{
static FT offset_(10000);
static const FT offset_(10000);
return offset_;
}
#endif

View File

@ -48,21 +48,6 @@ public:
private:
typedef Algebraic_structure_traits<FT> AST;
protected:
// static stuff
#if defined(__POWERPC__) && \
defined(__GNUC__) && (__GNUC__ == 3) && (__GNUC_MINOR__ == 4)
// hack to avoid nasty warning for G++ 3.4 on Darwin
static FT STEP()
{
return FT(2);
}
#else
static const FT& STEP()
{
static FT step_(2);
return step_;
}
#endif
// inline static
// FT square(const FT &x)
@ -291,9 +276,9 @@ public:
pleft.push_back(o);
pright.push_back(o);
const FT STEP(2);
for (int i = 1; i <= 100; i++) {
p = compute_points(i * i * STEP());
p = compute_points(i * i * STEP);
W << p[0];
W << p[1];

View File

@ -68,12 +68,12 @@ public:
}
int compute_k(const FT& tt) const {
// return int(CGAL::to_double(CGAL::sqrt(tt / this->STEP())));
return int(CGAL::sqrt(CGAL::to_double(tt) / CGAL::to_double(this->STEP())));
return int(CGAL::sqrt(CGAL::to_double(tt) / 2));
}
void generate_points(std::vector<Point_2>& p) const
{
const FT STEP(2);
FT s0, s1;
s0 = t(p1);
@ -92,20 +92,21 @@ public:
p.push_back( this->o );
k = -1;
tt = -this->STEP();
tt = - STEP;
while ( CGAL::compare(tt, s0) == LARGER ) {
p.insert( p.begin(), f(tt) );
k--;
tt = -FT(k * k) * this->STEP();
tt = -FT(k * k) * STEP;
}
p.insert( p.begin(), f(s0) );
k = 1;
tt = this->STEP();
tt = STEP;
while ( CGAL::compare(tt, s1) == SMALLER ) {
p.push_back( f(tt) );
k++;
tt = FT(k * k) * this->STEP();
tt = FT(k * k) * STEP;
}
p.push_back( f(s1) );
} else if ( !(CGAL::is_negative(s0)) &&
@ -123,7 +124,7 @@ public:
if ( CGAL::compare(tt, s0) != SMALLER )
p.push_back( f(tt) );
k++;
tt = FT(k * k) * this->STEP();
tt = FT(k * k) * STEP;
}
p.push_back( f(s1) );
} else {
@ -139,7 +140,7 @@ public:
if ( CGAL::compare(tt, s1) != LARGER )
p.push_back( f(tt) );
k--;
tt = -FT(k * k) * this->STEP();
tt = -FT(k * k) * STEP;
}
p.push_back( f(s0) );
}

View File

@ -164,7 +164,7 @@ public:
void remove(const Edge& e) {
CGAL_precondition( is_in_list(e) );
static Edge SENTINEL_QUEUE_EDGE = Edge(Face_handle(), -1);
static const Edge SENTINEL_QUEUE_EDGE = Edge(Face_handle(), -1);
if ( is_singleton() ) {
_front = SENTINEL_QUEUE_EDGE;