9parser = argparse.ArgumentParser(
10 description=
"ExaHyPE 2 - Shallow Water Finite Volume Riemann Kernel Benchmarking Script"
15 choices=peano4.api.output.CompileModes,
16 default=peano4.api.output.CompileModes[0],
17 help=
"|".join(peano4.api.output.CompileModes),
24 help=
"Number of launching threads",
31 help=
"Number of finite volumes per axis (dimension) per patch.",
37 default=[32, 64, 128, 256, 512, 1024, 2048],
39 help=
"Number of patches to study",
46 help=
"Number of samples per measurement",
53 help=
"Floating point accuracy to which the different kernel variants have to match (absolute). Pass in 0 to disable correctness check. Pass in values < 0 to use machine epsilon (default).",
59 help=
"Evaluate max. eigenvalue",
65 help=
"Assess host kernels",
71 help=
"Assess device kernels",
77 help=
"Enable a floating-point exception handler.",
81 choices=[
'fWave',
'hllem'],
83 help=
"Specify the Riemann solver to use. Choices are 'fWave' or 'hllem'."
86args = parser.parse_args()
88fv_riemann_solver = exahype2.solvers.fv.riemann.GlobalAdaptiveTimeStepWithEnclaveTasking(
90 patch_size=args.patch_size,
91 unknowns={
"h": 1,
"hu": 1,
"hv": 1},
92 auxiliary_variables={
"b": 1},
95 time_step_relaxation=0.5,
96 pde_terms_without_state=
True,
99fv_riemann_solver.set_implementation(
100 initial_conditions=
"",
101 boundary_conditions=exahype2.solvers.PDETerms.Empty_Implementation,
102 refinement_criterion=exahype2.solvers.PDETerms.Empty_Implementation,
106 riemann_solver=f
"return applications::exahype2::swe::{args.riemann}(QR, QL, FR, FL, LR, LL, xR, xL, h, t, dt, normal, APDQ, AMDQ);",
109fv_riemann_solver.add_user_solver_includes(
111#include "../../../../applications/exahype2/shallow-water/FWave.h"
112#include "../../../../applications/exahype2/shallow-water/HLLEM.h"
116project = exahype2.Project(
117 namespace=[
"benchmarks",
"exahype2",
"kernelbenchmarks"],
118 project_name=
"KernelBenchmarksFVRiemann",
120 executable=f
"KernelBenchmarksFVRiemann.{args.build_mode}",
122project.add_solver(fv_riemann_solver)
124project.set_global_simulation_parameters(
130 first_plot_time_stamp=0.0,
131 time_in_between_plots=0.0,
132 periodic_BC=[
False,
False]
135project.set_Peano4_installation(
"../../../../", mode=peano4.api.output.string_to_mode(args.build_mode))
136project = project.generate_Peano4_project(verbose=
True)
138accuracy = args.accuracy
141 accuracy = default = numpy.finfo(float).eps
142project.constants.export_constexpr_with_type(
"Accuracy", str(accuracy),
"double")
144project.constants.export_constexpr_with_type(
"NumberOfSamples", str(args.samples),
"int")
146formatted_num_patches =
"{{{}}}".format(
", ".join(str(val)
for val
in args.num_patches))
147project.constants.export_const_with_type(
"NumberOfPatchesToStudy", str(formatted_num_patches),
"tarch::la::Vector<%s, int>" % len(args.num_patches))
149project.constants.export_constexpr_with_type(
"NumberOfLaunchingThreads", str(args.num_threads),
"int")
152 project.constants.export_boolean(
"EnableFPE",
True)
154 project.constants.export_boolean(
"EnableFPE",
False)
156if args.cpu ==
False and args.gpu ==
False:
157 project.constants.export_boolean(
"AssessHostKernels",
True)
158 project.constants.export_boolean(
"AssessDeviceKernels",
True)
160 project.constants.export_boolean(
"AssessHostKernels",
True if args.cpu
else False)
161 project.constants.export_boolean(
"AssessDeviceKernels",
True if args.gpu
else False)
163project.constants.export_boolean(
"EvaluateFlux",
False)
164project.constants.export_boolean(
"EvaluateNonconservativeProduct",
False)
165project.constants.export_boolean(
"EvaluateEigenvalues",
False)
166project.constants.export_boolean(
"EvaluateRiemann",
True)
167project.constants.export_boolean(
"EvaluateSource",
False)
168project.constants.export_boolean(
"EvaluateMaximumEigenvalueAfterTimeStep",
True if args.eval_eig
else False)
170benchmark_main_file =
"../../kernel-benchmarks/KernelBenchmarksFVRiemann-main.cpp"
171os.system(
"cp {} KernelBenchmarksFVRiemann-main.cpp".format(benchmark_main_file))
173project.output.makefile.add_CXX_flag(
"-DGRAV=9.81")
174project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)
177print(fv_riemann_solver)