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=
"Assess serial kernels",
83 help=
"Assess parallel kernels",
89 help=
"Enable a floating-point exception handler.",
92args = parser.parse_args()
94fv_rusanov_solver = exahype2.solvers.fv.rusanov.GlobalAdaptiveTimeStepWithEnclaveTasking(
96 patch_size=args.patch_size,
97 unknowns={
"h": 1,
"hu": 1,
"hv": 1},
98 auxiliary_variables={
"b": 1},
101 time_step_relaxation=0.5,
102 pde_terms_without_state=
True,
105fv_rusanov_solver.set_implementation(
106 initial_conditions=
"",
107 boundary_conditions=exahype2.solvers.PDETerms.Empty_Implementation,
108 refinement_criterion=exahype2.solvers.PDETerms.Empty_Implementation,
109 flux=
"applications::exahype2::swe::flux(Q, faceCentre, volumeH, t, dt, normal, F);",
110 ncp=
"applications::exahype2::swe::nonconservativeProduct(Q, deltaQ, faceCentre, volumeH, t, dt, normal, BTimesDeltaQ);",
111 eigenvalues=
"applications::exahype2::swe::maxEigenvalue(Q, faceCentre, volumeH, t, dt, normal, maxEigenvalue);",
114fv_rusanov_solver.add_user_solver_includes(
116#include "../../../../applications/exahype2/shallow-water/SWE.h"
120project = exahype2.Project(
121 namespace=[
"benchmarks",
"exahype2",
"kernelbenchmarks"],
122 project_name=
"KernelBenchmarksFVRusanovDSL",
124 executable=f
"KernelBenchmarksFVRusanovDSL.{args.build_mode}",
126project.add_solver(fv_rusanov_solver)
128project.set_global_simulation_parameters(
134 first_plot_time_stamp=0.0,
135 time_in_between_plots=0.0,
136 periodic_BC=[
False,
False]
139project.set_Peano4_installation(
"../../../../", mode=peano4.api.output.string_to_mode(args.build_mode))
140project = project.generate_Peano4_project(verbose=
True)
142accuracy = args.accuracy
145 accuracy = default = numpy.finfo(float).eps
146project.constants.export_constexpr_with_type(
"Accuracy", str(accuracy),
"double")
148project.constants.export_constexpr_with_type(
"NumberOfSamples", str(args.samples),
"int")
150formatted_num_patches =
"{{{}}}".format(
", ".join(str(val)
for val
in args.num_patches))
151project.constants.export_const_with_type(
"NumberOfPatchesToStudy", str(formatted_num_patches),
"tarch::la::Vector<%s, int>" % len(args.num_patches))
153project.constants.export_constexpr_with_type(
"NumberOfLaunchingThreads", str(args.num_threads),
"int")
156 project.constants.export_boolean(
"EnableFPE",
True)
158 project.constants.export_boolean(
"EnableFPE",
False)
161if args.cpu ==
False and args.gpu ==
False:
162 project.output.makefile.add_CXX_flag(
"-DASSESS_HOST_KERNELS")
164 if args.cpu: project.output.makefile.add_CXX_flag(
"-DASSESS_HOST_KERNELS")
165 if args.gpu: project.output.makefile.add_CXX_flag(
"-DASSESS_DEVICE_KERNELS")
167if args.serial ==
False and args.parallel ==
False:
168 project.output.makefile.add_CXX_flag(
"-DASSESS_SERIAL_KERNELS")
169 project.output.makefile.add_CXX_flag(
"-DASSESS_PARALLEL_KERNELS")
171 if args.serial: project.output.makefile.add_CXX_flag(
"-DASSESS_SERIAL_KERNELS")
172 if args.parallel: project.output.makefile.add_CXX_flag(
"-DASSESS_PARALLEL_KERNELS")
174project.output.makefile.add_CXX_flag(
"-DASSESS_CPP_KERNELS")
176project.constants.export_boolean(
"EvaluateFlux",
True)
177project.constants.export_boolean(
"EvaluateNonconservativeProduct",
True)
178project.constants.export_boolean(
"EvaluateSource",
False)
179project.constants.export_boolean(
"EvaluateMaximumEigenvalueAfterTimeStep",
True if args.eval_eig
else False)
181benchmark_main_file =
"../../kernel-benchmarks/KernelBenchmarksFVRusanovDSL-main.cpp"
182os.system(
"cp {} KernelBenchmarksFVRusanovDSL-main.cpp".format(benchmark_main_file))
184project.output.makefile.add_CXX_flag(
"-DGRAV=9.81")
185project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)
188print(fv_rusanov_solver)