Description
The OpenCL C programming language implements the following additional
builtin vector functions.
We use the generic type name gentypen
(or gentypem
) to indicate the
builtin data types charn
, ucharn
, shortn
,
ushortn
,
intn
, uintn
, longn
^{[1]}, ulongn
, halfn
^{[2]}, floatn
, or
doublen
^{[3]} as the type for
the arguments unless otherwise stated.
We use the generic name ugentypen
to indicate the builtin unsigned
integer data types.
n is 2, 4, 8, or 16.
Function 
Description 
int vec_step(gentypen a) 
The vec_step builtin function takes a builtin scalar or vector data type argument and returns an integer value representing the number of elements in the scalar or vector. The argument is not evaluated. For all scalar types, vec_step returns 1. The vec_step builtin functions that take a 3component vector return 4. vec_step may also take a type name as an argument, e.g. vec_step(float2) Requires support for OpenCL C 1.1 or newer. 
gentypen shuffle(gentypem x,
ugentypen mask) 
The shuffle and shuffle2 builtin functions construct a permutation of elements from one or two input vectors respectively that are of the same type, returning a vector with the same element type as the input and length that is the same as the shuffle mask. The size of each element in the mask must match the size of each element in the result. For shuffle, only the ilogb(2m1) least significant bits of each mask element are considered. For shuffle2, only the ilogb(2m1)+1 least significant bits of each mask element are considered. Other bits in the mask shall be ignored. The elements of the input vectors are numbered from left to right across one or both of the vectors. For this purpose, the number of elements in a vector is given by vec_step(gentypem). The shuffle mask operand specifies, for each element of the result vector, which element of the one or two input vectors the result element gets. Requires support for OpenCL C 1.1 or newer. Examples:
Examples that are not valid are:

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.