7from applications
import set_euler_pde_terms
9parser = argparse.ArgumentParser(
10 description=
"ExaHyPE 2 - RusanovWithExplicitEuler Microbenchmarking Script"
15 choices=[
"euler",
"ccz4"],
17 help=
"Which application should be microbenchmarked",
25 help=
"Number of spatial dimensions.",
32 help=
"Number of finite volumes per axis (dimension) per patch.",
38 default=[32, 64, 128, 256, 512, 1024, 2048],
40 help=
"Number of patches to study",
47 help=
"Number of samples per measurement",
54 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).",
60 help=
"Assess host kernels",
66 help=
"Assess device kernels",
68args = parser.parse_args()
71 namespace=[
"exahype2",
"fv",
"rusanov",
"microbenchmark"],
72 project_name=
"kernel-microbenchmark",
74 executable=
"kernel-microbenchmark",
76solver_name =
"EulerFVSmooth"
78addition_includes = f
"""
79#include "kernels/{solver_name}_rusanov.h"
83if args.cpu ==
True or args.gpu ==
False:
84 function_calls += f
"""
85 assessKernel(wrapHostKernel<
86 cpp::nested::{solver_name}_timeStepWithRusanovStateless<
90 "host, AoSNested, serial, cpp, stateless",
92 ::tarch::accelerator::Device::HostDevice,
96 function_calls += f
"""
97 assessKernel(wrapFlattenedHostKernel<
98 cpp::cell_data_flattened_temporaries_nested::{solver_name}_timeStepWithRusanovStateless<
102 "host, AoS_CellDataFlattened_TemporariesNested, serial, cpp, stateless",
104 ::tarch::accelerator::Device::HostDevice,
108 function_calls += f
"""
109 assessKernel(wrapHostKernel<
110 cpp::cell_data_nested_temporaries_flattened::{solver_name}_timeStepWithRusanovStateless<
111 Abstract{solver_name}
114 "host, AoS_CellDataNested_TemporariesFlattened, serial, cpp, stateless",
116 ::tarch::accelerator::Device::HostDevice,
120 function_calls += f
"""
121 assessKernel(wrapFlattenedHostKernel<
122 cpp::flattened::{solver_name}_timeStepWithRusanovStateless<
123 Abstract{solver_name}
126 "host, AoSFlattened, serial, cpp, stateless",
128 ::tarch::accelerator::Device::HostDevice,
132 function_calls += f
"""
133 assessKernel(wrapMLIRNestedHostKernel<
134 mlir::nested::{solver_name}_timeStepWithRusanovStateless
136 "host, AoSNested, serial, mlir, stateless",
138 ::tarch::accelerator::Device::HostDevice,
142 function_calls += f
"""
143 assessKernel(wrapMLIRFlattenedHostKernel<
144 mlir::cell_data_flattened_temporaries_nested::{solver_name}_timeStepWithRusanovStateless
146 "host, AoS_CellDataFlattened_TemporariesNested, serial, mlir, stateless",
148 ::tarch::accelerator::Device::HostDevice,
152 function_calls += f
"""
153 assessKernel(wrapMLIRNestedHostKernel<
154 mlir::cell_data_nested_temporaries_flattened::{solver_name}_timeStepWithRusanovStateless
156 "host, AoS_CellDataNested_TemporariesFlattened, serial, mlir, stateless",
158 ::tarch::accelerator::Device::HostDevice,
162 function_calls += f
"""
163 assessKernel(wrapMLIRFlattenedHostKernel<
164 mlir::flattened::{solver_name}_timeStepWithRusanovStateless
166 "host, AoSFlattened, serial, mlir, stateless",
168 ::tarch::accelerator::Device::HostDevice,
176 function_calls += f
"""
177 assessKernel(wrapDeviceKernel<
178 cpp::flattened::{solver_name}_timeStepWithRusanovStateless<
179 Abstract{solver_name}
182 "device, AoS, parallel, omp",
191verbosity = peano4.api.LoggerVerbosity.OFF
194if args.application ==
"euler":
195 unknowns = 2 + args.dimensions
200 thesolver.add_user_solver_includes(
"#include <cmath>\n" "#include <algorithm>\n")
202 for stateless
in [
True,
False]:
203 set_euler_pde_terms(thesolver, args.dimensions, stateless)
206 constexpr double gamma = 1.4;
207 constexpr double p = 1.0;
208 constexpr double u = 1.0;
209 constexpr double domainLeft = -0.1;
210 constexpr double domainWidth = 0.2;
211 const double rho = 0.2 * std::sin(2.0 * M_PI * (x[0] - domainLeft) / domainWidth);
216 Q[3] = p / (gamma - 1) + 0.5 * rho * u * u;
219 Q[4] = p / (gamma - 1) + 0.5 * rho * u * u;
226elif args.application ==
"ccz4":
231if args.cpu ==
True or args.gpu ==
False:
232 solver_variants.append((exahype2.api.Target.Serial,
True, exahype2.api.OutputLanguage.CPP, exahype2.api.MemoryLayout.AoS_AllNested))
233 solver_variants.append((exahype2.api.Target.Serial,
True, exahype2.api.OutputLanguage.CPP, exahype2.api.MemoryLayout.AoS_CellDataFlattened_TemporariesNested))
234 solver_variants.append((exahype2.api.Target.Serial,
True, exahype2.api.OutputLanguage.CPP, exahype2.api.MemoryLayout.AoS_CellDataNested_TemporariesFlattened))
235 solver_variants.append((exahype2.api.Target.Serial,
True, exahype2.api.OutputLanguage.CPP, exahype2.api.MemoryLayout.AoS_AllFlattened))
237 solver_variants.append((exahype2.api.Target.Serial,
True, exahype2.api.OutputLanguage.MLIR, exahype2.api.MemoryLayout.AoS_AllNested))
238 solver_variants.append((exahype2.api.Target.Serial,
True, exahype2.api.OutputLanguage.MLIR, exahype2.api.MemoryLayout.AoS_CellDataFlattened_TemporariesNested))
239 solver_variants.append((exahype2.api.Target.Serial,
True, exahype2.api.OutputLanguage.MLIR, exahype2.api.MemoryLayout.AoS_CellDataNested_TemporariesFlattened))
240 solver_variants.append((exahype2.api.Target.Serial,
True, exahype2.api.OutputLanguage.MLIR, exahype2.api.MemoryLayout.AoS_AllFlattened))
242 solver_variants.append((exahype2.api.Target.Accelerator,
True, exahype2.api.OutputLanguage.CPP, exahype2.api.MemoryLayout.AoS_AllFlattened))
246 thesolver, volume_size=0.001
249project.add_solver(thesolver)
251build_mode = peano4.api.output.CompileMode.RELEASE
252project.set_global_simulation_parameters(
253 dimensions=args.dimensions,
254 offset=[-0.1, -0.1]
if args.dimensions == 2
else [-0.1, -0.1, -0.1],
255 size=[0.2, 0.2]
if args.dimensions == 2
else [0.2, 0.2, 0.2],
258 periodic_BC=[
True,
True,
True],
262project.set_Peano4_installation(
"../../../../../", build_mode)
263peano4_project = project.generate_Peano4_project(verbosity=verbosity)
265peano4_project.constants.export_constexpr_with_type(
"Accuracy", str(args.accuracy),
"double")
266peano4_project.constants.export_constexpr_with_type(
"NumberOfSamples", str(args.samples),
"int")
268formatted_num_patches =
"{{{}}}".format(
", ".join(str(val)
for val
in args.num_patches))
269peano4_project.constants.export_const_with_type(
"NumberOfPatchesToStudy", str(formatted_num_patches),
"tarch::la::Vector<%s, int>" % len(args.num_patches))
270peano4_project.constants.export_constexpr_with_type(
"NumberOfLaunchingThreads", str(1),
"int")
272peano4_project.output.makefile.add_CXX_flag(
"-MD")
273peano4_project.generate()
274peano4_project.build(make_clean_first=
False)
Solver for the Einstein equations in the first-order CCZ4 formulation.
Point-wise initial condition: given the physical position of a single degree of freedom,...
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.