1.1.1. Half Arithmetic Functions
[Half Precision Intrinsics]
To use these functions include the header file cuda_fp16.h in your program.
Functions
- __device__ __half __habs ( const __half a ) throw ( )
- Calculates the absolute value of input half number and returns the result.
- __device__ __half __hadd ( const __half a, const __half b ) throw ( )
- Performs half addition in round-to-nearest-even mode.
- __device__ __half __hadd_sat ( const __half a, const __half b ) throw ( )
- Performs half addition in round-to-nearest-even mode, with saturation to [0.0, 1.0].
- __device__ __half __hdiv ( const __half a, const __half b ) throw ( )
- Performs half division in round-to-nearest-even mode.
- __device__ __half __hfma ( const __half a, const __half b, const __half c ) throw ( )
- Performs half fused multiply-add in round-to-nearest-even mode.
- __device__ __half __hfma_sat ( const __half a, const __half b, const __half c ) throw ( )
- Performs half fused multiply-add in round-to-nearest-even mode, with saturation to [0.0, 1.0].
- __device__ __half __hmul ( const __half a, const __half b )
- Performs half multiplication in round-to-nearest-even mode.
- __device__ __half __hmul_sat ( const __half a, const __half b ) throw ( )
- Performs half multiplication in round-to-nearest-even mode, with saturation to [0.0, 1.0].
- __device__ __half __hneg ( const __half a ) throw ( )
- Negates input half number and returns the result.
- __device__ __half __hsub ( const __half a, const __half b ) throw ( )
- Performs half subtraction in round-to-nearest-even mode.
- __device__ __half __hsub_sat ( const __half a, const __half b ) throw ( )
- Performs half subtraction in round-to-nearest-even mode, with saturation to [0.0, 1.0].
Functions
- __device__ __half __habs ( const __half a ) throw ( )
-
Calculates the absolute value of input half number and returns the result.
Parameters
- a
- - half. Is only being read.
Returns
half
- The
absolute value of a.
Description
Calculates the absolute value of input half number and returns the result.
- __device__ __half __hadd ( const __half a, const __half b ) throw ( )
-
Performs half addition in round-to-nearest-even mode.
Parameters
- a
- - half. Is only being read.
- b
- - half. Is only being read.
Returns
half
- The
sum of a and b.
Description
Performs half addition of inputs a and b, in round-to-nearest-even mode. DEEPLEARN-SRM_REQ-94
- __device__ __half __hadd_sat ( const __half a, const __half b ) throw ( )
-
Performs half addition in round-to-nearest-even mode, with saturation to [0.0, 1.0].
Parameters
- a
- - half. Is only being read.
- b
- - half. Is only being read.
Returns
half
- The
sum of a and b, with respect to saturation.
Description
Performs half add of inputs a and b, in round-to-nearest-even mode, and clamps the result to range [0.0, 1.0]. NaN results are flushed to +0.0.
- __device__ __half __hdiv ( const __half a, const __half b ) throw ( )
-
Performs half division in round-to-nearest-even mode.
Parameters
- a
- - half. Is only being read.
- b
- - half. Is only being read.
Returns
half
- The
result of dividing a by b.
Description
Divides half input a by input b in round-to-nearest mode. DEEPLEARN-SRM_REQ-98
- __device__ __half __hfma ( const __half a, const __half b, const __half c ) throw ( )
-
Performs half fused multiply-add in round-to-nearest-even mode.
Parameters
- a
- - half. Is only being read.
- b
- - half. Is only being read.
- c
- - half. Is only being read.
Returns
half
- The
result of fused multiply-add operation on a, b, and c.
Description
Performs half multiply on inputs a and b, then performs a half add of the result with c, rounding the result once in round-to-nearest-even mode. DEEPLEARN-SRM_REQ-96
- __device__ __half __hfma_sat ( const __half a, const __half b, const __half c ) throw ( )
-
Performs half fused multiply-add in round-to-nearest-even mode, with saturation to [0.0, 1.0].
Parameters
- a
- - half. Is only being read.
- b
- - half. Is only being read.
- c
- - half. Is only being read.
Returns
half
- The
result of fused multiply-add operation on a, b, and c, with respect to saturation.
Description
Performs half multiply on inputs a and b, then performs a half add of the result with c, rounding the result once in round-to-nearest-even mode, and clamps the result to range [0.0, 1.0]. NaN results are flushed to +0.0.
- __device__ __half __hmul ( const __half a, const __half b )
-
Performs half multiplication in round-to-nearest-even mode.
Parameters
- a
- - half. Is only being read.
- b
- - half. Is only being read.
Returns
half
- The
result of multiplying a and b.
Description
Performs half multiplication of inputs a and b, in round-to-nearest mode. DEEPLEARN-SRM_REQ-99
- __device__ __half __hmul_sat ( const __half a, const __half b ) throw ( )
-
Performs half multiplication in round-to-nearest-even mode, with saturation to [0.0, 1.0].
Parameters
- a
- - half. Is only being read.
- b
- - half. Is only being read.
Returns
half
- The
result of multiplying a and b, with respect to saturation.
Description
Performs half multiplication of inputs a and b, in round-to-nearest mode, and clamps the result to range [0.0, 1.0]. NaN results are flushed to +0.0.
- __device__ __half __hneg ( const __half a ) throw ( )
-
Negates input half number and returns the result.
Parameters
- a
- - half. Is only being read.
Returns
half
- minus
a
Description
Negates input half number and returns the result. DEEPLEARN-SRM_REQ-100
- __device__ __half __hsub ( const __half a, const __half b ) throw ( )
-
Performs half subtraction in round-to-nearest-even mode.
Parameters
- a
- - half. Is only being read.
- b
- - half. Is only being read.
Returns
half
- The
result of subtracting b from a.
Description
Subtracts half input b from input a in round-to-nearest mode. DEEPLEARN-SRM_REQ-97
- __device__ __half __hsub_sat ( const __half a, const __half b ) throw ( )
-
Performs half subtraction in round-to-nearest-even mode, with saturation to [0.0, 1.0].
Parameters
- a
- - half. Is only being read.
- b
- - half. Is only being read.
Returns
half
- The
result of subtraction of b from a, with respect to saturation.
Description
Subtracts half input b from input a in round-to-nearest mode, and clamps the result to range [0.0, 1.0]. NaN results are flushed to +0.0.