46 template_parameters = [DSL.SyntaxTree.Argument(
"NumberOfVolumesPerAxisInPatch", DSL.SyntaxTree.TInteger()),
47 DSL.SyntaxTree.Argument(
"HaloSize", DSL.SyntaxTree.TInteger()),
48 DSL.SyntaxTree.Argument(
"NumberOfUnknowns", DSL.SyntaxTree.TInteger()),
49 DSL.SyntaxTree.Argument(
"NumberOfAuxiliaryVariables", DSL.SyntaxTree.TInteger()),
50 DSL.SyntaxTree.Argument(
"EvaluateFlux", DSL.SyntaxTree.TBoolean()),
51 DSL.SyntaxTree.Argument(
"EvaluateNonconservativeProduct", DSL.SyntaxTree.TBoolean()),
52 DSL.SyntaxTree.Argument(
"EvaluateSource", DSL.SyntaxTree.TBoolean()),
53 DSL.SyntaxTree.Argument(
"EvaluateMaximumEigenvalueAfterTimeStep", DSL.SyntaxTree.TBoolean())]
55 functor_arguments = [DSL.SyntaxTree.Argument(
"flux", DSL.SyntaxTree.TCustom(
"const FluxFunctor&")),
56 DSL.SyntaxTree.Argument(
"nonconservativeProduct", DSL.SyntaxTree.TCustom(
"const NonconservativeProductFunctor&")),
57 DSL.SyntaxTree.Argument(
"sourceTerm", DSL.SyntaxTree.TCustom(
"const SourceFunctor&")),
58 DSL.SyntaxTree.Argument(
"maxEigenvalue", DSL.SyntaxTree.TCustom(
"const MaxEigenvalueFunctor&"))]
60 rusanov_tree = DSL.Parser().parse(exahype2.solvers.fv.rusanov.timeStepWithRusanov2d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"rusanov"])
61 rusanov_kernel = rusanov_tree.print_cpp()
62 rusanov_call_with_measurement = rusanov_tree.print_definition_with_timer()
63 rusanov_kernel_declaration = rusanov_tree.print_declaration()
64 rusanov_call_with_measurement_declaration = rusanov_tree.print_declaration_with_timer()
66 rusanov_stateless_tree = DSL.Parser().parse(exahype2.solvers.fv.rusanov.timeStepWithRusanov2d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"rusanov"], stateless=
True)
67 rusanov_stateless_kernel = rusanov_stateless_tree.print_cpp()
68 rusanov_stateless_call_with_measurement = rusanov_stateless_tree.print_definition_with_timer()
69 rusanov_stateless_kernel_declaration = rusanov_stateless_tree.print_declaration()
70 rusanov_stateless_call_with_measurement_declaration = rusanov_stateless_tree.print_declaration_with_timer()
78 rusanov_omp_tree = DSL.Parser().parse(exahype2.solvers.fv.rusanov.timeStepWithRusanov2d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"rusanov",
"omp"])
79 rusanov_omp_kernel = rusanov_omp_tree.print_omp()
80 rusanov_omp_call_with_measurement = rusanov_omp_tree.print_definition_with_timer()
81 rusanov_omp_kernel_declaration = rusanov_omp_tree.print_declaration()
82 rusanov_omp_call_with_measurement_declaration = rusanov_omp_tree.print_declaration_with_timer()
84 rusanov_omp_stateless_tree = DSL.Parser().parse(exahype2.solvers.fv.rusanov.timeStepWithRusanov2d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"rusanov",
"omp"], stateless=
True)
85 rusanov_omp_stateless_kernel = rusanov_omp_stateless_tree.print_omp()
86 rusanov_omp_stateless_call_with_measurement = rusanov_omp_stateless_tree.print_definition_with_timer()
87 rusanov_omp_stateless_kernel_declaration = rusanov_omp_stateless_tree.print_declaration()
88 rusanov_omp_stateless_call_with_measurement_declaration = rusanov_omp_stateless_tree.print_declaration_with_timer()
90 rusanov_omp_accelerator_tree = DSL.Parser().parse(exahype2.solvers.fv.rusanov.timeStepWithRusanov2d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"rusanov",
"omp"], stateless=
True, use_accelerator=
True)
91 rusanov_omp_accelerator_kernel = rusanov_omp_accelerator_tree.print_omp()
92 rusanov_omp_accelerator_call_with_measurement = rusanov_omp_accelerator_tree.print_definition_with_timer()
93 rusanov_omp_accelerator_kernel_declaration = rusanov_omp_accelerator_tree.print_declaration()
94 rusanov_omp_accelerator_call_with_measurement_declaration = rusanov_omp_accelerator_tree.print_declaration_with_timer()
96 rusanov_sycl_accelerator_tree = DSL.Parser().parse(exahype2.solvers.fv.rusanov.timeStepWithRusanov2d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"rusanov",
"sycl"], stateless=
True, use_accelerator=
True)
97 rusanov_sycl_accelerator_kernel = rusanov_sycl_accelerator_tree.print_sycl()
98 rusanov_sycl_accelerator_call_with_measurement = rusanov_sycl_accelerator_tree.print_definition_with_timer()
99 rusanov_sycl_accelerator_kernel_declaration = rusanov_sycl_accelerator_tree.print_declaration()
100 rusanov_sycl_accelerator_call_with_measurement_declaration = rusanov_sycl_accelerator_tree.print_declaration_with_timer()
102 if not os.path.exists(
"kernels"):
103 os.makedirs(
"kernels")
105 file = open(
"kernels/rusanov2d.h",
"w")
106 file.write(f
"""#pragma once
107#include "exahype2/CellData.h"
108#include "exahype2/VolumeIndex.h"
109#include "exahype2/fv/PatchUtils.h"
110#include "exahype2/fv/rusanov/Functors.h"
111#include "peano4/utils/Loop.h"
112#include "tarch/timing/Measurement.h"
113#include "tarch/timing/Watch.h"
116{rusanov_kernel_declaration}
117{rusanov_call_with_measurement_declaration}
119{rusanov_stateless_kernel_declaration}
120{rusanov_stateless_call_with_measurement_declaration}
122#if defined(SharedOMP)
123{rusanov_omp_kernel_declaration}
124{rusanov_omp_call_with_measurement_declaration}
125{rusanov_omp_stateless_kernel_declaration}
126{rusanov_omp_stateless_call_with_measurement_declaration}
129#if defined(GPUOffloadingOMP)
130{rusanov_omp_accelerator_kernel_declaration}
131{rusanov_omp_accelerator_call_with_measurement_declaration}
134#if defined(GPUOffloadingSYCL)
135{rusanov_sycl_accelerator_kernel_declaration}
136{rusanov_sycl_accelerator_call_with_measurement_declaration}
139#include "rusanov2d.cpph"
143 file = open(
"kernels/rusanov2d.cpph",
"w")
144 file.write(rusanov_kernel)
145 file.write(rusanov_call_with_measurement)
146 file.write(rusanov_stateless_kernel)
147 file.write(rusanov_stateless_call_with_measurement)
149 file.write(
"#if defined(SharedOMP)\n")
150 file.write(rusanov_omp_kernel)
151 file.write(rusanov_omp_call_with_measurement)
152 file.write(rusanov_omp_stateless_kernel)
153 file.write(rusanov_omp_stateless_call_with_measurement)
154 file.write(
"#endif\n")
156 file.write(
"#if defined(GPUOffloadingOMP)\n")
157 file.write(rusanov_omp_accelerator_kernel)
158 file.write(rusanov_omp_accelerator_call_with_measurement)
159 file.write(
"#endif\n")
161 file.write(
"#if defined(GPUOffloadingSYCL)\n")
162 file.write(rusanov_sycl_accelerator_kernel)
163 file.write(rusanov_sycl_accelerator_call_with_measurement)
164 file.write(
"#endif\n")
168 template_parameters = [DSL.SyntaxTree.Argument(
"NumberOfVolumesPerAxisInPatch", DSL.SyntaxTree.TInteger()),
169 DSL.SyntaxTree.Argument(
"HaloSize", DSL.SyntaxTree.TInteger()),
170 DSL.SyntaxTree.Argument(
"NumberOfUnknowns", DSL.SyntaxTree.TInteger()),
171 DSL.SyntaxTree.Argument(
"NumberOfAuxiliaryVariables", DSL.SyntaxTree.TInteger()),
172 DSL.SyntaxTree.Argument(
"EvaluateFlux", DSL.SyntaxTree.TBoolean()),
173 DSL.SyntaxTree.Argument(
"EvaluateNonconservativeProduct", DSL.SyntaxTree.TBoolean()),
174 DSL.SyntaxTree.Argument(
"EvaluateSource", DSL.SyntaxTree.TBoolean()),
175 DSL.SyntaxTree.Argument(
"EvaluateMaximumEigenvalueAfterTimeStep", DSL.SyntaxTree.TBoolean())]
177 functor_arguments = [DSL.SyntaxTree.Argument(
"flux", DSL.SyntaxTree.TCustom(
"const FluxFunctor&")),
178 DSL.SyntaxTree.Argument(
"nonconservativeProduct", DSL.SyntaxTree.TCustom(
"const NonconservativeProductFunctor&")),
179 DSL.SyntaxTree.Argument(
"sourceTerm", DSL.SyntaxTree.TCustom(
"const SourceFunctor&")),
180 DSL.SyntaxTree.Argument(
"maxEigenvalue", DSL.SyntaxTree.TCustom(
"const MaxEigenvalueFunctor&"))]
182 rusanov_tree = DSL.Parser().parse(exahype2.solvers.fv.rusanov.timeStepWithRusanov3d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"rusanov"])
183 rusanov_kernel = rusanov_tree.print_cpp()
184 rusanov_call_with_measurement = rusanov_tree.print_definition_with_timer()
185 rusanov_kernel_declaration = rusanov_tree.print_declaration()
186 rusanov_call_with_measurement_declaration = rusanov_tree.print_declaration_with_timer()
188 rusanov_stateless_tree = DSL.Parser().parse(exahype2.solvers.fv.rusanov.timeStepWithRusanov3d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"rusanov"], stateless=
True)
189 rusanov_stateless_kernel = rusanov_stateless_tree.print_cpp()
190 rusanov_stateless_call_with_measurement = rusanov_stateless_tree.print_definition_with_timer()
191 rusanov_stateless_kernel_declaration = rusanov_stateless_tree.print_declaration()
192 rusanov_stateless_call_with_measurement_declaration = rusanov_stateless_tree.print_declaration_with_timer()
194 rusanov_accelerator_kernel = DSL.Parser().parse(exahype2.solvers.fv.rusanov.timeStepWithRusanov3d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"rusanov"],
True,
True).print_cpp()
195 rusanov_accelerator_call_with_measurement = DSL.Parser().parse(exahype2.solvers.fv.rusanov.timeStepWithRusanov3d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"rusanov"],
True,
True).print_definition_with_timer()
196 rusanov_accelerator_kernel_declaration = DSL.Parser().parse(exahype2.solvers.fv.rusanov.timeStepWithRusanov3d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"rusanov"],
True,
True).print_declaration()
197 rusanov_accelerator_call_with_measurement_declaration = DSL.Parser().parse(exahype2.solvers.fv.rusanov.timeStepWithRusanov3d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"rusanov"],
True,
True).print_declaration_with_timer()
199 rusanov_omp_tree = DSL.Parser().parse(exahype2.solvers.fv.rusanov.timeStepWithRusanov3d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"rusanov",
"omp"])
200 rusanov_omp_kernel = rusanov_omp_tree.print_omp()
201 rusanov_omp_call_with_measurement = rusanov_omp_tree.print_definition_with_timer()
202 rusanov_omp_kernel_declaration = rusanov_omp_tree.print_declaration()
203 rusanov_omp_call_with_measurement_declaration = rusanov_omp_tree.print_declaration_with_timer()
205 rusanov_omp_stateless_tree = DSL.Parser().parse(exahype2.solvers.fv.rusanov.timeStepWithRusanov3d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"rusanov",
"omp"], stateless=
True)
206 rusanov_omp_stateless_kernel = rusanov_omp_stateless_tree.print_omp()
207 rusanov_omp_stateless_call_with_measurement = rusanov_omp_stateless_tree.print_definition_with_timer()
208 rusanov_omp_stateless_kernel_declaration = rusanov_omp_stateless_tree.print_declaration()
209 rusanov_omp_stateless_call_with_measurement_declaration = rusanov_omp_stateless_tree.print_declaration_with_timer()
211 rusanov_omp_accelerator_tree = DSL.Parser().parse(exahype2.solvers.fv.rusanov.timeStepWithRusanov3d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"rusanov",
"omp"], stateless=
True, use_accelerator=
True)
212 rusanov_omp_accelerator_kernel = rusanov_omp_accelerator_tree.print_omp()
213 rusanov_omp_accelerator_call_with_measurement = rusanov_omp_accelerator_tree.print_definition_with_timer()
214 rusanov_omp_accelerator_kernel_declaration = rusanov_omp_accelerator_tree.print_declaration()
215 rusanov_omp_accelerator_call_with_measurement_declaration = rusanov_omp_accelerator_tree.print_declaration_with_timer()
217 rusanov_sycl_accelerator_tree = DSL.Parser().parse(exahype2.solvers.fv.rusanov.timeStepWithRusanov3d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"rusanov",
"sycl"], stateless=
True, use_accelerator=
True)
218 rusanov_sycl_accelerator_kernel = rusanov_sycl_accelerator_tree.print_sycl()
219 rusanov_sycl_accelerator_call_with_measurement = rusanov_sycl_accelerator_tree.print_definition_with_timer()
220 rusanov_sycl_accelerator_kernel_declaration = rusanov_sycl_accelerator_tree.print_declaration()
221 rusanov_sycl_accelerator_call_with_measurement_declaration = rusanov_sycl_accelerator_tree.print_declaration_with_timer()
223 if not os.path.exists(
"kernels"):
224 os.makedirs(
"kernels")
226 file = open(
"kernels/rusanov3d.h",
"w")
227 file.write(f
"""#pragma once
228#include "exahype2/CellData.h"
229#include "exahype2/VolumeIndex.h"
230#include "exahype2/fv/PatchUtils.h"
231#include "exahype2/fv/rusanov/Functors.h"
232#include "peano4/utils/Loop.h"
233#include "tarch/timing/Measurement.h"
234#include "tarch/timing/Watch.h"
237{rusanov_kernel_declaration}
238{rusanov_call_with_measurement_declaration}
239{rusanov_stateless_kernel_declaration}
240{rusanov_stateless_call_with_measurement_declaration}
241{rusanov_accelerator_kernel_declaration}
242{rusanov_accelerator_call_with_measurement_declaration}
244#if defined(SharedOMP)
245{rusanov_omp_kernel_declaration}
246{rusanov_omp_call_with_measurement_declaration}
247{rusanov_omp_stateless_kernel_declaration}
248{rusanov_omp_stateless_call_with_measurement_declaration}
251#if defined(GPUOffloadingOMP)
252{rusanov_omp_accelerator_kernel_declaration}
253{rusanov_omp_accelerator_call_with_measurement_declaration}
256#if defined(GPUOffloadingSYCL)
257{rusanov_sycl_accelerator_kernel_declaration}
258{rusanov_sycl_accelerator_call_with_measurement_declaration}
261#include "rusanov3d.cpph"
265 file = open(
"kernels/rusanov3d.cpph",
"w")
266 file.write(rusanov_kernel)
267 file.write(rusanov_call_with_measurement)
268 file.write(rusanov_stateless_kernel)
269 file.write(rusanov_stateless_call_with_measurement)
270 file.write(rusanov_accelerator_kernel)
271 file.write(rusanov_accelerator_call_with_measurement)
273 file.write(
"#if defined(SharedOMP)\n")
274 file.write(rusanov_omp_kernel)
275 file.write(rusanov_omp_call_with_measurement)
276 file.write(rusanov_omp_stateless_kernel)
277 file.write(rusanov_omp_stateless_call_with_measurement)
278 file.write(
"#endif\n")
280 file.write(
"#if defined(GPUOffloadingOMP)\n")
281 file.write(rusanov_omp_accelerator_kernel)
282 file.write(rusanov_omp_accelerator_call_with_measurement)
283 file.write(
"#endif\n")
285 file.write(
"#if defined(GPUOffloadingSYCL)\n")
286 file.write(rusanov_sycl_accelerator_kernel)
287 file.write(rusanov_sycl_accelerator_call_with_measurement)
288 file.write(
"#endif\n")