-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonday.tex
346 lines (305 loc) · 11.2 KB
/
monday.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
\documentclass[pdf,aspectratio=169]{beamer}
\usepackage{xifthen}
\usepackage{listings}
\usepackage[ruled]{algorithm2e}
\usepackage{hhline}
\usepackage{appendixnumberbeamer}
\usepackage{forloop}
\usepackage{makecell}
% Settings for listings package
\definecolor{mygreen}{rgb}{0,0.6,0}
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
\definecolor{mymauve}{rgb}{0.58,0,0.82}
\definecolor{altblue}{rgb}{0.0,0.6,1.0}
\definecolor{lstbg}{gray}{0.9}
\lstdefinelanguage[firedrake]{python}[]{python}{%
keywordstyle={[2]\color{red}},
morekeywords={[2]UnitCubeMesh,MeshHierarchy,FunctionSpace,Function,TrialFunction,TestFunction,DirichletBC,SpatialCoordinate,Constant,solve},
keywordstyle={[3]\color{orange}},
morekeywords={[3]grad,dx,inner,pi,sin,cos,tan}
}
\lstdefinelanguage[highlighting]{python}[firedrake]{python}{
moredelim=**[is][{\btHL[fill=red!30,draw=black,thin]}]{`mesh*}{`},
moredelim=**[is][{\btHL[fill=orange!30,draw=black,thin]}]{`fs*}{`},
moredelim=**[is][{\btHL[fill=mygreen!30,draw=black,thin]}]{`bcs*}{`},
moredelim=**[is][{\btHL[fill=blue!30,draw=black,thin]}]{`rhs*}{`},
moredelim=**[is][{\btHL[fill=violet!30,draw=black,thin]}]{`bilf*}{`}
}
\graphicspath{{./figures/}}
\mode<presentation>{
\usetheme{firedrake}
\usecolortheme{firedrake}
}
% Awkward widebar thing... (instead of mathabx)
\makeatletter
\newcommand*\rel@kern[1]{\kern#1\dimexpr\macc@kerna}
\newcommand*\widebar[1]{%
\begingroup
\def\mathaccent##1##2{%
\rel@kern{0.8}%
\overline{\rel@kern{-0.8}\macc@nucleus\rel@kern{0.2}}%
\rel@kern{-0.2}%
}%
\macc@depth\@ne
\let\math@bgroup\@empty \let\math@egroup\macc@set@skewchar
\mathsurround\z@ \frozen@everymath{\mathgroup\macc@group\relax}%
\macc@set@skewchar\relax
\let\mathaccentV\macc@nested@a
\macc@nested@a\relax111{#1}%
\endgroup
}
\makeatother
% Some tikz magic
\usepackage{tikz}
\usetikzlibrary{arrows}
% Define how TiKZ will draw the nodes
\tikzset{term/.style={draw=none,fill=none,rectangle,inner sep=0pt,anchor=base}}
\tikzstyle{every picture}+=[remember picture]
\everymath{\displaystyle}
\makeatletter
% Designate a term in a math environment to point to
% Syntax: \mathterm[node label]{some math}
\newcommand\mathterm[2][]{%
\@ifnextchar[{\@mathtermopts{#1}{#2}}{\@mathtermnoopts{#1}{#2}}}
\def\@mathtermnoopts#1#2{%
\tikz [baseline] { \node [term] (#1) {$#2$}; }}
\def\@mathtermopts#1#2[#3]{%
\tikz [baseline] { \node [rectangle,inner sep=2pt,rounded corners=2pt,anchor=base,,#3] (#1) {$#2$}; }}
\newcommand\textterm[2][]{%
\@ifnextchar[{\@texttermopts{#1}{#2}}{\@texttermnoopts{#1}{#2}}}
\def\@texttermnoopts#1#2{%
\tikz [baseline] { \node [term] (#1) {#2}; }}
\def\@texttermopts#1#2[#3]{%
\tikz [baseline] { \node [rectangle,inner sep=2pt,rounded corners=2pt,anchor=base,,#3] (#1) {#2}; }}
% A command to draw an arrow from the current position to a labelled math term
% Default color=black, default arrow head=stealth
% Syntax: \indicate[color]{term to point to}[path options]
\newcommand\indicate[2][black]{%
\tikz [baseline] \node [inner sep=0pt,anchor=base] (i#2) {\vphantom|};
\@ifnextchar[{\@indicateopts{#1}{#2}}{\@indicatenoopts{#1}{#2}}}
\def\@indicatenoopts#1#2{%
{\color{#1} \tikz[overlay] \path[line width=1pt,draw=#1,-stealth] (i#2) edge (#2);}}
\def\@indicateopts#1#2[#3]{%
{\color{#1} \tikz[overlay] \path[line width=1pt,draw=#1,-stealth] (i#2) [#3] edge (#2);}}
\newenvironment{btHighlight}[1][]
{\begingroup\tikzset{bt@Highlight@par/.style={#1}}\begin{lrbox}{\@tempboxa}}
{\end{lrbox}\bt@HL@box[bt@Highlight@par]{\@tempboxa}\endgroup}
\newcommand\btHL[1][]{%
\begin{btHighlight}[#1]\bgroup\aftergroup\bt@HL@endenv%
}
\def\bt@HL@endenv{%
\end{btHighlight}%
\egroup
}
\newcommand{\bt@HL@box}[2][]{%
\tikz[#1]{%
\pgfpathrectangle{\pgfpoint{1pt}{0pt}}{\pgfpoint{\wd #2}{\ht #2}}%
\pgfusepath{use as bounding box}%
\node[anchor=base west, fill=orange!30,outer sep=0pt,inner xsep=1pt, inner ysep=0pt, rounded corners=2pt, minimum height=\ht\strutbox+1pt,#1]{\raisebox{1pt}{\strut}\strut\usebox{#2}};
}%
}
\makeatother
%%%%% BEGIN lstlinebgrd highlighting
% Bug in lstlinebgrd
\makeatletter
\let\old@lstKV@SwitchCases\lstKV@SwitchCases
\def\lstKV@SwitchCases#1#2#3{}
\makeatother
\usepackage{lstlinebgrd}
\makeatletter
\let\lstKV@SwitchCases\old@lstKV@SwitchCases
\lst@Key{numbers}{none}{%
\def\lst@PlaceNumber{\lst@linebgrd}%
\lstKV@SwitchCases{#1}%
{none:\\%
left:\def\lst@PlaceNumber{\llap{\normalfont
\lst@numberstyle{\thelstnumber}\kern\lst@numbersep}\lst@linebgrd}\\%
right:\def\lst@PlaceNumber{\rlap{\normalfont
\kern\linewidth \kern\lst@numbersep
\lst@numberstyle{\thelstnumber}}\lst@linebgrd}%
}{\PackageError{Listings}{Numbers #1 unknown}\@ehc}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \btIfInRange{number}{range list}{TRUE}{FALSE}
%
% Test in int number <number> is element of a (comma separated) list of ranges
% (such as: {1,3-5,7,10-12,14}) and processes <TRUE> or <FALSE> respectively
\newcount\bt@rangea
\newcount\bt@rangeb
\newcommand\btIfInRange[2]{%
\global\let\bt@inrange\@secondoftwo%
\edef\bt@rangelist{#2}%
\foreach \range in \bt@rangelist {%
\afterassignment\bt@getrangeb%
\bt@rangea=0\range\relax%
\pgfmathtruncatemacro\result{ ( #1 >= \bt@rangea) && (#1 <= \bt@rangeb) }%
\ifnum\result=1\relax%
\breakforeach%
\global\let\bt@inrange\@firstoftwo%
\fi%
}%
\bt@inrange%
}
\newcommand\bt@getrangeb{%
\@ifnextchar\relax%
{\bt@rangeb=\bt@rangea}%
{\@getrangeb}%
}
\def\@getrangeb-#1\relax{%
\ifx\relax#1\relax%
\bt@rangeb=100000% \maxdimen is too large for pgfmath
\else%
\bt@rangeb=#1\relax%
\fi%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \btLstHL<overlay spec>{range list}
%
% TODO BUG: \btLstHL commands can not yet be accumulated if more than one overlay spec match.
%
\newcommand<>{\btLstHL}[1]{%
\only#2{\btIfInRange{\value{lstnumber}}{#1}{\color{black!30}\def\lst@linebgrdcmd{\color@block}}{\def\lst@linebgrdcmd####1####2####3{}}}%
}%
\makeatother
%%%%% END lstlinebgrd highlighting
\lstset{
backgroundcolor=\color{lstbg},
% choose the background color; you must add \usepackage{color} or \usepackage{xcolor}
basicstyle=\tiny\ttfamily,
% the size of the fonts that are used for the code
breakatwhitespace=true,
% sets if automatic breaks should only happen at whitespace
breaklines=true,
% sets automatic line breaking
captionpos=b,
% sets the caption-position to bottom
commentstyle=\color{mygreen},
% comment style
deletekeywords={},
% if you want to delete keywords from the given language
escapeinside={\#*}{*},
% if you want to add LaTeX within your code
extendedchars=true,
% lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
frame=single,
% adds a frame around the code
keepspaces=true,
% keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
keywordstyle=\color{blue},
% keyword style
%language=c++,
% the language of the code
otherkeywords={},
% if you want to add more keywords to the set
numbers=left,
% where to put the line-numbers; possible values are (none, left, right)
numbersep=5pt,
% how far the line-numbers are from the code
numberstyle=\tiny\color{mygray},
% the style that is used for the line-numbers
rulecolor=\color{black},
% if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))
showspaces=false,
% show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
showstringspaces=false,
% underline spaces within strings only
showtabs=false,
% show tabs within strings adding particular underscores
stepnumber=1,
% the step between two line-numbers. If it's 1, each line will be numbered
stringstyle=\color{mymauve},
% string literal style
tabsize=4,
% sets default tabsize to 4 spaces
title=\lstname,
% show the filename of files included with \lstinputlisting; also try caption instead of title
linebackgroundsep=3pt,linebackgroundwidth={\dimexpr\linewidth+6pt\relax}
%adjustments for lstlinebgrd highlighting
}
\newcommand{\citehere}[1]{{\footnotesize[#1]}}
\newcounter{nrank}
\title[]{Update: Firedrake on GPU + New-FL\\
\small SysGenX Meetup}
\author[JB,PF,DH]{\textbf{David Ham} \and Patrick Farrell \and Jack Betteridge \and Paul Kelly}
\date[26/9/2022]{26${}^\text{th}$ September 2022}
\begin{document}
\maketitle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Researcher and project structure}
\centering
\begin{tabular}{|c|c|}
\hline SysGenX & \makecell{Software for\\Research Communities} \\\hline
\makecell{J. Betteridge\\\\Deployment\\Memory management\\GPUs} & \makecell{K. Sagiyama\\\\I/O\\
Subdomains}\\\hline
\makecell{TBC\\\\UFL Rewrite}& \makecell{TBC\\\\Potentially AMR}\\\hline
\end{tabular}
\end{frame}
\begin{frame}{Research programme}
\begin{itemize}
\item Firedrake Spack installer
\item Firedrake Singularity image
\item Petsc4py garbage collector
\item GPUs
\item UFL rethink.
\end{itemize}
\end{frame}
\begin{frame}{Distributed garbage collection}
\begin{itemize}
\item Managed languages (Python, Julia...) destroy objects essentially at random.
\item PETSc expects all MPI ranks to destroy objects in concert.
\end{itemize}
This causes unpredictable deadlocks at scale.
\pause
Solution:
\begin{itemize}
\item Intercept destructor in managed language.
\item Objects to be destroyed are notified to PETSc as cleared for destruction.
\item PETSc periodically conducts a collective set intersection and actually destroys those objects all ranks agree on.
\end{itemize}
Code exists, merge to PETSc main is pending.
\end{frame}
\begin{frame}{Firedrake on GPUs}
Targetting transparent offload of operations to GPU. Three key operations:
\begin{itemize}
\item 1-Form assembly - WIP with UIUC.
\item Solvers/preconditioners - via PETSc
\item Matrix assembly - TBC.
\end{itemize}
\end{frame}
\begin{frame}[fragile]{GPU programming model}
\begin{lstlisting}[language={[firedrake]python},linebackgroundcolor={\btLstHL{15,16,22,23}}]
mesh = UnitSquareMesh(32, 32)
V = FunctionSpace(mesh, "CG", 1)
u = TrialFunction(V)
v = TestFunction(V)
x, y = SpatialCoordinate(mesh)
a = (inner(grad(u), grad(v)) + inner(u, v)) * dx
f = Function(V)
f.interpolate((1+8*pi*pi)*cos(x*pi*2)*cos(y*pi*2))
L = inner(f, v) * dx
fem_soln = Function(V)
sp = {"mat_type": "matfree",
"ksp_monitor_true_residual": None,
"ksp_converged_reason": None}
with offloading():
solve(a == L, fem_soln, solver_parameters=sp)
f.interpolate(cos(x*pi*2)*cos(y*pi*2))
assert norm(fem_soln-f) < 1e-2
with offloading():
assert norm(fem_soln-f) < 1e-2
\end{lstlisting}
\end{frame}
\begin{frame}{UFL Rethink}
At least:
\begin{enumerate}
\item Extensibility.
\item Closure (we don't "fall out" of UFL).
\item Scope: integral operators, interpolation, \ldots
\item Design mistakes: e.g. how to represent finite elements.
\item Extensions to support AMR, P-refinement\ldots
\item Performance at some points.
\end{enumerate}
Discussion starts tomorrow.
\end{frame}
\end{document}