2.3. Half Comparison Functions
To use these functions, include the header file cuda_fp16.h in your program.
Functions
- __host__ __device__ bool __heq(const __half a, const __half b)
-
Performs
halfif-equal comparison. - __host__ __device__ bool __hequ(const __half a, const __half b)
-
Performs
halfunordered if-equal comparison. - __host__ __device__ bool __hge(const __half a, const __half b)
-
Performs
halfgreater-equal comparison. - __host__ __device__ bool __hgeu(const __half a, const __half b)
-
Performs
halfunordered greater-equal comparison. - __host__ __device__ bool __hgt(const __half a, const __half b)
-
Performs
halfgreater-than comparison. - __host__ __device__ bool __hgtu(const __half a, const __half b)
-
Performs
halfunordered greater-than comparison. - __host__ __device__ int __hisinf(const __half a)
-
Checks if the input
halfnumber is infinite. - __host__ __device__ bool __hisnan(const __half a)
-
Determine whether
halfargument is a NaN. - __host__ __device__ bool __hle(const __half a, const __half b)
-
Performs
halfless-equal comparison. - __host__ __device__ bool __hleu(const __half a, const __half b)
-
Performs
halfunordered less-equal comparison. - __host__ __device__ bool __hlt(const __half a, const __half b)
-
Performs
halfless-than comparison. - __host__ __device__ bool __hltu(const __half a, const __half b)
-
Performs
halfunordered less-than comparison. - __host__ __device__ __half __hmax(const __half a, const __half b)
-
Calculates
halfmaximum of two input values. - __host__ __device__ __half __hmax_nan(const __half a, const __half b)
-
Calculates
halfmaximum of two input values, NaNs pass through. - __host__ __device__ __half __hmin(const __half a, const __half b)
-
Calculates
halfminimum of two input values. - __host__ __device__ __half __hmin_nan(const __half a, const __half b)
-
Calculates
halfminimum of two input values, NaNs pass through. - __host__ __device__ bool __hne(const __half a, const __half b)
-
Performs
halfnot-equal comparison. - __host__ __device__ bool __hneu(const __half a, const __half b)
-
Performs
halfunordered not-equal comparison. - __host__ __device__ bool operator!=(const __half &lh, const __half &rh)
-
Performs
halfunordered compare not-equal operation. - __host__ __device__ bool operator<(const __half &lh, const __half &rh)
-
Performs
halfordered less-than compare operation. - __host__ __device__ bool operator<=(const __half &lh, const __half &rh)
-
Performs
halfordered less-or-equal compare operation. - __host__ __device__ bool operator==(const __half &lh, const __half &rh)
-
Performs
halfordered compare equal operation. - __host__ __device__ bool operator>(const __half &lh, const __half &rh)
-
Performs
halfordered greater-than compare operation. - __host__ __device__ bool operator>=(const __half &lh, const __half &rh)
-
Performs
halfordered greater-or-equal compare operation.
2.3.1. Functions
-
__host__ __device__ bool __heq(const __half a, const __half b)
-
Performs
halfif-equal comparison.Performs
halfif-equal comparison of inputsaandb. NaN inputs generate false results.- Parameters
-
a – [in] - half. Is only being read.
b – [in] - half. Is only being read.
- Returns
-
bool
The boolean result of if-equal comparison of
aandb.
-
__host__ __device__ bool __hequ(const __half a, const __half b)
-
Performs
halfunordered if-equal comparison.Performs
halfif-equal comparison of inputsaandb. NaN inputs generate true results.- Parameters
-
a – [in] - half. Is only being read.
b – [in] - half. Is only being read.
- Returns
-
bool
The boolean result of unordered if-equal comparison of
aandb.
-
__host__ __device__ bool __hge(const __half a, const __half b)
-
Performs
halfgreater-equal comparison.Performs
halfgreater-equal comparison of inputsaandb. NaN inputs generate false results.- Parameters
-
a – [in] - half. Is only being read.
b – [in] - half. Is only being read.
- Returns
-
bool
The boolean result of greater-equal comparison of
aandb.
-
__host__ __device__ bool __hgeu(const __half a, const __half b)
-
Performs
halfunordered greater-equal comparison.Performs
halfgreater-equal comparison of inputsaandb. NaN inputs generate true results.- Parameters
-
a – [in] - half. Is only being read.
b – [in] - half. Is only being read.
- Returns
-
bool
The boolean result of unordered greater-equal comparison of
aandb.
-
__host__ __device__ bool __hgt(const __half a, const __half b)
-
Performs
halfgreater-than comparison.Performs
halfgreater-than comparison of inputsaandb. NaN inputs generate false results.- Parameters
-
a – [in] - half. Is only being read.
b – [in] - half. Is only being read.
- Returns
-
bool
The boolean result of greater-than comparison of
aandb.
-
__host__ __device__ bool __hgtu(const __half a, const __half b)
-
Performs
halfunordered greater-than comparison.Performs
halfgreater-than comparison of inputsaandb. NaN inputs generate true results.- Parameters
-
a – [in] - half. Is only being read.
b – [in] - half. Is only being read.
- Returns
-
bool
The boolean result of unordered greater-than comparison of
aandb.
-
__host__ __device__ int __hisinf(const __half a)
-
Checks if the input
halfnumber is infinite.Checks if the input
halfnumberais infinite.- Parameters
-
a – [in] - half. Is only being read.
- Returns
-
int
-1 if
ais equal to negative infinity,1 if
ais equal to positive infinity,0 otherwise.
-
__host__ __device__ bool __hisnan(const __half a)
-
Determine whether
halfargument is a NaN.Determine whether
halfvalueais a NaN.- Parameters
-
a – [in] - half. Is only being read.
- Returns
-
bool
true if argument is NaN.
-
__host__ __device__ bool __hle(const __half a, const __half b)
-
Performs
halfless-equal comparison.Performs
halfless-equal comparison of inputsaandb. NaN inputs generate false results.- Parameters
-
a – [in] - half. Is only being read.
b – [in] - half. Is only being read.
- Returns
-
bool
The boolean result of less-equal comparison of
aandb.
-
__host__ __device__ bool __hleu(const __half a, const __half b)
-
Performs
halfunordered less-equal comparison.Performs
halfless-equal comparison of inputsaandb. NaN inputs generate true results.- Parameters
-
a – [in] - half. Is only being read.
b – [in] - half. Is only being read.
- Returns
-
bool
The boolean result of unordered less-equal comparison of
aandb.
-
__host__ __device__ bool __hlt(const __half a, const __half b)
-
Performs
halfless-than comparison.Performs
halfless-than comparison of inputsaandb. NaN inputs generate false results.- Parameters
-
a – [in] - half. Is only being read.
b – [in] - half. Is only being read.
- Returns
-
bool
The boolean result of less-than comparison of
aandb.
-
__host__ __device__ bool __hltu(const __half a, const __half b)
-
Performs
halfunordered less-than comparison.Performs
halfless-than comparison of inputsaandb. NaN inputs generate true results.- Parameters
-
a – [in] - half. Is only being read.
b – [in] - half. Is only being read.
- Returns
-
bool
The boolean result of unordered less-than comparison of
aandb.
-
__host__ __device__ __half __hmax(const __half a, const __half b)
-
Calculates
halfmaximum of two input values.Calculates
halfmax(a,b) defined as (a>b) ?a:b.If either of inputs is NaN, the other input is returned.
If both inputs are NaNs, then canonical NaN is returned.
If values of both inputs are 0.0, then +0.0 > -0.0
- Parameters
-
a – [in] - half. Is only being read.
b – [in] - half. Is only being read.
- Returns
-
half
-
__host__ __device__ __half __hmax_nan(const __half a, const __half b)
-
Calculates
halfmaximum of two input values, NaNs pass through.Calculates
halfmax(a,b) defined as (a>b) ?a:b.If either of inputs is NaN, then canonical NaN is returned.
If values of both inputs are 0.0, then +0.0 > -0.0
- Parameters
-
a – [in] - half. Is only being read.
b – [in] - half. Is only being read.
- Returns
-
half
-
__host__ __device__ __half __hmin(const __half a, const __half b)
-
Calculates
halfminimum of two input values.Calculates
halfmin(a,b) defined as (a<b) ?a:b.If either of inputs is NaN, the other input is returned.
If both inputs are NaNs, then canonical NaN is returned.
If values of both inputs are 0.0, then +0.0 > -0.0
- Parameters
-
a – [in] - half. Is only being read.
b – [in] - half. Is only being read.
- Returns
-
half
-
__host__ __device__ __half __hmin_nan(const __half a, const __half b)
-
Calculates
halfminimum of two input values, NaNs pass through.Calculates
halfmin(a,b) defined as (a<b) ?a:b.If either of inputs is NaN, then canonical NaN is returned.
If values of both inputs are 0.0, then +0.0 > -0.0
- Parameters
-
a – [in] - half. Is only being read.
b – [in] - half. Is only being read.
- Returns
-
half
-
__host__ __device__ bool __hne(const __half a, const __half b)
-
Performs
halfnot-equal comparison.Performs
halfnot-equal comparison of inputsaandb. NaN inputs generate false results.- Parameters
-
a – [in] - half. Is only being read.
b – [in] - half. Is only being read.
- Returns
-
bool
The boolean result of not-equal comparison of
aandb.
-
__host__ __device__ bool __hneu(const __half a, const __half b)
-
Performs
halfunordered not-equal comparison.Performs
halfnot-equal comparison of inputsaandb. NaN inputs generate true results.- Parameters
-
a – [in] - half. Is only being read.
b – [in] - half. Is only being read.
- Returns
-
bool
The boolean result of unordered not-equal comparison of
aandb.
-
__host__ __device__ bool operator!=(const __half &lh, const __half &rh)
-
Performs
halfunordered compare not-equal operation.See also
-
__host__ __device__ bool operator<(const __half &lh, const __half &rh)
-
Performs
halfordered less-than compare operation.See also
-
__host__ __device__ bool operator<=(const __half &lh, const __half &rh)
-
Performs
halfordered less-or-equal compare operation.See also
-
__host__ __device__ bool operator==(const __half &lh, const __half &rh)
-
Performs
halfordered compare equal operation.See also
-
__host__ __device__ bool operator>(const __half &lh, const __half &rh)
-
Performs
halfordered greater-than compare operation.See also