7parser = argparse.ArgumentParser(
8 description=
"ExaHyPE 2 - RusanovWithExplicitEuler Microbenchmarking Script"
15 help=
"Number of finite volumes per axis (dimension) per patch.",
21 default=[32, 64, 128, 256, 512, 1024, 2048],
23 help=
"Number of patches to study",
30 help=
"Number of samples per measurement",
37 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).",
43 help=
"Assess host kernels",
49 help=
"Assess device kernels",
51args = parser.parse_args()
54 namespace=[
"exahype2",
"fv",
"rusanov",
"microbenchmark"],
55 project_name=
"kernel-microbenchmark",
57 executable=
"kernel-microbenchmark",
59solver_name =
"EulerFVSmooth"
61addition_includes = f
"""
62#include "kernels/{solver_name}_rusanov.h"
66if args.cpu ==
True or args.gpu ==
False:
67 function_calls += f
"""
68 assessKernel(wrapHostKernel<
69 {solver_name}_timeStepWithRusanovStateless<
70 Abstract{solver_name},
71 Abstract{solver_name}::PatchSize,
72 Abstract{solver_name}::HaloSize,
73 Abstract{solver_name}::NumberOfUnknowns,
74 Abstract{solver_name}::NumberOfAuxiliaryVariables
77 "host, AoS, serial, cpp, stateless",
79 ::tarch::accelerator::Device::HostDevice,
83 function_calls += f
"""
84 assessKernel(wrapHostKernel<
85 {solver_name}_timeStepWithRusanov<
86 Abstract{solver_name}::PatchSize,
87 Abstract{solver_name}::HaloSize,
88 Abstract{solver_name}::NumberOfUnknowns,
89 Abstract{solver_name}::NumberOfAuxiliaryVariables
92 "host, AoS, serial, cpp",
94 ::tarch::accelerator::Device::HostDevice,
101 function_calls += f
"""
102 assessKernel(wrapDeviceKernel<
103 {solver_name}_timeStepWithRusanovStateless<
104 Abstract{solver_name},
105 Abstract{solver_name}::PatchSize,
106 Abstract{solver_name}::HaloSize,
107 Abstract{solver_name}::NumberOfUnknowns,
108 Abstract{solver_name}::NumberOfAuxiliaryVariables
111 "device, AoS, parallel, omp",
121auxiliary_variables = 0
123verbosity = peano4.api.LoggerVerbosity.OFF
131thesolver.add_user_solver_includes(
"#include <cmath>\n" "#include <algorithm>\n")
133for stateless
in [
True,
False]:
134 thesolver.add_pde_term(
137 const double irho = 1.0 / Q[0];
138 constexpr double gamma = 1.4;
139 const double p = (gamma - 1.0) * (Q[3] - 0.5 * irho * (Q[1] * Q[1] + Q[2] * Q[2]));
144 F[1] = irho * Q[1] * Q[1] + p;
145 F[2] = irho * Q[1] * Q[2];
146 F[3] = irho * Q[1] * (Q[3] + p);
150 F[1] = irho * Q[2] * Q[1];
151 F[2] = irho * Q[2] * Q[2] + p;
152 F[3] = irho * Q[2] * (Q[3] + p);
159 thesolver.add_pde_term(
162 // Eigenvalues of the Euler flux Jacobian in direction "normal" are
163 // u_n +/- c, where u_n is the *velocity* component (momentum/density),
164 // not the raw momentum component - several earlier ExaHyPE
165 // applications/benchmarks used the raw momentum here by mistake, which
166 // silently gives a wrong (and usually too small) CFL time step bound.
167 const double irho = 1.0 / Q[0];
168 constexpr double gamma = 1.4;
169 const double p = (gamma - 1.0) * (Q[3] - 0.5 * irho * (Q[1] * Q[1] + Q[2] * Q[2]));
170 const double c = gamma * p * irho;
174 lambdaMax[0] = std::fmax(std::fabs(Q[1] * irho + c), std::fabs(Q[1] * irho - c));
177 lambdaMax[0] = std::fmax(std::fabs(Q[2] * irho + c), std::fabs(Q[2] * irho - c));
185 constexpr double gamma = 1.4;
186 constexpr double p = 1.0;
187 constexpr double u = 1.0;
188 constexpr double domainLeft = -0.1;
189 constexpr double domainWidth = 0.2;
190 const double rho = 1.0 + 0.2 * std::sin(2.0 * M_PI * (x[0] - domainLeft) / domainWidth);
194 Q[3] = p / (gamma - 1) + 0.5 * rho * u * u;
202if args.cpu ==
True or args.gpu ==
False:
203 solver_variants.append((exahype2.api.Target.Serial,
True))
204 solver_variants.append((exahype2.api.Target.Serial,
False))
206 solver_variants.append((exahype2.api.Target.Accelerator,
True))
210 thesolver, volume_size=0.001
213project.add_solver(thesolver)
215build_mode = peano4.api.output.CompileMode.RELEASE
216project.set_global_simulation_parameters(
217 dimensions=dimensions,
222 periodic_BC=[
True,
True,
True],
226project.set_Peano4_installation(
"../../../../../", build_mode)
227peano4_project = project.generate_Peano4_project(verbosity=verbosity)
229peano4_project.constants.export_constexpr_with_type(
"Accuracy", str(args.accuracy),
"double")
230peano4_project.constants.export_constexpr_with_type(
"NumberOfSamples", str(args.samples),
"int")
232formatted_num_patches =
"{{{}}}".format(
", ".join(str(val)
for val
in args.num_patches))
233peano4_project.constants.export_const_with_type(
"NumberOfPatchesToStudy", str(formatted_num_patches),
"tarch::la::Vector<%s, int>" % len(args.num_patches))
234peano4_project.constants.export_constexpr_with_type(
"NumberOfLaunchingThreads", str(1),
"int")
236peano4_project.generate()
237peano4_project.build(make_clean_first=
True)
The conservative flux F(Q) of a hyperbolic PDE.
Point-wise initial condition: given the physical position of a single degree of freedom,...
The maximum absolute eigenvalue of the flux Jacobian in a given direction, i.e.
Abstract base class for all ExaHyPE 2 solvers.
Finite Volumes with a Rusanov Riemann solver and explicit Euler time stepping, realised over a block-...
Setup phase counterpart to RusanovWithExplicitEuler: sets the initial condition for a Finite Volume s...
Optional realisation of exahype2.api.Project.mainfile_generator.