(no commit message)
[libreriscv.git] / openpower / sv.mdwn
1 [[!tag standards]]
2
3 Obligatory Dilbert:
4
5 <img src="https://assets.amuniversal.com/7fada35026ca01393d3d005056a9545d" width="600" />
6
7 ===
8
9 # SV (Simple Scalar Vectorisation) for the Power ISA
10
11 **SV is in DRAFT STATUS**. SV has not yet been submitted to the OpenPOWER Foundation ISA WG for review.
12
13 * <https://bugs.libre-soc.org/show_bug.cgi?id=213>
14 * <https://youtu.be/ZQ5hw9AwO1U> walkthrough video (19jun2022)
15
16 SV is designed as a Scalable Vector ISA for Hybrid 3D CPU GPU VPU workloads.
17 As such it brings features normally only found in Cray Supercomputers
18 (Cray-1, NEC SX-Aurora)
19 and in GPUs, but keeps strictly to a *Simple* RISC principle of leveraging
20 a *Scalar* ISA, exclusively using "Prefixing". **Not one single actual
21 explicit Vector opcode exists in SV, at all**. It is suitable for
22 low-power Embedded and DSP Workloads as much as it is for power-efficient
23 Supercomputing.
24
25 Fundamental design principles:
26
27 * Taking the simplicity of the RISC paradigm and applying it strictly and
28 uniformly to create a Scalable Vector ISA.
29 * Effectively a hardware for-loop, pausing PC, issuing multiple scalar
30 operations
31 * Preserving the underlying scalar execution dependencies as if the
32 for-loop had been expanded as actual scalar instructions
33 (termed "preserving Program Order")
34 * Augments ("tags") existing instructions, providing Vectorisation
35 "context" rather than adding new instructions.
36 * Does not modify or deviate from the underlying scalar Power ISA
37 unless it provides significant performance or other advantage to do so
38 in the Vector space (dropping the "sticky" characteristics
39 of XER.SO and CR0.SO for example)
40 * Designed for Supercomputing: avoids creating significant sequential
41 dependency hazards, allowing standard
42 high performance superscalar multi-issue
43 micro-architectures to be leveraged.
44
45 Advantages of these design principles:
46
47 * Simplicity of introduction and implementation on top of
48 the existing Power ISA without disruption.
49 * It is therefore easy to create a first (and sometimes only)
50 implementation as literally a for-loop in hardware, simulators, and
51 compilers.
52 * Hardware Architects may understand and implement SV as being an
53 extra pipeline stage, inserted between decode and issue, that is
54 a simple for-loop issuing element-level sub-instructions.
55 * More complex HDL can be done by repeating existing scalar ALUs and
56 pipelines as blocks and leveraging existing Multi-Issue Infrastructure
57 * As (mostly) a high-level "context" that does not (significantly) deviate
58 from scalar Power ISA and, in its purest form being "a for loop around
59 scalar instructions", it is minimally-disruptive and consequently stands
60 a reasonable chance of broad community adoption and acceptance
61 * Completely wipes not just SIMD opcode proliferation off the
62 map (SIMD is O(N^6) opcode proliferation)
63 but off of Vectorisation ISAs as well. No more separate Vector
64 instructions.
65
66 Comparative instruction count:
67
68 * ARM NEON SIMD: around 2,000 instructions, prerequisite: ARM Scalar.
69 * ARM SVE: around 4,000 instructions, prerequisite: NEON.
70 * ARM SVE2: around 1,000 instructions, prerequisite: SVE
71 * Intel AVX-512: around 4,000 instructions, prerequisite AVX, AVX2,
72 AVX-128 and AVX-256 which in turn critically rely on the rest of
73 x86, for a grand total of well over 10,000 instructions.
74 * RISV-V RVV: 192 instructions, prerequisite 96 Scalar RV64GC instructions
75 * SVP64: **five** instructions, 24-bit prefixing of
76 prerequisite SFS (150) or
77 SFFS (214) Compliancy Subsets
78
79 SV comprises several [[sv/compliancy_levels]] suited to Embedded, Energy
80 efficient High-Performance Compute, Distributed Computing and Advanced
81 Computational Supercomputing. The Compliancy Levels are arranged such
82 that even at the bare minimum Level, full Soft-Emulation of all
83 optional and future features is possible.
84
85 # Sub-pages
86
87 Pages being developed and examples
88
89 * [[sv/overview]] explaining the basics.
90 * [[sv/compliancy_levels]] for minimum subsets through to Advanced
91 Supercomputing.
92 * [[sv/implementation]] implementation planning and coordination
93 * [[sv/svp64]] contains the packet-format *only*, the [[sv/svp64/appendix]]
94 contains explanations and further details
95 * [[sv/svp64_quirks]] things in SVP64 that slightly break the rules
96 * [[opcode_regs_deduped]] autogenerated table of SVP64 decoder augmentation
97 * [[sv/sprs]] SPRs
98 * SVP64 "Modes":
99 - For condition register operations see [[sv/cr_ops]] - SVP64 Condition
100 Register ops: Guidelines
101 on Vectorisation of any v3.0B base operations which return
102 or modify a Condition Register bit or field.
103 - For LD/ST Modes, see [[sv/ldst]].
104 - For Branch modes, see [[sv/branches]] - SVP64 Conditional Branch
105 behaviour: All/Some Vector CRs
106 - For arithmetic and logical, see [[sv/normal]]
107 - [[sv/mv.vec]] pack/unpack move to and from vec2/3/4,
108 actually an RM.EXTRA Mode and a [[sv/remap]] mode
109
110 Core SVP64 instructions:
111
112 * [[sv/setvl]] the Cray-style "Vector Length" instruction
113 * [[sv/remap]] "Remapping" for Matrix Multiply and RGB "Structure Packing"
114 * [[sv/svstep]] Key stepping instruction for Vertical-First Mode
115
116 *Please note: there are only five instructions in the whole of SV.
117 Beyond this point are additional **Scalar** instructions related to
118 specific workloads that have nothing to do with the SV Specification*
119
120 **Additional Instructions for specific purposes (not SVP64)**
121
122 All of these instructions below have nothing to do with SV.
123 They are all entirely designed as Scalar instructions that, as
124 Scalar instructions, stand on their own merit. Considerable
125 lengths have been made to provide justifications for each of these
126 *Scalar* instructions.
127
128 Some of these Scalar instructions are specifically designed to make
129 Scalable Vector binaries more efficient, such
130 as the crweird group. Others are to bring the Scalar Power ISA
131 up-to-date within specific workloads,
132 such as a Javascript Rounding instruction. None of them are strictly
133 necessary but performance and power consumption may be (or, is already)
134 compromised
135 in certain workloads and use-cases without them.
136
137 Vector-related:
138
139 * [[sv/mv.swizzle]] vec2/3/4 Swizzles (RGBA, XYZW) for 3D and CUDA.
140 designed as a Scalar instruction.
141 * [[sv/vector_ops]] scalar operations needed for supporting vectors
142
143 Scalar Instructions:
144
145 * [[sv/cr_int_predication]] instructions needed for effective predication
146 * [[sv/bitmanip]]
147 * [[sv/fcvt]] FP Conversion (due to OpenPOWER Scalar FP32)
148 * [[sv/fclass]] detect class of FP numbers
149 * [[sv/int_fp_mv]] Move and convert GPR <-> FPR, needed for !VSX
150 * [[sv/av_opcodes]] scalar opcodes for Audio/Video
151 * Twin targetted instructions (two registers out, one implicit, just like
152 Load-with-Update).
153 Explanation of the rules for twin register targets
154 (implicit RS, FRS) explained in SVP64 [[sv/svp64/appendix]]
155 - [[isa/svfixedarith]]
156 - [[isa/svfparith]]
157 - [[sv/biginteger]] Operations that help with big arithmetic
158 * TODO: OpenPOWER adaptation [[openpower/transcendentals]]
159
160 # Other Scalable Vector ISAs
161
162 * Original Cray ISA
163 <http://www.bitsavers.org/pdf/cray/CRAY_Y-MP/HR-04001-0C_Cray_Y-MP_Computer_Systems_Functional_Description_Jun90.pdf>
164 * NEC SX Aurora (still in production, inspired by Cray)
165 <https://www.hpc.nec/documents/guide/pdfs/Aurora_ISA_guide.pdf>
166 * RISC-V RVV (inspired by Cray)
167 <https://github.com/riscv/riscv-v-spec>
168 * MRISC32 ISA Manual (under active development)
169 <https://github.com/mrisc32/mrisc32/tree/master/isa-manual>
170 * Mitch Alsup's MyISA 66000 Vector Processor ISA Manual is available from
171 Mitch on request.
172
173 A comprehensive list of 3D GPU, Packed SIMD, Predicated-SIMD and true Scalable
174 Vector ISAs may be found at the [[sv/vector_isa_comparison]] page.
175 Note: AVX-512 and SVE2 are *not strict Vector ISAs*, they are Predicated-SIMD.
176 *Public discussions have taken place at Conferences attended by both Intel
177 and ARM on adding a `setvl` instruction which would easily make both
178 AVX-512 and SVE2 truly "Scalable".*
179
180 # Major opcodes summary
181
182 Simple-V itself only requires four instructions with 6-bit Minor XO
183 (bits 26-31), and the SVP64 Prefix Encoding requires
184 25% space of the EXT001 Major Opcode.
185 There are **no** Vector Instructions and consequently **no further
186 opcode space is required**.
187
188 That said: for the target workloads for which Scalable Vectors are typically
189 used, the Scalar ISA on which SV critically relies is somewhat anaemic.
190 The Libre-SOC Team has therefore been addressing that by developing
191 a number of Scalar instructions in specialist areas (Big Integer,
192 Cryptography, 3D, Audio/Video, DSP) and it is these which require
193 considerable Scalar opcode space.
194
195 Please be advised that even though SV is entirely DRAFT status, there
196 is considerable concern that because there is not yet any two-way
197 day-to-day communication established with the OPF ISA WG, we have
198 no idea if any of these are conflicting with future plans by any OPF
199 Members. **The External ISA WG RFC Process is yet to be ratified
200 and Libre-SOC may not join the OPF as an entity because it does
201 not exist except in name. Even if it existed it would be a conflict
202 of interest to join the OPF, due to our funding remit from NLnet**.
203 We therefore proceed on the basis of making public the intention to
204 submit RFCs once the External ISA WG RFC Process is in place and,
205 in a wholly unsatisfactory manner have to *hope and trust* that
206 OPF ISA WG Members are reading this and take it into consideration.
207
208 **None of these Draft opcodes are intended for private custom
209 secret proprietary usage. They are all intended for entirely
210 public, upstream, high-profile mass-volume day-to-day usage at the
211 same level as add, popcnt and fld**
212
213 * SVP64 requires 25% of EXT01 (bits 6 and 9 set to 1)
214 * bitmanip requires two major opcodes (due to 16+ bit immediates)
215 those are currently EXT022 and EXT05.
216 * brownfield encoding in one of those two major opcodes still
217 requires multiple VA-Form operations (in greater numbers
218 than EXT04 has spare)
219 * space in EXT019 next to addpcis and crops is recommended
220 (or any 5-6 bit Minor XO areas)
221 * many X-Form opcodes currently in EXT022 have no preference
222 for a location at all, and may be moved to EXT059, EXT019,
223 EXT031 or other much more suitable location.
224
225 Note that there is no Sandbox allocation in the published ISA Spec for
226 v3.1 EXT01 usage, and because SVP64 is already 64-bit Prefixed,
227 Prefixed-Prefixed-instructions (SVP64 Prefixed v3.1 Prefixed)
228 would become a whopping 96-bit long instruction. Avoiding this
229 situation is a high priority which in turn by necessity puts pressure
230 on the 32-bit Major Opcode space.
231
232 Note also that EXT022, the Official Architectural Sandbox area
233 is under severe design pressure as it is insufficient to hold
234 the full extent of the instruction additions required to create
235 a Hybrid 3D CPU-VPU-GPU.
236
237 **Whilst SVP64 is only 4 instructions
238 the heavy focus on VSX for the past 12 years has left the SFFS Level
239 anaemic and out-of-date compared to ARM and x86. Approximately
240 100 additional Scalar Instructions are up for proposal**
241
242 # Other
243
244 Examples experiments future ideas discussion:
245
246 * [[sv/propagation]] Context propagation including svp64, swizzle and remap
247 * [[sv/masked_vector_chaining]]
248 * [[sv/discussion]]
249 * [[sv/example_dep_matrices]]
250 * [[sv/major_opcode_allocation]]
251 * [[sv/byteswap]]
252 * [[sv/16_bit_compressed]] experimental
253 * [[sv/toc_data_pointer]] experimental
254 * [[sv/predication]] discussion on predication concepts
255 * [[sv/register_type_tags]]
256 * [[sv/mv.x]] deprecated in favour of Indexed REMAP
257
258 Additional links:
259
260 * <https://www.sigarch.org/simd-instructions-considered-harmful/>
261 * [[sv/vector_isa_comparison]] - a list of Packed SIMD, GPU,
262 and other Scalable Vector ISAs
263 * [[simple_v_extension]] old (deprecated) version
264 * [[openpower/sv/llvm]]
265