gcc: Half-Precision

1 
1 6.12 Half-Precision Floating Point
1 ==================================
1 
1 On ARM and AArch64 targets, GCC supports half-precision (16-bit)
1 floating point via the '__fp16' type defined in the ARM C Language
1 Extensions.  On ARM systems, you must enable this type explicitly with
1 the '-mfp16-format' command-line option in order to use it.
1 
1  ARM targets support two incompatible representations for half-precision
1 floating-point values.  You must choose one of the representations and
1 use it consistently in your program.
1 
1  Specifying '-mfp16-format=ieee' selects the IEEE 754-2008 format.  This
1 format can represent normalized values in the range of 2^{-14} to 65504.
1 There are 11 bits of significand precision, approximately 3 decimal
1 digits.
1 
1  Specifying '-mfp16-format=alternative' selects the ARM alternative
1 format.  This representation is similar to the IEEE format, but does not
1 support infinities or NaNs.  Instead, the range of exponents is
1 extended, so that this format can represent normalized values in the
1 range of 2^{-14} to 131008.
1 
1  The GCC port for AArch64 only supports the IEEE 754-2008 format, and
1 does not require use of the '-mfp16-format' command-line option.
1 
1  The '__fp16' type may only be used as an argument to intrinsics defined
1 in '<arm_fp16.h>', or as a storage format.  For purposes of arithmetic
1 and other operations, '__fp16' values in C or C++ expressions are
1 automatically promoted to 'float'.
1 
1  The ARM target provides hardware support for conversions between
1 '__fp16' and 'float' values as an extension to VFP and NEON (Advanced
1 SIMD), and from ARMv8-A provides hardware support for conversions
1 between '__fp16' and 'double' values.  GCC generates code using these
1 hardware instructions if you compile with options to select an FPU that
1 provides them; for example, '-mfpu=neon-fp16 -mfloat-abi=softfp', in
1 addition to the '-mfp16-format' option to select a half-precision
1 format.
1 
1  Language-level support for the '__fp16' data type is independent of
1 whether GCC generates code using hardware floating-point instructions.
1 In cases where hardware support is not specified, GCC implements
1 conversions between '__fp16' and other types as library calls.
1 
1  It is recommended that portable code use the '_Float16' type defined by
1 ISO/IEC TS 18661-3:2015.  ⇒Floating Types.
1