From 60fe91ca69edcbbd4386542e80fbf62e623ad09e Mon Sep 17 00:00:00 2001 From: Ravenwater Date: Sun, 18 Feb 2024 09:10:34 -0500 Subject: [PATCH] unifying the type interface to posit regression tests across exhaustive and random --- .../verification/posit_test_suite_randoms.hpp | 4 +- static/posit/arithmetic/addition.cpp | 34 +++--- static/posit/arithmetic/complex_add.cpp | 64 +++------- static/posit/arithmetic/division.cpp | 30 ++--- static/posit/arithmetic/multiplication.cpp | 24 ++-- static/posit/arithmetic/randoms.cpp | 22 ++-- static/posit/arithmetic/subtraction.cpp | 26 ++-- static/posit/specialized/posit_128_2.cpp | 28 ++--- static/posit/specialized/posit_128_4.cpp | 28 ++--- static/posit/specialized/posit_16_1.cpp | 94 +++++++-------- static/posit/specialized/posit_16_2.cpp | 112 +++++++++--------- static/posit/specialized/posit_256_2.cpp | 12 +- static/posit/specialized/posit_256_5.cpp | 36 +++--- static/posit/specialized/posit_32_2.cpp | 94 +++++++-------- static/posit/specialized/posit_48_2.cpp | 28 ++--- static/posit/specialized/posit_64_2.cpp | 96 +++++++-------- static/posit/specialized/posit_64_3.cpp | 94 +++++++-------- static/posit/specialized/quire_32_2.cpp | 7 +- static/posit2/arithmetic/addition.cpp | 22 ++-- static/posito/arithmetic/addition.cpp | 24 ++-- static/posito/arithmetic/division.cpp | 28 ++--- static/posito/arithmetic/multiplication.cpp | 20 ++-- static/posito/arithmetic/subtraction.cpp | 24 ++-- 23 files changed, 462 insertions(+), 489 deletions(-) diff --git a/include/universal/verification/posit_test_suite_randoms.hpp b/include/universal/verification/posit_test_suite_randoms.hpp index ea91d7cec..097566ff3 100644 --- a/include/universal/verification/posit_test_suite_randoms.hpp +++ b/include/universal/verification/posit_test_suite_randoms.hpp @@ -202,7 +202,7 @@ namespace sw { namespace universal { // generate a random set of operands to test the binary operators for a posit configuration // Basic design is that we generate nrOfRandom posit values and store them in an operand array. // We will then execute the binary operator nrOfRandom combinations. - template + template int VerifyBinaryOperatorThroughRandoms(bool reportTestCases, int opcode, uint32_t nrOfRandoms) { std::string operation_string; switch (opcode) { @@ -247,7 +247,7 @@ namespace sw { namespace universal { bool firstDivideByZeroCall = true; int nrOfFailedTests = 0; for (unsigned i = 1; i < nrOfRandoms; i++) { - posit testa, testb, testc, testref; + TestType testa, testb, testc, testref; testa.setbits(distr(eng)); testb.setbits(distr(eng)); double da = double(testa); diff --git a/static/posit/arithmetic/addition.cpp b/static/posit/arithmetic/addition.cpp index 1d70876e7..5a7074bd4 100644 --- a/static/posit/arithmetic/addition.cpp +++ b/static/posit/arithmetic/addition.cpp @@ -11,8 +11,8 @@ #define POSIT_THROW_ARITHMETIC_EXCEPTION 0 // third: enable tracing // when you define ALGORITHM_VERBOSE_OUTPUT executing an ADD the code will print intermediate results -#define ALGORITHM_VERBOSE_OUTPUT -#define ALGORITHM_TRACE_ADD +//#define ALGORITHM_VERBOSE_OUTPUT +//#define ALGORITHM_TRACE_ADD #include #include #include @@ -75,7 +75,7 @@ try { nrOfFailedTestCases += ReportTestResult(VerifyAddition>(reportTestCases), "posit<3,2>", "addition"); nrOfFailedTestCases += ReportTestResult(VerifyAddition>(reportTestCases), "posit<3,3>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 2>(reportTestCases, OPCODE_ADD, 1000), "posit<64,2>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<64,2>", "addition"); ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return EXIT_SUCCESS; @@ -119,32 +119,32 @@ try { #endif #if REGRESSION_LEVEL_2 - nrOfFailedTestCases += ReportTestResult(VerifyAddition>(reportTestCases), "posit<10,0>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition>(reportTestCases), "posit<10,1>", "addition"); +// nrOfFailedTestCases += ReportTestResult(VerifyAddition>(reportTestCases), "posit<10,0>", "addition"); +// nrOfFailedTestCases += ReportTestResult(VerifyAddition>(reportTestCases), "posit<10,1>", "addition"); nrOfFailedTestCases += ReportTestResult(VerifyAddition>(reportTestCases), "posit<10,2>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition>(reportTestCases), "posit<10,3>", "addition"); +// nrOfFailedTestCases += ReportTestResult(VerifyAddition>(reportTestCases), "posit<10,3>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<16, 2>(reportTestCases, OPCODE_ADD, 1000), "posit<16,1>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<24, 2>(reportTestCases, OPCODE_ADD, 1000), "posit<24,1>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<16,1>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms> (reportTestCases, OPCODE_ADD, 1000), "posit<24,1>", "addition"); #endif #if REGRESSION_LEVEL_3 - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<20, 1>(reportTestCases, OPCODE_ADD, 1000), "posit<20,1>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<28, 1>(reportTestCases, OPCODE_ADD, 1000), "posit<28,1>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms> (reportTestCases, OPCODE_ADD, 1000), "posit<20,1>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms> (reportTestCases, OPCODE_ADD, 1000), "posit<28,1>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 1>(reportTestCases, OPCODE_ADD, 1000), "posit<32,1>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 2>(reportTestCases, OPCODE_ADD, 1000), "posit<32,2>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 3>(reportTestCases, OPCODE_ADD, 1000), "posit<32,3>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms> (reportTestCases, OPCODE_ADD, 1000), "posit<32,1>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms> (reportTestCases, OPCODE_ADD, 1000), "posit<32,2>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms> (reportTestCases, OPCODE_ADD, 1000), "posit<32,3>", "addition"); #endif #if REGRESSION_LEVEL_4 // nbits=48 also shows failures - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<48, 2>(reportTestCases, OPCODE_ADD, 1000), "posit<48,2>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms> (reportTestCases, OPCODE_ADD, 1000), "posit<48,2>", "addition"); // nbits=64 requires long double compiler support - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 2>(reportTestCases, OPCODE_ADD, 1000), "posit<64,2>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 3>(reportTestCases, OPCODE_ADD, 1000), "posit<64,3>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 4>(reportTestCases, OPCODE_ADD, 1000), "posit<64,4>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<64,2>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<64,3>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms> (reportTestCases, OPCODE_ADD, 1000), "posit<64,4>", "addition"); #ifdef HARDWARE_ACCELERATION nrOfFailedTestCases += ReportTestResult(VerifyAddition>(reportTestCases), "posit<12,1>", "addition"); diff --git a/static/posit/arithmetic/complex_add.cpp b/static/posit/arithmetic/complex_add.cpp index 53adcea89..627e4d5b6 100644 --- a/static/posit/arithmetic/complex_add.cpp +++ b/static/posit/arithmetic/complex_add.cpp @@ -153,9 +153,6 @@ try { nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "complex>", "addition"); nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "complex>", "addition"); -// nrOfFailedTestCases += ReportTestResult(ValidateThroughRandoms<16, 1>>(reportTestCases, OPCODE_ADD, 1000), "posit<16,1>", "addition"); -// nrOfFailedTestCases += ReportTestResult(ValidateThroughRandoms<64, 2>>(reportTestCases, OPCODE_ADD, 1000), "posit<64,2>", "addition"); - ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return EXIT_SUCCESS; #else @@ -172,59 +169,36 @@ try { #endif #if REGRESSION_LEVEL_2 -#endif - -#if REGRESSION_LEVEL_3 - /* TODO - nrOfFailedTestCases += ReportTestResult(ValidateThroughRandoms<16, 1>>(reportTestCases, OPCODE_ADD, 1000), "posit<16,1>", "addition"); - nrOfFailedTestCases += ReportTestResult(ValidateThroughRandoms<24, 1>>(reportTestCases, OPCODE_ADD, 1000), "posit<24,1>", "addition"); - nrOfFailedTestCases += ReportTestResult(ValidateThroughRandoms<32, 1>>(reportTestCases, OPCODE_ADD, 1000), "posit<32,1>", "addition"); - nrOfFailedTestCases += ReportTestResult(ValidateThroughRandoms<32, 2>>(reportTestCases, OPCODE_ADD, 1000), "posit<32,2>", "addition"); - */ - -#endif - -#if REGRESSION_LEVEL_4 - nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<5,0>", "addition"); nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<5,1>", "addition"); nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<5,2>", "addition"); nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<5,3>", "addition"); +#endif - nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<6,0>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<6,1>", "addition"); +#if REGRESSION_LEVEL_3 + // nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<6,0>", "addition"); +// nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<6,1>", "addition"); nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<6,2>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<6,3>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<6,4>", "addition"); + // nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<6,3>", "addition"); + // nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<6,4>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<7,0>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<7,1>", "addition"); + // nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<7,0>", "addition"); + // nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<7,1>", "addition"); nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<7,2>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<7,3>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<7,4>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<7,5>", "addition"); + // nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<7,3>", "addition"); + // nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<7,4>", "addition"); + // nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<7,5>", "addition"); +#endif - nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<8,0>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<8,1>", "addition"); +#if REGRESSION_LEVEL_4 +// nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<8,0>", "addition"); +// nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<8,1>", "addition"); nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<8,2>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<8,3>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<8,4>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<8,5>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<8,6>", "addition"); - - // nbits=48 also shows failures - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<48, 2>(reportTestCases, OPCODE_ADD, 1000), "posit<48,2>", "addition"); - - // nbits=64 requires long double compiler support - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 2>(reportTestCases, OPCODE_ADD, 1000), "posit<64,2>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 3>(reportTestCases, OPCODE_ADD, 1000), "posit<64,3>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 4>(reportTestCases, OPCODE_ADD, 1000), "posit<64,4>", "addition"); - +// nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<8,3>", "addition"); +// nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<8,4>", "addition"); +// nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<8,5>", "addition"); +// nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<8,6>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<10,1>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<12,1>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<14,1>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyComplexAddition>(reportTestCases), "posit<16,1>", "addition"); #endif // REGRESSION_LEVEL_4 ReportTestSuiteResults(test_suite, nrOfFailedTestCases); diff --git a/static/posit/arithmetic/division.cpp b/static/posit/arithmetic/division.cpp index 5e84224f3..7e7f349d3 100644 --- a/static/posit/arithmetic/division.cpp +++ b/static/posit/arithmetic/division.cpp @@ -12,7 +12,7 @@ // third: enable tracing // when you define ALGORITHM_VERBOSE_OUTPUT executing an ADD the code will print intermediate results //#define ALGORITHM_VERBOSE_OUTPUT -#define ALGORITHM_TRACE_DIV +//#define ALGORITHM_TRACE_DIV #include #include #include @@ -254,33 +254,33 @@ try { #endif #if REGRESSION_LEVEL_2 - nrOfFailedTestCases += ReportTestResult(VerifyDivision>(reportTestCases), "posit<10,0>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision>(reportTestCases), "posit<10,1>", "division"); +// nrOfFailedTestCases += ReportTestResult(VerifyDivision>(reportTestCases), "posit<10,0>", "division"); +// nrOfFailedTestCases += ReportTestResult(VerifyDivision>(reportTestCases), "posit<10,1>", "division"); nrOfFailedTestCases += ReportTestResult(VerifyDivision>(reportTestCases), "posit<10,2>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision>(reportTestCases), "posit<10,3>", "division"); +// nrOfFailedTestCases += ReportTestResult(VerifyDivision>(reportTestCases), "posit<10,3>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<16, 2>(reportTestCases, OPCODE_DIV, 1000), "posit<16,2>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<24, 2>(reportTestCases, OPCODE_DIV, 1000), "posit<24,2>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<16,2>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<24,2>", "division"); #endif #if REGRESSION_LEVEL_3 - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<20, 1>(reportTestCases, OPCODE_DIV, 1000), "posit<20,1>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<28, 1>(reportTestCases, OPCODE_DIV, 1000), "posit<28,1>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<20,1>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<28,1>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 1>(reportTestCases, OPCODE_DIV, 1000), "posit<32,1>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 2>(reportTestCases, OPCODE_DIV, 1000), "posit<32,2>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 3>(reportTestCases, OPCODE_DIV, 1000), "posit<32,3>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<32,1>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<32,2>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<32,3>", "division"); #endif #if REGRESSION_LEVEL_4 // nbits = 48 also shows failures - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<48, 2>(reportTestCases, OPCODE_DIV, 1000), "posit<48,2>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<48,2>", "division"); // nbits=64 requires long double compiler support - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 2>(reportTestCases, OPCODE_DIV, 1000), "posit<64,2>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 3>(reportTestCases, OPCODE_DIV, 1000), "posit<64,3>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<64,2>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<64,3>", "division"); // posit<64,4> is hitting subnormal numbers - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 4>(reportTestCases, OPCODE_DIV, 1000), "posit<64,4>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<64,4>", "division"); #ifdef HARDWARE_ACCELERATION nrOfFailedTestCases += ReportTestResult(VerifyDivision>(reportTestCases), "posit<12,1>", "division"); diff --git a/static/posit/arithmetic/multiplication.cpp b/static/posit/arithmetic/multiplication.cpp index 837dd7931..a5dd4a604 100644 --- a/static/posit/arithmetic/multiplication.cpp +++ b/static/posit/arithmetic/multiplication.cpp @@ -200,30 +200,30 @@ try { #endif #if REGRESSION_LEVEL_2 - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication>(reportTestCases), "posit<10,0>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication>(reportTestCases), "posit<10,1>", "multiplication"); +// nrOfFailedTestCases += ReportTestResult(VerifyMultiplication>(reportTestCases), "posit<10,0>", "multiplication"); +// nrOfFailedTestCases += ReportTestResult(VerifyMultiplication>(reportTestCases), "posit<10,1>", "multiplication"); nrOfFailedTestCases += ReportTestResult(VerifyMultiplication>(reportTestCases), "posit<10,2>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication>(reportTestCases), "posit<10,3>", "multiplication"); +// nrOfFailedTestCases += ReportTestResult(VerifyMultiplication>(reportTestCases), "posit<10,3>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<16, 2>(reportTestCases, OPCODE_MUL, 1000), "posit<16,2>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<24, 2>(reportTestCases, OPCODE_MUL, 1000), "posit<24,2>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_MUL, 1000), "posit<16,2>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_MUL, 1000), "posit<24,2>", "multiplication"); #endif #if REGRESSION_LEVEL_3 - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 1>(reportTestCases, OPCODE_MUL, 1000), "posit<32,1>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 2>(reportTestCases, OPCODE_MUL, 1000), "posit<32,2>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 3>(reportTestCases, OPCODE_MUL, 1000), "posit<32,3>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_MUL, 1000), "posit<32,1>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_MUL, 1000), "posit<32,2>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_MUL, 1000), "posit<32,3>", "multiplication"); #endif #if REGRESSION_LEVEL_4 // nbits=48 is also showing failures - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<48, 2>(reportTestCases, OPCODE_MUL, 1000), "posit<48,2>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_MUL, 1000), "posit<48,2>", "multiplication"); // nbits=64 requires long double compiler support - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 2>(reportTestCases, OPCODE_MUL, 1000), "posit<64,2>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 3>(reportTestCases, OPCODE_MUL, 1000), "posit<64,3>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_MUL, 1000), "posit<64,2>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_MUL, 1000), "posit<64,3>", "multiplication"); // posit<64,4> is hitting subnormal numbers - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 4>(reportTestCases, OPCODE_MUL, 1000), "posit<64,4>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_MUL, 1000), "posit<64,4>", "multiplication"); #ifdef HARDWARE_ACCELERATION nrOfFailedTestCases += ReportTestResult(VerifyMultiplication>(reportTestCases), "posit<12,1>", "multiplication"); diff --git a/static/posit/arithmetic/randoms.cpp b/static/posit/arithmetic/randoms.cpp index 2ccbf3fb8..f0df68d52 100644 --- a/static/posit/arithmetic/randoms.cpp +++ b/static/posit/arithmetic/randoms.cpp @@ -54,30 +54,24 @@ try { #else #if REGRESSION_LEVEL_1 - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<16, 2>(reportTestCases, OPCODE_ADD, 1000), "posit<16,2>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<16, 2>(reportTestCases, OPCODE_SUB, 1000), "posit<16,2>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<16, 2>(reportTestCases, OPCODE_MUL, 1000), "posit<16,2>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<16, 2>(reportTestCases, OPCODE_DIV, 1000), "posit<16,2>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<16,2>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, 1000), "posit<16,2>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_MUL, 1000), "posit<16,2>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<16,2>", "division"); #endif #if REGRESSION_LEVEL_2 #endif #if REGRESSION_LEVEL_3 - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 2>(reportTestCases, OPCODE_ADD, 1000), "posit<64,2>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 2>(reportTestCases, OPCODE_SUB, 1000), "posit<64,2>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 2>(reportTestCases, OPCODE_MUL, 1000), "posit<64,2>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 2>(reportTestCases, OPCODE_DIV, 1000), "posit<64,2>", "division"); - + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<64,2>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, 1000), "posit<64,2>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_MUL, 1000), "posit<64,2>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<64,2>", "division"); #endif #if REGRESSION_LEVEL_4 -#ifdef HARDWARE_ACCELERATION - nrOfFailedTestCases += ReportTestResult(VerifyAddition>(reportTestCases), "posit<12,1>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition>(reportTestCases), "posit<14,1>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition>(reportTestCases), "posit<16,1>", "addition"); -#endif // HARDWARE_ACCELERATION #endif // REGRESSION_LEVEL_4 diff --git a/static/posit/arithmetic/subtraction.cpp b/static/posit/arithmetic/subtraction.cpp index c0fe42377..105c48706 100644 --- a/static/posit/arithmetic/subtraction.cpp +++ b/static/posit/arithmetic/subtraction.cpp @@ -12,7 +12,7 @@ // third: enable tracing // when you define ALGORITHM_VERBOSE_OUTPUT executing an SUB the code will print intermediate results //#define ALGORITHM_VERBOSE_OUTPUT -#define ALGORITHM_TRACE_SUB +//#define ALGORITHM_TRACE_SUB #include #include #include @@ -132,29 +132,29 @@ try { #endif #if REGRESSION_LEVEL_2 - nrOfFailedTestCases += ReportTestResult(VerifySubtraction>(reportTestCases), "posit<10,0>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction>(reportTestCases), "posit<10,1>", "subtraction"); +// nrOfFailedTestCases += ReportTestResult(VerifySubtraction>(reportTestCases), "posit<10,0>", "subtraction"); +// nrOfFailedTestCases += ReportTestResult(VerifySubtraction>(reportTestCases), "posit<10,1>", "subtraction"); nrOfFailedTestCases += ReportTestResult(VerifySubtraction>(reportTestCases), "posit<10,2>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction>(reportTestCases), "posit<10,3>", "subtraction"); +// nrOfFailedTestCases += ReportTestResult(VerifySubtraction>(reportTestCases), "posit<10,3>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<16, 2>(reportTestCases, OPCODE_SUB, 1000), "posit<16,1>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<24, 2>(reportTestCases, OPCODE_SUB, 1000), "posit<24,1>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, 1000), "posit<16,1>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, 1000), "posit<24,1>", "subtraction"); #endif #if REGRESSION_LEVEL_3 - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 1>(reportTestCases, OPCODE_SUB, 1000), "posit<32,1>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 2>(reportTestCases, OPCODE_SUB, 1000), "posit<32,2>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 3>(reportTestCases, OPCODE_SUB, 1000), "posit<32,3>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, 1000), "posit<32,1>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, 1000), "posit<32,2>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, 1000), "posit<32,3>", "subtraction"); #endif #if REGRESSION_LEVEL_4 // nbits=48 is showing failures - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<48, 2>(reportTestCases, OPCODE_SUB, 1000), "posit<48,2>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, 1000), "posit<48,2>", "subtraction"); // nbits=64 requires long double compiler support - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 2>(reportTestCases, OPCODE_SUB, 1000), "posit<64,2>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 3>(reportTestCases, OPCODE_SUB, 1000), "posit<64,3>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 4>(reportTestCases, OPCODE_SUB, 1000), "posit<64,4>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, 1000), "posit<64,2>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, 1000), "posit<64,3>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, 1000), "posit<64,4>", "subtraction"); #ifdef HARDWARE_ACCELERATION nrOfFailedTestCases += ReportTestResult(VerifySubtraction>(reportTestCases), "posit<12,1>", "subtraction"); diff --git a/static/posit/specialized/posit_128_2.cpp b/static/posit/specialized/posit_128_2.cpp index 81bcbb50d..37eb74eb2 100644 --- a/static/posit/specialized/posit_128_2.cpp +++ b/static/posit/specialized/posit_128_2.cpp @@ -55,8 +55,8 @@ try { unsigned RND_TEST_CASES = 1024; - using Scalar = posit; - Scalar p; + using TestType = posit; + TestType p; std::cout << dynamic_range(p) << "\n\n"; std::string tag = type_tag(p); @@ -85,10 +85,10 @@ try { nrOfFailedTestCases += ReportCheck(tag, test, p.ispos()); RND_TEST_CASES = 1024; - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return EXIT_SUCCESS; // ignore failures @@ -118,10 +118,10 @@ try { nrOfFailedTestCases += ReportCheck(tag, test, p.ispos()); RND_TEST_CASES = 1024; - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); #endif @@ -141,10 +141,10 @@ try { RND_TEST_CASES = 1024 * 1024; std::cout << "Arithmetic tests " << RND_TEST_CASES << " randoms each\n"; std::cout << "Without an arithmetic reference, test failures can be ignored\n"; - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); nrOfFailedTestCases = 0; #endif diff --git a/static/posit/specialized/posit_128_4.cpp b/static/posit/specialized/posit_128_4.cpp index 7a38ee923..023255fc6 100644 --- a/static/posit/specialized/posit_128_4.cpp +++ b/static/posit/specialized/posit_128_4.cpp @@ -55,8 +55,8 @@ try { unsigned RND_TEST_CASES = 1024; - using Scalar = posit; - Scalar p; + using TestType = posit; + TestType p; std::cout << dynamic_range(p) << "\n\n"; std::string tag = type_tag(p); @@ -85,10 +85,10 @@ try { nrOfFailedTestCases += ReportCheck(tag, test, p.ispos()); RND_TEST_CASES = 1024; - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return EXIT_SUCCESS; // ignore failures @@ -118,10 +118,10 @@ try { nrOfFailedTestCases += ReportCheck(tag, test, p.ispos()); RND_TEST_CASES = 1024; - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); #endif @@ -141,10 +141,10 @@ try { RND_TEST_CASES = 1024 * 1024; std::cout << "Arithmetic tests " << RND_TEST_CASES << " randoms each\n"; std::cout << "Without an arithmetic reference, test failures can be ignored\n"; - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); nrOfFailedTestCases = 0; #endif diff --git a/static/posit/specialized/posit_16_1.cpp b/static/posit/specialized/posit_16_1.cpp index d0906f2e2..ae6a05251 100644 --- a/static/posit/specialized/posit_16_1.cpp +++ b/static/posit/specialized/posit_16_1.cpp @@ -56,15 +56,15 @@ try { unsigned RND_TEST_CASES = 1024 * 1024; - using Scalar = posit; - Scalar p; + using TestType = posit; + TestType p; std::cout << dynamic_range(p) << "\n\n"; std::string tag = type_tag(p); #if MANUAL_TESTING // float fa, fb; - posit a, b, c; + posit a, b, c; a.setnar(); b.setnar(); testLogicOperators(a, b); @@ -88,10 +88,10 @@ try { testLogicOperators(a, b); testLogicOperators(b, a); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPA, 100), tag, "+= (native) "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPS, 100), tag, "-= (native) "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPM, 100), tag, "*= (native) "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPD, 100), tag, "/= (native) "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPA, 100), tag, "+= (native) "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPS, 100), tag, "-= (native) "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPM, 100), tag, "*= (native) "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPD, 100), tag, "/= (native) "); ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return EXIT_SUCCESS; // ignore failures @@ -121,70 +121,70 @@ try { nrOfFailedTestCases += ReportCheck(tag, test, p.ispos()); RND_TEST_CASES = 1024; - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); #endif #if REGRESSION_LEVEL_2 // logic tests std::cout << "Logic operator tests\n"; - nrOfFailedTestCases += ReportTestResult( VerifyLogicEqual >(reportTestCases), tag, " == (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyLogicNotEqual >(reportTestCases), tag, " != (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyLogicLessThan >(reportTestCases), tag, " < (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyLogicLessOrEqualThan >(reportTestCases), tag, " <= (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyLogicGreaterThan >(reportTestCases), tag, " > (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyLogicGreaterOrEqualThan>(reportTestCases), tag, " >= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyLogicEqual (reportTestCases), tag, " == (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyLogicNotEqual (reportTestCases), tag, " != (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyLogicLessThan (reportTestCases), tag, " < (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyLogicLessOrEqualThan (reportTestCases), tag, " <= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyLogicGreaterThan (reportTestCases), tag, " > (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyLogicGreaterOrEqualThan(reportTestCases), tag, " >= (native) "); #endif #if REGRESSION_LEVEL_3 // conversion tests std::cout << "Assignment/conversion tests\n"; - nrOfFailedTestCases += ReportTestResult( VerifyIntegerConversion >(reportTestCases), tag, "integer assign (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyIntegerConversion (reportTestCases), tag, "integer assign (native) "); // FAIL = 0.25003 did not convert to 0.250061 instead it yielded 0.25 raw 0b0.01.0.000000000000 // FAIL = 0.99994 did not convert to 0.999878 instead it yielded 1 raw 0b0.10.0.000000000000 // posit<16, 1> float assign(native) FAIL 2 failed test cases - // nrOfFailedTestCases += ReportTestResult( VerifyConversion (true), tag, "float assign (native) "); + // nrOfFailedTestCases += ReportTestResult( VerifyConversion (true), tag, "float assign (native) "); RND_TEST_CASES = 4 * 1024 * 1024; // arithmetic tests // State space is too large for exhaustive testing, so we use randoms to try to catch any silly regressions std::cout << "Arithmetic tests " << RND_TEST_CASES << " randoms each\n"; - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPA, RND_TEST_CASES), tag, "+= (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPS, RND_TEST_CASES), tag, "-= (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPM, RND_TEST_CASES), tag, "*= (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPD, RND_TEST_CASES), tag, "/= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPA, RND_TEST_CASES), tag, "+= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPS, RND_TEST_CASES), tag, "-= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPM, RND_TEST_CASES), tag, "*= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPD, RND_TEST_CASES), tag, "/= (native) "); #endif #if REGRESSION_LEVEL_4 // elementary function tests std::cout << "Elementary function tests\n"; - nrOfFailedTestCases += ReportTestResult( VerifySqrt >(reportTestCases), tag, "sqrt (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyExp >(reportTestCases), tag, "exp "); - nrOfFailedTestCases += ReportTestResult( VerifyExp2 >(reportTestCases), tag, "exp2 "); - nrOfFailedTestCases += ReportTestResult( VerifyLog >(reportTestCases), tag, "log "); - nrOfFailedTestCases += ReportTestResult( VerifyLog2 >(reportTestCases), tag, "log2 "); - nrOfFailedTestCases += ReportTestResult( VerifyLog10 >(reportTestCases), tag, "log10 "); - nrOfFailedTestCases += ReportTestResult( VerifySine >(reportTestCases), tag, "sin "); - nrOfFailedTestCases += ReportTestResult( VerifyCosine >(reportTestCases), tag, "cos "); - nrOfFailedTestCases += ReportTestResult( VerifyTangent >(reportTestCases), tag, "tan "); - nrOfFailedTestCases += ReportTestResult( VerifyAsin >(reportTestCases), tag, "asin "); - nrOfFailedTestCases += ReportTestResult( VerifyAcos >(reportTestCases), tag, "acos "); - nrOfFailedTestCases += ReportTestResult( VerifyAtan >(reportTestCases), tag, "atan "); - nrOfFailedTestCases += ReportTestResult( VerifySinh >(reportTestCases), tag, "sinh "); - nrOfFailedTestCases += ReportTestResult( VerifyCosh >(reportTestCases), tag, "cosh "); - nrOfFailedTestCases += ReportTestResult( VerifyTanh >(reportTestCases), tag, "tanh "); - nrOfFailedTestCases += ReportTestResult( VerifyAsinh >(reportTestCases), tag, "asinh "); - nrOfFailedTestCases += ReportTestResult( VerifyAcosh >(reportTestCases), tag, "acosh "); - nrOfFailedTestCases += ReportTestResult( VerifyAtanh >(reportTestCases), tag, "atanh "); - - nrOfFailedTestCases += ReportTestResult( VerifyPowerFunction >(reportTestCases), tag, "pow "); + nrOfFailedTestCases += ReportTestResult( VerifySqrt (reportTestCases), tag, "sqrt (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyExp (reportTestCases), tag, "exp "); + nrOfFailedTestCases += ReportTestResult( VerifyExp2 (reportTestCases), tag, "exp2 "); + nrOfFailedTestCases += ReportTestResult( VerifyLog (reportTestCases), tag, "log "); + nrOfFailedTestCases += ReportTestResult( VerifyLog2 (reportTestCases), tag, "log2 "); + nrOfFailedTestCases += ReportTestResult( VerifyLog10 (reportTestCases), tag, "log10 "); + nrOfFailedTestCases += ReportTestResult( VerifySine (reportTestCases), tag, "sin "); + nrOfFailedTestCases += ReportTestResult( VerifyCosine (reportTestCases), tag, "cos "); + nrOfFailedTestCases += ReportTestResult( VerifyTangent (reportTestCases), tag, "tan "); + nrOfFailedTestCases += ReportTestResult( VerifyAsin (reportTestCases), tag, "asin "); + nrOfFailedTestCases += ReportTestResult( VerifyAcos (reportTestCases), tag, "acos "); + nrOfFailedTestCases += ReportTestResult( VerifyAtan (reportTestCases), tag, "atan "); + nrOfFailedTestCases += ReportTestResult( VerifySinh (reportTestCases), tag, "sinh "); + nrOfFailedTestCases += ReportTestResult( VerifyCosh (reportTestCases), tag, "cosh "); + nrOfFailedTestCases += ReportTestResult( VerifyTanh (reportTestCases), tag, "tanh "); + nrOfFailedTestCases += ReportTestResult( VerifyAsinh (reportTestCases), tag, "asinh "); + nrOfFailedTestCases += ReportTestResult( VerifyAcosh (reportTestCases), tag, "acosh "); + nrOfFailedTestCases += ReportTestResult( VerifyAtanh (reportTestCases), tag, "atanh "); + + nrOfFailedTestCases += ReportTestResult( VerifyPowerFunction (reportTestCases), tag, "pow "); #endif ReportTestSuiteResults(test_suite, nrOfFailedTestCases); diff --git a/static/posit/specialized/posit_16_2.cpp b/static/posit/specialized/posit_16_2.cpp index a97c7f102..208b5c6e8 100644 --- a/static/posit/specialized/posit_16_2.cpp +++ b/static/posit/specialized/posit_16_2.cpp @@ -56,8 +56,8 @@ try { unsigned RND_TEST_CASES = 10000; - using Scalar = posit; - Scalar p; + using TestType = posit; + TestType p; std::cout << dynamic_range(p) << "\n\n"; std::string tag = type_tag(p); @@ -102,18 +102,18 @@ try { testLogicOperators(b, a); } - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPA, 100), tag, "+= (native) "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPS, 100), tag, "-= (native) "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPM, 100), tag, "*= (native) "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPD, 100), tag, "/= (native) "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPA, 100), tag, "+= (native) "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPS, 100), tag, "-= (native) "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPM, 100), tag, "*= (native) "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPD, 100), tag, "/= (native) "); goto epilog; // skip the exhaustive tests std::cout << "Exhaustive tests" << std::endl; - nrOfFailedTestCases += ReportTestResult(VerifyDivision >(reportTestCases), tag, "div (native) "); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication>(reportTestCases), tag, "mul (native) "); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction >(reportTestCases), tag, "sub (native) "); - nrOfFailedTestCases += ReportTestResult(VerifyAddition >(reportTestCases), tag, "add (native) "); + nrOfFailedTestCases += ReportTestResult(VerifyDivision (reportTestCases), tag, "div (native) "); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication(reportTestCases), tag, "mul (native) "); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction (reportTestCases), tag, "sub (native) "); + nrOfFailedTestCases += ReportTestResult(VerifyAddition (reportTestCases), tag, "add (native) "); epilog: ReportTestSuiteResults(test_suite, nrOfFailedTestCases); @@ -143,82 +143,82 @@ try { test = "is positive"; nrOfFailedTestCases += ReportCheck(tag, test, p.ispos()); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); #endif #if REGRESSION_LEVEL_2 // logic tests std::cout << "Logic operator tests\n"; - nrOfFailedTestCases += ReportTestResult( VerifyLogicEqual >(reportTestCases), tag, " == (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyLogicNotEqual >(reportTestCases), tag, " != (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyLogicLessThan >(reportTestCases), tag, " < (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyLogicLessOrEqualThan >(reportTestCases), tag, " <= (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyLogicGreaterThan >(reportTestCases), tag, " > (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyLogicGreaterOrEqualThan>(reportTestCases), tag, " >= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyLogicEqual (reportTestCases), tag, " == (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyLogicNotEqual (reportTestCases), tag, " != (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyLogicLessThan (reportTestCases), tag, " < (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyLogicLessOrEqualThan (reportTestCases), tag, " <= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyLogicGreaterThan (reportTestCases), tag, " > (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyLogicGreaterOrEqualThan(reportTestCases), tag, " >= (native) "); #endif #if REGRESSION_LEVEL_3 // conversion tests std::cout << "Assignment/conversion tests\n"; - nrOfFailedTestCases += ReportTestResult( VerifyIntegerConversion >(reportTestCases), tag, "integer assign (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyIntegerConversion (reportTestCases), tag, "integer assign (native) "); // FAIL = 0.06251519627 did not convert to 0.06253051758 instead it yielded 0.0625 raw 0b0.01.00.00000000000 // FAIL = 0.9998789296 did not convert to 0.9997558594 instead it yielded 1 raw 0b0.10.00.00000000000 // posit< 16, 2> float assign(native) FAIL 2 failed test cases - // nrOfFailedTestCases += ReportTestResult( VerifyConversion (true), tag, "float assign (native) "); + // nrOfFailedTestCases += ReportTestResult( VerifyConversion (true), tag, "float assign (native) "); RND_TEST_CASES = 1024 * 1024; // arithmetic tests // State space is too large for exhaustive testing, so we use randoms to try to catch any silly regressions std::cout << "Arithmetic tests " << RND_TEST_CASES << " randoms each\n"; - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPA, RND_TEST_CASES), tag, "+= (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPS, RND_TEST_CASES), tag, "-= (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPM, RND_TEST_CASES), tag, "*= (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPD, RND_TEST_CASES), tag, "/= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPA, RND_TEST_CASES), tag, "+= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPS, RND_TEST_CASES), tag, "-= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPM, RND_TEST_CASES), tag, "*= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPD, RND_TEST_CASES), tag, "/= (native) "); #endif #if REGRESSION_LEVEL_4 // elementary function tests std::cout << "Elementary function tests\n"; - nrOfFailedTestCases += ReportTestResult( VerifySqrt >(reportTestCases), tag, "sqrt (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyExp >(reportTestCases), tag, "exp "); - nrOfFailedTestCases += ReportTestResult( VerifyExp2 >(reportTestCases), tag, "exp2 "); - nrOfFailedTestCases += ReportTestResult( VerifyLog >(reportTestCases), tag, "log "); - nrOfFailedTestCases += ReportTestResult( VerifyLog2 >(reportTestCases), tag, "log2 "); - nrOfFailedTestCases += ReportTestResult( VerifyLog10 >(reportTestCases), tag, "log10 "); - nrOfFailedTestCases += ReportTestResult( VerifySine >(reportTestCases), tag, "sin "); - nrOfFailedTestCases += ReportTestResult( VerifyCosine >(reportTestCases), tag, "cos "); - nrOfFailedTestCases += ReportTestResult( VerifyTangent >(reportTestCases), tag, "tan "); - nrOfFailedTestCases += ReportTestResult( VerifyAsin >(reportTestCases), tag, "asin "); - nrOfFailedTestCases += ReportTestResult( VerifyAcos >(reportTestCases), tag, "acos "); - nrOfFailedTestCases += ReportTestResult( VerifyAtan >(reportTestCases), tag, "atan "); - nrOfFailedTestCases += ReportTestResult( VerifySinh >(reportTestCases), tag, "sinh "); - nrOfFailedTestCases += ReportTestResult( VerifyCosh >(reportTestCases), tag, "cosh "); - nrOfFailedTestCases += ReportTestResult( VerifyTanh >(reportTestCases), tag, "tanh "); - nrOfFailedTestCases += ReportTestResult( VerifyAsinh >(reportTestCases), tag, "asinh "); - nrOfFailedTestCases += ReportTestResult( VerifyAcosh >(reportTestCases), tag, "acosh "); - nrOfFailedTestCases += ReportTestResult( VerifyAtanh >(reportTestCases), tag, "atanh "); - - nrOfFailedTestCases += ReportTestResult( VerifyPowerFunction >(reportTestCases), tag, "pow "); + nrOfFailedTestCases += ReportTestResult( VerifySqrt (reportTestCases), tag, "sqrt (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyExp (reportTestCases), tag, "exp "); + nrOfFailedTestCases += ReportTestResult( VerifyExp2 (reportTestCases), tag, "exp2 "); + nrOfFailedTestCases += ReportTestResult( VerifyLog (reportTestCases), tag, "log "); + nrOfFailedTestCases += ReportTestResult( VerifyLog2 (reportTestCases), tag, "log2 "); + nrOfFailedTestCases += ReportTestResult( VerifyLog10 (reportTestCases), tag, "log10 "); + nrOfFailedTestCases += ReportTestResult( VerifySine (reportTestCases), tag, "sin "); + nrOfFailedTestCases += ReportTestResult( VerifyCosine (reportTestCases), tag, "cos "); + nrOfFailedTestCases += ReportTestResult( VerifyTangent (reportTestCases), tag, "tan "); + nrOfFailedTestCases += ReportTestResult( VerifyAsin (reportTestCases), tag, "asin "); + nrOfFailedTestCases += ReportTestResult( VerifyAcos (reportTestCases), tag, "acos "); + nrOfFailedTestCases += ReportTestResult( VerifyAtan (reportTestCases), tag, "atan "); + nrOfFailedTestCases += ReportTestResult( VerifySinh (reportTestCases), tag, "sinh "); + nrOfFailedTestCases += ReportTestResult( VerifyCosh (reportTestCases), tag, "cosh "); + nrOfFailedTestCases += ReportTestResult( VerifyTanh (reportTestCases), tag, "tanh "); + nrOfFailedTestCases += ReportTestResult( VerifyAsinh (reportTestCases), tag, "asinh "); + nrOfFailedTestCases += ReportTestResult( VerifyAcosh (reportTestCases), tag, "acosh "); + nrOfFailedTestCases += ReportTestResult( VerifyAtanh (reportTestCases), tag, "atanh "); + + nrOfFailedTestCases += ReportTestResult( VerifyPowerFunction (reportTestCases), tag, "pow "); #endif #ifdef EXHAUSTIVE // arithmetic tests std::cout << "Arithmetic tests\n"; - nrOfFailedTestCases += ReportTestResult(VerifyAddition >(reportTestCases), tag, "add (native) "); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction >(reportTestCases), tag, "subtract (native) "); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication >(reportTestCases), tag, "multiply (native) "); - nrOfFailedTestCases += ReportTestResult(VerifyDivision >(reportTestCases), tag, "divide (native) "); - nrOfFailedTestCases += ReportTestResult(VerifyNegation >(reportTestCases), tag, "negate (native) "); - nrOfFailedTestCases += ReportTestResult(VerifyReciprocation >(reportTestCases), tag, "reciprocate (native) "); + nrOfFailedTestCases += ReportTestResult(VerifyAddition (reportTestCases), tag, "add (native) "); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction (reportTestCases), tag, "subtract (native) "); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication (reportTestCases), tag, "multiply (native) "); + nrOfFailedTestCases += ReportTestResult(VerifyDivision (reportTestCases), tag, "divide (native) "); + nrOfFailedTestCases += ReportTestResult(VerifyNegation (reportTestCases), tag, "negate (native) "); + nrOfFailedTestCases += ReportTestResult(VerifyReciprocation (reportTestCases), tag, "reciprocate (native) "); #endif ReportTestSuiteResults(test_suite, nrOfFailedTestCases); diff --git a/static/posit/specialized/posit_256_2.cpp b/static/posit/specialized/posit_256_2.cpp index 66c02ea1d..d8d19198b 100644 --- a/static/posit/specialized/posit_256_2.cpp +++ b/static/posit/specialized/posit_256_2.cpp @@ -55,8 +55,10 @@ try { unsigned RND_TEST_CASES = 1024; - posit p; + using TestType = posit; + TestType p; std::cout << dynamic_range(p) << "\n\n"; + std::string tag = type_tag(p); #if MANUAL_TESTING @@ -83,10 +85,10 @@ try { nrOfFailedTestCases += ReportCheck(test_tag, test, p.ispos()); RND_TEST_CASES = 1024; - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), test_tag, "addition "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), test_tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), test_tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), test_tag, "division "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), test_tag, "addition "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), test_tag, "subtraction "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), test_tag, "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), test_tag, "division "); ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return EXIT_SUCCESS; // ignore failures diff --git a/static/posit/specialized/posit_256_5.cpp b/static/posit/specialized/posit_256_5.cpp index 01d1686da..2522e9e8a 100644 --- a/static/posit/specialized/posit_256_5.cpp +++ b/static/posit/specialized/posit_256_5.cpp @@ -55,8 +55,10 @@ try { unsigned RND_TEST_CASES = 1024; - posit p; + using TestType = posit; + TestType p; std::cout << dynamic_range(p) << "\n\n"; + std::string tag = type_tag(p); #if MANUAL_TESTING @@ -83,10 +85,10 @@ try { nrOfFailedTestCases += ReportCheck(test_tag, test, p.ispos()); RND_TEST_CASES = 1024; - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), test_tag, "addition "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), test_tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), test_tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), test_tag, "division "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), test_tag, "addition "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), test_tag, "subtraction "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), test_tag, "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), test_tag, "division "); ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return EXIT_SUCCESS; // ignore failures @@ -116,19 +118,19 @@ try { nrOfFailedTestCases += ReportCheck(test_tag, test, p.ispos()); RND_TEST_CASES = 1024; - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), test_tag, "addition "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), test_tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), test_tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), test_tag, "division "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), test_tag, "addition "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), test_tag, "subtraction "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), test_tag, "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), test_tag, "division "); #endif #if REGRESSION_LEVEL_2 RND_TEST_CASES = 1024 * 16; - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), test_tag, "addition "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), test_tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), test_tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), test_tag, "division "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), test_tag, "addition "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), test_tag, "subtraction "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), test_tag, "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), test_tag, "division "); #endif @@ -143,10 +145,10 @@ try { RND_TEST_CASES = 1024 * 1024; std::cout << "Arithmetic tests " << RND_TEST_CASES << " randoms each\n"; std::cout << "Without an arithmetic reference, test failures can be ignored\n"; - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), test_tag, "addition "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), test_tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), test_tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), test_tag, "division "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), test_tag, "addition "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), test_tag, "subtraction "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), test_tag, "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), test_tag, "division "); nrOfFailedTestCases = 0; #endif diff --git a/static/posit/specialized/posit_32_2.cpp b/static/posit/specialized/posit_32_2.cpp index 84083b577..15ea05654 100644 --- a/static/posit/specialized/posit_32_2.cpp +++ b/static/posit/specialized/posit_32_2.cpp @@ -57,8 +57,8 @@ try { unsigned RND_TEST_CASES = 65536; - using Scalar = posit; - Scalar p; + using TestType = posit; + TestType p; std::string tag = type_tag(p); std::cout << dynamic_range(p) << "\n\n"; @@ -87,10 +87,10 @@ try { nrOfFailedTestCases += ReportCheck(tag, test, p.ispos()); RND_TEST_CASES = 5000; - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return EXIT_SUCCESS; // ignore failures @@ -119,42 +119,42 @@ try { test = "is positive"; nrOfFailedTestCases += ReportCheck(tag, test, p.ispos()); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); #endif #if REGRESSION_LEVEL_2 // logic tests std::cout << "Logic operator tests\n"; - nrOfFailedTestCases += ReportTestResult( VerifyLogicEqual >(reportTestCases), tag, " == (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyLogicNotEqual >(reportTestCases), tag, " != (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyLogicLessThan >(reportTestCases), tag, " < (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyLogicLessOrEqualThan >(reportTestCases), tag, " <= (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyLogicGreaterThan >(reportTestCases), tag, " > (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyLogicGreaterOrEqualThan>(reportTestCases), tag, " >= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyLogicEqual (reportTestCases), tag, " == (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyLogicNotEqual (reportTestCases), tag, " != (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyLogicLessThan (reportTestCases), tag, " < (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyLogicLessOrEqualThan (reportTestCases), tag, " <= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyLogicGreaterThan (reportTestCases), tag, " > (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyLogicGreaterOrEqualThan(reportTestCases), tag, " >= (native) "); // conversion tests // internally this generators are clamped as the state space 2^33 is too big std::cout << "Assignment/conversion tests\n"; - nrOfFailedTestCases += ReportTestResult( VerifyIntegerConversion >(reportTestCases), tag, "sint32 assign (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyUintConversion >(reportTestCases), tag, "uint32 assign (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyConversion , float>(reportTestCases), tag, "float assign (native) "); -// nrOfFailedTestCases += ReportTestResult( VerifyConversionThroughRandoms (tag, true, 100), tag, "float assign "); + nrOfFailedTestCases += ReportTestResult( VerifyIntegerConversion (reportTestCases), tag, "sint32 assign (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyUintConversion (reportTestCases), tag, "uint32 assign (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyConversion (reportTestCases), tag, "float assign (native) "); +// nrOfFailedTestCases += ReportTestResult( VerifyConversionThroughRandoms (tag, true, 100), tag, "float assign "); #endif #if REGRESSION_LEVEL_3 // arithmetic tests std::cout << "Arithmetic tests " << RND_TEST_CASES << " randoms each\n"; - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPA, RND_TEST_CASES), tag, "+= (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPS, RND_TEST_CASES), tag, "-= (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPM, RND_TEST_CASES), tag, "*= (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPD, RND_TEST_CASES), tag, "/= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPA, RND_TEST_CASES), tag, "+= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPS, RND_TEST_CASES), tag, "-= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPM, RND_TEST_CASES), tag, "*= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_IPD, RND_TEST_CASES), tag, "/= (native) "); #endif #if REGRESSION_LEVEL_4 @@ -162,26 +162,26 @@ try { std::cout << "Elementary function tests\n"; p.minpos(); double dminpos = double(p); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_SQRT, RND_TEST_CASES, dminpos), tag, "sqrt (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_EXP, RND_TEST_CASES, dminpos), tag, "exp "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_EXP2, RND_TEST_CASES, dminpos), tag, "exp2 "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_LOG, RND_TEST_CASES, dminpos), tag, "log "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_LOG2, RND_TEST_CASES, dminpos), tag, "log2 "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_LOG10, RND_TEST_CASES, dminpos), tag, "log10 "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_SIN, RND_TEST_CASES, dminpos), tag, "sin "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_COS, RND_TEST_CASES, dminpos), tag, "cos "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_TAN, RND_TEST_CASES, dminpos), tag, "tan "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ASIN, RND_TEST_CASES, dminpos), tag, "asin "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ACOS, RND_TEST_CASES, dminpos), tag, "acos "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ATAN, RND_TEST_CASES, dminpos), tag, "atan "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_SINH, RND_TEST_CASES, dminpos), tag, "sinh "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_COSH, RND_TEST_CASES, dminpos), tag, "cosh "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_TANH, RND_TEST_CASES, dminpos), tag, "tanh "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ASINH, RND_TEST_CASES, dminpos), tag, "asinh "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ACOSH, RND_TEST_CASES, dminpos), tag, "acosh "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ATANH, RND_TEST_CASES, dminpos), tag, "atanh "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_SQRT, RND_TEST_CASES, dminpos), tag, "sqrt (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_EXP, RND_TEST_CASES, dminpos), tag, "exp "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_EXP2, RND_TEST_CASES, dminpos), tag, "exp2 "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_LOG, RND_TEST_CASES, dminpos), tag, "log "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_LOG2, RND_TEST_CASES, dminpos), tag, "log2 "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_LOG10, RND_TEST_CASES, dminpos), tag, "log10 "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_SIN, RND_TEST_CASES, dminpos), tag, "sin "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_COS, RND_TEST_CASES, dminpos), tag, "cos "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_TAN, RND_TEST_CASES, dminpos), tag, "tan "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ASIN, RND_TEST_CASES, dminpos), tag, "asin "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ACOS, RND_TEST_CASES, dminpos), tag, "acos "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ATAN, RND_TEST_CASES, dminpos), tag, "atan "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_SINH, RND_TEST_CASES, dminpos), tag, "sinh "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_COSH, RND_TEST_CASES, dminpos), tag, "cosh "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_TANH, RND_TEST_CASES, dminpos), tag, "tanh "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ASINH, RND_TEST_CASES, dminpos), tag, "asinh "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ACOSH, RND_TEST_CASES, dminpos), tag, "acosh "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ATANH, RND_TEST_CASES, dminpos), tag, "atanh "); // elementary functions with two operands - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_POW, RND_TEST_CASES), tag, "pow "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_POW, RND_TEST_CASES), tag, "pow "); #endif diff --git a/static/posit/specialized/posit_48_2.cpp b/static/posit/specialized/posit_48_2.cpp index ea923f96e..8993ad356 100644 --- a/static/posit/specialized/posit_48_2.cpp +++ b/static/posit/specialized/posit_48_2.cpp @@ -54,8 +54,8 @@ try { unsigned RND_TEST_CASES = 1024; - using Scalar = posit; - Scalar p; + using TestType = posit; + TestType p; std::cout << dynamic_range(p) << "\n\n"; std::string tag = type_tag(p); @@ -83,10 +83,10 @@ try { nrOfFailedTestCases += ReportCheck(tag, test, p.ispos()); RND_TEST_CASES = 1024; - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return EXIT_SUCCESS; // ignore failures @@ -116,10 +116,10 @@ try { nrOfFailedTestCases += ReportCheck(tag, test, p.ispos()); RND_TEST_CASES = 1024; - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); #endif @@ -137,10 +137,10 @@ try { RND_TEST_CASES = 1024 * 16; std::cout << "Arithmetic tests " << RND_TEST_CASES << " randoms each\n"; std::cout << "Without an arithmetic reference, test failures can be ignored\n"; - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); #endif ReportTestSuiteResults(test_suite, nrOfFailedTestCases); diff --git a/static/posit/specialized/posit_64_2.cpp b/static/posit/specialized/posit_64_2.cpp index 8f593aa25..04650915f 100644 --- a/static/posit/specialized/posit_64_2.cpp +++ b/static/posit/specialized/posit_64_2.cpp @@ -54,13 +54,13 @@ try { unsigned RND_TEST_CASES = 1024; - using Scalar = posit; - Scalar p; + using TestType = posit; + TestType p; std::cout << dynamic_range(p) << "\n\n"; std::string tag = type_tag(p); #if MANUAL_TESTING - Scalar a, b, c; + TestType a, b, c; a = 1.0f; b = 1.5f; @@ -104,10 +104,10 @@ try { nrOfFailedTestCases += ReportCheck(tag, test, p.ispos()); RND_TEST_CASES = 1024; - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return EXIT_SUCCESS; // ignore failures @@ -137,43 +137,43 @@ try { nrOfFailedTestCases += ReportCheck(tag, test, p.ispos()); RND_TEST_CASES = 1024; - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); #endif #if REGRESSION_LEVEL_2 // logic tests std::cout << "Logic operator tests\n"; - nrOfFailedTestCases += ReportTestResult( VerifyPositLogicEqual (), tag, " == (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyPositLogicNotEqual (), tag, " != (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyPositLogicLessThan (), tag, " < (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyPositLogicLessOrEqualThan (), tag, " <= (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyPositLogicGreaterThan (), tag, " > (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyPositLogicGreaterOrEqualThan(), tag, " >= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyPositLogicEqual (), tag, " == (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyPositLogicNotEqual (), tag, " != (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyPositLogicLessThan (), tag, " < (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyPositLogicLessOrEqualThan (), tag, " <= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyPositLogicGreaterThan (), tag, " > (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyPositLogicGreaterOrEqualThan(), tag, " >= (native) "); // conversion tests // internally this generators are clamped as the state space 2^33 is too big std::cout << "Assignment/conversion tests\n"; - nrOfFailedTestCases += ReportTestResult( VerifyIntegerConversion (reportTestCases), tag, "sint32 assign (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyUintConversion (reportTestCases), tag, "uint32 assign (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyConversion (reportTestCases), tag, "float assign (native) "); -// nrOfFailedTestCases += ReportTestResult( VerifyConversionThroughRandoms (tag, true, 100), tag, "float assign "); + nrOfFailedTestCases += ReportTestResult( VerifyIntegerConversion (reportTestCases), tag, "sint32 assign (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyUintConversion (reportTestCases), tag, "uint32 assign (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyConversion (reportTestCases), tag, "float assign (native) "); +// nrOfFailedTestCases += ReportTestResult( VerifyConversionThroughRandoms (tag, true, 100), tag, "float assign "); #endif #if REGRESSION_LEVEL_3 // arithmetic tests std::cout << "Arithmetic tests " << RND_TEST_CASES << " randoms each\n"; - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "+= (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "-= (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "*= (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "/= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "+= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "-= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "*= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "/= (native) "); #endif @@ -182,26 +182,26 @@ try { std::cout << "Elementary function tests\n"; p.minpos(); double dminpos = double(p); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_SQRT, RND_TEST_CASES, dminpos), tag, "sqrt (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_EXP, RND_TEST_CASES, dminpos), tag, "exp "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_EXP2, RND_TEST_CASES, dminpos), tag, "exp2 "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_LOG, RND_TEST_CASES, dminpos), tag, "log "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_LOG2, RND_TEST_CASES, dminpos), tag, "log2 "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_LOG10, RND_TEST_CASES, dminpos), tag, "log10 "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_SIN, RND_TEST_CASES, dminpos), tag, "sin "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_COS, RND_TEST_CASES, dminpos), tag, "cos "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_TAN, RND_TEST_CASES, dminpos), tag, "tan "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ASIN, RND_TEST_CASES, dminpos), tag, "asin "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ACOS, RND_TEST_CASES, dminpos), tag, "acos "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ATAN, RND_TEST_CASES, dminpos), tag, "atan "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_SINH, RND_TEST_CASES, dminpos), tag, "sinh "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_COSH, RND_TEST_CASES, dminpos), tag, "cosh "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_TANH, RND_TEST_CASES, dminpos), tag, "tanh "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ASINH, RND_TEST_CASES, dminpos), tag, "asinh "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ACOSH, RND_TEST_CASES, dminpos), tag, "acosh "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ATANH, RND_TEST_CASES, dminpos), tag, "atanh "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_SQRT, RND_TEST_CASES, dminpos), tag, "sqrt (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_EXP, RND_TEST_CASES, dminpos), tag, "exp "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_EXP2, RND_TEST_CASES, dminpos), tag, "exp2 "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_LOG, RND_TEST_CASES, dminpos), tag, "log "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_LOG2, RND_TEST_CASES, dminpos), tag, "log2 "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_LOG10, RND_TEST_CASES, dminpos), tag, "log10 "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_SIN, RND_TEST_CASES, dminpos), tag, "sin "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_COS, RND_TEST_CASES, dminpos), tag, "cos "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_TAN, RND_TEST_CASES, dminpos), tag, "tan "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ASIN, RND_TEST_CASES, dminpos), tag, "asin "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ACOS, RND_TEST_CASES, dminpos), tag, "acos "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ATAN, RND_TEST_CASES, dminpos), tag, "atan "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_SINH, RND_TEST_CASES, dminpos), tag, "sinh "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_COSH, RND_TEST_CASES, dminpos), tag, "cosh "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_TANH, RND_TEST_CASES, dminpos), tag, "tanh "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ASINH, RND_TEST_CASES, dminpos), tag, "asinh "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ACOSH, RND_TEST_CASES, dminpos), tag, "acosh "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ATANH, RND_TEST_CASES, dminpos), tag, "atanh "); // elementary functions with two operands - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_POW, RND_TEST_CASES), tag, "pow "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_POW, RND_TEST_CASES), tag, "pow "); #endif ReportTestSuiteResults(test_suite, nrOfFailedTestCases); diff --git a/static/posit/specialized/posit_64_3.cpp b/static/posit/specialized/posit_64_3.cpp index aa5869484..a08c48911 100644 --- a/static/posit/specialized/posit_64_3.cpp +++ b/static/posit/specialized/posit_64_3.cpp @@ -54,8 +54,8 @@ try { unsigned RND_TEST_CASES = 5000; - using Scalar = posit; - Scalar p; + using TestType = posit; + TestType p; std::cout << dynamic_range(p) << "\n\n"; std::string tag = type_tag(p); @@ -83,10 +83,10 @@ try { nrOfFailedTestCases += ReportCheck(tag, test, p.ispos()); RND_TEST_CASES = 1024; - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return EXIT_SUCCESS; // ignore failures @@ -116,43 +116,43 @@ try { nrOfFailedTestCases += ReportCheck(tag, test, p.ispos()); RND_TEST_CASES = 1024; - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); #endif #if REGRESSION_LEVEL_2 // logic tests std::cout << "Logic operator tests\n"; - nrOfFailedTestCases += ReportTestResult( VerifyPositLogicEqual (), tag, " == (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyPositLogicNotEqual (), tag, " != (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyPositLogicLessThan (), tag, " < (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyPositLogicLessOrEqualThan (), tag, " <= (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyPositLogicGreaterThan (), tag, " > (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyPositLogicGreaterOrEqualThan(), tag, " >= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyPositLogicEqual (), tag, " == (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyPositLogicNotEqual (), tag, " != (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyPositLogicLessThan (), tag, " < (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyPositLogicLessOrEqualThan (), tag, " <= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyPositLogicGreaterThan (), tag, " > (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyPositLogicGreaterOrEqualThan(), tag, " >= (native) "); // conversion tests // internally this generators are clamped as the state space 2^33 is too big std::cout << "Assignment/conversion tests\n"; - nrOfFailedTestCases += ReportTestResult( VerifyIntegerConversion (reportTestCases), tag, "sint32 assign (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyUintConversion (reportTestCases), tag, "uint32 assign (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyConversion (reportTestCases), tag, "float assign (native) "); -// nrOfFailedTestCases += ReportTestResult( VerifyConversionThroughRandoms (tag, true, 100), tag, "float assign "); + nrOfFailedTestCases += ReportTestResult( VerifyIntegerConversion (reportTestCases), tag, "sint32 assign (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyUintConversion (reportTestCases), tag, "uint32 assign (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyConversion (reportTestCases), tag, "float assign (native) "); +// nrOfFailedTestCases += ReportTestResult( VerifyConversionThroughRandoms (tag, true, 100), tag, "float assign "); #endif #if REGRESSION_LEVEL_3 // arithmetic tests std::cout << "Arithmetic tests " << RND_TEST_CASES << " randoms each\n"; - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "+= (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "-= (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "*= (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "/= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "+= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "-= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "*= (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "/= (native) "); #endif @@ -161,26 +161,26 @@ try { std::cout << "Elementary function tests\n"; p.minpos(); double dminpos = double(p); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_SQRT, RND_TEST_CASES, dminpos), tag, "sqrt (native) "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_EXP, RND_TEST_CASES, dminpos), tag, "exp "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_EXP2, RND_TEST_CASES, dminpos), tag, "exp2 "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_LOG, RND_TEST_CASES, dminpos), tag, "log "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_LOG2, RND_TEST_CASES, dminpos), tag, "log2 "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_LOG10, RND_TEST_CASES, dminpos), tag, "log10 "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_SIN, RND_TEST_CASES, dminpos), tag, "sin "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_COS, RND_TEST_CASES, dminpos), tag, "cos "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_TAN, RND_TEST_CASES, dminpos), tag, "tan "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ASIN, RND_TEST_CASES, dminpos), tag, "asin "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ACOS, RND_TEST_CASES, dminpos), tag, "acos "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ATAN, RND_TEST_CASES, dminpos), tag, "atan "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_SINH, RND_TEST_CASES, dminpos), tag, "sinh "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_COSH, RND_TEST_CASES, dminpos), tag, "cosh "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_TANH, RND_TEST_CASES, dminpos), tag, "tanh "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ASINH, RND_TEST_CASES, dminpos), tag, "asinh "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ACOSH, RND_TEST_CASES, dminpos), tag, "acosh "); - nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ATANH, RND_TEST_CASES, dminpos), tag, "atanh "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_SQRT, RND_TEST_CASES, dminpos), tag, "sqrt (native) "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_EXP, RND_TEST_CASES, dminpos), tag, "exp "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_EXP2, RND_TEST_CASES, dminpos), tag, "exp2 "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_LOG, RND_TEST_CASES, dminpos), tag, "log "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_LOG2, RND_TEST_CASES, dminpos), tag, "log2 "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_LOG10, RND_TEST_CASES, dminpos), tag, "log10 "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_SIN, RND_TEST_CASES, dminpos), tag, "sin "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_COS, RND_TEST_CASES, dminpos), tag, "cos "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_TAN, RND_TEST_CASES, dminpos), tag, "tan "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ASIN, RND_TEST_CASES, dminpos), tag, "asin "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ACOS, RND_TEST_CASES, dminpos), tag, "acos "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ATAN, RND_TEST_CASES, dminpos), tag, "atan "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_SINH, RND_TEST_CASES, dminpos), tag, "sinh "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_COSH, RND_TEST_CASES, dminpos), tag, "cosh "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_TANH, RND_TEST_CASES, dminpos), tag, "tanh "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ASINH, RND_TEST_CASES, dminpos), tag, "asinh "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ACOSH, RND_TEST_CASES, dminpos), tag, "acosh "); + nrOfFailedTestCases += ReportTestResult( VerifyUnaryOperatorThroughRandoms(reportTestCases, OPCODE_ATANH, RND_TEST_CASES, dminpos), tag, "atanh "); // elementary functions with two operands - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_POW, RND_TEST_CASES), tag, "pow "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_POW, RND_TEST_CASES), tag, "pow "); #endif ReportTestSuiteResults(test_suite, nrOfFailedTestCases); diff --git a/static/posit/specialized/quire_32_2.cpp b/static/posit/specialized/quire_32_2.cpp index 641825af1..30a6611d2 100644 --- a/static/posit/specialized/quire_32_2.cpp +++ b/static/posit/specialized/quire_32_2.cpp @@ -45,6 +45,7 @@ try { constexpr size_t RND_TEST_CASES = 500000; + using TestType = posit; quire q; std::cout << dynamic_range() << "\n\n"; @@ -59,13 +60,13 @@ try { // conversion tests std::cout << "Assignment/conversion tests\n"; - posit p(SpecificValue::minpos); + TestType p(SpecificValue::minpos); q = p; // arithmetic tests std::cout << "Arithmetic tests " << RND_TEST_CASES << " randoms each\n"; - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), test_tag, "addition (native) "); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), test_tag, "multiplication (native) "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_ADD, RND_TEST_CASES), test_tag, "addition (native) "); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms(reportTestCases, OPCODE_MUL, RND_TEST_CASES), test_tag, "multiplication (native) "); ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); diff --git a/static/posit2/arithmetic/addition.cpp b/static/posit2/arithmetic/addition.cpp index 7d32c32de..7410ed3c8 100644 --- a/static/posit2/arithmetic/addition.cpp +++ b/static/posit2/arithmetic/addition.cpp @@ -126,27 +126,27 @@ try { nrOfFailedTestCases += ReportTestResult(VerifyAddition>(reportTestCases), "posit<10,2>", "addition"); nrOfFailedTestCases += ReportTestResult(VerifyAddition>(reportTestCases), "posit<10,3>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<16, 2>(reportTestCases, OPCODE_ADD, 1000), "posit<16,2>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<24, 2>(reportTestCases, OPCODE_ADD, 1000), "posit<24,1>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<16,2>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<24,1>", "addition"); #endif #if REGRESSION_LEVEL_3 - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<20, 1>(reportTestCases, OPCODE_ADD, 1000), "posit<20,1>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<28, 1>(reportTestCases, OPCODE_ADD, 1000), "posit<28,1>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<20,1>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<28,1>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 1>(reportTestCases, OPCODE_ADD, 1000), "posit<32,1>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 2>(reportTestCases, OPCODE_ADD, 1000), "posit<32,2>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 3>(reportTestCases, OPCODE_ADD, 1000), "posit<32,3>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<32,1>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<32,2>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<32,3>", "addition"); #endif #if REGRESSION_LEVEL_4 // nbits=48 also shows failures - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<48, 2>(reportTestCases, OPCODE_ADD, 1000), "posit<48,2>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<48,2>", "addition"); // nbits=64 requires long double compiler support - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 2>(reportTestCases, OPCODE_ADD, 1000), "posit<64,2>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 3>(reportTestCases, OPCODE_ADD, 1000), "posit<64,3>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 4>(reportTestCases, OPCODE_ADD, 1000), "posit<64,4>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<64,2>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<64,3>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<64,4>", "addition"); #ifdef HARDWARE_ACCELERATION nrOfFailedTestCases += ReportTestResult(VerifyAddition>(reportTestCases), "posit<12,1>", "addition"); diff --git a/static/posito/arithmetic/addition.cpp b/static/posito/arithmetic/addition.cpp index 9ded0c6fc..ff61134d9 100644 --- a/static/posito/arithmetic/addition.cpp +++ b/static/posito/arithmetic/addition.cpp @@ -159,8 +159,8 @@ try { // TODO: no working fast posit<8,2> yet //nrOfFailedTestCases += ReportTestResult(VerifyAddition>(reportTestCases), "posit< 8,2>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<16, 1>(reportTestCases, OPCODE_ADD, 65536), "posit<16,1>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<16, 2>(reportTestCases, OPCODE_ADD, 65536), "posit<16,2>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 65536), "posit<16,1>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 65536), "posit<16,2>", "addition"); #endif @@ -171,26 +171,26 @@ try { nrOfFailedTestCases += ReportTestResult(VerifyAddition>(reportTestCases), "posit<10,2>", "addition"); nrOfFailedTestCases += ReportTestResult(VerifyAddition>(reportTestCases), "posit<10,3>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<16, 2>(reportTestCases, OPCODE_ADD, 1000), "posit<16,2>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<24, 2>(reportTestCases, OPCODE_ADD, 1000), "posit<24,1>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<16,2>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<24,1>", "addition"); #endif #if REGRESSION_LEVEL_3 - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<20, 1>(reportTestCases, OPCODE_ADD, 1000), "posit<20,1>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<28, 1>(reportTestCases, OPCODE_ADD, 1000), "posit<28,1>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<20,1>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<28,1>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 2>(reportTestCases, OPCODE_ADD, 1000), "posit<32,2>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 3>(reportTestCases, OPCODE_ADD, 1000), "posit<32,3>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<32,2>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<32,3>", "addition"); #endif #if REGRESSION_LEVEL_4 // nbits=48 also shows failures - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<48, 2>(reportTestCases, OPCODE_ADD, 1000), "posit<48,2>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<48,2>", "addition"); // nbits=64 requires long double compiler support - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 2>(reportTestCases, OPCODE_ADD, 1000), "posit<64,2>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 3>(reportTestCases, OPCODE_ADD, 1000), "posit<64,3>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 4>(reportTestCases, OPCODE_ADD, 1000), "posit<64,4>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<64,2>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<64,3>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_ADD, 1000), "posit<64,4>", "addition"); #ifdef HARDWARE_ACCELERATION nrOfFailedTestCases += ReportTestResult(VerifyAddition>(reportTestCases), "posit<12,1>", "addition"); diff --git a/static/posito/arithmetic/division.cpp b/static/posito/arithmetic/division.cpp index b06b8d5de..713062ab3 100644 --- a/static/posito/arithmetic/division.cpp +++ b/static/posito/arithmetic/division.cpp @@ -221,7 +221,7 @@ try { } - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<16, 2>(reportTestCases, OPCODE_DIV, 65536), "posit<16,2>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 65536), "posit<16,2>", "division"); // nrOfFailedTestCases += ReportTestResult(sw::testing::VerifyDivision>(true), "posit<8,0>", "division"); // nrOfFailedTestCases += ReportTestResult(sw::testing::VerifyDivision>(true), "posit<16,1>", "division"); @@ -245,8 +245,8 @@ try { // TODO: no working fast posit<8,2> yet //nrOfFailedTestCases += ReportTestResult(VerifyMultiplication8, 2>>(reportTestCases), "posit< 8,2>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<16, 1>(reportTestCases, OPCODE_DIV, 65536), "posit<16,1>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<16, 2>(reportTestCases, OPCODE_DIV, 65536), "posit<16,2>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 65536), "posit<16,1>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 65536), "posit<16,2>", "division"); #endif @@ -256,28 +256,28 @@ try { nrOfFailedTestCases += ReportTestResult(VerifyDivision>(reportTestCases), "posit<10,2>", "division"); nrOfFailedTestCases += ReportTestResult(VerifyDivision>(reportTestCases), "posit<10,3>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<16, 2>(reportTestCases, OPCODE_DIV, 1000), "posit<16,2>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<24, 2>(reportTestCases, OPCODE_DIV, 1000), "posit<24,2>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<16,2>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<24,2>", "division"); #endif #if REGRESSION_LEVEL_3 - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<20, 1>(reportTestCases, OPCODE_DIV, 1000), "posit<20,1>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<28, 1>(reportTestCases, OPCODE_DIV, 1000), "posit<28,1>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<20,1>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<28,1>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 1>(reportTestCases, OPCODE_DIV, 1000), "posit<32,1>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 2>(reportTestCases, OPCODE_DIV, 1000), "posit<32,2>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 3>(reportTestCases, OPCODE_DIV, 1000), "posit<32,3>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<32,1>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<32,2>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<32,3>", "division"); #endif #if REGRESSION_LEVEL_4 // nbits = 48 also shows failures - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<48, 2>(reportTestCases, OPCODE_DIV, 1000), "posit<48,2>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<48,2>", "division"); // nbits=64 requires long double compiler support - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 2>(reportTestCases, OPCODE_DIV, 1000), "posit<64,2>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 3>(reportTestCases, OPCODE_DIV, 1000), "posit<64,3>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<64,2>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<64,3>", "division"); // posit<64,4> is hitting subnormal numbers - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 4>(reportTestCases, OPCODE_DIV, 1000), "posit<64,4>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_DIV, 1000), "posit<64,4>", "division"); #ifdef HARDWARE_ACCELERATION nrOfFailedTestCases += ReportTestResult(VerifyDivision>(reportTestCases), "posit<12,1>", "division"); diff --git a/static/posito/arithmetic/multiplication.cpp b/static/posito/arithmetic/multiplication.cpp index 0ca47e57e..5c47f04c2 100644 --- a/static/posito/arithmetic/multiplication.cpp +++ b/static/posito/arithmetic/multiplication.cpp @@ -192,30 +192,30 @@ try { // TODO: no working fast posit<8,2> yet //nrOfFailedTestCases += ReportTestResult(VerifyMultiplication(reportTestCases), "posit< 8,2>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<16, 1>(reportTestCases, OPCODE_MUL, 65536), "posit<16,1>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<16, 2>(reportTestCases, OPCODE_MUL, 65536), "posit<16,2>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_MUL, 65536), "posit<16,1>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_MUL, 65536), "posit<16,2>", "multiplication"); #endif #if REGRESSION_LEVEL_2 - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<16, 2>(reportTestCases, OPCODE_MUL, 1000), "posit<16,2>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<24, 2>(reportTestCases, OPCODE_MUL, 1000), "posit<24,2>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_MUL, 1000), "posit<16,2>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_MUL, 1000), "posit<24,2>", "multiplication"); #endif #if REGRESSION_LEVEL_3 - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 2>(reportTestCases, OPCODE_MUL, 1000), "posit<32,2>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 3>(reportTestCases, OPCODE_MUL, 1000), "posit<32,3>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_MUL, 1000), "posit<32,2>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_MUL, 1000), "posit<32,3>", "multiplication"); #endif #if REGRESSION_LEVEL_4 // nbits=48 is also showing failures - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<48, 2>(reportTestCases, OPCODE_MUL, 1000), "posit<48,2>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_MUL, 1000), "posit<48,2>", "multiplication"); // nbits=64 requires long double compiler support - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 2>(reportTestCases, OPCODE_MUL, 1000), "posit<64,2>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 3>(reportTestCases, OPCODE_MUL, 1000), "posit<64,3>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_MUL, 1000), "posit<64,2>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_MUL, 1000), "posit<64,3>", "multiplication"); // posit<64,4> is hitting subnormal numbers - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 4>(reportTestCases, OPCODE_MUL, 1000), "posit<64,4>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_MUL, 1000), "posit<64,4>", "multiplication"); #ifdef HARDWARE_ACCELERATION nrOfFailedTestCases += ReportTestResult(VerifyMultiplication>(reportTestCases), "posit<12,1>", "multiplication"); diff --git a/static/posito/arithmetic/subtraction.cpp b/static/posito/arithmetic/subtraction.cpp index 03ffcfba2..d4d2e3746 100644 --- a/static/posito/arithmetic/subtraction.cpp +++ b/static/posito/arithmetic/subtraction.cpp @@ -140,8 +140,8 @@ try { // TODO: no working fast posit<8,2> yet //nrOfFailedTestCases += ReportTestResult(VerifySubtraction>(reportTestCases), "posit< 8,2>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<16, 1>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<16,1>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<16, 2>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<16,2>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<16,1>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<16,2>", "subtraction"); #endif #if REGRESSION_LEVEL_2 @@ -150,26 +150,26 @@ try { nrOfFailedTestCases += ReportTestResult(VerifySubtraction>(reportTestCases), "posit<10,2>", "subtraction"); nrOfFailedTestCases += ReportTestResult(VerifySubtraction>(reportTestCases), "posit<10,3>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<16, 2>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<16,2>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<24, 2>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<24,1>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<16,2>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<24,1>", "subtraction"); #endif #if REGRESSION_LEVEL_3 - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<20, 1>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<20,1>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<28, 1>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<28,1>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<20,1>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<28,1>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 2>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<32,2>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<32, 3>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<32,3>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<32,2>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<32,3>", "subtraction"); #endif #if REGRESSION_LEVEL_4 // nbits=48 also shows failures - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<48, 2>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<48,2>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<48,2>", "subtraction"); // nbits=64 requires long double compiler support - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 2>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<64,2>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 3>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<64,3>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms<64, 4>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<64,4>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<64,2>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<64,3>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifyBinaryOperatorThroughRandoms>(reportTestCases, OPCODE_SUB, nrOfRandoms), "posit<64,4>", "subtraction"); #ifdef HARDWARE_ACCELERATION nrOfFailedTestCases += ReportTestResult(VerifySubtraction(reportTestCases), "posit<12,1>", "subtraction");