diff --git a/CMakeLists.txt b/CMakeLists.txt index 5489ac6e7..79d5939f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,7 @@ if(NOT DEFINED UNIVERSAL_VERSION_MAJOR) set(UNIVERSAL_VERSION_MAJOR 3) endif() if(NOT DEFINED UNIVERSAL_VERSION_MINOR) - set(UNIVERSAL_VERSION_MINOR 42) + set(UNIVERSAL_VERSION_MINOR 43) endif() if(NOT DEFINED UNIVERSAL_VERSION_PATCH) set(UNIVERSAL_VERSION_PATCH 1) @@ -77,9 +77,9 @@ option(USE_AVX2 "Build code with AVX2 ISA support" option(BUILD_ALL "Set to ON to build all components" OFF) # or subsets of the components option(BUILD_DEMONSTRATION "Set to ON to build all demonstration components" ON) -option(BUILD_NUMERICAL_CHECKS "Set to ON to build all the numerical components" OFF) +option(BUILD_NUMERICS "Set to ON to build all the numeric components" OFF) option(BUILD_BENCHMARKS "Set to ON to build all the benchmark components" OFF) -option(BUILD_REGRESSION_SUITES "Set to ON to build all the regression suites" OFF) +option(BUILD_NUMBER_SYSTEMS "Set to ON to build all the number systems" OFF) option(BUILD_MIXEDPRECISION_SDK "Set to ON to build the mixed-precision SDK" OFF) # or, build individual components @@ -90,12 +90,12 @@ option(BUILD_EDUCATION "Set to ON to build educational example option(BUILD_APPLICATIONS "Set to ON to build application examples" OFF) # numerical and special math functions -option(BUILD_NUMERICAL_CHALLENGES "Set to ON to build numerical challenge programs" OFF) -option(BUILD_NUMERICAL_UTILS "Set to ON to build numerical utilities" OFF) -option(BUILD_FPBENCH "Set to ON to build fpbench benchmarks" OFF) -option(BUILD_FUNCTIONS "Set to ON to build special functions programs" OFF) +option(BUILD_NUMERIC_CHALLENGES "Set to ON to build numerical challenge programs" OFF) +option(BUILD_NUMERIC_UTILS "Set to ON to build numerical utilities" OFF) +option(BUILD_NUMERIC_FPBENCH "Set to ON to build fpbench benchmarks" OFF) +option(BUILD_NUMERIC_FUNCTIONS "Set to ON to build special functions programs" OFF) # reproducible IEEE-754 -option(BUILD_IEEE_FLOAT_QUIRES "Set to ON to build reproducible IEEE floats" OFF) +option(BUILD_NUMERIC_IEEE_QUIRES "Set to ON to build reproducible IEEE floats" OFF) # C API library and test programs @@ -104,25 +104,25 @@ option(BUILD_C_API_SHIM_LIB "Set to ON to build C API shim library" option(BUILD_C_API_LIB_PIC "Set to ON to compile C API library with -fPIC" OFF) # number systems and their verification suites -option(BUILD_ARITHMETIC_CLASSES "Set to ON to build arithmetic class tests" OFF) -option(BUILD_NATIVE_TYPES "Set to ON to build native type tests" OFF) -option(BUILD_INTEGERS "Set to ON to build integer tests" OFF) -option(BUILD_DECIMALS "Set to ON to build decimal tests" OFF) -option(BUILD_FIXPNTS "Set to ON to build fixed-point tests" OFF) -option(BUILD_CFLOATS "Set to ON to build cfloat tests" OFF) -option(BUILD_AREALS "Set to ON to build areal tests" OFF) -option(BUILD_UNUM_TYPE_1 "Set to ON to build unum Type 1 tests" OFF) -option(BUILD_UNUM_TYPE_2 "Set to ON to build unum Type 2 tests" OFF) -option(BUILD_POSITS "Set to ON to build unum Type 3 posit tests" OFF) -option(BUILD_VALIDS "Set to ON to build unum Type 3 valid tests" OFF) -option(BUILD_REALS "Set to ON to build real tests" OFF) -option(BUILD_LNS "Set to ON to build LNS tests" OFF) +option(BUILD_NUMBER_ARITHMETIC_CLASSES "Set to ON to build arithmetic class tests" OFF) +option(BUILD_NUMBER_NATIVE_TYPES "Set to ON to build native type tests" OFF) +option(BUILD_NUMBER_INTEGERS "Set to ON to build integer tests" OFF) +option(BUILD_NUMBER_DECIMALS "Set to ON to build decimal tests" OFF) +option(BUILD_NUMBER_FIXPNTS "Set to ON to build fixed-point tests" OFF) +option(BUILD_NUMBER_CFLOATS "Set to ON to build cfloat tests" OFF) +option(BUILD_NUMBER_AREALS "Set to ON to build areal tests" OFF) +option(BUILD_NUMBER_UNUM_TYPE_1 "Set to ON to build unum Type 1 tests" OFF) +option(BUILD_NUMBER_UNUM_TYPE_2 "Set to ON to build unum Type 2 tests" OFF) +option(BUILD_NUMBER_POSITS "Set to ON to build unum Type 3 posit tests" OFF) +option(BUILD_NUMBER_VALIDS "Set to ON to build unum Type 3 valid tests" OFF) +option(BUILD_NUMBER_REALS "Set to ON to build real tests" OFF) +option(BUILD_NUMBER_LNS "Set to ON to build LNS tests" OFF) # conversion test suites -option(BUILD_CONVERSIONS "Set to ON to build conversion test suites" OFF) +option(BUILD_NUMBER_CONVERSIONS "Set to ON to build conversion test suites" OFF) # Basic Linear Algebra tests -option(BUILD_BLAS "Set to ON to build the BLAS tests" OFF) -option(BUILD_VMATH "Set to ON to build the BLAS vector math lib" OFF) +option(BUILD_LINEAR_ALGEBRA_BLAS "Set to ON to build the BLAS tests" OFF) +option(BUILD_LINEAR_ALGEBRA_VMATH "Set to ON to build the BLAS vector math lib" OFF) # benchmarking option(BUILD_BENCHMARK_PERFORMANCE "Set to ON to build performance benchmarks" OFF) @@ -206,15 +206,24 @@ endif() # enable the regression testing level of the build if(BUILD_REGRESSION_SANITY OR BUILD_REGRESSION_LEVEL_1) add_definitions(-D REGRESSION_LEVEL_OVERRIDE) - add_definitions(-D REGRESSION_LEVEL_1) + add_definitions(-D REGRESSION_LEVEL_1=1) + add_definitions(-D REGRESSION_LEVEL_2=0) + add_definitions(-D REGRESSION_LEVEL_3=0) + add_definitions(-D REGRESSION_LEVEL_4=0) endif(BUILD_REGRESSION_SANITY OR BUILD_REGRESSION_LEVEL_1) if(BUILD_REGRESSION_LEVEL_2) add_definitions(-D REGRESSION_LEVEL_OVERRIDE) - add_definitions(-D REGRESSION_LEVEL_2) + add_definitions(-D REGRESSION_LEVEL_1=1) + add_definitions(-D REGRESSION_LEVEL_2=1) + add_definitions(-D REGRESSION_LEVEL_3=0) + add_definitions(-D REGRESSION_LEVEL_4=0) endif(BUILD_REGRESSION_LEVEL_2) if(BUILD_REGRESSION_LEVEL_3) add_definitions(-D REGRESSION_LEVEL_OVERRIDE) - add_definitions(-D REGRESSION_LEVEL_3) + add_definitions(-D REGRESSION_LEVEL_1=1) + add_definitions(-D REGRESSION_LEVEL_2=1) + add_definitions(-D REGRESSION_LEVEL_3=1) + add_definitions(-D REGRESSION_LEVEL_4=0) endif(BUILD_REGRESSION_LEVEL_3) if(BUILD_REGRESSION_STRESS OR BUILD_REGRESSION_LEVEL_4) add_definitions(-D REGRESSION_LEVEL_OVERRIDE) @@ -253,7 +262,6 @@ if(CMAKE_COMPILER_IS_GNUCXX OR MINGW OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") #set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -O3 -DNDEBUG") #set(EXTRA_C_FLAGS_DEBUG "${EXTRA_C_FLAGS_DEBUG} -g3 -pthread") - #set(EXTRA_CXX_FLAGS "-std=c++20") # isn't this done by CMAKE_CXX_STANDARD? elseif(MSVC) # Streaming SIMD Extension (SSE) ISA if (USE_SSE3) @@ -276,8 +284,8 @@ elseif(MSVC) # include code quality flags set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} /MP") - add_definitions(-D _CRT_SECURE_NO_WARNINGS) - add_definitions(-D _SCL_SECURE_NO_WARNINGS) +# add_definitions(-D _CRT_SECURE_NO_WARNINGS) +# add_definitions(-D _SCL_SECURE_NO_WARNINGS) # specific flags for debug and release builds @@ -345,7 +353,7 @@ elseif(MSVC) # The Spectre-mitigated libraries for Visual Studio 2017 and later can be downloaded # in the Visual Studio Installer. They're found in the Individual Components tab under # Compilers, build tools, and runtimes, and have "Libs for Spectre" in the name. - set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} /Qspectre") + # set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} /Qspectre") # /Qspectre is very noise, so do not include it for debug builds # set(EXTRA_C_FLAGS_DEBUG "${EXTRA_C_FLAGS_DEBUG} /Qspectre") @@ -530,22 +538,19 @@ install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/${project_library_target_name} if(BUILD_ALL) # set the grouped components to build (will trigger builds when tested) set(BUILD_DEMONSTRATION ON) - set(BUILD_NUMERICAL_CHECKS ON) + set(BUILD_NUMERICS ON) set(BUILD_BENCHMARKS ON) - set(BUILD_REGRESSION_SUITES ON) + set(BUILD_NUMBER_SYSTEMS ON) set(BUILD_MIXEDPRECISION_SDK ON) # build the BLAS test/verification suites - set(BUILD_BLAS ON) - set(BUILD_VMATH ON) + set(BUILD_LINEAR_ALGEBRA_BLAS ON) + set(BUILD_LINEAR_ALGEBRA_VMATH ON) # build the C API library set(BUILD_C_API_PURE_LIB ON) set(BUILD_C_API_SHIM_LIB ON) - # build IEEE float/double quire capability - set(BUILD_IEEE_FLOAT_QUIRES ON) - # build the HW validation environment set(BUILD_VALIDATION_HW ON) endif(BUILD_ALL) @@ -555,15 +560,15 @@ if(BUILD_DEMONSTRATION) set(BUILD_EDUCATION ON) set(BUILD_APPLICATIONS ON) set(BUILD_CMD_LINE_TOOLS ON) - set(BUILD_PLAYGROUND ON) endif(BUILD_DEMONSTRATION) -if(BUILD_NUMERICAL_CHECKS) - set(BUILD_NUMERICAL_CHALLENGES ON) - set(BUILD_NUMERICAL_UTILS ON) - set(BUILD_FUNCTIONS ON) -endif(BUILD_NUMERICAL_CHECKS) +if(BUILD_NUMERICS) + set(BUILD_NUMERIC_CHALLENGES ON) + set(BUILD_NUMERIC_UTILS ON) + set(BUILD_NUMERIC_FUNCTIONS ON) + set(BUILD_NUMERIC_IEEE_QUIRES ON) +endif(BUILD_NUMERICS) if(BUILD_BENCHMARKS) # build the benchmark suites @@ -572,25 +577,25 @@ if(BUILD_BENCHMARKS) set(BUILD_BENCHMARK_ENERGY ON) endif(BUILD_BENCHMARKS) -if(BUILD_REGRESSION_SUITES) +if(BUILD_NUMBER_SYSTEMS) # build the different test/verification suites for each number system - set(BUILD_ARITHMETIC_CLASSES ON) - set(BUILD_NATIVE_TYPES ON) - set(BUILD_REALS ON) - set(BUILD_INTEGERS ON) - set(BUILD_DECIMALS ON) - set(BUILD_FIXPNTS ON) - set(BUILD_CFLOATS ON) - set(BUILD_AREALS ON) - set(BUILD_UNUM_TYPE_1 ON) - set(BUILD_UNUM_TYPE_2 ON) - set(BUILD_POSITS ON) - set(BUILD_VALIDS ON) - set(BUILD_LNS ON) + set(BUILD_NUMBER_ARITHMETIC_CLASSES ON) + set(BUILD_NUMBER_NATIVE_TYPES ON) + set(BUILD_NUMBER_REALS ON) + set(BUILD_NUMBER_INTEGERS ON) + set(BUILD_NUMBER_DECIMALS ON) + set(BUILD_NUMBER_FIXPNTS ON) + set(BUILD_NUMBER_CFLOATS ON) + set(BUILD_NUMBER_AREALS ON) + set(BUILD_NUMBER_UNUM_TYPE_1 ON) + set(BUILD_NUMBER_UNUM_TYPE_2 ON) + set(BUILD_NUMBER_POSITS ON) + set(BUILD_NUMBER_VALIDS ON) + set(BUILD_NUMBER_LNS ON) # build the conversion test suites - set(BUILD_CONVERSIONS ON) -endif(BUILD_REGRESSION_SUITES) + set(BUILD_NUMBER_CONVERSIONS ON) +endif(BUILD_NUMBER_SYSTEMS) if(BUILD_MIXEDPRECISION_SDK) set(BUILD_MIXEDPRECISION_ROOTS ON) @@ -602,74 +607,74 @@ if(BUILD_MIXEDPRECISION_SDK) endif(BUILD_MIXEDPRECISION_SDK) # Build the tests for the underlying storage classes -if(BUILD_ARITHMETIC_CLASSES) +if(BUILD_NUMBER_ARITHMETIC_CLASSES) add_subdirectory("tests/bitblock") add_subdirectory("tests/value") add_subdirectory("tests/blockbinary") add_subdirectory("tests/blockfraction") add_subdirectory("tests/blocktriple") -endif(BUILD_ARITHMETIC_CLASSES) +endif(BUILD_NUMBER_ARITHMETIC_CLASSES) -if(BUILD_NATIVE_TYPES) +if(BUILD_NUMBER_NATIVE_TYPES) add_subdirectory("tests/native") -endif(BUILD_NATIVE_TYPES) +endif(BUILD_NUMBER_NATIVE_TYPES) # Arbitrary integers tests -if(BUILD_INTEGERS) +if(BUILD_NUMBER_INTEGERS) add_subdirectory("tests/integer") add_subdirectory("tests/adaptiveint") -endif(BUILD_INTEGERS) +endif(BUILD_NUMBER_INTEGERS) -if(BUILD_DECIMALS) +if(BUILD_NUMBER_DECIMALS) add_subdirectory("tests/decimal") -endif(BUILD_DECIMALS) +endif(BUILD_NUMBER_DECIMALS) # Arbitrary fixed-point tests -if(BUILD_FIXPNTS) +if(BUILD_NUMBER_FIXPNTS) add_subdirectory("tests/fixpnt") -endif(BUILD_FIXPNTS) +endif(BUILD_NUMBER_FIXPNTS) # Arbitrary reals tests -if(BUILD_REALS) +if(BUILD_NUMBER_REALS) add_subdirectory("tests/adaptivefloat") -endif(BUILD_REALS) +endif(BUILD_NUMBER_REALS) -if(BUILD_LNS) +if(BUILD_NUMBER_LNS) add_subdirectory("tests/lns") -endif(BUILD_LNS) +endif(BUILD_NUMBER_LNS) -if(BUILD_UNUM_TYPE_1) +if(BUILD_NUMBER_UNUM_TYPE_1) add_subdirectory("tests/unum") -endif(BUILD_UNUM_TYPE_1) +endif(BUILD_NUMBER_UNUM_TYPE_1) -if(BUILD_UNUM_TYPE_2) +if(BUILD_NUMBER_UNUM_TYPE_2) add_subdirectory("tests/unum2") -endif(BUILD_UNUM_TYPE_2) +endif(BUILD_NUMBER_UNUM_TYPE_2) -if(BUILD_POSITS) +if(BUILD_NUMBER_POSITS) add_subdirectory("tests/posit") add_subdirectory("tests/posit/specialized") add_subdirectory("tests/adaptiveposit") -endif(BUILD_POSITS) +endif(BUILD_NUMBER_POSITS) -if(BUILD_VALIDS) +if(BUILD_NUMBER_VALIDS) add_subdirectory("tests/valid") -endif(BUILD_VALIDS) +endif(BUILD_NUMBER_VALIDS) # reals with an uncertainty bit -if(BUILD_AREALS) +if(BUILD_NUMBER_AREALS) add_subdirectory("tests/areal") -endif(BUILD_AREALS) +endif(BUILD_NUMBER_AREALS) # cfloats -if(BUILD_CFLOATS) +if(BUILD_NUMBER_CFLOATS) add_subdirectory("tests/cfloat") -endif(BUILD_CFLOATS) +endif(BUILD_NUMBER_CFLOATS) # conversion tests suites -if(BUILD_CONVERSION_TESTS) +if(BUILD_NUMBER_CONVERSIONS) add_subdirectory("tests/conversions") -endif(BUILD_CONVERSION_TESTS) +endif(BUILD_NUMBER_CONVERSIONS) if(BUILD_MIXEDPRECISION_ROOTS) @@ -754,24 +759,23 @@ add_subdirectory("applications/weather") endif(BUILD_APPLICATIONS) # numerical benchmarks and challenge problems -if(BUILD_NUMERICAL_CHALLENGES) +if(BUILD_NUMERIC_CHALLENGES) add_subdirectory("tests/numerical/properties") -endif(BUILD_NUMERICAL_CHALLENGES) -if(BUILD_NUMERICAL_UTILS) +endif(BUILD_NUMERIC_CHALLENGES) +if(BUILD_NUMERIC_UTILS) add_subdirectory("tests/numerical/utils") -endif(BUILD_NUMERICAL_UTILS) -if(BUILD_FPBENCH) +endif(BUILD_NUMERIC_UTILS) +if(BUILD_NUMERIC_FPBENCH) add_subdirectory("tests/numerical/fpbench") -endif(BUILD_FPBENCH) +endif(BUILD_NUMERIC_FPBENCH) +if(BUILD_NUMERIC_FUNCTIONS) +add_subdirectory("tests/functions") +endif(BUILD_NUMERIC_FUNCTIONS) if(BUILD_VALIDATION_HW) add_subdirectory("validation/hw") endif(BUILD_VALIDATION_HW) -if(BUILD_FUNCTIONS) -add_subdirectory("tests/functions") -endif(BUILD_FUNCTIONS) - if(BUILD_PLAYGROUND) add_subdirectory("playground") endif(BUILD_PLAYGROUND) @@ -793,10 +797,12 @@ add_subdirectory("tests/float") endif(BUILD_IEEE_FLOAT_QUIRES) # Basic Linear Algebra library -if(BUILD_BLAS) +if(BUILD_LINEAR_ALGEBRA_BLAS) add_subdirectory("tests/blas") +endif(BUILD_LINEAR_ALGEBRA_BLAS) +if(BUILD_LINEAR_ALGEBRA_VMATH) add_subdirectory("tests/vmath") -endif(BUILD_BLAS) +endif(BUILD_LINEAR_ALGEBRA_VMATH) #### # Configuration summary diff --git a/Dockerfile b/Dockerfile index 01e3cdc88..72aba0f54 100644 --- a/Dockerfile +++ b/Dockerfile @@ -52,7 +52,7 @@ RUN cmake -DBUILD_ALL=ON .. && make # the command 'make test' is run as part of the CI test pipeline of the release container # add a command that when you run the container without a command, it produces something meaningful -CMD ["echo", "Universal Numbers Library Builder Version 3.41.1"] +CMD ["echo", "Universal Numbers Library Builder Version 3.43.1"] # RELEASE stage @@ -110,4 +110,4 @@ WORKDIR /home/stillwater/universal/build # the command 'make test' is run as part of the CI test pipeline of this release container -CMD ["echo", "Universal Numbers Library Version 3.41.1"] +CMD ["echo", "Universal Numbers Library Version 3.43.1"] diff --git a/education/number/fixpnt/basic_operators.cpp b/education/number/fixpnt/basic_operators.cpp index c0ec03538..ad20c4d55 100644 --- a/education/number/fixpnt/basic_operators.cpp +++ b/education/number/fixpnt/basic_operators.cpp @@ -3,12 +3,13 @@ // Copyright (C) 2017-2021 Stillwater Supercomputing, Inc. // // This file is part of the universal numbers project, which is released under an MIT Open Source license. +#include #include -// quick helper to report on a posit's specialness +// quick helper to report on a fixpnt's specialness template -void checkSpecialCases(sw::universal::fixpnt p) { - std::cout << "fixpnt is " << (p.iszero() ? "zero " : "non-zero ") << (p.ispos() ? "positive " : "negative ") << std::endl; +void checkSpecialCases(sw::universal::fixpnt fp) { + std::cout << "fixpnt is " << (fp.iszero() ? "zero " : "non-zero ") << (fp.ispos() ? "positive " : "negative ") << std::endl; } // Demonstrate basic arithmetic with fixpnt numbers diff --git a/education/number/fixpnt/ranges.cpp b/education/number/fixpnt/ranges.cpp new file mode 100644 index 000000000..eee9b63fa --- /dev/null +++ b/education/number/fixpnt/ranges.cpp @@ -0,0 +1,67 @@ +// ranges.cpp : examples of fixpnt ranges +// +// Copyright (C) 2017-2021 Stillwater Supercomputing, Inc. +// +// This file is part of the universal numbers project, which is released under an MIT Open Source license. +#include +#include + +// print fixed-point ranges +int main() +try { + using namespace sw::universal; // standard namespace for fixpnt + + // value ranges of interesting fixed-point configurations + + // integers to understand the range + std::cout << "Fixed-points with only integer bits\n"; + ReportFixedPointRanges(std::cout, fixpnt< 4, 0, Modulo, uint16_t>()); + ReportFixedPointRanges(std::cout, fixpnt< 8, 0, Modulo, uint16_t>()); + ReportFixedPointRanges(std::cout, fixpnt<12, 0, Modulo, uint16_t>()); + ReportFixedPointRanges(std::cout, fixpnt<16, 0, Modulo, uint16_t>()); + ReportFixedPointRanges(std::cout, fixpnt<20, 0, Modulo, uint16_t>()); + ReportFixedPointRanges(std::cout, fixpnt<24, 0, Modulo, uint16_t>()); + ReportFixedPointRanges(std::cout, fixpnt<28, 0, Modulo, uint16_t>()); + ReportFixedPointRanges(std::cout, fixpnt<32, 0, Modulo, uint16_t>()); + std::cout << '\n'; + + // divide half the bits to integer and half to fraction + std::cout << "Fixed-points that evenly divide bits between integer and fraction bits\n"; + ReportFixedPointRanges(std::cout, fixpnt< 4, 2, Modulo, uint16_t>()); + ReportFixedPointRanges(std::cout, fixpnt< 8, 4, Modulo, uint16_t>()); + ReportFixedPointRanges(std::cout, fixpnt<12, 6, Modulo, uint16_t>()); + ReportFixedPointRanges(std::cout, fixpnt<16, 8, Modulo, uint16_t>()); + ReportFixedPointRanges(std::cout, fixpnt<20, 10, Modulo, uint16_t>()); + ReportFixedPointRanges(std::cout, fixpnt<24, 12, Modulo, uint16_t>()); + ReportFixedPointRanges(std::cout, fixpnt<28, 14, Modulo, uint16_t>()); + ReportFixedPointRanges(std::cout, fixpnt<32, 16, Modulo, uint16_t>()); + std::cout << '\n'; + + // allocate all bits to the fraction + std::cout << "Fixed-points with only fraction bits\n"; + ReportFixedPointRanges(std::cout, fixpnt< 4, 4, Modulo, uint16_t>()); + ReportFixedPointRanges(std::cout, fixpnt< 8, 8, Modulo, uint16_t>()); + ReportFixedPointRanges(std::cout, fixpnt<12, 12, Modulo, uint16_t>()); + ReportFixedPointRanges(std::cout, fixpnt<16, 16, Modulo, uint16_t>()); + ReportFixedPointRanges(std::cout, fixpnt<20, 20, Modulo, uint16_t>()); + ReportFixedPointRanges(std::cout, fixpnt<24, 24, Modulo, uint16_t>()); + ReportFixedPointRanges(std::cout, fixpnt<28, 28, Modulo, uint16_t>()); + ReportFixedPointRanges(std::cout, fixpnt<32, 32, Modulo, uint16_t>()); + std::cout << '\n'; + + + // a super accumulator for single precision posits: quire<512,240>\n"; + // unfortunately, this does not produce a readable range spec, :-( + // ReportFixedPointRanges(std::cout, fixpnt<512, 240, Modulo, uint32_t>()); + + std::cout.flush(); + return EXIT_SUCCESS; +} +catch (char const* msg) { + std::cerr << msg << std::endl; + return EXIT_FAILURE; +} +catch (...) { + std::cerr << "Caught unknown exception" << std::endl; + return EXIT_FAILURE; +} diff --git a/education/tables/fixpnts.cpp b/education/tables/fixpnts.cpp index edfb67d51..7605d13d2 100644 --- a/education/tables/fixpnts.cpp +++ b/education/tables/fixpnts.cpp @@ -14,11 +14,7 @@ // second: enable/disable fixpnt arithmetic exceptions #define FIXPNT_THROW_ARITHMETIC_EXCEPTION 1 -// minimum set of include files to reflect source code dependencies -#include -#include -#include -#include // ReportTestResult +#include #include // generate a full binary representation table for a given posit configuration @@ -81,7 +77,6 @@ try { } std::cout << "Generate value tables for fixpnt configurations\n"; - GenerateFixedPointTable<4, 0>(std::cout, csv); GenerateFixedPointTable<4, 1>(std::cout, csv); GenerateFixedPointTable<4, 2>(std::cout, csv); diff --git a/include/universal/common/numeric_limits_utility.hpp b/include/universal/common/numeric_limits_utility.hpp index ab59cd764..4c3817403 100644 --- a/include/universal/common/numeric_limits_utility.hpp +++ b/include/universal/common/numeric_limits_utility.hpp @@ -8,7 +8,7 @@ namespace sw::universal { // a standard table format for numeric_limits<> of type Scalar -template +template void numberTraits(std::ostream& ostr) { using namespace std; @@ -29,7 +29,7 @@ void numberTraits(std::ostream& ostr) { } // compare numeric_limits of two Real types -template +template void compareNumberTraits(std::ostream& ostr) { using namespace std; diff --git a/include/universal/internal/bitblock/bitblock.hpp b/include/universal/internal/bitblock/bitblock.hpp index ab58b535f..8901e4b4d 100644 --- a/include/universal/internal/bitblock/bitblock.hpp +++ b/include/universal/internal/bitblock/bitblock.hpp @@ -441,11 +441,13 @@ void integer_divide_unsigned(const bitblock& a, const bitblock(operand_size) - msb - 1; // prepare the subtractand subtractand = b; - subtractand <<= shift; - for (int i = operand_size - msb - 1; i >= 0; --i) { + subtractand <<= static_cast(shift); +// for (int i = operand_size - msb - 1; i >= 0; --i) { + for (int i = shift; i >= 0; --i) { + if (subtractand <= accumulator) { #ifdef DEBUG bool borrow = subtract(accumulator, subtractand); @@ -453,12 +455,12 @@ void integer_divide_unsigned(const bitblock& a, const bitblock(i)); } else { - result.reset(i); + result.reset(static_cast(i)); } - subtractand >>= 1; + subtractand >>= 1ull; } } } diff --git a/include/universal/internal/blockbinary/blockbinary.hpp b/include/universal/internal/blockbinary/blockbinary.hpp index d7b5551dc..8b0859b1a 100644 --- a/include/universal/internal/blockbinary/blockbinary.hpp +++ b/include/universal/internal/blockbinary/blockbinary.hpp @@ -8,6 +8,12 @@ #include #include +// should be defined by calling environment, just catching it here just in case it is not +#ifndef LONG_DOUBLE_SUPPORT +#pragma message("LONG_DOUBLE_SUPPORT is not defined") +#define LONG_DOUBLE_SUPPORT 0 +#endif + namespace sw::universal { // forward references @@ -386,7 +392,7 @@ class blockbinary { return (word & mask); } inline constexpr uint8_t nibble(size_t n) const noexcept { - uint8_t retval; + uint8_t retval{ 0 }; if (n < (1 + ((nbits - 1) >> 2))) { bt word = _block[(n * 4) / bitsInBlock]; size_t nibbleIndexInWord = n % (bitsInBlock >> 2); diff --git a/include/universal/internal/blocktriple/blocktriple.hpp b/include/universal/internal/blocktriple/blocktriple.hpp index 0bdb73248..f74d39b89 100644 --- a/include/universal/internal/blocktriple/blocktriple.hpp +++ b/include/universal/internal/blocktriple/blocktriple.hpp @@ -10,6 +10,11 @@ #include // check on required compilation guards +// should be defined by calling environment, just catching it here just in case it is not +#ifndef LONG_DOUBLE_SUPPORT +#pragma message("LONG_DOUBLE_SUPPORT is not defined") +#define LONG_DOUBLE_SUPPORT 0 +#endif #if !defined(BIT_CAST_SUPPORT) #pragma message("BIT_CAST_SUPPORT is not defined") #define BIT_CAST_SUPPORT 0 diff --git a/include/universal/native/ieee754.hpp b/include/universal/native/ieee754.hpp index 494cfe025..5a9694448 100644 --- a/include/universal/native/ieee754.hpp +++ b/include/universal/native/ieee754.hpp @@ -9,6 +9,8 @@ #include // for frexpf/frexp/frexpl float/double/long double fraction/exponent extraction #include #include +#include +#include namespace sw::universal { @@ -16,22 +18,27 @@ namespace sw::universal { template class ieee754_parameter { public: - static constexpr int nbits = 0; // number of bits total - static constexpr uint64_t smask = 0; // mask of the sign field - static constexpr int ebits = 0; // number of exponent bits - static constexpr int bias = 0; // exponent bias - static constexpr uint64_t emask = 0; // mask of the exponent field - static constexpr uint64_t eallset = 0; // mask of exponent value - static constexpr int fbits = 0; // number of fraction bits - static constexpr uint64_t hmask = 0; // mask of the hidden bit - static constexpr uint64_t fmask = 0; // mask of the fraction field - static constexpr uint64_t hfmask = 0; // mask of the signficicant field, i.e. hidden bit + fraction bits - static constexpr uint64_t fmsb = 0; // mask of the most significant fraction bit - static constexpr uint64_t qnanmask = 0; // mask of quiet NaN - static constexpr uint64_t snanmask = 0; // mask of signalling NaN + static constexpr int nbits = 0; // number of bits total + static constexpr uint64_t smask = 0; // mask of the sign field + static constexpr int ebits = 0; // number of exponent bits + static constexpr int bias = 0; // exponent bias + static constexpr uint64_t emask = 0; // mask of the exponent field + static constexpr uint64_t eallset = 0; // mask of exponent value + static constexpr int fbits = 0; // number of fraction bits + static constexpr uint64_t hmask = 0; // mask of the hidden bit + static constexpr uint64_t fmask = 0; // mask of the fraction field + static constexpr uint64_t hfmask = 0; // mask of the signficicant field, i.e. hidden bit + fraction bits + static constexpr uint64_t fmsb = 0; // mask of the most significant fraction bit + static constexpr uint64_t qnanmask = 0; // mask of quiet NaN + static constexpr uint64_t snanmask = 0; // mask of signalling NaN + static constexpr Real minNormal = 0.0; // value of smallest normal value + static constexpr Real minSubnormal = 0.0; // value of the smallest subnormal value + static constexpr int minNormalExp = 0; // exponent value of smallest normal value + static constexpr int minSubnormalExp = 0; // exponent value of smallest subnormal value }; // IEEE-754 parameter specializations are in the compiler specific sections + } // compiler specializations for IEEE-754 parameters @@ -53,6 +60,32 @@ namespace sw::universal { namespace sw::universal { + + template + std::ostream& operator<<(std::ostream& ostr, const ieee754_parameter& v) { + ostr << "Total number of bits : " << v.nbits << '\n'; + ostr << "number of exponent bits : " << v.ebits << '\n'; // number of exponent bits + ostr << "number of fraction bits : " << v.fbits << '\n'; // number of fraction bits + ostr << "exponent bias : " << v.bias << '\n'; // exponent bias + ostr << "sign field mask : " << to_binary(v.smask, v.nbits, true) << '\n'; // mask of the sign field + ostr << "exponent field mask : " << to_binary(v.emask, v.nbits, true) << '\n'; // mask of the exponent field + ostr << "mask of exponent value : " << to_binary(v.eallset, v.ebits, true) << '\n'; // mask of exponent value + + ostr << "mask of hidden bit : " << to_binary(v.hmask, v.nbits, true) << '\n'; // mask of the hidden bit + ostr << "fraction field mask : " << to_binary(v.fmask, v.nbits, true) << '\n'; // mask of the fraction field + ostr << "significant field mask : " << to_binary(v.hfmask, v.nbits, true) << '\n'; // mask of the signficicant field, i.e. hidden bit + fraction bits + ostr << "MSB fraction bit mask : " << to_binary(v.fmsb, v.nbits, true) << '\n'; // mask of the most significant fraction bit + ostr << "qNaN pattern : " << to_binary(v.qnanmask, v.nbits, true) << '\n'; // mask of quiet NaN + ostr << "sNaN pattern : " << to_binary(v.snanmask, v.nbits, true) << '\n'; // mask of signalling NaN + ostr << "smallest normal value : " << v.minNormal << '\n'; // value of smallest normal value + ostr << " : " << to_binary(v.minNormal) << '\n'; + ostr << "smallest subnormal value : " << v.minSubnormal << '\n'; // value of the smallest subnormal value + ostr << " : " << to_binary(v.minSubnormal) << '\n'; + ostr << "exponent smallest normal : " << v.minNormalExp << '\n'; // exponent value of smallest normal value + ostr << "exponent smallest subnormal : " << v.minSubnormalExp << '\n'; // exponent value of smallest subnormal value + return ostr; + } + //////////////////////////////////////////////////////////////////////// // numerical helpers diff --git a/include/universal/native/ieee754_clang.hpp b/include/universal/native/ieee754_clang.hpp index 6b362681e..280bf699c 100644 --- a/include/universal/native/ieee754_clang.hpp +++ b/include/universal/native/ieee754_clang.hpp @@ -28,6 +28,10 @@ class ieee754_parameter { static constexpr uint64_t fmsb = 0x0040'0000ull; static constexpr uint64_t qnanmask = 0x7FC0'0000ull; static constexpr uint64_t snanmask = 0x7FA0'0000ull; + static constexpr float minNormal = 1.1754943508222875079687365372222e-38f; // == 2^-126 + static constexpr float minSubnormal = 1.4012984643248170709237295832899e-45f; // == 2^-149 + static constexpr int minNormalExp = -126; + static constexpr int minSubnormalExp = -149; }; template<> @@ -46,6 +50,10 @@ class ieee754_parameter { static constexpr uint64_t fmsb = 0x0008'0000'0000'0000ull; static constexpr uint64_t qnanmask = 0x7FF8'0000'0000'0000ull; static constexpr uint64_t snanmask = 0x7FF4'0000'0000'0000ull; + static constexpr double minNormal = 2.2250738585072013830902327173324e-308; // == 2^-1022 + static constexpr double minSubnormal = 4.9406564584124654417656879286220e-324; // == 2^-1074 + static constexpr int minNormalExp = -1022; + static constexpr int minSubnormalExp = -1074; }; // CLang long double = 80 bit extended precision @@ -67,6 +75,10 @@ class ieee754_parameter { static constexpr uint64_t fmsb = 0x8000'0000'0000'0000ull; static constexpr uint64_t qnanmask = 0x7FF8'0000'0000'0000ull; static constexpr uint64_t snanmask = 0x7FF4'0000'0000'0000ull; + static constexpr long double minNormal = 3.3621031431120935062626778173218e-4932l; // == 2^-16382 + static constexpr long double minSubnormal = 3.6451995318824746025284059336194e-4951l; // == 2^-16445 + static constexpr int minNormalExp = -16382; + static constexpr int minSubnormalExp = -16445; }; } // namespace sw::universal diff --git a/include/universal/native/ieee754_gcc.hpp b/include/universal/native/ieee754_gcc.hpp index effa533c4..a0c4d0e3a 100644 --- a/include/universal/native/ieee754_gcc.hpp +++ b/include/universal/native/ieee754_gcc.hpp @@ -28,6 +28,10 @@ class ieee754_parameter { static constexpr uint64_t fmsb = 0x0040'0000ull; static constexpr uint64_t qnanmask = 0x7FC0'0000ull; static constexpr uint64_t snanmask = 0x7FA0'0000ull; + static constexpr float minNormal = 1.1754943508222875079687365372222e-38f; // == 2^-126 + static constexpr float minSubnormal = 1.4012984643248170709237295832899e-45f; // == 2^-149 + static constexpr int minNormalExp = -126; + static constexpr int minSubnormalExp = -149; }; template<> @@ -46,7 +50,12 @@ class ieee754_parameter { static constexpr uint64_t fmsb = 0x0008'0000'0000'0000ull; static constexpr uint64_t qnanmask = 0x7FF8'0000'0000'0000ull; static constexpr uint64_t snanmask = 0x7FF4'0000'0000'0000ull; + static constexpr double minNormal = 2.2250738585072013830902327173324e-308; // == 2^-1022 + static constexpr double minSubnormal = 4.9406564584124654417656879286220e-324; // == 2^-1074 + static constexpr int minNormalExp = -1022; + static constexpr int minSubnormalExp = -1074; }; + // GNU long double = 80 bit extended precision // // IEEE-754 parameter constexpressions for long double @@ -66,6 +75,10 @@ class ieee754_parameter { static constexpr uint64_t fmsb = 0x8000'0000'0000'0000ull; static constexpr uint64_t qnanmask = 0x7FF8'0000'0000'0000ull; static constexpr uint64_t snanmask = 0x7FF4'0000'0000'0000ull; + static constexpr long double minNormal = 3.3621031431120935062626778173218e-4932l; // == 2^-16382 + static constexpr long double minSubnormal = 3.6451995318824746025284059336194e-4951l; // == 2^-16445 + static constexpr int minNormalExp = -16382; + static constexpr int minSubnormalExp = -16445; }; } // namespace sw::universal diff --git a/include/universal/native/ieee754_msvc.hpp b/include/universal/native/ieee754_msvc.hpp index b2a0815c7..bfeeec9b1 100644 --- a/include/universal/native/ieee754_msvc.hpp +++ b/include/universal/native/ieee754_msvc.hpp @@ -15,36 +15,44 @@ namespace sw::universal { template<> class ieee754_parameter { public: - static constexpr int nbits = 32; - static constexpr uint64_t smask = 0x8000'0000ull; - static constexpr int ebits = 8; - static constexpr int bias = 127; - static constexpr uint64_t emask = 0x7F80'0000ull; - static constexpr uint64_t eallset = 0xFFull; - static constexpr int fbits = 23; - static constexpr uint64_t hmask = 0x0080'0000ull; - static constexpr uint64_t fmask = 0x007F'FFFFull; - static constexpr uint64_t hfmask = 0x00FF'FFFFull; - static constexpr uint64_t fmsb = 0x0040'0000ull; - static constexpr uint64_t qnanmask = 0x7FC0'0000ull; - static constexpr uint64_t snanmask = 0x7FC0'0001ull; + static constexpr int nbits = 32; + static constexpr uint64_t smask = 0x8000'0000ull; + static constexpr int ebits = 8; + static constexpr int bias = 127; + static constexpr uint64_t emask = 0x7F80'0000ull; + static constexpr uint64_t eallset = 0xFFull; + static constexpr int fbits = 23; + static constexpr uint64_t hmask = 0x0080'0000ull; + static constexpr uint64_t fmask = 0x007F'FFFFull; + static constexpr uint64_t hfmask = 0x00FF'FFFFull; + static constexpr uint64_t fmsb = 0x0040'0000ull; + static constexpr uint64_t qnanmask = 0x7FC0'0000ull; + static constexpr uint64_t snanmask = 0x7FC0'0001ull; + static constexpr float minNormal = 1.1754943508222875079687365372222e-38f; // == 2^-126 + static constexpr float minSubnormal = 1.4012984643248170709237295832899e-45f; // == 2^-149 + static constexpr int minNormalExp = -126; + static constexpr int minSubnormalExp = -149; }; template<> class ieee754_parameter { public: - static constexpr int nbits = 64; - static constexpr uint64_t smask = 0x8000'0000'0000'0000ull; - static constexpr int ebits = 11; - static constexpr int bias = 1023; - static constexpr uint64_t emask = 0x7FF0'0000'0000'0000ull; - static constexpr uint64_t eallset = 0x7FF; - static constexpr int fbits = 52; - static constexpr uint64_t hmask = 0x0010'0000'0000'0000ull; - static constexpr uint64_t fmask = 0x000F'FFFF'FFFF'FFFFull; - static constexpr uint64_t hfmask = 0x001F'FFFF'FFFF'FFFFull; - static constexpr uint64_t fmsb = 0x0008'0000'0000'0000ull; - static constexpr uint64_t qnanmask = 0x7FF8'0000'0000'0000ull; - static constexpr uint64_t snanmask = 0x7FF0'0000'0000'0001ull; + static constexpr int nbits = 64; + static constexpr uint64_t smask = 0x8000'0000'0000'0000ull; + static constexpr int ebits = 11; + static constexpr int bias = 1023; + static constexpr uint64_t emask = 0x7FF0'0000'0000'0000ull; + static constexpr uint64_t eallset = 0x7FF; + static constexpr int fbits = 52; + static constexpr uint64_t hmask = 0x0010'0000'0000'0000ull; + static constexpr uint64_t fmask = 0x000F'FFFF'FFFF'FFFFull; + static constexpr uint64_t hfmask = 0x001F'FFFF'FFFF'FFFFull; + static constexpr uint64_t fmsb = 0x0008'0000'0000'0000ull; + static constexpr uint64_t qnanmask = 0x7FF8'0000'0000'0000ull; + static constexpr uint64_t snanmask = 0x7FF0'0000'0000'0001ull; + static constexpr double minNormal = 2.2250738585072013830902327173324e-308; // == 2^-1022 + static constexpr double minSubnormal = 4.9406564584124654417656879286220e-324; // == 2^-1074 + static constexpr int minNormalExp = -1022; + static constexpr int minSubnormalExp = -1074; }; // MSVC long double = double precision @@ -65,6 +73,10 @@ class ieee754_parameter { static constexpr uint64_t fmsb = 0x0008'0000'0000'0000ull; static constexpr uint64_t qnanmask = 0x7FF8'0000'0000'0000ull; static constexpr uint64_t snanmask = 0x7FF0'0000'0000'0001ull; + static constexpr long double minNormal = 2.2250738585072013830902327173324e-308; // == 2^-1022 + static constexpr long double minSubnormal = 4.9406564584124654417656879286220e-324; // == 2^-1074 + static constexpr int minNormalExp = -1022; + static constexpr int minSubnormalExp = -1074; }; } // namespace sw::universal diff --git a/include/universal/number/areal/areal.hpp b/include/universal/number/areal/areal.hpp index 83e673f96..fb2cb95d5 100644 --- a/include/universal/number/areal/areal.hpp +++ b/include/universal/number/areal/areal.hpp @@ -6,6 +6,14 @@ #ifndef _AREAL_STANDARD_HEADER_ #define _AREAL_STANDARD_HEADER_ +//////////////////////////////////////////////////////////////////////////////////////// +/// COMPILATION DIRECTIVES TO DIFFERENT COMPILERS + +// compiler specific configuration for long double support +#include +// compiler specific configuration for C++20 bit_cast +#include + //////////////////////////////////////////////////////////////////////////////////////// /// BEHAVIORAL COMPILATION SWITCHES diff --git a/include/universal/number/areal/areal_impl.hpp b/include/universal/number/areal/areal_impl.hpp index 6cc76184f..15b85f4c7 100644 --- a/include/universal/number/areal/areal_impl.hpp +++ b/include/universal/number/areal/areal_impl.hpp @@ -1036,17 +1036,17 @@ class areal { void constexprClassParameters() const { std::cout << "nbits : " << nbits << '\n'; std::cout << "es : " << es << std::endl; - std::cout << "ALLONES : " << to_binary(ALLONES, true) << '\n'; - std::cout << "BLOCK_MASK : " << to_binary(BLOCK_MASK, true) << '\n'; + std::cout << "ALLONES : " << to_binary(ALLONES, bitsInBlock, true) << '\n'; + std::cout << "BLOCK_MASK : " << to_binary(BLOCK_MASK, bitsInBlock, true) << '\n'; std::cout << "nrBlocks : " << nrBlocks << '\n'; std::cout << "bits in MSU : " << bitsInMSU << '\n'; std::cout << "MSU : " << MSU << '\n'; - std::cout << "MSU MASK : " << to_binary(MSU_MASK, true) << '\n'; - std::cout << "SIGN_BIT_MASK : " << to_binary(SIGN_BIT_MASK, true) << '\n'; - std::cout << "LSB_BIT_MASK : " << to_binary(LSB_BIT_MASK, true) << '\n'; + std::cout << "MSU MASK : " << to_binary(MSU_MASK, bitsInBlock, true) << '\n'; + std::cout << "SIGN_BIT_MASK : " << to_binary(SIGN_BIT_MASK, bitsInBlock, true) << '\n'; + std::cout << "LSB_BIT_MASK : " << to_binary(LSB_BIT_MASK, bitsInBlock, true) << '\n'; std::cout << "MSU CAPTURES E : " << (MSU_CAPTURES_E ? "yes\n" : "no\n"); std::cout << "EXP_SHIFT : " << EXP_SHIFT << '\n'; - std::cout << "MSU EXP MASK : " << to_binary(MSU_EXP_MASK, true) << '\n'; + std::cout << "MSU EXP MASK : " << to_binary(MSU_EXP_MASK, bitsInBlock, true) << '\n'; std::cout << "EXP_BIAS : " << EXP_BIAS << '\n'; std::cout << "MAX_EXP : " << MAX_EXP << '\n'; std::cout << "MIN_EXP_NORMAL : " << MIN_EXP_NORMAL << '\n'; @@ -1460,6 +1460,7 @@ inline std::string to_binary(const areal& number, bool nibbleMark return ss.str(); } +#ifdef DEPRECATED // helper to report on BlockType blocks template inline std::string to_binary(const bt& number, bool nibbleMarker) { @@ -1476,6 +1477,7 @@ inline std::string to_binary(const bt& number, bool nibbleMarker) { } return ss.str(); } +#endif /// Magnitude of a scientific notation value (equivalent to turning the sign bit off). template diff --git a/include/universal/number/cfloat/cfloat.hpp b/include/universal/number/cfloat/cfloat.hpp index ec7640f65..11bec08ce 100644 --- a/include/universal/number/cfloat/cfloat.hpp +++ b/include/universal/number/cfloat/cfloat.hpp @@ -8,6 +8,10 @@ //////////////////////////////////////////////////////////////////////////////////////// /// COMPILATION DIRECTIVES TO DIFFERENT COMPILERS + +// compiler specific configuration for long double support +#include +// compiler specific configuration for C++20 bit_cast #include //////////////////////////////////////////////////////////////////////////////////////// diff --git a/include/universal/number/cfloat/cfloat_impl.hpp b/include/universal/number/cfloat/cfloat_impl.hpp index de05933b3..32d16e53d 100644 --- a/include/universal/number/cfloat/cfloat_impl.hpp +++ b/include/universal/number/cfloat/cfloat_impl.hpp @@ -4,10 +4,10 @@ // Copyright (C) 2017-2021 Stillwater Supercomputing, Inc. // // This file is part of the universal numbers project, which is released under an MIT Open Source license. -// compiler specific configuration for long double support -#include -// compiler specific configuration for C++20 bit_cast -#include + +// compiler specific environment has been delegated to be handled by the +// number system include file +// // supporting types and functions #include #include diff --git a/include/universal/number/fixpnt/attributes.hpp b/include/universal/number/fixpnt/attributes.hpp index cd348a513..a9e338018 100644 --- a/include/universal/number/fixpnt/attributes.hpp +++ b/include/universal/number/fixpnt/attributes.hpp @@ -31,18 +31,17 @@ int scale_minpos_fixpnt() { // generate the maxneg through maxpos value range of a fixed-point configuration // the type of arithmetic, Modulo or Saturating, does not affect the range -template -void ReportFixedPointRanges(std::ostream& ostr = std::cout) { +template +void ReportFixedPointRanges(std::ostream& ostr, const fixpnt& v) { using namespace std; - using FixedPoint = fixpnt; + using FixedPoint = fixpnt; FixedPoint fp; - ostr << "fixpnt<" << nbits << ", " << rbits << "> : " - << maxneg(fp) << " " - << minneg(fp) << " " + ostr << std::setw(40) << type_tag(v) << " : [ " + << fp.maxneg() << " ... " + << fp.minneg() << " " << "0 " - << minpos(fp) << " " - << maxpos(fp) - << endl; + << fp.minpos() << " ... " + << fp.maxpos() << " ]\n"; } template diff --git a/include/universal/number/fixpnt/fixpnt.hpp b/include/universal/number/fixpnt/fixpnt.hpp index 2dafb40cd..6fe797839 100644 --- a/include/universal/number/fixpnt/fixpnt.hpp +++ b/include/universal/number/fixpnt/fixpnt.hpp @@ -6,6 +6,14 @@ #ifndef _FIXPNT_STANDARD_HEADER_ #define _FIXPNT_STANDARD_HEADER_ +//////////////////////////////////////////////////////////////////////////////////////// +/// COMPILATION DIRECTIVES TO DIFFERENT COMPILERS + +// compiler specific configuration for long double support +#include +// compiler specific configuration for C++20 bit_cast +#include + //////////////////////////////////////////////////////////////////////////////////////// /// BEHAVIORAL COMPILATION SWITCHES diff --git a/include/universal/number/fixpnt/fixpnt_impl.hpp b/include/universal/number/fixpnt/fixpnt_impl.hpp index 7dd0889d9..362aff88e 100644 --- a/include/universal/number/fixpnt/fixpnt_impl.hpp +++ b/include/universal/number/fixpnt/fixpnt_impl.hpp @@ -83,7 +83,7 @@ inline int scale(const fixpnt& i) { } // calculate scale long scale = 0; - if (nbits > rbits + 1) { // subtle bug: in fixpnt numbers with only 1 bit before the radix point, '1' is maxneg, and thus while (v > 1) never completes + if constexpr (nbits > rbits + 1) { // subtle bug: in fixpnt numbers with only 1 bit before the radix point, '1' is maxneg, and thus while (v > 1) never completes v >>= rbits; while (v > 1) { ++scale; @@ -98,7 +98,7 @@ template inline constexpr fixpnt& convert(int64_t v, fixpnt& result) { if (0 == v) { result.setzero(); return result; } constexpr fixpnt maxpos(SpecificValue::maxpos), maxneg(SpecificValue::maxneg); - if (arithmetic == Saturating) { // check if we are in the representable range + if constexpr (arithmetic == Saturating) { // check if we are in the representable range if (v >= static_cast(maxpos)) { result = maxpos; return result; } if (v <= static_cast(maxneg)) { result = maxneg; return result; } } @@ -119,7 +119,7 @@ template inline constexpr fixpnt& convert_unsigned(uint64_t v, fixpnt& result) { if (0 == v) { result.setzero(); return result; } constexpr fixpnt maxpos(SpecificValue::maxpos), maxneg(SpecificValue::maxneg); - if (arithmetic == Saturating) { // check if we are in the representable range + if constexpr (arithmetic == Saturating) { // check if we are in the representable range if (v >= static_cast(maxpos)) { result = maxpos; return result; } if (v <= static_cast(maxneg)) { result = maxneg; return result; } } @@ -171,12 +171,16 @@ class fixpnt { // specific value constructor constexpr fixpnt(const SpecificValue code) : bb{ 0 } { switch (code) { + case SpecificValue::infpos: case SpecificValue::maxpos: maxpos(); break; case SpecificValue::minpos: minpos(); break; + case SpecificValue::qnan: + case SpecificValue::snan: + case SpecificValue::nar: case SpecificValue::zero: default: zero(); @@ -184,6 +188,7 @@ class fixpnt { case SpecificValue::minneg: minneg(); break; + case SpecificValue::infneg: case SpecificValue::maxneg: maxneg(); break; @@ -221,8 +226,7 @@ class fixpnt { fixpnt(unsigned long initial_value) noexcept { *this = initial_value; } fixpnt(unsigned long long initial_value) noexcept { *this = initial_value; } fixpnt(float initial_value) noexcept { *this = initial_value; } - fixpnt(double initial_value) noexcept { *this = initial_value; } - fixpnt(long double initial_value) noexcept { *this = initial_value; } + fixpnt(double initial_value) noexcept { *this = initial_value; } // access operator for bits // this needs a proxy to be able to create l-values @@ -241,141 +245,15 @@ class fixpnt { fixpnt& operator=(unsigned int rhs) { return convert_unsigned(rhs, *this); } fixpnt& operator=(unsigned long rhs) { return convert_unsigned(rhs, *this); } fixpnt& operator=(unsigned long long rhs) { return convert_unsigned(rhs, *this); } - fixpnt& operator=(float rhs) { - clear(); - if (rhs == 0.0) { - return *this; - } - if (arithmetic == Saturating) { // check if the value is in the representable range - fixpnt a; - a.maxpos(); - if (rhs >= float(a)) { return *this = a; } // set to max pos value - a.maxneg(); - if (rhs <= float(a)) { return *this = a; } // set to max neg value - } - float_decoder decoder; - decoder.f = rhs; - uint32_t raw = (1ul << 23ul) | decoder.parts.fraction; // TODO: this only works for normalized numbers 1.###, need a test for denorm - int radixPoint = 23 - (static_cast(decoder.parts.exponent) - 127); // move radix point to the right if scale > 0, left if scale < 0 - // our fixed-point has its radixPoint at rbits - int shiftRight = radixPoint - int(rbits); - // do we need to round? - if (shiftRight > 0) { - // yes, round the raw bits - // collect guard, round, and sticky bits - // this same logic will work for the case where - // we only have a guard bit and no round and/or sticky bits - // because the mask logic will make round and sticky both 0 - // so no need to special case it - uint32_t mask = (1ul << (shiftRight - 1)); - bool guard = (mask & raw); - mask >>= 1; - bool round = (mask & raw); - if (shiftRight > 1) { - mask = (0xFFFF'FFFFul << (shiftRight - 2)); - mask = ~mask; - } - else { - mask = 0; - } - bool sticky = (mask & raw); - - raw >>= shiftRight; // shift out the bits we are rounding away - bool lsb = (raw & 0x1ul); - // ... lsb | guard round sticky round - // x 0 x x down - // 0 1 0 0 down round to even - // 1 1 0 0 up round to even - // x 1 0 1 up - // x 1 1 0 up - // x 1 1 1 up - if (guard) { - if (lsb && (!round && !sticky)) ++raw; // round to even - if (round || sticky) ++raw; - } - } - raw = (decoder.parts.sign == 0) ? raw : (~raw + 1); // map to two's complement - setbits(raw); - return *this; - } - fixpnt& operator=(double rhs) { - clear(); - if (rhs == 0.0) { - return *this; - } - if (arithmetic == Saturating) { // check if the value is in the representable range - fixpnt a; - a.maxpos(); - if (rhs >= double(a)) { return *this = a; } // set to max pos value - a.maxneg(); - if (rhs <= double(a)) { return *this = a; } // set to max neg value - } - bool sign = rhs < 0.0 ? true : false; -#define TYPE_PUNNING -#ifdef TYPE_PUNNING - double_decoder decoder; - decoder.d = rhs; - uint64_t raw = (uint64_t(1) << 52) | decoder.parts.fraction; - int radixPoint = 52 - (int(decoder.parts.exponent) - 1023); // move radix point to the right if scale > 0, left if scale < 0 -#else - uint64_t fraction = *reinterpret_cast(&rhs) & 0x000F'FFFF'FFFF'FFFFull; - uint64_t raw = 0x0010'0000'0000'0000ull | fraction; - uint64_t exponent = (*reinterpret_cast(&rhs) & 0x7FF0'0000'0000'0000ull) >> 52; - - int radixPoint = 52 - (int(exponent) - 1023); // move radix point to the right if scale > 0, left if scale < 0 -#endif - - // our fixed-point has its radixPoint at rbits - int shiftRight = radixPoint - int(rbits); - // do we need to round? - if (shiftRight > 0) { - // yes, round the raw bits - // collect guard, round, and sticky bits - // this same logic will work for the case where - // we only have a guard bit and no round and sticky bits - // because the mask logic will make round and sticky both 0 - uint64_t mask = (uint64_t(1) << (shiftRight - 1)); - bool guard = (mask & raw); - mask >>= 1; - bool round = (mask & raw); - if (shiftRight > 1) { - mask = (0xFFFFFFFFFFFFFFFF << (shiftRight - 2)); - mask = ~mask; - } - else { - mask = 0; - } - bool sticky = (mask & raw); + fixpnt& operator=(float rhs) { return convert_ieee754(rhs); } + fixpnt& operator=(double rhs) { return convert_ieee754(rhs); } - raw >>= shiftRight; // shift out the bits we are rounding away - bool lsb = (raw & 0x1); - // ... lsb | guard round sticky round - // x 0 x x down - // 0 1 0 0 down round to even - // 1 1 0 0 up round to even - // x 1 0 1 up - // x 1 1 0 up - // x 1 1 1 up - if (guard) { - if (lsb && (!round && !sticky)) ++raw; // round to even - if (round || sticky) ++raw; - } - } - raw = sign ? (~raw + 1) : raw; // take two's complement if negative - setbits(raw); - return *this; - } - fixpnt& operator=(long double rhs) { - if (rhs == 0.0l) { - setzero(); - return *this; - } - //long_double_decoder decoder; - //decoder.ld = rhs; - std::cerr << "assignment from long double not implemented yet\n"; - float_assign(rhs); - return *this; - } + // guard long double support to enable ARM and RISC-V embedded environments +#if LONG_DOUBLE_SUPPORT + fixpnt(long double initial_value) noexcept { *this = initial_value; } + fixpnt& operator=(long double rhs) { return convert_ieee754(rhs); } + explicit operator long double() const { return to_native(); } +#endif // assignment operator for blockbinary type template @@ -401,6 +279,7 @@ class fixpnt { } return *this; } + #ifdef POSIT_CONCEPT_GENERALIZATION // TODO: SFINAE to assure we only match a posit concept template @@ -472,21 +351,20 @@ class fixpnt { } // conversion operators // Maybe remove explicit, MTL compiles, but we have lots of double computation then - explicit operator unsigned short() const { return to_ushort(); } - explicit operator unsigned int() const { return to_uint(); } - explicit operator unsigned long() const { return to_ulong(); } - explicit operator unsigned long long() const { return to_ulong_long(); } - explicit operator short() const { return convert_signed(); } - explicit operator int() const { return convert_signed(); } - explicit operator long() const { return convert_signed(); } - explicit operator long long() const { return convert_signed(); } - explicit operator float() const { return to_float(); } - explicit constexpr operator double() const { return to_double(); } - explicit operator long double() const { return to_long_double(); } + explicit operator unsigned short() const { return to_unsigned(); } + explicit operator unsigned int() const { return to_unsigned(); } + explicit operator unsigned long() const { return to_unsigned(); } + explicit operator unsigned long long() const { return to_unsigned(); } + explicit operator short() const { return to_signed(); } + explicit operator int() const { return to_signed(); } + explicit operator long() const { return to_signed(); } + explicit operator long long() const { return to_signed(); } + explicit operator float() const { return to_native(); } + explicit constexpr operator double() const { return to_native(); } // arithmetic operators fixpnt& operator+=(const fixpnt& rhs) { - if (arithmetic == Modulo) { + if constexpr (arithmetic == Modulo) { bb += rhs.bb; } else { @@ -508,7 +386,7 @@ class fixpnt { return *this; } fixpnt& operator-=(const fixpnt& rhs) { - if (arithmetic == Modulo) { + if constexpr (arithmetic == Modulo) { operator+=(sw::universal::twosComplement(rhs)); } else { @@ -530,7 +408,7 @@ class fixpnt { return *this; } fixpnt& operator*=(const fixpnt& rhs) { - if (arithmetic == Modulo) { + if constexpr (arithmetic == Modulo) { // blockbinary<2 * nbits, bt> c = urmul(this->bb, rhs.bb); blockbinary<2 * nbits, bt> c = urmul2(this->bb, rhs.bb); bool roundUp = c.roundingMode(rbits); @@ -559,7 +437,7 @@ class fixpnt { return *this; } fixpnt& operator/=(const fixpnt& rhs) { - if (arithmetic == Modulo) { + if constexpr (arithmetic == Modulo) { constexpr size_t roundingDecisionBits = 4; // guard, round, and 2 sticky bits blockbinary roundingBits; blockbinary<2 * nbits + roundingDecisionBits, bt> c = urdiv(this->bb, rhs.bb, roundingBits); @@ -681,15 +559,77 @@ class fixpnt { protected: // HELPER methods + template + inline constexpr fixpnt& convert_ieee754(Real rhs) { + clear(); + if (rhs == 0.0) return *this; + if constexpr (arithmetic == Saturating) { // check if the value is in the representable range + fixpnt a; + a.maxpos(); + if (rhs >= float(a)) { return *this = a; } // set to max pos value + a.maxneg(); + if (rhs <= float(a)) { return *this = a; } // set to max neg value + } + + bool s{ false }; + uint64_t unbiasedExponent{ 0 }; + uint64_t raw{ 0 }; + extractFields(rhs, s, unbiasedExponent, raw); // use native conversion + if (unbiasedExponent > 0) raw |= (1ull << ieee754_parameter::fbits); + int radixPoint = ieee754_parameter::fbits - (static_cast(unbiasedExponent) - ieee754_parameter::bias); + + // our fixed-point has its radixPoint at rbits + int shiftRight = radixPoint - int(rbits); + // do we need to round? + if (shiftRight > 0) { + // yes, round the raw bits + // collect guard, round, and sticky bits + // this same logic will work for the case where + // we only have a guard bit and no round and/or sticky bits + // because the mask logic will make round and sticky both 0 + // so no need to special case it + uint64_t mask = (1ull << (shiftRight - 1)); + bool guard = (mask & raw); + mask >>= 1; + bool round = (mask & raw); + if (shiftRight > 1) { + mask = (0xFFFF'FFFF'FFFF'FFFFull << (shiftRight - 2)); + mask = ~mask; + } + else { + mask = 0; + } + bool sticky = (mask & raw); + + raw >>= shiftRight; // shift out the bits we are rounding away + bool lsb = (raw & 0x1ul); + // ... lsb | guard round sticky round + // x 0 x x down + // 0 1 0 0 down round to even + // 1 1 0 0 up round to even + // x 1 0 1 up + // x 1 1 0 up + // x 1 1 1 up + if (guard) { + if (lsb && (!round && !sticky)) ++raw; // round to even + if (round || sticky) ++raw; + } + } + raw = (s ? (~raw + 1) : raw); // if negative, map to two's complement + setbits(raw); + return *this; + } + // conversion functions - // from fixed-point to native - template - typename std::enable_if< std::is_integral::value && std::is_signed::value, - Integer>::type convert_signed() const { - if (nbits <= rbits) return 0; - constexpr unsigned sizeOfInteger = 8 * sizeof(Integer); - Integer ll = 0; - Integer mask = 1; + + // from fixed-point to native signed integer + template + typename std::enable_if< std::is_integral::value && std::is_signed::value, + NativeInt>::type to_signed() const { + if constexpr (nbits <= rbits) return 0; + constexpr unsigned sizeOfInteger = 8 * sizeof(NativeInt); + NativeInt ll = 0; + NativeInt mask = 1; unsigned upper = (nbits < sizeOfInteger ? nbits : sizeOfInteger); for (unsigned i = rbits; i < upper; ++i) { ll |= at(i) ? mask : 0; @@ -703,6 +643,47 @@ class fixpnt { } return ll; } + + // from fixed-point to native unsigned integer + template + typename std::enable_if< std::is_integral::value&& std::is_unsigned::value, + NativeInt>::type to_unsigned() const { + return NativeInt(bb.to_long_long()); + } + + template + TargetFloat to_native() const { + // pick up the absolute value of the minimum normal and subnormal exponents + constexpr size_t minNormalExponent = static_cast(-ieee754_parameter ::minNormalExp); + constexpr size_t minSubnormalExponent = static_cast(-ieee754_parameter::minSubnormalExp); + static_assert(rbits <= minSubnormalExponent, "to_native: fixpnt fraction is too small to represent with requested floating-point type"); + TargetFloat multiplier = 0; + if constexpr (rbits > minNormalExponent) { // value is a subnormal number + multiplier = ieee754_parameter::minSubnormal; + for (size_t i = 0; i < minSubnormalExponent - rbits; ++i) { + multiplier *= 2.0f; // these are error free multiplies + } + } + else { + // the value is a normal number + multiplier = ieee754_parameter::minNormal; + for (size_t i = 0; i < minNormalExponent - rbits; ++i) { + multiplier *= 2.0f; // these are error free multiplies + } + } + // you pop out here with the starting bit value + fixpnt raw = (sign() ? sw::universal::twosComplement(*this) : *this); + // construct the value + TargetFloat value{ 0.0 }; + for (size_t i = 0; i < nbits; ++i) { + if (raw.at(i)) value += multiplier; + multiplier *= 2.0; // these are error free multiplies + } + return (sign() ? -value : value); + } + +#ifdef DEPRECATED + unsigned short to_ushort() const { return static_cast(to_ulong_long()); } @@ -715,6 +696,7 @@ class fixpnt { unsigned long long to_ulong_long() const { return static_cast(bb.to_long_long()); } + float to_float() const { // minimum positive normal value of a single precision float == 2^-126 // float minpos_normal = 1.1754943508222875079687365372222e-38 @@ -745,7 +727,7 @@ class fixpnt { } return (sign() ? -value : value); } - constexpr double to_double() const { + double to_double() const { // minimum positive normal value of a double precision float == 2^-1022 // double dbl_minpos_normal = 2.2250738585072013830902327173324e-308; // minimum positive subnormal value of a double precision float == 2 ^ -1074 @@ -784,7 +766,7 @@ class fixpnt { template void float_assign(Ty& rhs) { clear(); - if (arithmetic == Saturating) { + if constexpr (arithmetic == Saturating) { // we are implementing saturation for values that are outside of the fixed-point's range // check if we are in the representable range fixpnt maxpos(SpecificValue::maxpos), maxneg(SpecificValue::maxneg); @@ -807,6 +789,7 @@ class fixpnt { Ty tmp = rhs * one; *this = uint64_t(tmp); } +#endif private: blockbinary bb; @@ -1967,7 +1950,7 @@ std::string convert_to_decimal_string(const fixpnt support::decimal partial, multiplier; fixpnt number; number = value.sign() ? sw::universal::twosComplement(value) : value; - if (nbits > rbits) { + if constexpr (nbits > rbits) { // convert the fixed point by first handling the integer part multiplier.setdigit(1); // convert fixpnt to decimal by adding and doubling multipliers diff --git a/include/universal/number/fixpnt/manipulators.hpp b/include/universal/number/fixpnt/manipulators.hpp index bc0a6a029..85f29f6af 100644 --- a/include/universal/number/fixpnt/manipulators.hpp +++ b/include/universal/number/fixpnt/manipulators.hpp @@ -12,11 +12,13 @@ namespace sw::universal { template std::string type_tag(const fixpnt& v) { std::stringstream s; + if (v.iszero()) s << ' '; // remove 'unreferenced formal parameter warning from compilation log s << "fixpnt<" - << nbits << ", " - << rbits << ", " - << (arithmetic ? "Modulo, " : "Saturating, ") - << typeid(bt).name() << "> = " << v; + << std::setw(3) << nbits << ", " + << std::setw(3) << rbits << ", " + << (arithmetic ? " Modulo, " : + "Saturating, ") + << typeid(bt).name() << '>'; return s.str(); } @@ -29,15 +31,9 @@ template std::string type_tag() { constexpr size_t nbits = FixedPoint::nbits; constexpr size_t rbits = FixedPoint::rbits; - using bt = typename FixedPoint::BlockType; constexpr bool arithmetic = FixedPoint::arithmetic; - std::stringstream s; - s << "fixpnt<" - << nbits << ", " - << rbits << ", " - << (arithmetic ? "Modulo, " : "Saturating, ") - << typeid(bt).name() << '>'; - return s.str(); + using bt = typename FixedPoint::BlockType; + return type_tag(fixpnt()); } } // namespace sw::universal diff --git a/include/universal/number/integer/integer_impl.hpp b/include/universal/number/integer/integer_impl.hpp index de8ad2def..bc7233579 100644 --- a/include/universal/number/integer/integer_impl.hpp +++ b/include/universal/number/integer/integer_impl.hpp @@ -523,9 +523,9 @@ class integer { inline constexpr integer& convert_signed(SignedInt rhs) noexcept { clear(); if (0 == rhs) return *this; - uint64_t v = rhs; - bool negative = (v < 0 ? true : false); constexpr size_t argbits = sizeof(rhs); + bool negative = (rhs < 0 ? true : false); + int64_t v = rhs; unsigned upper = (nbits <= _nbits ? nbits : argbits); for (unsigned i = 0; i < upper && v != 0; ++i) { if (v & 0x1ull) setbit(i); diff --git a/include/universal/number/lns/lns.hpp b/include/universal/number/lns/lns.hpp index 755877187..70bbdb7f9 100644 --- a/include/universal/number/lns/lns.hpp +++ b/include/universal/number/lns/lns.hpp @@ -6,6 +6,14 @@ #ifndef _LNS_STANDARD_HEADER_ #define _LNS_STANDARD_HEADER_ +//////////////////////////////////////////////////////////////////////////////////////// +/// COMPILATION DIRECTIVES TO DIFFERENT COMPILERS + +// compiler specific configuration for long double support +#include +// compiler specific configuration for C++20 bit_cast +#include + //////////////////////////////////////////////////////////////////////////////////////// /// BEHAVIORAL COMPILATION SWITCHES diff --git a/include/universal/utility/directives.hpp b/include/universal/utility/directives.hpp index 72948428e..3f47cc9b9 100644 --- a/include/universal/utility/directives.hpp +++ b/include/universal/utility/directives.hpp @@ -8,10 +8,22 @@ #pragma warning(disable : 4820) // bytes padding added after data member // this is a good warning to catch Universal library conditional compilation errors -//#pragma warning(disable : 4688) // warning C4668: '__STDC_WANT_SECURE_LIB__' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' +//#pragma warning(disable : 4688) warning C4668: 'LONG_DOUBLE_SUPPORT' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' +// but this one warning is making life difficult +// warning C4668: '__STDC_WANT_SECURE_LIB__' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' +// TODO: figure out what compiler flag configuration is causing this, +// but side step it in the mean time +#ifndef __STDC_WANT_SECURE_LIB__ +#define __STDC_WANT_SECURE_LIB__ 1 +#endif #pragma warning(disable : 5045) // Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified +#ifndef LONG_DOUBLE_SUPPORT +// this is too chatty +// #pragma message("MSVC does not have LONG_DOUBLE_SUPPORT") +#define LONG_DOUBLE_SUPPORT 0 +#endif #endif #include diff --git a/include/universal/verification/areal_test_suite.hpp b/include/universal/verification/areal_test_suite.hpp index 22cbd33f9..2c889bf3a 100644 --- a/include/universal/verification/areal_test_suite.hpp +++ b/include/universal/verification/areal_test_suite.hpp @@ -11,6 +11,7 @@ #include #include // fpclassify, isnormal, issubnormal, isinf, isnan +#include namespace sw::universal { @@ -171,7 +172,7 @@ namespace sw::universal { std::cout << "interval: " << to_binary(previousInterval) << " : " << previousInterval << std::endl; std::cout << "current : " << to_binary(current) << " : " << current << std::endl; std::cout << "interval: " << to_binary(interval) << " : " << interval << std::endl; - std::cout << "delta : " << delta << " : " << to_binary(delta, true) << std::endl; + std::cout << "delta : " << delta << " : " << to_binary(delta) << std::endl; } // da - delta = (prev,current) == previous + ubit = previous interval value testValue = da - delta; @@ -191,7 +192,7 @@ namespace sw::universal { std::cout << "interval: " << to_binary(previousInterval) << " : " << previousInterval << std::endl; std::cout << "current : " << to_binary(current) << " : " << current << std::endl; std::cout << "interval: " << to_binary(interval) << " : " << interval << std::endl; - std::cout << "delta : " << delta << " : " << to_binary(delta, true) << std::endl; + std::cout << "delta : " << delta << " : " << to_binary(delta) << std::endl; } } diff --git a/include/universal/verification/bitblock_test_suite.hpp b/include/universal/verification/bitblock_test_suite.hpp index cc924ec33..757093b8b 100644 --- a/include/universal/verification/bitblock_test_suite.hpp +++ b/include/universal/verification/bitblock_test_suite.hpp @@ -50,7 +50,7 @@ int VerifyBitsetAddition(bool bReportIndividualTestCases = false) { for (unsigned j = 0; j < NR_TEST_CASES; j++) { b = convert_to_bitblock(j); ref = static_cast(i + j); - bref = convert_to_bitblock(ref); + bref = convert_to_bitblock(static_cast(ref)); carry = add_unsigned(a, b, bsum); if (carry) { int maxNr = (int(1) << (nbits-1)); @@ -83,7 +83,7 @@ int VerifyBitsetSubtraction(bool bReportIndividualTestCases = false) { for (unsigned j = 0; j < NR_TEST_CASES; j++) { b = convert_to_bitblock(j); ref = static_cast(i - j); - bref = convert_to_bitblock(ref); + bref = convert_to_bitblock(static_cast(ref)); borrow = subtract_unsigned(a, b, bsub); if (borrow) { if (a >= b) ReportBinaryArithmeticError("FAIL", "-", a, b, bref, bsub); @@ -115,7 +115,7 @@ int VerifyBitsetMultiplication(bool bReportIndividualTestCases = false) { for (unsigned j = 0; j < NR_TEST_CASES; j++) { b = convert_to_bitblock(j); ref = static_cast(i * j); - bref = convert_to_bitblock(ref); + bref = convert_to_bitblock(static_cast(ref)); multiply_unsigned(a, b, bmul); if (bref != bmul) { nrOfFailedTestCases++; @@ -137,7 +137,7 @@ int VerifyBitsetDivision(bool bReportIndividualTestCases = false) { int nrOfFailedTestCases = 0; bitblock a, b; bitblock bdiv, bref; - int ref; + unsigned ref; for (unsigned i = 0; i < NR_TEST_CASES; i++) { a = convert_to_bitblock(i); diff --git a/include/universal/verification/fixpnt_test_suite.hpp b/include/universal/verification/fixpnt_test_suite.hpp index 9ec938ee9..3f6d38a30 100644 --- a/include/universal/verification/fixpnt_test_suite.hpp +++ b/include/universal/verification/fixpnt_test_suite.hpp @@ -238,9 +238,9 @@ int VerifyAddition(bool bReportIndividualTestCases) { } if (nrOfFailedTests > 100) return nrOfFailedTests; } - if (i % 1024 == 0) std::cout << '.'; +// if (i % 1024 == 0) std::cout << '.'; } - std::cout << std::endl; +// std::cout << std::endl; return nrOfFailedTests; } @@ -290,9 +290,9 @@ int VerifySubtraction(bool bReportIndividualTestCases) { } if (nrOfFailedTests > 100) return nrOfFailedTests; } - if (i % 1024 == 0) std::cout << '.'; +// if (i % 1024 == 0) std::cout << '.'; } - std::cout << std::endl; +// std::cout << std::endl; return nrOfFailedTests; } @@ -342,9 +342,9 @@ int VerifyMultiplication(bool bReportIndividualTestCases) { } if (nrOfFailedTests > 24) return nrOfFailedTests; } - if (i % 1024 == 0) std::cout << '.'; +// if (i % 1024 == 0) std::cout << '.'; } - std::cout << std::endl; +// std::cout << std::endl; return nrOfFailedTests; } @@ -398,25 +398,24 @@ int VerifyDivision(bool bReportIndividualTestCases) { } if (nrOfFailedTests > 24) return nrOfFailedTests; } - if (i % 1024 == 0) std::cout << '.'; +// if (i % 1024 == 0) std::cout << '.'; } - std::cout << std::endl; +// std::cout << std::endl; return nrOfFailedTests; } ////////////////////////////////////////////////////////////////////////// // enumeration utility functions - template -void GenerateFixedPointValues(std::ostream& ostr = std::cout) { +void GenerateFixedPointValues(std::ostream& ostr, const fixpnt& v) { constexpr size_t NR_TEST_CASES = (size_t(1) << nbits); fixpnt a; - ostr << " fixpnt<" << nbits << "," << rbits << ">\n"; + ostr << type_tag(v) << '\n'; for (size_t i = 0; i < NR_TEST_CASES; ++i) { a.setbits(i); float f = float(a); - ostr << to_binary(a) << " | " << to_triple(a) << " | " << std::setw(15) << a << " | " << std::setw(15) << f << std::endl; + ostr << to_binary(a) << " | " << to_triple(a) << " | " << std::setw(15) << a << " | " << std::setw(15) << f << '\n'; } } diff --git a/include/universal/verification/test_reporters.hpp b/include/universal/verification/test_reporters.hpp index a56bcdd4f..577e42820 100644 --- a/include/universal/verification/test_reporters.hpp +++ b/include/universal/verification/test_reporters.hpp @@ -26,15 +26,16 @@ template void ReportConversionError(const std::string& test_case, const std::string& op, double input, double reference, const TestType& result) { constexpr size_t nbits = TestType::nbits; // number system concept requires a static member indicating its size in bits auto old_precision = std::cerr.precision(); + std::cerr << std::setprecision(10); std::cerr << test_case << " " << op << " " << std::setw(NUMBER_COLUMN_WIDTH) << input << " did not convert to " << std::setw(NUMBER_COLUMN_WIDTH) << reference << " instead it yielded " << std::setw(NUMBER_COLUMN_WIDTH) << double(result) - << " raw " << std::setw(nbits) << to_binary(result) - << std::setprecision(old_precision) - << std::endl; + << " raw " << std::setw(nbits) << to_binary(result); + std::cerr << '\n'; + std::cerr << std::setprecision(old_precision); } template @@ -47,7 +48,7 @@ void ReportConversionSuccess(const std::string& test_case, const std::string& op << std::setw(NUMBER_COLUMN_WIDTH) << result << " golden reference is " << std::setw(NUMBER_COLUMN_WIDTH) << reference << " raw " << std::setw(nbits) << to_binary(result) - << std::endl; + << '\n'; } template @@ -62,7 +63,7 @@ void ReportUnaryArithmeticError(const std::string& test_case, const std::string& << std::setw(NUMBER_COLUMN_WIDTH) << result << " " << to_binary(ref) << " vs " << to_binary(result) << std::setprecision(old_precision) - << std::endl; + << '\n'; } template @@ -76,7 +77,7 @@ void ReportUnaryArithmeticSucces(const std::string& test_case, const std::string << std::setw(NUMBER_COLUMN_WIDTH) << result << " reference value is " << std::setw(NUMBER_COLUMN_WIDTH) << ref << std::setprecision(old_precision) - << std::endl; + << '\n'; } template @@ -100,7 +101,7 @@ void ReportBinaryArithmeticError(const std::string& test_case, const std::string << " " << op << " " << to_binary(rhs) << std::setprecision(old_precision) - << std::endl; + << '\n'; } template @@ -116,7 +117,7 @@ void ReportBinaryArithmeticSuccess(const std::string& test_case, const std::stri << std::setw(NUMBER_COLUMN_WIDTH) << ref << " " << to_binary(result) << " vs " << to_binary(ref) << std::setprecision(old_precision) - << std::endl; + << '\n'; } /// @@ -138,7 +139,7 @@ void ReportAssignmentError(const std::string& test_case, const std::string& op, << " != " << std::setw(NUMBER_COLUMN_WIDTH) << result << " golden reference is " << std::setw(NUMBER_COLUMN_WIDTH) << ref - << " " << to_binary(result) << " vs " << to_binary(ref) << std::endl; + << " " << to_binary(result) << " vs " << to_binary(ref) << '\n'; } /// @@ -160,7 +161,7 @@ void ReportAssignmentSuccess(const std::string& test_case, const std::string& op << " == " << std::setw(NUMBER_COLUMN_WIDTH) << result << " reference value is " << std::setw(NUMBER_COLUMN_WIDTH) << ref - << " bit pattern " << to_binary(result) << std::endl; + << " bit pattern " << to_binary(result) << '\n'; } template @@ -171,7 +172,7 @@ void ReportOneInputFunctionError(const std::string& test_case, const std::string << " != " << std::setw(NUMBER_COLUMN_WIDTH) << reference << " instead it yielded " << std::setw(NUMBER_COLUMN_WIDTH) << result - << " " << to_binary(reference) << " vs " << to_binary(result) << std::endl; + << " " << to_binary(reference) << " vs " << to_binary(result) << '\n'; } template @@ -182,7 +183,7 @@ void ReportOneInputFunctionSuccess(const std::string& test_case, const std::stri << " == " << std::setw(NUMBER_COLUMN_WIDTH) << result << " reference value is " << std::setw(NUMBER_COLUMN_WIDTH) << reference - << " " << components_to_string(result) << std::endl; + << " " << components_to_string(result) << '\n'; } template @@ -198,7 +199,7 @@ void ReportTwoInputFunctionError(const std::string& test_case, const std::string << std::setw(NUMBER_COLUMN_WIDTH) << result << " " << reference << " vs " << result << std::setprecision(precision) - << std::endl; + << '\n'; } template @@ -214,7 +215,7 @@ void ReportTwoInputFunctionSuccess(const std::string& test_case, const std::stri << std::setw(NUMBER_COLUMN_WIDTH) << result << " " << reference << " vs " << result << std::setprecision(precision) - << std::endl; + << '\n'; } } // namespace sw::universal diff --git a/tests/areal/api/api.cpp b/tests/areal/api/api.cpp index 48abffa16..78ddf08de 100644 --- a/tests/areal/api/api.cpp +++ b/tests/areal/api/api.cpp @@ -12,26 +12,20 @@ #include #include #include -// minimum set of include files to reflect source code dependencies -#include -#include // hex_print and the like + +#include #include #define MANUAL_TESTING 1 #define STRESS_TESTING 0 -int main(int argc, char** argv) +int main() try { using namespace sw::universal; - if (argc > 0) { - std::cout << argv[0] << std::endl; - } - // const size_t RND_TEST_CASES = 0; // no randoms, 8-bit posits can be done exhaustively - + std::cout << "areal<> Application Programming Interface tests" << std::endl; int nrOfFailedTestCases = 0; - std::cout << "areal<> Application Programming Interface tests" << std::endl; #if MANUAL_TESTING diff --git a/tests/areal/api/assignment.cpp b/tests/areal/api/assignment.cpp index f06af98ea..cf53885f6 100644 --- a/tests/areal/api/assignment.cpp +++ b/tests/areal/api/assignment.cpp @@ -15,11 +15,8 @@ #define AREAL_THROW_ARITHMETIC_EXCEPTION 0 // enabling tracing #define TRACE_CONVERSION 0 -// minimum set of include files to reflect source code dependencies -#include -// fixed-point type manipulators such as pretty printers -#include -#include + +#include #include #include @@ -438,11 +435,12 @@ int main(int argc, char** argv) try { using namespace sw::universal; + std::string test_suite = "areal assignment"; + std::string test_tag = "assignment"; + std::cout << test_suite << '\n'; bool bReportIndividualTestCases = false; int nrOfFailedTestCases = 0; - std::string tag = "AREAL assignment: "; - #if MANUAL_TESTING using Real = sw::universal::areal<8, 2>; @@ -503,7 +501,6 @@ try { nrOfFailedTestCases = 0; // disregard any test failures in manual testing mode #else - std::cout << "AREAL assignment validation\n"; bool bVerbose = false; @@ -514,34 +511,34 @@ try { nrOfFailedTestCases += VerifySpecialCases("long double->areal special cases"); std::cout << "Single block representations\n--------------------------------------------- es = 1 encodings\n"; - nrOfFailedTestCases += TestSingleBlockRepresentations<1, float>(tag, "=float", bReportIndividualTestCases, bVerbose); - nrOfFailedTestCases += TestSingleBlockRepresentations<1, double>(tag, "=double", bReportIndividualTestCases, bVerbose); + nrOfFailedTestCases += TestSingleBlockRepresentations<1, float>(test_tag, "=float", bReportIndividualTestCases, bVerbose); + nrOfFailedTestCases += TestSingleBlockRepresentations<1, double>(test_tag, "=double", bReportIndividualTestCases, bVerbose); std::cout << "--------------------------------------------- es = 2 encodings\n"; - nrOfFailedTestCases += TestSingleBlockRepresentations<2, float>(tag, "=float", bReportIndividualTestCases, bVerbose); - nrOfFailedTestCases += TestSingleBlockRepresentations<2, double>(tag, "=double", bReportIndividualTestCases, bVerbose); + nrOfFailedTestCases += TestSingleBlockRepresentations<2, float>(test_tag, "=float", bReportIndividualTestCases, bVerbose); + nrOfFailedTestCases += TestSingleBlockRepresentations<2, double>(test_tag, "=double", bReportIndividualTestCases, bVerbose); std::cout << "--------------------------------------------- es = 3 encodings\n"; - nrOfFailedTestCases += TestSingleBlockRepresentations<3, float>(tag, "=float", bReportIndividualTestCases, bVerbose); - nrOfFailedTestCases += TestSingleBlockRepresentations<3, double>(tag, "=double", bReportIndividualTestCases, bVerbose); + nrOfFailedTestCases += TestSingleBlockRepresentations<3, float>(test_tag, "=float", bReportIndividualTestCases, bVerbose); + nrOfFailedTestCases += TestSingleBlockRepresentations<3, double>(test_tag, "=double", bReportIndividualTestCases, bVerbose); std::cout << "--------------------------------------------- es = 4 encodings\n"; - nrOfFailedTestCases += TestSingleBlockRepresentations<4, float>(tag, "=float", bReportIndividualTestCases, bVerbose); - nrOfFailedTestCases += TestSingleBlockRepresentations<4, double>(tag, "=double", bReportIndividualTestCases, bVerbose); + nrOfFailedTestCases += TestSingleBlockRepresentations<4, float>(test_tag, "=float", bReportIndividualTestCases, bVerbose); + nrOfFailedTestCases += TestSingleBlockRepresentations<4, double>(test_tag, "=double", bReportIndividualTestCases, bVerbose); std::cout << "Double block representations\n--------------------------------------------- es = 1 encodings\n"; - nrOfFailedTestCases += TestDoubleBlockRepresentations<1, float>(tag, "=float", bReportIndividualTestCases, bVerbose); - nrOfFailedTestCases += TestDoubleBlockRepresentations<1, double>(tag, "=double", bReportIndividualTestCases, bVerbose); + nrOfFailedTestCases += TestDoubleBlockRepresentations<1, float>(test_tag, "=float", bReportIndividualTestCases, bVerbose); + nrOfFailedTestCases += TestDoubleBlockRepresentations<1, double>(test_tag, "=double", bReportIndividualTestCases, bVerbose); std::cout << "--------------------------------------------- es = 2 encodings\n"; - nrOfFailedTestCases += TestDoubleBlockRepresentations<2, float>(tag, "=float", bReportIndividualTestCases, bVerbose); - nrOfFailedTestCases += TestDoubleBlockRepresentations<2, double>(tag, "=double", bReportIndividualTestCases, bVerbose); + nrOfFailedTestCases += TestDoubleBlockRepresentations<2, float>(test_tag, "=float", bReportIndividualTestCases, bVerbose); + nrOfFailedTestCases += TestDoubleBlockRepresentations<2, double>(test_tag, "=double", bReportIndividualTestCases, bVerbose); std::cout << "--------------------------------------------- es = 3 encodings\n"; - nrOfFailedTestCases += TestDoubleBlockRepresentations<3, float>(tag, "=float", bReportIndividualTestCases, bVerbose); - nrOfFailedTestCases += TestDoubleBlockRepresentations<3, double>(tag, "=double", bReportIndividualTestCases, bVerbose); + nrOfFailedTestCases += TestDoubleBlockRepresentations<3, float>(test_tag, "=float", bReportIndividualTestCases, bVerbose); + nrOfFailedTestCases += TestDoubleBlockRepresentations<3, double>(test_tag, "=double", bReportIndividualTestCases, bVerbose); std::cout << "--------------------------------------------- es = 4 encodings\n"; - nrOfFailedTestCases += TestDoubleBlockRepresentations<4, float>(tag, "=float", bReportIndividualTestCases, bVerbose); - nrOfFailedTestCases += TestDoubleBlockRepresentations<4, double>(tag, "=double", bReportIndividualTestCases, bVerbose); + nrOfFailedTestCases += TestDoubleBlockRepresentations<4, float>(test_tag, "=float", bReportIndividualTestCases, bVerbose); + nrOfFailedTestCases += TestDoubleBlockRepresentations<4, double>(test_tag, "=double", bReportIndividualTestCases, bVerbose); std::cout << "Triple block representations\n--------------------------------------------- es = 1 encodings\n"; - nrOfFailedTestCases += TestTripleBlockRepresentations<1, float>(tag, "=float", bReportIndividualTestCases, bVerbose); - nrOfFailedTestCases += TestTripleBlockRepresentations<1, double>(tag, "=double", bReportIndividualTestCases, bVerbose); + nrOfFailedTestCases += TestTripleBlockRepresentations<1, float>(test_tag, "=float", bReportIndividualTestCases, bVerbose); + nrOfFailedTestCases += TestTripleBlockRepresentations<1, double>(test_tag, "=double", bReportIndividualTestCases, bVerbose); /* diff --git a/tests/areal/api/constexpr.cpp b/tests/areal/api/constexpr.cpp index 7ccedb161..01784d160 100644 --- a/tests/areal/api/constexpr.cpp +++ b/tests/areal/api/constexpr.cpp @@ -14,16 +14,11 @@ // second: enable/disable areal arithmetic exceptions #define AREAL_THROW_ARITHMETIC_EXCEPTION 1 -// minimum set of include files to reflect source code dependencies -#include -// fixed-point type manipulators such as pretty printers -#include -#include +#include +#include -#if BIT_CAST_SUPPORT // stylistic constexpr of pi that we'll assign constexpr to an areal constexpr double pi = 3.14159265358979323846; -#endif // BIT_CAST_SUPPORT template void TestConstexprConstruction() { @@ -112,9 +107,9 @@ int main() try { using namespace sw::universal; + std::string test_suite = "areal constexpr "; + std::cout << test_suite << '\n'; int nrOfFailedTestCases = 0; - - std::cout << "AREAL constexpr tests\n"; using Real = areal<12, 2>; Real a; @@ -124,12 +119,7 @@ try { TestConstexprAssignment(); TestConstexprSpecificValues(); - if (nrOfFailedTestCases > 0) { - std::cout << "FAIL\n"; - } - else { - std::cout << "PASS\n"; - } + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); } catch (char const* msg) { diff --git a/tests/areal/api/special_cases.cpp b/tests/areal/api/special_cases.cpp index cb2c899ed..57768c2f7 100644 --- a/tests/areal/api/special_cases.cpp +++ b/tests/areal/api/special_cases.cpp @@ -12,9 +12,8 @@ #include #include #include -// minimum set of include files to reflect source code dependencies -#include -#include // hex_print and the like + +#include #include #include diff --git a/tests/areal/arithmetic/addition.cpp b/tests/areal/arithmetic/addition.cpp index 14b67b0ab..a3f2fe201 100644 --- a/tests/areal/arithmetic/addition.cpp +++ b/tests/areal/arithmetic/addition.cpp @@ -8,8 +8,8 @@ #pragma warning(disable : 4710) // function is not inlined #pragma warning(disable : 5045) // Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified #endif -// minimum set of include files to reflect source code dependencies -#include + +#include #include #include #include diff --git a/tests/areal/conversion/double_conversion.cpp b/tests/areal/conversion/double_conversion.cpp index ba334987b..bbf9134f7 100644 --- a/tests/areal/conversion/double_conversion.cpp +++ b/tests/areal/conversion/double_conversion.cpp @@ -18,10 +18,7 @@ // third: enable trace conversion #define TRACE_CONVERSION 0 -// minimum set of include files to reflect source code dependencies -#include -#include -#include +#include #include #include #include // only used for value table generation diff --git a/tests/areal/conversion/float_conversion.cpp b/tests/areal/conversion/float_conversion.cpp index 5d858c667..9a5027567 100644 --- a/tests/areal/conversion/float_conversion.cpp +++ b/tests/areal/conversion/float_conversion.cpp @@ -18,10 +18,7 @@ // third: enable trace conversion #define TRACE_CONVERSION 0 -// minimum set of include files to reflect source code dependencies -#include -#include -#include +#include #include #include #include // only used for value table generation diff --git a/tests/areal/conversion/sampling.cpp b/tests/areal/conversion/sampling.cpp index 310665a13..304249ee7 100644 --- a/tests/areal/conversion/sampling.cpp +++ b/tests/areal/conversion/sampling.cpp @@ -16,10 +16,7 @@ // second: enable/disable arithmetic exceptions #define AREAL_THROW_ARITHMETIC_EXCEPTION 0 -// minimum set of include files to reflect source code dependencies -#include -#include -#include +#include #include diff --git a/tests/areal/logic/logic.cpp b/tests/areal/logic/logic.cpp index f768767c3..260558136 100644 --- a/tests/areal/logic/logic.cpp +++ b/tests/areal/logic/logic.cpp @@ -4,8 +4,7 @@ // // This file is part of the universal numbers project, which is released under an MIT Open Source license. -// minimum set of include files to reflect source code dependencies -#include +#include #include namespace sw::universal { diff --git a/tests/areal/standard/double_precision.cpp b/tests/areal/standard/double_precision.cpp index 4b6de1c27..6f9ebfc15 100644 --- a/tests/areal/standard/double_precision.cpp +++ b/tests/areal/standard/double_precision.cpp @@ -5,37 +5,15 @@ // This file is part of the universal numbers project, which is released under an MIT Open Source license. #include #include -// minimum set of include files to reflect source code dependencies -#include + +#include #include int main(int argc, char** argv) try { using namespace sw::universal; - //const size_t RND_TEST_CASES = 500000; - - constexpr size_t nbits = 64; - constexpr size_t es = 11; - int nrOfFailedTestCases = 0; - std::string tag = " cfloat<64,11>"; - - std::cout << "Standard double-precision cfloat<64,52> configuration tests\n"; - - cfloat r; - r = 1.2345; - std::cout << r << '\n'; - -#if 0 - std::cout << "Arithmetic tests " << RND_TEST_CASES << " randoms each" << std::endl; - bool bReportIndividualTestCases = false; - - nrOfFailedTestCases += ReportTestResult(ValidateThroughRandoms(tag, bReportIndividualTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); - nrOfFailedTestCases += ReportTestResult(ValidateThroughRandoms(tag, bReportIndividualTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(ValidateThroughRandoms(tag, bReportIndividualTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(ValidateThroughRandoms(tag, bReportIndividualTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); -#endif return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); } @@ -43,11 +21,11 @@ catch (char const* msg) { std::cerr << "Caught exception: " << msg << std::endl; return EXIT_FAILURE; } -catch (const sw::universal::cfloat_arithmetic_exception& err) { +catch (const sw::universal::areal_arithmetic_exception& err) { std::cerr << "Uncaught real arithmetic exception: " << err.what() << std::endl; return EXIT_FAILURE; } -catch (const sw::universal::cfloat_internal_exception& err) { +catch (const sw::universal::areal_internal_exception& err) { std::cerr << "Uncaught real internal exception: " << err.what() << std::endl; return EXIT_FAILURE; } diff --git a/tests/areal/standard/half_precision.cpp b/tests/areal/standard/half_precision.cpp index e62c01505..adc0af93a 100644 --- a/tests/areal/standard/half_precision.cpp +++ b/tests/areal/standard/half_precision.cpp @@ -5,8 +5,8 @@ // This file is part of the universal numbers project, which is released under an MIT Open Source license. #include #include -// minimum set of include files to reflect source code dependencies -#include + +#include #include // Standard posit with nbits = 16 have es = 1 exponent bit. @@ -15,29 +15,8 @@ int main(int argc, char** argv) try { using namespace sw::universal; - //const size_t RND_TEST_CASES = 500000; - - const size_t nbits = 16; - const size_t es = 5; - int nrOfFailedTestCases = 0; - std::string tag = " cfloat<16,5>"; - - std::cout << "Standard cfloat<16,5> configuration tests\n"; - - cfloat r; - r = 1.2345; - std::cout << r << '\n'; - -#if 0 - cout << "Arithmetic tests " << RND_TEST_CASES << " randoms each" << endl; - bool bReportIndividualTestCases = false; - nrOfFailedTestCases += ReportTestResult(ValidateThroughRandoms(tag, bReportIndividualTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); - nrOfFailedTestCases += ReportTestResult(ValidateThroughRandoms(tag, bReportIndividualTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(ValidateThroughRandoms(tag, bReportIndividualTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(ValidateThroughRandoms(tag, bReportIndividualTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); -#endif return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); } @@ -45,11 +24,11 @@ catch (char const* msg) { std::cerr << "Caught exception: " << msg << std::endl; return EXIT_FAILURE; } -catch (const sw::universal::cfloat_arithmetic_exception& err) { +catch (const sw::universal::areal_arithmetic_exception& err) { std::cerr << "Uncaught real arithmetic exception: " << err.what() << std::endl; return EXIT_FAILURE; } -catch (const sw::universal::cfloat_internal_exception& err) { +catch (const sw::universal::areal_internal_exception& err) { std::cerr << "Uncaught real internal exception: " << err.what() << std::endl; return EXIT_FAILURE; } diff --git a/tests/areal/standard/quad_precision.cpp b/tests/areal/standard/quad_precision.cpp index 111f94d00..e75df37d3 100644 --- a/tests/areal/standard/quad_precision.cpp +++ b/tests/areal/standard/quad_precision.cpp @@ -5,37 +5,15 @@ // This file is part of the universal numbers project, which is released under an MIT Open Source license. #include #include -// minimum set of include files to reflect source code dependencies -#include + +#include #include int main(int argc, char** argv) try { using namespace sw::universal; - //const size_t RND_TEST_CASES = 500000; - - constexpr size_t nbits = 128; - constexpr size_t es = 15; - int nrOfFailedTestCases = 0; - std::string tag = " areal<128,15>"; - - std::cout << "Standard quad-precision cfloat<128,15> configuration tests\n"; - - cfloat r; - r = 1.2345; - std::cout << r << '\n'; - -#if 0 - std::cout << "Arithmetic tests " << RND_TEST_CASES << " randoms each" << std::endl; - bool bReportIndividualTestCases = false; - - nrOfFailedTestCases += ReportTestResult(ValidateThroughRandoms(tag, bReportIndividualTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); - nrOfFailedTestCases += ReportTestResult(ValidateThroughRandoms(tag, bReportIndividualTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(ValidateThroughRandoms(tag, bReportIndividualTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(ValidateThroughRandoms(tag, bReportIndividualTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); -#endif return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); } @@ -43,11 +21,11 @@ catch (char const* msg) { std::cerr << "Caught exception: " << msg << std::endl; return EXIT_FAILURE; } -catch (const sw::universal::cfloat_arithmetic_exception& err) { +catch (const sw::universal::areal_arithmetic_exception& err) { std::cerr << "Uncaught real arithmetic exception: " << err.what() << std::endl; return EXIT_FAILURE; } -catch (const sw::universal::cfloat_internal_exception& err) { +catch (const sw::universal::areal_internal_exception& err) { std::cerr << "Uncaught real internal exception: " << err.what() << std::endl; return EXIT_FAILURE; } diff --git a/tests/areal/standard/quarter_precision.cpp b/tests/areal/standard/quarter_precision.cpp index b9da0690f..fb521b5f6 100644 --- a/tests/areal/standard/quarter_precision.cpp +++ b/tests/areal/standard/quarter_precision.cpp @@ -10,10 +10,9 @@ #endif #include #include -// minimum set of include files to reflect source code dependencies -#include -#include -#include + +#include +#include #define MANUAL_TESTING 1 #define STRESS_TESTING 0 @@ -22,41 +21,8 @@ int main(int argc, char** argv) try { using namespace sw::universal; - if (argc > 0) { - std::cout << argv[0] << std::endl; - } - // const size_t RND_TEST_CASES = 0; // no randoms, 8-bit posits can be done exhaustively - - constexpr size_t nbits = 8; - constexpr size_t es = 2; - int nrOfFailedTestCases = 0; - std::string tag = " areal<8,2>"; - - std::cout << "Standard quarter precision cfloat<8,2> configuration tests\n"; - -#if MANUAL_TESTING - - bool bReportIndividualTestCases = true; - { - using TestType = cfloat; - nrOfFailedTestCases += ExhaustiveNumberSystemTest(tag, bReportIndividualTestCases); - } - - -#else // !MANUAL_TESTING - - bool bReportIndividualTestCases = false; - nrOfFailedTestCases += ExhaustiveNumberSystemTest(bReportIndividualTestCases); - -#endif // MANUAL_TESTING - if (nrOfFailedTestCases) { - std::cout << tag << " tests FAIL: " << nrOfFailedTestCases << " failures\n"; - } - else { - std::cout << tag << " tests PASS\n"; - } return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); } catch (char const* msg) { diff --git a/tests/areal/standard/single_precision.cpp b/tests/areal/standard/single_precision.cpp index 78e306fac..942a38d15 100644 --- a/tests/areal/standard/single_precision.cpp +++ b/tests/areal/standard/single_precision.cpp @@ -5,37 +5,15 @@ // This file is part of the universal numbers project, which is released under an MIT Open Source license. #include #include -// minimum set of include files to reflect source code dependencies -#include + +#include #include int main(int argc, char** argv) try { using namespace sw::universal; - //const size_t RND_TEST_CASES = 500000; - - constexpr size_t nbits = 32; - constexpr size_t es = 8; - int nrOfFailedTestCases = 0; - std::string tag = " cfloat<32,8>"; - - std::cout << "Standard single-precision cfloat<8,23> configuration tests\n"; - - cfloat r; - r = 1.2345; - std::cout << r << '\n'; - -#if 0 - std::cout << "Arithmetic tests " << RND_TEST_CASES << " randoms each" << std::endl; - bool bReportIndividualTestCases = false; - - nrOfFailedTestCases += ReportTestResult(ValidateThroughRandoms(tag, bReportIndividualTestCases, OPCODE_ADD, RND_TEST_CASES), tag, "addition "); - nrOfFailedTestCases += ReportTestResult(ValidateThroughRandoms(tag, bReportIndividualTestCases, OPCODE_SUB, RND_TEST_CASES), tag, "subtraction "); - nrOfFailedTestCases += ReportTestResult(ValidateThroughRandoms(tag, bReportIndividualTestCases, OPCODE_MUL, RND_TEST_CASES), tag, "multiplication"); - nrOfFailedTestCases += ReportTestResult(ValidateThroughRandoms(tag, bReportIndividualTestCases, OPCODE_DIV, RND_TEST_CASES), tag, "division "); -#endif return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); } @@ -43,11 +21,11 @@ catch (char const* msg) { std::cerr << "Caught exception: " << msg << std::endl; return EXIT_FAILURE; } -catch (const sw::universal::cfloat_arithmetic_exception& err) { +catch (const sw::universal::areal_arithmetic_exception& err) { std::cerr << "Uncaught real arithmetic exception: " << err.what() << std::endl; return EXIT_FAILURE; } -catch (const sw::universal::cfloat_internal_exception& err) { +catch (const sw::universal::areal_internal_exception& err) { std::cerr << "Uncaught real internal exception: " << err.what() << std::endl; return EXIT_FAILURE; } diff --git a/tests/bitblock/arithmetic.cpp b/tests/bitblock/arithmetic.cpp index e74b6701e..19d54cedd 100644 --- a/tests/bitblock/arithmetic.cpp +++ b/tests/bitblock/arithmetic.cpp @@ -3,6 +3,7 @@ // Copyright (C) 2017-2021 Stillwater Supercomputing, Inc. // // This file is part of the universal numbers project, which is released under an MIT Open Source license. +#include #define BITBLOCK_THROW_ARITHMETIC_EXCEPTION 1 #undef BITBLOCK_ROUND_TIES_AWAY_FROM_ZERO #undef BITBLOCK_ROUND_TIES_TO_ZERO @@ -69,7 +70,7 @@ int IncrementRightAdjustedBitset() { r1.set(nbits - 1 - i, true); carry = false; std::cout << "carry " << (carry ? "1" : "0") << " r1 " << r1 << " <-- input" << std::endl; - carry = increment_unsigned(r1, int(i)); + carry = increment_unsigned(r1, i); std::cout << "carry " << (carry ? "1" : "0") << " r1 " << r1 << " <-- result" << std::endl; } @@ -113,7 +114,7 @@ int VerifyCopyInto(bool bReportIndividualTestCases = false) { #define MANUAL_TESTING 0 #define STRESS_TESTING 0 -int main(int argc, char** argv) +int main() try { using namespace sw::universal; using namespace sw::universal::internal; diff --git a/tests/bitblock/logic.cpp b/tests/bitblock/logic.cpp index d8aa15c73..2774bd43e 100644 --- a/tests/bitblock/logic.cpp +++ b/tests/bitblock/logic.cpp @@ -3,6 +3,7 @@ // Copyright (C) 2017-2021 Stillwater Supercomputing, Inc. // // This file is part of the universal numbers project, which is released under an MIT Open Source license. +#include #define BITBLOCK_THROW_ARITHMETIC_EXCEPTION 1 #undef BITBLOCK_ROUND_TIES_AWAY_FROM_ZERO #undef BITBLOCK_ROUND_TIES_TO_ZERO diff --git a/tests/bitblock/multi_word.cpp b/tests/bitblock/multi_word.cpp index 21042aac4..4dcf470b0 100644 --- a/tests/bitblock/multi_word.cpp +++ b/tests/bitblock/multi_word.cpp @@ -3,6 +3,7 @@ // Copyright (C) 2017-2021 Stillwater Supercomputing, Inc. // // This file is part of the universal numbers project, which is released under an MIT Open Source license. +#include #define BITBLOCK_THROW_ARITHMETIC_EXCEPTION 1 #undef BITBLOCK_ROUND_TIES_AWAY_FROM_ZERO #undef BITBLOCK_ROUND_TIES_TO_ZERO @@ -174,7 +175,7 @@ int VerifyCopyInto(bool bReportIndividualTestCases = false) { #define MANUAL_TESTING 0 #define STRESS_TESTING 0 -int main(int argc, char** argv) +int main() try { using namespace sw::universal; using namespace sw::universal::internal; diff --git a/tests/cfloat/api/api.cpp b/tests/cfloat/api/api.cpp index 20c16b33f..85c7a9246 100644 --- a/tests/cfloat/api/api.cpp +++ b/tests/cfloat/api/api.cpp @@ -14,19 +14,24 @@ // third: enable trace conversion #define TRACE_CONVERSION 0 -#include -#include // hex_print and the like -#include +#include +// Regression testing guards: typically set by the cmake configuration, but MANUAL_TESTING is an override #define MANUAL_TESTING 1 -#define STRESS_TESTING 0 - -int main(int argc, char** argv) +// REGRESSION_LEVEL_OVERRIDE is set by the cmake file to drive a specific regression intensity +// It is the responsibility of the regression test to organize the tests in a quartile progression. +//#undef REGRESSION_LEVEL_OVERRIDE +#ifndef REGRESSION_LEVEL_OVERRIDE +#define REGRESSION_LEVEL_1 1 +#define REGRESSION_LEVEL_2 1 +#define REGRESSION_LEVEL_3 0 +#define REGRESSION_LEVEL_4 0 +#endif + +int main() try { using namespace sw::universal; - print_cmd_line(argc, argv); - int nrOfFailedTestCases = 0; std::cout << "cfloat<> Application Programming Interface tests\n"; diff --git a/tests/cfloat/conversion/nonsaturating/normal/from_blocktriple.cpp b/tests/cfloat/conversion/nonsaturating/normal/from_blocktriple.cpp index de131a2b4..0d9d67a80 100644 --- a/tests/cfloat/conversion/nonsaturating/normal/from_blocktriple.cpp +++ b/tests/cfloat/conversion/nonsaturating/normal/from_blocktriple.cpp @@ -186,11 +186,11 @@ try { #define STRESS_TESTING 0 #if STRESS_TESTING - nrOfFailedTestCases += ReportTestResult(VerifyCfloatFromBlocktripleConversion, BlockTripleOperator::ADD>(bReportIndividualTestCases), tag, "cfloat<8,2,uint8_t,0,0,0> from blocktriple ADD"); - nrOfFailedTestCases += ReportTestResult(VerifyCfloatFromBlocktripleConversion, BlockTripleOperator::ADD>(bReportIndividualTestCases), tag, "cfloat<8,3,uint8_t,0,0,0> from blocktriple ADD"); - nrOfFailedTestCases += ReportTestResult(VerifyCfloatFromBlocktripleConversion, BlockTripleOperator::ADD>(bReportIndividualTestCases), tag, "cfloat<8,4,uint8_t,0,0,0> from blocktriple ADD"); - nrOfFailedTestCases += ReportTestResult(VerifyCfloatFromBlocktripleConversion, BlockTripleOperator::ADD>(bReportIndividualTestCases), tag, "cfloat<8,5,uint8_t,0,0,0> from blocktriple ADD"); - nrOfFailedTestCases += ReportTestResult(VerifyCfloatFromBlocktripleConversion, BlockTripleOperator::ADD>(bReportIndividualTestCases), tag, "cfloat<8,6,uint8_t,0,0,0> from blocktriple ADD"); + nrOfFailedTestCases += ReportTestResult(VerifyCfloatFromBlocktripleConversion, BlockTripleOperator::ADD>(bReportIndividualTestCases), test_tag, "cfloat<8,2,uint8_t,0,0,0> from blocktriple ADD"); + nrOfFailedTestCases += ReportTestResult(VerifyCfloatFromBlocktripleConversion, BlockTripleOperator::ADD>(bReportIndividualTestCases), test_tag, "cfloat<8,3,uint8_t,0,0,0> from blocktriple ADD"); + nrOfFailedTestCases += ReportTestResult(VerifyCfloatFromBlocktripleConversion, BlockTripleOperator::ADD>(bReportIndividualTestCases), test_tag, "cfloat<8,4,uint8_t,0,0,0> from blocktriple ADD"); + nrOfFailedTestCases += ReportTestResult(VerifyCfloatFromBlocktripleConversion, BlockTripleOperator::ADD>(bReportIndividualTestCases), test_tag, "cfloat<8,5,uint8_t,0,0,0> from blocktriple ADD"); + nrOfFailedTestCases += ReportTestResult(VerifyCfloatFromBlocktripleConversion, BlockTripleOperator::ADD>(bReportIndividualTestCases), test_tag, "cfloat<8,6,uint8_t,0,0,0> from blocktriple ADD"); #endif ReportTestSuiteResults(test_suite, nrOfFailedTestCases); @@ -202,81 +202,81 @@ try { // es = 1 is invalid for this cfloat configuration /* - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 3, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 3,1>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 4, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 4,1>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 5, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 5,1>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 6, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 6,1>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 7, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 7,1>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 8, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 8,1>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 9, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 9,1>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<10, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<10,1>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<12, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<12,1>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<16, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<16,1>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<18, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<18,1>"); // 3 blocks + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 3, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 3,1>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 4, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 4,1>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 5, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 5,1>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 6, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 6,1>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 7, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 7,1>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 8, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 8,1>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 9, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 9,1>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<10, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<10,1>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<12, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<12,1>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<16, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<16,1>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<18, 1, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<18,1>"); // 3 blocks */ // es = 2 - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 4, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 4,2>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 5, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 5,2>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 6, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 6,2>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 7, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 7,2>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 8, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 8,2>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<10, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<10,2>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<12, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<12,2>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<14, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<14,2>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<16, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<16,2>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<18, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<18,2>"); // 3 blocks + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 4, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 4,2>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 5, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 5,2>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 6, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 6,2>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 7, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 7,2>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 8, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 8,2>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<10, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<10,2>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<12, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<12,2>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<14, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<14,2>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<16, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<16,2>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<18, 2, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<18,2>"); // 3 blocks // es = 3 - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 5, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 5,3>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 6, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 6,3>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 7, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 7,3>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 8, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 8,3>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<10, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<10,3>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<12, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<12,3>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<14, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<14,3>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<18, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<18,3>"); // 3 blocks + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 5, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 5,3>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 6, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 6,3>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 7, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 7,3>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 8, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 8,3>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<10, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<10,3>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<12, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<12,3>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<14, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<14,3>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<18, 3, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<18,3>"); // 3 blocks // es = 4 - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 6, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 6,4>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 7, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 7,4>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 8, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 8,4>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<10, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<10,4>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<12, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<12,4>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<14, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<14,4>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<18, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<18,4>"); // 3 blocks + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 6, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 6,4>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 7, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 7,4>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 8, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 8,4>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<10, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<10,4>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<12, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<12,4>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<14, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<14,4>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<18, 4, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<18,4>"); // 3 blocks // es = 5 - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 7, 5, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 7,5>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 8, 5, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 8,5>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<10, 5, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<10,5>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<12, 5, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<12,5>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<14, 5, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<14,5>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<18, 5, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<18,5>"); // 3 blocks + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 7, 5, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 7,5>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 8, 5, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 8,5>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<10, 5, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<10,5>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<12, 5, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<12,5>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<14, 5, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<14,5>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<18, 5, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<18,5>"); // 3 blocks // es = 6 - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 8, 6, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 8,6>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 9, 6, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 9,6>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<10, 6, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<10,6>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<12, 6, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<12,6>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<14, 6, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<14,6>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 8, 6, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 8,6>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 9, 6, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 9,6>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<10, 6, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<10,6>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<12, 6, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<12,6>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<14, 6, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<14,6>"); // es = 7 - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 9, 7, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat< 9,7>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<10, 7, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<10,7>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<12, 7, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<12,7>"); - nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<14, 7, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<14,7>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat< 9, 7, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat< 9,7>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<10, 7, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<10,7>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<12, 7, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<12,7>"); + nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<14, 7, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<14,7>"); // still failing // es = 8 -// nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<11, 8, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<11,8>"); -// nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<12, 8, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<12,8>"); -// nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<14, 8, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), tag, "cfloat<14,8>"); +// nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<11, 8, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<11,8>"); +// nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<12, 8, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<12,8>"); +// nrOfFailedTestCases = ReportTestResult(VerifyCfloatFromBlocktripleConversion< cfloat<14, 8, uint8_t, hasSubnormals, hasSupernormals, isSaturating>, BlockTripleOperator::ADD >(bReportIndividualTestCases), test_tag, "cfloat<14,8>"); #endif #if REGRESSION_LEVEL_2 diff --git a/tests/conversions/posit_integer.cpp b/tests/conversions/posit_integer.cpp index 14225ecae..23b092ee5 100644 --- a/tests/conversions/posit_integer.cpp +++ b/tests/conversions/posit_integer.cpp @@ -9,10 +9,10 @@ #include // configure the integer arithmetic class #define INTEGER_THROW_ARITHMETIC_EXCEPTION 1 -#include +#include // configure the posit arithmetic class #define POSIT_THROW_ARITHMETIC_EXCEPTION 1 -#include +#include // is representable @@ -61,7 +61,7 @@ int VerifyInteger2PositConversion(const std::string& tag, bool bReportIndividual constexpr size_t NR_INTEGERS = (1 << ibits); //for (integer i = min_int(); i <= max_int(); ++i) { // this doesn't work for signed integers for (size_t pattern = 0; pattern < NR_INTEGERS; ++pattern) { - i.set_raw_bits(pattern); + i.setbits(pattern); p = i; // p = i requires ADAPTER_POSIT_AND_INTEGER to be set which is accomplished by // #include @@ -82,7 +82,7 @@ int VerifyPosit2IntegerConversion(const std::string& tag, bool bReportIndividual integer i; constexpr size_t NR_POSITS = (1 << pbits); for (size_t pattern = 0; pattern < NR_POSITS; ++pattern) { - p.set_raw_bits(pattern); + p.setbits(pattern); long diff; if (p.isnar()) { i = 0; diff --git a/tests/conversions/rounding.cpp b/tests/conversions/rounding.cpp index bd3f4ccd0..5048ac68e 100644 --- a/tests/conversions/rounding.cpp +++ b/tests/conversions/rounding.cpp @@ -6,7 +6,7 @@ #include #include // configure the posit arithmetic -#include +#include // configure the integer arithmetic class #define INTEGER_THROW_ARITHMETIC_EXCEPTION 1 #include diff --git a/tests/fixpnt/api/api.cpp b/tests/fixpnt/api/api.cpp index 4b4ce3671..8a7828c24 100644 --- a/tests/fixpnt/api/api.cpp +++ b/tests/fixpnt/api/api.cpp @@ -9,12 +9,8 @@ #define FIXPNT_FAST_SPECIALIZATION // second: enable/disable fixpnt arithmetic exceptions #define FIXPNT_THROW_ARITHMETIC_EXCEPTION 1 - -// minimum set of include files to reflect source code dependencies -#include -// fixed-point type manipulators such as pretty printers -#include -#include +#include +#include // Regression testing guards: typically set by the cmake configuration, but MANUAL_TESTING is an override #define MANUAL_TESTING 1 @@ -34,9 +30,11 @@ try { if (argc > 0) { std::cout << argv[0] << std::endl; } + std::string test_suite = "fixed-point class interface "; + std::cout << test_suite << '\n'; int nrOfFailedTestCases = 0; - std::cout << "fixed-point class interface tests\n"; + ///////////////////////////////////////////////////////////////////////////////////// //// MODULAR fixed-point (the default) @@ -373,12 +371,7 @@ try { } #endif // LATER - if (nrOfFailedTestCases > 0) { - std::cout << "FAIL\n"; - } - else { - std::cout << "PASS\n"; - } + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); } catch (char const* msg) { diff --git a/tests/fixpnt/api/complex_api.cpp b/tests/fixpnt/api/complex_api.cpp index 2d490e3c4..e4e613452 100644 --- a/tests/fixpnt/api/complex_api.cpp +++ b/tests/fixpnt/api/complex_api.cpp @@ -24,7 +24,7 @@ namespace sw::universal::complex_literals { std::complex> operator""_i(long double _Val) { // return imaginary _Val - return (std::complex>(0.0, static_cast>(_Val))); + return (std::complex>(0.0, static_cast>(double(_Val)))); } std::complex> operator""_i(unsigned long long _Val) diff --git a/tests/fixpnt/arithmetic/mod_addition.cpp b/tests/fixpnt/arithmetic/mod_addition.cpp index 14d8e73b8..131524541 100644 --- a/tests/fixpnt/arithmetic/mod_addition.cpp +++ b/tests/fixpnt/arithmetic/mod_addition.cpp @@ -13,10 +13,7 @@ // second: enable/disable fixpnt arithmetic exceptions #define FIXPNT_THROW_ARITHMETIC_EXCEPTION 1 -// minimum set of include files to reflect source code dependencies -#include -#include -#include +#include #include // generate specific test case that you can trace with the trace conditions in fixed_point.hpp @@ -50,23 +47,23 @@ void GenerateTestCase(Ty _a, Ty _b) { #define REGRESSION_LEVEL_4 1 #endif -int main(int argc, char** argv) +int main() try { using namespace sw::universal; - std::cout << "Fixed-point modular addition validation\n"; + std::string test_suite = "fixed-point modular addition: "; + std::string test_tag = "modular addition "; + std::cout << test_suite << '\n'; bool bReportIndividualTestCases = false; int nrOfFailedTestCases = 0; - std::string tag = "modular addition failed: "; - #if MANUAL_TESTING fixpnt<8, 4> f; f = 3.5f; - bitset<8> bs(f.getbb().block(0)); - cout << bs << endl; - cout << f << endl; + blockbinary<8> bs(f.getbb().block(0)); + std::cout << bs << '\n'; + std::cout << f << '\n'; // generate individual testcases to hand trace/debug GenerateTestCase<8, 4>(0.5f, 1.0f); @@ -74,77 +71,78 @@ try { { fixpnt<8, 0> fp; fp = 4; - cout << fp << endl; + std::cout << fp << '\n'; } { fixpnt<8, 4> fp; fp = 4.125f; - cout << fp << endl; + std::cout << fp << '\n'; } { fixpnt<4, 1> a, b, c; a = 0; - b = 2; + b = 0.5; c = a + b; - cout << a << " + " << b << " = " << c << endl; + std::cout << a << " + " << b << " = " << c << '\n'; } bReportIndividualTestCases = true; - nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Modulo,uint8_t>", "addition"); - + nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Modulo,uint8_t>", test_tag); #ifdef REGRESSION_LEVEL_4 - nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,0,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,2,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,3,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,4,Modulo,uint8_t>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,0,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,2,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,3,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,4,Modulo,uint8_t>", test_tag); #endif + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); + return EXIT_SUCCESS; // ignore failures #else #if REGRESSION_LEVEL_1 - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 4, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 0,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 4, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 1,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 4, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 2,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 4, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 3,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 4, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 4,Modulo,uint8_t>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 4, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 0,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 4, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 1,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 4, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 2,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 4, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 3,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 4, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 4,Modulo,uint8_t>", test_tag); #endif #if REGRESSION_LEVEL_2 - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 0,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 1,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 2,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 3,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 4,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 5, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 5,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 6, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 6,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 7, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 7,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 8, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 8,Modulo,uint8_t>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 0,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 1,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 2,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 3,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 4,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 5, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 5,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 6, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 6,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 7, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 7,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 8, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 8,Modulo,uint8_t>", test_tag); #endif #if REGRESSION_LEVEL_3 - nrOfFailedTestCases += ReportTestResult(VerifyAddition<10, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<10, 3,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<10, 5, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<10, 5,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<10, 7, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<10, 7,Modulo,uint8_t>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<10, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<10, 3,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<10, 5, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<10, 5,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<10, 7, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<10, 7,Modulo,uint8_t>", test_tag); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<11, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<11, 3,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<11, 5, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<11, 5,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<11, 7, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<11, 7,Modulo,uint8_t>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<11, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<11, 3,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<11, 5, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<11, 5,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<11, 7, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<11, 7,Modulo,uint8_t>", test_tag); #endif #if REGRESSION_LEVEL_4 - nrOfFailedTestCases += ReportTestResult(VerifyAddition<12, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<12, 0,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<12, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<12, 4,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<12, 8, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<12, 8,Modulo,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<12,12, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<12,12,Modulo,uint8_t>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<12, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<12, 0,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<12, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<12, 4,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<12, 8, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<12, 8,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<12,12, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<12,12,Modulo,uint8_t>", test_tag); #endif -#endif // MANUAL_TESTING - + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); +#endif // MANUAL_TESTING } catch (char const* msg) { std::cerr << msg << std::endl; diff --git a/tests/fixpnt/arithmetic/mod_division.cpp b/tests/fixpnt/arithmetic/mod_division.cpp index 6d7172478..67c65c4ec 100644 --- a/tests/fixpnt/arithmetic/mod_division.cpp +++ b/tests/fixpnt/arithmetic/mod_division.cpp @@ -14,10 +14,7 @@ // second: enable/disable fixpnt arithmetic exceptions #define FIXPNT_THROW_ARITHMETIC_EXCEPTION 1 -// minimum set of include files to reflect source code dependencies -#include -#include -#include +#include #include // unrounded multiplication, returns a blockbinary that is of size 2*nbits @@ -229,16 +226,15 @@ void GenerateComparison(size_t a_bits, size_t b_bits) { #define REGRESSION_LEVEL_4 1 #endif -int main(int argc, char** argv) +int main() try { using namespace sw::universal; - std::cout << "Fixed-point modular division validation\n"; + std::string test_suite = "fixed-point modular division "; + std::string test_tag = "modular division "; bool bReportIndividualTestCases = false; int nrOfFailedTestCases = 0; - std::string tag = "modular division: "; - #if MANUAL_TESTING constexpr size_t nbits = 4; @@ -249,46 +245,45 @@ try { GenerateComparison(0x3, 0x4); // 0110 and 0100 in 4bit formats GenerateComparison(0x4, 0x1); // 010.0 / 000.1 = 2 / 0.5 = 4 = 100.0 = -4 - return 0; - // generate individual testcases to hand trace/debug GenerateTestCase<4, 1>(3.0f, 1.5f); - nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,0,Modulo,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Modulo,uint8_t>", "division"); - // nrOfFailedTestCases += ReportTestResult(VerifyDivision<8, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<8,4,Modulo,uint8_t>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,0,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Modulo,uint8_t>", test_tag); + // nrOfFailedTestCases += ReportTestResult(VerifyDivision<8, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<8,4,Modulo,uint8_t>", test_tag); #ifdef REGRESSION_LEVEL_4 - nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,0,Modulo,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Modulo,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,2,Modulo,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,3,Modulo,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,4,Modulo,uint8_t>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,0,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,2,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,3,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,4,Modulo,uint8_t>", test_tag); #endif - nrOfFailedTestCases = 0; // ignore any failures in MANUAL mode + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); + return EXIT_SUCCESS; // ignore failures #else #if REGRESSION_LEVEL_1 - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 4, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 0,Modulo,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 4, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 1,Modulo,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 4, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 2,Modulo,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 4, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 3,Modulo,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 4, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 4,Modulo,uint8_t>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 4, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 0,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 4, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 1,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 4, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 2,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 4, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 3,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 4, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 4,Modulo,uint8_t>", test_tag); #endif #if REGRESSION_LEVEL_2 - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 0,Modulo,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 1,Modulo,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 2,Modulo,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 3,Modulo,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 4,Modulo,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 5, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 5,Modulo,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 6, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 6,Modulo,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 7, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 7,Modulo,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 8, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 8,Modulo,uint8_t>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 0,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 1,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 2,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 3,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 4,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 5, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 5,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 6, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 6,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 7, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 7,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 8, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 8,Modulo,uint8_t>", test_tag); #endif #if REGRESSION_LEVEL_3 @@ -299,9 +294,10 @@ try { #endif + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); + return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); #endif // MANUAL_TESTING - return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); } catch (char const* msg) { std::cerr << msg << std::endl; diff --git a/tests/fixpnt/arithmetic/mod_multiplication.cpp b/tests/fixpnt/arithmetic/mod_multiplication.cpp index 182ce35dc..496cc4369 100644 --- a/tests/fixpnt/arithmetic/mod_multiplication.cpp +++ b/tests/fixpnt/arithmetic/mod_multiplication.cpp @@ -13,10 +13,7 @@ // second: enable/disable fixpnt arithmetic exceptions #define FIXPNT_THROW_ARITHMETIC_EXCEPTION 1 -// minimum set of include files to reflect source code dependencies -#include -#include -#include +#include #include // generate specific test case that you can trace with the trace conditions in fixed_point.hpp @@ -42,7 +39,7 @@ void GenerateTestCase(Ty _a, Ty _b) { } // Regression testing guards: typically set by the cmake configuration, but MANUAL_TESTING is an override -#define MANUAL_TESTING 0 +#define MANUAL_TESTING 1 // REGRESSION_LEVEL_OVERRIDE is set by the cmake file to drive a specific regression intensity // It is the responsibility of the regression test to organize the tests in a quartile progression. //#undef REGRESSION_LEVEL_OVERRIDE @@ -53,22 +50,21 @@ void GenerateTestCase(Ty _a, Ty _b) { #define REGRESSION_LEVEL_4 1 #endif -int main(int argc, char** argv) +int main() try { using namespace sw::universal; - std::cout << "Fixed-point modular multiplication validation\n"; + std::string test_suite = "fixed-point modular multiplication "; + std::string test_tag = "modular multiplication"; bool bReportIndividualTestCases = true; int nrOfFailedTestCases = 0; - std::string tag = "modular multiplication failed: "; - #if MANUAL_TESTING { blockbinary<8> a, b; - a.set_raw_bits(0x02); - b.set_raw_bits(0x80); + a.setbits(0x02); + b.setbits(0x80); blockbinary<16> c; c = urmul2(a, b); std::cout << a << " * " << b << " = " << c << " : " << (long long)c << '\n'; @@ -82,6 +78,9 @@ try { GenerateTestCase<8, 4>(fb, fa); // generate individual testcases to hand trace/debug + GenerateTestCase<4, 0>(0.5f, 1.5f); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,0,Modulo,uint8_t>", test_tag); + return 0; GenerateTestCase<4, 1>(-0.5f, -3.5f); GenerateTestCase<4, 1>(-3.5f, -0.5f); @@ -96,70 +95,71 @@ try { GenerateTestCase<8, 1>(-64.0f, -63.0f); GenerateTestCase<8, 1>(-64.0f, -62.5f); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<8, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<8,1,Modulo,uint8_t>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<8, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<8,4,Modulo,uint8_t>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<8, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<8,1,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<8, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<8,4,Modulo,uint8_t>", test_tag); #if REGRESSION_LEVEL_4 - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,0,Modulo,uint8_t>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Modulo,uint8_t>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,2,Modulo,uint8_t>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,3,Modulo,uint8_t>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,4,Modulo,uint8_t>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,0,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,2,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,3,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,4,Modulo,uint8_t>", test_tag); #endif - nrOfFailedTestCases = 0; // ignore any failures in MANUAL mode + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); + return EXIT_SUCCESS; // ignore failures #else #if REGRESSION_LEVEL_1 - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 4, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 0,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 4, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 1,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 4, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 2,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 4, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 3,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 4, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 4,Modulo,uint8_t >", "multiplication"); - - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 6, 0,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 6, 1,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 6, 2,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 6, 3,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 6, 4,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 5, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 6, 5,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 6, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 6, 6,Modulo,uint8_t >", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 4, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 0,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 4, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 1,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 4, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 2,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 4, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 3,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 4, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 4,Modulo,uint8_t >", test_tag); + + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 6, 0,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 6, 1,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 6, 2,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 6, 3,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 6, 4,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 5, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 6, 5,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 6, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 6, 6,Modulo,uint8_t >", test_tag); #endif #if REGRESSION_LEVEL_2 - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 0,Modulo,uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 0,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 1,Modulo,uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 1,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 2,Modulo,uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 2,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 3,Modulo,uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 3,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 4,Modulo,uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 4,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 5,Modulo,uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 5,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 6,Modulo,uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 6,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 7,Modulo,uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 7,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 8,Modulo,uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 8,Modulo,uint8_t >", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 0,Modulo,uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 0,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 1,Modulo,uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 1,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 2,Modulo,uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 2,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 3,Modulo,uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 3,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 4,Modulo,uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 4,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 5,Modulo,uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 5,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 6,Modulo,uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 6,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 7,Modulo,uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 7,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 8,Modulo,uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 8,Modulo,uint8_t >", test_tag); #endif #if REGRESSION_LEVEL_3 - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10, 0, Modulo, uint8_t >(bReportIndividualTestCases), "fixpnt<10, 0,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10, 4, Modulo, uint8_t >(bReportIndividualTestCases), "fixpnt<10, 4,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10, 7, Modulo, uint8_t >(bReportIndividualTestCases), "fixpnt<10, 7,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10, 8, Modulo, uint8_t >(bReportIndividualTestCases), "fixpnt<10, 8,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10, 9, Modulo, uint8_t >(bReportIndividualTestCases), "fixpnt<10, 9,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10,10, Modulo, uint8_t >(bReportIndividualTestCases), "fixpnt<10,10,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10,10, Modulo, uint16_t>(bReportIndividualTestCases), "fixpnt<10,10,Modulo,uint16_t>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10, 0, Modulo, uint8_t >(bReportIndividualTestCases), "fixpnt<10, 0,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10, 4, Modulo, uint8_t >(bReportIndividualTestCases), "fixpnt<10, 4,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10, 7, Modulo, uint8_t >(bReportIndividualTestCases), "fixpnt<10, 7,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10, 8, Modulo, uint8_t >(bReportIndividualTestCases), "fixpnt<10, 8,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10, 9, Modulo, uint8_t >(bReportIndividualTestCases), "fixpnt<10, 9,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10,10, Modulo, uint8_t >(bReportIndividualTestCases), "fixpnt<10,10,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10,10, Modulo, uint16_t>(bReportIndividualTestCases), "fixpnt<10,10,Modulo,uint16_t>", test_tag); #endif #if REGRESSION_LEVEL_4 - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<12, 0,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<12, 4,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12, 7, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<12, 7,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12, 8, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<12, 8,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12, 9, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<12, 9,Modulo,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12,12, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<12,12,Modulo,uint8_t >", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<12, 0,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<12, 4,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12, 7, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<12, 7,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12, 8, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<12, 8,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12, 9, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<12, 9,Modulo,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12,12, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<12,12,Modulo,uint8_t >", test_tag); #endif -#endif // MANUAL_TESTING - + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); +#endif // MANUAL_TESTING } catch (char const* msg) { std::cerr << msg << std::endl; diff --git a/tests/fixpnt/arithmetic/mod_subtraction.cpp b/tests/fixpnt/arithmetic/mod_subtraction.cpp index 4fb79c3a0..bfce5322b 100644 --- a/tests/fixpnt/arithmetic/mod_subtraction.cpp +++ b/tests/fixpnt/arithmetic/mod_subtraction.cpp @@ -13,10 +13,7 @@ // second: enable/disable fixpnt arithmetic exceptions #define FIXPNT_THROW_ARITHMETIC_EXCEPTION 1 -// minimum set of include files to reflect source code dependencies -#include -#include -#include +#include #include // generate specific test case that you can trace with the trace conditions in fixed_point.hpp @@ -50,16 +47,15 @@ void GenerateTestCase(Ty _a, Ty _b) { #define REGRESSION_LEVEL_4 1 #endif -int main(int argc, char** argv) +int main() try { using namespace sw::universal; - std::cout << "Fixed-point modular subtraction validation\n"; + std::string test_suite = "fixed-point modular subtraction "; + std::string test_tag = "modular subtraction"; bool bReportIndividualTestCases = false; int nrOfFailedTestCases = 0; - std::string tag = "modular subtraction failed: "; - #if MANUAL_TESTING fixpnt<8, 4> f; @@ -72,68 +68,71 @@ try { GenerateTestCase<8, 4>(0.5f, 1.0f); bReportIndividualTestCases = true; - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 0, Modulo, uint8_t>("Manual Testing", bReportIndividualTestCases), "fixpnt<4,0,Modulo,uint8_t>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 0, Modulo, uint8_t>("Manual Testing", bReportIndividualTestCases), "fixpnt<4,0,Modulo,uint8_t>", test_tag); #if REGRESSION_LEVEL_4 - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,0,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,2,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,3,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,4,Modulo,uint8_t>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,0,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,2,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,3,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<4,4,Modulo,uint8_t>", test_tag); #endif + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); + return EXIT_SUCCESS; // ignore failures #else #if REGRESSION_LEVEL_1 - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 0,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 1,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 2,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 3,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 4,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 5, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 5,Modulo,uint8_t>", "subtraction"); - - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 0,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 1,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 2,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 3,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 4,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 5, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 5,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 6, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 6,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 7, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 7,Modulo,uint8_t>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 0,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 1,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 2,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 3,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 4,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 5, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 5,Modulo,uint8_t>", test_tag); + + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 0,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 1,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 2,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 3,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 4,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 5, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 5,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 6, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 6,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 7, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 7,Modulo,uint8_t>", test_tag); #endif #if REGRESSION_LEVEL_2 - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 0,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 1,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 2,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 3,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 4,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 5, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 5,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 6, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 6,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 7, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 7,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 8, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 8,Modulo,uint8_t>", "subtraction"); - - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 9, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 9, 3,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 9, 5, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 9, 5,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 9, 7, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 9, 7,Modulo,uint8_t>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 0,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 1, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 1,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 2, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 2,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 3,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 4, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 4,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 5, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 5,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 6, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 6,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 7, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 7,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 8, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 8,Modulo,uint8_t>", test_tag); + + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 9, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 9, 3,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 9, 5, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 9, 5,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 9, 7, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt< 9, 7,Modulo,uint8_t>", test_tag); #endif #if REGRESSION_LEVEL_3 - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<13, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<13, 0,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<13, 5, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<13, 5,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<13, 9, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<13, 9,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<13,12, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<13,12,Modulo,uint8_t>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<13, 0, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<13, 0,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<13, 5, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<13, 5,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<13, 9, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<13, 9,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<13,12, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<13,12,Modulo,uint8_t>", test_tag); #endif #if REGRESSION_LEVEL_4 - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<15, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<15, 3,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<15, 6, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<15, 6,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<15, 9, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<15, 9,Modulo,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<15,12, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<15,12,Modulo,uint8_t>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<15, 3, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<15, 3,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<15, 6, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<15, 6,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<15, 9, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<15, 9,Modulo,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<15,12, Modulo, uint8_t>(bReportIndividualTestCases), "fixpnt<15,12,Modulo,uint8_t>", test_tag); #endif #endif // MANUAL_TESTING + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); } catch (char const* msg) { diff --git a/tests/fixpnt/arithmetic/sat_addition.cpp b/tests/fixpnt/arithmetic/sat_addition.cpp index 61a7f593f..5e0977547 100644 --- a/tests/fixpnt/arithmetic/sat_addition.cpp +++ b/tests/fixpnt/arithmetic/sat_addition.cpp @@ -13,11 +13,7 @@ // second: enable/disable fixpnt arithmetic exceptions #define FIXPNT_THROW_ARITHMETIC_EXCEPTION 1 -// minimum set of include files to reflect source code dependencies -#include -// fixed-point type manipulators such as pretty printers -#include -#include +#include #include // generate specific test case that you can trace with the trace conditions in fixed_point.hpp @@ -51,16 +47,15 @@ void GenerateTestCase(Ty _a, Ty _b) { #define REGRESSION_LEVEL_4 1 #endif -int main(int argc, char** argv) +int main() try { using namespace sw::universal; - std::cout << "Fixed-point saturating addition validation\n"; + std::string test_suite = "Fixed-point saturating addition "; + std::string test_tag = "saturating addition"; bool bReportIndividualTestCases = false; int nrOfFailedTestCases = 0; - std::string tag = "saturating addition failed: "; - #if MANUAL_TESTING fixpnt<8, 4> f; @@ -73,59 +68,61 @@ try { GenerateTestCase<8, 4>(0.5f, 1.0f); bReportIndividualTestCases = true; - nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Saturating,uint8_t>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Saturating,uint8_t>", test_tag); #ifdef REGRESSION_LEVEL_4 - nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,0,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,2,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,3,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,4,Saturating,uint8_t>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,0,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,2,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,3,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<4, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,4,Saturating,uint8_t>", test_tag); #endif + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); + return EXIT_SUCCESS; // ignore failures #else #if REGRESSION_LEVEL_1 - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 4, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 0,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 4, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 1,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 4, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 2,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 4, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 3,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 4, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 4,Saturating,uint8_t>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 4, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 0,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 4, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 1,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 4, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 2,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 4, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 3,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 4, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 4,Saturating,uint8_t>", test_tag); #endif #if REGRESSION_LEVEL_2 - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 0,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 1,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 2,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 3,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 4,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 5, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 5,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 6, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 6,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 7, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 7,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 8, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 8,Saturating,uint8_t>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 0,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 1,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 2,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 3,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 4,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 5, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 5,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 6, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 6,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 7, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 7,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition< 8, 8, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 8,Saturating,uint8_t>", test_tag); #endif #if REGRESSION_LEVEL_3 - nrOfFailedTestCases += ReportTestResult(VerifyAddition<10, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<10, 3,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<10, 5, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<10, 5,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<10, 7, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<10, 7,Saturating,uint8_t>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<10, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<10, 3,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<10, 5, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<10, 5,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<10, 7, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<10, 7,Saturating,uint8_t>", test_tag); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<11, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<11, 3,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<11, 5, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<11, 5,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<11, 7, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<11, 7,Saturating,uint8_t>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<11, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<11, 3,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<11, 5, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<11, 5,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<11, 7, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<11, 7,Saturating,uint8_t>", test_tag); #endif #if REGRESSION_LEVEL_4 - nrOfFailedTestCases += ReportTestResult(VerifyAddition<12, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<12, 0,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<12, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<12, 4,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<12, 8, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<12, 8,Saturating,uint8_t>", "addition"); - nrOfFailedTestCases += ReportTestResult(VerifyAddition<12,12, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<12,12,Saturating,uint8_t>", "addition"); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<12, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<12, 0,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<12, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<12, 4,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<12, 8, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<12, 8,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyAddition<12,12, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<12,12,Saturating,uint8_t>", test_tag); #endif -#endif // MANUAL_TESTING - + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); +#endif // MANUAL_TESTING } catch (char const* msg) { std::cerr << msg << std::endl; diff --git a/tests/fixpnt/arithmetic/sat_division.cpp b/tests/fixpnt/arithmetic/sat_division.cpp index 335173a32..6dc1c262c 100644 --- a/tests/fixpnt/arithmetic/sat_division.cpp +++ b/tests/fixpnt/arithmetic/sat_division.cpp @@ -14,11 +14,8 @@ // second: enable/disable fixpnt arithmetic exceptions #define FIXPNT_THROW_ARITHMETIC_EXCEPTION 1 -// minimum set of include files to reflect source code dependencies #include -#include -#include -#include +#include #include // unrounded multiplication, returns a blockbinary that is of size 2*nbits @@ -230,16 +227,15 @@ void GenerateComparison(size_t a_bits, size_t b_bits) { #define REGRESSION_LEVEL_4 1 #endif -int main(int argc, char** argv) +int main() try { using namespace sw::universal; - std::cout << "Fixed-point saturating division validation\n"; + std::string test_suite = "fixed-point saturating division "; + std::string test_tag = "saturating division"; bool bReportIndividualTestCases = false; int nrOfFailedTestCases = 0; - std::string tag = "saturating division: "; - #if MANUAL_TESTING constexpr size_t nbits = 4; @@ -255,41 +251,42 @@ try { // generate individual testcases to hand trace/debug GenerateTestCase<4, 1>(3.0f, 1.5f); - nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,0,Saturating,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Saturating,uint8_t>", "division"); - // nrOfFailedTestCases += ReportTestResult(VerifyDivision<8, 4, Saturating, uint8_t>(true), "fixpnt<8,4,Saturating,uint8_t>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,0,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Saturating,uint8_t>", test_tag); + // nrOfFailedTestCases += ReportTestResult(VerifyDivision<8, 4, Saturating, uint8_t>(true), "fixpnt<8,4,Saturating,uint8_t>", test_tag); #ifdef REGRESSION_LEVEL_4 - nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,0,Saturating,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Saturating,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,2,Saturating,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,3,Saturating,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,4,Saturating,uint8_t>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,0,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,2,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,3,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision<4, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,4,Saturating,uint8_t>", test_tag); #endif - nrOfFailedTestCases = 0; // ignore any failures in MANUAL mode + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); + return EXIT_SUCCESS; // ignore failures #else #if REGRESSION_LEVEL_1 - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 4, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 0,Saturating,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 4, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 1,Saturating,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 4, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 2,Saturating,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 4, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 3,Saturating,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 4, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 4,Saturating,uint8_t>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 4, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 0,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 4, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 1,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 4, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 2,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 4, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 3,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 4, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 4, 4,Saturating,uint8_t>", test_tag); #endif #if REGRESSION_LEVEL_2 - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 0,Saturating,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 1,Saturating,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 2,Saturating,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 3,Saturating,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 4,Saturating,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 5, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 5,Saturating,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 6, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 6,Saturating,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 7, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 7,Saturating,uint8_t>", "division"); - nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 8, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 8,Saturating,uint8_t>", "division"); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 0,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 1,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 2,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 3,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 4,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 5, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 5,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 6, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 6,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 7, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 7,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyDivision< 8, 8, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 8,Saturating,uint8_t>", test_tag); #endif #if REGRESSION_LEVEL_3 @@ -299,9 +296,10 @@ try { #if REGRESSION_LEVEL_4 #endif -#endif // MANUAL_TESTING + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); +#endif // MANUAL_TESTING } catch (char const* msg) { std::cerr << msg << std::endl; diff --git a/tests/fixpnt/arithmetic/sat_multiplication.cpp b/tests/fixpnt/arithmetic/sat_multiplication.cpp index 5e707e93a..9956c1c16 100644 --- a/tests/fixpnt/arithmetic/sat_multiplication.cpp +++ b/tests/fixpnt/arithmetic/sat_multiplication.cpp @@ -53,16 +53,15 @@ void GenerateTestCase(Ty _a, Ty _b) { #define REGRESSION_LEVEL_4 1 #endif -int main(int argc, char** argv) +int main() try { using namespace sw::universal; - std::cout << "Fixed-point saturating multiplication validation\n"; + std::string test_suite = "fixed-point saturating multiplication "; + std::string test_tag = "saturating multiplication"; bool bReportIndividualTestCases = false; int nrOfFailedTestCases = 0; - std::string tag = "modular multiplication failed: "; - #if MANUAL_TESTING { @@ -88,96 +87,97 @@ try { GenerateTestCase<4, 1>(-0.5f, -3.5f); GenerateTestCase<4, 1>(-3.5f, -0.5f); GenerateTestCase<4, 1>( 1.5f, 2.5f); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Saturating,uint8_t>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Saturating,uint8_t>", test_tag); cout << endl; // fixpnt<6,2> GenerateTestCase<6, 2>(0.25f, -8.0f); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<6, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<6,2,Saturating,uint8_t>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<6, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<6,2,Saturating,uint8_t>", test_tag); cout << endl; // fixpnt<6,5> GenerateTestCase<6, 5>(0.03125f, -1.0f); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<6, 5, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<6,5,Saturating,uint8_t>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<6, 5, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<6,5,Saturating,uint8_t>", test_tag); cout << endl; // fixpnt<8,4> GenerateTestCase<8, 4>(1.125f, -7.0625f); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<8, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<8,4,Saturating,uint8_t>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<8, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<8,4,Saturating,uint8_t>", test_tag); // fixpnt<8,8> GenerateTestCase<8, 8>(0.01171875f, 0.3359375f); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<8, 8, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<8,8,Saturating,uint8_t>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<8, 8, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<8,8,Saturating,uint8_t>", test_tag); // fixpnt<10,9> GenerateTestCase<10,9>(0.251953125f, 0.994140625f); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10,9, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<10,9,Saturating,uint8_t>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10,9, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<10,9,Saturating,uint8_t>", test_tag); #ifdef REGRESSION_LEVEL_4 - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,0,Saturating,uint8_t>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Saturating,uint8_t>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,2,Saturating,uint8_t>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,3,Saturating,uint8_t>", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,4,Saturating,uint8_t>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,0,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,2,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,3,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<4, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,4,Saturating,uint8_t>", test_tag); #endif - nrOfFailedTestCases = 0; // ignore any failures in MANUAL mode + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); + return EXIT_SUCCESS; // ignore failures #else #if REGRESSION_LEVEL_1 - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 4, 0, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 4, 0,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 4, 1, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 4, 1,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 4, 2, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 4, 2,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 4, 3, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 4, 3,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 4, 4, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 4, 4,Saturating,uint8_t >", "multiplication"); - - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 0, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 6, 0,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 1, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 6, 1,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 2, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 6, 2,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 3, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 6, 3,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 4, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 6, 4,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 5, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 6, 5,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 6, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 6, 6,Saturating,uint8_t >", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 4, 0, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 4, 0,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 4, 1, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 4, 1,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 4, 2, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 4, 2,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 4, 3, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 4, 3,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 4, 4, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 4, 4,Saturating,uint8_t >", test_tag); + + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 0, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 6, 0,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 1, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 6, 1,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 2, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 6, 2,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 3, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 6, 3,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 4, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 6, 4,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 5, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 6, 5,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 6, 6, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 6, 6,Saturating,uint8_t >", test_tag); #endif #if REGRESSION_LEVEL_2 - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 0, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 8, 0,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 1, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 8, 1,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 2, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 8, 2,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 3, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 8, 3,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 4, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 8, 4,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 5, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 8, 5,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 6, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 8, 6,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 7, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 8, 7,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 8, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 8, 8,Saturating,uint8_t >", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 0, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 8, 0,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 1, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 8, 1,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 2, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 8, 2,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 3, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 8, 3,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 4, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 8, 4,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 5, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 8, 5,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 6, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 8, 6,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 7, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 8, 7,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication< 8, 8, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt< 8, 8,Saturating,uint8_t >", test_tag); #endif #if REGRESSION_LEVEL_3 - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10, 0, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<10, 0,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10, 3, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<10, 3,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10, 4, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<10, 4,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10, 7, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<10, 7,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10, 8, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<10, 8,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10, 9, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<10, 9,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10,10, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<10,10,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10,10, Saturating, uint16_t>(bReportIndividualTestCases), "fixpnt<10,10,Saturating,uint16_t>", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10, 0, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<10, 0,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10, 3, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<10, 3,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10, 4, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<10, 4,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10, 7, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<10, 7,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10, 8, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<10, 8,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10, 9, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<10, 9,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10,10, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<10,10,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<10,10, Saturating, uint16_t>(bReportIndividualTestCases), "fixpnt<10,10,Saturating,uint16_t>", test_tag); #endif #if REGRESSION_LEVEL_4 - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12, 0, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<12,0,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12, 4, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<12,4,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12, 7, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<12,7,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12, 8, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<12,8,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12, 9, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<12,9,Saturating,uint8_t >", "multiplication"); - nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12,12, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<12,12,Saturating,uint8_t >", "multiplication"); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12, 0, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<12,0,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12, 4, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<12,4,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12, 7, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<12,7,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12, 8, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<12,8,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12, 9, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<12,9,Saturating,uint8_t >", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifyMultiplication<12,12, Saturating, uint8_t >(bReportIndividualTestCases), "fixpnt<12,12,Saturating,uint8_t >", test_tag); #endif -#endif // MANUAL_TESTING - + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); +#endif // MANUAL_TESTING } catch (char const* msg) { std::cerr << msg << std::endl; diff --git a/tests/fixpnt/arithmetic/sat_subtraction.cpp b/tests/fixpnt/arithmetic/sat_subtraction.cpp index 0b8cc18a0..3d8f62a2c 100644 --- a/tests/fixpnt/arithmetic/sat_subtraction.cpp +++ b/tests/fixpnt/arithmetic/sat_subtraction.cpp @@ -13,10 +13,7 @@ // second: enable/disable fixpnt arithmetic exceptions #define FIXPNT_THROW_ARITHMETIC_EXCEPTION 1 -// minimum set of include files to reflect source code dependencies -#include -#include -#include +#include #include // generate specific test case that you can trace with the trace conditions in fixed_point.hpp @@ -50,16 +47,15 @@ void GenerateTestCase(Ty _a, Ty _b) { #define REGRESSION_LEVEL_4 1 #endif -int main(int argc, char** argv) +int main() try { using namespace sw::universal; - std::cout << "Fixed-point saturating subtraction validation\n"; + std::string test_suite = "fixed-point saturating subtraction "; + std::string test_tag = "saturating subtraction"; bool bReportIndividualTestCases = false; int nrOfFailedTestCases = 0; - std::string tag = "saturating subtraction failed: "; - #if MANUAL_TESTING // generate individual testcases to hand trace/debug @@ -70,69 +66,71 @@ try { GenerateTestCase<4, 1>(-4.0f, -4.0f); bReportIndividualTestCases = true; - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Saturating,uint8_t>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Saturating,uint8_t>", test_tag); #if REGRESSION_LEVEL_4 - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,0,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,2,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,3,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,4,Saturating,uint8_t>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,0,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,1,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,2,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,3,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<4, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<4,4,Saturating,uint8_t>", test_tag); #endif + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); + return EXIT_SUCCESS; // ignore failures #else #if REGRESSION_LEVEL_1 - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 0,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 1,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 2,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 3,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 4,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 5, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 5,Saturating,uint8_t>", "subtraction"); - - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 0,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 1,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 2,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 3,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 4,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 5, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 5,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 6, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 6,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 7, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 7,Saturating,uint8_t>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 0,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 1,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 2,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 3,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 4,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 5, 5, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 5, 5,Saturating,uint8_t>", test_tag); + + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 0,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 1,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 2,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 3,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 4,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 5, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 5,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 6, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 6,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 7, 7, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 7, 7,Saturating,uint8_t>", test_tag); #endif #if REGRESSION_LEVEL_2 - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 0,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 1,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 2,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 3,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 4,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 5, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 5,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 6, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 6,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 7, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 7,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 8, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 8,Saturating,uint8_t>", "subtraction"); - - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 9, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<9,3,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 9, 5, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<9,5,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 9, 7, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<9,7,Saturating,uint8_t>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 0,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 1, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 1,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 2, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 2,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 3,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 4, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 4,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 5, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 5,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 6, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 6,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 7, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 7,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 8, 8, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt< 8, 8,Saturating,uint8_t>", test_tag); + + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 9, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<9,3,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 9, 5, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<9,5,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction< 9, 7, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<9,7,Saturating,uint8_t>", test_tag); #endif #if REGRESSION_LEVEL_3 - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<13, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<13, 0,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<13, 5, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<13, 5,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<13, 9, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<13, 9,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<13,12, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<13,12,Saturating,uint8_t>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<13, 0, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<13, 0,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<13, 5, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<13, 5,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<13, 9, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<13, 9,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<13,12, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<13,12,Saturating,uint8_t>", test_tag); #endif #if REGRESSION_LEVEL_4 - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<15, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<15, 3,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<15, 6, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<15, 6,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<15, 9, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<15, 9,Saturating,uint8_t>", "subtraction"); - nrOfFailedTestCases += ReportTestResult(VerifySubtraction<15,12, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<15,12,Saturating,uint8_t>", "subtraction"); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<15, 3, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<15, 3,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<15, 6, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<15, 6,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<15, 9, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<15, 9,Saturating,uint8_t>", test_tag); + nrOfFailedTestCases += ReportTestResult(VerifySubtraction<15,12, Saturating, uint8_t>(bReportIndividualTestCases), "fixpnt<15,12,Saturating,uint8_t>", test_tag); #endif -#endif // MANUAL_TESTING - + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); +#endif // MANUAL_TESTING } catch (char const* msg) { std::cerr << msg << std::endl; diff --git a/tests/fixpnt/complex/mod_complex_add.cpp b/tests/fixpnt/complex/mod_complex_add.cpp index f171c013f..238544f80 100644 --- a/tests/fixpnt/complex/mod_complex_add.cpp +++ b/tests/fixpnt/complex/mod_complex_add.cpp @@ -90,7 +90,7 @@ namespace sw::universal::complex_literals { std::complex> operator""_i(long double _Val) { // return imaginary _Val - return (std::complex>(0.0, static_cast>(_Val))); + return (std::complex>(0.0, static_cast>(double(_Val)))); } std::complex> operator""_i(unsigned long long _Val) diff --git a/tests/fixpnt/conversion/mod_conversion.cpp b/tests/fixpnt/conversion/mod_conversion.cpp index f1f3535da..ab2d426bb 100644 --- a/tests/fixpnt/conversion/mod_conversion.cpp +++ b/tests/fixpnt/conversion/mod_conversion.cpp @@ -13,10 +13,7 @@ // second: enable/disable fixpnt arithmetic exceptions #define FIXPNT_THROW_ARITHMETIC_EXCEPTION 0 -// minimum set of include files to reflect source code dependencies -#include -#include -#include +#include #include // generate specific test case that you can trace with the trace conditions in fixed_point.hpp @@ -40,7 +37,7 @@ void GenerateTestCase(Ty _a, Ty _b) { template -void GenerateFixedPointComparisonTable(std::string& tag) { +void GenerateFixedPointComparisonTable() { using namespace sw::universal; constexpr size_t NR_VALUES = (size_t(1) << nbits); fixpnt fp; @@ -55,118 +52,6 @@ void GenerateFixedPointComparisonTable(std::string& tag) { } } -/* -void GenerateFixedPointRangeTable() { - using namespace sw::universal; - std::cout << "fixpnt<4,#> ranges\n"; - ReportFixedPointRanges<4, 0, Modulo>(cout); - ReportFixedPointRanges<4, 1, Modulo>(cout); - ReportFixedPointRanges<4, 2, Modulo>(cout); - ReportFixedPointRanges<4, 3, Modulo>(cout); - ReportFixedPointRanges<4, 4, Modulo>(cout); - std::cout << "fixpnt<6,#> ranges\n"; - ReportFixedPointRanges<6, 0, Modulo>(cout); - ReportFixedPointRanges<6, 1, Modulo>(cout); - ReportFixedPointRanges<6, 2, Modulo>(cout); - ReportFixedPointRanges<6, 3, Modulo>(cout); - ReportFixedPointRanges<6, 4, Modulo>(cout); - ReportFixedPointRanges<6, 5, Modulo>(cout); - ReportFixedPointRanges<6, 6, Modulo>(cout); - std::cout << "fixpnt<8,#> ranges\n"; - ReportFixedPointRanges<8, 0, Modulo>(cout); - ReportFixedPointRanges<8, 1, Modulo>(cout); - ReportFixedPointRanges<8, 2, Modulo>(cout); - ReportFixedPointRanges<8, 3, Modulo>(cout); - ReportFixedPointRanges<8, 4, Modulo>(cout); - ReportFixedPointRanges<8, 5, Modulo>(cout); - ReportFixedPointRanges<8, 6, Modulo>(cout); - ReportFixedPointRanges<8, 7, Modulo>(cout); - ReportFixedPointRanges<8, 8, Modulo>(cout); - std::cout << "fixpnt<10,#> ranges\n"; - ReportFixedPointRanges<10, 0, Modulo>(cout); - ReportFixedPointRanges<10, 1, Modulo>(cout); - ReportFixedPointRanges<10, 2, Modulo>(cout); - ReportFixedPointRanges<10, 3, Modulo>(cout); - ReportFixedPointRanges<10, 4, Modulo>(cout); - ReportFixedPointRanges<10, 5, Modulo>(cout); - ReportFixedPointRanges<10, 6, Modulo>(cout); - ReportFixedPointRanges<10, 7, Modulo>(cout); - ReportFixedPointRanges<10, 8, Modulo>(cout); - ReportFixedPointRanges<10, 9, Modulo>(cout); - ReportFixedPointRanges<10, 10, Modulo>(cout); - std::cout << "fixpnt<12,#> ranges\n"; - ReportFixedPointRanges<12, 0, Modulo>(cout); - ReportFixedPointRanges<12, 1, Modulo>(cout); - ReportFixedPointRanges<12, 2, Modulo>(cout); - ReportFixedPointRanges<12, 3, Modulo>(cout); - ReportFixedPointRanges<12, 4, Modulo>(cout); - ReportFixedPointRanges<12, 5, Modulo>(cout); - ReportFixedPointRanges<12, 6, Modulo>(cout); - ReportFixedPointRanges<12, 7, Modulo>(cout); - ReportFixedPointRanges<12, 8, Modulo>(cout); - ReportFixedPointRanges<12, 9, Modulo>(cout); - ReportFixedPointRanges<12, 10, Modulo>(cout); - ReportFixedPointRanges<12, 11, Modulo>(cout); - ReportFixedPointRanges<12, 12, Modulo>(cout); - std::cout << "fixpnt<14,#> ranges\n"; - ReportFixedPointRanges<14, 0, Modulo>(cout); - ReportFixedPointRanges<14, 1, Modulo>(cout); - ReportFixedPointRanges<14, 2, Modulo>(cout); - ReportFixedPointRanges<14, 3, Modulo>(cout); - ReportFixedPointRanges<14, 4, Modulo>(cout); - ReportFixedPointRanges<14, 5, Modulo>(cout); - ReportFixedPointRanges<14, 6, Modulo>(cout); - ReportFixedPointRanges<14, 7, Modulo>(cout); - ReportFixedPointRanges<14, 8, Modulo>(cout); - ReportFixedPointRanges<14, 9, Modulo>(cout); - ReportFixedPointRanges<14, 10, Modulo>(cout); - ReportFixedPointRanges<14, 11, Modulo>(cout); - ReportFixedPointRanges<14, 12, Modulo>(cout); - ReportFixedPointRanges<14, 13, Modulo>(cout); - ReportFixedPointRanges<14, 14, Modulo>(cout); - std::cout << "fixpnt<16,#> ranges\n"; - ReportFixedPointRanges<16, 0, Modulo>(cout); - ReportFixedPointRanges<16, 1, Modulo>(cout); - ReportFixedPointRanges<16, 2, Modulo>(cout); - ReportFixedPointRanges<16, 3, Modulo>(cout); - ReportFixedPointRanges<16, 4, Modulo>(cout); - ReportFixedPointRanges<16, 5, Modulo>(cout); - ReportFixedPointRanges<16, 6, Modulo>(cout); - ReportFixedPointRanges<16, 7, Modulo>(cout); - ReportFixedPointRanges<16, 8, Modulo>(cout); - ReportFixedPointRanges<16, 9, Modulo>(cout); - ReportFixedPointRanges<16, 10, Modulo>(cout); - ReportFixedPointRanges<16, 11, Modulo>(cout); - ReportFixedPointRanges<16, 12, Modulo>(cout); - ReportFixedPointRanges<16, 13, Modulo>(cout); - ReportFixedPointRanges<16, 14, Modulo>(cout); - ReportFixedPointRanges<16, 15, Modulo>(cout); - ReportFixedPointRanges<16, 16, Modulo>(cout); - std::cout << "fixpnt<20,#> ranges\n"; - ReportFixedPointRanges<20, 0, Modulo>(cout); - ReportFixedPointRanges<20, 1, Modulo>(cout); - ReportFixedPointRanges<20, 2, Modulo>(cout); - ReportFixedPointRanges<20, 3, Modulo>(cout); - ReportFixedPointRanges<20, 4, Modulo>(cout); - ReportFixedPointRanges<20, 5, Modulo>(cout); - ReportFixedPointRanges<20, 6, Modulo>(cout); - ReportFixedPointRanges<20, 7, Modulo>(cout); - ReportFixedPointRanges<20, 8, Modulo>(cout); - ReportFixedPointRanges<20, 9, Modulo>(cout); - ReportFixedPointRanges<20, 10, Modulo>(cout); - ReportFixedPointRanges<20, 11, Modulo>(cout); - ReportFixedPointRanges<20, 12, Modulo>(cout); - ReportFixedPointRanges<20, 13, Modulo>(cout); - ReportFixedPointRanges<20, 14, Modulo>(cout); - ReportFixedPointRanges<20, 15, Modulo>(cout); - ReportFixedPointRanges<20, 16, Modulo>(cout); - ReportFixedPointRanges<20, 17, Modulo>(cout); - ReportFixedPointRanges<20, 18, Modulo>(cout); - ReportFixedPointRanges<20, 19, Modulo>(cout); - ReportFixedPointRanges<20, 20, Modulo>(cout); -} -*/ - // Regression testing guards: typically set by the cmake configuration, but MANUAL_TESTING is an override #define MANUAL_TESTING 0 // REGRESSION_LEVEL_OVERRIDE is set by the cmake file to drive a specific regression intensity @@ -179,108 +64,81 @@ void GenerateFixedPointRangeTable() { #define REGRESSION_LEVEL_4 1 #endif -int main(int argc, char** argv) +int main() try { using namespace sw::universal; + std::string test_suite = "fixed-point modulo conversion "; + std::string test_tag = "conversion"; bool bReportIndividualTestCases = true; int nrOfFailedTestCases = 0; - std::string tag = "conversion: "; - #if MANUAL_TESTING - ReportFixedPointRanges<12, 0, Modulo>(cout); - - //ReportFixedPointRanges<12, 1, Modulo>(cout); - //GenerateFixedPointValues<12, 1>(); - - //GenerateFixedPointRangeTable(); - - //cout << "quire<512,240>\n"; - //ReportFixedPointRanges<512, 240, Modulo>(cout); - - GenerateFixedPointValues<4, 2>(); - - /* - GenerateFixedPointValues<4, 0>(); - GenerateFixedPointValues<4, 1>(); - GenerateFixedPointValues<4, 2>(); - GenerateFixedPointValues<4, 3>(); - GenerateFixedPointValues<4, 4>(); - - GenerateFixedPointValues<5, 4>(); - GenerateFixedPointValues<5, 5>(); + fixpnt<4, 1, Modulo, uint8_t> f; + f = 0.25f; + std::cout << to_binary(f) << " : " << f << std::endl; - GenerateFixedPointValues<8, 8>(); + ReportFixedPointRanges(std::cout, fixpnt< 4, 0, Modulo, uint16_t>()); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 0, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 4, 0,Modulo,uint8_t>"); + ReportFixedPointRanges(std::cout, fixpnt< 4, 1, Modulo, uint16_t>()); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 1, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 4, 1,Modulo,uint8_t>"); - GenerateFixedPointValues<16, 8>(); - */ - nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 4>(bReportIndividualTestCases), tag, "fixpnt<4,4>"); - - nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 8>(bReportIndividualTestCases), tag, "fixpnt<8,8>"); - - nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 1>(bReportIndividualTestCases), tag, "fixpnt<12,1>"); - -#if STRESS_TESTING - - // manual exhaustive test - -#endif +// nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 4, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 4, 4,Modulo,uint8_t>"); + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); + return EXIT_SUCCESS; // ignore failures #else // !MANUAL_TESTING - std::cout << "Fixed-point Modulo conversion validation\n"; - #if REGRESSION_LEVEL_1 - nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 0, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 4, 0,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 1, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 4, 1,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 2, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 4, 2,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 3, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 4, 3,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 4, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 4, 4,Modulo,uint8_t>"); - - nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 0, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 8, 0,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 1, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 8, 1,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 2, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 8, 2,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 3, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 8, 3,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 4, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 8, 4,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 5, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 8, 5,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 6, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 8, 6,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 7, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 8, 7,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 8, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 8, 8,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 0, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 4, 0,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 1, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 4, 1,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 2, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 4, 2,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 3, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 4, 3,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 4, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 4, 4,Modulo,uint8_t>"); + + nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 0, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 8, 0,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 1, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 8, 1,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 2, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 8, 2,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 3, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 8, 3,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 4, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 8, 4,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 5, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 8, 5,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 6, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 8, 6,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 7, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 8, 7,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 8, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 8, 8,Modulo,uint8_t>"); #endif #if REGRESSION_LEVEL_2 - nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 0, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<12, 0,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 1, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<12, 1,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 2, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<12, 2,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 3, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<12, 3,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 4, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<12, 4,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 6, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<12, 6,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 8, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<12, 8,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<12,10, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<12,10,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<12,12, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<12,12,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 0, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<12, 0,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 1, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<12, 1,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 2, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<12, 2,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 3, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<12, 3,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 4, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<12, 4,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 6, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<12, 6,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 8, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<12, 8,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<12,10, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<12,10,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<12,12, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<12,12,Modulo,uint8_t>"); #endif #if REGRESSION_LEVEL_3 - nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 0, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<16, 0,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 1, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<16, 1,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 2, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<16, 2,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 3, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<16, 3,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 4, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<16, 4,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 8, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<16, 8,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<16,12, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<16,12,Modulo,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<16,16, Modulo, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<16,16,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 0, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<16, 0,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 1, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<16, 1,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 2, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<16, 2,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 3, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<16, 3,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 4, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<16, 4,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 8, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<16, 8,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<16,12, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<16,12,Modulo,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<16,16, Modulo, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<16,16,Modulo,uint8_t>"); #endif #if REGRESSION_LEVEL_4 #endif -#endif // MANUAL_TESTING - + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); +#endif // MANUAL_TESTING } catch (char const* msg) { std::cerr << msg << std::endl; diff --git a/tests/fixpnt/conversion/mod_subnormal_conversion.cpp b/tests/fixpnt/conversion/mod_subnormal_conversion.cpp index 55ddbdc3d..55055ec54 100644 --- a/tests/fixpnt/conversion/mod_subnormal_conversion.cpp +++ b/tests/fixpnt/conversion/mod_subnormal_conversion.cpp @@ -13,10 +13,7 @@ // second: enable/disable fixpnt arithmetic exceptions #define FIXPNT_THROW_ARITHMETIC_EXCEPTION 0 -// minimum set of include files to reflect source code dependencies -#include -#include -#include +#include #include /* @@ -105,15 +102,15 @@ void DoubleGenerateFixedPointValues(std::ostream& ostr = std::cout) { #define REGRESSION_LEVEL_4 1 #endif -int main(int argc, char** argv) +int main() try { using namespace sw::universal; - // bool bReportIndividualTestCases = false; + std::string test_suite = "fixed-point modular subnormal conversion "; + std::string test_tag = "conversion of IEEE-754 subnormals"; + bool bReportIndividualTestCases = false; int nrOfFailedTestCases = 0; - std::string tag = "conversion of IEEE-754 subnormals: "; - #if MANUAL_TESTING // minpos_subnormal value float multiplier = 1.4012984643248170709237295832899e-45; @@ -133,13 +130,14 @@ try { //FloatGenerateFixedPointValues<8, 4>(); //DoubleGenerateFixedPointValues<8, 4>(); - // can't use the regular exhaustive test suites for these very large fixed-points - // nrOfFailedTestCases = ReportTestResult(VerifyAssignment<256, 150, Modular, uint32_t, float>(bReportIndividualTestCases), tag, "fixpnt<4,0, Modular, uint32_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyAssignment<4, 1, Modulo, uint8_t, float>(bReportIndividualTestCases), test_tag, "fixpnt<4,1, Modulo, uint32_t>"); + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); + return EXIT_SUCCESS; // ignore failures #else - std::cout << "Fixed-point modular subnormal conversion validation\n"; #if REGRESSION_LEVEL_1 + nrOfFailedTestCases = ReportTestResult(VerifyAssignment<4, 1, Modulo, uint8_t, float>(bReportIndividualTestCases), test_tag, "fixpnt<4,1, Modulo, uint32_t>"); #endif @@ -155,9 +153,9 @@ try { #endif -#endif // MANUAL_TESTING - + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); +#endif // MANUAL_TESTING } catch (char const* msg) { std::cerr << msg << std::endl; diff --git a/tests/fixpnt/conversion/sat_conversion.cpp b/tests/fixpnt/conversion/sat_conversion.cpp index c7aaced79..5627069e9 100644 --- a/tests/fixpnt/conversion/sat_conversion.cpp +++ b/tests/fixpnt/conversion/sat_conversion.cpp @@ -13,10 +13,7 @@ // second: enable/disable fixpnt arithmetic exceptions #define FIXPNT_THROW_ARITHMETIC_EXCEPTION 0 -// minimum set of include files to reflect source code dependencies -#include "universal/number/fixpnt/fixpnt_impl.hpp" -#include "universal/number/fixpnt/manipulators.hpp" -#include "universal/number/fixpnt/mathlib.hpp" +#include #include // generate specific test case that you can trace with the trace conditions in fixed_point.hpp @@ -40,7 +37,7 @@ void GenerateTestCase(Ty _a, Ty _b) { template -void GenerateFixedPointComparisonTable(std::string& tag) { +void GenerateFixedPointComparisonTable() { using namespace sw::universal; constexpr size_t NR_VALUES = (size_t(1) << nbits); fixpnt fp; @@ -55,118 +52,6 @@ void GenerateFixedPointComparisonTable(std::string& tag) { } } -/* -void GenerateFixedPointRangeTable() { - using namespace sw::universal; - std::cout << "fixpnt<4,#> ranges\n"; - ReportFixedPointRanges<4, 0, Saturating>(cout); - ReportFixedPointRanges<4, 1, Saturating>(cout); - ReportFixedPointRanges<4, 2, Saturating>(cout); - ReportFixedPointRanges<4, 3, Saturating>(cout); - ReportFixedPointRanges<4, 4, Saturating>(cout); - std::cout << "fixpnt<6,#> ranges\n"; - ReportFixedPointRanges<6, 0, Saturating>(cout); - ReportFixedPointRanges<6, 1, Saturating>(cout); - ReportFixedPointRanges<6, 2, Saturating>(cout); - ReportFixedPointRanges<6, 3, Saturating>(cout); - ReportFixedPointRanges<6, 4, Saturating>(cout); - ReportFixedPointRanges<6, 5, Saturating>(cout); - ReportFixedPointRanges<6, 6, Saturating>(cout); - std::cout << "fixpnt<8,#> ranges\n"; - ReportFixedPointRanges<8, 0, Saturating>(cout); - ReportFixedPointRanges<8, 1, Saturating>(cout); - ReportFixedPointRanges<8, 2, Saturating>(cout); - ReportFixedPointRanges<8, 3, Saturating>(cout); - ReportFixedPointRanges<8, 4, Saturating>(cout); - ReportFixedPointRanges<8, 5, Saturating>(cout); - ReportFixedPointRanges<8, 6, Saturating>(cout); - ReportFixedPointRanges<8, 7, Saturating>(cout); - ReportFixedPointRanges<8, 8, Saturating>(cout); - std::cout << "fixpnt<10,#> ranges\n"; - ReportFixedPointRanges<10, 0, Saturating>(cout); - ReportFixedPointRanges<10, 1, Saturating>(cout); - ReportFixedPointRanges<10, 2, Saturating>(cout); - ReportFixedPointRanges<10, 3, Saturating>(cout); - ReportFixedPointRanges<10, 4, Saturating>(cout); - ReportFixedPointRanges<10, 5, Saturating>(cout); - ReportFixedPointRanges<10, 6, Saturating>(cout); - ReportFixedPointRanges<10, 7, Saturating>(cout); - ReportFixedPointRanges<10, 8, Saturating>(cout); - ReportFixedPointRanges<10, 9, Saturating>(cout); - ReportFixedPointRanges<10, 10, Saturating>(cout); - std::cout << "fixpnt<12,#> ranges\n"; - ReportFixedPointRanges<12, 0, Saturating>(cout); - ReportFixedPointRanges<12, 1, Saturating>(cout); - ReportFixedPointRanges<12, 2, Saturating>(cout); - ReportFixedPointRanges<12, 3, Saturating>(cout); - ReportFixedPointRanges<12, 4, Saturating>(cout); - ReportFixedPointRanges<12, 5, Saturating>(cout); - ReportFixedPointRanges<12, 6, Saturating>(cout); - ReportFixedPointRanges<12, 7, Saturating>(cout); - ReportFixedPointRanges<12, 8, Saturating>(cout); - ReportFixedPointRanges<12, 9, Saturating>(cout); - ReportFixedPointRanges<12, 10, Saturating>(cout); - ReportFixedPointRanges<12, 11, Saturating>(cout); - ReportFixedPointRanges<12, 12, Saturating>(cout); - std::cout << "fixpnt<14,#> ranges\n"; - ReportFixedPointRanges<14, 0, Saturating>(cout); - ReportFixedPointRanges<14, 1, Saturating>(cout); - ReportFixedPointRanges<14, 2, Saturating>(cout); - ReportFixedPointRanges<14, 3, Saturating>(cout); - ReportFixedPointRanges<14, 4, Saturating>(cout); - ReportFixedPointRanges<14, 5, Saturating>(cout); - ReportFixedPointRanges<14, 6, Saturating>(cout); - ReportFixedPointRanges<14, 7, Saturating>(cout); - ReportFixedPointRanges<14, 8, Saturating>(cout); - ReportFixedPointRanges<14, 9, Saturating>(cout); - ReportFixedPointRanges<14, 10, Saturating>(cout); - ReportFixedPointRanges<14, 11, Saturating>(cout); - ReportFixedPointRanges<14, 12, Saturating>(cout); - ReportFixedPointRanges<14, 13, Saturating>(cout); - ReportFixedPointRanges<14, 14, Saturating>(cout); - std::cout << "fixpnt<16,#> ranges\n"; - ReportFixedPointRanges<16, 0, Saturating>(cout); - ReportFixedPointRanges<16, 1, Saturating>(cout); - ReportFixedPointRanges<16, 2, Saturating>(cout); - ReportFixedPointRanges<16, 3, Saturating>(cout); - ReportFixedPointRanges<16, 4, Saturating>(cout); - ReportFixedPointRanges<16, 5, Saturating>(cout); - ReportFixedPointRanges<16, 6, Saturating>(cout); - ReportFixedPointRanges<16, 7, Saturating>(cout); - ReportFixedPointRanges<16, 8, Saturating>(cout); - ReportFixedPointRanges<16, 9, Saturating>(cout); - ReportFixedPointRanges<16, 10, Saturating>(cout); - ReportFixedPointRanges<16, 11, Saturating>(cout); - ReportFixedPointRanges<16, 12, Saturating>(cout); - ReportFixedPointRanges<16, 13, Saturating>(cout); - ReportFixedPointRanges<16, 14, Saturating>(cout); - ReportFixedPointRanges<16, 15, Saturating>(cout); - ReportFixedPointRanges<16, 16, Saturating>(cout); - std::cout << "fixpnt<20,#> ranges\n"; - ReportFixedPointRanges<20, 0, Saturating>(cout); - ReportFixedPointRanges<20, 1, Saturating>(cout); - ReportFixedPointRanges<20, 2, Saturating>(cout); - ReportFixedPointRanges<20, 3, Saturating>(cout); - ReportFixedPointRanges<20, 4, Saturating>(cout); - ReportFixedPointRanges<20, 5, Saturating>(cout); - ReportFixedPointRanges<20, 6, Saturating>(cout); - ReportFixedPointRanges<20, 7, Saturating>(cout); - ReportFixedPointRanges<20, 8, Saturating>(cout); - ReportFixedPointRanges<20, 9, Saturating>(cout); - ReportFixedPointRanges<20, 10, Saturating>(cout); - ReportFixedPointRanges<20, 11, Saturating>(cout); - ReportFixedPointRanges<20, 12, Saturating>(cout); - ReportFixedPointRanges<20, 13, Saturating>(cout); - ReportFixedPointRanges<20, 14, Saturating>(cout); - ReportFixedPointRanges<20, 15, Saturating>(cout); - ReportFixedPointRanges<20, 16, Saturating>(cout); - ReportFixedPointRanges<20, 17, Saturating>(cout); - ReportFixedPointRanges<20, 18, Saturating>(cout); - ReportFixedPointRanges<20, 19, Saturating>(cout); - ReportFixedPointRanges<20, 20, Saturating>(cout); -} -*/ - // Regression testing guards: typically set by the cmake configuration, but MANUAL_TESTING is an override #define MANUAL_TESTING 0 // REGRESSION_LEVEL_OVERRIDE is set by the cmake file to drive a specific regression intensity @@ -179,15 +64,15 @@ void GenerateFixedPointRangeTable() { #define REGRESSION_LEVEL_4 1 #endif -int main(int argc, char** argv) +int main() try { using namespace sw::universal; + std::string test_suite = "fixed-point saturating conversion "; + std::string test_tag = "conversion IEEE-754 normals"; bool bReportIndividualTestCases = true; int nrOfFailedTestCases = 0; - std::string tag = "conversion: "; - #if MANUAL_TESTING ReportFixedPointRanges<12, 0>(cout); @@ -198,70 +83,64 @@ try { //cout << "quire<512,240>\n"; //ReportFixedPointRanges<512, 240>(cout); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 4, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<4,4,Saturating,uint8_t>"); - - nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 8, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<8,8,Saturating,uint8_t>"); - - nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 1, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<12,1,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 4, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<4,4,Saturating,uint8_t>"); -#if STRESS_TESTING + nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 8, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<8,8,Saturating,uint8_t>"); - // manual exhaustive test - -#endif + nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 1, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<12,1,Saturating,uint8_t>"); + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); + return EXIT_SUCCESS; // ignore failures #else // !MANUAL_TESTING - std::cout << "Fixed-point Saturating conversion validation\n"; - #if REGRESSION_LEVEL_1 - nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 0, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 4, 0,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 1, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 4, 1,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 2, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 4, 2,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 3, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 4, 3,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 4, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 4, 4,Saturating,uint8_t>"); - - nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 0, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 8, 0,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 1, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 8, 1,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 2, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 8, 2,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 3, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 8, 3,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 4, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 8, 4,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 5, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 8, 5,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 6, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 8, 6,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 7, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 8, 7,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 8, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt< 8, 8,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 0, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 4, 0,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 1, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 4, 1,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 2, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 4, 2,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 3, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 4, 3,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<4, 4, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 4, 4,Saturating,uint8_t>"); + + nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 0, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 8, 0,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 1, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 8, 1,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 2, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 8, 2,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 3, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 8, 3,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 4, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 8, 4,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 5, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 8, 5,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 6, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 8, 6,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 7, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 8, 7,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<8, 8, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt< 8, 8,Saturating,uint8_t>"); #endif #if REGRESSION_LEVEL_2 - nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 0, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<12, 0,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 1, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<12, 1,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 2, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<12, 2,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 3, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<12, 3,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 4, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<12, 4,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 6, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<12, 6,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 8, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<12, 8,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<12,10, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<12,10,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<12,12, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<12,12,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 0, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<12, 0,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 1, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<12, 1,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 2, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<12, 2,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 3, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<12, 3,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 4, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<12, 4,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 6, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<12, 6,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<12, 8, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<12, 8,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<12,10, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<12,10,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<12,12, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<12,12,Saturating,uint8_t>"); #endif #if REGRESSION_LEVEL_3 - nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 0, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<16, 0,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 1, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<16, 1,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 2, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<16, 2,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 3, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<16, 3,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 4, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<16, 4,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 8, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<16, 8,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<16,12, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<16,12,Saturating,uint8_t>"); - nrOfFailedTestCases = ReportTestResult(VerifyConversion<16,16, Saturating, uint8_t>(bReportIndividualTestCases), tag, "fixpnt<16,16,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 0, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<16, 0,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 1, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<16, 1,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 2, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<16, 2,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 3, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<16, 3,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 4, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<16, 4,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<16, 8, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<16, 8,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<16,12, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<16,12,Saturating,uint8_t>"); + nrOfFailedTestCases = ReportTestResult(VerifyConversion<16,16, Saturating, uint8_t>(bReportIndividualTestCases), test_tag, "fixpnt<16,16,Saturating,uint8_t>"); #endif #if REGRESSION_LEVEL_4 #endif -#endif // MANUAL_TESTING - + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); +#endif // MANUAL_TESTING } catch (char const* msg) { std::cerr << msg << std::endl; diff --git a/tests/fixpnt/conversion/sat_subnormal_conversion.cpp b/tests/fixpnt/conversion/sat_subnormal_conversion.cpp index 0002c6c8e..1f5203f97 100644 --- a/tests/fixpnt/conversion/sat_subnormal_conversion.cpp +++ b/tests/fixpnt/conversion/sat_subnormal_conversion.cpp @@ -13,11 +13,7 @@ // second: enable/disable fixpnt arithmetic exceptions #define FIXPNT_THROW_ARITHMETIC_EXCEPTION 0 -// minimum set of include files to reflect source code dependencies -#include -// fixed-point type manipulators such as pretty printers -#include -#include +#include #include /* @@ -106,15 +102,15 @@ void DoubleGenerateFixedPointValues(std::ostream& ostr = std::cout) { #define REGRESSION_LEVEL_4 1 #endif -int main(int argc, char** argv) +int main() try { using namespace sw::universal; - // bool bReportIndividualTestCases = false; + std::string test_suite = "Fixed-point saturating subnormal conversion "; + std::string test_tag = "conversion of IEEE-754 subnormals"; + bool bReportIndividualTestCases = false; int nrOfFailedTestCases = 0; - std::string tag = "conversion of IEEE-754 subnormals: "; - #if MANUAL_TESTING // minpos_subnormal value float multiplier = 1.4012984643248170709237295832899e-45; @@ -137,8 +133,10 @@ try { // can't use the regular exhaustive test suites for these very large fixed-points // nrOfFailedTestCases = ReportTestResult(ValidateAssignment<256, 150, Modular, uint32_t, float>(bReportIndividualTestCases), tag, "fixpnt<4,0, Modular, uint32_t>"); + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); + return EXIT_SUCCESS; // ignore failures #else - std::cout << "Fixed-point saturating subnormal conversion validation\n"; + #if REGRESSION_LEVEL_1 @@ -156,9 +154,9 @@ try { #endif -#endif // MANUAL_TESTING - + ReportTestSuiteResults(test_suite, nrOfFailedTestCases); return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS); +#endif // MANUAL_TESTING } catch (char const* msg) { std::cerr << msg << std::endl; diff --git a/tests/lns/arithmetic_add.cpp b/tests/lns/arithmetic_add.cpp index b67563213..3eec6e7ff 100644 --- a/tests/lns/arithmetic_add.cpp +++ b/tests/lns/arithmetic_add.cpp @@ -5,7 +5,7 @@ // This file is part of the universal numbers project, which is released under an MIT Open Source license. // minimum set of include files to reflect source code dependencies -#include +#include #include // ReportTestResult #include diff --git a/tests/lns/arithmetic_mul.cpp b/tests/lns/arithmetic_mul.cpp index a52ed5d27..6b7ba7808 100644 --- a/tests/lns/arithmetic_mul.cpp +++ b/tests/lns/arithmetic_mul.cpp @@ -5,7 +5,7 @@ // This file is part of the universal numbers project, which is released under an MIT Open Source license. // minimum set of include files to reflect source code dependencies -#include +#include #include // ReportTestResult #include diff --git a/tests/native/representable.cpp b/tests/native/representable.cpp index 49c5de8af..bd9d56578 100644 --- a/tests/native/representable.cpp +++ b/tests/native/representable.cpp @@ -5,6 +5,7 @@ // This file is part of the universal numbers project, which is released under an MIT Open Source license. #include #include +#include // is representable #include @@ -29,6 +30,12 @@ try { ReproducibilityTestSuite(); +#if LONG_DOUBLE_SUPPORT + constexpr long double denorm_min = std::numeric_limits::denorm_min(); + std::cout << "smallest long double: " << to_binary(denorm_min) << " : " << denorm_min << '/n'; +#endif + constexpr long double denorm_min = std::numeric_limits::denorm_min(); + std::cout << "smallest long double: " << denorm_min << '/n'; std::cout << "done" << std::endl; return EXIT_SUCCESS; diff --git a/tools/cmake/summary.cmake b/tools/cmake/summary.cmake index e09009fb0..e30e583f1 100644 --- a/tools/cmake/summary.cmake +++ b/tools/cmake/summary.cmake @@ -95,36 +95,36 @@ function(universal_print_configuration_summary) universal_status("") universal_status(" BUILD_ALL : ${BUILD_ALL}") universal_status(" BUILD_DEMONSTRATION : ${BUILD_DEMONSTRATION}") - universal_status(" BUILD_NUMERICAL_CHECKS : ${BUILD_NUMERICAL_CHECKS}") + universal_status(" BUILD_NUMERICS : ${BUILD_NUMERICS}") universal_status(" BUILD_BENCHMARKS : ${BUILD_BENCHMARKS}") - universal_status(" BUILD_REGRESSION_SUITES : ${BUILD_REGRESSION_SUITES}") + universal_status(" BUILD_NUMBER_SYSTEMS : ${BUILD_NUMBER_SYSTEMS}") universal_status(" BUILD_MIXEDPRECISION_SDK : ${BUILD_MIXEDPRECISION_SDK}") universal_status("") - universal_status(" BUILD_ARITHMETIC_CLASSES : ${BUILD_ARITHMETIC_CLASSES}") - universal_status(" BUILD_NATIVE_TYPES : ${BUILD_NATIVE_TYPES}") - universal_status(" BUILD_INTEGERS : ${BUILD_INTEGERS}") - universal_status(" BUILD_DECIMALS : ${BUILD_DECIMALS}") - universal_status(" BUILD_FIXPNTS : ${BUILD_FIXPNTS}") - universal_status(" BUILD_CFLOATS : ${BUILD_CFLOATS}") - universal_status(" BUILD_AREALS : ${BUILD_AREALS}") - universal_status(" BUILD_UNUM_TYPE_1 : ${BUILD_UNUM_TYPE_1}") - universal_status(" BUILD_UNUM_TYPE_2 : ${BUILD_UNUM_TYPE_2}") - universal_status(" BUILD_POSITS : ${BUILD_POSITS}") - universal_status(" BUILD_VALIDS : ${BUILD_VALIDS}") - universal_status(" BUILD_LNS : ${BUILD_LNS}") - universal_status(" BUILD_REALS : ${BUILD_REALS}") - universal_status(" BUILD_CONVERSIONS : ${BUILD_CONVERSIONS}") + universal_status(" BUILD_NUMBER_ARITHMETIC_CLASSES : ${BUILD_NUMBER_ARITHMETIC_CLASSES}") + universal_status(" BUILD_NUMBER_NATIVE_TYPES : ${BUILD_NUMBER_NATIVE_TYPES}") + universal_status(" BUILD_NUMBER_INTEGERS : ${BUILD_NUMBER_INTEGERS}") + universal_status(" BUILD_NUMBER_DECIMALS : ${BUILD_NUMBER_DECIMALS}") + universal_status(" BUILD_NUMBER_FIXPNTS : ${BUILD_NUMBER_FIXPNTS}") + universal_status(" BUILD_NUMBER_CFLOATS : ${BUILD_NUMBER_CFLOATS}") + universal_status(" BUILD_NUMBER_AREALS : ${BUILD_NUMBER_AREALS}") + universal_status(" BUILD_NUMBER_UNUM_TYPE_1 : ${BUILD_NUMBER_UNUM_TYPE_1}") + universal_status(" BUILD_NUMBER_UNUM_TYPE_2 : ${BUILD_NUMBER_UNUM_TYPE_2}") + universal_status(" BUILD_NUMBER_POSITS : ${BUILD_NUMBER_POSITS}") + universal_status(" BUILD_NUMBER_VALIDS : ${BUILD_NUMBER_VALIDS}") + universal_status(" BUILD_NUMBER_LNS : ${BUILD_NUMBER_LNS}") + universal_status(" BUILD_NUMBER_REALS : ${BUILD_NUMBER_REALS}") + universal_status(" BUILD_NUMBER_CONVERSIONS : ${BUILD_NUMBER_CONVERSIONS}") universal_status("") universal_status(" BUILD_CMD_LINE_TOOLS : ${BUILD_CMD_LINE_TOOLS}") universal_status(" BUILD_EDUCATION : ${BUILD_EDUCATION}") universal_status(" BUILD_APPLICATIONS : ${BUILD_APPLICATIONS}") universal_status(" BUILD_PLAYGROUND : ${BUILD_PLAYGROUND}") universal_status("") - universal_status(" BUILD_NUMERICAL_CHALLENGES : ${BUILD_NUMERICAL_CHALLENGES}") - universal_status(" BUILD_NUMERICAL_UTILS : ${BUILD_NUMERICAL_UTILS}") - universal_status(" BUILD_FPBENCH : ${BUILD_FPBENCH}") - universal_status(" BUILD_FUNCTIONS : ${BUILD_FUNCTIONS}") - universal_status(" BUILD_IEEE_FLOAT_QUIRES : ${BUILD_IEEE_FLOAT_QUIRES}") + universal_status(" BUILD_NUMERIC_CHALLENGES : ${BUILD_NUMERIC_CHALLENGES}") + universal_status(" BUILD_NUMERIC_UTILS : ${BUILD_NUMERIC_UTILS}") + universal_status(" BUILD_NUMERIC_FPBENCH : ${BUILD_NUMERIC_FPBENCH}") + universal_status(" BUILD_NUMERIC_FUNCTIONS : ${BUILD_NUMERIC_FUNCTIONS}") + universal_status(" BUILD_NUMERIC_IEEE_QUIRES : ${BUILD_NUMERIC_IEEE_QUIRES}") universal_status("") universal_status(" BUILD_BENCHMARK_PERFORMANCE : ${BUILD_BENCHMARK_PERFORMANCE}") universal_status(" BUILD_BENCHMARK_ACCURACY : ${BUILD_BENCHMARK_ACCURACY}") @@ -137,8 +137,8 @@ function(universal_print_configuration_summary) universal_status(" BUILD_MIXEDPRECISION_OPTIMIZE : ${BUILD_MIXEDPRECISION_OPTIMIZE}") universal_status(" BUILD_MIXEDPRECISION_CONJUGATE : ${BUILD_MIXEDPRECISION_CONJUGATE}") universal_status("") - universal_status(" BUILD_BLAS : ${BUILD_BLAS}") - universal_status(" BUILD_VMATH : ${BUILD_VMATH}") + universal_status(" BUILD_LINEAR_ALGEBRA_BLAS : ${BUILD_LINEAR_ALGEBRA_BLAS}") + universal_status(" BUILD_LINEAR_ALGEBRA_VMATH : ${BUILD_LINEAR_ALGEBRA_VMATH}") universal_status("") universal_status("") universal_status(" BUILD_C_API_PURE_LIB : ${BUILD_C_API_PURE_LIB}") diff --git a/tools/cmd/double.cpp b/tools/cmd/double.cpp index 2b371149f..0f3b4b5f7 100644 --- a/tools/cmd/double.cpp +++ b/tools/cmd/double.cpp @@ -3,7 +3,13 @@ // Copyright (C) 2017-2021 Stillwater Supercomputing, Inc. // // This file is part of the universal numbers project, which is released under an MIT Open Source license. +#include +#include #include +#define BITBLOCK_THROW_ARITHMETIC_EXCEPTION 0 +#define VALUE_THROW_ARITHMETIC_EXCEPTION 0 +#include +#include #include // receive a float and print the components of a double representation @@ -27,6 +33,21 @@ try { value v(d); std::cout << "double: " << std::setprecision(max_digits10) << d << " " << to_triple(v) << '\n'; + + using Scalar = double; + + std::cout << "Universal parameterization of IEEE-754 fields\n"; + std::cout << ieee754_parameter() << '\n'; + + std::cout << "Number Traits of IEEE-754 double\n"; + numberTraits(std::cout); + + std::cout << "smallest normal number\n"; + std::cout << to_binary(std::numeric_limits::min()) << '\n'; + std::cout << "smallest denormalized number\n"; + std::cout << to_binary(std::numeric_limits::denorm_min()) << '\n'; + + std::cout.flush(); return EXIT_SUCCESS; } catch (const char* const msg) { diff --git a/tools/cmd/float.cpp b/tools/cmd/float.cpp index c1dd68f8a..cc47718ce 100644 --- a/tools/cmd/float.cpp +++ b/tools/cmd/float.cpp @@ -3,7 +3,13 @@ // Copyright (C) 2017-2021 Stillwater Supercomputing, Inc. // // This file is part of the universal numbers project, which is released under an MIT Open Source license. +#include +#include #include +#define BITBLOCK_THROW_ARITHMETIC_EXCEPTION 0 +#define VALUE_THROW_ARITHMETIC_EXCEPTION 0 +#include +#include #include // receive a float and print its components @@ -27,6 +33,20 @@ try { value v(f); std::cout << "float: " << std::setprecision(max_digits10) << f << " " << to_triple(v) << '\n'; + + using Scalar = float; + + std::cout << "Universal parameterization of IEEE-754 fields\n"; + std::cout << ieee754_parameter() << '\n'; + + std::cout << "Number Traits of IEEE-754 float\n"; + numberTraits(std::cout); + + std::cout << "smallest normal number\n"; + std::cout << to_binary(std::numeric_limits::min()) << '\n'; + std::cout << "smallest denormalized number\n"; + std::cout << to_binary(std::numeric_limits::denorm_min()) << '\n'; + return EXIT_SUCCESS; } catch (const char* const msg) { diff --git a/tools/cmd/longdouble.cpp b/tools/cmd/longdouble.cpp index d1eca6997..300093bc4 100644 --- a/tools/cmd/longdouble.cpp +++ b/tools/cmd/longdouble.cpp @@ -3,7 +3,13 @@ // Copyright (C) 2017-2021 Stillwater Supercomputing, Inc. // // This file is part of the universal numbers project, which is released under an MIT Open Source license. +#include +#include #include +#define BITBLOCK_THROW_ARITHMETIC_EXCEPTION 0 +#define VALUE_THROW_ARITHMETIC_EXCEPTION 0 +#include +#include #include // receive a float and print the components of a long double representation @@ -19,7 +25,7 @@ try { std::cerr << "longdouble: components of an IEEE long-double (compiler dependent, 80-bit extended precision on x86 and ARM, 128-bit on RISC-V\n"; std::cerr << "Show the sign/scale/fraction components of an IEEE long double.\n"; std::cerr << "Usage: longdouble long_double_value\n"; - std::cerr << "Example: compld 0.03124999\n"; + std::cerr << "Example: longdouble 0.03124999\n"; std::cerr << "long double: 0.0312499899999999983247 (+,-6,000000000000000000000000000000000011111111111110000000000000000)\n"; return EXIT_SUCCESS; // signal successful completion for ctest } @@ -27,6 +33,20 @@ try { value v(q); std::cout << "long double: " << std::setprecision(max_digits10) << q << " " << to_triple(v) << '\n'; + + using Scalar = long double; + + std::cout << "Universal parameterization of IEEE-754 fields\n"; + std::cout << ieee754_parameter() << '\n'; + + std::cout << "Number Traits of IEEE-754 long double\n"; + numberTraits(std::cout); + + std::cout << "smallest normal number\n"; + std::cout << to_binary(std::numeric_limits::min()) << '\n'; + std::cout << "smallest denormalized number\n"; + std::cout << to_binary(std::numeric_limits::denorm_min()) << '\n'; + return EXIT_SUCCESS; } catch (const char* const msg) {