Skip to content

x86 f16: implement rounding support#1380

Merged
mr-c merged 1 commit intosimd-everywhere:masterfrom
TheNumbat:f16-rounding
Feb 10, 2026
Merged

x86 f16: implement rounding support#1380
mr-c merged 1 commit intosimd-everywhere:masterfrom
TheNumbat:f16-rounding

Conversation

@TheNumbat
Copy link
Copy Markdown
Contributor

@TheNumbat TheNumbat commented Jan 30, 2026

Makes _mm_cvtps_ph/_mm256_cvtps_ph respect the rounding mode argument. Assumes _MM_FROUND_CUR_DIRECTION is always half-to-even, which isn't strictly correct, but is already assumed by various other functions.

Enables the rounding mode tests and adds a few more. There should be no behavior changes for the round-nearest and round-current cases.

@mr-c
Copy link
Copy Markdown
Collaborator

mr-c commented Jan 31, 2026

Some errors from Microsoft Visual Studio 2015 version 19.00.24241.7 and Visual Studio 2017 version 19.16.27035:

https://ci.appveyor.com/project/nemequ/simde/builds/53462546/job/ya2shs5yojpisa31#L4688

../test/x86/f16c.c:101: assertion failed: r0[1] == simde_x_mm_loadu_epi16(test_vec[i].r0)[1] (-512 == 32256)
../test/x86/f16c.c:313: assertion failed: r0[1] == simde_x_mm_loadu_epi16(test_vec[i].r0)[1] (-512 == 32256)

@mr-c mr-c force-pushed the f16-rounding branch 2 times, most recently from 9e8035c to 234fb23 Compare February 1, 2026 11:53
@TheNumbat
Copy link
Copy Markdown
Contributor Author

TheNumbat commented Feb 2, 2026

Hmm, this is weird. It's rounding qnan to -qnan instead of qnan. Could be a compiler bug that was fixed in vs2019? Are there any other differences between those jobs?

@TheNumbat
Copy link
Copy Markdown
Contributor Author

The only difference from 19.14 to 19.20 (which gives the expected answer) seems to be some spills: https://godbolt.org/z/Y59G5vK65

@TheNumbat
Copy link
Copy Markdown
Contributor Author

Actually, it appears they changed NAN...https://godbolt.org/z/MGGfP5bfs

@TheNumbat
Copy link
Copy Markdown
Contributor Author

TheNumbat commented Feb 2, 2026

I just removed the test since signed nan handling already differs between targets

Comment thread simde/x86/f16c.h Outdated
@mr-c mr-c force-pushed the f16-rounding branch 3 times, most recently from 8d1733d to 5d6d7fd Compare February 3, 2026 20:01
@mr-c mr-c changed the title Implement f16 rounding modes x86 f16: implement rounding support Feb 3, 2026
@mr-c mr-c enabled auto-merge (rebase) February 3, 2026 20:02
auto-merge was automatically disabled February 4, 2026 16:24

Head branch was pushed to by a user without write access

@TheNumbat
Copy link
Copy Markdown
Contributor Author

Looks like the Azure CI pipeline started timing out?

@mr-c
Copy link
Copy Markdown
Collaborator

mr-c commented Feb 5, 2026

@TheNumbat I will rebase this PR once #1384 is merged

@mr-c mr-c enabled auto-merge (rebase) February 9, 2026 07:17
Assumes `_MM_FROUND_CUR_DIRECTION` is always half-to-even, which isn't strictly
correct, but is already assumed by various other functions.
@mr-c mr-c merged commit 05dbd17 into simd-everywhere:master Feb 10, 2026
133 of 134 checks passed
@mr-c
Copy link
Copy Markdown
Collaborator

mr-c commented Feb 10, 2026

Thank you @TheNumbat !

@TheNumbat
Copy link
Copy Markdown
Contributor Author

np! also, for context, I'm now using simde to run https://github.com/janestreet/ocaml_simd on arm 👍

@mr-c
Copy link
Copy Markdown
Collaborator

mr-c commented Feb 10, 2026

np! also, for context, I'm now using simde to run https://github.com/janestreet/ocaml_simd on arm 👍

Very cool, thank you for letting us know! Do you want to send them a PR to incorporate SIMDe directly?

@TheNumbat
Copy link
Copy Markdown
Contributor Author

TheNumbat commented Feb 10, 2026

It's already incorporated internally (I work at Jane Street) - should appear in the repo soon-ish

@mr-c
Copy link
Copy Markdown
Collaborator

mr-c commented Feb 10, 2026

It's already incorporated internally (I work at Jane Street) - should appear in the repo soon-ish

Huzzah! Can you add an entry at https://github.com/simd-everywhere/simde/wiki/Projects-Using-SIMDe ? 💞

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