2.1. __half Struct Reference

[Half Precision Intrinsics]

This structure implements the datatype for storing half-precision floating-point numbers. The structure implements assignment, arithmetic and comparison operators, and type conversions. 16 bits are being used in total: 1 sign bit, 5 bits for the exponent, and the significand is being stored in 10 bits. The total precision is 11 bits. There are 15361 representable numbers within the interval [0.0, 1.0], endpoints included. On average we have log10(2**11) ~ 3.311 decimal digits.

The objective here is to provide IEEE754-compliant implementation of binary16 type and arithmetic with limitations due to device HW not supporting floating-point exceptions.

Public Constructors

__host____device__ ​ __half ( const unsigned long long val )
__host____device__ ​ __half ( const long long val )
__host____device__ ​ __half ( const unsignedlong  val )
__host____device__ ​ __half ( const long val )
__host____device__ ​ __half ( const unsigned int  val )
__host____device__ ​ __half ( const int  val )
__host____device__ ​ __half ( const unsigned short val )
__host____device__ ​ __half ( const short val )
__host____device__ ​ __half ( const double  f )
__host____device__ ​ __half ( const float  f )
__host____device__ ​ __half ( const __half_raw& hr )
__host____device__ ​ __half ( )

Public Member Functions

__host____device__ ​  operator __half_raw ( ) const
__host____device__ ​  operator __half_raw ( ) const
__host____device__ ​ constexpr operator bool ( ) const
__host____device__ ​  operator char ( ) const
__host____device__ ​  operator float ( ) const
__host____device__ ​  operator int ( ) const
__host____device__ ​  operator long ( ) const
__host____device__ ​  operator long long ( ) const
__host____device__ ​  operator short ( ) const
__host____device__ ​  operator signed char ( ) const
__host____device__ ​  operator unsigned char ( ) const
__host____device__ ​  operator unsigned int ( ) const
__host____device__ ​  operator unsigned long ( ) const
__host____device__ ​  operator unsigned long long ( ) const
__host____device__ ​  operator unsigned short ( ) const
__host____device____halfoperator= ( const unsigned long long val )
__host____device____halfoperator= ( const long long val )
__host____device____halfoperator= ( const unsigned int  val )
__host____device____halfoperator= ( const int  val )
__host____device____halfoperator= ( const unsigned short val )
__host____device____halfoperator= ( const short val )
__host____device____halfoperator= ( const double  f )
__host____device____halfoperator= ( const float  f )
__host____device____halfoperator= ( const __half_raw& hr )
__host____device____halfoperator= ( const __half_raw& hr )
__host____device____halfoperator= ( const __half_raw& hr )

Protected Variables

unsigned short  __x

Constructors

__host____device____half::__half ( const unsigned long long val ) [inline]
Description

Construct __half from unsignedlonglong input using default round-to-nearest-even rounding mode.

__host____device____half::__half ( const long long val ) [inline]
Description

Construct __half from longlong input using default round-to-nearest-even rounding mode.

__host____device____half::__half ( const unsignedlong  val ) [inline]
Description

Construct __half from unsignedlong input using default round-to-nearest-even rounding mode.

__host____device____half::__half ( const long val ) [inline]
Description

Construct __half from long input using default round-to-nearest-even rounding mode.

__host____device____half::__half ( const unsigned int  val ) [inline]
Description

Construct __half from unsignedint input using default round-to-nearest-even rounding mode.

__host____device____half::__half ( const int  val ) [inline]
Description

Construct __half from int input using default round-to-nearest-even rounding mode.

__host____device____half::__half ( const unsigned short val ) [inline]
Description

Construct __half from unsignedshort integer input using default round-to-nearest-even rounding mode.

__host____device____half::__half ( const short val ) [inline]
Description

Construct __half from short integer input using default round-to-nearest-even rounding mode.

__host____device____half::__half ( const double  f ) [inline]
Description

Construct __half from double input using default round-to-nearest-even rounding mode.

__host____device____half::__half ( const float  f ) [inline]
Description

Construct __half from float input using default round-to-nearest-even rounding mode.

__host____device____half::__half ( const __half_raw& hr ) [inline]
Description

Constructor from __half_raw.

__host____device____half::__half ( ) [inline]
Description

Constructor by default.

Member Functions

