1.2. Half Precision Intrinsics

This section describes half precision intrinsic functions. To use these functions, include the header file cuda_fp16.h in your program. All of the functions defined here are available in device code. Some of the functions are also available to host compilers, please refer to respective functions' documentation for details.

NOTE: Aggressive floating-point optimizations performed by host or device compilers may affect numeric behavior of the functions implemented in this header.

The following macros are available to help users selectively enable/disable various definitions present in the header file:

  • CUDA_NO_HALF - If defined, this macro will prevent the definition of additional type aliases in the global namespace, helping to avoid potential conflicts with symbols defined in the user program.

  • __CUDA_NO_HALF_CONVERSIONS__ - If defined, this macro will prevent the use of the C++ type conversions (converting constructors and conversion operators) that are common for built-in floating-point types, but may be undesirable for half which is essentially a user-defined type.

  • __CUDA_NO_HALF_OPERATORS__ and __CUDA_NO_HALF2_OPERATORS__ - If defined, these macros will prevent the inadvertent use of usual arithmetic and comparison operators. This enforces the storage-only type semantics and prevents C++ style computations on half and half2 types.

Modules

 
 
 
 
 
 
 
 

Classes

struct 
__half data type
struct 
__half2 data type
struct 
__half2_raw data type
struct 
__half_raw data type

Typedefs

typedef struct __half __nv_half
This datatype is an __nv_ prefixed alias.
typedef struct __half2 __nv_half2
This datatype is an __nv_ prefixed alias.
typedef struct __half2_raw __nv_half2_raw
This datatype is an __nv_ prefixed alias.
typedef struct __half_raw __nv_half_raw
This datatype is an __nv_ prefixed alias.
typedef struct __half half
This datatype is meant to be the first-class or fundamental implementation of the half-precision numbers format.
typedef struct __half2 half2
This datatype is meant to be the first-class or fundamental implementation of type for pairs of half-precision numbers.
typedef struct __half nv_half
This datatype is an nv_ prefixed alias.
typedef struct __half2 nv_half2
This datatype is an nv_ prefixed alias.

Typedefs

typedef struct __half __nv_half

This datatype is an __nv_ prefixed alias.

typedef struct __half2 __nv_half2

This datatype is an __nv_ prefixed alias.

typedef struct __half2_raw __nv_half2_raw

This datatype is an __nv_ prefixed alias.

typedef struct __half_raw __nv_half_raw

This datatype is an __nv_ prefixed alias.

typedef struct __half half

This datatype is meant to be the first-class or fundamental implementation of the half-precision numbers format. Should be implemented in the compiler in the future. Current implementation is a simple typedef to a respective user-level type with underscores.

typedef struct __half2 half2

This datatype is meant to be the first-class or fundamental implementation of type for pairs of half-precision numbers. Should be implemented in the compiler in the future. Current implementation is a simple typedef to a respective user-level type with underscores.

typedef struct __half nv_half

This datatype is an nv_ prefixed alias.

typedef struct __half2 nv_half2

This datatype is an nv_ prefixed alias.

Half Arithmetic Constants

Half Arithmetic Functions

Half2 Arithmetic Functions

Half Comparison Functions

Half2 Comparison Functions

Half Precision Conversion and Data Movement

Half Math Functions

Half2 Math Functions