1.1.6. Half Math Functions
[Half Precision Intrinsics]
To use these functions, include the header file cuda_fp16.h in your program.
Functions
- __device__ __half atomicAdd ( const __half* address, const __half val )
- Adds val to the value stored at address in global or shared memory, and writes this value back to address. This operation is performed in one atomic operation.
- __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 mode.
- __device__ __half hexp10 ( const __half a )
- Calculates half decimal exponential function in round-to-nearest mode.
- __device__ __half hexp2 ( const __half a )
- Calculates half binary exponential function in round-to-nearest 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 atomicAdd ( const __half* address, const __half val )
-
Adds val to the value stored at address in global or shared memory, and writes this value back to address. This operation is performed in one atomic operation.
Parameters
- address
- - half*. An address in global or shared memory.
- val
- - half. The value to be added.
Returns
half
- The
old value read from address.
Description
The location of address must be in global or shared memory. This operation has undefined behavior otherwise. This operation is only supported by devices of compute capability 7.x and higher.
Note:For more details for this function see the Atomic Functions section in the CUDA C++ Programming Guide.
- __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 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 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 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 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.