C++ library and thread initialization
|
Type
|
Level
|
MID
|
UID
|
REFS
|
Title
|
Statement
|
Rationale
|
Comment
|
BIBLIOGRAPHY
|
STATUS
|
COMPONENT
|
APPLICABILITY
|
VERIFICATION_METHODS
|
VERIFICATION_CRITERIA
|
SOURCE
|
LANGUAGE
|
VISIBILITY
|
INTERFACE
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
SW_SPEC
|
1 |
|
|
Incoming links from:
1. Bounded-difference values, numerical profiles and valid use
3. Box bounded-integer wrapping, overflow choices and guard refinement
3. Box extrapolation with selected limiting constraints
1. Box construction from supported constraints
2. Box construction from supported congruences
3. Cartesian enclosure of a polyhedral generator system
4. Box conversion from bounded-difference shapes
5. Box conversion from octagonal shapes
6. Complexity-sensitive box conversion from polyhedra
7. Cartesian enclosure of a rational grid
8. Box conversion from partially reduced products
2. Least box enclosure of nonnegative real-time progression
3. Selected-coordinate integer-point normalization of boxes
2. Constraint and congruence exports of box values
3. Affine boundedness, extrema and witnesses on boxes
1. Cartesian box values, coordinate identity and valid use
6. Coefficient zero and one constant access
1. Compound-domain values and valid use
1. Rational-grid values, coefficient profile and valid use
2. Explicit whole-library initialization and finalization
2. Explicit whole-library initialization and finalization
1. Directed native integral conversion to native floating-point storage
1. Octagonal values, numerical profiles and valid use
1. Polyhedral values, coefficient profile and valid use
1. Optimization and ranking valid use
6. Coordinate-set diagnostic output and formatter prerequisites
7. Active Variable formatter and initialized thread state
27 |
The public C++ header shall establish an initialization owner in each participating translation unit unless PPL_NO_AUTOMATIC_INITIALIZATION is defined before that translation unit first includes <ppl.hh>. The first successfully constructed Init owner shall establish shared library facilities and initialize its calling thread. Additional owners shall retain that initialized lifetime without reinitializing its existing thread state. Destruction of an owner while another owner remains shall preserve the shared facilities. Destruction of the last owner shall finalize the owning thread and release shared initialization facilities. The first-owner construction and last-owner destruction shall be serialized by the caller and shall occur on the same thread. All other participating threads shall complete their PPL use and thread finalization before last-owner destruction. Every PPL object or borrowed view whose validity depends on the initialized facilities shall cease to be used, and every required owned-object cleanup shall finish, before those facilities are finalized. A later initialized lifetime shall not revive objects or views from an earlier lifetime. The owner counter, saved-rounding storage, automatic-owner pointers and irrational-precision storage shall be statically zero-initialized. The optional rounding-verifier function pointers shall be statically initialized to their designated probes. Their definitions shall enforce constant initialization with constinit. Runtime owner and thread setup shall establish the numerical state specified by this protocol. Explicit Init guards shall be used only within this ownership protocol. The number of simultaneously live owners shall remain representable by unsigned int. Callers shall not copy, move or assign Init or Thread_Init guards. Automatic initialization shall not by itself initialize worker threads. Thread entry and exit shall follow 🔗 3. Thread initialization, default state and finalization. If first-owner construction reports a supported recoverable exception, it shall release resources acquired for the failed construction, restore the preceding variable formatter, irrational precision and rounding state, and leave no initialization owner contributed by the failed construction. If setup replaced a signal handler, failure shall restore its preceding action without discarding the caller's pending notifications or changing the caller's timer. |
Translation-unit ownership keeps initialized facilities available during static and automatic object lifetimes. First/last-owner and thread-exit conditions make the ownership boundary and its synchronization explicit. |
|
|
|
|
|
Compile and run a public-header client with initialized objects in more than one translation unit, including their static construction and destruction. Exercise nested explicit owners and confirm that destroying an inner owner preserves live models, formatter selection and rounding state. Exercise repeated whole-library lifetimes after all dependent objects have been destroyed. Inspect first/last-owner transitions and configuration-dependent ownership. Inject supported construction failures and check acquired-resource cleanup, formatter, precision and rounding restoration, and absence of an owner from a failed construction. Check restoration of a preceding signal action and preservation of caller-owned timer state and pending notifications on failure. Review guard noncopying and serialized first/last-owner prerequisites. Check independent public-header workers, default formatter and precision, parent-state isolation and worker rounding restoration. |
src/initializer.hh: per-translation-unit automatic owner. src/Init_defs.hh and src/Init.cc: initialization-owner lifetime. tests/initialization1.cc: nested owners and repeated explicit lifetimes. tests/initialization2.cc and tests/initialization2_aux.cc: automatic initialization across translation units. tests/initialization3.cc: first-owner failure, resource cleanup and retry. tests/initialization4.cc: native rounding-initialization failure fixture. tests/threadsafepublic1.cc: Check independent public-header workers, default formatter and precision, parent-state isolation and worker rounding restoration. |
|
|
Public header: <ppl.hh>. Initialization-owner declarations: namespace Parma_Polyhedra_Library { class Init { public: Init(); ~Init(); }; } The header-selection macro is PPL_NO_AUTOMATIC_INITIALIZATION; it shall be selected consistently across participating C++ client translation units before their first public-header inclusion. |
||
|
SW_SPEC
|
2 |
|
|
|
When automatic initialization is disabled by PPL_NO_AUTOMATIC_INITIALIZATION before public-header inclusion, initialize() shall acquire one library initialization owner on its first successful call without an existing explicit owner. Repeated calls while that owner exists shall preserve it and its active thread state, rather than acquire additional owners or reset the formatter, numerical constants or precision. finalize() shall release that explicit owner. A call to finalize() shall require an existing explicit owner; a sequence of repeated initialize() calls shall require only one matching finalize(). The explicit owner shall obey the first/last-owner, dependent-object cleanup and same-thread conditions of 🔗 1. Initialization owners and automatic C++ initialization. After successful finalize(), a later initialize() shall establish a fresh initialized lifetime. Supported recoverable failure in initialize() shall release resources acquired for the failed owner and shall permit a later call to attempt initialization afresh. When the header provides automatic initialization, initialize(), finalize(), thread_initialize() and thread_finalize() shall be no-ops; the automatic owner and explicit Thread_Init guards shall govern those lifetimes instead. |
An explicit initialization mode supports applications and bindings that own the library lifetime themselves. Idempotent entry and a single release avoid interpreting repeated requests as additional independent ownership. |
|
|
|
|
|
Build a client with automatic initialization disabled and no automatically initializing helper translation unit. Check repeated initialization while a custom formatter, precision and live numerical models are present; confirm that one finalization ends that owned lifetime. Repeat balanced lifetimes and check fresh default state. Inject a first-owner allocation failure and confirm that a later initialization establishes usable state. In a separate automatically initialized client, call all four entry points while models and a custom formatter are live and confirm that they do not alter the active lifetime. |
src/initializer.hh: public entry points and macro-dependent no-ops. src/Init.cc: explicit-owner acquisition and release. tests/initialization1.cc: explicit initialization and repeated lifetimes. tests/initialization2.cc: automatic-mode no-op entry points. tests/initialization3.cc: explicit acquisition failure and successful retry. tests/initialization4.cc: failure after native rounding initialization. |
|
|
Public whole-library entry points: namespace Parma_Polyhedra_Library { void initialize(); void finalize(); } Their definitions are selected by the public-header initialization macro as described in 🔗 1. Initialization owners and automatic C++ initialization. |
||
|
SW_SPEC
|
3 |
|
|
Incoming links from:
1. Bounded-difference values, numerical profiles and valid use
3. Box bounded-integer wrapping, overflow choices and guard refinement
3. Box extrapolation with selected limiting constraints
1. Box construction from supported constraints
2. Box construction from supported congruences
3. Cartesian enclosure of a polyhedral generator system
4. Box conversion from bounded-difference shapes
5. Box conversion from octagonal shapes
6. Complexity-sensitive box conversion from polyhedra
7. Cartesian enclosure of a rational grid
8. Box conversion from partially reduced products
2. Least box enclosure of nonnegative real-time progression
3. Selected-coordinate integer-point normalization of boxes
2. Constraint and congruence exports of box values
3. Affine boundedness, extrema and witnesses on boxes
1. Cartesian box values, coordinate identity and valid use
1. Ordered coefficient-map values and valid tree use
2. Finite coefficient construction, copying and comparison
6. Coefficient zero and one constant access
7. Coefficient constant-stage acquisition and release
1. Compound-domain values and valid use
1. Affine congruence meaning and valid numerical use
1. Constraint relation meaning and numerical prerequisites
20. Distance scratch storage, admissible overlaps and numeric conditions
1. Extended-number row meaning and construction states
1. Generator kinds and numerical prerequisites
1. Grid-generator values and integer versus continuous displacement
1. Rational-grid values, coefficient profile and valid use
1. Initialization owners and automatic C++ initialization
5. Interruptible thread registration and request lifetime
1. Affine value, numerical prerequisites and shared zero
1. Directed native integral conversion to native floating-point storage
1. Octagonal values, numerical profiles and valid use
9. Distance workspace protocol and admissible overlaps
8. Coordinate-map diagnostic printing and output failures
1. Polyhedral values, coefficient profile and valid use
1. Internal coefficient-row values and valid use
1. Augmented coefficient products and numerical prerequisites
1. Optimization and ranking valid use
3. Selection and ownership of irrational rational precision
6. Coordinate-set diagnostic output and formatter prerequisites
7. Active Variable formatter and initialized thread state
42 |
While a library initialization owner remains alive, each additional thread using PPL thread-specific facilities shall establish exactly one active thread initialization lifetime before those facilities are used. A directly constructed Thread_Init guard shall establish that lifetime and shall finalize it when the guard is destroyed on the same thread. A direct guard shall not overlap an already active PPL thread-initialization lifetime on that thread and shall not be copied, moved or assigned. In a client compiled with automatic initialization disabled, thread_initialize() shall establish a thread lifetime if none is owned by that entry protocol. Repeated calls while that protocol owns an active lifetime shall preserve its constants, precision and formatter. thread_finalize() shall require and end that protocol-owned active lifetime. Direct guards and these entry points shall not be mixed for the same active lifetime. The thread initialized by the first library owner shall have an active protocol-owned thread lifetime when last-owner destruction begins. Successful thread initialization shall establish the numerical constants used by expressions, constraints, congruences, generators, their systems and polyhedra, set irrational_precision() to 128, and select Variable::default_output_function as the active variable formatter, as specified by 🔗 7. Active Variable formatter and initialized thread state. When configured rounding control is available, it shall save and replace the calling thread's rounding direction as specified by 🔗 4. Rounding-state exchange during an initialized thread lifetime. In a thread-safe configuration these states shall belong to the calling thread and shall be isolated from the corresponding state of other initialized threads. In a configuration without thread support, clients shall use one initialized thread and shall not create overlapping thread-initialization lifetimes. Before finalization, all PPL use and required owned-object cleanup depending on that thread's initialized state shall finish. Finalization shall release the thread-owned initialization resources and restore its saved rounding direction when rounding control is configured. Reentry after completed finalization shall establish fresh default state; it shall not revive earlier objects or views. If thread construction reports a supported recoverable exception, resources acquired for the incomplete lifetime shall be released, and the preceding variable formatter, irrational precision and rounding state shall be restored. |
Constants, formatter callbacks, irrational precision and saved rounding state must have an explicit thread lifetime. Idempotent entry preserves active state; reentry after cleanup deliberately establishes a new default state. |
|
|
|
|
|
Check usable numerical constants and representative expressions and domains within explicitly initialized thread lifetimes. Set a custom formatter and precision, repeat thread entry, and confirm that active state is unchanged. Finalize after destroying dependent objects, reenter, and confirm the default formatter and precision. In thread-safe configurations run two initialized workers while preserving distinct caller and worker state; check rounding restoration on worker exit and caller-state isolation. Exercise both direct guards and the manual entry protocol in their supported contexts. Review partial-construction cleanup with injected failures and object cleanup before thread and whole-library finalization. Check independent public-header workers, default formatter and precision, parent-state isolation and worker rounding restoration. |
src/Init_defs.hh and src/Init.cc: Thread_Init and initialized state. src/initializer.hh: manual thread entry and exit. src/thread_safe.hh: configuration-dependent thread-local storage. tests/initialization1.cc: manual thread entry, reentry and worker isolation. tests/initialization2.cc: direct worker guard within an automatic lifetime. tests/initialization3.cc: manual and direct thread-entry failure and retry. tests/initialization4.cc: failure after native thread rounding initialization. tests/threadsafepublic1.cc: Check independent public-header workers, default formatter and precision, parent-state isolation and worker rounding restoration. |
|
|
Public thread-lifetime declarations: namespace Parma_Polyhedra_Library { class Thread_Init { public: Thread_Init(); ~Thread_Init(); }; void thread_initialize(); void thread_finalize(); } The entry-point functions act only when automatic initialization was disabled before public-header inclusion. Thread_Init guards also support worker entry in automatically initialized C++ clients. |
||
|
SW_SPEC
|
4 |
|
|
|
On a configured platform with floating-point rounding control, successful thread initialization shall save the calling thread's preceding rounding direction and establish upward rounding, the direction used for ROUND_DIRECT computations. During that active thread lifetime, restore_pre_PPL_rounding() shall restore the direction saved at thread initialization, and set_rounding_for_PPL() shall reestablish upward rounding. Repeated calls shall not replace the saved preceding direction. Normal thread finalization shall restore that saved direction. Each exchange shall affect only the calling thread's rounding direction in a thread-safe configuration. The caller shall invoke these functions within a valid initialized thread lifetime and shall call set_rounding_for_PPL() before resuming PPL computations that require its rounding state after the preceding state has been restored or the client has otherwise changed rounding. The exchange shall not promise preservation or restoration of unrelated floating-point status flags, trap masks or other environment state. When the selected configuration has no floating-point rounding control, set_rounding_for_PPL() and restore_pre_PPL_rounding() shall perform no rounding-state operation. Their presence shall not make an unsupported floating-point computation supported. |
A client may need its own rounding direction between PPL computations. Saving once per thread lifetime gives restoration a stable meaning across repeated exchanges. |
|
|
|
|
|
For every supported incoming rounding direction, initialize the thread, check upward rounding and a representative upward-rounded computation, exchange to the saved direction and back repeatedly, and confirm restoration after finalization. Include nested library owners to ensure that they do not replace the saved direction. In a thread-safe configuration check worker restoration and isolation from the calling thread. Compile and inspect the no-control configuration so that no unsupported rounding-control operation is introduced. Keep rounding direction checks distinct from claims about the complete floating-point environment. Check independent public-header workers, default formatter and precision, parent-state isolation and worker rounding restoration. |
src/Init_defs.hh and src/Init_inlines.hh: rounding-exchange interface. src/Init.cc: saving, establishing and restoring thread rounding direction. tests/initialization1.cc: repeated lifetimes and direction exchanges. tests/initialization2.cc: restoration by a direct worker guard. tests/initialization3.cc: restoration after failed thread construction. tests/initialization4.cc: restoration after native rounding state changes. tests/threadsafepublic1.cc: Check independent public-header workers, default formatter and precision, parent-state isolation and worker rounding restoration. |
|
|
Public rounding exchange declarations: namespace Parma_Polyhedra_Library { void set_rounding_for_PPL(); void restore_pre_PPL_rounding(); } Availability of platform rounding control is selected by the configured PPL_CAN_CONTROL_FPU value. |
||
|
SW_SPEC
|
5 |
|
|
Incoming link from:
8. Cooperative abandonment checkpoint ordering and propagation
1 |
Within the library/thread lifecycle of 🔗 3. Thread initialization, default state and finalization, make_interruptible shall return a callable that initializes PPL thread state, registers the calling thread for interruption, invokes the wrapped callable with forwarded arguments and unregisters the thread before finalizing thread state. Return values and exceptions shall propagate to the caller. The registration shall also end during exception unwinding. A registration lifetime shall not overlap another PPL thread-initialization lifetime on the same thread. interrupt_thread shall serialize lookup against registration and removal. It shall return false when the supplied thread has no active registration. Otherwise it shall replace the thread's registration-scoped request and return true. A null request withdraws that request. Unregistering shall also withdraw the request. Both operations shall leave the separate caller-owned slot in 🔗 7. Caller-owned abandonment request and exception object intact. Acceptance does not guarantee that a checkpoint will occur before normal completion. At an abandonment checkpoint the requested Throwable follows 🔗 8. Cooperative abandonment checkpoint ordering and propagation. A non-null supplied object remains caller-owned and shall outlive all possible accesses by the target thread; requesters shall synchronize its lifetime and any concurrent calls themselves. The registry and its mutex shall remain alive until all registered calls and requesters have completed. Internal registration guards shall not be copied, moved or assigned. |
A cancellation request refers to another thread's thread-local state, whose address must remain valid during the synchronized lookup and request. |
|
|
|
|
|
Use synchronized workers to check accepted requests, rejection for default, unregistered and joined threads, exception-unwinding removal and a second lifetime without a stale request. Check that retracting a registration request and ending the registration preserve a separately published request. Keep the Throwable alive until join. Inspect mutex coverage, destruction order and request delivery at native checkpoints. |
src/make_threadable.hh; src/make_threadable.cc; tests/Polyhedron/threadsafe2.cc. |
|
|
Namespace Parma_Polyhedra_Library, in thread-safe builds: template <typename Function> Implementation::Interruptible<Function> make_interruptible(Function f); bool interrupt_thread(const std::thread& target, const Throwable* const throwable); Function shall be copy-constructible and callable through a const object with the supplied argument types. Internal Implementation::Interruptible and Abandon_Init own the registration interval, sharing one synchronized thread-id registry. |