Description

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

Table 1. Built-in Scalar Data Types

Type

Description

bool1

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

A signed two’s complement 64-bit integer.

unsigned long, ulong

An unsigned 64-bit integer.

float

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

double2

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

half

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

size_t

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

ptrdiff_t

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

intptr_t

A signed integer type3 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

An unsigned integer type3 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.

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

[3] These are 32-bit types if the value of the CL_DEVICE_ADDRESS_BITS device query is 32-bits, and 64-bit types if the value of the query is 64-bits.

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

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 (c) 2014-2020 Khronos Group. This work is licensed under a Creative Commons Attribution 4.0 International License.