Peano
Loading...
Searching...
No Matches
performance-studies.py
Go to the documentation of this file.
1# This file is part of the Peano 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
7import exahype2
8import dastgen2
9
10import peano4.toolbox.particles
11import numpy as np
12
13import jinja2
14
15from SBH import KernelParallelisation
16from SBH import Limiter
17from SBH import FD4SolverWithLimiter
18from SBH import FD4SolverWithoutLimiter
19from SBH import FVSolver
20
21# See comments in README.dox
22# export PYTHONPATH=../../../../python
23# export PYTHONPATH=$PYTHONPATH:../../../../applications/ccz4
24from CCZ4Solver import CCZ4Solver_FV_GlobalAdaptiveTimeStepWithEnclaveTasking
25from CCZ4Solver import CCZ4Solver_FD4_GlobalAdaptiveTimeStepWithEnclaveTasking
26from CCZ4Solver import (
27 CCZ4Solver_FD4_SecondOrderFormulation_GlobalAdaptiveTimeStepWithEnclaveTasking,
28)
29
30from CCZ4Solver import CCZ4Solver_FV_GlobalAdaptiveTimeStep
31from CCZ4Solver import CCZ4Solver_FD4_GlobalAdaptiveTimeStep
32
33#python3 performance-studies.py -lbm tailored -s fd4-rk1-limited-ps-3 --scheduler native-no-priorities --trees 6 --interpolation-method linear -cs 5.4 --plot
34
35if __name__ == "__main__":
36 parser = argparse.ArgumentParser(
37 description="ExaHyPE 2 - CCZ4-Performance studies benchmarking script"
38 )
39 parser.add_argument(
40 "-j",
41 "--parallel-builds",
42 dest="j",
43 type=int,
44 default=-1,
45 help="Parallel builds",
46 )
47 parser.add_argument(
48 "-pd",
49 "--peano-dir",
50 dest="peanodir",
51 default="../../../../",
52 help="Peano4 directory",
53 )
54 parser.add_argument(
55 "-o",
56 "--output",
57 dest="output",
58 default="peano_sbh",
59 help="Executable name (output)",
60 )
61 parser.add_argument(
62 "-v",
63 "--verbose",
64 dest="verbose",
65 action="store_true",
66 default=False,
67 help="Verbose",
68 )
69 parser.add_argument(
70 "-et",
71 "--end-time",
72 dest="end_time",
73 type=float,
74 default=0.01,
75 help="End of simulation",
76 )
77 parser.add_argument(
78 "--trees",
79 dest="trees",
80 type=int,
81 required=True,
82 help="Number of trees (subpartitions) per rank",
83 )
84 parser.add_argument(
85 "-cs",
86 "--cell-size",
87 dest="cell_size",
88 type=float,
89 default=1.8,
90 help="Minimal cell size (AMR) or regular mesh cell size (without AMR), default=1.8",
91 )
92 parser.add_argument("-m", "--mode", dest="mode", choices=peano4.output.CompileModes, default=peano4.output.CompileModes[0], help="|".join(peano4.output.CompileModes) )
93 parser.add_argument(
94 "-amr",
95 "--amr",
96 dest="amr",
97 action="store_true",
98 default=False,
99 help="Enable AMR",
100 )
101 parser.add_argument(
102 "-p",
103 "--plot",
104 dest="plot",
105 action="store_true",
106 default=False,
107 help="Plot initial and final solution",
108 )
109 parser.add_argument(
110 "-sched",
111 "--scheduler",
112 dest="scheduler",
113 choices=[
114 "native-no-priorities",
115 "native",
116 "tailored",
117 "parallel-for",
118 "subtasks",
119 "subtasks-and-kernel-parallelisation",
120 ],
121 required=True,
122 help="Task scheduler flavours",
123 )
124 parser.add_argument(
125 "-s",
126 "--solver",
127 dest="solver",
128 choices=[
129 "fv",
130 "fd4-rk1-ps-3",
131 "fd4-rk1-ps-6",
132 "fd4-rk1-limited-ps-3",
133 "fd4-rk1-limited-ps-6",
134 ],
135 required=True,
136 help="Pick solver type",
137 )
138 parser.add_argument(
139 "--no-make",
140 dest="no_make",
141 action="store_true",
142 help="Do not compile the code after generation",
143 )
144 parser.add_argument(
145 "--interpolation-method",
146 dest="interpolation_method",
147 choices=["linear", "matrix", "secondOrder"],
148 default="linear",
149 help="Set method to interpolate between solvers",
150 )
151
152 args = parser.parse_args()
153
154 #
155 # Start of real ExaHyPE 2 script
156 #
157 project = exahype2.Project(
158 ["benchmarks", "exahype2", "ccz4"],
159 "ccz4",
160 executable=args.output,
161 )
162
163 dimensions = 3
164 offset = [-9, -9, -9]
165 domain_size = [18, 18, 18]
166
167 if args.amr:
168 max_cell_size = domain_size[0] / 3.0
169 else:
170 max_cell_size = args.cell_size
171
172
175 if "limited" in args.solver:
176 if args.scheduler == "native-no-priorities":
177 project.set_multicore_orchestration(
178 "tarch::multicore::orchestration::Hardcoded::createNative()"
179 )
180 enable_higher_priority_for_FV_tasks = False
181 parallelise_interpolation = KernelParallelisation.NONE
182 fv_kernel_parallelisation = KernelParallelisation.NONE
183 elif args.scheduler == "native":
184 project.set_multicore_orchestration(
185 "tarch::multicore::orchestration::Hardcoded::createNative()"
186 )
187 enable_higher_priority_for_FV_tasks = True
188 parallelise_interpolation = KernelParallelisation.NONE
189 fv_kernel_parallelisation = KernelParallelisation.NONE
190 elif args.scheduler == "tailored":
191 project.set_multicore_orchestration(
192 "new benchmarks::exahype2::ccz4::MulticoreOrchestration()"
193 )
194 enable_higher_priority_for_FV_tasks = True
195 parallelise_interpolation = KernelParallelisation.NONE
196 fv_kernel_parallelisation = KernelParallelisation.NONE
197 elif args.scheduler == "parallel-for":
198 project.set_multicore_orchestration(
199 "new benchmarks::exahype2::ccz4::MulticoreOrchestration()"
200 )
201 enable_higher_priority_for_FV_tasks = True
202 parallelise_interpolation = KernelParallelisation.PARALLEL_FOR
203 fv_kernel_parallelisation = KernelParallelisation.NONE
204 elif args.scheduler == "subtasks":
205 project.set_multicore_orchestration(
206 "new benchmarks::exahype2::ccz4::MulticoreOrchestration()"
207 )
208 enable_higher_priority_for_FV_tasks = True
209 parallelise_interpolation = KernelParallelisation.SUBTASKS
210 fv_kernel_parallelisation = KernelParallelisation.NONE
211 elif args.scheduler == "subtasks-and-kernel-parallelisation":
212 project.set_multicore_orchestration(
213 "new benchmarks::exahype2::ccz4::MulticoreOrchestration()"
214 )
215 enable_higher_priority_for_FV_tasks = True
216 parallelise_interpolation = KernelParallelisation.SUBTASKS
217 fv_kernel_parallelisation = KernelParallelisation.SUBTASKS
218 else:
219 assert False, "not supported yet"
220
221 added_limiter = False
222 if "fd4-rk1-ps-" in args.solver:
223 FD4PatchSize = int(args.solver[-1])
224 my_primary_solver = FD4SolverWithoutLimiter(
225 name="CCZ4SBH",
226 patch_size=FD4PatchSize,
227 min_cell_size=args.cell_size,
228 max_cell_size=max_cell_size,
229 )
230 project.add_solver(my_primary_solver)
231 added_limiter = False
232 args.end_time *= 10
233 elif "fd4-rk1-limited-ps-" in args.solver:
234 FD4PatchSize = int(args.solver[-1])
235 my_primary_solver = FD4SolverWithLimiter(
236 name="CCZ4SBH",
237 patch_size=FD4PatchSize,
238 min_cell_size=args.cell_size,
239 max_cell_size=max_cell_size,
240 parallelisation_of_interpolation=parallelise_interpolation,
241 parallelisation_of_kernels=fv_kernel_parallelisation,
242 interpolation_method=args.interpolation_method,
243 )
244
245 my_secondary_solver = Limiter(
246 name="CCZ4SBH",
247 patch_size=FD4PatchSize,
248 amend_priorities=enable_higher_priority_for_FV_tasks,
249 parallelisation_of_kernels=fv_kernel_parallelisation,
250 )
251 project.add_solver(my_primary_solver)
252 project.add_solver(my_secondary_solver)
253 added_limiter = True
254 elif "fv" in args.solver:
255 my_primary_solver = FVSolver(
256 name="CCZ4SBH",
257 patch_size=4,
258 min_cell_size=args.cell_size,
259 max_cell_size=max_cell_size,
260 )
261 project.add_solver(my_primary_solver)
262 added_limiter = False
263 args.end_time *= 10
264 else:
265 raise "unknown solver type {}".format(args.solver)
266
267
270
271 if args.plot:
272 plot_interval = args.end_time
273 else:
274 plot_interval = 0.0
275
276 project.set_global_simulation_parameters(
277 dimensions, # dimensions
278 offset,
279 domain_size,
280 args.end_time,
281 0.0,
282 plot_interval,
283 [False, False, False],
284 8, # plotter precision
285 )
286
287 project.set_output_path("./")
288
289 project.set_build_mode(peano4.output.string_to_mode(args.mode))
290
291 peano4_project = project.generate_Peano4_project(verbose=args.verbose)
292
293 my_primary_solver.add_makefile_parameters(
294 peano4_project, "../../../../applications/ccz4"
295 )
296
297 peano4_project.output.makefile.add_linker_flag("-lm -lgsl -lgslcblas")
298 peano4_project.output.makefile.add_cpp_file(
299 "../../../../applications/ccz4/libtwopunctures/TP_Utilities.cpp"
300 )
301 peano4_project.output.makefile.add_cpp_file(
302 "../../../../applications/ccz4/libtwopunctures/TP_Parameters.cpp"
303 )
304 peano4_project.output.makefile.add_cpp_file(
305 "../../../../applications/ccz4/libtwopunctures/TP_Logging.cpp"
306 )
307 peano4_project.output.makefile.add_cpp_file(
308 "../../../../applications/ccz4/libtwopunctures/TwoPunctures.cpp"
309 )
310 peano4_project.output.makefile.add_cpp_file(
311 "../../../../applications/ccz4/libtwopunctures/CoordTransf.cpp"
312 )
313 peano4_project.output.makefile.add_cpp_file(
314 "../../../../applications/ccz4/libtwopunctures/Equations.cpp"
315 )
316 peano4_project.output.makefile.add_cpp_file(
317 "../../../../applications/ccz4/libtwopunctures/FuncAndJacobian.cpp"
318 )
319 peano4_project.output.makefile.add_cpp_file(
320 "../../../../applications/ccz4/libtwopunctures/Newton.cpp"
321 )
322 if added_limiter:
323 peano4_project.output.makefile.add_cpp_file("MulticoreOrchestration.cpp")
324 # peano4_project.output.makefile.add_h_file(
325 # "../CompressedFloat.h"
326 # )
327 peano4_project.output.makefile.add_CXX_flag("-DIncludeTwoPunctures")
328 if added_limiter:
329 peano4_project.output.makefile.add_CXX_flag("-DCoupleWithFV")
330 peano4_project.output.makefile.add_cpp_file("CCZ4SBH_FV.cpp")
331 peano4_project.output.makefile.add_h_file("CCZ4SBH_FV.h")
332 peano4_project.output.makefile.add_cpp_file("CCZ4SBH_FD4.cpp")
333 peano4_project.output.makefile.add_h_file("CCZ4SBH_FD4.h")
334 elif "fv" in args.solver:
335 peano4_project.output.makefile.add_CXX_flag("-DPureFV")
336 peano4_project.output.makefile.add_cpp_file("CCZ4SBH_FV.cpp")
337 peano4_project.output.makefile.add_h_file("CCZ4SBH_FV.h")
338 else:
339 peano4_project.output.makefile.add_CXX_flag("-DPureFD4")
340 peano4_project.output.makefile.add_cpp_file("CCZ4SBH_FD4.cpp")
341 peano4_project.output.makefile.add_h_file("CCZ4SBH_FD4.h")
342
343 peano4_project.generate(throw_away_data_after_generation=False)
344 peano4_project.build(
345 make=not args.no_make, make_clean_first=True, number_of_parallel_builds=args.j
346 )
4th order Finite Differences solver with a limiter
Definition SBH.py:205
Construct 4th order Finite Differences solver without a limiter.
Definition SBH.py:568
A finite volume solver.
Definition SBH.py:692
Construct the Finite Volume (limiter) scheme.
Definition SBH.py:45