'\" t .\" Title: shuffle, shuffle2 .\" Author: The Khronos Group .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 01/14/2021 .\" Manual: OpenCL Manual .\" Source: The Khronos Group .\" Language: English .\" .TH "SHUFFLE, SHUFFLE2" "3clc" "01/14/2021" "The Khronos Group" "OpenCL Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" shuffle \- Constructs a permutation of elements from one (or two) input vectors\&. .SH "" .HP \w'gentypen\ shuffle('u .BI "gentypen shuffle(gentype\fIm\fR\ " "x" ", ugentype\fIn\fR\ " "mask" ");" .HP \w'gentypen\ shuffle2('u .BI "gentypen shuffle2(gentype\fIm\fR\ " "x" ", gentype\fIm\fR\ " "y" ", ugentype\fIn\fR\ " "mask" ");" .SH "DESCRIPTION" .PP The \fBshuffle\fR and \fBshuffle2\fR 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 \fImask\fR must match the size of each element in the result\&. For \fBshuffle\fR, only the \fBilogb\fR(3clc)(2\fIm\fR\-1) least significant bits of each \fImask\fR element are considered\&. For \fBshuffle2\fR, only the \fBilogb\fR(3clc)(2\fIm\fR\-1)+1 least significant bits of each \fImask\fR element are considered\&. Other bits in the \fImask\fR shall be ignored\&. .PP 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 \fBvec_step\fR(3clc)(gentype\fIm\fR)\&. The shuffle \fImask\fR operand specifies, for each element of the result vector, which element of the one or two input vectors the result element gets\&. .PP We use the generic type name \fBgentype\fR\fB\fIn\fR\fR (or \fBgentype\fR\fB\fIm\fR\fR) to indicate the built\-in data types \fBchar{2|4|8|16}\fR, \fBuchar{2|4|8|16}\fR, \fBshort{2|4|8|16}\fR, \fBushort{2|4|8|16}\fR, \fBint{2|4|8|16}\fR, \fBuint{2|4|8|16}\fR, \fBlong{2|4|8|16}\fR, \fBulong{2|4|8|16}\fR, or \fBfloat{2|4|8|16}\fR as the type for the arguments unless otherwise stated\&. We use the generic name \fBugentype\fR\fB\fIn\fR\fR to indicate the built\-in unsigned integer data types\&. If the \fBdouble\fR is supported, then \fBgentype\fR\fB\fIn\fR\fR (or \fBgentype\fR\fB\fIm\fR\fR) also indicate the built\-in data types \fBdouble{2|4|8|16}\fR\&. .PP The generic type name \fBgentype\fR\fB\fIn\fR\fR (or \fBgentype\fR\fB\fIm\fR\fR) may indicate the data type \fBhalf{2|4|8|16}\fR if the \fBcl_khr_fp16\fR(3clc) extension is supported\&. .SS "Example" .TS tab(:); l. T{ uint4 mask = (uint4)(3, 2, 1, 0); float4 a; float4 r = shuffle(a, mask); // r\&.s0123 = a\&.wzyx uint8 mask = (uint8)(0, 1, 2, 3, 4, 5, 6, 7); float4 a, b; float8 r = shuffle2(a, b, mask); // r\&.s0123 = a\&.xyzw // r\&.s4567 = b\&.xyzw uint4 mask; float8 a; float4 b; b = shuffle(a, mask); T} .TE .sp 1 .PP Examples that are not valid are: .TS tab(:); l. T{ uint8 mask; short16 a; short8 b; b = shuffle(a, mask); T} .TE .sp 1 .SH "SPECIFICATION" .PP \m[blue]\fBOpenCL Specification\fR\m[]\&\s-2\u[1]\d\s+2 .SH "SEE ALSO" .PP \fBmiscVectorFunctions\fR(3clc) .SH "AUTHORS" .PP \fBThe Khronos Group\fR .SH "COPYRIGHT" .br Copyright \(co 2007-2011 The Khronos Group Inc. .br Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials. .sp .SH "NOTES" .IP " 1." 4 OpenCL Specification .RS 4 \%page 282, section 6.12.12 Miscellaneous Vector Functions .RE