(no commit message)
[libreriscv.git] / openpower / sv / vector_swizzle.mdwn
1 # SV Vector Prefix Swizzle
2
3 3D GPU operations on batches of vec2, vec3 and vec4 often require re-ordering of the elements in an "out of lane" fashion with respect to standard high performance non-GPU-centric Vector Processors. Examples include:
4
5 * Normalisation of Vectors of XYZ with respect to one dimension
6 * Alteration of ARGB pixel vectors wuth respect to opacity (A)
7 * Adjustment of YUV vectors with respect to luminosity
8
9 and many more. Lane-based Vector Processors not having the 2/3/4 inter-lane crossing have some difficulty processing such data and require it to be pushed into memory and retrieved, which is prohibitively costly in both instructions, time, and power consumption.
10
11 The cost is so great and the requirement so common that it easily justifies augmenting the ISA of a GPU to be able to specify the reordering of vec2/3/4 elements, often drastically increasing the instruction size in the process.
12
13 The reason for the dramatic increase is that the reordering of each element in vec4 requires 2 bits per element, plus a predicate mask. This means a minimum of 3 bits per element: 12 bits for a vec4, and if there are 2 src operands this is a whopping 24 bits of immediate data, per instruction.
14
15 There is also benefit to encoding some useful immediates into src operands, on a per sub-element basis: being able to specify for example that the Z element of a vec4 is to be 1.0 saves a complex LD-immediate merging operation for that lane.
16
17 # Options
18
19 ## Predication plus indices
20
21 * 4 bits for predication
22 * 2 bits per element
23
24 ## SUBVL plus indices
25
26 * SUBVL specifies the length (vec2/3/4)
27 * However index selection is 2 bits per element
28 * Therefore the src SUBVL must be separate and distinct from the dest SUBVL
29
30 ## Predication mixed with immediates and indices
31
32 * Three bits per element.
33 * One encoding (0b000) indicates "mask"
34 * Four encodings (0b1NN) indicate vec4 selection
35 * Three remaining indices indicate constants
36 - 0 (or 0.0)
37 - 1 (or 1.0)
38 - -1 (or -1.0) or some other option?