Is there anything as half precision floating points in CUDA?
Background: I want to manipulate an opengl texture using glTexSubImage3D with data from a PBO which I generate using CUDA. The texture is stored in GL_INTENSITY16 format (which is a half precision floating type afaik) and I dont want to use glPixelTransferf(GL_x_SCALE,...) to scale from integer values since it seems to be much faster without the scaling.
Any advice?
CUDA doesn't support it: The type of a texel, which is restricted to the basic integer and single-precision floating-point types and any of the 1-, 2-, and 4-component vector types defined in Built-in Vector Types that are derived from the basic integer and single-precision floating-point types.
Devices of compute capability 2.0 and later are capable of single and double precision arithmetic following the IEEE 754 standard, and have hardware units for performing fused multiply-add in both single and double precision. Take advantage of the CUDA math library functions.
CUDA only natively supports 32 and 64 bit floating precision types.
Both driver and runtime APIs support binding to half float textures, but the resulting read inside the kernel will return the value promoted to a 32 bit floating point number. The CUDA standard libraries include __half2float()
and __float2half_rn()
functions for converting between half and single precision floating point types (the half float stored in a 16 bit integer). So it might be possible to do the manipulation in 32 bit precision kernels with reads and writes done using 16 bit types. But for native 16 bit floating point, I think you are out of luck.
EDIT to add that in 2015, NVIDIA extended half precision floating point support with the CUDA 7.5 toolkit by added half
and half2
types and intrinsic functions to handle them. It has also been announced that (not yet released) Pascal architecture will support IEE754-2008 compliant half precision operations in hardware.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With