8import exahype2.dslhype
as DSL
10parser = argparse.ArgumentParser(
11 description=
"ExaHyPE 2 - Euler Discontinuous Galerkin Kernel Benchmarking Script"
16 choices=peano4.api.output.CompileModes,
17 default=peano4.api.output.CompileModes[0],
18 help=
"|".join(peano4.api.output.CompileModes),
25 help=
"Number of launching threads",
32 help=
"Number of Dimensions for patch.",
39 help=
"Number of finite volumes per axis (dimension) per patch.",
45 default=[32, 64, 128, 256],
47 help=
"Number of patches to study",
54 help=
"Number of samples per measurement",
61 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).",
67 help=
"Evaluate max. eigenvalue",
73 help=
"Enable MLIR kernel compilation support",
79 help=
"Enable CPP kernels",
85 help=
"Assess host kernels",
91 help=
"Assess device kernels",
97 help=
"Assess serial kernels",
103 help=
"Assess parallel kernels",
109 help=
"Enable a floating-point exception handler.",
114 dest=
"function_to_benchmark",
115 choices=[
"cellIntegral",
"riemannProblem"],
116 default=
"cellIntegral",
117 help=
"Set which function to benchmark.",
120args = parser.parse_args()
122dg_solver = exahype2.solvers.rkdg.rusanov.GlobalAdaptiveTimeStep(
124 polynomials=exahype2.solvers.GaussLegendreBasis(args.dg_order),
126 unknowns={
"rho": 1,
"u": 1,
"v": 1,
"w": 1,
"e": 1}
if args.dimensions == 3
else {
"rho": 1,
"u": 1,
"v": 1,
"e": 1},
127 auxiliary_variables = {},
130 time_step_relaxation=0.5,
131 pde_terms_without_state=
True,
134dg_solver.set_implementation(
135 initial_conditions=
"",
136 boundary_conditions=exahype2.solvers.PDETerms.Empty_Implementation,
137 refinement_criterion=exahype2.solvers.PDETerms.Empty_Implementation,
138 flux=
"applications::exahype2::euler::flux(Q, faceCentre, faceCentre, t, dt, normal, F);",
139 ncp=exahype2.solvers.PDETerms.None_Implementation,
140 eigenvalues=
"applications::exahype2::euler::maxEigenvalue(Q, faceCentre, faceCentre, t, dt, normal, maxEigenvalue);",
141 source_term=exahype2.solvers.PDETerms.None_Implementation,
142 point_source=exahype2.solvers.PDETerms.None_Implementation
144dg_solver.add_user_solver_includes(
146 #include "../../../../applications/exahype2/euler/Euler.h"
150project = exahype2.Project(
151 namespace=[
"benchmarks",
"exahype2",
"kernelbenchmarks"],
152 project_name=
"KernelBenchmarksDiscontinuousGalerkinDSL",
154 executable=f
"KernelBenchmarksDiscontinuousGalerkinDSL.{args.build_mode}",
156project.add_solver(dg_solver)
158project.set_global_simulation_parameters(
159 dimensions=args.dimensions,
160 size=[1.0, 1.0]
if args.dimensions == 2
else [1.0, 1.0, 1.0],
161 offset=[0.0, 0.0]
if args.dimensions == 2
else [0.0, 0.0, 0.0],
164 first_plot_time_stamp=0.0,
165 time_in_between_plots=0.0,
166 periodic_BC=[
False,
False]
if args.dimensions == 2
else [
False,
False,
False]
169project.set_Peano4_installation(
"../../../../", mode=peano4.api.output.string_to_mode(args.build_mode))
170project = project.generate_Peano4_project(verbose=
True)
172accuracy = args.accuracy
175 accuracy = default = numpy.finfo(float).eps
176project.constants.export_constexpr_with_type(
"Accuracy", str(accuracy),
"double")
178project.constants.export_constexpr_with_type(
"NumberOfSamples", str(args.samples),
"int")
180formatted_num_patches =
"{{{}}}".format(
", ".join(str(val)
for val
in args.num_patches))
181project.constants.export_const_with_type(
"NumberOfPatchesToStudy", str(formatted_num_patches),
"tarch::la::Vector<%s, int>" % len(args.num_patches))
183project.constants.export_constexpr_with_type(
"NumberOfLaunchingThreads", str(args.num_threads),
"int")
186 project.constants.export_boolean(
"EnableFPE",
True)
188 project.constants.export_boolean(
"EnableFPE",
False)
191if args.cpu ==
False and args.gpu ==
False:
192 project.output.makefile.add_CXX_flag(
"-DASSESS_HOST_KERNELS")
194 if args.cpu: project.output.makefile.add_CXX_flag(
"-DASSESS_HOST_KERNELS")
195 if args.gpu: project.output.makefile.add_CXX_flag(
"-DASSESS_DEVICE_KERNELS")
197if args.serial ==
False and args.parallel ==
False:
198 project.output.makefile.add_CXX_flag(
"-DASSESS_SERIAL_KERNELS")
199 project.output.makefile.add_CXX_flag(
"-DASSESS_PARALLEL_KERNELS")
201 if args.serial: project.output.makefile.add_CXX_flag(
"-DASSESS_SERIAL_KERNELS")
202 if args.parallel: project.output.makefile.add_CXX_flag(
"-DASSESS_PARALLEL_KERNELS")
204project.constants.export_boolean(
"EvaluateFlux",
True)
205project.constants.export_boolean(
"EvaluateNonconservativeProduct",
False)
206project.constants.export_boolean(
"EvaluateSource",
False)
207project.constants.export_boolean(
"EvaluatePointSources",
False)
208project.constants.export_boolean(
"EvaluateMaximumEigenvalueAfterTimeStep",
True if args.eval_eig
else False)
210project.constants.define_value(
"FluxMacro",
"1")
212if args.function_to_benchmark ==
"cellIntegral":
213 project.output.makefile.add_CXX_flag(
"-DASSESS_CELL_INTEGRAL_KERNELS")
214elif args.function_to_benchmark ==
"riemannProblem":
215 project.output.makefile.add_CXX_flag(
"-DASSESS_RIEMANN_PROBLEM_KERNELS")
217project.constants.define_value(
"GAMMA", str(1.0))
219benchmark_main_file =
"../../kernel-benchmarks/KernelBenchmarksDiscontinuousGalerkinDSL-main.cpp"
220os.system(
"cp {} KernelBenchmarksDiscontinuousGalerkinDSL-main.cpp".format(benchmark_main_file))
222project.output.makefile.add_CXX_flag(
"-DGRAV=9.81")
226 DSL.set_mlir_environment(project,
"dg_cellIntegral", f
"euler_{args.dimensions}d.mlir", args.dimensions, args.gpu)
227 project.output.makefile.add_CXX_flag(
"-DASSESS_MLIR_KERNELS")
230if args.enable_cpp
or not args.enable_mlir:
231 project.output.makefile.add_CXX_flag(
"-DASSESS_CPP_KERNELS")
233project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)