update fosdem 2024 ddffirst strncpy section on slides
[libreriscv.git] / conferences / fosdem2024 / fosdem2024_ddffirst / fosdem2024_ddffirst.tex
1 \documentclass[slidestop]{beamer}
2 \usepackage{beamerthemesplit}
3 \usepackage{graphics}
4 \usepackage{pstricks}
5 \usepackage{pgffor}
6 \usepackage{listings}
7
8 \graphicspath{{./}}
9
10 \title{Data-Dependent-Fail-First}
11 \author{Luke Kenneth Casson Leighton and Shriya Sharma}
12
13
14 \begin{document}
15
16 \frame{
17 \begin{center}
18 \huge{The Libre-SOC Hybrid 3D CPU}\\
19 \vspace{32pt}
20 \Large{Data-Dependent-Fail-First}\\
21
22 \vspace{24pt}
23 \Large{FOSDEM2024}\\
24 \vspace{16pt}
25 \large{Sponsored by NLnet's PET Programme}\\
26 \vspace{6pt}
27 \large{\today}
28 \end{center}
29 }
30
31
32
33 \begin{frame}[fragile]
34 \frametitle{Simple-V CMPI in a nutshell}
35
36 \begin{semiverbatim}
37 function op\_cmpi(BA, RA, SI) # cmpi not vector-cmpi!
38 (assuming you know power-isa)
39  int i, id=0, ira=0;
40  for (i = 0; i < VL; i++)
41   CR[BA+id] <= compare(ireg[RA+ira], SI);
42 if (reg\_is\_vectorised[BA] ) \{ id += 1; \}
43 if (reg\_is\_vectorised[RA])  \{ ira += 1; \}
44 \end{semiverbatim}
45
46 \begin{itemize}
47 \item Above is oversimplified: predication etc. left out
48 \item Scalar-scalar and scalar-vector and vector-vector now all in one
49 \item OoO may choose to push CMPIs into instr. queue (v. busy!)
50 \end{itemize}
51 \end{frame}
52
53
54 \frame{\frametitle{Load/Store Fault-First}
55
56 \begin{itemize}
57 \item Problem: vector load and store can cause a page fault
58 \item Solution: a protocol that allows optional load/store
59 \item instruction \textit{requests} a number of elements
60 \item instruction \textit{informs} the number actually loaded
61 \item first element load/store is not optional (cannot fail)
62 \item ARM SVE: https://arxiv.org/pdf/1803.06185.pdf
63 \item more: wikipedia Vector processor page: Fault/Fail First
64 \vspace{10pt}
65 \item Load/Store is Memory to/from Register, what about
66 Register to Register?
67 \item Register-to-register: "Data-Dependent Fail-First."
68 \item Z80 LDIR: Mem-Register, CPIR: Register-Register
69 \end{itemize}
70 }
71
72 \begin{frame}[fragile]
73 \frametitle{Data-Dependent-Fail-First in a nutshell}
74
75 \begin{semiverbatim}
76 function op\_cmpi(BA, RA, SI) # cmpi not vector-cmpi!
77 int i, id=0, ira=0;
78 for (i = 0; i < VL; i++)
79 CR[BA+id] <= compare(ireg[RA+ira], SI);
80 if (reg\_is\_vectorised[BA] ) \{ id += 1; \}
81 if (reg\_is\_vectorised[RA])  \{ ira += 1; \}
82 if test (CR[BA+id]) == FAIL: \{ VL = i + 1; break \}
83 \end{semiverbatim}
84
85 \begin{itemize}
86 \item Parallelism still perfectly possible
87 ("hold" writing results until sequential post-analysis
88 carried out. Best done with OoO)
89 \item VL truncation can be inclusive or exclusive
90 (include or exclude a NULL pointer or a
91 string-end character, or overflow result)
92 \item \textit{Truncation can be to zero Vector Length}
93 \end{itemize}
94 \end{frame}
95
96 \frame{\frametitle{Power ISA v3.1 vstribr}
97
98 \lstinputlisting[language={}]{vstribr.txt}
99
100 \begin{itemize}
101 \item ironically this hard-coded instruction is
102 identical to general-purpose Simple-V DD-FFirst...
103 \end{itemize}
104
105 }
106
107 \frame{\frametitle{Pospopcount}
108
109 \begin{itemize}
110 \item Positional popcount adds up the totals of each bit set to 1 in each bit-position, of an array of input values.
111 \item Notoriously difficult to do in SIMD assembler: typically 550 lines
112 \item https://github.com/clausecker/pospop
113
114 \end{itemize}
115
116 \lstinputlisting[language={}]{pospopcount.c}
117
118
119 }
120
121 \frame{\frametitle{Pospopcount}
122
123 \begin{center}
124 \includegraphics[width=0.5\textwidth]{pospopcount.png}
125 \end{center}
126 \begin{itemize}
127 \item The challenge is to perform an appropriate transpose of the data (the CPU can only work on registers, horizontally),
128 in blocks that suit the processor and the ISA capacity.
129
130
131 \end{itemize}
132 }
133
134 \frame{\frametitle{Pospopcount}
135
136 \begin{center}
137 \includegraphics[width=0.6\textwidth]{array_popcnt.png}
138 \end{center}
139
140 \begin{itemize}
141
142 \item The draft gbbd instruction implements the transpose (shown above),
143 preparing the data to use standard popcount.
144 (gbbd is based on Power ISA vgbbd, v3.1 p445)
145
146 \end{itemize}
147
148 }
149
150 \frame{\frametitle{pospopcount assembler}
151
152
153 \lstinputlisting[language={}]{pospopcount.s}
154
155 }
156
157 \frame{\frametitle{strncpy}
158
159 \lstinputlisting[language={}]{strncpy.c}
160 \begin{itemize}
161 \item two simple-looking for-loops,
162 data-dependent in the first.
163 \item sv.cmpi stops at the first zero, /vli includes the zero
164 in VL.
165 \item note the post-increment Load/Store: saves
166 pre-decrementing
167 \item a Vector of CRs is produced which then get tested
168 by the sv.bc/all instruction, counting down CTR
169 per item tested.
170 \item Power ISA added hard-coded data-dependent capacity
171 into vstribr, where SVP64 it is generic (applies
172 to any instruction)
173 \item even the null-ing part is not straightforward as
174 it could be mis-aligned compared to the VSX width.
175 \item end-result: assembler-optimised strncpy on Power
176 ISA v3.0 is a whopping 240 instructions. SVP64 is 10
177 and parallel in HW
178 \end{itemize}
179 }
180
181
182
183 \frame{\frametitle{strncpy assembler}
184
185 \lstinputlisting[language={}]{strncpy.s}
186
187 }
188
189 \frame{\frametitle{sv.lbz/ff=RC1/vli *16,1(10)}
190 \begin{center}
191 \includegraphics[width=0.6\textwidth]{lbz_ff_vli.png}
192 \end{center}
193
194 \begin{itemize}
195 \item r10 points to memory address 0x001007
196 \item sv.lbz (Power ISA load byte immediate) multiplies immediate
197 offset by element step index, to get Effective Address (EA)
198 \item LD/ST has no Rc=1 so Data-Dependent Fail-First specified
199 as "ff=RC1". Not LD/ST Fault First! vli: VL inclusive
200 \item Test done after each load. Fails at Memory contents
201 0x001009. Inclusive Mode: VL is truncated to 5 (FIVE) not 4
202 \end{itemize}
203 }
204
205 \frame{\frametitle{linked-list walking}
206
207 \begin{itemize}
208 \item "TODO
209 \end{itemize}
210 }
211
212 \frame{\frametitle{sv.ld/ff=RC1/vli *17, 8(*16)}
213
214 \begin{center}
215 \includegraphics[width=1.0\textwidth]{linked_list_dd.png}
216 \end{center}
217 }
218
219 \frame{\frametitle{maxloc}
220 \begin{itemize}
221 \item "TODO
222 \end{itemize}
223 }
224
225 \frame{\frametitle{Summary}
226
227 \begin{itemize}
228 \item Goal is to create a mass-volume low-power embedded SoC suitable
229 for use in netbooks, chromebooks, tablets, smartphones, IoT SBCs.
230 \item No way we could implement a project of this magnitude without
231 nmigen (being able to use python OO to HDL)
232 \item Collaboration with OpenPOWER Foundation and Members absolutely
233 essential. No short-cuts. Standards to be developed and ratified
234 so that everyone benefits.
235 \item Riding the wave of huge stability of OpenPOWER ecosystem
236 \item Greatly simplified open 3D and Video drivers reduces product
237 development costs for customers
238 \item It also happens to be fascinating, deeply rewarding technically
239 challenging, and funded by NLnet
240
241 \end{itemize}
242 }
243
244 \frame{\frametitle{How can you help?}
245
246 \vspace{5pt}
247
248 \begin{itemize}
249 \item Start here! https://libre-soc.org \\
250 Mailing lists https://lists.libre-soc.org \\
251 IRC Freenode libre-soc \\
252 etc. etc. (it's a Libre project, go figure) \\
253 \vspace{3pt}
254 \item Can I get paid? Yes! NLnet funded\\
255 See https://libre-soc.org/nlnet/\#faq \\
256 \vspace{3pt}
257 \item Also profit-sharing in any commercial ventures \\
258 \vspace{3pt}
259 \item How many opportunities to develop Libre SoCs exist,\\
260 and actually get paid for it?
261 \vspace{3pt}
262 \item I'm not a developer, how can I help?\\
263 - Plenty of research needed, artwork, website \\
264 - Help find customers and OEMs willing to commit (LOI)
265 \end{itemize}
266 }
267
268
269
270 \frame{
271 \begin{center}
272 {\Huge The end\vspace{12pt}\\
273 Thank you\vspace{12pt}\\
274 Questions?\vspace{12pt}
275 }
276 \end{center}
277
278 \begin{itemize}
279 \item Discussion: http://lists.libre-soc.org
280 \item Freenode IRC \#libre-soc
281 \item http://libre-soc.org/
282 \item http://nlnet.nl/PET
283 \item https://libre-soc.org/nlnet/\#faq
284 \end{itemize}
285 }
286
287
288 \end{document}