Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
V3.58: modular and saturating lns arithmetic (#300)
* bumping SEMVER to v3.58 * adding lns performance baseline * adding dynamic range API to LNS * adding special values constexpr constructor to lns * Fix posit8_str C API declaration/definition mismatch Fixes a warning (gcc12): c_api/pure_c/posit/posit8.c:43:23: warning: argument 1 of type ‘char *’ declared as a pointer [-Warray-parameter=] 43 | void posit8_str(char* str, posit8_t a) include/universal/number/posit/posit_c_macros.h:90:29: note: previously declared as an array ‘char[static 16]’ 90 | void POSIT_MKNAME(str)(char out[static POSIT_MKNAME(str_SIZE)], POSIT_T p); * Fix missing <cstring> include for paranoia.c strrchr The missing #include breaks the build (on gcc12) * Simplify clear() *this = {} copy-assign a default constructed object * Reduce repetitive array code with variadics The blocksignificant(raw,radixPoint) constructor, and the significant_ull() member function were using constexpr-if chains to initialize or read from array elements. Variadic template expansion reduces the code size and the chances of cut-n-paste errors between the different-size code blocks. It does however increase the logic complexity (and compile time). Using std::index_sequence<I...> to deduce I.. requires two stages; a variadic helper constructor is added and delegated to while the significant_ull member function does a recursive bootstrap. * Apply noexcept consistently Universal has a lot of noexcept spec functions, and that seems the right decision for a provider of low level types. The noexcept usage in this blocksignificant file was inconsistent, so I made it more consistent by adding noexcept in most places, apart from on the division functions in case divide by zero is defined as throwing in future. * Remove inline specifier from member functions defined in class They're implicitly inline when defined in-line. Note that the inline spec is left on the free function defined at the end of the file (twosComplementFree) because it is needed there. * Add more constexpr, for consistency * Make more friends, make them public and hidden There were some private friend declarations at the end of the class definition, then the definitions were free function templates. I removed the private label, making them public, and brought the definitions inline, also bringing in other free operators that were not declared inline. * Add missing template disambiguator Stops GCC 12 warnings * Silence type-punning warning GCC warning: dereferencing type-punned pointer will break strict-aliasing rules on e.g. uint32_t f(float f) { return *(uint32_t*)&f; } Silenced by using a union instead. * Add initializers to silence uninitialized warnings These are all due to type_tag(x) implementations that access their argument x. Ironically, it looks like these were modified at some point to access their argument in order to silence warnings about 'unused formal parameter'; a fix for that should be to remove the formal parameter name (and its superfluous use) - I'll do a PR. * Remove type_tag formal arg name, and its use The type_tag(x) overload implementations deduce their argument type: template <typename X> string type_tag(X x); or template <typename X> string type_tag(X const& x); The formal argument x shouldn't be used; only its type X is pertinent. The declarations should drop the name: template <typename X> string type_tag(X); An alternative signature then takes no argument; convenient when there is no variable to use so it saves declaring one uneccesarily: template <typename X> string type_tag(); Here the type cannot be deduced so must be provided: type_tag<X>(). The two overloads can be combined into a one with a default argument: template <typename X> string type_tag(X = {}); (assuming that X is default constructible). Note that type_tag should really be a constexpr function (or a variable template, or a type trait) because it deals only with types. However, relying on C++ runtime typeinfo disallows any compile-time definition, as does returning std::string (and implementing with stringstream). If the signature is changed to return a 'constexpr string' type then I can PR a constexpr type_tag implementation. * adding MSC guard to specialize posit8_str for vc++ * Comment out unused retval variable Looks like it should've been commented out in recent change "cleaning up blocktriple regression tests to reduce output" which commented out retval's useage. Commenting out rather than removing because there's a TODO. (Third time I've prepared this change, it keeps getting lost.) (I think this is the last of the non _block related warnings.) * completing classify regression test * gcc fix for missing fpclassify declaration * WIP: debugging fmod behavior: it appears to use double precision math * bit_cast polyfill, detects and uses std, builtin or non-builtin C++20 introduced std::bit_cast, with clang, gcc and msvc implementing it with a builtin, __builtin_bit_cast(T,v), portable between compilers and available in < c++20 language modes. If compiler-provided constexpr-capable bit_cast is detected it's used, otherwise this header defines a non-constexpr bit_cast, useful as a UB-free alternative to 'type-punning', for trivially copyable types. The BIT_CAST_CONSTEXPR preprocessor symbol is defined as constexpr if sw::bit_cast is constexpr, otherwise it's defined as empty, allowing clients to propagate constexpr on functions that depend on bit_cast, and BIT_CAST_IS_CONSTEXPR symbol is defined as true or false. The earlier BIT_CAST_SUPPORT, and related CONSTEXRESSION, symbols are now redundant and can be deprecated. * removing unused files * adding dev containers for different gcc compilers * adding MSVC compiler flag to enable latest C++20 features * redesigning the lerp function include * WIP: creating a common arithmetic behavior configuration enum * adding negation to lns and streamlining arithmetic type testing * forgot to make lns negation operator-() constexpr * bug fix in tempered logt and expt functions and test * bumping SEMVER to v3.59 and moving dev container to gcc11 * fixing identifying version environment vars for dev containers * g++ exclusion of riscv, which is a specialized g++ * temporary removal of 3D hypotenuse math functions for g++ * removing conversion experiment test from posit regression suite * code hygiene for quire test * adding VerifyHypot test to posit mathlib regression suite * adding VerifyHypot test to cfloat mathlib regression suite * setting up lns arithmetic test suites for dev testing * updating README with new LNCS proceedings and latest cmake install guidance * adding Wilkinson's polynomial info * WIP: adding mathlib stubs to lns * adding protection to call out incorrect parameterization of lns * WIP: adding arithmetic behavior parameters to LNS * compilation fixes required for API change of fixpnt * compilation fix for hypotl function for lns * compilation fixes for gcc * warnings removal for gcc * rearranging assignment regression test for posits to the conversion set * WIP: adding a conversion test to lns * adding LNS tables to documentation * WIP: lns saturation arithmetic * lns conversion from IEEE-754 using saturating arithmetic * WIP: saturating lns multiplication * saturating lns multiplication * saturating lns addition (marshalling through double) * saturating lns subtraction (marshalling through double) * ready to use generic or specialized regression test * saturating lns division (native implementation) * compilation fix for areal regression tests * clang compilation fix * first attempt to try to recover from a bad merge Co-authored-by: Will Wray <[email protected]>
- Loading branch information