Built-in scalar data types.
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 Language | Description | API type for application |
---|---|---|
|
A conditional data type which is either |
n/a |
|
A signed two’s complement 8-bit integer. |
|
unsigned char, uchar |
An unsigned 8-bit integer. |
|
|
A signed two’s complement 16-bit integer. |
|
unsigned short, ushort |
An unsigned 16-bit integer. |
|
|
A signed two’s complement 32-bit integer. |
|
unsigned int, uint |
An unsigned 32-bit integer. |
|
|
A signed two’s complement 64-bit integer. |
|
unsigned long, ulong |
An unsigned 64-bit integer. |
|
|
A 32-bit floating point. The float data type must conform to the IEEE 754 single precision storage format. |
|
|
A 64-bit floating point.
The |
|
|
A 16-bit float.
The |
|
|
The unsigned integer type of the result of the sizeof operator.
This is a 32-bit unsigned integer if |
n/a |
|
A signed integer type that is the result of subtracting two pointers.
This is a 32-bit signed integer if |
n/a |
|
A signed integer type with the property that any valid pointer to |
n/a |
|
An unsigned integer type with the property that any valid pointer to |
n/a |
|
The |
|
The half
floating-point is supported as an optional extension.
An application that wants to use half
and halfn
will need to include the #pragma OPENCL EXTENSION cl_khr_fp16 : enable directive.
This will extended the list of built-in vector and scalar data types to include the following:
Type in OpenCL Language | Description | API type for application |
---|---|---|
|
A 2-component half-precision floating-point vector. |
|
|
A 3-component half-precision floating-point vector. |
|
|
A 4-component half-precision floating-point vector. |
|
|
An 8-component half-precision floating-point vector. |
|
|
A 16-component half-precision floating-point vector. |
|
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
.