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/exahype2/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
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 help="Set method to interpolate between solvers",
148 )
149
150 args = parser.parse_args()
151
152 #
153 # Start of real ExaHyPE 2 script
154 #
155 project = exahype2.Project(
156 ["benchmarks", "exahype2", "ccz4"],
157 "ccz4",
158 executable=args.output,
159 )
160
161 dimensions = 3
162 offset = [-9, -9, -9]
163 domain_size = [18, 18, 18]
164
165 if args.amr:
166 max_cell_size = domain_size[0] / 3.0
167 else:
168 max_cell_size = args.cell_size
169
170
173 if "limited" in args.solver:
174 if args.scheduler == "native-no-priorities":
175 project.set_multicore_orchestration(
176 "tarch::multicore::orchestration::Hardcoded::createNative()"
177 )
178 enable_higher_priority_for_FV_tasks = False
179 parallelise_interpolation = KernelParallelisation.NONE
180 fv_kernel_parallelisation = KernelParallelisation.NONE
181 elif args.scheduler == "native":
182 project.set_multicore_orchestration(
183 "tarch::multicore::orchestration::Hardcoded::createNative()"
184 )
185 enable_higher_priority_for_FV_tasks = True
186 parallelise_interpolation = KernelParallelisation.NONE
187 fv_kernel_parallelisation = KernelParallelisation.NONE
188 elif args.scheduler == "tailored":
189 project.set_multicore_orchestration(
190 "new benchmarks::exahype2::ccz4::MulticoreOrchestration()"
191 )
192 enable_higher_priority_for_FV_tasks = True
193 parallelise_interpolation = KernelParallelisation.NONE
194 fv_kernel_parallelisation = KernelParallelisation.NONE
195 elif args.scheduler == "parallel-for":
196 project.set_multicore_orchestration(
197 "new benchmarks::exahype2::ccz4::MulticoreOrchestration()"
198 )
199 enable_higher_priority_for_FV_tasks = True
200 parallelise_interpolation = KernelParallelisation.PARALLEL_FOR
201 fv_kernel_parallelisation = KernelParallelisation.NONE
202 elif args.scheduler == "subtasks":
203 project.set_multicore_orchestration(
204 "new benchmarks::exahype2::ccz4::MulticoreOrchestration()"
205 )
206 enable_higher_priority_for_FV_tasks = True
207 parallelise_interpolation = KernelParallelisation.SUBTASKS
208 fv_kernel_parallelisation = KernelParallelisation.NONE
209 elif args.scheduler == "subtasks-and-kernel-parallelisation":
210 project.set_multicore_orchestration(
211 "new benchmarks::exahype2::ccz4::MulticoreOrchestration()"
212 )
213 enable_higher_priority_for_FV_tasks = True
214 parallelise_interpolation = KernelParallelisation.SUBTASKS
215 fv_kernel_parallelisation = KernelParallelisation.SUBTASKS
216 else:
217 assert False, "not supported yet"
218
219 added_limiter = False
220 if "fd4-rk1-ps-" in args.solver:
221 FD4PatchSize = int(args.solver[-1])
222 my_primary_solver = FD4SolverWithoutLimiter(
223 name="CCZ4SBH",
224 patch_size=FD4PatchSize,
225 min_cell_size=args.cell_size,
226 max_cell_size=max_cell_size,
227 )
228 project.add_solver(my_primary_solver)
229 added_limiter = False
230 args.end_time *= 10
231 elif "fd4-rk1-limited-ps-" in args.solver:
232 FD4PatchSize = int(args.solver[-1])
233 my_primary_solver = FD4SolverWithLimiter(
234 name="CCZ4SBH",
235 patch_size=FD4PatchSize,
236 min_cell_size=args.cell_size,
237 max_cell_size=max_cell_size,
238 parallelisation_of_interpolation=parallelise_interpolation,
239 parallelisation_of_kernels=fv_kernel_parallelisation,
240 interpolation_method=args.interpolation_method,
241 )
242
243 my_secondary_solver = Limiter(
244 name="CCZ4SBH",
245 patch_size=FD4PatchSize,
246 amend_priorities=enable_higher_priority_for_FV_tasks,
247 parallelisation_of_kernels=fv_kernel_parallelisation,
248 )
249 project.add_solver(my_primary_solver)
250 project.add_solver(my_secondary_solver)
251 added_limiter = True
252 elif "fv" in args.solver:
253 my_primary_solver = FVSolver(
254 name="CCZ4SBH",
255 patch_size=4,
256 min_cell_size=args.cell_size,
257 max_cell_size=max_cell_size,
258 )
259 project.add_solver(my_primary_solver)
260 added_limiter = False
261 args.end_time *= 10
262 else:
263 raise "unknown solver type {}".format(args.solver)
264
265
268
269 if args.plot:
270 plot_interval = args.end_time
271 else:
272 plot_interval = 0.0
273
274 project.set_global_simulation_parameters(
275 dimensions, # dimensions
276 offset,
277 domain_size,
278 args.end_time,
279 0.0,
280 plot_interval,
281 [False, False, False],
282 8, # plotter precision
283 )
284
285 project.set_output_path("./")
286 # probe_point = [-12,-12,0.0]
287 # project.add_plot_filter( probe_point,[24.0,24.0,0.01],1 )
288 # my_solver.select_dofs_to_print = [0,12,16,17,18,54,59,60]
289
290 project.set_Peano4_installation(args.peanodir, peano4.output.string_to_mode(args.mode))
291
292 peano4_project = project.generate_Peano4_project(verbose=args.verbose)
293
294 my_primary_solver.add_makefile_parameters(
295 peano4_project, "../../../../applications/exahype2/ccz4"
296 )
297
298 peano4_project.output.makefile.add_linker_flag("-lm -lgsl -lgslcblas")
299 peano4_project.output.makefile.add_cpp_file(
300 "../../../../applications/exahype2/ccz4/libtwopunctures/TP_Utilities.cpp"
301 )
302 peano4_project.output.makefile.add_cpp_file(
303 "../../../../applications/exahype2/ccz4/libtwopunctures/TP_Parameters.cpp"
304 )
305 peano4_project.output.makefile.add_cpp_file(
306 "../../../../applications/exahype2/ccz4/libtwopunctures/TP_Logging.cpp"
307 )
308 peano4_project.output.makefile.add_cpp_file(
309 "../../../../applications/exahype2/ccz4/libtwopunctures/TwoPunctures.cpp"
310 )
311 peano4_project.output.makefile.add_cpp_file(
312 "../../../../applications/exahype2/ccz4/libtwopunctures/CoordTransf.cpp"
313 )
314 peano4_project.output.makefile.add_cpp_file(
315 "../../../../applications/exahype2/ccz4/libtwopunctures/Equations.cpp"
316 )
317 peano4_project.output.makefile.add_cpp_file(
318 "../../../../applications/exahype2/ccz4/libtwopunctures/FuncAndJacobian.cpp"
319 )
320 peano4_project.output.makefile.add_cpp_file(
321 "../../../../applications/exahype2/ccz4/libtwopunctures/Newton.cpp"
322 )
323 if added_limiter:
324 peano4_project.output.makefile.add_cpp_file("MulticoreOrchestration.cpp")
325 # peano4_project.output.makefile.add_h_file(
326 # "../CompressedFloat.h"
327 # )
328 peano4_project.output.makefile.add_CXX_flag("-DIncludeTwoPunctures")
329 if added_limiter:
330 peano4_project.output.makefile.add_CXX_flag("-DCoupleWithFV")
331 peano4_project.output.makefile.add_cpp_file("CCZ4SBH_FV.cpp")
332 peano4_project.output.makefile.add_h_file("CCZ4SBH_FV.h")
333 peano4_project.output.makefile.add_cpp_file("CCZ4SBH_FD4.cpp")
334 peano4_project.output.makefile.add_h_file("CCZ4SBH_FD4.h")
335 elif "fv" in args.solver:
336 peano4_project.output.makefile.add_CXX_flag("-DPureFV")
337 peano4_project.output.makefile.add_cpp_file("CCZ4SBH_FV.cpp")
338 peano4_project.output.makefile.add_h_file("CCZ4SBH_FV.h")
339 else:
340 peano4_project.output.makefile.add_CXX_flag("-DPureFD4")
341 peano4_project.output.makefile.add_cpp_file("CCZ4SBH_FD4.cpp")
342 peano4_project.output.makefile.add_h_file("CCZ4SBH_FD4.h")
343
344 peano4_project.generate(throw_away_data_after_generation=False)
345 peano4_project.build(
346 make=not args.no_make, make_clean_first=True, number_of_parallel_builds=args.j
347 )
4th order Finite Differences solver with a limiter
Definition SBH.py:205
Construct 4th order Finite Differences solver without a limiter.
Definition SBH.py:567
A finite volume solver.
Definition SBH.py:691
Construct the Finite Volume (limiter) scheme.
Definition SBH.py:45