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

linalg/pinv failure on 32bit #11642

Closed
yuyichao opened this issue Jun 9, 2015 · 3 comments
Closed

linalg/pinv failure on 32bit #11642

yuyichao opened this issue Jun 9, 2015 · 3 comments
Labels
system:32-bit Affects only 32-bit systems

Comments

@yuyichao
Copy link
Contributor

yuyichao commented Jun 9, 2015

I got the following error on a 32bit container which I think I haven't seen on the CI before.

[root@yuyichao julia]# ./julia test/runtests.jl linalg/pinv
     * linalg/pinv         exception on 1: ERROR: LoadError: mismatch of non-finite elements: 
  a = Inf
  0.0 = 0.0
 in test_approx_eq at ./test.jl:131
 in anonymous at ./no file:298
 in include at ./boot.jl:253
 in runtests at /build/julia-git/src/julia/test/testdefs.jl:197
 in anonymous at ./multi.jl:644
 in run_work_thunk at ./multi.jl:605
 in remotecall_fetch at ./multi.jl:678
 in remotecall_fetch at ./multi.jl:693
 in anonymous at ./task.jl:1422
while loading /build/julia-git/src/julia/test/linalg/pinv.jl, in expression starting on line 294
ERROR: LoadError: LoadError: mismatch of non-finite elements: 
  a = Inf
  0.0 = 0.0
 in test_approx_eq at ./test.jl:131
 in anonymous at ./no file:298
 in include at ./boot.jl:253
 in runtests at /build/julia-git/src/julia/test/testdefs.jl:197
 in anonymous at ./multi.jl:644
 in run_work_thunk at ./multi.jl:605
 in remotecall_fetch at ./multi.jl:678
 in remotecall_fetch at ./multi.jl:693
 in anonymous at ./task.jl:1422
while loading /build/julia-git/src/julia/test/linalg/pinv.jl, in expression starting on line 294
while loading /build/julia-git/src/julia/test/runtests.jl, in expression starting on line 5

Version info.

Julia Version 0.4.0-dev+5287
Commit c7e2b33* (2015-06-09 22:19 UTC)
Platform Info:
  System: Linux (i686-pc-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz
  WORD_SIZE: 32
  BLAS: libopenblas (DYNAMIC_ARCH NO_AFFINITY Nehalem)
  LAPACK: libopenblas
  LIBM: libm
  LLVM: libLLVM-3.6.1
@yuyichao
Copy link
Contributor Author

yuyichao commented Jun 9, 2015

A slightly better repro.

julia> using Base.Test

julia> debug = true
true

julia> for eltya in (Float32, Float64)
           debug && println("\n\n<<<<<", eltya, ">>>>>")
           debug && println("\n--- sub-normal constant ---")
           a = pinv(realmin(eltya)/100)
           @test_approx_eq a 0.0
           debug && println("\n\n<<<<<Complex{", eltya, "}>>>>>")
           debug && println("\n--- sub-normal constant ---")
           a = pinv(realmin(eltya)/100*(1+1im))
           @test_approx_eq a 0.0
       end


<<<<<Float32>>>>>

--- sub-normal constant ---
ERROR: mismatch of non-finite elements: 
  a = Inf
  0.0 = 0.0
 in test_approx_eq at ./test.jl:131
 in anonymous at ./no file:5

@tkelman tkelman added the system:32-bit Affects only 32-bit systems label Jun 9, 2015
@yuyichao
Copy link
Contributor Author

yuyichao commented Jun 9, 2015

Maybe a llvm 3.6.1 bug?

julia> a = (realmin(Float32) / 100)
1.1755f-40                                                                        

julia> @code_llvm pinv(a)

define float @julia_pinv_21040(float) {                                           
top:                                                                              
  %1 = fdiv float 1.000000e+00, %0                                                
  %2 = fsub float %1, %1                                                          
  store volatile float %2, float* bitcast (i128* @jl_float_temp to float*), align 4                                                                                 
  %3 = load volatile float* bitcast (i128* @jl_float_temp to float*), align 4     
  %4 = fcmp une float %3, 0.000000e+00                                            
  %5 = select i1 %4, float 0.000000e+00, float %1                                 
  ret float %5                                                                    
}                                                                                 

julia> inv(a)
Inf32                                                                             

julia> isfinite(inv(a))
false

julia> @code_lowered pinv(a)
1-element Array{Any,1}:
 :($(Expr(:lambda, Any[:x], Any[Any[Any[:x,:Any,0],Any[:xi,:Any,18]],Any[],0,Any[]], :(begin  # linalg/dense.jl, line 442:
        xi = inv(x) # line 443:
        return ifelse(isfinite(xi),xi,zero(xi))
    end))))

julia> @code_native pinv(a)
        .text
Filename: dense.jl
Source line: 0
        pushl   %ebp
        movl    %esp, %ebp
        fld1
Source line: 442
        fdivs   8(%ebp)
Source line: 443
        fld     %st(0)
        fsub    %st(1)
        fstps   -835670016
        flds    -835670016
        fldz
        fxch    %st(1)
        fucomp  %st(1)
        fnstsw  %ax
        sahf
        jne     L43
        jp      L43
        fstp    %st(0)
        fldz
        fxch    %st(1)
L43:    fstp    %st(1)
        popl    %ebp

@yuyichao
Copy link
Contributor Author

Close because this is a known issue with MARCH=i686

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
system:32-bit Affects only 32-bit systems
Projects
None yet
Development

No branches or pull requests

2 participants