Skip to content

Fix sort_test build on toolchains without native float16#3113

Open
dcsid wants to merge 1 commit into
google:masterfrom
dcsid:fix/sort-test-f16
Open

Fix sort_test build on toolchains without native float16#3113
dcsid wants to merge 1 commit into
google:masterfrom
dcsid:fix/sort-test-f16

Conversation

@dcsid

@dcsid dcsid commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

sort_test.cc fails to build where hwy::float16_t is emulated: std::iota with T{0} needs construction from int, and -kInf needs unary minus (GCC 9–12, Clang 11–15, armv7, ppc64le, LoongArch64, Windows LLVM). Fixes #3112.

Errors reproduce under -DHWY_HAVE_SCALAR_F16_TYPE=0 and compile cleanly with the fix; sort_test --gtest_filter='*SelectWithNaN*' passes on AArch64.

@jan-wassenberg jan-wassenberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks :) FYI #3109 fixes the missing #if. Let's wait for that one to land, then merge.

I'm curious which compiler you're targeting? HWY_HAVE_SCALAR_F16_OPERATORS is not universal, but ought to be widely available. Perhaps we can get that to 1, or maybe we should extend the emulation of hwy::float16_t.

std::iota with T{0} requires construction from int, and -kInf requires
unary minus; the emulated hwy::float16_t provides neither. Use
ConvertScalarTo and ScalarAbs instead. Fixes google#3112.
@dcsid dcsid force-pushed the fix/sort-test-f16 branch from 1d8e63d to 50a7f41 Compare June 12, 2026 18:13
@dcsid

dcsid commented Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto #3109, now just the ConvertScalarTo/ScalarAbs constructs.

No particular compiler, just hit it on the CI matrix. FWIW the emulated float16_t gaps were construction from int (std::iota's T{0}) and unary minus (-kInf); covering those via HWY_HAVE_SCALAR_F16_OPERATORS or the emulation would drop the need for the guard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sort_test fails to build on toolchains without native float16 (since 636d64d8)

2 participants