72 template_parameters = [DSL.SyntaxTree.Argument(
"NV", DSL.SyntaxTree.TInteger()),
73 DSL.SyntaxTree.Argument(
"H", DSL.SyntaxTree.TInteger()),
74 DSL.SyntaxTree.Argument(
"NumberOfUnknowns", DSL.SyntaxTree.TInteger()),
75 DSL.SyntaxTree.Argument(
"NumberOfAuxiliaryVariables", DSL.SyntaxTree.TInteger()),
76 DSL.SyntaxTree.Argument(
"EvaluateFlux", DSL.SyntaxTree.TBoolean()),
77 DSL.SyntaxTree.Argument(
"EvaluateNonconservativeProduct", DSL.SyntaxTree.TBoolean()),
78 DSL.SyntaxTree.Argument(
"EvaluateSource", DSL.SyntaxTree.TBoolean()),
79 DSL.SyntaxTree.Argument(
"EvaluateMaximumEigenvalueAfterTimeStep", DSL.SyntaxTree.TBoolean())]
81 functor_arguments = [DSL.SyntaxTree.Argument(
"flux", DSL.SyntaxTree.TCustom(
"const FluxFunctor&")),
82 DSL.SyntaxTree.Argument(
"nonconservativeProduct", DSL.SyntaxTree.TCustom(
"const NonconservativeProductFunctor&")),
83 DSL.SyntaxTree.Argument(
"sourceTerm", DSL.SyntaxTree.TCustom(
"const SourceFunctor&")),
84 DSL.SyntaxTree.Argument(
"maxEigenvalue", DSL.SyntaxTree.TCustom(
"const MaxEigenvalueFunctor&"))]
86 musclhancock_kernel_tree = DSL.Parser().parse(exahype2.solvers.fv.musclhancock.timeStepWithMUSCLHancock2d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"musclhancock"], stateless=
False)
87 musclhancock_kernel = musclhancock_kernel_tree.print_cpp()
88 musclhancock_call_with_measurement = musclhancock_kernel_tree.print_definition_with_timer()
89 musclhancock_kernel_declaration = musclhancock_kernel_tree.print_declaration()
90 musclhancock_call_with_measurement_declaration = musclhancock_kernel_tree.print_declaration_with_timer()
92 musclhancock_stateless_kernel_tree = DSL.Parser().parse(exahype2.solvers.fv.musclhancock.timeStepWithMUSCLHancock2d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"musclhancock"], stateless=
True)
93 musclhancock_stateless_kernel = musclhancock_stateless_kernel_tree.print_cpp()
94 musclhancock_stateless_call_with_measurement = musclhancock_stateless_kernel_tree.print_definition_with_timer()
95 musclhancock_stateless_kernel_declaration = musclhancock_stateless_kernel_tree.print_declaration()
96 musclhancock_stateless_call_with_measurement_declaration = musclhancock_stateless_kernel_tree.print_declaration_with_timer()
98 musclhancock_omp_kernel_tree = DSL.Parser().parse(exahype2.solvers.fv.musclhancock.timeStepWithMUSCLHancock2d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"musclhancock",
"omp"], stateless=
False)
99 musclhancock_omp_kernel = musclhancock_omp_kernel_tree.print_omp()
100 musclhancock_omp_call_with_measurement = musclhancock_omp_kernel_tree.print_definition_with_timer()
101 musclhancock_omp_kernel_declaration = musclhancock_omp_kernel_tree.print_declaration()
102 musclhancock_omp_call_with_measurement_declaration = musclhancock_omp_kernel_tree.print_declaration_with_timer()
104 musclhancock_omp_stateless_kernel_tree = DSL.Parser().parse(exahype2.solvers.fv.musclhancock.timeStepWithMUSCLHancock2d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"musclhancock",
"omp"], stateless=
True)
105 musclhancock_omp_stateless_kernel = musclhancock_omp_stateless_kernel_tree.print_omp()
106 musclhancock_omp_stateless_call_with_measurement = musclhancock_omp_stateless_kernel_tree.print_definition_with_timer()
107 musclhancock_omp_stateless_kernel_declaration = musclhancock_omp_stateless_kernel_tree.print_declaration()
108 musclhancock_omp_stateless_call_with_measurement_declaration = musclhancock_omp_stateless_kernel_tree.print_declaration_with_timer()
110 musclhancock_omp_accelerator_kernel_tree = DSL.Parser().parse(exahype2.solvers.fv.musclhancock.timeStepWithMUSCLHancock2d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"musclhancock",
"omp"], stateless=
True, use_accelerator=
True)
111 musclhancock_omp_accelerator_kernel = musclhancock_omp_accelerator_kernel_tree.print_omp()
112 musclhancock_omp_accelerator_call_with_measurement = musclhancock_omp_accelerator_kernel_tree.print_definition_with_timer()
113 musclhancock_omp_accelerator_kernel_declaration = musclhancock_omp_accelerator_kernel_tree.print_declaration()
114 musclhancock_omp_accelerator_call_with_measurement_declaration = musclhancock_omp_accelerator_kernel_tree.print_declaration_with_timer()
116 if not os.path.exists(
"kernels"):
117 os.makedirs(
"kernels")
119 file = open(
"kernels/musclhancock2d.h",
"w")
120 file.write(f
"""#pragma once
121#include "exahype2/CellData.h"
122#include "exahype2/VolumeIndex.h"
123#include "exahype2/fv/PatchUtils.h"
124#include "exahype2/fv/musclhancock/Functors.h"
125#include "peano4/utils/Loop.h"
126#include "tarch/timing/Measurement.h"
127#include "tarch/timing/Watch.h"
129{musclhancock_kernel_declaration}
130{musclhancock_call_with_measurement_declaration}
132{musclhancock_stateless_kernel_declaration}
133{musclhancock_stateless_call_with_measurement_declaration}
135#if defined(SharedOMP)
136{musclhancock_omp_kernel_declaration}
137{musclhancock_omp_call_with_measurement_declaration}
138{musclhancock_omp_stateless_kernel_declaration}
139{musclhancock_omp_stateless_call_with_measurement_declaration}
142#if defined(GPUOffloadingOMP)
143{musclhancock_omp_accelerator_kernel_declaration}
144{musclhancock_omp_accelerator_call_with_measurement_declaration}
147#include "musclhancock2d.cpph"
151 file = open(
"kernels/musclhancock2d.cpph",
"w")
152 file.write(musclhancock_kernel)
153 file.write(musclhancock_call_with_measurement)
154 file.write(musclhancock_stateless_kernel)
155 file.write(musclhancock_stateless_call_with_measurement)
157 file.write(
"#if defined(SharedOMP)\n")
158 file.write(musclhancock_omp_kernel)
159 file.write(musclhancock_omp_call_with_measurement)
160 file.write(musclhancock_omp_stateless_kernel)
161 file.write(musclhancock_omp_stateless_call_with_measurement)
162 file.write(
"#endif\n")
164 file.write(
"#if defined(GPUOffloadingOMP)\n")
165 file.write(musclhancock_omp_accelerator_kernel)
166 file.write(musclhancock_omp_accelerator_call_with_measurement)
167 file.write(
"#endif\n")
171 template_parameters = [DSL.SyntaxTree.Argument(
"NV", DSL.SyntaxTree.TInteger()),
172 DSL.SyntaxTree.Argument(
"H", DSL.SyntaxTree.TInteger()),
173 DSL.SyntaxTree.Argument(
"NumberOfUnknowns", DSL.SyntaxTree.TInteger()),
174 DSL.SyntaxTree.Argument(
"NumberOfAuxiliaryVariables", DSL.SyntaxTree.TInteger()),
175 DSL.SyntaxTree.Argument(
"EvaluateFlux", DSL.SyntaxTree.TBoolean()),
176 DSL.SyntaxTree.Argument(
"EvaluateNonconservativeProduct", DSL.SyntaxTree.TBoolean()),
177 DSL.SyntaxTree.Argument(
"EvaluateSource", DSL.SyntaxTree.TBoolean()),
178 DSL.SyntaxTree.Argument(
"EvaluateMaximumEigenvalueAfterTimeStep", DSL.SyntaxTree.TBoolean())]
180 functor_arguments = [DSL.SyntaxTree.Argument(
"flux", DSL.SyntaxTree.TCustom(
"const FluxFunctor&")),
181 DSL.SyntaxTree.Argument(
"nonconservativeProduct", DSL.SyntaxTree.TCustom(
"const NonconservativeProductFunctor&")),
182 DSL.SyntaxTree.Argument(
"sourceTerm", DSL.SyntaxTree.TCustom(
"const SourceFunctor&")),
183 DSL.SyntaxTree.Argument(
"maxEigenvalue", DSL.SyntaxTree.TCustom(
"const MaxEigenvalueFunctor&"))]
185 musclhancock_kernel_tree = DSL.Parser().parse(exahype2.solvers.fv.musclhancock.timeStepWithMUSCLHancock3d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"musclhancock"], stateless=
False)
186 musclhancock_kernel = musclhancock_kernel_tree.print_cpp()
187 musclhancock_call_with_measurement = musclhancock_kernel_tree.print_definition_with_timer()
188 musclhancock_kernel_declaration = musclhancock_kernel_tree.print_declaration()
189 musclhancock_call_with_measurement_declaration = musclhancock_kernel_tree.print_declaration_with_timer()
191 musclhancock_stateless_kernel_tree = DSL.Parser().parse(exahype2.solvers.fv.musclhancock.timeStepWithMUSCLHancock3d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"musclhancock"], stateless=
True)
192 musclhancock_stateless_kernel = musclhancock_stateless_kernel_tree.print_cpp()
193 musclhancock_stateless_call_with_measurement = musclhancock_stateless_kernel_tree.print_definition_with_timer()
194 musclhancock_stateless_kernel_declaration = musclhancock_stateless_kernel_tree.print_declaration()
195 musclhancock_stateless_call_with_measurement_declaration = musclhancock_stateless_kernel_tree.print_declaration_with_timer()
197 musclhancock_omp_kernel_tree = DSL.Parser().parse(exahype2.solvers.fv.musclhancock.timeStepWithMUSCLHancock3d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"musclhancock",
"omp"], stateless=
False)
198 musclhancock_omp_kernel = musclhancock_omp_kernel_tree.print_omp()
199 musclhancock_omp_call_with_measurement = musclhancock_omp_kernel_tree.print_definition_with_timer()
200 musclhancock_omp_kernel_declaration = musclhancock_omp_kernel_tree.print_declaration()
201 musclhancock_omp_call_with_measurement_declaration = musclhancock_omp_kernel_tree.print_declaration_with_timer()
203 musclhancock_omp_stateless_kernel_tree = DSL.Parser().parse(exahype2.solvers.fv.musclhancock.timeStepWithMUSCLHancock3d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"musclhancock",
"omp"], stateless=
True)
204 musclhancock_omp_stateless_kernel = musclhancock_omp_stateless_kernel_tree.print_omp()
205 musclhancock_omp_stateless_call_with_measurement = musclhancock_omp_stateless_kernel_tree.print_definition_with_timer()
206 musclhancock_omp_stateless_kernel_declaration = musclhancock_omp_stateless_kernel_tree.print_declaration()
207 musclhancock_omp_stateless_call_with_measurement_declaration = musclhancock_omp_stateless_kernel_tree.print_declaration_with_timer()
209 musclhancock_omp_accelerator_kernel_tree = DSL.Parser().parse(exahype2.solvers.fv.musclhancock.timeStepWithMUSCLHancock3d, template_parameters, functor_arguments, [
"exahype2",
"fv",
"musclhancock",
"omp"], stateless=
True, use_accelerator=
True)
210 musclhancock_omp_accelerator_kernel = musclhancock_omp_accelerator_kernel_tree.print_omp()
211 musclhancock_omp_accelerator_call_with_measurement = musclhancock_omp_accelerator_kernel_tree.print_definition_with_timer()
212 musclhancock_omp_accelerator_kernel_declaration = musclhancock_omp_accelerator_kernel_tree.print_declaration()
213 musclhancock_omp_accelerator_call_with_measurement_declaration = musclhancock_omp_accelerator_kernel_tree.print_declaration_with_timer()
215 if not os.path.exists(
"kernels"):
216 os.makedirs(
"kernels")
218 file = open(
"kernels/musclhancock3d.h",
"w")
219 file.write(f
"""#pragma once
220#include "exahype2/CellData.h"
221#include "exahype2/VolumeIndex.h"
222#include "exahype2/fv/PatchUtils.h"
223#include "exahype2/fv/musclhancock/Functors.h"
224#include "peano4/utils/Loop.h"
225#include "tarch/timing/Measurement.h"
226#include "tarch/timing/Watch.h"
228{musclhancock_kernel_declaration}
229{musclhancock_call_with_measurement_declaration}
231{musclhancock_stateless_kernel_declaration}
232{musclhancock_stateless_call_with_measurement_declaration}
234#if defined(SharedOMP)
235{musclhancock_omp_kernel_declaration}
236{musclhancock_omp_call_with_measurement_declaration}
237{musclhancock_omp_stateless_kernel_declaration}
238{musclhancock_omp_stateless_call_with_measurement_declaration}
241#if defined(GPUOffloadingOMP)
242{musclhancock_omp_accelerator_kernel_declaration}
243{musclhancock_omp_accelerator_call_with_measurement_declaration}
246#include "musclhancock3d.cpph"
250 file = open(
"kernels/musclhancock3d.cpph",
"w")
251 file.write(musclhancock_kernel)
252 file.write(musclhancock_call_with_measurement)
253 file.write(musclhancock_stateless_kernel)
254 file.write(musclhancock_stateless_call_with_measurement)
256 file.write(
"#if defined(SharedOMP)\n")
257 file.write(musclhancock_omp_kernel)
258 file.write(musclhancock_omp_call_with_measurement)
259 file.write(musclhancock_omp_stateless_kernel)
260 file.write(musclhancock_omp_stateless_call_with_measurement)
261 file.write(
"#endif\n")
263 file.write(
"#if defined(GPUOffloadingOMP)\n")
264 file.write(musclhancock_omp_accelerator_kernel)
265 file.write(musclhancock_omp_accelerator_call_with_measurement)
266 file.write(
"#endif\n")
269def create_compute_Riemann_kernel_for_MUSCLHancock_dsl(flux_implementation,
271 source_implementation,
272 compute_max_eigenvalue_of_next_time_step,
273 solver_variant: SolverVariant,
274 kernel_variant: KernelVariant):
276 Return only the unqualified function call, i.e., without any namespaces.
277 So by setting the right namespace as prefix, you can direct it to particular
281 template =
"timeStepWithMUSCLHancock"
283 if solver_variant == SolverVariant.WithVirtualFunctions:
285 {{NUMBER_OF_VOLUMES_PER_AXIS}},
287 {{NUMBER_OF_UNKNOWNS}},
288 {{NUMBER_OF_AUXILIARY_VARIABLES}},
289 {% if FLUX_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
290 {% if NCP_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
291 {% if SOURCE_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
292 {% if COMPUTE_MAX_EIGENVALUE==False %} false {% else %} true {% endif %}
295 [[maybe_unused]] const double* __restrict__ Q, // Q[{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}}]
296 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& faceCentre,
297 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& volumeH,
298 [[maybe_unused]] double t,
299 [[maybe_unused]] double dt,
300 [[maybe_unused]] int normal,
301 [[maybe_unused]] double* __restrict__ F // F[{{NUMBER_OF_UNKNOWNS}}]
303 {% if FLUX_IMPLEMENTATION!="<none>" %}
304 repositories::{{SOLVER_INSTANCE}}.flux(Q, faceCentre, volumeH, t, dt, normal, F);
308 [[maybe_unused]] const double* __restrict__ Q, // Q[{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}}]
309 [[maybe_unused]] const double* __restrict__ deltaQ, // deltaQ[{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}}]
310 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& faceCentre,
311 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& volumeH,
312 [[maybe_unused]] double t,
313 [[maybe_unused]] double dt,
314 [[maybe_unused]] int normal,
315 [[maybe_unused]] double* __restrict__ BTimesDeltaQ // BTimesDeltaQ[{{NUMBER_OF_UNKNOWNS}}]
317 {% if NCP_IMPLEMENTATION!="<none>" %}
318 repositories::{{SOLVER_INSTANCE}}.nonconservativeProduct(Q, deltaQ, faceCentre, volumeH, t, dt, normal, BTimesDeltaQ);
322 [[maybe_unused]] const double* __restrict__ Q, // Q[{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}}]
323 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& volumeX,
324 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& volumeH,
325 [[maybe_unused]] double t,
326 [[maybe_unused]] double dt,
327 [[maybe_unused]] double* __restrict__ S // S[{{NUMBER_OF_UNKNOWNS}}]
329 {% if SOURCE_IMPLEMENTATION!="<none>" %}
330 repositories::{{SOLVER_INSTANCE}}.sourceTerm(Q, volumeX, volumeH, t, dt, S);
334 [[maybe_unused]] const double* __restrict__ Q, // Q[{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}}]
335 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& faceCentre,
336 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& volumeH,
337 [[maybe_unused]] double t,
338 [[maybe_unused]] double dt,
339 [[maybe_unused]] int normal,
340 [[maybe_unused]] double* __restrict__ maxEigenvalue
342 repositories::{{SOLVER_INSTANCE}}.maxEigenvalue(Q, faceCentre, volumeH, t, dt, normal, maxEigenvalue);
346 elif solver_variant == SolverVariant.Stateless:
347 template +=
"""Stateless<
349 {{NUMBER_OF_VOLUMES_PER_AXIS}},
351 {{NUMBER_OF_UNKNOWNS}},
352 {{NUMBER_OF_AUXILIARY_VARIABLES}},
353 {% if FLUX_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
354 {% if NCP_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
355 {% if SOURCE_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
356 {% if COMPUTE_MAX_EIGENVALUE==False %} false {% else %} true {% endif %}
359 elif solver_variant == SolverVariant.Accelerator:
360 template +=
"""Stateless<
362 {{NUMBER_OF_VOLUMES_PER_AXIS}},
364 {{NUMBER_OF_UNKNOWNS}},
365 {{NUMBER_OF_AUXILIARY_VARIABLES}},
366 {% if FLUX_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
367 {% if NCP_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
368 {% if SOURCE_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
369 {% if COMPUTE_MAX_EIGENVALUE==False %} false {% else %} true {% endif %}
370 >(targetDevice, patchData);
373 assert False,
"Not supported combination: {} x {}".format(solver_variant, kernel_variant)
375 result = jinja2.Template( template, undefined=jinja2.DebugUndefined)
377 d[
"FLUX_IMPLEMENTATION"] = flux_implementation
378 d[
"NCP_IMPLEMENTATION"] = ncp_implementation
379 d[
"SOURCE_IMPLEMENTATION"] = source_implementation
380 d[
"COMPUTE_MAX_EIGENVALUE"] = compute_max_eigenvalue_of_next_time_step
381 return result.render(**d)
383def create_compute_Riemann_kernel_for_MusclHancock(flux_implementation,
385 source_implementation,
386 compute_max_eigenvalue_of_next_time_step,
388 riemann_kernel_variant):
391 I return only the unqualified function call, i.e. without any namespaces.
392 So by setting the right namespace as prefix, you can direct it to particular
395 solver_variant: SolverVariant
397 riemann_kernel_variant: RiemannKernelVariant
400 RiemannKernelCalls = {
401 RiemannKernelVariant.PatchWiseAoSStack:
"timeStepWithMUSCLHancock_patchwise_call_stack",
402 RiemannKernelVariant.PatchWiseAoSoAStack:
"timeStepWithMUSCLHancock_patchwise_call_stack",
403 RiemannKernelVariant.PatchWiseSoAStack:
"timeStepWithMUSCLHancock_patchwise_call_stack",
404 RiemannKernelVariant.BatchedAoSStack:
"timeStepWithMUSCLHancock_batched_call_stack",
405 RiemannKernelVariant.BatchedAoSoAStack:
"timeStepWithMUSCLHancock_batched_call_stack",
406 RiemannKernelVariant.BatchedSoAStack:
"timeStepWithMUSCLHancock_batched_call_stack",
407 RiemannKernelVariant.PatchWiseSplitTermsAoSStack:
"timeStepWithMUSCLHancock_patchwise_split_terms_call_stack",
408 RiemannKernelVariant.PatchWiseSplitTermsAoSoAStack:
"timeStepWithMUSCLHancock_patchwise_split_terms_call_stack",
409 RiemannKernelVariant.PatchWiseAoSHeap:
"timeStepWithMUSCLHancock_patchwise_heap",
410 RiemannKernelVariant.PatchWiseAoSoAHeap:
"timeStepWithMUSCLHancock_patchwise_heap",
411 RiemannKernelVariant.PatchWiseSoAHeap:
"timeStepWithMUSCLHancock_patchwise_heap",
412 RiemannKernelVariant.BatchedAoSHeap:
"timeStepWithMUSCLHancock_batched_heap",
413 RiemannKernelVariant.BatchedAoSoAHeap:
"timeStepWithMUSCLHancock_batched_heap",
414 RiemannKernelVariant.BatchedSoAHeap:
"timeStepWithMUSCLHancock_batched_heap",
415 RiemannKernelVariant.TaskGraphAoSHeap:
"timeStepWithMUSCLHancock_batched_heap",
416 RiemannKernelVariant.TaskGraphAoSoAHeap:
"timeStepWithMUSCLHancock_batched_heap",
417 RiemannKernelVariant.TaskGraphSoAHeap:
"timeStepWithMUSCLHancock_batched_heap",
418 RiemannKernelVariant.PatchWiseSplitTermsAoSHeap:
"timeStepWithMUSCLHancock_patchwise_split_terms_heap",
419 RiemannKernelVariant.PatchWiseSplitTermsAoSoAHeap:
"timeStepWithMUSCLHancock_patchwise_split_terms_heap",
420 RiemannKernelVariant.PatchWiseInSitu:
"timeStepWithMUSCLHancock_patchwise_in_situ",
421 RiemannKernelVariant.BatchedInSitu:
"timeStepWithMUSCLHancock_patchwise_in_situ"
424 EnumeratorTemplateTypes = {
425 RiemannKernelVariant.PatchWiseAoSStack:
"::exahype2::enumerator::AoSLexicographicEnumerator",
426 RiemannKernelVariant.PatchWiseAoSoAStack:
"::exahype2::enumerator::AoSoALexicographicEnumerator",
427 RiemannKernelVariant.PatchWiseSoAStack:
"::exahype2::enumerator::SoALexicographicEnumerator",
428 RiemannKernelVariant.BatchedAoSStack:
"::exahype2::enumerator::AoSLexicographicEnumerator",
429 RiemannKernelVariant.BatchedAoSoAStack:
"::exahype2::enumerator::AoSoALexicographicEnumerator",
430 RiemannKernelVariant.BatchedSoAStack:
"::exahype2::enumerator::SoALexicographicEnumerator",
431 RiemannKernelVariant.PatchWiseSplitTermsAoSStack:
"::exahype2::enumerator::AoSLexicographicEnumerator",
432 RiemannKernelVariant.PatchWiseSplitTermsAoSoAStack:
"::exahype2::enumerator::AoSoALexicographicEnumerator",
433 RiemannKernelVariant.PatchWiseAoSHeap:
"::exahype2::enumerator::AoSLexicographicEnumerator",
434 RiemannKernelVariant.PatchWiseAoSoAHeap:
"::exahype2::enumerator::AoSoALexicographicEnumerator",
435 RiemannKernelVariant.PatchWiseSoAHeap:
"::exahype2::enumerator::SoALexicographicEnumerator",
436 RiemannKernelVariant.BatchedAoSHeap:
"::exahype2::enumerator::AoSLexicographicEnumerator",
437 RiemannKernelVariant.BatchedAoSoAHeap:
"::exahype2::enumerator::AoSoALexicographicEnumerator",
438 RiemannKernelVariant.BatchedSoAHeap:
"::exahype2::enumerator::SoALexicographicEnumerator",
439 RiemannKernelVariant.TaskGraphAoSHeap:
"::exahype2::enumerator::AoSLexicographicEnumerator",
440 RiemannKernelVariant.TaskGraphAoSoAHeap:
"::exahype2::enumerator::AoSoALexicographicEnumerator",
441 RiemannKernelVariant.TaskGraphSoAHeap:
"::exahype2::enumerator::SoALexicographicEnumerator",
442 RiemannKernelVariant.PatchWiseSplitTermsAoSHeap:
"::exahype2::enumerator::AoSLexicographicEnumerator",
443 RiemannKernelVariant.PatchWiseSplitTermsAoSoAHeap:
"::exahype2::enumerator::AoSoALexicographicEnumerator",
444 RiemannKernelVariant.PatchWiseInSitu:
None,
445 RiemannKernelVariant.BatchedInSitu:
None
448 template = RiemannKernelCalls[riemann_kernel_variant]
450 if solver_variant == SolverVariant.WithVirtualFunctions:
451 template +=
"""_functors(
453 {{NUMBER_OF_VOLUMES_PER_AXIS}},
455 {{NUMBER_OF_UNKNOWNS}},
456 {{NUMBER_OF_AUXILIARY_VARIABLES}},
457 {% if FLUX_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
458 {% if NCP_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
459 {% if SOURCE_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
460 {% if COMPUTE_MAX_EIGENVALUE==False %} false {% else %} true {% endif %},
462 const double * __restrict__ Q,
463 const tarch::la::Vector<Dimensions,double>& faceCentre,
464 const tarch::la::Vector<Dimensions,double>& volumeH,
468 double * __restrict__ F
470 {% if FLUX_IMPLEMENTATION!="<none>" %}
471 repositories::{{SOLVER_INSTANCE}}.flux( Q, faceCentre, volumeH, t, dt, normal, F );
475 const double * __restrict__ Q,
476 const double * __restrict__ deltaQ,
477 const tarch::la::Vector<Dimensions,double>& faceCentre,
478 const tarch::la::Vector<Dimensions,double>& volumeH,
482 double * __restrict__ BTimesDeltaQ
484 {% if NCP_IMPLEMENTATION!="<none>" %}
485 repositories::{{SOLVER_INSTANCE}}.nonconservativeProduct( Q, deltaQ, faceCentre, volumeH, t, dt, normal, BTimesDeltaQ );
489 const double * __restrict__ Q,
490 const tarch::la::Vector<Dimensions,double>& volumeX,
491 const tarch::la::Vector<Dimensions,double>& volumeH,
494 double * __restrict__ S
496 {% if SOURCE_IMPLEMENTATION!="<none>" %}
497 repositories::{{SOLVER_INSTANCE}}.sourceTerm( Q, volumeX, volumeH, t, dt, S );
501 const double * __restrict__ Q,
502 const tarch::la::Vector<Dimensions,double>& faceCentre,
503 const tarch::la::Vector<Dimensions,double>& volumeH,
508 return repositories::{{SOLVER_INSTANCE}}.maxEigenvalue( Q, faceCentre, volumeH, t, dt, normal);
512 if solver_variant == SolverVariant.Stateless
and EnumeratorTemplateTypes[riemann_kernel_variant]==
None:
513 template +=
"""_static_calls<{{SOLVER_NAME}},{{NUMBER_OF_VOLUMES_PER_AXIS}},{{HALO_SIZE}}, {{NUMBER_OF_UNKNOWNS}}, {{NUMBER_OF_AUXILIARY_VARIABLES}}>(
515 {% if FLUX_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
516 {% if NCP_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
517 {% if SOURCE_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
518 {% if COMPUTE_MAX_EIGENVALUE==False %} false {% else %} true {% endif %}
521 if solver_variant == SolverVariant.Accelerator
and EnumeratorTemplateTypes[riemann_kernel_variant]==
None:
522 template +=
"""_static_calls<{{SOLVER_NAME}},{{NUMBER_OF_VOLUMES_PER_AXIS}},{{HALO_SIZE}}, {{NUMBER_OF_UNKNOWNS}}, {{NUMBER_OF_AUXILIARY_VARIABLES}}>(
525 {% if FLUX_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
526 {% if NCP_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
527 {% if SOURCE_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
528 {% if COMPUTE_MAX_EIGENVALUE==False %} false {% else %} true {% endif %}
531 if solver_variant == SolverVariant.Stateless
and EnumeratorTemplateTypes[riemann_kernel_variant]!=
None:
532 template +=
"""_static_calls<{{SOLVER_NAME}},{{NUMBER_OF_VOLUMES_PER_AXIS}},{{HALO_SIZE}}, {{NUMBER_OF_UNKNOWNS}}, {{NUMBER_OF_AUXILIARY_VARIABLES}}, {{TEMP_DATA_ENUMERATOR}}>(
534 {% if FLUX_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
535 {% if NCP_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
536 {% if SOURCE_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
537 {% if COMPUTE_MAX_EIGENVALUE==False %} false {% else %} true {% endif %}
540 if solver_variant == SolverVariant.Accelerator
and EnumeratorTemplateTypes[riemann_kernel_variant]!=
None:
541 template +=
"""_static_calls<{{SOLVER_NAME}},{{NUMBER_OF_VOLUMES_PER_AXIS}},{{HALO_SIZE}}, {{NUMBER_OF_UNKNOWNS}}, {{NUMBER_OF_AUXILIARY_VARIABLES}}, {{TEMP_DATA_ENUMERATOR}}>(
544 {% if FLUX_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
545 {% if NCP_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
546 {% if SOURCE_IMPLEMENTATION=="<none>" %} false {% else %} true {% endif %},
547 {% if COMPUTE_MAX_EIGENVALUE==False %} false {% else %} true {% endif %}
552 result = jinja2.Template( template, undefined=jinja2.DebugUndefined)
554 d[
"FLUX_IMPLEMENTATION" ] = flux_implementation
555 d[
"NCP_IMPLEMENTATION" ] = ncp_implementation
556 d[
"SOURCE_IMPLEMENTATION" ] = source_implementation
557 d[
"COMPUTE_MAX_EIGENVALUE" ] = compute_max_eigenvalue_of_next_time_step
561 d[
"TEMP_DATA_ENUMERATOR" ] = EnumeratorTemplateTypes[riemann_kernel_variant]
562 return result.render(**d)