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

Optimize round and roundf #253

Merged
merged 1 commit into from
Jul 2, 2021
Merged

Optimize round and roundf #253

merged 1 commit into from
Jul 2, 2021

Conversation

bvinc
Copy link
Contributor

@bvinc bvinc commented Jul 1, 2021

In reference to #154, this optimizes the round and roundf functions. This does not change the behavior at all.

I compared all f32 values to verify that the behavior of roundf has not changed.

For round, I directly translated the roundf function and verified that it behaved the same with random bits for the sign and exponent and beginning and end of the mantissa.

I ran some criterion benchmarks and basically both functions went from about 7ns to about 3ns.

round/round             time:   [7.1414 ns 7.1470 ns 7.1543 ns]                         
round/round_new         time:   [3.0178 ns 3.0311 ns 3.0471 ns]                             

roundf/roundf           time:   [6.8636 ns 6.8767 ns 6.9016 ns]                           
roundf/roundf_new       time:   [2.8326 ns 2.8401 ns 2.8562 ns]                               

@Lokathor
Copy link
Contributor

Lokathor commented Jul 1, 2021

Looks like we had some CI trouble, but actually we haven't been passing CI lately to begin with.

It appears that none of the failures were because of thia PR.

My only thought is that in general we might want to mark these and other functions as inline, but that can be done later.

@bvinc I can merge if you're all done.

@bvinc
Copy link
Contributor Author

bvinc commented Jul 2, 2021

I'm done, but I'll add #inline too if you want. Looks like it should definitely be on copysign/copysignf. Are you sure we also want inline on trunc/truncf?

@Lokathor
Copy link
Contributor

Lokathor commented Jul 2, 2021

oh i forgot how big that one is.

we'll do inline separate, I'll just merge for now.

@Lokathor Lokathor merged commit aa030b8 into rust-lang:master Jul 2, 2021
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