PPL  1.2
Parma_Polyhedra_Library::Init Class Reference

Class for initialization and finalization. More...

#include <Init_defs.hh>

Public Member Functions

 Init ()
 Initializes the PPL. More...
 
 ~Init ()
 Finalizes the PPL. More...
 

Static Private Attributes

static const unsigned DEFAULT_IRRATIONAL_PRECISION = 128U
 Default precision parameter used for irrational calculations. More...
 
static unsigned int count = 0
 Count the number of objects created. More...
 
static fpu_rounding_direction_type old_rounding_direction
 

Friends

void set_rounding_for_PPL ()
 Sets the FPU rounding mode so that the PPL abstractions based on floating point numbers work correctly. More...
 
void restore_pre_PPL_rounding ()
 Sets the FPU rounding mode as it was before initialization of the PPL. More...
 

Detailed Description

Class for initialization and finalization.

Nifty Counter initialization class, ensuring that the library is initialized only once and before its first use. A count of the number of translation units using the library is maintained. A static object of Init type will be declared by each translation unit using the library. As a result, only one of them will initialize and properly finalize the library.

Definition at line 72 of file Init_defs.hh.

Constructor & Destructor Documentation

Parma_Polyhedra_Library::Init::Init ( )

Initializes the PPL.

Definition at line 133 of file Init.cc.

References Parma_Polyhedra_Library::Coefficient_constants_initialize(), count, DEFAULT_IRRATIONAL_PRECISION, Parma_Polyhedra_Library::Variable::default_output_function(), Parma_Polyhedra_Library::fpu_get_rounding_direction(), Parma_Polyhedra_Library::fpu_initialize_control_functions(), Parma_Polyhedra_Library::fpu_set_rounding_direction(), Parma_Polyhedra_Library::initialize(), Parma_Polyhedra_Library::Constraint_System::initialize(), Parma_Polyhedra_Library::Congruence_System::initialize(), Parma_Polyhedra_Library::Grid_Generator_System::initialize(), Parma_Polyhedra_Library::Generator_System::initialize(), Parma_Polyhedra_Library::Congruence::initialize(), Parma_Polyhedra_Library::Polyhedron::initialize(), Parma_Polyhedra_Library::Constraint::initialize(), Parma_Polyhedra_Library::Grid_Generator::initialize(), Parma_Polyhedra_Library::Generator::initialize(), Parma_Polyhedra_Library::Linear_Expression::initialize(), old_rounding_direction, ppl_set_GMP_memory_allocation_functions(), Parma_Polyhedra_Library::ROUND_DIRECT, Parma_Polyhedra_Library::round_fpu_dir(), Parma_Polyhedra_Library::set_irrational_precision(), and Parma_Polyhedra_Library::Variable::set_output_function().

133  {
134  // Only when the first Init object is constructed...
135  if (count++ == 0) {
136  // ... the GMP memory allocation functions are set, ...
138  // ... the default output function for Variable objects is set, ...
140  // ... the Coefficient constants are initialized, ...
142  // ... the Linear_Expression class is initialized, ...
144  // ... the Constraint, Generator, Congruence, Grid_Generator,
145  // Constraint_System, Generator_System, Congruence_System,
146  // Grid_Generator_System and Polyhedron classes are initialized, ...
156 
157 #if PPL_HAVE_DECL_SETITIMER && PPL_HAVE_DECL_SIGACTION
158  // ... the Watchdog subsystem is initialized, ...
160 #endif // PPL_HAVE_DECL_SETITIMER && PPL_HAVE_DECL_SIGACTION
161 
162 #if PPL_CAN_CONTROL_FPU
163 
164  // ... and the FPU rounding direction is set.
168 
169 #if defined(PPL_ARM_CAN_CONTROL_FPU) && PPL_ARM_CAN_CONTROL_FPU
170  if (ppl_test_rounding() != 0) {
171  throw std::logic_error("PPL configuration error:"
172  " PPL_ARM_CAN_CONTROL_FPU evaluates to true,"
173  " but rounding does not work.");
174  }
175 #endif // defined(PPL_ARM_CAN_CONTROL_FPU) && PPL_ARM_CAN_CONTROL_FPU
176 
177 #endif // PPL_CAN_CONTROL_FPU
178 
179  // The default is chosen to have a precision greater than most
180  // precise IEC 559 floating point (112 bits of mantissa).
182  }
183 }
static unsigned int count
Count the number of objects created.
Definition: Init_defs.hh:90
static void initialize()
Initializes the class.
Definition: Congruence.cc:270
static void initialize()
Initializes the class.
static const unsigned DEFAULT_IRRATIONAL_PRECISION
Default precision parameter used for irrational calculations.
Definition: Init_defs.hh:87
void set_irrational_precision(const unsigned p)
Sets the precision parameter used for irrational calculations.
void Coefficient_constants_initialize()
Initializes the Coefficient constants.
fpu_rounding_direction_type fpu_get_rounding_direction()
Returns the current FPU rounding direction.
static void initialize()
Initializes the class.
fpu_rounding_direction_type round_fpu_dir(Rounding_Dir dir)
static void initialize()
Initializes the class.
static void initialize()
Initializes the class.
Definition: Generator.cc:281
static void default_output_function(std::ostream &s, const Variable v)
The default output function.
Definition: Variable.cc:39
void initialize()
Initializes the library.
Definition: initializer.hh:52
static fpu_rounding_direction_type old_rounding_direction
Definition: Init_defs.hh:91
void fpu_initialize_control_functions()
Initializes the FPU control functions.
void ppl_set_GMP_memory_allocation_functions(void)
static void initialize()
Initializes the class.
static void initialize()
Initializes the class.
static void initialize()
Initializes the class.
Definition: Constraint.cc:271
static void set_output_function(output_function_type *p)
Sets the output function to be used for printing Variable objects.
void fpu_set_rounding_direction(fpu_rounding_direction_type dir)
Sets the FPU rounding direction to dir.
static void initialize()
Initializes the class.
static void initialize()
Initializes the class.
Parma_Polyhedra_Library::Init::~Init ( )

