Skip to content
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

Add round_ties_even to f32 and f64 #95317

Merged
merged 4 commits into from
Mar 7, 2023

Conversation

Jules-Bertholet
Copy link
Contributor

@Jules-Bertholet Jules-Bertholet commented Mar 25, 2022

Tracking issue: #96710

Redux of #82273. See also #55107

Adds a new method, round_ties_even, to f32 and f64, that rounds the float to the nearest integer , rounding halfway cases to the number with an even least significant bit. Uses the roundeven LLVM intrinsic to do this.

Of the five IEEE 754 rounding modes, this is the only one that doesn't already have a round-to-integer function exposed by Rust (others are round, floor, ceil, and trunc). Ties-to-even is also the rounding mode used for int-to-float and float-to-float as casts, as well as float arithmentic operations. So not having an explicit rounding method for it seems like an oversight.

Bikeshed: this PR currently uses round_ties_even for the name of the method. But maybe round_ties_to_even is better, or round_even, or round_to_even?

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 25, 2022
@rust-highfive
Copy link
Collaborator

Some changes occured to rustc_codegen_gcc

cc @antoyo

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @yaahc (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 25, 2022
@yaahc yaahc added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Mar 28, 2022
@bors

This comment was marked as outdated.

@rust-log-analyzer

This comment has been minimized.

@pnkfelix
Copy link
Member

Assuming that the symbol names are correct for the cranelift and gcc codegen backends, the compiler changes here look simple and correct.

so I'd say r=me for the compiler side. I'll let @yaahc speak for the libs side.

@clarfonthey
Copy link
Contributor

Don't think this should block merging this PR, but just to add my opinion to the mix, I've basically always seen this called round-even which would translate to round_even as a method name. "round ties to even" or "round ties even" just seems unnecessarily verbose, especially when the documentation should alleviate any confusion on what it does.

@yaahc
Copy link
Member

yaahc commented Apr 29, 2022

I'm reassigning this PR because I'm taking a break from the review rotation for a little while. Thank you for your patience.

r? rust-lang/libs-api

@scottmcm
Copy link
Member

scottmcm commented May 4, 2022

Given that we have div_euclid, maybe something like round_banker? It's short-ish, and gives good search results.

Other inspiration from wikipedia:

This variant of the round-to-nearest method is also called convergent rounding, statistician's rounding, Dutch rounding, Gaussian rounding, odd–even rounding, or bankers' rounding.

@m-ou-se
Copy link
Member

m-ou-se commented May 4, 2022

Bikeshed: this PR currently usesround_ties_even for the name of the method. But maybe round_ties_to_even is better, or round_even, or round_to_even?

We can leave the bikeshed for later, after adding this as unstable but before stabilization.

Can you open a tracking issue for this feature? Please include the open question about the name of the function, and the open question about whether this should be the default behaviour of round() as was mentioned by @dsprenkels on #82273. Thanks!

@Jules-Bertholet
Copy link
Contributor Author

Tracking issue opened.

@bors

This comment was marked as outdated.

@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 20, 2022
@apiraino
Copy link
Contributor

apiraino commented Jul 6, 2022

Hello, is the status (waiting for review) of this PR correct? Any pending comments from T-libs? Thanks

@scottmcm scottmcm added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 6, 2022
@scottmcm
Copy link
Member

scottmcm commented Jul 6, 2022

Looks like this has a r=me for the compiler changes, and a "seems reasonable" from libs-api, so I think this is just waiting on a tracking issue (#95317 (comment)) to be mergeable, with bikesheds to happen on that tracking issue. So I've marked it S-author.

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 4, 2023
@rust-log-analyzer
Copy link
Collaborator

The job dist-x86_64-mingw failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[2618/3025] Building CXX object tools/dsymutil/CMakeFiles/dsymutil.dir/DwarfLinkerForBinary.cpp.obj
[2619/3025] Building CXX object tools/dsymutil/CMakeFiles/dsymutil.dir/Reproducer.cpp.obj
[2620/3025] Building CXX object tools/dsymutil/CMakeFiles/dsymutil.dir/dsymutil-driver.cpp.obj
[2621/3025] Linking CXX static library lib\libLLVMBPFCodeGen.a
FAILED: lib/libLLVMBPFCodeGen.a 
cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E rm -f lib\libLLVMBPFCodeGen.a && D:\a\rust\rust\mingw64\bin\ar.exe qc lib\libLLVMBPFCodeGen.a  lib/Target/BPF/CMakeFiles/LLVMBPFCodeGen.dir/BPFAbstractMemberAccess.cpp.obj lib/Target/BPF/CMakeFiles/LLVMBPFCodeGen.dir/BPFAdjustOpt.cpp.obj lib/Target/BPF/CMakeFiles/LLVMBPFCodeGen.dir/BPFAsmPrinter.cpp.obj lib/Target/BPF/CMakeFiles/LLVMBPFCodeGen.dir/BPFCheckAndAdjustIR.cpp.obj lib/Target/BPF/CMakeFiles/LLVMBPFCodeGen.dir/BPFFrameLowering.cpp.obj lib/Target/BPF/CMakeFiles/LLVMBPFCodeGen.dir/BPFInstrInfo.cpp.obj lib/Target/BPF/CMakeFiles/LLVMBPFCodeGen.dir/BPFIRPeephole.cpp.obj lib/Target/BPF/CMakeFiles/LLVMBPFCodeGen.dir/BPFISelDAGToDAG.cpp.obj lib/Target/BPF/CMakeFiles/LLVMBPFCodeGen.dir/BPFISelLowering.cpp.obj lib/Target/BPF/CMakeFiles/LLVMBPFCodeGen.dir/BPFMCInstLower.cpp.obj lib/Target/BPF/CMakeFiles/LLVMBPFCodeGen.dir/BPFPreserveDIType.cpp.obj lib/Target/BPF/CMakeFiles/LLVMBPFCodeGen.dir/BPFRegisterInfo.cpp.obj lib/Target/BPF/CMakeFiles/LLVMBPFCodeGen.dir/BPFSelectionDAGInfo.cpp.obj lib/Target/BPF/CMakeFiles/LLVMBPFCodeGen.dir/BPFSubtarget.cpp.obj lib/Target/BPF/CMakeFiles/LLVMBPFCodeGen.dir/BPFTargetMachine.cpp.obj lib/Target/BPF/CMakeFiles/LLVMBPFCodeGen.dir/BPFMIPeephole.cpp.obj lib/Target/BPF/CMakeFiles/LLVMBPFCodeGen.dir/BPFMIChecking.cpp.obj lib/Target/BPF/CMakeFiles/LLVMBPFCodeGen.dir/BPFMISimplifyPatchable.cpp.obj lib/Target/BPF/CMakeFiles/LLVMBPFCodeGen.dir/BTFDebug.cpp.obj && D:\a\rust\rust\mingw64\bin\ranlib.exe lib\libLLVMBPFCodeGen.a && cd ."
D:\a\rust\rust\mingw64\bin\ranlib.exe: could not create temporary file whilst writing archive: no more archived files
[2622/3025] Linking CXX static library lib\libLLVMGlobalISel.a
[2623/3025] Linking CXX static library lib\libLLVMMSP430CodeGen.a
[2624/3025] Building CXX object tools/dsymutil/CMakeFiles/dsymutil.dir/BinaryHolder.cpp.obj
[2625/3025] Building CXX object tools/lli/ChildTarget/CMakeFiles/lli-child-target.dir/ChildTarget.cpp.obj
[2625/3025] Building CXX object tools/lli/ChildTarget/CMakeFiles/lli-child-target.dir/ChildTarget.cpp.obj
[2626/3025] Linking CXX static library lib\libLLVMHexagonCodeGen.a
[2627/3025] Linking CXX executable bin\llvm-profdata.exe
[2628/3025] Linking CXX static library lib\libLLVMPasses.a
ninja: build stopped: subcommand failed.
command did not execute successfully, got: exit code: 1


build script failed, must exit now', C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\cmake-0.1.48\src\lib.rs:975:5
 finished in 250.789 seconds
Build completed unsuccessfully in 0:07:03

@WaffleLapkin
Copy link
Member

D:\a\rust\rust\mingw64\bin\ranlib.exe: could not create temporary file whilst writing archive: no more archived files

Looks spurious.
@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 6, 2023
@bors
Copy link
Contributor

bors commented Mar 7, 2023

⌛ Testing commit 371d570 with merge 9f10e462f6256a1db9f38ef3bc46f917dd753c95...

@bors
Copy link
Contributor

bors commented Mar 7, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 7, 2023
@WaffleLapkin
Copy link
Member

This failure doesn't look related either
@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 7, 2023
@bors
Copy link
Contributor

bors commented Mar 7, 2023

⌛ Testing commit 371d570 with merge 0a3b557...

@bors
Copy link
Contributor

bors commented Mar 7, 2023

☀️ Test successful - checks-actions
Approved by: pnkfelix,m-ou-se,scottmcm
Pushing 0a3b557 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 7, 2023
@bors bors merged commit 0a3b557 into rust-lang:master Mar 7, 2023
@rustbot rustbot added this to the 1.70.0 milestone Mar 7, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (0a3b557): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.3% [1.3%, 1.3%] 1
Regressions ❌
(secondary)
0.8% [0.8%, 0.8%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.3% [-2.2%, -0.9%] 5
All ❌✅ (primary) 1.3% [1.3%, 1.3%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

@rust-log-analyzer
Copy link
Collaborator

The job i686-mingw-1 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
error: make failed
status: exit code: 2
command: "make"
--- stdout -------------------------------
make[1]: Entering directory '/d/a/rust/rust/tests/run-make-fulldeps/target-specs'
PATH="/d/a/rust/rust/build/i686-pc-windows-gnu/test/run-make-fulldeps/target-specs/target-specs:D:\a\rust\rust\build\i686-pc-windows-gnu\stage2\bin:/d/a/rust/rust/build/i686-pc-windows-gnu/stage0-bootstrap-tools/i686-pc-windows-gnu/release/deps:/d/a/rust/rust/build/i686-pc-windows-gnu/stage0/bin:/d/a/rust/rust/ninja:/d/a/rust/rust/mingw32/bin:/c/hostedtoolcache/windows/Python/3.11.2/x64/Scripts:/c/hostedtoolcache/windows/Python/3.11.2/x64:/usr/bin:/d/a/rust/rust/sccache:/c/Program Files/MongoDB/Server/5.0/bin:/c/aliyun-cli:/c/vcpkg:/c/cf-cli:/c/Program Files (x86)/NSIS:/c/tools/zstd:/c/Program Files/Mercurial:/c/hostedtoolcache/windows/stack/2.9.3/x64:/c/cabal/bin:/c/ghcup/bin:/c/Program Files/dotnet:/c/mysql/bin:/c/Program Files/R/R-4.2.2/bin/x64:/c/SeleniumWebDrivers/GeckoDriver:/c/Program Files (x86)/sbt/bin:/c/Program Files (x86)/GitHub CLI:/c/Program Files/Git/bin:/c/Program Files (x86)/pipx_bin:/c/npm/prefix:/c/hostedtoolcache/windows/go/1.17.13/x64/bin:/c/hostedtoolcache/windows/Python/3.7.9/x64/Scripts:/c/hostedtoolcache/windows/Python/3.7.9/x64:/c/hostedtoolcache/windows/Ruby/2.5.9/x64/bin:/c/tools/kotlinc/bin:/c/hostedtoolcache/windows/Java_Temurin-Hotspot_jdk/8.0.362-9/x64/bin:/c/Program Files/ImageMagick-7.1.0-Q16-HDRI:/c/Program Files (x86)/Microsoft SDKs/Azure/CLI2/wbin:/c/ProgramData/kind:/c/Program Files/Eclipse Foundation/jdk-8.0.302.8-hotspot/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/ProgramData/Chocolatey/bin:/c/Program Files/PowerShell/7:/c/Program Files/Microsoft/Web Platform Installer:/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn:/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit:/c/Program Files (x86)/Microsoft SQL Server/110/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/120/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/130/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/140/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/150/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/160/DTS/Binn:/c/Program Files/OpenSSL/bin:/c/Strawberry/c/bin:/c/Strawberry/perl/site/bin:/c/Strawberry/perl/bin:/c/ProgramData/chocolatey/lib/pulumi/tools/Pulumi/bin:/c/Program Files/TortoiseSVN/bin:/c/Program Files/CMake/bin:/c/ProgramData/chocolatey/lib/maven/apache-maven-3.9.0/bin:/c/Program Files/Microsoft Service Fabric/bin/Fabric/Fabric.Code:/c/Program Files/Microsoft SDKs/Service Fabric/Tools/ServiceFabricLocalClusterManager:/c/Program Files/nodejs:/c/Program Files/Git/cmd:/c/Program Files/Git/mingw64/bin:/c/Program Files/Git/usr/bin:/c/Program Files/GitHub CLI:/c/tools/php:/c/Program Files (x86)/sbt/bin:/c/SeleniumWebDrivers/ChromeDriver:/c/SeleniumWebDrivers/EdgeDriver:/c/Program Files/Amazon/AWSCLIV2:/c/Program Files/Amazon/SessionManagerPlugin/bin:/c/Program Files/Amazon/AWSSAMCLI/bin:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/Program Files (x86)/Microsoft BizTalk Server:/c/Program Files/LLVM/bin:/c/Users/runneradmin/.dotnet/tools:/c/Users/runneradmin/.cargo/bin:/c/Users/runneradmin/AppData/Local/Microsoft/WindowsApps" 'D:\a\rust\rust\build\i686-pc-windows-gnu\stage2\bin\rustc.exe' --out-dir /d/a/rust/rust/build/i686-pc-windows-gnu/test/run-make-fulldeps/target-specs/target-specs -L /d/a/rust/rust/build/i686-pc-windows-gnu/test/run-make-fulldeps/target-specs/target-specs  foo.rs --target=my-awesome-platform.json --crate-type=lib --emit=asm
"D:\a\rust\rust/src/etc/cat-and-grep.sh" -v morestack < /d/a/rust/rust/build/i686-pc-windows-gnu/test/run-make-fulldeps/target-specs/target-specs/foo.s
[[[ begin stdout ]]]
 .text
 .file "foo.91a024fd-cgu.0"
 .section ".note.GNU-stack","",@progbits
Some tests failed in compiletest suite=run-make-fulldeps mode=run-make host=i686-pc-windows-gnu target=i686-pc-windows-gnu

[[[ end stdout ]]]
PATH="/d/a/rust/rust/build/i686-pc-windows-gnu/test/run-make-fulldeps/target-specs/target-specs:D:\a\rust\rust\build\i686-pc-windows-gnu\stage2\bin:/d/a/rust/rust/build/i686-pc-windows-gnu/stage0-bootstrap-tools/i686-pc-windows-gnu/release/deps:/d/a/rust/rust/build/i686-pc-windows-gnu/stage0/bin:/d/a/rust/rust/ninja:/d/a/rust/rust/mingw32/bin:/c/hostedtoolcache/windows/Python/3.11.2/x64/Scripts:/c/hostedtoolcache/windows/Python/3.11.2/x64:/usr/bin:/d/a/rust/rust/sccache:/c/Program Files/MongoDB/Server/5.0/bin:/c/aliyun-cli:/c/vcpkg:/c/cf-cli:/c/Program Files (x86)/NSIS:/c/tools/zstd:/c/Program Files/Mercurial:/c/hostedtoolcache/windows/stack/2.9.3/x64:/c/cabal/bin:/c/ghcup/bin:/c/Program Files/dotnet:/c/mysql/bin:/c/Program Files/R/R-4.2.2/bin/x64:/c/SeleniumWebDrivers/GeckoDriver:/c/Program Files (x86)/sbt/bin:/c/Program Files (x86)/GitHub CLI:/c/Program Files/Git/bin:/c/Program Files (x86)/pipx_bin:/c/npm/prefix:/c/hostedtoolcache/windows/go/1.17.13/x64/bin:/c/hostedtoolcache/windows/Python/3.7.9/x64/Scripts:/c/hostedtoolcache/windows/Python/3.7.9/x64:/c/hostedtoolcache/windows/Ruby/2.5.9/x64/bin:/c/tools/kotlinc/bin:/c/hostedtoolcache/windows/Java_Temurin-Hotspot_jdk/8.0.362-9/x64/bin:/c/Program Files/ImageMagick-7.1.0-Q16-HDRI:/c/Program Files (x86)/Microsoft SDKs/Azure/CLI2/wbin:/c/ProgramData/kind:/c/Program Files/Eclipse Foundation/jdk-8.0.302.8-hotspot/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/ProgramData/Chocolatey/bin:/c/Program Files/PowerShell/7:/c/Program Files/Microsoft/Web Platform Installer:/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn:/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit:/c/Program Files (x86)/Microsoft SQL Server/110/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/120/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/130/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/140/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/150/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/160/DTS/Binn:/c/Program Files/OpenSSL/bin:/c/Strawberry/c/bin:/c/Strawberry/perl/site/bin:/c/Strawberry/perl/bin:/c/ProgramData/chocolatey/lib/pulumi/tools/Pulumi/bin:/c/Program Files/TortoiseSVN/bin:/c/Program Files/CMake/bin:/c/ProgramData/chocolatey/lib/maven/apache-maven-3.9.0/bin:/c/Program Files/Microsoft Service Fabric/bin/Fabric/Fabric.Code:/c/Program Files/Microsoft SDKs/Service Fabric/Tools/ServiceFabricLocalClusterManager:/c/Program Files/nodejs:/c/Program Files/Git/cmd:/c/Program Files/Git/mingw64/bin:/c/Program Files/Git/usr/bin:/c/Program Files/GitHub CLI:/c/tools/php:/c/Program Files (x86)/sbt/bin:/c/SeleniumWebDrivers/ChromeDriver:/c/SeleniumWebDrivers/EdgeDriver:/c/Program Files/Amazon/AWSCLIV2:/c/Program Files/Amazon/SessionManagerPlugin/bin:/c/Program Files/Amazon/AWSSAMCLI/bin:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/Program Files (x86)/Microsoft BizTalk Server:/c/Program Files/LLVM/bin:/c/Users/runneradmin/.dotnet/tools:/c/Users/runneradmin/.cargo/bin:/c/Users/runneradmin/AppData/Local/Microsoft/WindowsApps" 'D:\a\rust\rust\build\i686-pc-windows-gnu\stage2\bin\rustc.exe' --out-dir /d/a/rust/rust/build/i686-pc-windows-gnu/test/run-make-fulldeps/target-specs/target-specs -L /d/a/rust/rust/build/i686-pc-windows-gnu/test/run-make-fulldeps/target-specs/target-specs  foo.rs --target=my-invalid-platform.json 2>&1 | "D:\a\rust\rust/src/etc/cat-and-grep.sh" "Error loading target specification"
[[[ begin stdout ]]]
error: Error loading target specification: expected value at line 1 column 1. Run `rustc --print target-list` for a list of built-in targets


[[[ end stdout ]]]
PATH="/d/a/rust/rust/build/i686-pc-windows-gnu/test/run-make-fulldeps/target-specs/target-specs:D:\a\rust\rust\build\i686-pc-windows-gnu\stage2\bin:/d/a/rust/rust/build/i686-pc-windows-gnu/stage0-bootstrap-tools/i686-pc-windows-gnu/release/deps:/d/a/rust/rust/build/i686-pc-windows-gnu/stage0/bin:/d/a/rust/rust/ninja:/d/a/rust/rust/mingw32/bin:/c/hostedtoolcache/windows/Python/3.11.2/x64/Scripts:/c/hostedtoolcache/windows/Python/3.11.2/x64:/usr/bin:/d/a/rust/rust/sccache:/c/Program Files/MongoDB/Server/5.0/bin:/c/aliyun-cli:/c/vcpkg:/c/cf-cli:/c/Program Files (x86)/NSIS:/c/tools/zstd:/c/Program Files/Mercurial:/c/hostedtoolcache/windows/stack/2.9.3/x64:/c/cabal/bin:/c/ghcup/bin:/c/Program Files/dotnet:/c/mysql/bin:/c/Program Files/R/R-4.2.2/bin/x64:/c/SeleniumWebDrivers/GeckoDriver:/c/Program Files (x86)/sbt/bin:/c/Program Files (x86)/GitHub CLI:/c/Program Files/Git/bin:/c/Program Files (x86)/pipx_bin:/c/npm/prefix:/c/hostedtoolcache/windows/go/1.17.13/x64/bin:/c/hostedtoolcache/windows/Python/3.7.9/x64/Scripts:/c/hostedtoolcache/windows/Python/3.7.9/x64:/c/hostedtoolcache/windows/Ruby/2.5.9/x64/bin:/c/tools/kotlinc/bin:/c/hostedtoolcache/windows/Java_Temurin-Hotspot_jdk/8.0.362-9/x64/bin:/c/Program Files/ImageMagick-7.1.0-Q16-HDRI:/c/Program Files (x86)/Microsoft SDKs/Azure/CLI2/wbin:/c/ProgramData/kind:/c/Program Files/Eclipse Foundation/jdk-8.0.302.8-hotspot/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/ProgramData/Chocolatey/bin:/c/Program Files/PowerShell/7:/c/Program Files/Microsoft/Web Platform Installer:/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn:/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit:/c/Program Files (x86)/Microsoft SQL Server/110/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/120/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/130/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/140/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/150/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/160/DTS/Binn:/c/Program Files/OpenSSL/bin:/c/Strawberry/c/bin:/c/Strawberry/perl/site/bin:/c/Strawberry/perl/bin:/c/ProgramData/chocolatey/lib/pulumi/tools/Pulumi/bin:/c/Program Files/TortoiseSVN/bin:/c/Program Files/CMake/bin:/c/ProgramData/chocolatey/lib/maven/apache-maven-3.9.0/bin:/c/Program Files/Microsoft Service Fabric/bin/Fabric/Fabric.Code:/c/Program Files/Microsoft SDKs/Service Fabric/Tools/ServiceFabricLocalClusterManager:/c/Program Files/nodejs:/c/Program Files/Git/cmd:/c/Program Files/Git/mingw64/bin:/c/Program Files/Git/usr/bin:/c/Program Files/GitHub CLI:/c/tools/php:/c/Program Files (x86)/sbt/bin:/c/SeleniumWebDrivers/ChromeDriver:/c/SeleniumWebDrivers/EdgeDriver:/c/Program Files/Amazon/AWSCLIV2:/c/Program Files/Amazon/SessionManagerPlugin/bin:/c/Program Files/Amazon/AWSSAMCLI/bin:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/Program Files (x86)/Microsoft BizTalk Server:/c/Program Files/LLVM/bin:/c/Users/runneradmin/.dotnet/tools:/c/Users/runneradmin/.cargo/bin:/c/Users/runneradmin/AppData/Local/Microsoft/WindowsApps" 'D:\a\rust\rust\build\i686-pc-windows-gnu\stage2\bin\rustc.exe' --out-dir /d/a/rust/rust/build/i686-pc-windows-gnu/test/run-make-fulldeps/target-specs/target-specs -L /d/a/rust/rust/build/i686-pc-windows-gnu/test/run-make-fulldeps/target-specs/target-specs  foo.rs --target=my-incomplete-platform.json 2>&1 | "D:\a\rust\rust/src/etc/cat-and-grep.sh" 'Field llvm-target'
[[[ begin stdout ]]]
error: Error loading target specification: Field llvm-target in target specification is required. Run `rustc --print target-list` for a list of built-in targets


[[[ end stdout ]]]
RUST_TARGET_PATH=. PATH="/d/a/rust/rust/build/i686-pc-windows-gnu/test/run-make-fulldeps/target-specs/target-specs:D:\a\rust\rust\build\i686-pc-windows-gnu\stage2\bin:/d/a/rust/rust/build/i686-pc-windows-gnu/stage0-bootstrap-tools/i686-pc-windows-gnu/release/deps:/d/a/rust/rust/build/i686-pc-windows-gnu/stage0/bin:/d/a/rust/rust/ninja:/d/a/rust/rust/mingw32/bin:/c/hostedtoolcache/windows/Python/3.11.2/x64/Scripts:/c/hostedtoolcache/windows/Python/3.11.2/x64:/usr/bin:/d/a/rust/rust/sccache:/c/Program Files/MongoDB/Server/5.0/bin:/c/aliyun-cli:/c/vcpkg:/c/cf-cli:/c/Program Files (x86)/NSIS:/c/tools/zstd:/c/Program Files/Mercurial:/c/hostedtoolcache/windows/stack/2.9.3/x64:/c/cabal/bin:/c/ghcup/bin:/c/Program Files/dotnet:/c/mysql/bin:/c/Program Files/R/R-4.2.2/bin/x64:/c/SeleniumWebDrivers/GeckoDriver:/c/Program Files (x86)/sbt/bin:/c/Program Files (x86)/GitHub CLI:/c/Program Files/Git/bin:/c/Program Files (x86)/pipx_bin:/c/npm/prefix:/c/hostedtoolcache/windows/go/1.17.13/x64/bin:/c/hostedtoolcache/windows/Python/3.7.9/x64/Scripts:/c/hostedtoolcache/windows/Python/3.7.9/x64:/c/hostedtoolcache/windows/Ruby/2.5.9/x64/bin:/c/tools/kotlinc/bin:/c/hostedtoolcache/windows/Java_Temurin-Hotspot_jdk/8.0.362-9/x64/bin:/c/Program Files/ImageMagick-7.1.0-Q16-HDRI:/c/Program Files (x86)/Microsoft SDKs/Azure/CLI2/wbin:/c/ProgramData/kind:/c/Program Files/Eclipse Foundation/jdk-8.0.302.8-hotspot/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/ProgramData/Chocolatey/bin:/c/Program Files/PowerShell/7:/c/Program Files/Microsoft/Web Platform Installer:/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn:/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit:/c/Program Files (x86)/Microsoft SQL Server/110/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/120/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/130/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/140/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/150/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/160/DTS/Binn:/c/Program Files/OpenSSL/bin:/c/Strawberry/c/bin:/c/Strawberry/perl/site/bin:/c/Strawberry/perl/bin:/c/ProgramData/chocolatey/lib/pulumi/tools/Pulumi/bin:/c/Program Files/TortoiseSVN/bin:/c/Program Files/CMake/bin:/c/ProgramData/chocolatey/lib/maven/apache-maven-3.9.0/bin:/c/Program Files/Microsoft Service Fabric/bin/Fabric/Fabric.Code:/c/Program Files/Microsoft SDKs/Service Fabric/Tools/ServiceFabricLocalClusterManager:/c/Program Files/nodejs:/c/Program Files/Git/cmd:/c/Program Files/Git/mingw64/bin:/c/Program Files/Git/usr/bin:/c/Program Files/GitHub CLI:/c/tools/php:/c/Program Files (x86)/sbt/bin:/c/SeleniumWebDrivers/ChromeDriver:/c/SeleniumWebDrivers/EdgeDriver:/c/Program Files/Amazon/AWSCLIV2:/c/Program Files/Amazon/SessionManagerPlugin/bin:/c/Program Files/Amazon/AWSSAMCLI/bin:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/Program Files (x86)/Microsoft BizTalk Server:/c/Program Files/LLVM/bin:/c/Users/runneradmin/.dotnet/tools:/c/Users/runneradmin/.cargo/bin:/c/Users/runneradmin/AppData/Local/Microsoft/WindowsApps" 'D:\a\rust\rust\build\i686-pc-windows-gnu\stage2\bin\rustc.exe' --out-dir /d/a/rust/rust/build/i686-pc-windows-gnu/test/run-make-fulldeps/target-specs/target-specs -L /d/a/rust/rust/build/i686-pc-windows-gnu/test/run-make-fulldeps/target-specs/target-specs  foo.rs --target=my-awesome-platform --crate-type=lib --emit=asm
RUST_TARGET_PATH=. PATH="/d/a/rust/rust/build/i686-pc-windows-gnu/test/run-make-fulldeps/target-specs/target-specs:D:\a\rust\rust\build\i686-pc-windows-gnu\stage2\bin:/d/a/rust/rust/build/i686-pc-windows-gnu/stage0-bootstrap-tools/i686-pc-windows-gnu/release/deps:/d/a/rust/rust/build/i686-pc-windows-gnu/stage0/bin:/d/a/rust/rust/ninja:/d/a/rust/rust/mingw32/bin:/c/hostedtoolcache/windows/Python/3.11.2/x64/Scripts:/c/hostedtoolcache/windows/Python/3.11.2/x64:/usr/bin:/d/a/rust/rust/sccache:/c/Program Files/MongoDB/Server/5.0/bin:/c/aliyun-cli:/c/vcpkg:/c/cf-cli:/c/Program Files (x86)/NSIS:/c/tools/zstd:/c/Program Files/Mercurial:/c/hostedtoolcache/windows/stack/2.9.3/x64:/c/cabal/bin:/c/ghcup/bin:/c/Program Files/dotnet:/c/mysql/bin:/c/Program Files/R/R-4.2.2/bin/x64:/c/SeleniumWebDrivers/GeckoDriver:/c/Program Files (x86)/sbt/bin:/c/Program Files (x86)/GitHub CLI:/c/Program Files/Git/bin:/c/Program Files (x86)/pipx_bin:/c/npm/prefix:/c/hostedtoolcache/windows/go/1.17.13/x64/bin:/c/hostedtoolcache/windows/Python/3.7.9/x64/Scripts:/c/hostedtoolcache/windows/Python/3.7.9/x64:/c/hostedtoolcache/windows/Ruby/2.5.9/x64/bin:/c/tools/kotlinc/bin:/c/hostedtoolcache/windows/Java_Temurin-Hotspot_jdk/8.0.362-9/x64/bin:/c/Program Files/ImageMagick-7.1.0-Q16-HDRI:/c/Program Files (x86)/Microsoft SDKs/Azure/CLI2/wbin:/c/ProgramData/kind:/c/Program Files/Eclipse Foundation/jdk-8.0.302.8-hotspot/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/ProgramData/Chocolatey/bin:/c/Program Files/PowerShell/7:/c/Program Files/Microsoft/Web Platform Installer:/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn:/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit:/c/Program Files (x86)/Microsoft SQL Server/110/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/120/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/130/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/140/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/150/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/160/DTS/Binn:/c/Program Files/OpenSSL/bin:/c/Strawberry/c/bin:/c/Strawberry/perl/site/bin:/c/Strawberry/perl/bin:/c/ProgramData/chocolatey/lib/pulumi/tools/Pulumi/bin:/c/Program Files/TortoiseSVN/bin:/c/Program Files/CMake/bin:/c/ProgramData/chocolatey/lib/maven/apache-maven-3.9.0/bin:/c/Program Files/Microsoft Service Fabric/bin/Fabric/Fabric.Code:/c/Program Files/Microsoft SDKs/Service Fabric/Tools/ServiceFabricLocalClusterManager:/c/Program Files/nodejs:/c/Program Files/Git/cmd:/c/Program Files/Git/mingw64/bin:/c/Program Files/Git/usr/bin:/c/Program Files/GitHub CLI:/c/tools/php:/c/Program Files (x86)/sbt/bin:/c/SeleniumWebDrivers/ChromeDriver:/c/SeleniumWebDrivers/EdgeDriver:/c/Program Files/Amazon/AWSCLIV2:/c/Program Files/Amazon/SessionManagerPlugin/bin:/c/Program Files/Amazon/AWSSAMCLI/bin:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/Program Files (x86)/Microsoft BizTalk Server:/c/Program Files/LLVM/bin:/c/Users/runneradmin/.dotnet/tools:/c/Users/runneradmin/.cargo/bin:/c/Users/runneradmin/AppData/Local/Microsoft/WindowsApps" 'D:\a\rust\rust\build\i686-pc-windows-gnu\stage2\bin\rustc.exe' --out-dir /d/a/rust/rust/build/i686-pc-windows-gnu/test/run-make-fulldeps/target-specs/target-specs -L /d/a/rust/rust/build/i686-pc-windows-gnu/test/run-make-fulldeps/target-specs/target-specs  foo.rs --target=my-x86_64-unknown-linux-gnu-platform --crate-type=lib --emit=asm
make[1]: Leaving directory '/d/a/rust/rust/tests/run-make-fulldeps/target-specs'
--- stderr -------------------------------
--- stderr -------------------------------
warning: target json file contains unused fields: morestack

warning: `extern` block uses type `[u8; 16]`, which is not FFI-safe
   |
   |
19 |     fn _foo() -> [u8; 16];
   |                  ^^^^^^^^ not FFI-safe
   = help: consider passing a pointer to the array
   = help: consider passing a pointer to the array
   = note: passing raw arrays by value is not FFI-safe
   = note: `#[warn(improper_ctypes)]` on by default
warning: 1 warning emitted


warning: target json file contains unused fields: morestack

warning: `extern` block uses type `[u8; 16]`, which is not FFI-safe
   |
   |
19 |     fn _foo() -> [u8; 16];
   |                  ^^^^^^^^ not FFI-safe
   = help: consider passing a pointer to the array
   = help: consider passing a pointer to the array
   = note: passing raw arrays by value is not FFI-safe
   = note: `#[warn(improper_ctypes)]` on by default
warning: 1 warning emitted


warning: target json file contains unused fields: morestack

warning: `extern` block uses type `[u8; 16]`, which is not FFI-safe
   |
   |
19 |     fn _foo() -> [u8; 16];
   |                  ^^^^^^^^ not FFI-safe
   = help: consider passing a pointer to the array
   = help: consider passing a pointer to the array
   = note: passing raw arrays by value is not FFI-safe
   = note: `#[warn(improper_ctypes)]` on by default
warning: 1 warning emitted


make[1]: *** [Makefile:8: all] Segmentation fault



failures:
failures:
    [run-make] tests\run-make-fulldeps\target-specs

test result: FAILED. 188 passed; 1 failed; 41 ignored; 0 measured; 0 filtered out; finished in 74.99s

Build completed unsuccessfully in 1:00:54
make: *** [Makefile:78: ci-mingw-subset-1] Error 1

@saethlin
Copy link
Member

saethlin commented Mar 11, 2023

Why do the tests here use assert_approx_eq? It looks to me like at least the existing test cases could be using assert_eq, and that any imprecision at all would be a bug, even if it is less than 1e-6, no?

@Jules-Bertholet
Copy link
Contributor Author

I just cargo-culted the round tests, which use assert_approx_eq. It seems the choice was originally made in 0e2242f

bjorn3 pushed a commit to bjorn3/rust that referenced this pull request Mar 15, 2023
…=pnkfelix,m-ou-se,scottmcm

Add `round_ties_even` to `f32` and `f64`

Tracking issue: rust-lang#96710

Redux of rust-lang#82273. See also rust-lang#55107

Adds a new method, `round_ties_even`, to `f32` and `f64`, that rounds the float to the nearest integer , rounding halfway cases to the number with an even least significant bit. Uses the `roundeven` LLVM intrinsic to do this.

Of the five IEEE 754 rounding modes, this is the only one that doesn't already have a round-to-integer function exposed by Rust (others are `round`, `floor`, `ceil`, and `trunc`).  Ties-to-even is also the rounding mode used for int-to-float and float-to-float `as` casts, as well as float arithmentic operations. So not having an explicit rounding method for it seems like an oversight.

Bikeshed: this PR currently uses `round_ties_even` for the name of the method. But maybe `round_ties_to_even` is better, or `round_even`, or `round_to_even`?
antoyo pushed a commit to antoyo/rust that referenced this pull request Jun 19, 2023
…=pnkfelix,m-ou-se,scottmcm

Add `round_ties_even` to `f32` and `f64`

Tracking issue: rust-lang#96710

Redux of rust-lang#82273. See also rust-lang#55107

Adds a new method, `round_ties_even`, to `f32` and `f64`, that rounds the float to the nearest integer , rounding halfway cases to the number with an even least significant bit. Uses the `roundeven` LLVM intrinsic to do this.

Of the five IEEE 754 rounding modes, this is the only one that doesn't already have a round-to-integer function exposed by Rust (others are `round`, `floor`, `ceil`, and `trunc`).  Ties-to-even is also the rounding mode used for int-to-float and float-to-float `as` casts, as well as float arithmentic operations. So not having an explicit rounding method for it seems like an oversight.

Bikeshed: this PR currently uses `round_ties_even` for the name of the method. But maybe `round_ties_to_even` is better, or `round_even`, or `round_to_even`?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.