#mageec Log for 2013-07-24

--- Log opened Wed Jul 24 00:00:49 2013
-!- munaafghumran [~mg0950@cpc10-aztw24-2-0-cust177.aztw.cable.virginmedia.com] has joined #mageec07:38
AWhetterWeird bugs day #2: The result of an arithmetic expression is different on 32 bit and 64 bit, despite the operands being the same and overflow not occuring11:43
AWhetterThis seems odd. The expression is of the form (ans += a * b) where all variables are floats. If I store a * b in a float before adding the float to ans, it works12:03
@simoncooktry a*b in brackets?12:06
@simoncookit shouldnt make a difference as * has higer precedence than += but possibly worth a try12:07
AWhetterNope. Doesn't work12:08
@simoncookdoes the difference in assembly generated hint at anything12:08
AWhetterHow do I find that out?12:10
@simoncookadding -S to gcc will stop the compilation after generating an assembly file, or -save-temps will save all the temporaries including the assembly file and finish compilation, then just diff12:11
@simoncookwhat types are a and b?12:16
AWhetterfloats12:17
AWhetterI don't really know assembly well enough but I think there's something that might be significantly different.12:18
AWhetterWould you mind taking a look?12:18
@simoncookI can, I was just about to get lunch, so I can look in about half an hour12:20
AWhetterok. Maybe I'll go for lunch as well then.12:20
AWhetterhttp://underrun.org/~gadget/32to64.diff12:20
AWhetterThe diff is there though whenever you get back12:20
AWhetterThanks :)12:20
@simoncookcan you also link the code that you built12:21
-!- amylaar_ [~joern@cust213-dsl91-135-11.idnet.net] has joined #mageec12:35
@jeremybennettI asked amylaar_ (Joern) to join and give the benefit of his expertise12:43
AWhettersimoncook: yeah. I'll tar it up now12:47
AWhetterhttp://underrun.org/~gadget/float_matmult.tar.gz12:50
AWhetterThe line is line 222 in matmult.c12:51
AWhetterAt the moment it has the working code but if you remove the to_add variable is fails on 32 bit12:52
AWhetterIt's the 337th loop iteration that fails. So in gdb I'm doing break 222, run, continue 337, *check variables*, continue, *check variables* and the result is incorrect12:54
@simoncookso on an incorrect result it exists with non-zero return code, its working fine here for me in both cases12:59
@simoncookaah wait, without you said, let me change that12:59
@simoncookHave you run this on a non-x86 platform, does this also fail, I think this may be just errors in comparing two floats (0.000013668251%)13:27
@simoncookJust rounding errors, ignorable IMO13:28
AWhetterNot sure. I'll run it on one of the ARM boards now13:42
@jeremybennettLooking at the values in your checking array, you are close to the limit of 32-bit floats - around 7 decimal digits13:44
@jeremybennettIn fact you are beyond - you are specifying 9 digits. FP calculations are tricky around the limit a = x * y followed by b +=a may not give the same result as b += x * y if the internal calculation is done to greater accuracy.13:47
AWhetterI'll double check but it looks like it works on arm13:48
@jeremybennettI suspect there is an option to enforce strict 32-bit IEE 745 compliance, but I could imagine that by default the internal FP calculation is more accurate, and so you may have variability in the last bit.13:48
AWhetterYep. It works on arm13:49
@jeremybennettI suggest your test for correctness should be tolerant of a +/- 1-bit variation in the LSB of the mantissa.13:49
amylaar_there's -ffloat-store, and -mfpmath=sse .14:01
@jeremybennettAnd by IEEE 745 I mean IEEE 754 (http://en.wikipedia.org/wiki/IEEE_754-1985)14:06
AWhetterIt works if I ignore the least significant bit of the mantissa14:25
AWhetterThanks for the help everyone14:25
@simoncookJust to add a possible minor complication, are you ignoring that bit in a way that doesnt break regardless of endianness14:27
AWhetterNo but it's easy to make it work for both14:28
AWhetterI have no idea if the other benchmarks are going to work on any endianness though14:28
@jeremybennettBut they ought to. I imagine we have both LE and BE devices in our collection.14:29
amylaar_on most hosts, the endianness of int32_t and float is the same.14:38
amylaar_To cover the rest, you'd have to do some complex tests - either autoconf, or something done at runtime in your program.14:39
-!- munaafghumran_ [~mg0950@cpc10-aztw24-2-0-cust177.aztw.cable.virginmedia.com] has joined #mageec20:11
-!- munaafghumran [~mg0950@cpc10-aztw24-2-0-cust177.aztw.cable.virginmedia.com] has quit [Ping timeout: 268 seconds]20:14
-!- munaafghumran_ [~mg0950@cpc10-aztw24-2-0-cust177.aztw.cable.virginmedia.com] has quit [Ping timeout: 268 seconds]21:47
--- Log closed Thu Jul 25 00:00:54 2013

Generated by irclog2html.py 2.12.1 by Marius Gedminas - find it at mg.pov.lt!