CUDA Math API (PDF) - v9.0.176 (older) - Last updated September 2, 2017 - Send Feedback

## 1.1.2. Half2 Arithmetic Functions

## [Half Precision Intrinsics]

### Functions

__device__ ​ __half2 __hadd2 ( const __half2 a, const __half2 b )
  Performs `half2` vector addition in round-to-nearest-even mode.
__device__ ​ __half2 __hadd2_sat ( const __half2 a, const __half2 b )
  Performs `half2` vector addition in round-to-nearest-even mode, with saturation to [0.0, 1.0].
__device__ ​ __half2 __hfma2 ( const __half2 a, const __half2 b, const __half2 c )
  Performs `half2` vector fused multiply-add in round-to-nearest-even mode.
__device__ ​ __half2 __hfma2_sat ( const __half2 a, const __half2 b, const __half2 c )
  Performs `half2` vector fused multiply-add in round-to-nearest-even mode, with saturation to [0.0, 1.0].
__device__ ​ __half2 __hmul2 ( const __half2 a, const __half2 b )
  Performs `half2` vector multiplication in round-to-nearest-even mode.
__device__ ​ __half2 __hmul2_sat ( const __half2 a, const __half2 b )
  Performs `half2` vector multiplication in round-to-nearest-even mode, with saturation to [0.0, 1.0].
__device__ ​ __half2 __hneg2 ( const __half2 a )
  Negates both halves of the input `half2` number and returns the result.
__device__ ​ __half2 __hsub2 ( const __half2 a, const __half2 b )
  Performs `half2` vector subtraction in round-to-nearest-even mode.
__device__ ​ __half2 __hsub2_sat ( const __half2 a, const __half2 b )
  Performs `half2` vector subtraction in round-to-nearest-even mode, with saturation to [0.0, 1.0].

### Functions

__device__ ​ __half2 __hadd2 ( const __half2 a, const __half2 b )
  Performs `half2` vector addition in round-to-nearest-even mode.

  ###### Returns

  Returns the `half2` vector result of adding vectors `a` and `b`.

  ###### Description

  Performs `half2` vector add of inputs `a` and `b`, in round-to-nearest mode.

__device__ ​ __half2 __hadd2_sat ( const __half2 a, const __half2 b )
  Performs `half2` vector addition in round-to-nearest-even mode, with saturation to [0.0, 1.0].

  ###### Returns

  Returns the `half2` vector result of adding vectors `a` and `b` with saturation.

  ###### Description

  Performs `half2` vector add of inputs `a` and `b`, in round-to-nearest mode, and clamps the results to range [0.0, 1.0]. NaN results are flushed to +0.0.

__device__ ​ __half2 __hfma2 ( const __half2 a, const __half2 b, const __half2 c )
  Performs `half2` vector fused multiply-add in round-to-nearest-even mode.

  ###### Returns

  Returns the `half2` vector result of the fused multiply-add operation on vectors `a`, `b`, and `c`.

  ###### Description

  Performs `half2` vector multiply on inputs `a` and `b`, then performs a `half2` vector add of the result with `c`, rounding the result once in round-to-nearest-even mode.

__device__ ​ __half2 __hfma2_sat ( const __half2 a, const __half2 b, const __half2 c )
  Performs `half2` vector fused multiply-add in round-to-nearest-even mode, with saturation to [0.0, 1.0].

  ###### Returns

  Returns the `half2` vector result of the fused multiply-add operation on vectors `a`, `b`, and `c` with saturation.

  ###### Description

  Performs `half2` vector multiply on inputs `a` and `b`, then performs a `half2` vector add of the result with `c`, rounding the result once in round-to-nearest-even mode, and clamps the results to range [0.0, 1.0]. NaN results are flushed to +0.0.

__device__ ​ __half2 __hmul2 ( const __half2 a, const __half2 b )
  Performs `half2` vector multiplication in round-to-nearest-even mode.

  ###### Returns

  Returns the `half2` vector result of multiplying vectors `a` and `b`.

  ###### Description

  Performs `half2` vector multiplication of inputs `a` and `b`, in round-to-nearest-even mode.

__device__ ​ __half2 __hmul2_sat ( const __half2 a, const __half2 b )
  Performs `half2` vector multiplication in round-to-nearest-even mode, with saturation to [0.0, 1.0].

  ###### Returns

  Returns the `half2` vector result of multiplying vectors `a` and `b` with saturation.

  ###### Description

  Performs `half2` vector multiplication of inputs `a` and `b`, in round-to-nearest-even mode, and clamps the results to range [0.0, 1.0]. NaN results are flushed to +0.0.

__device__ ​ __half2 __hneg2 ( const __half2 a )
  Negates both halves of the input `half2` number and returns the result.

  ###### Returns

  Returns `half2` number with both halves negated.

  ###### Description

  Negates both halves of the input `half2` number `a` and returns the result.

__device__ ​ __half2 __hsub2 ( const __half2 a, const __half2 b )
  Performs `half2` vector subtraction in round-to-nearest-even mode.

  ###### Returns

  Returns the `half2` vector result of subtraction vector `b` from `a`.

  ###### Description

  Subtracts `half2` input vector `b` from input vector `a` in round-to-nearest-even mode.

__device__ ​ __half2 __hsub2_sat ( const __half2 a, const __half2 b )
  Performs `half2` vector subtraction in round-to-nearest-even mode, with saturation to [0.0, 1.0].

  ###### Returns

  Returns the `half2` vector result of subtraction vector `b` from `a` with saturation.

  ###### Description

  Subtracts `half2` input vector `b` from input vector `a` in round-to-nearest-even mode, and clamps the results to range [0.0, 1.0]. NaN results are flushed to +0.0.