1.2.7. Half Math Functions

[Half Precision Intrinsics]

To use these functions, include the header file cuda_fp16.h in your program.

Functions

__device____half hceil ( const __half h )
Calculate ceiling of the input argument.
__device____half hcos ( const __half a )
Calculates half cosine in round-to-nearest-even mode.
__device____half hexp ( const __half a )
Calculates half natural exponential function in round-to-nearest-even mode.
__device____half hexp10 ( const __half a )
Calculates half decimal exponential function in round-to-nearest-even mode.
__device____half hexp2 ( const __half a )
Calculates half binary exponential function in round-to-nearest-even mode.
__device____half hfloor ( const __half h )
Calculate the largest integer less than or equal to h.
__device____half hlog ( const __half a )
Calculates half natural logarithm in round-to-nearest-even mode.
__device____half hlog10 ( const __half a )
Calculates half decimal logarithm in round-to-nearest-even mode.
__device____half hlog2 ( const __half a )
Calculates half binary logarithm in round-to-nearest-even mode.
__device____half hrcp ( const __half a )
Calculates half reciprocal in round-to-nearest-even mode.
__device____half hrint ( const __half h )
Round input to nearest integer value in half-precision floating-point number.
__device____half hrsqrt ( const __half a )
Calculates half reciprocal square root in round-to-nearest-even mode.
__device____half hsin ( const __half a )
Calculates half sine in round-to-nearest-even mode.
__device____half hsqrt ( const __half a )
Calculates half square root in round-to-nearest-even mode.
__device____half htrunc ( const __half h )
Truncate input argument to the integral part.

Functions

__device____half hceil ( const __half h )
Calculate ceiling of the input argument.
Parameters
h
- half. Is only being read.
Returns

half

  • The smallest integer value not less than h.
Description

Compute the smallest integer value not less than h.

__device____half hcos ( const __half a )
Calculates half cosine in round-to-nearest-even mode.
Parameters
a
- half. Is only being read.
Returns

half

  • The cosine of a.
Description

Calculates half cosine of input a in round-to-nearest-even mode.

__device____half hexp ( const __half a )
Calculates half natural exponential function in round-to-nearest-even mode.
Parameters
a
- half. Is only being read.
Returns

half

  • The natural exponential function on a.
Description

Calculates half natural exponential function of input a in round-to-nearest-even mode.

__device____half hexp10 ( const __half a )
Calculates half decimal exponential function in round-to-nearest-even mode.
Parameters
a
- half. Is only being read.
Returns

half

  • The decimal exponential function on a.
Description

Calculates half decimal exponential function of input a in round-to-nearest-even mode.

__device____half hexp2 ( const __half a )
Calculates half binary exponential function in round-to-nearest-even mode.
Parameters
a
- half. Is only being read.
Returns

half

  • The binary exponential function on a.
Description

Calculates half binary exponential function of input a in round-to-nearest-even mode.

__device____half hfloor ( const __half h )
Calculate the largest integer less than or equal to h.
Parameters
h
- half. Is only being read.
Returns

half

  • The largest integer value which is less than or equal to h.
Description

Calculate the largest integer value which is less than or equal to h.

__device____half hlog ( const __half a )
Calculates half natural logarithm in round-to-nearest-even mode.
Parameters
a
- half. Is only being read.
Returns

half

  • The natural logarithm of a.
Description

Calculates half natural logarithm of input a in round-to-nearest-even mode.

__device____half hlog10 ( const __half a )
Calculates half decimal logarithm in round-to-nearest-even mode.
Parameters
a
- half. Is only being read.
Returns

half

  • The decimal logarithm of a.
Description

Calculates half decimal logarithm of input a in round-to-nearest-even mode.

__device____half hlog2 ( const __half a )
Calculates half binary logarithm in round-to-nearest-even mode.
Parameters
a
- half. Is only being read.
Returns

half

  • The binary logarithm of a.
Description

Calculates half binary logarithm of input a in round-to-nearest-even mode.

__device____half hrcp ( const __half a )
Calculates half reciprocal in round-to-nearest-even mode.
Parameters
a
- half. Is only being read.
Returns

half

  • The reciprocal of a.
Description

Calculates half reciprocal of input a in round-to-nearest-even mode.

__device____half hrint ( const __half h )
Round input to nearest integer value in half-precision floating-point number.
Parameters
h
- half. Is only being read.
Returns

half

  • The nearest integer to h.
Description

Round h to the nearest integer value in half-precision floating-point format, with halfway cases rounded to the nearest even integer value.

__device____half hrsqrt ( const __half a )
Calculates half reciprocal square root in round-to-nearest-even mode.
Parameters
a
- half. Is only being read.
Returns

half

  • The reciprocal square root of a.
Description

Calculates half reciprocal square root of input a in round-to-nearest-even mode.

__device____half hsin ( const __half a )
Calculates half sine in round-to-nearest-even mode.
Parameters
a
- half. Is only being read.
Returns

half

  • The sine of a.
Description

Calculates half sine of input a in round-to-nearest-even mode.

__device____half hsqrt ( const __half a )
Calculates half square root in round-to-nearest-even mode.
Parameters
a
- half. Is only being read.
Returns

half

  • The square root of a.
Description

Calculates half square root of input a in round-to-nearest-even mode.

__device____half htrunc ( const __half h )
Truncate input argument to the integral part.
Parameters
h
- half. Is only being read.
Returns

half

  • The truncated integer value.
Description

Round h to the nearest integer value that does not exceed h in magnitude.