680 karma · joined Mar 27, 2014 (12y ago) · 212 submissions
comment 5y ago · link · parent
comment 5y ago · link · parent
The problem isn't necessarily the code they wrote themselves: it is often that they've compiled someone else's code or an open source library with fast-math, which broke some internal piece.
comment 5y ago · link · parent
As always, the devil is in the details: you typically can't check exact equality, as e.g. reassociating arithmetic can give slightly different (but not necessarily worse) results. So the challenge is coming up with appropriate measure of determining whether something is wrong.
comment 5y ago · link · parent
However if you do f(x) - g(x), the absolute error is on the order of 2e190: if f(x) - g(x) is small, then now the relative error can be huge (this is known as catastrophic cancellation).
comment 5y ago · link · parent
a * d - b * c
If a == b and c == d (and all are finite), then this should give 0 (which is true for strict IEEE 754 math), but if you replace it with an fma then you can get either a positive or negative value, depending on the order in which it was contracted. Issues like this pop up in complex multiplication, or applying the quadratic formula.
comment 5y ago · link · parent
comment 5y ago · link · parent
14.
Beware of fast-math(simonbyrne.github.io ↗)
189 points · by simonbyrne · 5y ago · 107 comments
comment 5y ago · link · parent
Possibly prompted by historical precedent: https://en.wikipedia.org/wiki/Moscow_Signal
comment 6y ago · link · parent
comment 7y ago · link · parent
- its exposition is complicated (trying to prove everything in a general base makes it difficult to understand)
- it's woefully out of date (lack of guard digits haven't been an issue for at least 25 years, extended precision hasn't been an issue for the past 10 or so, and most languages now default to having fairly strict floating point semantics)
- it gets bogged down in irrelevant minutiae (rounding modes and exception flags, while available in modern hardware, aren't really supported by any modern languages/compilers)
- it doesn't really provide any practical advice (it barely mentions binary-decimal conversion, it jumps to doubling precision and Kahan summation without suggesting any intermediate steps such as sorted or pairwise summation).
But my biggest complaint is the frequency with which users are referred to it on StackOverflow as if (1) it is a good way to learn about floating point concepts, and (2) anyone using floating point numbers should be expected to understand it all.
comment 7y ago · link · parent
Additionally, these sorts of supercomputers are also a way for governments to implicitly subsidise their tech industries: when viewed through that lens, spreading these contracts around makes a lot more sense.
comment 7y ago · link · parent
comment 7y ago · link · parent
That said, gotos are still occasionally very useful: jumping out of nested loops and implementing finite-state machines are both made much easier and clearer via gotos than trying to force them into more standard control flow statements.
The linux kernel also makes judicious use of gotos for cleaning up error handling: https://koblents.com/Ches/Links/Month-Mar-2013/20-Using-Goto...
comment 7y ago · link · parent
28.
ReviewNB: Code Reviews for Jupyter Notebooks(reviewnb.com ↗)
2 points · by simonbyrne · 7y ago · discuss
comment 7y ago · link · parent
R makes it very easy to see the underlying R code (you just type the function name), until you get to a ".Call" or ".Primitive": from that point, it is effectively a black box.
But as most of Julia is written in Julia, you can easily inspect and understand how functions work, all the way down. Moreover, by using the @code_* macros, you can also inspect the various stages by which the code is transformed from high level Julia code down to the actual machine code which is running on your computer.