Peano
Loading...
Searching...
No Matches
Limiter.py
Go to the documentation of this file.
1# This file is part of the ExaHyPE2 project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3from copy import deepcopy
4
5import peano4.output
6
8
9
10class Limiter:
11 def __init__(self, dictionary):
12 self.d = deepcopy(dictionary)
13
15 self, namespace, output, subdirectory, template_prefix, output_path
16 ):
17 self._build_gemms()
18
20 headfile_template=template_prefix + "Limiter.template.h",
21 cppfile_template=template_prefix + "Limiter.template.cpp",
22 classname=output_path + "/Limiter",
23 namespace=namespace,
24 subdirectory=subdirectory + ".",
25 dictionary=self.d,
26 default_overwrite=True,
27 apply_iteratively=True,
28 )
29 output.add(generated_kernels)
30 output.makefile.add_h_file(output_path + "/Limiter.h", generated=True)
31 output.makefile.add_cpp_file(output_path + "/Limiter.cpp", generated=True)
32
33 def _build_gemms(self):
34 self.d["GEMMS"] = {}
35 nDim = self.d["DIMENSIONS"]
36 nDof = self.d["NUMBER_OF_DOF"]
37 nDof2 = nDof * nDof
38 nDofPad = self.d["NUMBER_OF_DOF_PADDED"]
39 nDofLim = self.d["NUMBER_OF_DOF_LIMITER"]
40 nDofLim2 = nDofLim * nDofLim
41 nDofLimPad = self.d["NUMBER_OF_DOF_LIMITER_PADDED"]
42 nUnknowns = self.d["NUMBER_OF_UNKNOWNS"]
43 nUnknownsPad = self.d["NUMBER_OF_UNKNOWNS_PADDED"]
44 nData = self.d["NUMBER_OF_DATA"]
45 nDataPad = self.d["NUMBER_OF_DATA_PADDED"]
46
47 self.d["GEMMS"]["dg2fv_x"] = Gemms(
48 nData,
49 nDofLim,
50 nDof,
51 nData,
52 nDofPad,
53 nDataPad,
54 1,
55 0,
56 0,
57 1,
58 "dg2fv_x",
59 "nopf",
60 "gemm",
61 ) # input slice not aligned
62 if nDim == 3:
63 self.d["GEMMS"]["dg2fv_y"] = Gemms(
64 nDataPad,
65 nDofLim,
66 nDof,
67 nDofLim * nDataPad,
68 nDofPad,
69 nDofLim * nDataPad,
70 1,
71 0,
72 1,
73 1,
74 "dg2fv_y",
75 "nopf",
76 "gemm",
77 ) # M is padded in both input and output
78 self.d["GEMMS"]["dg2fv_z"] = Gemms(
79 nData,
80 nDofLim,
81 nDof,
82 nDofLim2 * nDataPad,
83 nDofPad,
84 nDofLim2 * nData,
85 1,
86 0,
87 1,
88 0,
89 "dg2fv_z",
90 "nopf",
91 "gemm",
92 ) # output slice not aligned
93 else:
94 self.d["GEMMS"]["dg2fv_y"] = Gemms(
95 nData,
96 nDofLim,
97 nDof,
98 nDofLim * nDataPad,
99 nDofPad,
100 nDofLim * nData,
101 1,
102 0,
103 1,
104 0,
105 "dg2fv_y",
106 "nopf",
107 "gemm",
108 ) # output slice not aligned
109
110 # Project to DG
111 self.d["GEMMS"]["fv2dg_x"] = Gemms(
112 nData,
113 nDof,
114 nDofLim,
115 nData,
116 nDofLimPad,
117 nDataPad,
118 1,
119 0,
120 0,
121 1,
122 "fv2dg_x",
123 "nopf",
124 "gemm",
125 ) # input slice not aligned
126 if nDim == 3:
127 self.d["GEMMS"]["fv2dg_y"] = Gemms(
128 nDataPad,
129 nDof,
130 nDofLim,
131 nDof * nDataPad,
132 nDofLimPad,
133 nDof * nDataPad,
134 1,
135 0,
136 1,
137 1,
138 "fv2dg_y",
139 "nopf",
140 "gemm",
141 ) # M is padded in both input and output
142 self.d["GEMMS"]["fv2dg_z"] = Gemms(
143 nData,
144 nDof,
145 nDofLim,
146 nDof2 * nDataPad,
147 nDofLimPad,
148 nDof2 * nData,
149 1,
150 0,
151 1,
152 0,
153 "fv2dg_z",
154 "nopf",
155 "gemm",
156 ) # output slice not aligned
157 else:
158 self.d["GEMMS"]["fv2dg_y"] = Gemms(
159 nData,
160 nDof,
161 nDofLim,
162 nDof * nDataPad,
163 nDofLimPad,
164 nDof * nData,
165 1,
166 0,
167 1,
168 0,
169 "fv2dg_y",
170 "nopf",
171 "gemm",
172 ) # output slice not aligned
173
174 # Project to Lobatto for Min/Max
175 self.d["GEMMS"]["uh2lob_x"] = Gemms(
176 nData,
177 nDof,
178 nDof,
179 nData,
180 nDofPad,
181 nDataPad,
182 1,
183 0,
184 0,
185 1,
186 "uh2lob_x",
187 "nopf",
188 "gemm",
189 ) # input slice not aligned
190 if nDim == 3:
191 self.d["GEMMS"]["uh2lob_y"] = Gemms(
192 nDataPad,
193 nDof,
194 nDof,
195 nDof * nDataPad,
196 nDofPad,
197 nDof * nDataPad,
198 1,
199 0,
200 1,
201 1,
202 "uh2lob_y",
203 "nopf",
204 "gemm",
205 ) # M is padded in both input and output
206 self.d["GEMMS"]["uh2lob_z_slice"] = Gemms(
207 nDataPad,
208 nDof,
209 nDof,
210 nDof2 * nDataPad,
211 nDofPad,
212 nDataPad,
213 1,
214 0,
215 1,
216 1,
217 "uh2lob_z_slice",
218 "nopf",
219 "gemm",
220 ) # will only write a slice, overwrite
221 else:
222 self.d["GEMMS"]["uh2lob_y_slice"] = Gemms(
223 nDataPad,
224 nDof,
225 nDof,
226 nDof * nDataPad,
227 nDofPad,
228 nDataPad,
229 1,
230 0,
231 1,
232 1,
233 "uh2lob_y_slice",
234 "nopf",
235 "gemm",
236 ) # will only write a slice, overwrite
237
238 # Project to FV for Min/Max, reuse previous GEMM except last one for slice.
239 if nDim == 3:
240 self.d["GEMMS"]["dg2fv_z_slice"] = Gemms(
241 nDataPad,
242 nDofLim,
243 nDof,
244 nDofLim2 * nDataPad,
245 nDofPad,
246 nDataPad,
247 1,
248 0,
249 1,
250 1,
251 "dg2fv_z_slice",
252 "nopf",
253 "gemm",
254 ) # will only write a slice, overwrite
255 else:
256 self.d["GEMMS"]["dg2fv_y_slice"] = Gemms(
257 nDataPad,
258 nDofLim,
259 nDof,
260 nDofLim * nDataPad,
261 nDofPad,
262 nDataPad,
263 1,
264 0,
265 1,
266 1,
267 "dg2fv_y_slice",
268 "nopf",
269 "gemm",
270 ) # will only write a slice, overwrite
271
272 if self.d["USE_LIBXSMM"]:
273 self.controller.generateGemms("asm_limiter.c", self.d["GEMMS"].values())
Specification of a dense matrix-matrix multiplication.
Definition Gemms.py:6
generate_kernels(self, namespace, output, subdirectory, template_prefix, output_path)
Definition Limiter.py:16