Vector Data Types

Description

The char, unsigned char, short, unsigned short, integer, unsigned integer, long, unsigned long, and float vector data types are supported. The vector data type is defined with the type name i.e. char, uchar, short, ushort, int, uint, float, long, or ulong followed by a literal value n that defines
the number of elements in the vector. Supported values of n are 2, 3, 4, 8, and 16 for all vector data types.

The built-in vector 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 vector data type in the OpenCL C programming language and the corresponding data type available to the application:

Type in OpenCL Language

Description

API type for application

charn

A 8-bit signed two's complement integer vector.

cl_charn

ucharn

A 8-bit unsigned integer vector.

cl_ucharn

shortn

A 16-bit signed two's complement integer vector.

cl_shortn

ushortn

A 16-bit unsigned integer vector.

cl_ushortn

intn

A 32-bit signed two's complement integer vector.

cl_int

uintn

A 32-bit unsigned integer vector.

cl_uintn

longn

A 64-bit signed two's complement integer vector.

cl_longn

ulongn

A 64-bit unsigned integer vector.

cl_ulongn

floatn

A float vector

cl_floatn

Notes

Built-in vector data types are supported by the OpenCL implementation even if the underlying compute device does not support any or all of the vector data types. These are to be converted by the device compiler to appropriate instructions that use underlying built-in types supported natively by the compute device.

Optional Double Precision and Half Floating Point

OpenCL 1.0 adds support for double precision and half floating-point as optional extensions. The double data type must confirm to the IEEE-754 double precision storage format.

An application that wants to use double will need to include the #pragma OPENCL
EXTENSION cl_khr_fp64 : enable directive before any double precision data type is declared in the kernel code. This will extended the list of built-in vector and scalar data types to include the following: