Earlier quoted context omitted.
Direct3D used to flip the x87 FPU to single precision mode by default. This produced some amazing bugs when your other C libraries reasonably assumed that a double would be at least 64 bits. (The FPU mode settings affected the thread that called Direct3D, and most programs used to be single-threaded.) It seems they changed this behavior in Direct3D 10: https://microsoft.public.win32.programmer.directx.graphics.n...
I stumbled into this bug in a rather spetacular manner. I was making a game using D3D, Lua and Chipmunk physics, and some of the behaviour of the game was being odd. So I started to try printing random stuff with Lua, eventually I just tried: print(5+5), and to my surprise my console outputted "11". I went into Lua's irc channel to talk about this, and everyone said I was nuts, that the number was too small to trigge…
Someone’s Been Messing with My Subnormals
111–120 of 132 posts
Re: Someone’s Been Messing with My Subnormals
#112FWIW, this is tangential to this awesome article, but if the author is here or anyone else who cares: that statement isn’t true, you are not legally obligated to mention GNU Parallel. It is nice to do though! The link even says this explicitly, and also separately mentions the citation notice is only asking for scientific paper citations, not blog citations. I love parallel, but boy has that citation notice thing caused a lot of confusion over the years.
Re: Someone’s Been Messing with My Subnormals
#113At a previous company I worked at, we had an issue with our software (Windows-based, written in a proprietary language) randomly crashing. After some debugging, we found that this happened whenever the user made some specific actions, but only if, in that session, the user had previously printed something or opened a file picker. The culprit was either a printer driver or a shell extension which, when loaded, changed…
Of course that's why floating point math is mostly a big no-no in driver code. Unless the driver preserves and restores FPU state on its own.
Re: Someone’s Been Messing with My Subnormals
#114Global state is the root of so many evils! FPU rounding mode, FPU flush-to-zero mode, C locale, errno, and probably some other things should all be eliminated. The functionality should still exist but not as global flags.
Somewhere on this page there's a discussion of dirty upper half states in Intel vector instructions, and something similar might help there.
Re: Someone’s Been Messing with My Subnormals
#115> it turns out that when you use -Ofast, -fno-fast-math does not, in fact, disable fast math. lol. lmao. What about -fno-unsafe-math-optimizations?
Nope, it still links in crtfastmath: $ gcc -Ofast -fno-unsafe-math-optimizations -fpic -shared foo.c -o foo.so $ objdump -j .text --disassemble=set_fast_math foo.so foo.so: file format elf64-x86-64 Disassembly of section .text: 0000000000001040 : 1040: f3 0f 1e fa endbr64 1044: 0f ae 5c 24 fc stmxcsr -0x4(%rsp) 1049: 81 4c 24 fc 40 80 00 orl $0x8040,-0x4(%rsp) 1050: 00 1051: 0f ae 54 24 fc ldmxcsr -0x4(%rsp) 1056: c3…
Do people ever actually test their fixes?
Edit: right, via btrees:
https://github.com/zopefoundation/BTrees/pull/179/files
https://github.com/zopefoundation/meta/commit/2a33089508792e...
Re: Someone’s Been Messing with My Subnormals
#11610/10 yak shave. Would certainly read again
Re: Someone’s Been Messing with My Subnormals
#117At a previous company I worked at, we had an issue with our software (Windows-based, written in a proprietary language) randomly crashing. After some debugging, we found that this happened whenever the user made some specific actions, but only if, in that session, the user had previously printed something or opened a file picker. The culprit was either a printer driver or a shell extension which, when loaded, changed…
I've heard so many stories akin to this one that I just shake my head. It's a self-inflicted wound that people who prioritize performance above other considerations keep inflicting on everyone else . I hope we learned our lessons on this specific question in the design of Wasm. There are subnormals in Wasm and you can't turn them off for performance.
Re: Someone’s Been Messing with My Subnormals
#118Global state is the root of so many evils! FPU rounding mode, FPU flush-to-zero mode, C locale, errno, and probably some other things should all be eliminated. The functionality should still exist but not as global flags.
At least many of those are thread-local. But not C locale, it is truly horrible.
And implicit locales should just die. It's sad that even newer functionality like std::format relies on them. Sadder that if it didn't then you'd probably have compiler developers pulling shit like GCC/libstdc++ does for std::from_chars [0] which defeats the entire point of that function but hey, at least they can mark that as implemented. Not like there are suitably licensed implementations of the functionality [1] available that they could use instead if they don't want to implement float parsing themselves.
[0] https://github.com/gcc-mirror/gcc/blob/master/libstdc++-v3/s...
Re: Someone’s Been Messing with My Subnormals
#119I ran Gentoo back in the good old days. The biggest draw was that after about a week of compiling my system ran a lot faster because of all the compiler optimisations one could enable because it only had to work on your CPU. I might be misremembering, but I think fastmath was one of the flags explicitly warned against in the Gentoo manual.
Though compiling for the exact CPU was definitely not insignificant before the amd64 switch which gave a new baseline - many distros still targeted i586.
Re: Someone’s Been Messing with My Subnormals
#120Earlier quoted context omitted.
Yeah, I don't know the breakdown between better hardware and better compiler optimizations (even in the default settings) and less differentiation between processors, but I've done some minor not-very-scientific tests of compiling packages with O3/march=mtune=native and in my limited experience it wasn't particularly useful. Like, not just small benefits, but zero or below the noise floor benefits in my benchmarks. O…
Tune for native sometimes makes a difference but not always. Targeting a platform that is known to have AVX2, instead of detecting AVX2 at runtime and bouncing through the PLT, can make a large difference. PGO remains the largest opportunity.