On Wed, 18 Oct 2017, Nicholas Park wrote:

In that work, the authors developed a tool, Herbie, that was also
incorporated into a web-based demo.

Yes, nice tool.

Herbie doesn't support the less-than operator, but I tried two variants (sqrt(2) * 0.5 - abs(x)) and (0.5 - x * x). If I interpret their output correctly, neither has accuracy issues.

Yes. I think. The first subtraction is accurate to 2*ULP (unit in the last places) but the second is accurate to 2*ULP which is why I worry. This is in a low level maths routine where you need to (understandably) get narky about accuracy. Note that if you use an FMA, a fused multiply-add unit, that brings it back to one ULP. Pondering loss of accuracy sends my head spinning sometimes.

On the performance side, I thought I'd check what assembly those two variants generate using Matt Godbolt's Compiler Explorer. With "-O3" and "-ffast-math" flags set, the results are quite similar between Clang 5 and GCC 7.2.

Yes. Great site that.

Of the two, I think "x * x < 0.5" looks more readable.

Thanks for the input - Damian

Pacific Engineering Systems International, 277-279 Broadway, Glebe NSW 2037
Ph:+61-2-8571-0847 .. Fx:+61-2-9692-9623 | unsolicited email not wanted here
Views & opinions here are mine and not those of any past or present employer

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers

Reply via email to