Peano
Loading...
Searching...
No Matches
AMRRoutines.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
10
11class AMRRoutines(object):
12 def __init__(self, dictionary):
13 self.d = deepcopy(dictionary)
14
16 self, namespace, output, subdirectory, template_prefix, output_path
17 ):
18 self._build_gemms(namespace, output, subdirectory, template_prefix, output_path)
19
21 headfile_template=template_prefix + "AMRRoutines.template.h",
22 cppfile_template=template_prefix + "AMRRoutines.template.cpp",
23 classname=output_path + "/AMRRoutines",
24 namespace=namespace,
25 subdirectory=subdirectory + ".",
26 dictionary=self.d,
27 default_overwrite=True,
28 apply_iteratively=True,
29 )
30 output.add(generated_kernels)
31 output.makefile.add_h_file(output_path + "/AMRRoutines.h", generated=True)
32 output.makefile.add_cpp_file(output_path + "/AMRRoutines.cpp", generated=True)
33
34 def _build_gemms(self, namespace, output, subdirectory, template_prefix, output_path):
35 # Define a sequence of GEMMS
36 self.d["GEMMS"] = {}
37 nDim = self.d["DIMENSIONS"]
38 nDof = self.d["NUMBER_OF_DOF"]
39 nDof2 = nDof * nDof
40 nDofPad = self.d["NUMBER_OF_DOF_PADDED"]
41 nUnknownsPad = self.d["NUMBER_OF_UNKNOWNS_PADDED"]
42 nData = self.d["NUMBER_OF_DATA"]
43 nDataPad = self.d["NUMBER_OF_DATA_PADDED"]
44
45 # Always overwrite input (no need to set to 0), except if add.
46 # nDim-1 face projection, inputs are padded.
47 self.d["GEMMS"]["face_Q_x"] = Gemms(
48 nDataPad,
49 nDof,
50 nDof,
51 nDataPad,
52 nDofPad,
53 nDataPad,
54 1,
55 0,
56 1,
57 1,
58 "face_Q_x",
59 "nopf",
60 "gemm",
61 self.d["SOLUTION_STORAGE_PRECISION"]
62 )
63 self.d["GEMMS"]["face_F_x"] = Gemms(
64 nUnknownsPad,
65 nDof,
66 nDof,
67 nUnknownsPad,
68 nDofPad,
69 nUnknownsPad,
70 1,
71 0,
72 1,
73 1,
74 "face_F_x",
75 "nopf",
76 "gemm",
77 self.d["SOLUTION_STORAGE_PRECISION"]
78 )
79 self.d["GEMMS"]["face_F_x_add"] = Gemms(
80 nUnknownsPad,
81 nDof,
82 nDof,
83 nUnknownsPad,
84 nDofPad,
85 nUnknownsPad,
86 1,
87 1,
88 1,
89 1,
90 "face_F_x_add",
91 "nopf",
92 "gemm",
93 self.d["SOLUTION_STORAGE_PRECISION"]
94 )
95 if nDim == 3:
96 self.d["GEMMS"]["face_Q_y"] = Gemms(
97 nDataPad,
98 nDof,
99 nDof,
100 nDataPad * nDof,
101 nDofPad,
102 nDataPad * nDof,
103 1,
104 0,
105 1,
106 1,
107 "face_Q_y",
108 "nopf",
109 "gemm",
110 self.d["SOLUTION_STORAGE_PRECISION"]
111 )
112 self.d["GEMMS"]["face_F_y"] = Gemms(
113 nUnknownsPad,
114 nDof,
115 nDof,
116 nUnknownsPad * nDof,
117 nDofPad,
118 nUnknownsPad * nDof,
119 1,
120 0,
121 1,
122 1,
123 "face_F_y",
124 "nopf",
125 "gemm",
126 self.d["SOLUTION_STORAGE_PRECISION"]
127 )
128 self.d["GEMMS"]["face_F_y_add"] = Gemms(
129 nUnknownsPad,
130 nDof,
131 nDof,
132 nUnknownsPad * nDof,
133 nDofPad,
134 nUnknownsPad * nDof,
135 1,
136 1,
137 1,
138 1,
139 "face_F_y_add",
140 "nopf",
141 "gemm",
142 self.d["SOLUTION_STORAGE_PRECISION"]
143 )
144
145 self.d["GEMMS"]["volume_x"] = Gemms(
146 nData,
147 nDof,
148 nDof,
149 nData,
150 nDofPad,
151 nDataPad,
152 1,
153 0,
154 0,
155 # 1,
156 1,
157 "volume_x",
158 "nopf",
159 "gemm",
160 self.d["SOLUTION_STORAGE_PRECISION"]
161 )
162
163 if nDim == 3:
164 self.d["GEMMS"]["volume_y"] = Gemms(nDataPad, nDof, nDof, nDataPad*nDof , nDofPad, nDataPad*nDof, 1, 0, 1,
165 # 1,
166 1, "volume_y",
167 "nopf",
168 "gemm",
169 self.d["SOLUTION_STORAGE_PRECISION"])
170 self.d["GEMMS"]["volume_z"] = Gemms(nData , nDof, nDof, nDataPad*nDof2, nDofPad, nData*nDof2 , 1, 0, 1,
171 # 1,
172 0, "volume_z",
173 "nopf",
174 "gemm",
175 self.d["SOLUTION_STORAGE_PRECISION"])
176 self.d["GEMMS"]["volume_z_add"] = Gemms(nData, nDof, nDof, nDataPad*nDof2, nDofPad, nData*nDof2 , 1, 1, 1,
177 # 1,
178 0, "volume_z_add",
179 "nopf",
180 "gemm",
181 self.d["SOLUTION_STORAGE_PRECISION"])
182 else:
183 self.d["GEMMS"]["volume_y"] = Gemms(nData , nDof, nDof, nDataPad*nDof , nDofPad, nData*nDof , 1, 0, 1,
184 # 1,
185 0, "volume_y",
186 "nopf",
187 "gemm",
188 self.d["SOLUTION_STORAGE_PRECISION"])
189 self.d["GEMMS"]["volume_y_add"] = Gemms(nData, nDof, nDof, nDataPad*nDof , nDofPad, nData*nDof , 1, 1, 1,
190 # 1,
191 0, "volume_y_add",
192 "nopf",
193 "gemm",
194 self.d["SOLUTION_STORAGE_PRECISION"])
195
196 if self.d["USE_LIBXSMM"]:
197 generate_gemms(
198 output_path=output_path,
199 output_file_name="AMRRoutines_libxsmm.c",
200 namespace=namespace,
201 dict=self.d,
202 gemm_config_list=self.d["GEMMS"].values(),
203 )
generate_kernels(self, namespace, output, subdirectory, template_prefix, output_path)
_build_gemms(self, namespace, output, subdirectory, template_prefix, output_path)
Specification of a dense matrix-matrix multiplication.
Definition Gemms.py:6