Control Assertion Checking¶
SAF_ASSERT_DISABLE
is a symbol defined in init.c.
Synopsis:
-
SAF_ASSERT_DISABLE
¶
Description: There are three environment variables that control, independently, the level or pre-, post- and assert- condition checking done by SAF. They are…
1 | SAF_ASSERT_DISABLE
|
1 | SAF_PRECOND_DISABLE
|
1 | SAF_POSTCOND_DISABLE
|
These three environment variables control the level of assertion, pre-condition and post-condition checking,
respectively, that SAF does during execution. Each is a string valued environment variable with possible values
“none”, “high”, “medium”, and “all”. For example, a value of “none” for SAF__ASSERT_DISABLE
means that none
of the assertion checking is disabled. A value of “high” means that all high cost assertions are disabled but
medium and low cost assertions are still enabled. A value “medium” means that all high and medium cost
assertions are disabled but low cost assertions are still enabled. A value of “all” means that all assertions
are disabled. Likewise, SAF__PRECOND_DISABLE
controls pre-condition checking and SAF__POSTCOND_DISABLE
controls post-condition checking.
The cost of an assertion, pre-condition or post-condition is specified in terms relative to the SAF function in which the condition is checked. This means that a simple test for a null pointer in a very simple SAF function, such as saf_setProps_LibComm, is considered high cost while in a saf_declare_field it is considered low cost. This is so because the test for a null pointer in saf_setProps_LibComm relative to the other work saf_setProps_LibComm does is high cost while that same test in saf_declare_field is relatively low cost.
In addition to controlling SAF’s assertion, pre-condition and post-condition checking, these environment
variables also control similar checks that go on in the lower layers of SAF. These lower layers do not
have high, medium and low check costs. Instead, they can either be turned on or off. The checks are performed
if SAF__ASSERT_DISABLE
is “none”, and not performed otherwise.
Assertion, pre-condition and post-condition checking has a marked effect on performance. To obtain maximum performance, all checks should be turned off using
1 2 3 | setenv SAF_ASSERT_DISABLE all
setenv SAF_PRECOND_DISABLE all
setenv SAF_POSTCOND_DISABLE all
|
or
1 2 3 | env SAF_ASSERT_DISABLE=all \
SAF_PRECOND_DISABLE=all \
SAF_POSTCOND_DISABLE=all a.out ...
|
For each of these environment variables, if it does not exist, SAF will set the default values depending on whether the library was compiled for production or development. For a production compile, the default values for all three environment settings are “all” meaning that the error checking for assertion, pre-condition and post-condition checking is set for maximal performance. For a development compile, the default setting for all three is “none” meaning it is set for maximal error checking.
See Also:
- saf_declare_field: 16.12: Declare a field
- saf_setProps_LibComm: 5.7: Set the MPI communicator for the library
- Environment: Introduction for current chapter