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

Complex signed NaN test fails on Darwin/Aarch64 #38419

Closed
Keno opened this issue Nov 13, 2020 · 6 comments · Fixed by #38420
Closed

Complex signed NaN test fails on Darwin/Aarch64 #38419

Keno opened this issue Nov 13, 2020 · 6 comments · Fixed by #38420
Labels
system:arm ARMv7 and AArch64 system:mac Affects only macOS

Comments

@Keno
Copy link
Member

Keno commented Nov 13, 2020

Test Failed at /Users/julia/julia23/test/complex.jl:1049
  Expression: isequal(one(T) / complex(T(Inf), T(-NaN)), complex(zero(T), zero(T)))
   Evaluated: isequal(0.0f0 - 0.0f0im, 0.0f0 + 0.0f0im)
Test Failed at /Users/julia/julia23/test/complex.jl:1054
  Expression: isequal(one(T) / complex(T(-Inf), T(-NaN)), complex(-(zero(T)), zero(T)))
   Evaluated: isequal(-0.0f0 - 0.0f0im, -0.0f0 + 0.0f0im)
Test Failed at /Users/julia/julia23/test/complex.jl:1067
  Expression: isequal(one(T) / complex(T(-NaN), T(Inf)), complex(-(zero(T)), -(zero(T))))
   Evaluated: isequal(0.0f0 - 0.0f0im, -0.0f0 - 0.0f0im)
Test Failed at /Users/julia/julia23/test/complex.jl:1071
  Expression: isequal(one(T) / complex(T(-NaN), T(-Inf)), complex(-(zero(T)), zero(T)))
   Evaluated: isequal(0.0f0 + 0.0f0im, -0.0f0 + 0.0f0im)

The reason for this seems to be that Apple turns on the RunFast flag, which normalizes away the sign bit of the NaN on certain operations. The question is to what extent we want to allow that or do we need to turn off RunFast or adjust the test or one of the implementations? Note that these tests do pass for Float64, only Float32 is at issue.

cc @stevengj

@Keno Keno added system:mac Affects only macOS system:arm ARMv7 and AArch64 labels Nov 13, 2020
@Keno Keno mentioned this issue Nov 13, 2020
31 tasks
@Keno
Copy link
Member Author

Keno commented Nov 13, 2020

In particular zero_subnormals is also on on this platform, so we should decide if that's what we want.

@Keno
Copy link
Member Author

Keno commented Nov 13, 2020

Or maybe we want to turn on zero_subnormals by default everywhere, since that's where things seem to be going.

@oscardssmith
Copy link
Member

Wait what? Is zeroing subnormals even ieee 704 compliant?

@Keno
Copy link
Member Author

Keno commented Nov 13, 2020

No, it isn't, but subnormals are hard to handle and cost 100-1000x as much as regular operations on modern hardware, so most ISAs not have a bit you can flip to zero them and not pay the cost. It's off by default on Aarch64 linux, so maybe we should just turn it off on Darwin also, but I figured it'd be worth taking an explicit call on that.

@oscardssmith
Copy link
Member

Note that removing subnormals breaks error compensation, and most of the theorems about floating point arithmetic

@Keno
Copy link
Member Author

Keno commented Nov 13, 2020

I guess the safe thing for now is just to turn off the fast flags, and maybe later we can add them back together with a nicer API for actually using them. We do support changing the flag right now (even on x86), but the compiler doesn't actually respect it, so it doesn't really work.

Keno added a commit that referenced this issue Nov 13, 2020
In #38419 we noticed that on AArch64 Darwin, processes start with the
FZ and DN floating point flags set. To maintain consistency across platforms,
reset these flags whenever we start julia. Not that default_nans isn't available
on x86, so while we do have julia-level wrappers for the fz flag, I'm not
adding any for the dn flag. The function is exported, so if somebody really
needs it in some aarch64-specific code, they can ccall it.
Keno added a commit that referenced this issue Nov 13, 2020
In #38419 we noticed that on AArch64 Darwin, processes start with the
FZ and DN floating point flags set. To maintain consistency across platforms,
reset these flags whenever we start julia. Not that default_nans isn't available
on x86, so while we do have julia-level wrappers for the fz flag, I'm not
adding any for the dn flag. The function is exported, so if somebody really
needs it in some aarch64-specific code, they can ccall it.
Keno added a commit that referenced this issue Nov 14, 2020
In #38419 we noticed that on AArch64 Darwin, processes start with the
FZ and DN floating point flags set. To maintain consistency across platforms,
reset these flags whenever we start julia. Not that default_nans isn't available
on x86, so while we do have julia-level wrappers for the fz flag, I'm not
adding any for the dn flag. The function is exported, so if somebody really
needs it in some aarch64-specific code, they can ccall it.
JeffBezanson pushed a commit that referenced this issue Nov 18, 2020
In #38419 we noticed that on AArch64 Darwin, processes start with the
FZ and DN floating point flags set. To maintain consistency across platforms,
reset these flags whenever we start julia. Not that default_nans isn't available
on x86, so while we do have julia-level wrappers for the fz flag, I'm not
adding any for the dn flag. The function is exported, so if somebody really
needs it in some aarch64-specific code, they can ccall it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
system:arm ARMv7 and AArch64 system:mac Affects only macOS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants