6.15.13. Miscellaneous Vector Functions
6.15.13. 其他矢量函数
The OpenCL C programming language implements the following additional built-in vector functions. We use the generic type name gentypen
(or gentypem
) to indicate the built-in data types charn
, ucharn
, shortn
, ushortn
, intn
, uintn
, longn
[70], ulongn
, halfn
[71], floatn
, or doublen
[72] as the type for the arguments unless otherwise stated. We use the generic name ugentypen
to indicate the built-in unsigned integer data types. n is 2, 4, 8, or 16.
OpenCL C编程语言实现了以下附加的内置矢量函数。除非另有说明,否则我们使用泛型类型名称gentypen(或gentypem)来表示内置数据类型charn、ucharn、shortn、ushortn、intn、uintn、longn[70]、ulongn、halfn[71]、floatn或doublen[72]作为参数的类型。我们使用泛型名称ugentypen来表示内置的无符号整数数据类型。n为2、4、8或16。
Function 函数 | Description 描述 |
---|---|
int vec_step(gentypen a) | The vec_step built-in function takes a built-in 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. vec_step内置函数接受内置标量或矢量数据类型参数,并返回一个表示标量或矢量中元素数量的整数值。该论点未被评估。 For all scalar types, vec_step returns 1. 对于所有标量类型,vec_step返回1。 The vec_step built-in functions that take a 3-component vector return 4. vec_step内置函数接受3分量矢量返回4。 vec_step may also take a type name as an argument, e.g. vec_step(float2) vec_step也可以接受类型名称作为参数,例如vec_step(float2) Requires support for OpenCL C 1.1 or newer. 需要支持OpenCL C 1.1或更高版本。 |
gentypen shuffle(gentypem x, ugentypen mask) | The shuffle and shuffle2 built-in 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(2m-1) least significant bits of each mask element are considered. For shuffle2, only the ilogb(2m-1)+1 least significant bits of each mask element are considered. Other bits in the mask shall be ignored. shuffle和shuffle2内置函数分别从一个或两个相同类型的输入矢量中构造元素的置换,返回一个与输入元素类型相同、长度与shuffle掩码相同的矢量。掩码中每个元素的大小必须与结果中的每个元素的尺寸相匹配。对于shuffle,只考虑每个掩码元素的ilogb(2m-1)最低有效位。对于shuffle2,只考虑每个掩码元素的ilogb(2m-1)+1个最低有效位。掩码中的其他位应忽略。 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. 输入矢量的元素在一个或两个矢量上从左向右编号。为此,矢量中的元素数量由vec_step(gentypem)给出。shuffle掩码操作数为结果矢量的每个元素指定了结果元素获得的一个或两个输入矢量中的哪个元素。 Requires support for OpenCL C 1.1 or newer. 需要支持OpenCL C 1.1或更高版本。 Examples: 示例 Examples that are not valid are: 无效的示例包括: |