9from CCZ4Solver
import CCZ4Solver_RKDG_GlobalAdaptiveTimeStepWithEnclaveTasking
11parser = argparse.ArgumentParser(
12 description=
"ExaHyPE 2 - CCZ4 Discontinuous Galerkin Kernel Benchmarking Script"
17 choices=peano4.api.output.CompileModes,
18 default=peano4.api.output.CompileModes[0],
19 help=
"|".join(peano4.api.output.CompileModes),
26 help=
"Number of launching threads",
33 help=
"Number of finite volumes per axis (dimension) per patch.",
39 default=[32, 64, 128, 256],
41 help=
"Number of patches to study",
48 help=
"Number of samples per measurement",
55 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).",
61 help=
"Evaluate max. eigenvalue",
67 help=
"Enable MLIR kernel compilation support",
73 help=
"Enable CPP kernels",
79 help=
"Assess host kernels",
85 help=
"Assess device kernels",
91 help=
"Assess serial kernels",
97 help=
"Assess parallel kernels",
103 help=
"Enable a floating-point exception handler.",
108 dest=
"function_to_benchmark",
109 choices=[
"cellIntegral",
"riemannProblem"],
110 default=
"cellIntegral",
111 help=
"Set which function to benchmark.",
114args = parser.parse_args()
118 rk_order=args.dg_order,
119 polynomials=exahype2.solvers.GaussLegendreBasis(args.dg_order),
122 pde_terms_without_state=
True,
125project = exahype2.Project(
126 namespace=[
"benchmarks",
"exahype2",
"kernelbenchmarks"],
127 project_name=
"KernelBenchmarksDiscontinuousGalerkinDSL",
129 executable=f
"KernelBenchmarksDiscontinuousGalerkinDSL.{args.build_mode}",
131dg_solver.add_all_solver_constants()
132project.add_solver(dg_solver)
134project.set_global_simulation_parameters(
136 size=[1.0, 1.0, 1.0],
137 offset=[0.0, 0.0, 0.0],
140 first_plot_time_stamp=0.0,
141 time_in_between_plots=0.0,
142 periodic_BC=[
False,
False,
False]
145project.set_Peano4_installation(
"../../../../", mode=peano4.api.output.string_to_mode(args.build_mode))
146project = project.generate_Peano4_project(verbose=
True)
148accuracy = args.accuracy
151 accuracy = default = numpy.finfo(float).eps
152project.constants.export_constexpr_with_type(
"Accuracy", str(accuracy),
"double")
154project.constants.export_constexpr_with_type(
"NumberOfSamples", str(args.samples),
"int")
156formatted_num_patches =
"{{{}}}".format(
", ".join(str(val)
for val
in args.num_patches))
157project.constants.export_const_with_type(
"NumberOfPatchesToStudy", str(formatted_num_patches),
"tarch::la::Vector<%s, int>" % len(args.num_patches))
159project.constants.export_constexpr_with_type(
"NumberOfLaunchingThreads", str(args.num_threads),
"int")
162 project.constants.export_boolean(
"EnableFPE",
True)
164 project.constants.export_boolean(
"EnableFPE",
False)
167if args.cpu ==
False and args.gpu ==
False:
168 project.output.makefile.add_CXX_flag(
"-DASSESS_HOST_KERNELS")
170 if args.cpu: project.output.makefile.add_CXX_flag(
"-DASSESS_HOST_KERNELS")
171 if args.gpu: project.output.makefile.add_CXX_flag(
"-DASSESS_DEVICE_KERNELS")
173if args.serial ==
False and args.parallel ==
False:
174 project.output.makefile.add_CXX_flag(
"-DASSESS_SERIAL_KERNELS")
175 project.output.makefile.add_CXX_flag(
"-DASSESS_PARALLEL_KERNELS")
177 if args.serial: project.output.makefile.add_CXX_flag(
"-DASSESS_SERIAL_KERNELS")
178 if args.parallel: project.output.makefile.add_CXX_flag(
"-DASSESS_PARALLEL_KERNELS")
180project.constants.export_boolean(
"EvaluateFlux",
False)
181project.constants.export_boolean(
"EvaluateNonconservativeProduct",
True)
182project.constants.export_boolean(
"EvaluateSource",
True)
183project.constants.export_boolean(
"EvaluatePointSources",
False)
184project.constants.export_boolean(
"EvaluateMaximumEigenvalueAfterTimeStep",
True if args.eval_eig
else False)
186project.constants.define_value(
"NonconservativeProductMacro",
"1")
188project.constants.define_value(
"GAMMA", str(1.0))
190if args.function_to_benchmark ==
"cellIntegral":
191 project.output.makefile.add_CXX_flag(
"-DASSESS_CELL_INTEGRAL_KERNELS")
192elif args.function_to_benchmark ==
"riemannProblem":
193 project.constants.define_value(
"BenchmarkRiemannProblem",
"1")
195benchmark_main_file =
"../../kernel-benchmarks/KernelBenchmarksDiscontinuousGalerkinDSL-main.cpp"
196os.system(
"cp {} KernelBenchmarksDiscontinuousGalerkinDSL-main.cpp".format(benchmark_main_file))
198dg_solver.add_makefile_parameters(
199 project,
"../../../../applications/exahype2/ccz4"
202project.output.makefile.add_CXX_flag(
"-DGRAV=9.81")
206 print(f
"Enabling MLIR kernel compilation support for 3D...")
210 os.environ[
'MLIR_DIMENSIONS'] =
"3"
213 project.output.makefile.add_cpp_file(
"MLIRbridge.cpp")
214 project.output.makefile.add_CXX_flag(
"-DUSE_MLIR")
217 project.output.makefile.add_linker_flag(
"-lomp")
218 project.output.makefile.add_linker_flag(
"-lomptarget")
220 print(
"Enabling MLIR GPU kernel compilation support")
221 project.output.makefile.d[
"MLIR_GPU"] =
True
222 project.output.makefile.add_CXX_flag(
"-DMLIR_GPU")
223 project.output.makefile.add_linker_flag(
"-ldl")
224 project.output.makefile.add_linker_flag(
"-pthread")
228 project.output.makefile.d[
"MLIR_SOURCES_GPU"] = f
"dg_cellIntegral3d.mlir"
229 project.output.makefile.d[
"MLIR_LL_FILE_GPU"] = f
"dg_cellIntegral3d_gpu.ll"
230 project.output.makefile.d[
"MLIR_OBJECT_GPU"] = f
"dg_cellIntegral3d_mlir_gpu.o"
232 if project.output.makefile.d[
"GPU_VENDOR"] ==
"NVIDIA":
233 project.output.makefile.d[
"MLIR_GPU_NVIDIA"] =
True
234 project.output.makefile.add_CXX_flag(
"-DMLIR_GPU_NVIDIA")
235 CUDA_HOME = os.path.dirname(subprocess.check_output(
"which nvcc", shell=
True).decode().strip())
236 project.output.makefile.add_cpp_file(
"MLIRbridgeCUDAfunctions.cpp")
237 project.output.makefile.add_linker_flag(
"-lcuda")
238 project.output.makefile.add_linker_flag(
"-lcudart")
239 project.output.makefile.add_linker_flag(
"-lmlir_cuda_runtime")
240 project.output.makefile.add_linker_flag(f
"-L{CUDA_HOME}/../targets/sbsa-linux/lib")
241 cuda_bridge_header_file =
"../../../../python/exahype2/dslhype/MLIRbridgeCUDAfunctions.h"
242 cuda_bridge_file =
"../../../../python/exahype2/dslhype/MLIRbridgeCUDAfunctions.cpp"
243 os.system(
"cp {} MLIRbridgeCUDAfunctions.h".format(cuda_bridge_header_file))
244 os.system(
"cp {} MLIRbridgeCUDAfunctions.cpp".format(cuda_bridge_file))
245 elif project.output.makefile.d[
"GPU_VENDOR"] ==
"AMD":
246 project.output.makefile.d[
"MLIR_GPU_AMD"] =
True
247 project.output.makefile.add_CXX_flag(
"-DMLIR_GPU_AMD")
248 ROCM_HOME = os.path.dirname(subprocess.check_output(
"which hipcc", shell=
True).decode().strip()) +
"/.."
249 os.environ[
"ROCM_HOME"] = ROCM_HOME
250 project.output.makefile.add_cpp_file(
"MLIRbridgeHIPfunctions.cpp")
251 project.output.makefile.add_CXX_flag(
"-D__HIP_PLATFORM_AMD__")
252 project.output.makefile.add_linker_flag(
"-lamdhip64")
253 project.output.makefile.add_CXX_flag(f
"-I{ROCM_HOME}/include")
254 project.output.makefile.add_linker_flag(
"-lmlir_rocm_runtime")
255 hip_bridge_header_file =
"../../../../python/exahype2/dslhype/MLIRbridgeHIPfunctions.h"
256 hip_bridge_file =
"../../../../python/exahype2/dslhype/MLIRbridgeHIPfunctions.cpp"
257 os.system(
"cp {} MLIRbridgeHIPfunctions.h".format(hip_bridge_header_file))
258 os.system(
"cp {} MLIRbridgeHIPfunctions.cpp".format(hip_bridge_file))
260 raise RuntimeError(
"Unknown GPU vendor, please set it when configuring Peano with --with-gpu-vendor")
262 project.output.makefile.d[
"MLIR_ENABLED"] =
True
263 project.output.makefile.d[
"MLIR_PHYSICS_FILE"] = f
"ccz4_physics.mlir"
264 project.output.makefile.d[
"MLIR_SOURCES"] = f
"dg_cellIntegral3d.mlir"
265 project.output.makefile.d[
"MLIR_LL_FILE"] = f
"dg_cellIntegral3d.ll"
266 project.output.makefile.d[
"MLIR_OBJECT"] = f
"dg_cellIntegral3d_mlir.o"
267 project.output.makefile.d[
"MLIR_SOURCES_OMP"] = f
"dg_cellIntegral3d_omp.mlir"
268 project.output.makefile.d[
"MLIR_LL_FILE_OMP"] = f
"dg_cellIntegral3d_omp.ll"
269 project.output.makefile.d[
"MLIR_OBJECT_OMP"] = f
"dg_cellIntegral3d_mlir_omp.o"
271 project.output.makefile.add_CXX_flag(
"-DASSESS_MLIR_KERNELS")
274if args.enable_cpp
or not args.enable_mlir:
275 project.output.makefile.add_CXX_flag(
"-DASSESS_CPP_KERNELS")
277project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)
CCZ4 solver using Runge-Kutta Discontinuous Galerkin and global adaptive time stepping incl enclave t...