[ET Trac] [Einstein Toolkit] #1563: Provide always-working isnan etc.
Einstein Toolkit
trac-noreply at einsteintoolkit.org
Fri Apr 18 07:26:47 CDT 2014
#1563: Provide always-working isnan etc.
--------------------------+-------------------------------------------------
Reporter: eschnett | Owner:
Type: enhancement | Status: reopened
Priority: major | Milestone:
Component: Cactus | Version: development version
Resolution: | Keywords:
--------------------------+-------------------------------------------------
Comment (by eschnett):
The meaning of isnan is specified in the C/C++ standard in the same way as
e.g. sqrt. If you call sqrt(1.0), then you expect the compiler to evaluate
this at compile time in the same way as isnan(1.0); since the compiler
knows the result, it doesn't need to emit a run-time call. If you then use
-ffast-math, which means that you tell the compiler that it should assume
that no calculation ever results in a nan and thus the expensive special
cases for nan can be ignored, then the compiler will assume that isnan
always returns false, and will omit the call.
No, there is no option to avoid this, except to not use -ffast-math, which
prevent all sorts of very useful optimizations.
I expect that the speed difference between CCTK_isnan and isnan is mostly
that isnan can be inlined, while CCTK_isnan cannot. Apart from this, they
will likely lead to identical code on x86 architectures. On other
architectures, CCTK_isnan may be significantly more expensive than isnan.
I will add support for float and long double as well.
--
Ticket URL: <https://trac.einsteintoolkit.org/ticket/1563#comment:3>
Einstein Toolkit <http://einsteintoolkit.org>
The Einstein Toolkit
More information about the Trac
mailing list