Skip to content

Documents arithmetic reduction semantics #412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 5, 2018

Conversation

gnzlbg
Copy link
Contributor

@gnzlbg gnzlbg commented Apr 3, 2018

This PR documents the arithmetic reductions and updates stdsimd to the latest changes in the RFC:

  • sum -> wrapping_sum
  • product -> wrapping_product
  • min -> min_element
  • max -> max_element.

Currently there are two open issues that affect computations involving NaNs:

  • llvm.experimental.vector.reduce.f{min,max} do not behave like we'd like with respect to NaNs due to min_element / max_element produce incorrect results for NaNs in the last place #408 (which points to the LLVM bug). Basically, we want these to behave like min/max for floating point numbers, that is, they should always return a number unless all elements in a vector are NaN just like IEEE-754 {min,max}Num and {minimum,maximum}Number do. Right now, they behave more like fcmp+select, producing different results depending on where NaNs are situated inside a vector. For example, (NaN, 1., 2., -1.).min_element() returns -1. but (-1., 1., 2., NaN).min_element() returns NaN...

  • llvm.experimental.vector.reduce.f{add,mul} are a bit broken upstream and only work with math flags enabled. . . (see floating-point sum / product are buggy w.r.t. NaNs #409 which points to the LLVM bug). They do produce correct results AFAICT, but because fast-maths are enabled code around these makes incorrect assumptions about their results when they are NaN. For example: (1., 2., NaN, 4.).wrapping_sum() returns NaN but (1., 2., NaN, 4.).wrapping_sum().is_nan() returns false...

We should work around these in stdsimd.

@gnzlbg gnzlbg merged commit 65740ab into rust-lang:master Apr 5, 2018
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.

2 participants