Is there any device functions in CUDA to obtain IEEE 754 special values like inf, NaN? I mean the stable way, not by some maths ops that could be optimized-out by compilers.
I only manage to find a device function called nan() that must take some unknown string argument.
The numerical capabilities are encoded in the compute capability number of your GPU. Devices of compute capability 2.0 and later are capable of single and double precision arithmetic following the IEEE 754 standard, and have hardware units for performing fused multiply-add in both single and double precision.
Many applications require higher-accuracy mathematical calculations. In these applications, data is represented by values that are twice as large (using 64 binary bits instead of 32 bits). These larger values are called double-precision (64-bit). Less accurate values are called single-precision (32-bit).
Available to any CUDA C or CUDA C++ application simply by adding “#include math. h” in your source code, the CUDA Math library ensures that your application benefits from high performance math routines optimized for every NVIDIA GPU architecture.
How about CUDART_NAN
(double) and CUDART_NAN_F
(float) defined in /usr/local/cuda/include/math_constants.h
:
#define CUDART_NAN_F __int_as_float(0x7fffffff)
#define CUDART_NAN __longlong_as_double(0xfff8000000000000ULL)
and:
#define CUDART_INF_F __int_as_float(0x7f800000)
#define CUDART_INF __longlong_as_double(0x7ff0000000000000ULL)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With