Skip to content

V3.98: posit v1 to posit v2 transition and adding arm64, PPC, and MINGW as cross-platform targets#508

Merged
Ravenwater merged 31 commits intomainfrom
v3.98
Feb 13, 2026
Merged

V3.98: posit v1 to posit v2 transition and adding arm64, PPC, and MINGW as cross-platform targets#508
Ravenwater merged 31 commits intomainfrom
v3.98

Conversation

@Ravenwater
Copy link
Contributor

making the bitset based posit implementation legacy and moving the limb-based implementation default.

This also brings in the FDP and Atomic Fused operators, FMA, FMMA, FAM, and separates out the quire as a standalone feature you pull in for quire related algorithms

Ravenwater and others added 30 commits February 11, 2026 19:50
… default

Move the old bitset-based posit (2-param template) to posit1/ for backward
compatibility, and promote the new BlockType-based posit2 (3-param template)
to posit/ so that #include <universal/number/posit/posit.hpp> gives consumers
the modern implementation.

Key changes:
- include/sw/universal/number/posit/ now contains the new 3-param posit
- include/sw/universal/number/posit1/ preserves the old 2-param posit
- Math library copied from posit1 into new posit with 3-param signatures
- posit_traits.hpp updated for 3-param, new posit1_traits.hpp for 2-param
- Test directories: static/posit/ (new), static/posit1/ (old)
- sqrt.hpp fixed for blockbinary::bits() → unsigned cast in table lookups
- Verification header decoupled from direct mathlib include

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The quire super-accumulator is only implemented for the old 2-param
posit (now posit1). Update the two quire test files to include
posit1/posit1.hpp instead of posit/posit.hpp.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
posito uses positRegime, positExponent, and positFraction from the old
posit implementation. Update posito.hpp and posito_impl.hpp to include
from posit1/ instead of posit/. Also fix number_system.cpp which
explicitly included posit/posit.hpp alongside posito.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- valid_impl.hpp: use posit1/posit_impl.hpp (valid depends on bitblock)
- exceptions.hpp: add shared include guard to prevent redefinition when
  both posit/ and posit1/ exceptions are included in the same TU
