-
Notifications
You must be signed in to change notification settings - Fork 0
/
builtin_pattern.tex
120 lines (86 loc) · 2.66 KB
/
builtin_pattern.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
\documentclass{report}
\usepackage{xcolor}
\usepackage{listings}
\newcommand{\concept}[1]{\fontfamily{pcr}{\selectfont #1}}
\input{lststyle_hir.tex}
\begin{document}
Built-ins in LFRic and PSyclone are dof-wise (point-wise) operations
used for arithmetic operations on fields (e.g. adding, subtracting,
scaling, inner product). They can write the result of the operation
in a new quantity (e.g. $Z = X + Y$) or they can just
update one of the input arguments (e.g. $X = X + Y$).
\begin{lstlisting}[style=dsl]
computation BuiltIn():
field x, y, z
field
iterationSpace = DofMap
dofmap = {z.function_space.last_dof
# last_dof can be owned or annexed,
# sanity check that all fields
# are on the same function space
}
forall df in dofmap:
z.data[df] = Operation(\
x.data[df], y.data[df])
\end{lstlisting}
or
\begin{lstlisting}[style=dsl]
computation BuiltIn{
field x, y, z
field entities
entities = UniqueDofs(owned, annexed)
iterationSpace = {
BuiltIn(z) = Operation<entities>(y, z; +, -, *, /)
}
}
\end{lstlisting}
BuiltIns which take fields and return scalars effectively
perform global sums (such as sum of a field or an inner product).
This process can be performed over local sums as shown below.
\begin{lstlisting}[style=dsl]
computation ReductionBuiltIn():
field y, z
field dofmap
scalar lsum, sum
dofmap = {z.function_space.last_dof
# last_dof is always owned,
# sanity check that all fields
# are on the same function space
}
# OMP parallel do
forall df in dofmap:
lsum[thread_id] = lsum[thread_id] + \
Operation(\x.data[df], y.data[df])
forall thread_id in threads:
sum = sum + lsum[thread_id]
\end{lstlisting}
or
\begin{lstlisting}[style=dsl]
computation reductionBuiltIn{
field x, y
scalar lsum, reductionBuiltIn
field entities
entities = UniqueDofs(owned, annexed)
iterationSpace = {
lsum = Operation<entities>(x, y; inner_product, [])
reductionBuiltIn(sum) = reduction<lsum(:)>
}
}
\end{lstlisting}
Whether the unique dofs are accessed up to owned or annexed dofs can be
controlled by PSyclone.
\subsection{Data Structure}
\begin{itemize}
\item Field data defined with \concept{Dofmap}
\end{itemize}
\subsection{Dimensionality}
\begin{itemize}
\item All 3D degrees of freedom.
\end{itemize}
\subsection{Access Pattern}
\begin{itemize}
\item Point-wise operations without neighbours, operate over unique dofs.
\end{itemize}
Functionality to get last dof (owned, annexed and at defined depth)
is stored in function space object.
\end{document}