Description

The following table describes the list of built-in scalar data types.

Table 1. Built-in Scalar Data Types

Type

Description

bool [1]

A 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.

char

A signed two’s complement 8-bit integer.

unsigned char, uchar

An unsigned 8-bit integer.

short

A signed two’s complement 16-bit integer.

unsigned short, ushort

An unsigned 16-bit integer.

int

A signed two’s complement 32-bit integer.

unsigned int, uint

An unsigned 32-bit integer.

long [2]

A signed two’s complement 64-bit integer.

unsigned long, ulong [2]

An unsigned 64-bit integer.

float

A 32-bit floating-point number. The float data type must conform to the IEEE 754 single precision storage format.

double [3]

A 64-bit floating-point number. The double data type must conform to the IEEE 754 double precision storage format.

Requires support for OpenCL C 1.2 or newer. In OpenCL C 3.0 it requires support of the __opencl_c_fp64 feature. Also see extension cl_khr_fp64.

half

A 16-bit floating-point number. The half data type must conform to the IEEE 754-2008 half precision storage format.

size_t [4]

The unsigned integer type of the result of the sizeof operator.

ptrdiff_t [4]

A signed integer type that is the result of subtracting two pointers.

intptr_t [4]

A 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.

uintptr_t [4]

An 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.

void

The void type comprises an empty set of values; it is an incomplete type that cannot be completed.

If the double-precision floating-point extension cl_khr_fp64 or the __opencl_c_fp64 feature is not supported, implementations may implicitly cast double-precision floating-point literals to single-precision literals. The use of double-precision literals without double-precision support should result in a diagnostic.

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 Language

API type for application

bool

n/a

char

cl_char

unsigned char, uchar

cl_uchar

short

cl_short

unsigned short, ushort

cl_ushort

int

cl_int

unsigned int, uint

cl_uint

long

cl_long

unsigned long, ulong

cl_ulong

float

cl_float

double

cl_double [5]

half

cl_half

size_t

n/a

ptrdiff_t

n/a

intptr_t

n/a

uintptr_t

n/a

void

void

See Also

Document Notes

For more information, see the OpenCL C Specification

This page is extracted from the OpenCL C Specification. Fixes and changes should be made to the Specification, not directly.

Copyright 2014-2023 The Khronos Group Inc.

SPDX-License-Identifier: CC-BY-4.0


1. When any scalar value is converted to bool, the result is 0 if the value compares equal to 0; otherwise, the result is 1.
2. The long, unsigned long and ulong scalar types are optional types for EMBEDDED profile devices that are supported if the value of the CL_DEVICE_EXTENSIONS device query contains cles_khr_int64. An OpenCL C 3.0 compiler must also define the __opencl_c_int64 feature macro unconditionally for FULL profile devices, or for EMBEDDED profile devices that support these types.
3. The double scalar type is an optional type that is supported if the value of the CL_DEVICE_DOUBLE_FP_CONFIG device query is not zero. If this is the case then an OpenCL C 3.0 compiler must also define the __opencl_c_fp64 feature macro.
4. This is a 32-bit type if the value of the CL_DEVICE_ADDRESS_BITS device query is 32-bits, and a 64-bit type if the value of the query is 64-bits.
5. Requires support for OpenCL C 1.2 or above. Also see extension cl_khr_fp64.