- takum, posito conversion tests: use posit1 (they also include posito
  which transitively includes posit1, can't mix with new 3-param posit)
- C API: all files updated to use posit1/ paths (posit_c_api.h,
  posit_c_macros.h, specialized headers, posit.hpp)
- Conversion tests: rounding, to_integer, to_posit, adapt_integer use
  old posit internals (bitblock, value) so need posit1
- BLAS fused solvers: use quire/fdp which only exists in posit1
- Education/tools: quire demos and posit property tools use posit1

CI_LITE: 397/397 tests pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- error_tracking_traits.hpp: update posit forward declaration and
  partial specialization from 2-param to 3-param template
- tracked_shadow.hpp: update posit forward declaration and TrackedPosit
  alias to 3-param template
- Tensor CG/DNN files: switch to posit1 (they use quire/fdp solvers)
- Simple mixed-precision files: remove boilerplate quire_exception catch
  blocks (std::runtime_error catch covers them)

CI_LITE: 397/397 tests pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- gemm.cpp (5 variants): switch to posit1 (uses sw::universal::fdp)
- dot/matvec/posit perf benchmarks (19 files): remove boilerplate
  quire_exception catch blocks (std::runtime_error covers them)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- education/number/posit/ (15 files): switch to posit1 (use old posit
  internals like positRegime, positExponent, positFraction, pretty_print)
- tools/cmd/posit.cpp, float2posit.cpp: switch to posit1 (use bitblock,
  internal::value, pretty_print)
- benchmark/performance/posit/performance.cpp: fix POSIT_OLD_GENERATION
  include path to posit1, update #else to new posit path

BUILD_ALL: 0 errors. CI_LITE: 397/397 tests pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Switch files using old posit internals (value<>, bitblock, quire, fdp,
  pretty_print, info_print, .get(), useed<nbits,es>, positRegime,
  positExponent, positFraction, setBitblock) to posit1
- Remove boilerplate quire_exception catch blocks from files using new posit
- Fix posit/posito coexistence: files including posito must use posit1
- Fix posit/valid coexistence: files including valid must use posit1
- Update number_systems.hpp aggregator to use posit1 (full-featured)
- Update datafile.hpp is_posit trait to is_posit1
- Fix enable_if_posit -> enable_if_posit1 in error_vs_cost.cpp
- Fix attention.cpp posit2->posit path

Files affected: 50 across applications/, education/, linalg/,
numeric/, playground/, and include/sw/blas/

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Performance benchmarks exercise all values including division by zero,
and the CG solver can encounter divide-by-zero when low-precision posits
cause stalling. Both need arithmetic exceptions disabled.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add bridge functions (convert, posit_to_value, posit_normalize_to) to
posit_impl.hpp that convert between internal::value<>/bitblock<> and
blocktriple<>/blocksignificand<> type systems. Create posit/quire.hpp
and posit/fdp.hpp adapted from posit1 with bt-templated posit-facing
methods. Migrate 19 consumer files from posit1 to new posit. Make fused
solver headers posit-agnostic so IR apps using posito can stay on posit1.
934/934 tests pass on both gcc and clang.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Migrate two_sum.cpp (.get() -> .bits(), minpos free fn -> member fn),
values.cpp, extract.cpp (add using namespace internal), and propq.cpp
to use posit/posit.hpp. Create posit/twoSum.hpp adapted from posit1
with bt-templated signature. 934/934 tests pass on gcc and clang.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace internal::value<> and internal::bitblock<> with blocktriple<> in
values.cpp and extract.cpp. The blocktriple type is the modern replacement
for the legacy value<> type system.

- values.cpp: ValidateValue -> ValidateBlocktriple, replace round_to<>
  demo with precision-across-sizes demo showing significand degradation
- extract.cpp: replace extract_fp_components/bitblock/value chain with
  blocktriple for IEEE display and direct posit assignment for conversion

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
All 13 operator>(literal_type lhs, posit rhs) free functions had an
inverted comparison: returned lhs < rhs instead of rhs < lhs. Also
fix check_inward_projection_range calls missing the bt template arg
in float2posit.cpp and conversion.cpp.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…posit.hpp

Eliminates the last value<> dependency from the posit arithmetic pipeline.
fma/fam/fmma now use blocktriple<> exclusively with extract-and-reconstruct
helpers for chaining operations across operator types. Quire/fdp moved to
standalone opt-in headers; 25+ consumer files updated with explicit includes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…sion

On aarch64-linux-gnu-g++, long double is IEEE 754 binary128 (same as
POWER), not 80-bit x87 extended. The long_double_decoder union lacked
the upper/fraction split fields, and gcc_long_double.hpp fell through
to the x86 code path referencing the nonexistent bit63 member.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…igned long long

On MinGW-w64, uint64_t and unsigned long long are the same type, so
the overload in gcc_long_double.hpp clashes with the one already
provided by extract_fp_components.hpp. Guard with !_WIN32.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The posit_c_api_pure library was only linked under if(UNIX) or
if(MSVC). MinGW cross-compilation sets CMAKE_SYSTEM_NAME=Windows,
so neither condition matched and the library was never linked.
Always link the library; only add -lm on UNIX.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The old add_test() calls used a manual path via RUNTIME_OUTPUT_DIRECTORY
which was never set, and didn't include .exe suffix for Windows targets.
Switch to add_test(NAME ... COMMAND ...) which lets CMake resolve the
correct executable path and automatically prepend the crosscompiling
emulator (wine for MinGW, qemu for ARM/RISC-V/POWER).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Wine can't find libgcc_s_seh-1.dll and libstdc++-6.dll at runtime.
Adding -static to linker flags embeds the runtime into each executable.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Two MinGW-specific GCC bugs caused 5 test failures in the CI:

1. LNS sign bit loss (4 tests): GCC's IPA ICF incorrectly folds
   different lns<nbits> setbit template instantiation fragments after
   function splitting. When lns<4> and lns<8> are in the same TU,
   the 8-bit version loses all sign bits. Fix: -fno-ipa-icf

2. floatcascade multiplication precision (1 test): MinGW's software
   std::fma() has subtle precision errors for some inputs (off by
   1-2 ULPs), breaking the error-free transformations that
   floatcascade relies on for quad-double precision. Fix: -mfma
   to use hardware FMA3 instructions instead.

Both workarounds are applied via CMAKE_CXX_FLAGS_INIT in the MinGW
toolchain file. All 390 CI_LITE tests now pass under MinGW+Wine.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Ravenwater Ravenwater self-assigned this Feb 13, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 13, 2026

Important

Review skipped

Too many files!

This PR contains 300 files, which is 150 over the limit of 150.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch v3.98

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Ravenwater Ravenwater merged commit d359b54 into main Feb 13, 2026
24 of 25 checks passed
@Ravenwater Ravenwater deleted the v3.98 branch February 13, 2026 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant