Re:C and C++ Prioritize Performance over Correctness
by bayindirh on Friday August 18, 2023 @06:57PM
(#37183192)
Thanks for the information, I'll look into that. There's another comment talking about an algorithm I have implemented, it should be around in this thread.
> So instead of doing this the dumb way and enabling -ffast-math for the whole program (which most certainly won't need it)...
When you write HPC enabled simulation code, you certainly need it, and this is where I use it.
Re:C and C++ Prioritize Performance over Correctness
by maximilianburke on Friday August 18, 2023 @10:52PM
(#37185001)
Is HPC code magically immune to values containing infs or NaNs?
> Rust doesn't allow any of that, moreover limits me the way I can write my programs, no thanks.
I'm willing to prove you wrong here. Can you give some concrete examples?
For -ffast-math you can most certainly enable it, but AFAIK for now only in a localized fashion through intrinsics, e.g.:
https://doc.rust-lang.org/std/intrinsics/fn.fadd_fast.html
https://doc.rust-lang.org/std/intrinsics/fn.fmul_fast.html
So instead of doing this the dumb way and enabling -ffast-math for the whole program (which most certainly won't need it) you can profile where you're spending the majority of your time, and only do this where it'll matter, and without the possibility of randomly breaking the rest of your numeric code.
Personally I find this to be a vastly better approach.