10import exahype2.dslhype
as DSL
12from CCZ4Solver
import CCZ4Solver_FV_GlobalAdaptiveTimeStepWithEnclaveTasking
14parser = argparse.ArgumentParser(
15 description=
"ExaHyPE 2 - CCZ4 Finite Volume Rusanov Kernel Benchmarking Script"
20 choices=peano4.api.output.CompileModes,
21 default=peano4.api.output.CompileModes[0],
22 help=
"|".join(peano4.api.output.CompileModes),
29 help=
"Number of launching threads",
36 help=
"Number of finite volumes per axis (dimension) per patch.",
42 default=[32, 64, 128, 256, 512, 1024, 2048],
44 help=
"Number of patches to study",
51 help=
"Number of samples per measurement",
58 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).",
64 help=
"Evaluate max. eigenvalue",
70 help=
"Assess host kernels",
76 help=
"Assess device kernels",
82 help=
"Assess serial kernels",
88 help=
"Assess parallel kernels",
94 help=
"Enable a floating-point exception handler.",
102 help=
"Number of dimensions to use: only 3 makes sense for this application",
108 help=
"Enable MLIR kernel compilation support",
114 help=
"Enable CPP kernels",
117 "--enable-memref-flattening",
118 dest=
"enable_memref_flattening",
120 help=
"Enable CPP kernels",
123 "--enable-function-inlining",
124 dest=
"enable_function_inlining",
126 help=
"Enable inlining of Polygeist functions",
129 "--enable-memory-reuse",
130 dest=
"enable_memory_reuse",
132 help=
"Enable reuse of scratchpad memory allocations",
135 "--enable-memory-fusion",
136 dest=
"enable_memory_fusion",
138 help=
"Enable fusion of allocations into one",
141 "--enable-loop-fusion",
142 dest=
"enable_loop_fusion",
144 help=
"Enable fusion of loops with the same bounds",
147 "--enable-imperfect-nested-loops-to-perfect",
148 dest=
"enable_imperfect_nested_loops_to_perfect",
150 help=
"Enable conversion of imperfectly nested parallels into a perfectly nested parallels",
153 "--enable-nested-parallel-ops-to-multidimensional",
154 dest=
"enable_nested_parallel_ops_to_multidimensional",
156 help=
"Enable conversion of nested parallels into a single multidimensional operation",
159 "--enable-omp-tasks",
160 dest=
"enable_omp_tasks",
162 help=
"Enable use of OpenMP tasks as opposed to loop parallelism",
165 "--omp-task-version",
166 choices=[
"task",
"taskloop"],
170 "--omp-single-region",
174 "--nested-parallel-count",
177 help=
"Number of dimensions to use: 2 or 3. Conversion is enabled if the count is positive.",
183 help=
"Number of parallel builds to use",
187 default=
"KernelBenchmarksFVRusanovDSL",
189 help=
"Name of final application",
191args = parser.parse_args()
195 patch_size=args.patch_size,
198 pde_terms_without_state=
True
201project = exahype2.Project(
202 namespace=[
"benchmarks",
"exahype2",
"kernelbenchmarks"],
203 project_name=
"KernelBenchmarksFVRusanovDSL",
205 executable=f
"{args.o}.{args.build_mode}",
207fv_rusanov_solver.add_all_solver_constants()
208project.add_solver(fv_rusanov_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))
265 if args.enable_memory_reuse:
266 max_patch_size = (args.patch_size + 2) * (args.patch_size + 2) * (args.patch_size + 2) * 59
269 DSL.set_mlir_environment(project,
"rusanov", f
"ccz4_physics.mlir", args.dimensions, args.gpu,
270 args.enable_memref_flattening,
271 args.enable_function_inlining,
272 args.nested_parallel_count,
273 args.enable_imperfect_nested_loops_to_perfect,
274 args.enable_nested_parallel_ops_to_multidimensional,
275 args.enable_omp_tasks,
276 args.omp_task_version,
277 args.omp_single_region,
279 args.enable_memory_fusion,
280 args.enable_loop_fusion
282 project.output.makefile.add_CXX_flag(
"-DASSESS_MLIR_KERNELS")
285if args.enable_cpp
or not args.enable_mlir:
286 project.output.makefile.add_CXX_flag(
"-DASSESS_CPP_KERNELS")
289benchmark_main_file =
"../../kernel-benchmarks/KernelBenchmarksFVRusanovDSL-main.cpp"
290os.system(
"cp {} KernelBenchmarksFVRusanovDSL-main.cpp".format(benchmark_main_file))
292project.output.makefile.add_CXX_flag(
"-DGRAV=9.81")
294fv_rusanov_solver.add_makefile_parameters(
295 project,
"../../../../applications/exahype2/ccz4"
297project.generate(throw_away_data_after_generation=
False)
298print(
"Building...", flush=
True)
299project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True, number_of_parallel_builds=args.j)
302print(fv_rusanov_solver, flush=
True)
CCZ4 solver using finite volumes and global adaptive time stepping incl enclave tasking.