Peano
Loading...
Searching...
No Matches
kernel-benchmarks-fv-muscl-hancock-dsl.py
Go to the documentation of this file.
1# This file is part of the ExaHyPE2 project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3import os
4import argparse
5
6import peano4.api
7import exahype2
8
9from CCZ4Solver import CCZ4Solver_FV_MUSCL_GlobalAdaptiveTimeStepWithEnclaveTasking
10
11parser = argparse.ArgumentParser(
12 description="ExaHyPE 2 - CCZ4 Finite Volume MUSCL-Hancock Kernel Benchmarking Script"
13)
14parser.add_argument(
15 "-m",
16 "--build-mode",
17 choices=peano4.api.output.CompileModes,
18 default=peano4.api.output.CompileModes[0], # Release
19 help="|".join(peano4.api.output.CompileModes),
20)
21parser.add_argument(
22 "-t",
23 "--num-threads",
24 default=1,
25 type=int,
26 help="Number of launching threads",
27)
28parser.add_argument(
29 "-ps",
30 "--patch-size",
31 default=16,
32 type=int,
33 help="Number of finite volumes per axis (dimension) per patch.",
34)
35parser.add_argument(
36 "-p",
37 "--num-patches",
38 nargs="+",
39 default=[32, 64, 128, 256, 512, 1024, 2048],
40 type=int,
41 help="Number of patches to study",
42)
43parser.add_argument(
44 "-samples",
45 "--samples",
46 default=10,
47 type=int,
48 help="Number of samples per measurement",
49)
50parser.add_argument(
51 "-a",
52 "--accuracy",
53 default=0.0,
54 type=float,
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).",
56)
57parser.add_argument(
58 "-e",
59 "--eval-eig",
60 action="store_true",
61 help="Evaluate max. eigenvalue",
62)
63parser.add_argument(
64 "-cpu",
65 "--cpu",
66 action="store_true",
67 help="Assess host kernels",
68)
69parser.add_argument(
70 "-gpu",
71 "--gpu",
72 action="store_true",
73 help="Assess device kernels",
74)
75parser.add_argument(
76 "-fpe",
77 "--fpe",
78 action="store_true",
79 help="Enable a floating-point exception handler.",
80)
81parser.add_argument(
82 "-j",
83 default=-1,
84 type=int,
85 help="Number of parallel builds to use",
86)
87parser.add_argument(
88 "-d",
89 "--dimensions",
90 default=2,
91 choices = [2, 3],
92 type=int,
93 help="Number of dimensions to use: 2 or 3",
94)
95args = parser.parse_args()
96
98 name="FVMUSCLHancock",
99 patch_size=args.patch_size,
100 min_volume_h=0.001, # max_cell_size -> arbitrary value
101 max_volume_h=0.001, # min_cell_size -> arbitrary value
102 pde_terms_without_state=True,
103)
104
105project = exahype2.Project(
106 namespace=["benchmarks", "exahype2", "kernelbenchmarks"],
107 project_name="KernelBenchmarksFVMUSCLHancockDSL",
108 directory=".",
109 executable=f"KernelBenchmarksFVMUSCLHancockDSL.{args.build_mode}",
110)
111fv_muscl_solver.add_all_solver_constants()
112project.add_solver(fv_muscl_solver)
113
114project.set_global_simulation_parameters(
115 dimensions=args.dimensions,
116 size=[1.0] * args.dimensions,
117 offset=[0.0] * args.dimensions,
118 min_end_time=0.1,
119 max_end_time=0.1,
120 first_plot_time_stamp=0.0,
121 time_in_between_plots=0.0,
122 periodic_BC=[False] * args.dimensions
123)
124
125project.set_Peano4_installation("../../../../", mode=peano4.api.output.string_to_mode(args.build_mode))
126project = project.generate_Peano4_project(verbose=True)
127
128accuracy = args.accuracy
129if accuracy < 0:
130 import numpy
131 accuracy = default = numpy.finfo(float).eps
132project.constants.export_constexpr_with_type("Accuracy", str(accuracy), "double")
133
134project.constants.export_constexpr_with_type("NumberOfSamples", str(args.samples), "int")
135
136formatted_num_patches = "{{{}}}".format(", ".join(str(val) for val in args.num_patches))
137project.constants.export_const_with_type("NumberOfPatchesToStudy", str(formatted_num_patches), "tarch::la::Vector<%s, int>" % len(args.num_patches))
138
139project.constants.export_constexpr_with_type("NumberOfLaunchingThreads", str(args.num_threads), "int")
140
141if args.fpe:
142 project.constants.export_boolean("EnableFPE", True)
143else:
144 project.constants.export_boolean("EnableFPE", False)
145
146if args.cpu == False and args.gpu == False:
147 project.constants.export_boolean("AssessHostKernels", True)
148 project.constants.export_boolean("AssessDeviceKernels", True)
149else:
150 project.constants.export_boolean("AssessHostKernels", True if args.cpu else False)
151 project.constants.export_boolean("AssessDeviceKernels", True if args.gpu else False)
152
153project.constants.export_boolean("EvaluateFlux", False)
154project.constants.export_boolean("EvaluateNonconservativeProduct", True)
155project.constants.export_boolean("EvaluateSource", False)
156project.constants.export_boolean("EvaluateMaximumEigenvalueAfterTimeStep", True if args.eval_eig else False) # Reduction
157
158project.constants.define_value("GAMMA", str(1.0))
159
160benchmark_main_file = "../../kernel-benchmarks/KernelBenchmarksFVMUSCLHancockDSL-main.cpp"
161os.system("cp {} KernelBenchmarksFVMUSCLHancockDSL-main.cpp".format(benchmark_main_file))
162
163project.output.makefile.add_CXX_flag("-DGRAV=9.81")
164
165fv_muscl_solver.add_makefile_parameters(
166 project, "../../../../applications/exahype2/ccz4"
167)
168project.generate(throw_away_data_after_generation=False)
169project.build(make=True, make_clean_first=True, throw_away_data_after_build=True, number_of_parallel_builds=args.j)
170
171print(project)
172print(fv_muscl_solver)
CCZ4 solver using finite volumes and global adaptive time stepping incl enclave tasking.