Description

The char, unsigned char, short, unsigned short, int, unsigned int, 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, long, ulong, or float, 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.

[4] 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. Refer to Appendix B for a description of the order of the components of a vector type in memory.

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

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

ulongn

A vector of n 64-bit unsigned integer values.

floatn

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

doublen5

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

[5] The double vector type is an optional type that is supported if the value of the CL_DEVICE_DOUBLE_FP_CONFIG device query is not zero.

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