GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — TST: Fix test_numeric on riscv64 by markdryan · Pull Request #25430 · numpy/numpy

Conversation

@markdryan

@markdryan markdryan commented Dec 19, 2023

Copy link
Copy Markdown

Modify test_numeric so that it passes on riscv64. The subtest TestBoolCmp::test_float currently fails on riscv64 as it assumes that the sign of -np.nan is retained when stored to and read back from an array. This is not always the case on riscv64. Many RISC-V instructions that produce NaNs return a canonical NaN, as defined by the RISC-V specification. The canonical NaNs are always positive. In this particular test the negative sign of the -np.nan is lost when it is converted from a double to a float before being stored in self.signf. It's best not to make any assumptions about the retention of signs for negative NaNs on RISC-V so we disable both sign tests for -np.nan on riscv64.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot added the 05 - Testing label Dec 19, 2023
@markdryan

markdryan commented Dec 19, 2023

Copy link
Copy Markdown
Author

This issue was mentioned previously in #8213 . Here I simply disable the tests entirely on risvc64 rather than modifying them to try to get them to pass as it's best to not to assume that the sign of negative NaNs will be retained on RISC-V.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seberg

seberg commented Dec 19, 2023

Copy link
Copy Markdown
Member

One thing that I do wonder a bit is whether we cannot actually make sure that assignment of a scalar NaN preserves the sign and if necessary that the NaN scalar has no signbit set (is positive).

I am a bit curious how much of this is just because the way we define np.nan is maybe just not ideal.

(This is under the assumption that mainly casts do not preserve NaN sign or payload(?))

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markdryan

markdryan commented Dec 19, 2023

Copy link
Copy Markdown
Author

One thing that I do wonder a bit is whether we cannot actually make sure that assignment of a scalar NaN preserves the sign and if necessary that the NaN scalar has no signbit set (is positive).

I am a bit curious how much of this is just because the way we define np.nan is maybe just not ideal.

(This is under the assumption that mainly casts do not preserve NaN sign or payload(?))

It's not just the casts. The RISC-V floating point arithmetic instructions (e.g., FADD, FSUB, FMUL, FMADD, FMIN, FMAX) all return the canonical NaN. Now, loads and stores and instructions that copy floating points values between registers without conversion do preserve the signs of NaNs. Even so, in this patch I disable

self.signd[3::6][self.ed[3::6]] = -np.nan

on riscv64 even though there's no conversion and this test actually passes. I felt it was a bit too fragile to leave it enabled as we'd be relying on nothing happening to that value other than it being stored and loaded. As an example of fragility,

self.signd[3::6][self.ed[3::6]] = -np.nan * 1

passes on amd64 but fails on riscv64, even though there's no conversion.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seberg

seberg commented Dec 19, 2023

Copy link
Copy Markdown
Member

Hmmm, if the test isn't failing: I don't really see anything but store/load happening here, so I honestly wouldn't change it. (The interesting part I guess being that there is no cast here in the setup code.)

self.signd[3::6][self.ed[3::6]] = -np.nan * 1 passes on ...

Yes, OK. This type of thing we should just skip on RISC V. TBH, if it goes beyond multiplying by -1 and maybe casts, maybe we shouldn't be checking NaN signs anyway probably. It isn't like any more complex math tries to do the right thing.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Mark Ryan
TST: Fix test_numeric on riscv64
468678a
Modify test_numeric so that it passes on riscv64.  The subtest
TestBoolCmp::test_float currently fails on riscv64 as it assumes that
the sign of -np.nan is retained when stored to and read back from an
array.  This is not always the case on riscv64.  Many RISC-V
instructions that produce NaNs return a canonical NaN, as defined by
the RISC-V specification. The canonical NaNs are always positive.  In
this particular test the negative sign of the -np.nan is lost when it
is converted from a double to a float before being stored in
self.signf.  We disable the float32 sign tests for -np.nan on
riscv64 allowing test_numeric to pass.
@markdryan
markdryan force-pushed the riscv64-fix-test-numeric branch from 6ac0051 to 468678a Compare January 2, 2024 12:27
@markdryan

markdryan commented Jan 2, 2024

Copy link
Copy Markdown
Author

@seberg I've re-enabled the double sign test for -np.nan on RISC-V in my PR. As discussed above, this test doesn't actually fail on RISC-V. The PR now just disables the float32 sign tests for -np.nan on RISC-V. I've also rebased the PR against main.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seberg

seberg commented Jan 18, 2024

Copy link
Copy Markdown
Member

Sorry, forgot about this. Let's get this in if it fixes tests on RISC-V. Thanks @markdryan

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seberg
seberg merged commit 41dcc02 into numpy:main Jan 18, 2024
@charris charris added the 09 - Backport-Candidate PRs tagged should be backported label Jan 18, 2024
@charris charris mentioned this pull request Jan 18, 2024
TST: Fix test_numeric on riscv64 #25618
Merged
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Jan 18, 2024
@bedroge bedroge mentioned this pull request Jun 17, 2024
BUG: 6 failing tests on RISC-V #26734
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

05 - Testing

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@markdryan @seberg @charris
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.