What Rust construct uses nearbyint from libsystem_m?

I've profiled my program with Valgrind and Callgrind and found that most of the time is spent in the nearbyint$fenv_access_off function.

I've found that it's a LLVM intrinsic, but which Rust language construct uses it? How can I avoid it?

Answers


Doing a search for nearbyint finds the related symbols nearbyintf32 and nearbyintf64. These are documented as returning the nearest integer to a floating point value. However, there appears to be no calls to that specific function.

fenv_access_off appears to be an OS X specific aspect of the math library.

The other thing in your trace is round. I can believe that round could use nearbyint. I also don't see any cases of round in the standard library that seem like they would occur in a tight loop.

Beyond this, anything is pure guessing.


I've reproduced it with:

fn main() {
    let data:Vec<_> = (0..999999).map(|x|{
        (x as f64).powf(2.2).round() as u8
    }).collect();
}

so it seems as u8 is implemented using nearbyint.

It's the same speed as C uchar = round(pow(i, 2.2)), so I'll have to replace it with a good'ol lookup tableā€¦


Need Your Help

Splash screen never fully loading before being closed

c# winforms splash

I am currently adding a splash screen to my winform. My splash screen is just another form, where,

Why paint messages get lost even after calling UpdateWindow()?

c++ windows mfc paint cwnd

I have an application with following windows hierarchy: