CL_KHR_FP16(3clc)
π CL_KHR_FP16 π
okay bestie, welcome to the OpenCL Manual, page for CL_KHR_FP16(3clc) β we're talking optional half floating-point support and it's giving tiny-but-mighty β¨
πΈ NAME πΈ
cl_khr_fp16 β optional half floating-point support, bestie π
To even use it, you gotta include this directive:
#pragma OPENCL EXTENSION cl_khr_fp16 :
enable
π¦ DESCRIPTION π¦
so like, this extension adds support for half scalar and vector types as built-in types that you can use for arithmetic operations, conversions, etc. If your application wants to use half and halfn types, you literally have to include that directive up there. no directive, no halfsies. periodt. π
The list of built-in scalar and vector data types gets extended to include the types in the table below π
The built-in vector data types for halfn are also declared as appropriate types in the OpenCL API (and header files) so your application can use them. Here's the built-in vector data types for halfn as defined in the OpenCL C programming language, plus the matching data type available to the application:
half2β 2-component half-precision floating-point vector β API type for application:cl_half2half3β 3-component half-precision floating-point vector β API type for application:cl_half3half4β 4-component half-precision floating-point vector β API type for application:cl_half4half8β 8-component half-precision floating-point vector β API type for application:cl_half8half16β 16-component half-precision floating-point vector β API type for application:cl_half16
The relational, equality, logical and logical unary operators(3clc) can be used with half scalar and halfn vector types, and they shall produce a scalar int and vector shortn result respectively. yes queen, the operators work π«Ά
The OpenCL compiler accepts an h and H suffix on floating point literals, indicating the literal is typed as a half. cute, right? π
The macro names given in the following list must use the values specified. These constant expressions are suitable for use in #if preprocessing directives. π₯
Here's the table describing the corresponding macro names available to the application (macro in OpenCL Language β value β macro for application):
#define HALF_DIGβ3βHALF_DIG#define HALF_MANT_DIGβ11βHALF_MANT_DIG#define HALF_MAX_10_EXPβ+4βHALF_MAX_10_EXP#define HALF_MAX_EXPβ+16βHALF_MAX_EXP#define HALF_MIN_10_EXPβ-4βHALF_MIN_10_EXP#define HALF_MIN_EXPβ-13βHALF_MIN_EXP#define HALF_RADIXβ2βHALF_RADIX#define HALF_MAXβ0x1.ffcp15hβHALF_MAX#define HALF_MINβ0x1.0p-14hβHALF_MIN#define HALF_EPSILONβ0x1.0p-10hβHALF_EPSILON
The following constants are also available. They are of type half and are accurate within the precision of the half type π
M_E_Hβ Value of eM_LOG2E_Hβ Value of log2 eM_LOG10E_Hβ Value of log10 eM_LN2_Hβ Value of ln 2M_LN10_Hβ Value of ln 10M_PI_Hβ Value of ΟM_PI_2_Hβ Value of Ο / 2M_PI_4_Hβ Value of Ο / 4M_1_PI_Hβ Value of 1 / ΟM_2_PI_Hβ Value of 2 / ΟM_2_SQRTPI_Hβ Value of 2 / βΟM_SQRT2_Hβ Value of β2M_SQRT1_2_Hβ Value of 1 / β2
An application may query the configuration information using the op-code CL_DEVICE_HALF_FP_CONFIG with clGetDeviceInfo(3clc) for an OpenCL device that supports half precision floating-point. lowkey the move π
β¨ SPECIFICATION β¨
OpenCL Specification[1]
π SEE ALSO π
EXTENSION(3clc)clGetDeviceInfo(3clc)mathFunctions(3clc)commonFunctions(3clc)geometricFunctions(3clc)relationalFunctions(3clc)vectorDataLoadandStoreFunctions(3clc)asyncCopyFunctions(3clc)imageFunctions(3clc)
π AUTHORS π
The Khronos Group π
πΈ COPYRIGHT πΈ
Copyright Β© 2007-2011 The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the following condition: the above copyright notice and this permission notice shall be included in all copies or substantial portions of the Materials.
bestie this part is not vibe-only, it's the actual legal dealio, so keep that notice in all copies or substantial portions, fr fr π«Ά
π NOTES π
- OpenCL Specification, page 14, section 9.5 - Half Floating-Point
k that's the whole page, you ate it π
mwah! this iconic lil' slice of the OpenCL Manual was served up by The Khronos Group, dated 01/14/2021, filed under CL_KHR_FP16(3clc) β go forth and half-precision, bestie π¦β¨
π¦ where this page comes from
- ubuntu jammy: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- ubuntu noble: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms