-
Notifications
You must be signed in to change notification settings - Fork 318
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
NaN propagation in exponential function #1016
Comments
Hi @nielskm , we were not focusing on NaN propagation in the design of the math library. This typically comes at a (minor but nonzero) cost. The relevant line is |
highway/hwy/contrib/math/math-inl.h Lines 1124 to 1125 in 6bc3405
The highway/hwy/contrib/math/math-inl.h Lines 829 to 832 in 6bc3405
https://www.felixcloutier.com/x86/VSCALEFPD.html https://uops.info/html-instr/VSCALEFPD_ZMM_ZMM_ZMM.html EDIT: I'm not sure exactly how it's handled / I'd have to look a lot closer, but can confirm that my implementation in Julia that uses |
Thank you both for your detailed replies! NaN propagation is not essential in my application, but I just happened to test highway Exp against std::exp and the exponential function implemented in Eigen3. Both of the others propagate NaNs, which made me wonder if this was a deliberate design choice in highway. |
@chriselrod good point about using vscale for LoadExpShortRange. We could add an AddExponent op or similar to take advantage of that, if anyone is interested. It was indeed a deliberate design choice but that can be changed if/when someone really cares about NaN propagation :) |
When applying the
Exp
function toNaN
on my CPU (Intel i7-1185G7 using the AVX3_DL target) the function returns0.0
instead of theNaN
that I expected (and thatstd::exp
returns).Is this a bug or performance-related feature of the highway
Exp
function?The text was updated successfully, but these errors were encountered: