Peano
Loading...
Searching...
No Matches
FusedSpaceTimePredictorVolumeIntegral.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
7from .Gemms import Gemms
8from .Gemms import generate_gemms
9
10from exahype2.solvers.MathUtils import MathUtils
11
12
14 def __init__(self, dictionary):
15 self.d = deepcopy(dictionary)
16
18 self, namespace, output, subdirectory, template_prefix, output_path
19 ):
20 self._build_gemms(namespace, output, subdirectory, template_prefix, output_path)
21
22 if self.d["IS_LINEAR"]:
23 # Size of the tmp array
24 self.d["TMP_ARRAY_SIZE"] = max(
25 (
26 self.d["NUMBER_OF_DOF"] * self.d["NUMBER_OF_UNKNOWNS_PADDED"]
27 if self.d["USE_FLUX"]
28 else 0
29 ),
30 (
31 self.d["DIMENSIONS"] * self.d["NUMBER_OF_UNKNOWNS_PADDED"]
32 if self.d["USE_NCP"]
33 else 0
34 ),
35 )
36 self.d["NAME_SUFFIX"] = ""
37
38 if self.d["USE_POINT_SOURCE"]:
39 # Assembling the basis function for the point source
40 QuadratureWeights, QuadratureNodes = MathUtils.getGaussLegendre(
41 self.d["NUMBER_OF_DOF"]
42 )
43 self.d["BASIS_FUNCTIONS"] = MathUtils.assembleBasisFunction(
44 QuadratureNodes
45 )
46
47 d = deepcopy(self.d)
48 d["USE_POINT_SOURCE"] = False
49 d["NAME_SUFFIX"] = "WithoutPointSources"
50
51 generated_kernels = (
53 headfile_template=template_prefix
54 + "FusedSpaceTimePredictorVolumeIntegral.template.h",
55 cppfile_template=template_prefix
56 + "FusedSpaceTimePredictorVolumeIntegralLinear.template.cpp",
57 classname=output_path
58 + "/FusedSpaceTimePredictorVolumeIntegral"
59 + d["NAME_SUFFIX"],
60 namespace=namespace,
61 subdirectory=subdirectory + ".",
62 dictionary=d,
63 default_overwrite=True,
64 apply_iteratively=True,
65 )
66 )
67 output.add(generated_kernels)
68 output.makefile.add_h_file(
69 output_path
70 + "/FusedSpaceTimePredictorVolumeIntegral"
71 + d["NAME_SUFFIX"]
72 + ".h",
73 generated=True,
74 )
75 output.makefile.add_cpp_file(
76 output_path
77 + "/FusedSpaceTimePredictorVolumeIntegral"
78 + d["NAME_SUFFIX"]
79 + ".cpp",
80 generated=True,
81 )
82
84 headfile_template=template_prefix
85 + "FusedSpaceTimePredictorVolumeIntegral.template.h",
86 cppfile_template=template_prefix
87 + "FusedSpaceTimePredictorVolumeIntegralLinear.template.cpp"
88 if self.d["IS_LINEAR"]
89 else template_prefix
90 + "FusedSpaceTimePredictorVolumeIntegralNonlinear.template.cpp",
91 classname=output_path + "/FusedSpaceTimePredictorVolumeIntegral",
92 namespace=namespace,
93 subdirectory=subdirectory + ".",
94 dictionary=self.d,
95 default_overwrite=True,
96 apply_iteratively=True,
97 )
98 output.add(generated_kernels)
99 output.makefile.add_h_file(
100 output_path + "/FusedSpaceTimePredictorVolumeIntegral.h", generated=True
101 )
102 output.makefile.add_cpp_file(
103 output_path + "/FusedSpaceTimePredictorVolumeIntegral.cpp", generated=True
104 )
105
106 def _build_gemms(self, namespace, output, subdirectory, template_prefix, output_path):
107 # GEMMS: M, N, K, LDA, LDB, LDC, alpha, beta, Align A, Align C, name, prefetching, type
108 self.d["GEMMS"] = {}
109 nDim = self.d["DIMENSIONS"]
110 nDof = self.d["NUMBER_OF_DOF"]
111 nDof2 = nDof * nDof
112 nDofPad = self.d["NUMBER_OF_DOF_PADDED"]
113 nUnknowns = self.d["NUMBER_OF_UNKNOWNS"]
114 nUnknownsPad = self.d["NUMBER_OF_UNKNOWNS_PADDED"]
115 nData = self.d["NUMBER_OF_DATA"]
116 nDataPad = self.d["NUMBER_OF_DATA_PADDED"]
117
118 if self.d["IS_LINEAR"]:
119 if self.d["USE_FLUX"]:
120 self.d["GEMMS"]["flux_x"] = Gemms(
121 nUnknownsPad,
122 nDof,
123 nDof,
124 nUnknownsPad,
125 nDofPad,
126 nUnknownsPad,
127 1,
128 0,
129 1,
130 1,
131 "flux_x",
132 "nopf",
133 "gemm",
134 self.d["PREDICTOR_COMPUTATION_PRECISIONS"],
135 ) # beta, 0 => overwrite C
136 self.d["GEMMS"]["flux_y"] = Gemms(
137 nUnknownsPad,
138 nDof,
139 nDof,
140 nUnknownsPad * nDof,
141 nDofPad,
142 nUnknownsPad,
143 1,
144 0,
145 1,
146 1,
147 "flux_y",
148 "nopf",
149 "gemm",
150 self.d["PREDICTOR_COMPUTATION_PRECISIONS"],
151 ) # beta, 0 => overwrite C
152 if self.d["DIMENSIONS"] >= 3:
153 self.d["GEMMS"]["flux_z"] = Gemms(
154 nUnknownsPad,
155 nDof,
156 nDof,
157 nUnknownsPad * nDof2,
158 nDofPad,
159 nUnknownsPad,
160 1,
161 0,
162 1,
163 1,
164 "flux_z",
165 "nopf",
166 "gemm",
167 self.d["PREDICTOR_COMPUTATION_PRECISIONS"],
168 ) # beta, 0 => overwrite C
169 if self.d["USE_NCP"]:
170 self.d["GEMMS"]["gradQ_x"] = Gemms(
171 nUnknowns,
172 nDof,
173 nDof,
174 nDataPad,
175 nDofPad,
176 nUnknownsPad,
177 1,
178 1,
179 1,
180 1,
181 "gradQ_x",
182 "nopf",
183 "gemm",
184 self.d["PREDICTOR_COMPUTATION_PRECISIONS"],
185 )
186 self.d["GEMMS"]["gradQ_y"] = Gemms(
187 nUnknowns,
188 nDof,
189 nDof,
190 nDataPad * nDof,
191 nDofPad,
192 nUnknownsPad * nDof,
193 1,
194 1,
195 1,
196 1,
197 "gradQ_y",
198 "nopf",
199 "gemm",
200 self.d["PREDICTOR_COMPUTATION_PRECISIONS"],
201 )
202 if self.d["DIMENSIONS"] >= 3:
203 self.d["GEMMS"]["gradQ_z"] = Gemms(
204 nUnknowns,
205 nDof,
206 nDof,
207 nDataPad * nDof2,
208 nDofPad,
209 nUnknownsPad * nDof2,
210 1,
211 1,
212 1,
213 1,
214 "gradQ_z",
215 "nopf",
216 "gemm",
217 self.d["PREDICTOR_COMPUTATION_PRECISIONS"],
218 )
219 else: # nonlinear
220 if self.d["USE_FLUX"]:
221 self.d["GEMMS"]["rhs_x"] = Gemms(
222 nUnknownsPad,
223 nDof,
224 nDof,
225 nUnknownsPad,
226 nDofPad,
227 nUnknownsPad,
228 1,
229 1,
230 1,
231 1,
232 "rhs_x",
233 "nopf",
234 "gemm",
235 self.d["PREDICTOR_COMPUTATION_PRECISIONS"],
236 )
237 self.d["GEMMS"]["rhs_y"] = Gemms(
238 nUnknownsPad,
239 nDof,
240 nDof,
241 nUnknownsPad * nDof,
242 nDofPad,
243 nUnknownsPad * nDof,
244 1,
245 1,
246 1,
247 1,
248 "rhs_y",
249 "nopf",
250 "gemm",
251 self.d["PREDICTOR_COMPUTATION_PRECISIONS"],
252 )
253 if self.d["DIMENSIONS"] >= 3:
254 self.d["GEMMS"]["rhs_z"] = Gemms(
255 nUnknownsPad,
256 nDof,
257 nDof,
258 nUnknownsPad * nDof2,
259 nDofPad,
260 nUnknownsPad * nDof2,
261 1,
262 1,
263 1,
264 1,
265 "rhs_z",
266 "nopf",
267 "gemm",
268 self.d["PREDICTOR_COMPUTATION_PRECISIONS"],
269 )
270 self.d["GEMMS"]["lduh_x"] = Gemms(
271 nUnknownsPad,
272 nDof,
273 nDof,
274 nUnknownsPad,
275 nDofPad,
276 nData,
277 1,
278 1,
279 1,
280 1,
281 "lduh_x",
282 "nopf",
283 "gemm",
284 self.d["PREDICTOR_COMPUTATION_PRECISIONS"],
285 )
286 self.d["GEMMS"]["lduh_y"] = Gemms(
287 nUnknownsPad,
288 nDof,
289 nDof,
290 nUnknownsPad,
291 nDofPad,
292 nData * nDof,
293 1,
294 1,
295 1,
296 1,
297 "lduh_y",
298 "nopf",
299 "gemm",
300 self.d["PREDICTOR_COMPUTATION_PRECISIONS"],
301 )
302 if self.d["DIMENSIONS"] >= 3:
303 self.d["GEMMS"]["lduh_z"] = Gemms(
304 nUnknownsPad,
305 nDof,
306 nDof,
307 nUnknownsPad,
308 nDofPad,
309 nData * nDof2,
310 1,
311 1,
312 1,
313 1,
314 "lduh_z",
315 "nopf",
316 "gemm",
317 self.d["PREDICTOR_COMPUTATION_PRECISIONS"],
318 )
319 if self.d["USE_NCP"]:
320 self.d["GEMMS"]["gradQ_x"] = Gemms(
321 nUnknowns,
322 nDof,
323 nDof,
324 nDataPad,
325 nDofPad,
326 nUnknownsPad,
327 1,
328 1,
329 1,
330 1,
331 "gradQ_x",
332 "nopf",
333 "gemm",
334 self.d["PREDICTOR_COMPUTATION_PRECISIONS"],
335 )
336 self.d["GEMMS"]["gradQ_y"] = Gemms(
337 nUnknowns,
338 nDof,
339 nDof,
340 nDataPad * nDof,
341 nDofPad,
342 nUnknownsPad * nDof,
343 1,
344 1,
345 1,
346 1,
347 "gradQ_y",
348 "nopf",
349 "gemm",
350 self.d["PREDICTOR_COMPUTATION_PRECISIONS"],
351 )
352 if self.d["DIMENSIONS"] >= 3:
353 self.d["GEMMS"]["gradQ_z"] = Gemms(
354 nUnknowns,
355 nDof,
356 nDof,
357 nDataPad * nDof2,
358 nDofPad,
359 nUnknownsPad * nDof2,
360 1,
361 1,
362 1,
363 1,
364 "gradQ_z",
365 "nopf",
366 "gemm",
367 self.d["PREDICTOR_COMPUTATION_PRECISIONS"],
368 )
369
370 self.d["GEMMS"]["lqi"] = Gemms(
371 nUnknownsPad,
372 nDof,
373 nDof,
374 nUnknownsPad * (nDof**nDim),
375 nDofPad,
376 nUnknownsPad,
377 1,
378 0,
379 1,
380 1,
381 "lqi",
382 "nopf",
383 "gemm",
384 self.d["PREDICTOR_COMPUTATION_PRECISIONS"],
385 ) # beta, 0 => overwrite C
386
387 if self.d["USE_LIBXSMM"]:
388 generate_gemms(
389 output_path=output_path,
390 output_file_name="FusedSpaceTimePredictorVolumeIntegral_libxsmm.c",
391 namespace=namespace,
392 dict=self.d,
393 gemm_config_list=self.d["GEMMS"].values(),
394 )
Specification of a dense matrix-matrix multiplication.
Definition Gemms.py:6