Finalizes the PPL.

Definition at line 185 of file Init.cc.

References Parma_Polyhedra_Library::Coefficient_constants_finalize(), Parma_Polyhedra_Library::finalize(), Parma_Polyhedra_Library::Constraint_System::finalize(), Parma_Polyhedra_Library::Congruence_System::finalize(), Parma_Polyhedra_Library::Grid_Generator_System::finalize(), Parma_Polyhedra_Library::Generator_System::finalize(), Parma_Polyhedra_Library::Congruence::finalize(), Parma_Polyhedra_Library::Polyhedron::finalize(), Parma_Polyhedra_Library::Constraint::finalize(), Parma_Polyhedra_Library::Grid_Generator::finalize(), Parma_Polyhedra_Library::Generator::finalize(), Parma_Polyhedra_Library::Linear_Expression::finalize(), and Parma_Polyhedra_Library::fpu_set_rounding_direction().

185  {
186  // Only when the last Init object is destroyed...
187  if (--count == 0) {
188 #if PPL_CAN_CONTROL_FPU
189  // ... the FPU rounding direction is restored, ...
191 #endif
192 
193 #if PPL_HAVE_DECL_SETITIMER && PPL_HAVE_DECL_SIGACTION
194  // ... the Watchdog subsystem is finalized, ...
196 #endif // PPL_HAVE_DECL_SETITIMER && PPL_HAVE_DECL_SIGACTION
197 
198  // ... the Polyhedron, Grid_Generator_System, Congruence_System,
199  // Generator_System, Constraint_System, Grid_Generator,
200  // Congruence, Generator and Constraint classes are finalized
201  // IN THAT ORDER, ...
211  // ... the Linear_Expression class is finalized, ...
213  // ... and the Coefficient constants are finalized.
215  }
216 }
static unsigned int count
Count the number of objects created.
Definition: Init_defs.hh:90
void Coefficient_constants_finalize()
Finalizes the Coefficient constants.
static void finalize()
Finalizes the class.
static void finalize()
Finalizes the class.
static void finalize()
Finalizes the class.
void finalize()
Finalizes the library.
Definition: initializer.hh:60
static void finalize()
Finalizes the class.
Definition: Generator.cc:292
static void finalize()
Finalizes the class.
Definition: Constraint.cc:290
static void finalize()
Finalizes the class.
Definition: Congruence.cc:281
static fpu_rounding_direction_type old_rounding_direction
Definition: Init_defs.hh:91
static void finalize()
Finalizes the class.
static void finalize()
Finalizes the class.
void fpu_set_rounding_direction(fpu_rounding_direction_type dir)
Sets the FPU rounding direction to dir.
static void finalize()
Finalizes the class.

Friends And Related Function Documentation

void restore_pre_PPL_rounding ( )
friend

Sets the FPU rounding mode as it was before initialization of the PPL.

This is important if the application uses floating-point computations outside the PPL. It is crucial when the application uses functions from a mathematical library that are not guaranteed to work correctly under all rounding modes.

After calling this function it is absolutely necessary to call set_rounding_for_PPL() before using any PPL abstractions based on floating point numbers. This is performed automatically at finalization-time.

Definition at line 40 of file Init_inlines.hh.

40  {
41 #if PPL_CAN_CONTROL_FPU
43 #endif
44 }
static fpu_rounding_direction_type old_rounding_direction
Definition: Init_defs.hh:91
void fpu_set_rounding_direction(fpu_rounding_direction_type dir)
Sets the FPU rounding direction to dir.
void set_rounding_for_PPL ( )
friend

Sets the FPU rounding mode so that the PPL abstractions based on floating point numbers work correctly.

This is performed automatically at initialization-time. Calling this function is needed only if restore_pre_PPL_rounding() has been previously called.

Definition at line 33 of file Init_inlines.hh.

33  {
34 #if PPL_CAN_CONTROL_FPU
36 #endif
37 }
fpu_rounding_direction_type round_fpu_dir(Rounding_Dir dir)
void fpu_set_rounding_direction(fpu_rounding_direction_type dir)
Sets the FPU rounding direction to dir.

Member Data Documentation

unsigned int Parma_Polyhedra_Library::Init::count = 0
staticprivate

Count the number of objects created.

Definition at line 90 of file Init_defs.hh.

Referenced by Init().

const unsigned Parma_Polyhedra_Library::Init::DEFAULT_IRRATIONAL_PRECISION = 128U
staticprivate

Default precision parameter used for irrational calculations.

The default is chosen to have a precision greater than most precise IEC 559 floating point (112 bits of mantissa).

Definition at line 87 of file Init_defs.hh.

Referenced by Init().

PPL::fpu_rounding_direction_type Parma_Polyhedra_Library::Init::old_rounding_direction
staticprivate

Definition at line 91 of file Init_defs.hh.

Referenced by Init(), and Parma_Polyhedra_Library::restore_pre_PPL_rounding().


The documentation for this class was generated from the following files: