|
Cholla 3.0.1-dev
Cholla - Massively parallel hydro on GPUs
|
A namespace for various testing related utility functions. Many of those functions will likely use the STL so this namespace should not be considered compatible with CUDA/HIP. More...
Classes | |
| class | GlobalString |
| Holds a single std::string that's intended to be read only and global. Use for storing the path of the root directory of Cholla. More... | |
Functions | |
| int64_t | ulpsDistanceDbl (double const &a, double const &b) |
| Compute the Units in the Last Place (ULP) difference between two doubles. | |
| bool | nearlyEqualDbl (double const &a, double const &b, double &absoluteDiff, int64_t &ulpsDiff, double const &fixedEpsilon=1E-14, int64_t const &ulpsEpsilon=4) |
| Check if two doubles are nearly equal. | |
| void | wrapperEqual (int i, int j, int k, std::string const &dataSetName, double test_value, double fid_value, double fixedEpsilon=5.0E-12) |
| void | analyticConstant (system_test::SystemTestRunner testObject, std::string const &dataSetName, double value) |
| void | analyticSine (system_test::SystemTestRunner testObject, std::string const &dataSetName, double constant, double amplitude, double kx, double ky, double kz, double phase, double tolerance) |
| template<int checkType = 0> | |
| void | Check_Results (double fiducialNumber, double testNumber, std::string const &outString, double fixedEpsilon=-999, int64_t ulpsEpsilon=-999) |
| A simple function to compare two doubles with the nearlyEqualDbl function, perform a GTest assert on the result, and print out the values. | |
| void | Check_Interface (reconstruction::InterfaceState const &test_data, reconstruction::InterfaceState const &fiducial_data, size_t const direction) |
| Function for checking if every member in a reconstruction::InterfaceState struct matches the fiducial values. | |
A namespace for various testing related utility functions. Many of those functions will likely use the STL so this namespace should not be considered compatible with CUDA/HIP.
|
inline |
Function for checking if every member in a reconstruction::InterfaceState struct matches the fiducial values.
| [in] | test_data | The data to test |
| [in] | fiducial_data | The fiducial data |
| [in] | direction | What direction the test was run in. |
| void testing_utilities::Check_Results | ( | double | fiducialNumber, |
| double | testNumber, | ||
| std::string const & | outString, | ||
| double | fixedEpsilon = -999, |
||
| int64_t | ulpsEpsilon = -999 |
||
| ) |
A simple function to compare two doubles with the nearlyEqualDbl function, perform a GTest assert on the result, and print out the values.
| checkType | The type of GTest assertion to use. "0" for and "EXPECT" and "1" for an "ASSERT" |
| [in] | fiducialNumber | The fiducial number to test against |
| [in] | testNumber | The unverified number to test |
| [in] | outString | A string to be printed in the first line of the output message. Format will be "Difference in outString" |
| [in] | fixedEpsilon | The fixed epsilon to use in the comparison. Negative values are ignored and default behaviour is used |
| [in] | ulpsEpsilon | The ULP epsilon to use in the comparison. Negative values are ignored and default behaviour is used |
| bool testing_utilities::nearlyEqualDbl | ( | double const & | a, |
| double const & | b, | ||
| double & | absoluteDiff, | ||
| int64_t & | ulpsDiff, | ||
| double const & | fixedEpsilon = 1E-14, |
||
| int64_t const & | ulpsEpsilon = 4 |
||
| ) |
Check if two doubles are nearly equal.
This function checks if two doubles are "nearly equal" which is defined as either: A) the absolute difference between them is less than the fixedEpsilon argument or B) the units in the last place (ULP) difference is less than the ulpsEpsilon argument. Both of the epsilon arguments have default values which generally should not need to be changed.
Why does fixedEpsilon default to 1E-14? Running the Sod shock tube when Cholla was compiled with GCC 9.3.0 vs. XL 16.1.1-10 on Summit lead to absolute differences in the results up to 1.77636E-15. A priori we chose that a difference between two numbers that was less than one order of magnitude greater than the difference between compilers would be considered "equal". I.e. since the maximum absolute error between the GCC and XL compilers was ~1.7E-15 our allowed margin of error should be ~1E-14.
Why does ulpsEpsilon default to 4? Repeating the test above I computed the largest ULP difference that wasn't caught by the absolute difference requirement of 1E-14. It turns out that there were no uncaught differences at all so I kept ulpsEpsilon at 4 since that's the Googletest default for their floating point assertions
| [in] | a | The first double you wish to compare. Order doesn't matter. |
| [in] | b | The first double you wish to compare. Order doesn't matter. |
| [out] | absoluteDiff | The absolute difference between the numbers. Only returned if the numbers are not equal. If the numbers are equal then behaviour is undefined |
| [out] | ulpsDiff | The ULP difference between the numbers. Only returned if the numbers are not equal. If the numbers are equal then behaviour is undefined |
| [in] | fixedEpsilon | The allowed difference in real numbers. Defaults to 1E-14 |
| [in] | ulpsEpsilon | The allowed difference of ULPs. Defaults to 4 |
| int64_t testing_utilities::ulpsDistanceDbl | ( | double const & | a, |
| double const & | b | ||
| ) |
Compute the Units in the Last Place (ULP) difference between two doubles.
This function is modified from Comparing Floating-Point Numbers Is Tricky by Matt Kline which is in turn based on Comparing Floating Point Numbers, 2012 Edition by Bruce Dawson. The latter seems to be the bible of floating point comparison and is the basis of Googletests ASSERT_DOUBLE_EQ assertion.
This particular function checks that the two numbers if the numbers are perfectly equal, +0, -0, Nan, inf, or differently signed then it computes the ULP difference between them are returns it
| [in] | a | The first double you wish to compare. Order doesn't matter. |
| [in] | b | The second double you wish to compare. Order doesn't matter. |