9parser = argparse.ArgumentParser(
10 description=
"ExaHyPE 2 - Shallow Water Finite Volume Rusanov 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.",
80args = parser.parse_args()
82fv_rusanov_solver = exahype2.solvers.fv.rusanov.GlobalAdaptiveTimeStepWithEnclaveTasking(
84 patch_size=args.patch_size,
85 unknowns={
"h": 1,
"hu": 1,
"hv": 1},
86 auxiliary_variables={
"b": 1},
89 time_step_relaxation=0.5,
90 pde_terms_without_state=
True,
93fv_rusanov_solver.set_implementation(
94 initial_conditions=
"",
95 boundary_conditions=exahype2.solvers.PDETerms.Empty_Implementation,
96 refinement_criterion=exahype2.solvers.PDETerms.Empty_Implementation,
97 flux=
"applications::exahype2::swe::flux(Q, faceCentre, volumeH, t, dt, normal, F);",
98 ncp=
"applications::exahype2::swe::nonconservativeProduct(Q, deltaQ, faceCentre, volumeH, t, dt, normal, BTimesDeltaQ);",
99 eigenvalues=
"return applications::exahype2::swe::maxEigenvalue(Q, faceCentre, volumeH, t, dt, normal);",
102fv_rusanov_solver.add_user_solver_includes(
104#include "../../../../applications/exahype2/shallow-water/SWE.h"
108project = exahype2.Project(
109 namespace=[
"benchmarks",
"exahype2",
"kernelbenchmarks"],
110 project_name=
"KernelBenchmarksFVRusanov",
112 executable=f
"KernelBenchmarksFVRusanov.{args.build_mode}",
114project.add_solver(fv_rusanov_solver)
116project.set_global_simulation_parameters(
122 first_plot_time_stamp=0.0,
123 time_in_between_plots=0.0,
124 periodic_BC=[
False,
False]
127project.set_Peano4_installation(
"../../../../", mode=peano4.api.output.string_to_mode(args.build_mode))
128project = project.generate_Peano4_project(verbose=
True)
130accuracy = args.accuracy
133 accuracy = default = numpy.finfo(float).eps
134project.constants.export_constexpr_with_type(
"Accuracy", str(accuracy),
"double")
136project.constants.export_constexpr_with_type(
"NumberOfSamples", str(args.samples),
"int")
138formatted_num_patches =
"{{{}}}".format(
", ".join(str(val)
for val
in args.num_patches))
139project.constants.export_const_with_type(
"NumberOfPatchesToStudy", str(formatted_num_patches),
"tarch::la::Vector<%s, int>" % len(args.num_patches))
141project.constants.export_constexpr_with_type(
"NumberOfLaunchingThreads", str(args.num_threads),
"int")
144 project.constants.export_boolean(
"EnableFPE",
True)
146 project.constants.export_boolean(
"EnableFPE",
False)
148if args.cpu ==
False and args.gpu ==
False:
149 project.constants.export_boolean(
"AssessHostKernels",
True)
150 project.constants.export_boolean(
"AssessDeviceKernels",
True)
152 project.constants.export_boolean(
"AssessHostKernels",
True if args.cpu
else False)
153 project.constants.export_boolean(
"AssessDeviceKernels",
True if args.gpu
else False)
155project.constants.export_boolean(
"EvaluateFlux",
True)
156project.constants.export_boolean(
"EvaluateNonconservativeProduct",
True)
157project.constants.export_boolean(
"EvaluateSource",
False)
158project.constants.export_boolean(
"EvaluateMaximumEigenvalueAfterTimeStep",
True if args.eval_eig
else False)
160benchmark_main_file =
"../../kernel-benchmarks/KernelBenchmarksFVRusanov-main.cpp"
161os.system(
"cp {} KernelBenchmarksFVRusanov-main.cpp".format(benchmark_main_file))
163project.output.makefile.add_CXX_flag(
"-DGRAV=9.81")
164project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)
167print(fv_rusanov_solver)