'\" t .\" Title: cl_khr_fp16 .\" Author: The Khronos Group .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 01/14/2021 .\" Manual: OpenCL Manual .\" Source: The Khronos Group .\" Language: English .\" .TH "CL_KHR_FP16" "3clc" "01/14/2021" "The Khronos Group" "OpenCL Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" cl_khr_fp16 \- Optional half floating\-point support\&. .SS "" .TS tab(:); l. T{ #pragma OPENCL EXTENSION cl_khr_fp16 : enable T} .TE .sp 1 .SH "DESCRIPTION" .PP This extension adds support for half scalar and vector types as built\-in types that can be used for arithmetic operations, conversions, etc\&. An application that wants to use \fBhalf\fR and \fBhalf\fR\fB\fIn\fR\fR types will need to include the directive shown above\&. .PP The list of built\-in scalar and vector data types are extended to include the types in the table below\&. .PP The built\-in vector data types for \fBhalfn\fR are also declared as appropriate types in the OpenCL API (and header files) that can be used by an application\&. The following table describes the built\-in vector data types for \fBhalf\fR\fB\fIn\fR\fR as defined in the OpenCL C programming language and the corresponding data type available to the application: .PP .TS allbox tab(:); lB lB lB. T{ Type in OpenCL Language T}:T{ Description T}:T{ API type for application T} .T& l l l l l l l l l l l l l l l. T{ half2 T}:T{ 2\-component half\-precision floating\-point vector T}:T{ cl_half2 T} T{ half3 T}:T{ 3\-component half\-precision floating\-point vector T}:T{ cl_half3 T} T{ half4 T}:T{ 4\-component half\-precision floating\-point vector T}:T{ cl_half4 T} T{ half8 T}:T{ 8\-component half\-precision floating\-point vector T}:T{ cl_half8 T} T{ half16 T}:T{ 16\-component half\-precision floating\-point vector T}:T{ cl_half16 T} .TE .sp 1 .PP The relational, equality, logical and logical unary \fBoperators\fR(3clc) can be used with \fBhalf\fR scalar and \fBhalf\fR\fB\fIn\fR\fR vector types and shall produce a scalar \fBint\fR and vector \fBshort\fR\fB\fIn\fR\fR result respectively\&. .PP The OpenCL compiler accepts \fBan\fR h \fBand\fR H suffix on floating point literals, indicating the literal is typed as a \fBhalf\fR\&. .PP The macro names given in the following list must use the values specified\&. These constant expressions are suitable for use in \fB#if\fR preprocessing directives\&. .PP The following table also describes the corresponding macro names available to the application\&. .TS tab(:); lB lB lB. T{ Macro in OpenCL Language T}:T{ value T}:T{ Macro for application T} .T& l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l. T{ #define HALF_DIG T}:T{ 3 T}:T{ \fBHALF_DIG\fR T} T{ #define HALF_MANT_DIG T}:T{ 11 T}:T{ \fBHALF_MANT_DIG\fR T} T{ #define HALF_MAX_10_EXP T}:T{ +4 T}:T{ \fBHALF_MAX_10_EXP\fR T} T{ #define HALF_MAX_EXP T}:T{ +16 T}:T{ \fBHALF_MAX_EXP\fR T} T{ #define HALF_MIN_10_EXP T}:T{ \-4 T}:T{ \fBHALF_MIN_10_EXP\fR T} T{ #define HALF_MIN_EXP T}:T{ \-13 T}:T{ \fBHALF_MIN_EXP\fR T} T{ #define HALF_RADIX T}:T{ 2 T}:T{ \fBHALF_RADIX\fR T} T{ #define HALF_MAX T}:T{ 0x1\&.ffcp15h T}:T{ \fBHALF_MAX\fR T} T{ #define HALF_MIN T}:T{ 0x1\&.0p\-14h T}:T{ \fBHALF_MIN\fR T} T{ #define HALF_EPSILON T}:T{ 0x1\&.0p\-10h T}:T{ \fBHALF_EPSILON\fR T} .TE .sp 1 .PP The following constants are also available\&. They are of type \fBhalf\fR and are accurate within the precision of the \fBhalf\fR type\&. .TS allbox tab(:); lB lB. T{ Constant T}:T{ Description T} .T& l l l l l l l l l l l l l l l l l l l l l l l l l l. T{ M_E_H T}:T{ Value of e T} T{ M_LOG2E_H T}:T{ Value of log2 e T} T{ M_LOG10E_H T}:T{ Value of log10 e T} T{ M_LN2_H T}:T{ Value of ln 2 T} T{ M_LN10_H T}:T{ Value of ln 10 T} T{ M_PI_H T}:T{ Value of π T} T{ M_PI_2_H T}:T{ Value of π / 2 T} T{ M_PI_4_H T}:T{ Value of π / 4 T} T{ M_1_PI_H T}:T{ Value of 1 / π T} T{ M_2_PI_H T}:T{ Value of 2 / π T} T{ M_2_SQRTPI_H T}:T{ Value of 2 / √π T} T{ M_SQRT2_H T}:T{ Value of √2 T} T{ M_SQRT1_2_H T}:T{ Value of 1 / √2 T} .TE .sp 1 .PP Ann application may query the configuration information using the op\-code \fBCL_DEVICE_HALF_FP_CONFIG\fR with \fBclGetDeviceInfo\fR(3clc) for an OpenCL device that supports half precision floating\-point\&. .SH "SPECIFICATION" .PP \m[blue]\fBOpenCL Specification\fR\m[]\&\s-2\u[1]\d\s+2 .SH "SEE ALSO" .PP \fBEXTENSION\fR(3clc), \fBclGetDeviceInfo\fR(3clc), \fBmathFunctions\fR(3clc), \fBcommonFunctions\fR(3clc), \fBgeometricFunctions\fR(3clc), \fBrelationalFunctions\fR(3clc), \fBvectorDataLoadandStoreFunctions\fR(3clc), \fBasyncCopyFunctions\fR(3clc), \fBimageFunctions\fR(3clc) .SH "AUTHORS" .PP \fBThe Khronos Group\fR .SH "COPYRIGHT" .br Copyright \(co 2007-2011 The Khronos Group Inc. .br 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 condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials. .sp .SH "NOTES" .IP " 1." 4 OpenCL Specification .RS 4 \%page 14, section 9.5 - Half Floating-Point .RE