zlacker

[parent] [thread] 4 comments
1. Ashame+(OP)[view] [source] 2024-01-17 00:45:26
Because compilers can and have implemented sqrt in terms of rsqrt which is .. fun to work with. This also on SSE.
replies(2): >>mabste+eo >>jcranm+uq
2. mabste+eo[view] [source] 2024-01-17 03:45:57
>>Ashame+(OP)
I spent most of my career working with rsqrt haha. And had my fair share of non-754 architectures too!

Every 754 architecture (including SSE) I've worked on has an accurate sqrt().

I'm assuming you're talking about with "fast math" enabled? In which case all bets are off anyway!

replies(1): >>Ashame+CC2
3. jcranm+uq[view] [source] 2024-01-17 04:06:33
>>Ashame+(OP)
sqrt is a fundamental IEEE 754 operation, required to be correctly rounded, and many architectures implement a dedicated, correctly rounded sqrt instruction.

Now, there is also often an approximate rsqrt and approximate reciprocal, with varying degrees of accuracy, and that can be "fun."

◧◩
4. Ashame+CC2[view] [source] [discussion] 2024-01-17 18:36:23
>>mabste+eo
No; compilers have done this even without fast-math. Gcc does not seem to do this anymore, but still does plenty of unsafe optimizations by default, like FMA.

Or maybe the library you use...

replies(1): >>mabste+g77
◧◩◪
5. mabste+g77[view] [source] [discussion] 2024-01-18 22:37:14
>>Ashame+CC2
Argh, sounds really frustrating! It's hard enough to get accuracy when you can control operations never mind when the compiler is doing magic behind the scenes!

FMAs were difficult. The Visual Studio compiler in particular didn't support purposeful FMAs for SSE instructions so you had to rely on the compiler to recognise and replace multiply-additions. Generally I want FMAs because they're more accurate but I want to control where they go.

[go to top]