'\" t .\" Title: Scalar Data Types .\" Author: The Khronos Group .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 01/14/2021 .\" Manual: OpenCL Manual .\" Source: The Khronos Group .\" Language: English .\" .TH "SCALAR DATA TYPES" "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" Scalar_Data_Types \- Built\-in scalar data types\&. .SH "DESCRIPTION" .PP These are the data types available in the OpenCL C programming language used to create kernels that are executed on OpenCL device(s)\&. The OpenCL C programming language (also referred to as OpenCL C) is based on the ISO/IEC 9899:1999 C language specification (a\&.k\&.a\&. C99 specification) with specific extensions and restrictions\&. Please refer to the ISO/IEC 9899:1999 specification for a detailed description of the language grammar\&. This section describes modifications and restrictions to ISO/IEC 9899:1999 supported in OpenCL C\&. .PP Most built\-in scalar data types 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 scalar data type in the OpenCL C programming language and the corresponding data type available to the application: .TS allbox tab(:); lB lB lB. T{ Type in OpenCL C 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 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 l l l l l l. T{ \fBbool\fR T}:T{ A conditional data type which is either \fItrue\fR or \fIfalse\fR\&. The value \fItrue\fR expands to the integer constant 1 and the value \fIfalse\fR expands to the integer constant 0\&. When any scalar value is converted to bool, the result is 0 if the value compares equal to 0; otherwise, the result is 1\&. T}:T{ n/a T} T{ \fBchar\fR T}:T{ A signed two\*(Aqs complement 8\-bit integer\&. T}:T{ \fBcl_char\fR T} T{ .if n \{\ .RS 4 .\} .nf \fBunsigned char\fR, \fBuchar\fR .fi .if n \{\ .RE .\} .sp T}:T{ An unsigned 8\-bit integer\&. T}:T{ \fBcl_uchar\fR T} T{ \fBshort\fR T}:T{ A signed two\*(Aqs complement 16\-bit integer\&. T}:T{ \fBcl_short\fR T} T{ .if n \{\ .RS 4 .\} .nf \fBunsigned short\fR, \fBushort\fR .fi .if n \{\ .RE .\} .sp T}:T{ An unsigned 16\-bit integer\&. T}:T{ \fBcl_ushort\fR T} T{ \fBint\fR T}:T{ A signed two\*(Aqs complement 32\-bit integer\&. T}:T{ \fBcl_int\fR T} T{ .if n \{\ .RS 4 .\} .nf \fBunsigned int\fR, \fBuint\fR .fi .if n \{\ .RE .\} .sp T}:T{ An unsigned 32\-bit integer\&. T}:T{ \fBcl_uint\fR T} T{ \fBlong\fR T}:T{ A signed two\*(Aqs complement 64\-bit integer\&. T}:T{ \fBcl_long\fR T} T{ .if n \{\ .RS 4 .\} .nf \fBunsigned long\fR, \fBulong\fR .fi .if n \{\ .RE .\} .sp T}:T{ An unsigned 64\-bit integer\&. T}:T{ \fBcl_ulong\fR T} T{ \fBfloat\fR T}:T{ A 32\-bit floating point\&. The float data type must conform to the IEEE 754 single precision storage format\&. T}:T{ \fBcl_float\fR T} T{ \fBdouble\fR T}:T{ A 64\-bit floating point\&. The \fBdouble\fR data type must conform to the IEEE 754 double precision storage format\&. The \fBdouble\fR scalar type is an optional type that is supported if \fBCL_DEVICE_DOUBLE_FP_CONFIG\fR for a device is not zero\&. See the table for \fIparam_name\fR for \fBclGetDeviceInfo\fR(3clc) for details\&. T}:T{ \fBcl_double\fR T} T{ \fBhalf\fR T}:T{ A 16\-bit float\&. The \fBhalf\fR data type must conform to the IEEE 754\-2008 half precision storage format\&. T}:T{ \fBcl_half\fR T} T{ \fBsize_t\fR T}:T{ The unsigned integer type of the result of the sizeof operator\&. This is a 32\-bit unsigned integer if \fBCL_DEVICE_ADDRESS_BITS\fR defined in \fBclGetDeviceInfo\fR(3clc) is 32\-bits and is a 64\-bit unsigned integer if \fBCL_DEVICE_ADDRESS_BITS\fR is 64\-bits\&. T}:T{ n/a T} T{ \fBptrdiff_t\fR T}:T{ A signed integer type that is the result of subtracting two pointers\&. This is a 32\-bit signed integer if \fBCL_DEVICE_ADDRESS_BITS\fR defined in \fBclGetDeviceInfo\fR(3clc) is 32\-bits and is a 64\-bit signed integer if \fBCL_DEVICE_ADDRESS_BITS\fR is 64\-bits\&. T}:T{ n/a T} T{ \fBintptr_t\fR T}:T{ A signed integer type with the property that any valid pointer to \fBvoid\fR can be converted to this type, then converted back to pointer to \fBvoid\fR, and the result will compare equal to the original pointer\&. This is a 32\-bit signed integer if \fBCL_DEVICE_ADDRESS_BITS\fR defined in table 4\&.3 is 32\-bits and is a 64\-bit signed integer if \fBCL_DEVICE_ADDRESS_BITS\fR is 64\-bits\&. T}:T{ n/a T} T{ \fBuintptr_t\fR T}:T{ An unsigned integer type with the property that any valid pointer to \fBvoid\fR can be converted to this type, then converted back to pointer to \fBvoid\fR, and the result will compare equal to the original pointer\&. This is a 32\-bit signed integer if \fBCL_DEVICE_ADDRESS_BITS\fR defined in table 4\&.3 is 32\-bits and is a 64\-bit signed integer if \fBCL_DEVICE_ADDRESS_BITS\fR is 64\-bits\&. T}:T{ n/a T} T{ \fBvoid\fR T}:T{ The \fBvoid\fR type comprises an empty set of values; it is an incomplete type that cannot be completed\&. T}:T{ \fBvoid\fR T} .TE .sp 1 .SH "OPTIONAL HALF FLOATING POINT" .PP The \fBhalf\fR floating\-point is supported as an optional extension\&. An application that wants to use \fBhalf\fR and \fBhalf\fR\fB\fIn\fR\fR will need to include the \fBcl_khr_fp16\fR(3clc) directive\&. This will extended the list of built\-in vector and scalar data types to include the following: .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{ \fBhalf2\fR T}:T{ A 2\-component half\-precision floating\-point vector\&. T}:T{ \fBcl_half2\fR T} T{ \fBhalf3\fR T}:T{ A 3\-component half\-precision floating\-point vector\&. T}:T{ \fBcl_half3\fR T} T{ \fBhalf4\fR T}:T{ A 4\-component half\-precision floating\-point vector\&. T}:T{ \fBcl_half4\fR T} T{ \fBhalf8\fR T}:T{ An 8\-component half\-precision floating\-point vector\&. T}:T{ \fBcl_half8\fR T} T{ \fBhalf16\fR T}:T{ A 16\-component half\-precision floating\-point vector\&. T}:T{ \fBcl_half16\fR T} .TE .sp 1 .PP The relational, equality, logical and logical unary operators 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 an h and H suffix on floating point literals, indicating the literal is typed as a \fBhalf\fR\&. .SH "SPECIFICATION" .PP \m[blue]\fBOpenCL Specification\fR\m[]\&\s-2\u[1]\d\s+2 .SH "SEE ALSO" .PP \fBmacroLimits\fR(3clc), \fBvectorDataTypes\fR(3clc), \fBreservedDataTypes\fR(3clc), \fBotherDataTypes\fR(3clc), \fBabstractDataTypes\fR(3clc), \fBenums\fR(3clc), \fBcl_khr_fp16\fR(3clc), \fBcl_khr_fp64\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 195, section 6.1.1 - Built-in Scalar Data Types .RE