Description

The char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, float and double vector data types are supported. [1] The vector data type is defined with the type name, i.e. char, uchar, short, ushort, int, uint, long, ulong, float, or double 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.

Vector types with three elements, i.e. where n is 3, require support for OpenCL C 1.1 or newer.

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

Table 1. Built-in Vector Data Types

Type

Description

charn

A vector of n 8-bit signed two’s complement integer values.

ucharn

A vector of n 8-bit unsigned integer values.

shortn

A vector of n 16-bit signed two’s complement integer values.

ushortn

A vector of n 16-bit unsigned integer values.

intn

A vector of n 32-bit signed two’s complement integer values.

uintn

A vector of n 32-bit unsigned integer values.

longn [2]

A vector of n 64-bit signed two’s complement integer values.

ulongn [2]

A vector of n 64-bit unsigned integer values.

floatn

A vector of n 32-bit floating-point values.

doublen [3]

A vector of n 64-bit floating-point values.

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.

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

API type for application

charn

cl_charn

ucharn

cl_ucharn

shortn

cl_shortn

ushortn

cl_ushortn

intn

cl_intn

uintn

cl_uintn

longn

cl_longn

ulongn

cl_ulongn

floatn

cl_floatn

doublen

cl_doublen

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. Built-in vector data types are supported by the OpenCL implementation even if the underlying compute device does not natively support any or all of the vector data types. They are to be converted by the device compiler to appropriate instructions that use underlying built-in types supported natively by the compute device. Refer to Appendix B in the OpenCL API specification for a description of the order of the components of a vector type in memory.
2. The longn and ulongn vector 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 doublen vector 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.