Reference

scalarDataTypes(3clc)

Built-in scalar data types.

NAME

Scalar_Data_Types - Built-in scalar data types.

DESCRIPTION

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.

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:

Type in OpenCL C LanguageDescriptionAPI type for application
boolA conditional data type which is either true or false. The value true expands to the integer constant 1 and the value false 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.n/a
charA signed two's complement 8-bit integer.cl_char
unsigned char, uchar
An unsigned 8-bit integer.cl_uchar
shortA signed two's complement 16-bit integer.cl_short
unsigned short, ushort
An unsigned 16-bit integer.cl_ushort
intA signed two's complement 32-bit integer.cl_int
unsigned int, uint
An unsigned 32-bit integer.cl_uint
longA signed two's complement 64-bit integer.cl_long
unsigned long, ulong
An unsigned 64-bit integer.cl_ulong
floatA 32-bit floating point. The float data type must conform to the IEEE 754 single precision storage format.cl_float
doubleA 64-bit floating point. The double data type must conform to the IEEE 754 double precision storage format. The double scalar type is an optional type that is supported if CL_DEVICE_DOUBLE_FP_CONFIG for a device is not zero. See the table for param_name for clGetDeviceInfo(3clc) for details.cl_double
halfA 16-bit float. The half data type must conform to the IEEE 754-2008 half precision storage format.cl_half
size_tThe unsigned integer type of the result of the sizeof operator. This is a 32-bit unsigned integer if CL_DEVICE_ADDRESS_BITS defined in clGetDeviceInfo(3clc) is 32-bits and is a 64-bit unsigned integer if CL_DEVICE_ADDRESS_BITS is 64-bits.n/a
ptrdiff_tA signed integer type that is the result of subtracting two pointers. This is a 32-bit signed integer if CL_DEVICE_ADDRESS_BITS defined in clGetDeviceInfo(3clc) is 32-bits and is a 64-bit signed integer if CL_DEVICE_ADDRESS_BITS is 64-bits.n/a
intptr_tA signed integer type with the property that any valid pointer to void can be converted to this type, then converted back to pointer to void, and the result will compare equal to the original pointer. This is a 32-bit signed integer if CL_DEVICE_ADDRESS_BITS defined in table 4.3 is 32-bits and is a 64-bit signed integer if CL_DEVICE_ADDRESS_BITS is 64-bits.n/a
uintptr_tAn unsigned integer type with the property that any valid pointer to void can be converted to this type, then converted back to pointer to void, and the result will compare equal to the original pointer. This is a 32-bit signed integer if CL_DEVICE_ADDRESS_BITS defined in table 4.3 is 32-bits and is a 64-bit signed integer if CL_DEVICE_ADDRESS_BITS is 64-bits.n/a
voidThe void type comprises an empty set of values; it is an incomplete type that cannot be completed.void

OPTIONAL HALF FLOATING POINT

The half floating-point is supported as an optional extension. An application that wants to use half and halfn will need to include the cl_khr_fp16(3clc) directive. This will extended the list of built-in vector and scalar data types to include the following:

Type in OpenCL LanguageDescriptionAPI type for application
half2A 2-component half-precision floating-point vector.cl_half2
half3A 3-component half-precision floating-point vector.cl_half3
half4A 4-component half-precision floating-point vector.cl_half4
half8An 8-component half-precision floating-point vector.cl_half8
half16A 16-component half-precision floating-point vector.cl_half16

The relational, equality, logical and logical unary operators can be used with half scalar and halfn vector types and shall produce a scalar int and vector shortn result respectively.

The OpenCL compiler accepts an h and H suffix on floating point literals, indicating the literal is typed as a half.

SPECIFICATION

OpenCL Specification[1]

SEE ALSO

macroLimits(3clc), vectorDataTypes(3clc), reservedDataTypes(3clc), otherDataTypes(3clc), abstractDataTypes(3clc), enums(3clc), cl_khr_fp16(3clc), cl_khr_fp64(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 condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.

NOTES

1.

OpenCL Specification

page 195, section 6.1.1 - Built-in Scalar Data Types

History