Half precision floating points in CUDA
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 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.
精彩评论