slow float comparison

125 views
Skip to first unread message

wil...@gmail.com

unread,
May 21, 2014, 3:28:10 PM5/21/14
to juli...@googlegroups.com
I have following problem: one of the comparison between two floats takes upto 10 times slower then other.

Here is a code (https://github.com/wildart/kNN.jl/blob/master/src/kdtree.jl#L99-L120). In line 99 and line 120 have the same two floats comparison. When functions runs line 120 is executed more times then line 99, but profiler show strange results

 1407 .../v0.3/kNN/src/kdtree.jl nearest                                    99
   161 .../v0.3/kNN/src/kdtree.jl nearest                                   120

If we look at the generated code, see below, for line 120 intrinsic function called, but for line 99, called wrapper to intrinsic comparison function

        Line 99                                             Line 120
        unless #s1169::Bool goto 4                 unless #s1162::Bool goto 14
        #s1168 = #s1169::Bool                        #s1161 = #s1162::Bool
        goto 5                                                goto 15
        4:                                                      14:
        #s1168 = d < T::Float64                       #s1161 = top(le_float)(d::Float64,T::Float64)::Bool
        5:                                                      15:
        unless #s1168 goto 10 # line 100:        unless #s1161::Bool goto 17 # line 121:

I attached script that reproduces this problem.

problem.jl

wil...@gmail.com

unread,
May 21, 2014, 3:41:27 PM5/21/14
to juli...@googlegroups.com
Forgot to add, I'm running 0.3.0-1044 from ppa:staticfloat/julianightlies.

Iain Dunning

unread,
May 21, 2014, 8:46:47 PM5/21/14
to juli...@googlegroups.com
What is the type of d after evaluate?
Reply all
Reply to author
Forward
0 new messages