Live data from Hacker News

Someone’s Been Messing with My Subnormals

moyix.blogspot.com

11–20 of 132 posts

Re: Someone’s Been Messing with My Subnormals

#11

Dynamic linking is the root of all kinds of evil, enough said.

The content of this post has nothing to do with the specifics of dynamic linking: it would be just as true if the wheels in question had static binaries instead.

Eh, somewhere in the middle. Someone else put ‘-ffast-math’ in a compile line and it poisons FP math far away with no recompile?

I believe it’s a necessary price in this case, but it does highlight how suboptimal it is to pay the price in other cases.

Re: Someone’s Been Messing with My Subnormals

#12

I 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.

It was and people would still use it because “hey it says fast”.

The CPU flags was less interesting to me compared to being able to disable features like X.

Re: Someone’s Been Messing with My Subnormals

#13

I 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.

There was a big warning that it might produce broken system, iirc

Re: Someone’s Been Messing with My Subnormals

#14

Earlier quoted context omitted.

The content of this post has nothing to do with the specifics of dynamic linking: it would be just as true if the wheels in question had static binaries instead.

Eh, somewhere in the middle. Someone else put ‘-ffast-math’ in a compile line and it poisons FP math far away with no recompile? I believe it’s a necessary price in this case, but it does highlight how suboptimal it is to pay the price in other cases.

It's fair to point out that shared objects surface the problem here, but I don't know if I would lay the blame with them: the underlying problem is that a FPU control register isn't (and can't be) meaningfully isolated. Python needs to use shared objects for loadable extensions, but the contaminating code might be statically linked into that shared object.

(I don't say this because I want to excuse dynamic linking, which I also generally dislike! Only that I think the problem is somewhere else in this particular case.)

Re: Someone’s Been Messing with My Subnormals

#16

I 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.

ChromeOS is sort of the successor to Gentoo. The images are built with profile-guided, link-time, and post-link optimization, and they are targeted to the specific CPU in a given Chromebook. Every other Linux leaves a large amount of performance on the table by targeting a common denominator CPU that's 20 years old and not having PGO.

Re: Someone’s Been Messing with My Subnormals

#17
post #16

I 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.

ChromeOS is sort of the successor to Gentoo. The images are built with profile-guided, link-time, and post-link optimization, and they are targeted to the specific CPU in a given Chromebook. Every other Linux leaves a large amount of performance on the table by targeting a common denominator CPU that's 20 years old and not having PGO.

Apple avoid this problem with their OS by having a separate architecture slice for modern x64 (Haswell+).

Re: Someone’s Been Messing with My Subnormals

#18
The problem here is that enabling FTZ/DAZ flags involves modifying global (technically thread-local) state that is relatively expensive to do. Ideally, you'd want to twiddle these flags only for code that wants to work in this mode, but given the relative expense of this operation, it's not entirely practicable to auto-add twiddling to every function call, and doing it manually is somewhat challenging because compilers tend to support accessing the floating-point status rather poorly. Also, FTZ/DAZ aren't IEEE 754, so there's no portable function for twiddling these bits as there is for other rounding mode or exception controls. I will note that icc's -fp-model=fast and MSVC's /fp:fast correctly do not link code with crtfastmath.

As a side note, this kind of thing is why I think a good title for a fast-math would be "Fast math, or how I learned to start worrying and hate floating point."

Re: Someone’s Been Messing with My Subnormals

#19

I 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.

> I might be misremembering, but I think fastmath was one of the flags explicitly warned against in the Gentoo manual.

It is, here: https://wiki.gentoo.org/wiki/GCC_optimization#But_I_get_bett...

Post reply on HN