__host____device____half::operator __half_raw ( ) const [inherited]
Description

Type cast to __half_raw operator with volatile input.

__host____device____half::operator __half_raw ( ) const [inherited]
Description

Type cast to __half_raw operator.

__host____device__ ​ constexpr __half::operator bool ( ) const [inherited, inline]
Description

Conversion operator to bool data type. +0 and -0 inputs convert to false. Non-zero inputs convert to true.

__host____device____half::operator char ( ) const [inherited]
Description

Conversion operator to an implementation defined char data type. Using round-toward-zero rounding mode.

Detects signedness of the char type and proceeds accordingly, see further details in signed and unsigned char operators.

__host____device____half::operator float ( ) const [inherited]
Description

Type cast to float operator.

__host____device____half::operator int ( ) const [inherited]
Description

Conversion operator to int data type. Using round-toward-zero rounding mode.

See __half2int_rz( __half) for further details

__host____device____half::operator long ( ) const [inherited]
Description

Conversion operator to long data type. Using round-toward-zero rounding mode.

__host____device____half::operator long long ( ) const [inherited]
Description

Conversion operator to longlong data type. Using round-toward-zero rounding mode.

See __half2ll_rz( __half) for further details

__host____device____half::operator short ( ) const [inherited]
Description

Conversion operator to short data type. Using round-toward-zero rounding mode.

See __half2short_rz( __half) for further details

__host____device____half::operator signed char ( ) const [inherited]
Description

Conversion operator to signedchar data type. Using round-toward-zero rounding mode.

See __half2char_rz( __half) for further details

__host____device____half::operator unsigned char ( ) const [inherited]
Description

Conversion operator to unsignedchar data type. Using round-toward-zero rounding mode.

See __half2uchar_rz( __half) for further details

__host____device____half::operator unsigned int ( ) const [inherited]
Description

Conversion operator to unsignedint data type. Using round-toward-zero rounding mode.

See __half2uint_rz( __half) for further details

__host____device____half::operator unsigned long ( ) const [inherited]
Description

Conversion operator to unsignedlong data type. Using round-toward-zero rounding mode.

__host____device____half::operator unsigned long long ( ) const [inherited]
Description

Conversion operator to unsignedlonglong data type. Using round-toward-zero rounding mode.

See __half2ull_rz( __half) for further details

__host____device____half::operator unsigned short ( ) const [inherited]
Description

Conversion operator to unsignedshort data type. Using round-toward-zero rounding mode.

See __half2ushort_rz( __half) for further details

__host____device____half& __half::operator= ( const unsigned long long val ) [inherited]
Description

Type cast from unsignedlonglong assignment operator, using default round-to-nearest-even rounding mode.

__host____device____half& __half::operator= ( const long long val ) [inherited]
Description

Type cast from longlong assignment operator, using default round-to-nearest-even rounding mode.

__host____device____half& __half::operator= ( const unsigned int  val ) [inherited]
Description

Type cast from unsignedint assignment operator, using default round-to-nearest-even rounding mode.

__host____device____half& __half::operator= ( const int  val ) [inherited]
Description

Type cast from int assignment operator, using default round-to-nearest-even rounding mode.

__host____device____half& __half::operator= ( const unsigned short val ) [inherited]
Description

Type cast from unsignedshort assignment operator, using default round-to-nearest-even rounding mode.

__host____device____half& __half::operator= ( const short val ) [inherited]
Description

Type cast from short assignment operator, using default round-to-nearest-even rounding mode.

__host____device____half& __half::operator= ( const double  f ) [inherited]
Description

Type cast to __half assignment operator from double input using default round-to-nearest-even rounding mode.

__host____device____half& __half::operator= ( const float  f ) [inherited]
Description

Type cast to __half assignment operator from float input using default round-to-nearest-even rounding mode.

__host____device____half& __half::operator= ( const __half_raw& hr ) [inherited]
Description

Assignment operator from volatile__half_raw to volatile__half.

__host____device____half& __half::operator= ( const __half_raw& hr ) [inherited]
Description

Assignment operator from __half_raw to volatile__half.

__host____device____half& __half::operator= ( const __half_raw& hr ) [inherited]
Description

Assignment operator from __half_raw.

Variables

unsigned short __half::__x [inherited, protected]

Protected storage variable contains the bits of floating-point data.