1 // subtraction.cpp: test suite runner for subtraction on classic floats
2 //
3 // Copyright (C) 2017-2021 Stillwater Supercomputing, Inc.
4 //
5 // This file is part of the universal numbers project, which is released under an MIT Open Source license.
6 #include <universal/utility/directives.hpp>
7 // minimum set of include files to reflect source code dependencies
8 #define BLOCKTRIPLE_VERBOSE_OUTPUT
9 //#define BLOCKTRIPLE_TRACE_ADD
10 #include <universal/number/cfloat/cfloat.hpp>
11 #include <universal/verification/test_status.hpp>
12 #include <universal/verification/test_case.hpp>
13 //#include <universal/verification/test_suite_arithmetic.hpp>
14 #include <universal/verification/cfloat_test_suite.hpp>
15 #include <universal/number/cfloat/table.hpp>
16
17 #define MANUAL_TESTING 1
18 #define STRESS_TESTING 0
19
20 /*
21 Minimum number of operand bits for the adder = <abits>
22 to yield correctly rounded subtraction
23
24 number of exponent bits = <es>
25 nbits 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
26 1 - - - - - - - - - - - - - - - -
27 2 - - - - - - - - - - - - - - - -
28 3 2 - - - - - - - - - - - - - - -
29 4 3 3 - - - - - - - - - - - - - -
30 5 4 4 4 - - - - - - - - - - - - -
31 6 5 5 6 4 - - - - - - - - - - - -
32 7 6 6 8 6 4 - - - - - - - - - - -
33 8 7 7 10 8 6 4 - - - - - - - - - -
34 9 8 8 11 10 8 6 4 - - - - - - - - -
35 10 9 9 12 12 10 8 6 4 - - - - - - - -
36 11 10 10 13 14 12 10 8 6 4 - - - - - - -
37 12 11 11 14 16 14 12 10 8 6 4 - - - - - -
38 13 12 12 15 18 16 14 12 10 8 6 ? - - - - -
39 14 13 13 16 20 18 16 14 12 10 8 ? ? - - - -
40 15 14 14 17 22 20 18 16 14 12 10 ? ? ? - - -
41 16 15 15 18 24 22 20 18 16 14 12 ? ? ? ? - -
42
43 */
44
main()45 int main()
46 try {
47 using namespace sw::universal;
48
49 int nrOfFailedTestCases = 0;
50 std::string tag = "cfloat_ttt subtraction failed: ";
51
52 // cfloat encoding configuration for the test
53 constexpr bool hasSubnormals = true;
54 constexpr bool hasSupernormals = true;
55 constexpr bool isSaturating = true;
56
57 #if MANUAL_TESTING
58
59 // 9,176 0b0.0001.001 0b1.0110.000 0b1.0110.000 0b1.0101.111 -0.48242
60 // FAIL 0.017578125 + -0.5 != -0.5 golden reference is - 0.46875 result 0b1.0110.000 vs ref 0b1.0101.111
61 std::cout << "Manual Testing\n";
62 {
63 float fa = 0.017578125; // 0.375; // 0.3125f; // 0.03125f; // 0.21875f;
64 // float fb = std::numeric_limits<float>::signaling_NaN();
65 // float fb = std::numeric_limits<float>::quiet_NaN();
66 // float fa = std::numeric_limits<float>::infinity();
67 float fb = 0.5f; // 7.625f; // 0.0625f; 3.9375f;
68
69 cfloat < 8, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating > a, b, c;
70 a.constexprClassParameters();
71 a = fa;
72 b = fb;
73 c = a - b;
74 std::cout << a << " - " << b << " = " << c << '\n';
75 std::cout << to_binary(a) << " + " << to_binary(b) << " = " << to_binary(c) << '\n';
76
77 TestCase< cfloat<8, 4, uint8_t>, float>(TestCaseOperator::SUB, fa, fb);
78 }
79
80 { // special cases of snan/qnan
81 constexpr float fa = std::numeric_limits<float>::quiet_NaN();
82 float fb = -fa;
83 std::cout << "fa = " << fa << " -fa = " << -fa << '\n';
84 std::cout << "fb = " << fb << " -fb = " << -fb << '\n';
85 std::cout << 0.0f << " - " << fa << " = " << (0.0f - fa) << '\n';
86 std::cout << 0.0f << " + " << fa << " = " << (0.0f + fa) << '\n';
87 std::cout << 0.0f << " - " << fb << " = " << (0.0f - fb) << '\n';
88 std::cout << fa << " - " << 0.0f << " = " << (fa - 0.0f) << '\n';
89 std::cout << fb << " - " << 0.0f << " = " << (fb - 0.0f) << '\n';
90 std::cout << fa << " - " << fa << " = " << (fa - fa) << '\n';
91 std::cout << fa << " - " << fb << " = " << (fa - fb) << '\n';
92 std::cout << fb << " - " << fa << " = " << (fb - fa) << '\n';
93 std::cout << fb << " - " << fb << " = " << (fb - fb) << '\n';
94 std::cout << to_binary(fa - fb) << '\n';
95 }
96
97 { // special cases of +-inf
98 constexpr float fa = std::numeric_limits<float>::infinity();
99 float fb = -fa;
100 std::cout << fa << " - " << fa << " = " << (fa - fa) << '\n';
101 std::cout << fa << " - " << fb << " = " << (fa - fb) << '\n';
102 std::cout << fb << " - " << fa << " = " << (fb - fa) << '\n';
103 std::cout << fb << " - " << fb << " = " << (fb - fb) << '\n';
104 std::cout << to_binary(fa - fb) << '\n';
105 }
106
107 nrOfFailedTestCases += ReportTestResult(
108 VerifyCfloatSubtraction<
109 cfloat<3, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(true),
110 "cfloat<3,1,uint8_t,t,t,t>",
111 "subtraction");
112 nrOfFailedTestCases += ReportTestResult(
113 VerifyCfloatSubtraction<
114 cfloat<4, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(true),
115 "cfloat<4,1,uint8_t,t,t,t>",
116 "subtraction");
117
118 std::cout << "Number of failed test cases : " << nrOfFailedTestCases << std::endl;
119 nrOfFailedTestCases = 0; // disregard any test failures in manual testing mode
120
121 #else
122 std::cout << "classic floating-point subtraction validation\n";
123
124 bool bReportIndividualTestCases = false;
125 constexpr bool hasSubnormals = true;
126 constexpr bool hasSupernormals = true;
127 constexpr bool isSaturating = true;
128
129 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<3, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 3, 1,uint8_t,t,t,t>", "subtraction");
130
131 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<4, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 4, 1,uint8_t,t,t,t>", "subtraction");
132 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<4, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 4, 2,uint8_t,t,t,t>", "subtraction");
133
134 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<5, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 5, 1,uint8_t,t,t,t>", "subtraction");
135 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<5, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 5, 2,uint8_t,t,t,t>", "subtraction");
136 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<5, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 5, 3,uint8_t,t,t,t>", "subtraction");
137
138 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<6, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 6, 1,uint8_t,t,t,t>", "subtraction");
139 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<6, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 6, 2,uint8_t,t,t,t>", "subtraction");
140 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<6, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 6, 3,uint8_t,t,t,t>", "subtraction");
141 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<6, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 6, 4,uint8_t,t,t,t>", "subtraction");
142
143 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<7, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 7, 1,uint8_t,t,t,t>", "subtraction");
144 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<7, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 7, 2,uint8_t,t,t,t>", "subtraction");
145 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<7, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 7, 3,uint8_t,t,t,t>", "subtraction");
146 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<7, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 7, 4,uint8_t,t,t,t>", "subtraction");
147 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<7, 5, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 7, 5,uint8_t,t,t,t>", "subtraction");
148
149 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<8, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 8, 1,uint8_t,t,t,t>", "subtraction");
150 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<8, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 8, 2,uint8_t,t,t,t>", "subtraction");
151 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<8, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 8, 3,uint8_t,t,t,t>", "subtraction");
152 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<8, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 8, 4,uint8_t,t,t,t>", "subtraction");
153 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<8, 5, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 8, 5,uint8_t,t,t,t>", "subtraction");
154 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<8, 6, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 8, 6,uint8_t,t,t,t>", "subtraction");
155
156 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<9, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 9, 1,uint8_t,t,t,t>", "subtraction");
157 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<9, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 9, 2,uint8_t,t,t,t>", "subtraction");
158 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<9, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 9, 3,uint8_t,t,t,t>", "subtraction");
159 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<9, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 9, 4,uint8_t,t,t,t>", "subtraction");
160 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<9, 5, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 9, 5,uint8_t,t,t,t>", "subtraction");
161 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<9, 6, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 9, 6,uint8_t,t,t,t>", "subtraction");
162 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<9, 7, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat< 9, 7,uint8_t,t,t,t>", "subtraction");
163
164 #if STRESS_TESTING
165 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<10, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<10, 1,uint8_t,t,t,t>", "subtraction");
166 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<10, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<10, 2,uint8_t,t,t,t>", "subtraction");
167 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<10, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<10, 3,uint8_t,t,t,t>", "subtraction");
168 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<10, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<10, 4,uint8_t,t,t,t>", "subtraction");
169 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<10, 5, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<10, 5,uint8_t,t,t,t>", "subtraction");
170 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<10, 6, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<10, 6,uint8_t,t,t,t>", "subtraction");
171 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<10, 7, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<10, 7,uint8_t,t,t,t>", "subtraction");
172 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<10, 8, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<10, 8,uint8_t,t,t,t>", "subtraction");
173
174 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<11, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<11, 1,uint8_t,t,t,t>", "subtraction");
175 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<11, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<11, 2,uint8_t,t,t,t>", "subtraction");
176 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<11, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<11, 3,uint8_t,t,t,t>", "subtraction");
177 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<11, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<11, 4,uint8_t,t,t,t>", "subtraction");
178 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<11, 5, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<11, 5,uint8_t,t,t,t>", "subtraction");
179 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<11, 6, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<11, 6,uint8_t,t,t,t>", "subtraction");
180 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<11, 7, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<11, 7,uint8_t,t,t,t>", "subtraction");
181 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<11, 8, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<11, 8,uint8_t,t,t,t>", "subtraction");
182 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<11, 9, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<11, 9,uint8_t,t,t,t>", "subtraction");
183
184 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<12, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<12, 1,uint8_t,t,t,t>", "subtraction");
185 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<12, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<12, 2,uint8_t,t,t,t>", "subtraction");
186 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<12, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<12, 3,uint8_t,t,t,t>", "subtraction");
187 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<12, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<12, 4,uint8_t,t,t,t>", "subtraction");
188 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<12, 5, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<12, 5,uint8_t,t,t,t>", "subtraction");
189 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<12, 6, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<12, 6,uint8_t,t,t,t>", "subtraction");
190 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<12, 7, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<12, 7,uint8_t,t,t,t>", "subtraction");
191 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<12, 8, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<12, 8,uint8_t,t,t,t>", "subtraction");
192 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<12, 9, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<12, 9,uint8_t,t,t,t>", "subtraction");
193 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<12,10, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<12,10,uint8_t,t,t,t>", "subtraction");
194
195 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<13, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<13, 3,uint8_t,t,t,t>", "subtraction");
196 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<13, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<13, 4,uint8_t,t,t,t>", "subtraction");
197 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<13, 5, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<13, 5,uint8_t,t,t,t>", "subtraction");
198 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<13, 6, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<13, 6,uint8_t,t,t,t>", "subtraction");
199 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<13, 7, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<13, 7,uint8_t,t,t,t>", "subtraction");
200 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<13, 8, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<13, 8,uint8_t,t,t,t>", "subtraction");
201 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<13, 9, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<13, 9,uint8_t,t,t,t>", "subtraction");
202 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<13, 10, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<13,10,uint8_t,t,t,t>", "subtraction");
203 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<13, 11, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<13,11,uint8_t,t,t,t>", "subtraction");
204
205 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<14, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<14, 3,uint8_t,t,t,t>", "subtraction");
206 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<14, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<14, 4,uint8_t,t,t,t>", "subtraction");
207 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<14, 5, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<14, 5,uint8_t,t,t,t>", "subtraction");
208 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<14, 6, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<14, 6,uint8_t,t,t,t>", "subtraction");
209 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<14, 7, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<14, 7,uint8_t,t,t,t>", "subtraction");
210 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<14, 8, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<14, 8,uint8_t,t,t,t>", "subtraction");
211 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<14, 9, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<14, 9,uint8_t,t,t,t>", "subtraction");
212 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<14, 10, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<14,10,uint8_t,t,t,t>", "subtraction");
213 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<14, 11, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<14,11,uint8_t,t,t,t>", "subtraction");
214
215 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<15, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<15, 3,uint8_t,t,t,t>", "subtraction");
216 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<15, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<15, 4,uint8_t,t,t,t>", "subtraction");
217 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<15, 5, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<15, 5,uint8_t,t,t,t>", "subtraction");
218 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<15, 6, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<15, 6,uint8_t,t,t,t>", "subtraction");
219 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<15, 7, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<15, 7,uint8_t,t,t,t>", "subtraction");
220 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<15, 8, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<15, 8,uint8_t,t,t,t>", "subtraction");
221 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<15, 9, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<15, 9,uint8_t,t,t,t>", "subtraction");
222 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<15, 10, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<15,10,uint8_t,t,t,t>", "subtraction");
223 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<15, 11, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<15,11,uint8_t,t,t,t>", "subtraction");
224
225 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<16, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<16, 3,uint8_t,t,t,t>", "subtraction");
226 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<16, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<16, 4,uint8_t,t,t,t>", "subtraction");
227 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<16, 5, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<16, 5,uint8_t,t,t,t>", "subtraction");
228 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<16, 6, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<16, 6,uint8_t,t,t,t>", "subtraction");
229 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<16, 7, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<16, 7,uint8_t,t,t,t>", "subtraction");
230 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<16, 8, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<16, 8,uint8_t,t,t,t>", "subtraction");
231 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<16, 9, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<16, 9,uint8_t,t,t,t>", "subtraction");
232 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<16, 10, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<16,10,uint8_t,t,t,t>", "subtraction");
233 nrOfFailedTestCases += ReportTestResult(VerifyCfloatSubtraction< cfloat<16, 11, uint8_t, hasSubnormals, hasSupernormals, isSaturating> >(bReportIndividualTestCases), "cfloat<16,11,uint8_t,t,t,t>", "subtraction");
234
235 #endif // STRESS_TESTING
236
237
238 #endif // MANUAL_TESTING
239
240 return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS);
241
242 }
243 catch (char const* msg) {
244 std::cerr << "Caught ad-hoc exception: " << msg << std::endl;
245 return EXIT_FAILURE;
246 }
247 catch (const sw::universal::universal_arithmetic_exception& err) {
248 std::cerr << "Caught unexpected universal arithmetic exception : " << err.what() << std::endl;
249 return EXIT_FAILURE;
250 }
251 catch (const sw::universal::universal_internal_exception& err) {
252 std::cerr << "Caught unexpected universal internal exception: " << err.what() << std::endl;
253 return EXIT_FAILURE;
254 }
255 catch (const std::runtime_error& err) {
256 std::cerr << "Caught runtime exception: " << err.what() << std::endl;
257 return EXIT_FAILURE;
258 }
259 catch (...) {
260 std::cerr << "Caught unknown exception" << std::endl;
261 return EXIT_FAILURE;
262 }
263