Skip to content

RISC-V: seed extrema reductions from a valid input element - #6225

Open
SmaCow666 wants to merge 3 commits into
OpenMathLib:developfrom
SmaCow666:fix/rvv-extrema-valid-seed
Open

SmaCow666 wants to merge 3 commits into
OpenMathLib:developfrom
SmaCow666:fix/rvv-extrema-valid-seed

Conversation

@SmaCow666

Copy link
Copy Markdown

The RVV extrema kernels initialize their accumulators with FLT_MAX or -FLT_MAX, including in double precision. A finite input such as DZAMIN of one complex value {0x1p900, 0x1p899} therefore returns FLT_MAX instead of 0x1.8p900. The same initialization also clips all-positive-infinity minima and all-negative-infinity maxima.

Initialize both the reduction seed and vector accumulators from the first valid comparison value, after the existing empty/invalid-increment checks. This follows the scalar kernels and avoids introducing a finite sentinel into the reduction. Add twelve regression cases to the existing min/amin tests, including a finite double value immediately above FLT_MAX.

Local/QEMU validation used upstream 02f585444a0fba2505cfda77cc6684de008ea477, Clang 21.1.8, LP64D/32-bit BLAS integers, S/D/C/Z BLAS, pthreads with a two-thread limit, and QEMU 9.1.0:

  • Complete builds from the pinned upstream tree for RISCV64_ZVL128B and RISCV64_ZVL256B, with each PR applied independently.
  • Both targets: 153/153 unit tests and 1479/1479 extension tests pass, together with all enabled official Fortran BLAS and CBLAS Level-1/2/3 drivers in all four precisions.
  • VLEN=512: ZVL128B passes 153/153 unit and 1479/1479 extension tests. ZVL256B has three unit failures and 34 extension failures, exactly matching the named failures in the unmodified library at the same VLEN and thread count; all twelve added regressions and the targeted API checks pass. This configuration is not an all-passing full-library result. Primary runs use the target's minimum VLEN and request two threads; VLEN512 runs request one.
  • 43,200 boundary/classification checks across five RISC-V rounding modes, including 40,320 exception-flag comparisons, all passed. Arrays were read-only and bounded by inaccessible pages.
  • Proposed tests linked to unmodified current archives fail 12 cases on ZVL128B and 9 on ZVL256B; both patched suites pass.
  • Twenty Clang warning-as-error precision/NO_CBLAS compilations passed; NO_CBLAS test objects have no CBLAS references and their 22-test runners pass for both targets.
  • GCC 11 scalar-kernel portability control: 22/22 tests passed (rv64gc).
  • Library-member comparison confines changes to the affected kernels; exported symbol sets are unchanged. The patch passes git apply --check --whitespace=error-all against the pinned upstream tree.

BLAS was built with NO_LAPACK=1. A modern GCC RVV build and legacy C910V intrinsics have not been tested. No performance improvement is claimed.

Native RISC-V Linux validation (VLEN=256):

  • The same independently patched binaries pass all four target/thread cells: RISCV64_ZVL128B and RISCV64_ZVL256B, each with one and two requested threads. Each cell passes 153/153 unit tests, 1479/1479 extension tests, and all 24 enabled official S/D/C/Z Fortran BLAS and CBLAS Level-1/2/3 drivers.
  • This patch accounts for 120 native program executions; the shared unmodified-library baseline accounts for another 108. Both independently tested patches together account for 348 executions, rather than 348 per patch.
  • 43,200 guarded boundary/classification calls and 40,320 exception-flag comparisons across five rounding modes pass. Each NO_CBLAS runner passes 22/22 tests. Proposed tests linked to unmodified libraries retain the expected 12 (ZVL128B) or 9 (ZVL256B) failures per thread setting.

Native and QEMU results are separate correctness evidence; no hardware performance measurement is claimed.

XuhuiNiu added 3 commits November 5, 2026 13:14
Seed RVV extrema reductions from valid inputs instead of FLT_MAX sentinels.
Add regressions to the existing unit-test framework.

Validated against pinned upstream 02f5854 with full BLAS/CBLAS suites in QEMU and on native RISC-V VLEN256 hardware.

This branch has not been deployed

No deployments
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