rust-lang / rust-lang/portable-simd

Test suite assumes that cos, exp, and other functions have deterministic precision

Open
#463 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1.1k
Forks
108
Avg merge
22h 53m
Merged PRs (30d)
3

Description

After landing https://github.com/rust-lang/rust/pull/138062, the portable-simd test suite no longer passes in Miri:

0.005650   ---- f32::cos::lanes_1 stdout ----
  0.000026   
  0.000010   thread 'f32::cos::lanes_1' panicked at /home/runner/work/miri-test-libstd/miri-test-libstd/rust-src-patched/library/portable-simd/crates/test_helpers/src/lib.rs:126:43:
  0.000008   called `Result::unwrap()` on an `Err` value: Fail(Reason("assertion failed: `(left == right)` \n  left: `[-0.7418637 (bf3deac8)]`,\n right: `[-0.7418636 (bf3deac6)]` at crates/test_helpers/src/lib.rs:183"), [-207806100.0])
  0.000008   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
  0.000007   note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
  0.000007   
  0.000007   ---- f32::cos::lanes_2 stdout ----
  0.000007   
  0.000007   thread 'f32::cos::lanes_2' panicked at /home/runner/work/miri-test-libstd/miri-test-libstd/rust-src-patched/library/portable-simd/crates/test_helpers/src/lib.rs:126:43:
  0.000007   called `Result::unwrap()` on an `Err` value: Fail(Reason("assertion failed: `(left == right)` \n  left: `[-0.7418637 (bf3deac8), 1.0 (3f800000)]`,\n right: `[-0.74186367 (bf3deac7), 1.0 (3f800000)]` at crates/test_helpers/src/lib.rs:183"), [-207806100.0, 0.0])
  0.000022   failures:
  0.070860       f32::cos::lanes_1
  0.014170       f32::cos::lanes_2
  0.013913       f32::cos::lanes_3
  0.015623       f32::cos::lanes_6
  0.013689       f32::exp2::lanes_1
  0.014103       f32::exp2::lanes_2
  0.015393       f32::exp2::lanes_3
  0.013566       f32::exp2::lanes_6
  0.013604       f32::exp::lanes_1
  0.015736       f32::exp::lanes_2
  0.013619       f32::exp::lanes_3
  0.013681       f32::exp::lanes_6
  0.013655       f32::ln::lanes_1
  0.015216       f32::ln::lanes_2
  0.013688       f32::ln::lanes_3
  0.013658       f32::ln::lanes_6
  0.015251       f32::log10::lanes_1
  0.013628       f32::log10::lanes_2
  0.013611       f32::log10::lanes_3
  0.015248       f32::log10::lanes_6
  0.013703       f32::log2::lanes_1
  0.013625       f32::log2::lanes_2
  0.015322       f32::log2::lanes_3
  0.014007       f32::log2::lanes_6
  0.013735       f32::log::lanes_2
  0.015216       f32::log::lanes_3
  0.013565       f32::log::lanes_6
  0.013636       f32::sin::lanes_1
  0.015283       f32::sin::lanes_2
  0.014103       f32::sin::lanes_3
  0.013599       f32::sin::lanes_6
  0.015191       f64::cos::lanes_1
  0.013988       f64::cos::lanes_2
  0.013582       f64::cos::lanes_3
  0.013634       f64::cos::lanes_6
  0.015589       f64::exp2::lanes_1
  0.013691       f64::exp2::lanes_2
  0.013704       f64::exp2::lanes_3
  0.015679       f64::exp2::lanes_6
  0.013647       f64::exp::lanes_1
  0.014061       f64::exp::lanes_2
  0.015406       f64::exp::lanes_3
  0.013673       f64::exp::lanes_6
  0.013610       f64::ln::lanes_1
  0.015338       f64::ln::lanes_2
  0.013550       f64::ln::lanes_3
  0.013579       f64::ln::lanes_6
  0.015199       f64::log10::lanes_1
  0.013582       f64::log10::lanes_2
  0.013587       f64::log10::lanes_3
  0.015058       f64::log10::lanes_6
  0.013520       f64::log2::lanes_1
  0.013474       f64::log2::lanes_2
  0.013490       f64::log2::lanes_3
  0.014898       f64::log2::lanes_6
  0.013661       f64::log::lanes_1
  0.013527       f64::log::lanes_2
  0.014919       f64::log::lanes_3
  0.013641       f64::log::lanes_6
  0.013585       f64::sin::lanes_1
  0.015452       f64::sin::lanes_2
  0.013729       f64::sin::lanes_3
  0.013687       f64::sin::lanes_6

These functions do not have guaranteed precision, so results should probably by compared with assert_approx_ex instead of assert_eq, at least when running in Miri.

Cc @LorrensP-2158466

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in library/portable-simd/crates/test_helpers/src/lib.rs around lines 126 and 183, where the reported comparisons fail, and review how the listed trigonometric, exponential, and logarithmic tests use the helpers. Run the portable-simd test suite in Miri and verify that these functions use appropriate approximate comparisons and no longer produce the reported failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.