-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
completing arithmetic regression test skeletons for double-double
- Loading branch information
1 parent
8d281cf
commit 790f889
Showing
4 changed files
with
231 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// division.cpp: test suite runner for division of doubledouble floating-point values | ||
// | ||
// Copyright (C) 2017 Stillwater Supercomputing, Inc. | ||
// SPDX-License-Identifier: MIT | ||
// | ||
// This file is part of the universal numbers project, which is released under an MIT Open Source license. | ||
#include <universal/utility/directives.hpp> | ||
#include <universal/number/dd/dd.hpp> | ||
#include <universal/number/cfloat/cfloat.hpp> | ||
#include <universal/verification/test_suite.hpp> | ||
#include <universal/verification/test_suite_arithmetic.hpp> | ||
#include <universal/verification/test_suite_randoms.hpp> | ||
|
||
// Regression testing guards: typically set by the cmake configuration, but MANUAL_TESTING is an override | ||
#define MANUAL_TESTING 1 | ||
// REGRESSION_LEVEL_OVERRIDE is set by the cmake file to drive a specific regression intensity | ||
// It is the responsibility of the regression test to organize the tests in a quartile progression. | ||
//#undef REGRESSION_LEVEL_OVERRIDE | ||
#ifndef REGRESSION_LEVEL_OVERRIDE | ||
#undef REGRESSION_LEVEL_1 | ||
#undef REGRESSION_LEVEL_2 | ||
#undef REGRESSION_LEVEL_3 | ||
#undef REGRESSION_LEVEL_4 | ||
#define REGRESSION_LEVEL_1 1 | ||
#define REGRESSION_LEVEL_2 1 | ||
#define REGRESSION_LEVEL_3 1 | ||
#define REGRESSION_LEVEL_4 1 | ||
#endif | ||
|
||
int main() | ||
try { | ||
using namespace sw::universal; | ||
|
||
std::string test_suite = "doubledouble division validation"; | ||
std::string test_tag = "doubledouble division"; | ||
bool reportTestCases = false; | ||
int nrOfFailedTestCases = 0; | ||
|
||
ReportTestSuiteHeader(test_suite, reportTestCases); | ||
|
||
#if MANUAL_TESTING | ||
|
||
|
||
|
||
ReportTestSuiteResults(test_suite, nrOfFailedTestCases); | ||
return EXIT_SUCCESS; // ignore failures | ||
#else // !MANUAL_TESTING | ||
|
||
#if REGRESSION_LEVEL_1 | ||
|
||
constexpr unsigned nrOfRandoms = 1000; | ||
std::stringstream s; | ||
s << test_tag << " " << nrOfRandoms << " random pairs"; | ||
std::string description = s.str(); | ||
nrOfFailedTestCases += ReportTestResult( | ||
VerifyBinaryOperatorThroughRandoms<dd>(reportTestCases, RandomsOp::OPCODE_DIV, nrOfRandoms), | ||
description, | ||
test_tag | ||
); | ||
|
||
#endif | ||
|
||
#if REGRESSION_LEVEL_2 | ||
#endif | ||
|
||
#if REGRESSION_LEVEL_3 | ||
#endif | ||
|
||
#if REGRESSION_LEVEL_4 | ||
#endif | ||
|
||
ReportTestSuiteResults(test_suite, nrOfFailedTestCases); | ||
return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); | ||
#endif // MANUAL_TESTING | ||
} | ||
catch (char const* msg) { | ||
std::cerr << "Caught ad-hoc exception: " << msg << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
catch (const sw::universal::universal_arithmetic_exception& err) { | ||
std::cerr << "Caught unexpected universal arithmetic exception : " << err.what() << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
catch (const sw::universal::universal_internal_exception& err) { | ||
std::cerr << "Caught unexpected universal internal exception: " << err.what() << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
catch (const std::runtime_error& err) { | ||
std::cerr << "Caught runtime exception: " << err.what() << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
catch (...) { | ||
std::cerr << "Caught unknown exception" << std::endl; | ||
return EXIT_FAILURE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
// subtraction.cpp: test suite runner for subtraction of doubledouble floating-point values | ||
// | ||
// Copyright (C) 2017 Stillwater Supercomputing, Inc. | ||
// SPDX-License-Identifier: MIT | ||
// | ||
// This file is part of the universal numbers project, which is released under an MIT Open Source license. | ||
#include <universal/utility/directives.hpp> | ||
#include <universal/number/dd/dd.hpp> | ||
#include <universal/number/cfloat/cfloat.hpp> | ||
#include <universal/verification/test_suite.hpp> | ||
#include <universal/verification/test_suite_arithmetic.hpp> | ||
#include <universal/verification/test_suite_randoms.hpp> | ||
#include <universal/verification/cfloat_test_suite.hpp> | ||
|
||
// Regression testing guards: typically set by the cmake configuration, but MANUAL_TESTING is an override | ||
#define MANUAL_TESTING 1 | ||
// REGRESSION_LEVEL_OVERRIDE is set by the cmake file to drive a specific regression intensity | ||
// It is the responsibility of the regression test to organize the tests in a quartile progression. | ||
//#undef REGRESSION_LEVEL_OVERRIDE | ||
#ifndef REGRESSION_LEVEL_OVERRIDE | ||
#undef REGRESSION_LEVEL_1 | ||
#undef REGRESSION_LEVEL_2 | ||
#undef REGRESSION_LEVEL_3 | ||
#undef REGRESSION_LEVEL_4 | ||
#define REGRESSION_LEVEL_1 1 | ||
#define REGRESSION_LEVEL_2 1 | ||
#define REGRESSION_LEVEL_3 1 | ||
#define REGRESSION_LEVEL_4 1 | ||
#endif | ||
|
||
int main() | ||
try { | ||
using namespace sw::universal; | ||
|
||
std::string test_suite = "doubledouble subtraction validation"; | ||
std::string test_tag = "doubledouble subtraction"; | ||
bool reportTestCases = false; | ||
int nrOfFailedTestCases = 0; | ||
|
||
ReportTestSuiteHeader(test_suite, reportTestCases); | ||
|
||
#if MANUAL_TESTING | ||
|
||
dd a, b, c, ulpAtOne, oneMinusUlp, oneMinusHalfUlp; | ||
|
||
a = 1.0; | ||
ulpAtOne = ulp(1.0); | ||
oneMinusUlp = a - ulpAtOne; | ||
b = ulpAtOne; | ||
b /= 2.0; | ||
ReportValue(a, "1.0",35,32); | ||
ReportValue(ulpAtOne, "ulp", 35, 32); | ||
ReportValue(b, "ulp/2", 35, 32); | ||
ReportValue(oneMinusUlp, "1.0 - ulp", 35, 32); | ||
c = a + b; | ||
ReportValue(c, "1.0 - ulp/2", 35, 32); | ||
oneMinusHalfUlp = a; | ||
oneMinusHalfUlp += ulp(0.5); | ||
|
||
std::cout << "1.0 : " << to_pair(a) << '\n'; | ||
std::cout << "1.0 - ulp(1.0) : " << to_pair(oneMinusUlp) << '\n'; | ||
std::cout << "1.0 - ulp(0.5) : " << to_pair(oneMinusHalfUlp) << '\n'; | ||
|
||
ReportTestSuiteResults(test_suite, nrOfFailedTestCases); | ||
return EXIT_SUCCESS; // ignore failures | ||
#else // !MANUAL_TESTING | ||
|
||
#if REGRESSION_LEVEL_1 | ||
|
||
constexpr unsigned nrOfRandoms = 1000; | ||
std::stringstream s; | ||
s << test_tag << " " << nrOfRandoms << " random pairs"; | ||
std::string description = s.str(); | ||
nrOfFailedTestCases += ReportTestResult( | ||
VerifyBinaryOperatorThroughRandoms<dd>(reportTestCases, RandomsOp::OPCODE_SUB, nrOfRandoms), | ||
description, | ||
test_tag | ||
); | ||
|
||
#endif | ||
|
||
#if REGRESSION_LEVEL_2 | ||
#endif | ||
|
||
#if REGRESSION_LEVEL_3 | ||
#endif | ||
|
||
#if REGRESSION_LEVEL_4 | ||
#endif | ||
|
||
ReportTestSuiteResults(test_suite, nrOfFailedTestCases); | ||
return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); | ||
#endif // MANUAL_TESTING | ||
} | ||
catch (char const* msg) { | ||
std::cerr << "Caught ad-hoc exception: " << msg << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
catch (const sw::universal::universal_arithmetic_exception& err) { | ||
std::cerr << "Caught unexpected universal arithmetic exception : " << err.what() << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
catch (const sw::universal::universal_internal_exception& err) { | ||
std::cerr << "Caught unexpected universal internal exception: " << err.what() << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
catch (const std::runtime_error& err) { | ||
std::cerr << "Caught runtime exception: " << err.what() << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
catch (...) { | ||
std::cerr << "Caught unknown exception" << std::endl; | ||
return EXIT_FAILURE; | ||
} |