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

numbers test failure on 32bit #11654

Closed
yuyichao opened this issue Jun 10, 2015 · 16 comments
Closed

numbers test failure on 32bit #11654

yuyichao opened this issue Jun 10, 2015 · 16 comments

Comments

@yuyichao
Copy link
Contributor

I got the following test failure on a 32bit machine.....

     * numbers             exception on 1: ERROR: LoadError: test failed: 9.007199f15 == 9.0072f15
 in expression: T(i,r) == T(BigFloat(i),r)
 in error at ./error.jl:21
 in default_handler at ./test.jl:29
 in do_test at ./test.jl:52
 in anonymous at ./no file:977
 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/numbers.jl, in expression starting on line 972
ERROR: LoadError: LoadError: test failed: 9.007199f15 == 9.0072f15
 in expression: T(i,r) == T(BigFloat(i),r)
 in error at ./error.jl:21
 in default_handler at ./test.jl:29
 in do_test at ./test.jl:52
 in anonymous at ./no file:977
 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/numbers.jl, in expression starting on line 972
while loading /build/julia-git/src/julia/test/runtests.jl, in expression starting on line 5

Failing case

julia> const T = Float32
Float32

julia> i = 9007199254740993
9007199254740993

julia> r = RoundUp
Base.Rounding.RoundingMode{:Up}()

julia> b = BigFloat(i)
9.007199254740993000000000000000000000000000000000000000000000000000000000000000e+15

julia> t1 = T(i, r)
9.007199f15

julia> t2 = T(b, r)
9.0072f15

julia> t1 == t2
false

So it seems that Float32(9007199254740993, RoundUp) is not rounding up on 32bit?

Version Info is the same with the other 32bit issue I posted

julia> versioninfo()
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

Here's the LLVM and asm output

julia> @code_llvm Base.Rounding._convert_rounding(Float32, 9007199254740993, RoundUp)

define float @julia__convert_rounding_21203(%jl_value_t*, i64) {
top:
  %2 = sitofp i64 %1 to float
  %3 = fcmp olt float %2, 0x43E0000000000000
  %4 = fptosi float %2 to i64
  %5 = icmp slt i64 %4, %1
  %6 = and i1 %3, %5
  br i1 %6, label %if, label %L

if:                                               ; preds = %top
  %7 = call float @julia_nextfloat_20965(float %2, i32 1)
  ret float %7

L:                                                ; preds = %top
  ret float %2
}
julia> @code_native Base.Rounding._convert_rounding(Float32, 9007199254740993, RoundUp)
        .text
Filename: rounding.jl
Source line: 0
        pushl   %ebp
        movl    %esp, %ebp
        subl    $40, %esp
        movl    12(%ebp), %edx
        movl    16(%ebp), %ecx
Source line: 76
        movl    %ecx, -4(%ebp)
        movl    %edx, -8(%ebp)
        fildll  -8(%ebp)
Source line: 77
        fnstcw  -18(%ebp)
        movw    -18(%ebp), %ax
        movw    $3199, -18(%ebp)        # imm = 0xC7F
        fldcw   -18(%ebp)
        movw    %ax, -18(%ebp)
        fld     %st(0)
        fistpll -16(%ebp)
        fldcw   -18(%ebp)
        flds    -836567040
        fucomp  %st(1)
        fnstsw  %ax
        sahf
        jbe     L98
        cmpl    %edx, -16(%ebp)
        setae   %al
        cmpl    %ecx, -12(%ebp)
        setge   %cl
        je      L78
        movb    %cl, %al
L78:    testb   %al, %al
        jne     L98
        fstps   (%esp)
        movl    $1, 4(%esp)
        calll   0x13c0a3
L98:    addl    $40, %esp
        popl    %ebp
        retl

@simonbyrne
Copy link
Contributor

What's your code_llvm(<,(Float32,Int64))?

@simonbyrne
Copy link
Contributor

I'll need to have another look at it, but the code_llvm looks correct (it has optimised out some more operations than LLVM3.3). Is this an x87 excess precision issue?

@yuyichao
Copy link
Contributor Author

julia> code_llvm(<, Tuple{Float32, Int64})

define i1 @"julia_<_20846"(float, i64) {
top:
  %2 = sitofp i64 %1 to float
  %3 = fcmp ogt float %2, %0
  %4 = fcmp oeq float %2, %0
  %5 = fcmp olt float %2, 0x43E0000000000000
  %6 = and i1 %4, %5
  %7 = fptosi float %2 to i64
  %8 = icmp slt i64 %7, %1
  %9 = and i1 %6, %8
  %10 = or i1 %3, %9
  ret i1 %10
}

@yuyichao
Copy link
Contributor Author

BTW, there seems to be a new other failure in this container as well. Should I report them individually?....

@nalimilan
Copy link
Member

Just to be sure: you didn't pass MARCH=i386 or i686 when building?

@yuyichao
Copy link
Contributor Author

@nalimilan Build flags are here MARCH is i686.

IIRC, the build fails (or sth similar) if MARCH is not set....

@yuyichao
Copy link
Contributor Author

openblas is compiled separately in case it looks confusing in versioninfo()

@nalimilan
Copy link
Member

OK, so that's the same issue as #7185 (among others). You need to build Julia with at least MARCH=pentium4 at the moment.

It would make sense to raise an error from the Makefile when i386 or i686 is passed, to avoid wasting people's time.

@yuyichao
Copy link
Contributor Author

I see.

@yuyichao
Copy link
Contributor Author

@nalimilan So is #11642 also the same issue?

@nalimilan
Copy link
Member

I have no idea, but it's really worth retrying with MARCH=pentium4.

@yuyichao
Copy link
Contributor Author

@nalimilan Doing that

@yuyichao
Copy link
Contributor Author

@nalimilan It appears to be the same issue.

@nalimilan
Copy link
Member

Nice to hear!

@nalimilan
Copy link
Member

This PR should make this less of a trap: #11656

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants