From 50e3efe58d3e44b19ebe1cf86c42fc07f0c26603 Mon Sep 17 00:00:00 2001 From: Ravenwater Date: Sun, 24 Dec 2023 08:22:46 -0500 Subject: [PATCH] bug fix and reporting improvement of posit randoms --- .../universal/verification/posit_test_randoms.hpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/include/universal/verification/posit_test_randoms.hpp b/include/universal/verification/posit_test_randoms.hpp index fa3943ff1..814a1329d 100644 --- a/include/universal/verification/posit_test_randoms.hpp +++ b/include/universal/verification/posit_test_randoms.hpp @@ -243,6 +243,8 @@ namespace sw { namespace universal { std::mt19937_64 eng(rd()); // use the 64-bit Mersenne Twister 19937 generator and seed it with entropy. // define the distribution, by default it goes from 0 to MAX(unsigned long long) std::uniform_int_distribution distr; + bool firstNaRCall = true; + bool firstDivideByZeroCall = true; int nrOfFailedTests = 0; for (unsigned i = 1; i < nrOfRandoms; i++) { posit testa, testb, testc, testref; @@ -260,8 +262,15 @@ namespace sw { namespace universal { executeBinary(opcode, da, db, dc, testa, testb, testc, testref); } catch (const posit_arithmetic_exception& err) { - if (testa.isnar() || testb.isnar() || ((opcode == OPCODE_DIV || opcode == OPCODE_IPD) && testb.iszero())) { - if (reportTestCases) std::cerr << "Correctly caught arithmetic exception: " << err.what() << std::endl; + if (testa.isnar() || testb.isnar()) { + if (reportTestCases && firstNaRCall) std::cerr << "Correctly caught arithmetic exception: " << err.what() << std::endl; + firstNaRCall = false; + continue; + } + else if (((opcode == OPCODE_DIV || opcode == OPCODE_IPD) && testb.iszero())) { + if (reportTestCases && firstDivideByZeroCall) std::cerr << "Correctly caught arithmetic exception: " << err.what() << std::endl; + firstDivideByZeroCall = false; + continue; } else { throw; // rethrow