SourceXtractorPlusPlus icon indicating copy to clipboard operation
SourceXtractorPlusPlus copied to clipboard

Should we use the compilation flag "-fno-finite-math-only"?

Open ayllon opened this issue 5 years ago • 1 comments

-ffast-math enables by default -ffinite-math-only, which tells the compiler it does not need to worry about operations that involve NaN and Inf. As one of these optimizations, it may decide to just throw away any call to std::isinf or std::isnan, and replace them with the constant false.

Not a big problem, I think, as the only std::isnan calls we have are basically asserts that, indeed, we have no NaN propagating through the code, but I worry since we do use NaN explicitly to mask out values (i.e. pixels above threshold that do not belong to the source), and it might bite us in the future?

P.S I was doing some tests with the Python-to-computing-graph involving a call to log(-10) and was kind of surprised when std::isnan told me that it is a good value.

ayllon avatar Sep 25 '20 07:09 ayllon

I think fast-math is a significant boost of performance but it comes at the price that we should not use NaNs and can't ever rely on them.

marcschefer avatar Sep 25 '20 09:09 marcschefer