ATLAS Offline Software
Loading...
Searching...
No Matches
FloatingPointHelpers Namespace Reference

Namespaces

namespace  BitCastHelper
namespace  LeadingZerosPortability
namespace  OperatorsHelper

Classes

struct  ConversionHelper
struct  ConversionHelper< Format, Format >
struct  ConversionHelper< StandardDouble, StandardFloat >
class  IEEE754_like
 Specifies a floating point format like those described in IEEE-754, with an adjustable number of bits in the exponent and mantissa. More...

Typedefs

using StandardFloat = IEEE754_like<23, 8>
using StandardDouble = IEEE754_like<52, 11>
using CUDAHalfFloat = IEEE754_like<10, 5>
using CUDABFloat16 = IEEE754_like<7, 8>

Enumerations

enum class  RoundingModes {
  ToPlusInfinity , ToMinusInfinity , ToZero , ToNearestEven ,
  ToNearestAwayFromZero , Default = ToNearestEven
}
 Specifies the rounding mode to use for the operations. More...

Functions

template<class T, class FDest, class FSource>
static constexpr T down_convert (const T pattern, const RoundingModes rt=RoundingModes::Default)
 Converts pattern from the larger floating point format FSource to FDest.
template<class T, class FDest, class FSource>
static constexpr T up_convert (const T pattern, const RoundingModes rt=RoundingModes::Default)
 Converts pattern from the smaller floating point format FSource to FDest.

Typedef Documentation

◆ CUDABFloat16

Definition at line 916 of file FPHelpers.h.

◆ CUDAHalfFloat

Definition at line 915 of file FPHelpers.h.

◆ StandardDouble

Definition at line 834 of file FPHelpers.h.

◆ StandardFloat

Definition at line 832 of file FPHelpers.h.

Enumeration Type Documentation

◆ RoundingModes

Specifies the rounding mode to use for the operations.

Enumerator
ToPlusInfinity 
ToMinusInfinity 
ToZero 
ToNearestEven 
ToNearestAwayFromZero 
Default 

Definition at line 57 of file FPHelpers.h.

Function Documentation

◆ down_convert()

template<class T, class FDest, class FSource>
constexpr T FloatingPointHelpers::down_convert ( const T pattern,
const RoundingModes rt = RoundingModes::Default )
inlinestaticconstexpr

Converts pattern from the larger floating point format FSource to FDest.

Note: A few tests show that, under some circumstances, compilers may make this branchless. Clang seemed to do it, but not GCC. NVCC (for the GPU) surely did. There's probably still room for improvement, but...

Definition at line 807 of file FPHelpers.h.

808 {
809 static_assert(FDest::mantissa_size_bits() <= FSource::mantissa_size_bits() &&
810 FDest::exponent_size_bits() <= FSource::exponent_size_bits(),
811 "The destination type must not be a larger floating point type than the source one.");
812
814 }
static constexpr T down_convert(const T pattern, const RoundingModes rt=RoundingModes::Default)
Converts pattern from the larger floating point format FSource to FDest.
Definition FPHelpers.h:807

◆ up_convert()

template<class T, class FDest, class FSource>
constexpr T FloatingPointHelpers::up_convert ( const T pattern,
const RoundingModes rt = RoundingModes::Default )
inlinestaticconstexpr

Converts pattern from the smaller floating point format FSource to FDest.

Warning
: This could be re-written in a more branchless way, so performance might be sub-optimal...

Definition at line 823 of file FPHelpers.h.

824 {
825 static_assert(FDest::mantissa_size_bits() >= FSource::mantissa_size_bits() &&
826 FDest::exponent_size_bits() >= FSource::exponent_size_bits(),
827 "The source type must not be a larger floating point type than the destination one.");
829 }
static constexpr T up_convert(const T pattern, const RoundingModes rt=RoundingModes::Default)
Converts pattern from the smaller floating point format FSource to FDest.
Definition FPHelpers.h:823