9import exahype2.dslhype
as DSL
11from CCZ4Solver
import CCZ4Solver_FD4_GlobalAdaptiveTimeStepWithEnclaveTasking
13parser = argparse.ArgumentParser(
14 description=
"ExaHyPE 2 - CCZ4 FD4 Kernel Benchmarking Script"
19 choices=peano4.api.output.CompileModes,
20 default=peano4.api.output.CompileModes[0],
21 help=
"|".join(peano4.api.output.CompileModes),
28 help=
"Number of launching threads",
35 help=
"Number of finite volumes per axis (dimension) per patch.",
41 default=[32, 64, 128, 256, 512, 1024, 2048],
43 help=
"Number of patches to study",
50 help=
"Number of samples per measurement",
57 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).",
63 help=
"Evaluate max. eigenvalue",
69 help=
"Assess host kernels",
75 help=
"Assess device kernels",
81 help=
"Assess serial kernels",
87 help=
"Assess parallel kernels",
93 help=
"Enable a floating-point exception handler.",
101 help=
"Number of dimensions to use: 2 or 3",
107 help=
"Enable MLIR kernel compilation support",
113 help=
"Enable CPP kernels",
116 "--enable-memref-flattening",
117 dest=
"enable_memref_flattening",
119 help=
"Enable CPP kernels",
122 "--enable-function-inlining",
123 dest=
"enable_function_inlining",
125 help=
"Enable inlining of Polygeist functions",
128 "--enable-memory-reuse",
129 dest=
"enable_memory_reuse",
131 help=
"Enable reuse of scratchpad memory allocations",
134 "--enable-memory-fusion",
135 dest=
"enable_memory_fusion",
137 help=
"Enable fusion of allocations into one",
140 "--enable-loop-fusion",
141 dest=
"enable_loop_fusion",
143 help=
"Enable fusion of loops with the same bounds",
146 "--enable-imperfect-nested-loops-to-perfect",
147 dest=
"enable_imperfect_nested_loops_to_perfect",
149 help=
"Enable conversion of imperfectly nested parallels into a perfectly nested parallels",
152 "--enable-nested-parallel-ops-to-multidimensional",
153 dest=
"enable_nested_parallel_ops_to_multidimensional",
155 help=
"Enable conversion of nested parallels into a single multidimensional operation",
158 "--enable-omp-tasks",
159 dest=
"enable_omp_tasks",
161 help=
"Enable use of OpenMP tasks as opposed to loop parallelism",
164 "--omp-task-version",
165 choices=[
"task",
"taskloop"],
169 "--omp-single-region",
173 "--nested-parallel-count",
176 help=
"Number of dimensions to use: 2 or 3. Conversion is enabled if the count is positive.",
182 help=
"Number of parallel builds to use",
186 default=
"KernelBenchmarksFD4DSL",
188 help=
"Name of final application",
191args = parser.parse_args()
195 patch_size=args.patch_size,
196 min_meshcell_h=0.001,
197 max_meshcell_h=0.001,
198 pde_terms_without_state=
True,
202project = exahype2.Project(
203 namespace=[
"benchmarks",
"exahype2",
"kernelbenchmarks"],
204 project_name=
"KernelBenchmarksFD4DSL",
206 executable=f
"{args.o}.{args.build_mode}",
208fd4_solver.add_all_solver_constants()
209project.add_solver(fd4_solver)
210project.set_global_simulation_parameters(
211 dimensions=args.dimensions,
212 size=[1.0] * args.dimensions,
213 offset=[0.0] * args.dimensions,
216 first_plot_time_stamp=0.0,
217 time_in_between_plots=0.0,
218 periodic_BC=[
False] * args.dimensions
221project.set_Peano4_installation(
"../../../../", mode=peano4.api.output.string_to_mode(args.build_mode))
222project = project.generate_Peano4_project(verbose=
True)
224accuracy = args.accuracy
227 accuracy = default = numpy.finfo(float).eps
228project.constants.export_constexpr_with_type(
"Accuracy", str(accuracy),
"double")
230project.constants.export_constexpr_with_type(
"NumberOfSamples", str(args.samples),
"int")
232formatted_num_patches =
"{{{}}}".format(
", ".join(str(val)
for val
in args.num_patches))
233project.constants.export_const_with_type(
"NumberOfPatchesToStudy", str(formatted_num_patches),
"tarch::la::Vector<%s, int>" % len(args.num_patches))
235project.constants.export_constexpr_with_type(
"NumberOfLaunchingThreads", str(args.num_threads),
"int")
238 project.constants.export_boolean(
"EnableFPE",
True)
240 project.constants.export_boolean(
"EnableFPE",
False)
243if args.cpu ==
False and args.gpu ==
False:
244 project.output.makefile.add_CXX_flag(
"-DASSESS_HOST_KERNELS")
246 if args.cpu: project.output.makefile.add_CXX_flag(
"-DASSESS_HOST_KERNELS")
247 if args.gpu: project.output.makefile.add_CXX_flag(
"-DASSESS_DEVICE_KERNELS")
249if args.serial ==
False and args.parallel ==
False:
250 project.output.makefile.add_CXX_flag(
"-DASSESS_SERIAL_KERNELS")
251 project.output.makefile.add_CXX_flag(
"-DASSESS_PARALLEL_KERNELS")
253 if args.serial: project.output.makefile.add_CXX_flag(
"-DASSESS_SERIAL_KERNELS")
254 if args.parallel: project.output.makefile.add_CXX_flag(
"-DASSESS_PARALLEL_KERNELS")
256project.constants.export_boolean(
"EvaluateFlux",
False)
257project.constants.export_boolean(
"EvaluateNonconservativeProduct",
True)
258project.constants.export_boolean(
"EvaluateSource",
True)
259project.constants.export_boolean(
"EvaluateMaximumEigenvalueAfterTimeStep",
True if args.eval_eig
else False)
261project.constants.define_value(
"GAMMA", str(1.0))
262project.constants.define_value(
"KOSigma", str(8))
266 if args.enable_memory_reuse:
267 max_patch_size = (args.patch_size + 6) * (args.patch_size + 6) * (args.patch_size + 6) * 59
270 DSL.set_mlir_environment(project,
"FD4", f
"ccz4_physics.mlir", args.dimensions, args.gpu,
271 args.enable_memref_flattening,
272 args.enable_function_inlining,
273 args.nested_parallel_count,
274 args.enable_imperfect_nested_loops_to_perfect,
275 args.enable_nested_parallel_ops_to_multidimensional,
276 args.enable_omp_tasks,
277 args.omp_task_version,
278 args.omp_single_region,
280 args.enable_memory_fusion,
281 args.enable_loop_fusion
283 project.output.makefile.add_CXX_flag(
"-DASSESS_MLIR_KERNELS")
286if args.enable_cpp
or not args.enable_mlir:
287 project.output.makefile.add_CXX_flag(
"-DASSESS_CPP_KERNELS")
289benchmark_main_file =
"../../kernel-benchmarks/KernelBenchmarksFD4DSL-main.cpp"
290os.system(
"cp {} KernelBenchmarksFD4DSL-main.cpp".format(benchmark_main_file))
292project.output.makefile.add_CXX_flag(
"-DGRAV=9.81")
294fd4_solver.add_makefile_parameters(
295 project,
"../../../../applications/exahype2/ccz4"
297project.generate(throw_away_data_after_generation=
False)
298project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True, number_of_parallel_builds=args.j)
CCZ4 solver using fourth-order finite differences and global adaptive time stepping incl enclave task...