20 Represents an ExaHyPE 2 project. An ExaHyPE2 project is a Peano 4
21 project with a particular set of actions (algorithmic phases)
22 that you can choose from and with particular solver types. It
23 realises a builder mechanism, i.e. you build up your ExaHyPE 2
24 project and then you finally tell the project "give me the Peano 4
25 project". From hereon, you can use this Peano 4 project to actually
26 set up the Peano 4 application.
28 The project will have a marker per cell that encodes stuff alike
29 a boundary marker. But it is also used to coordinate different
32 @see generate_Peano4_project()
38 Base class for the code generation steps that turn an ExaHyPE 2
39 Project's configuration into actual generated files.
41 generate_Peano4_project() below currently does this work inline (see
42 the "@todo Has to go into a generator" note in there); the various
43 steps it performs (writing the solver implementation files, the
44 solver repository, the main file, ...) are meant to become Generator
45 subclasses instead, of which SolverToCPPFiles is the first.
55 Add this generator's output to peano_project (a
56 peano4.api.Project-compatible object, or anything else that
57 add()'s cleanly into peano_project.output). This is the one
58 thing every Generator has to implement.
60 peano_project: peano4.api.Project
61 The Peano 4 project that self.project.generate_Peano4_project()
62 is currently assembling. It is a local variable there, not an
63 attribute - merely passed through here, so this generator can
64 add its own artefacts to it.
67 def __init__(self, namespace, project_name, executable, directory=".", subdirectory="", abstract_overwrite=True):
96 "tarch/accelerator/Device.h"
108 from .generators.DefaultSimulationMain
import DefaultSimulationMain
114 from .generators.SolverRepositoryGenerator
import SolverRepositoryGenerator
123 self.
compiler = peano4.api.taskgraph.compiler.Sequential.translate
127 """! Set load balancing scheme
129 The load balancing scheme controls how subtress are distributed both
130 among ranks and threads, i.e. the instance is important for MPI but
131 also whenever you use any multithreading strategy.
133 Similar to set_multicore_orchestration(), you have to let the project
134 know about where the load balancing is held. If you rely on the
135 load balancing toolbox and if you have configured Peano with the
136 load balancing toolbox, then simply adding the right eader is
139 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
140 project.add_mainfile_include( "toolbox/loadbalancing/strategies/Hardcoded.h)
141 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
143 If you use a bespoke load balancing, you also have to add the
144 implementation file or hosting library to the project.
146 @param load_balancer_name: string
147 Should be full-qualified name of the load balancer.
148 By default, I recommend to pass "toolbox::loadbalancing::strategies::RecursiveSubdivision".
150 @param load_balancer_arguments: string
151 If your load balancing requires parameters, add them
152 here. It is a string that will be copied into the C++ class instantiation.
153 Please add the brackets yourself, i.e. "(3,4,5)" is fine, but "3,4,5" is not.
154 The only exception is the empty parameter list. Here, you can/should simply
155 add the empty string.
162 """! Set a log filter file name
164 Pass in the empty string, if you don't want the code to use the
165 hard-coded defaults. That is, by default an ExaHyPE2 application
166 searches for a file exahype2.log-filter. Through this call, you can
167 instruct the project to use another filter file.
169 @param file_name String
170 Name of the log filter file that the application should load on
178 """! Set number of threads to use
180 Pass in number of threads (positive integer) or a string such as
181 "tarch::multicore::Core::UseDefaultNumberOfThreads". Please note that
182 this value is handed through to Peano which in turn passes it on the
183 tarch::multicore::Core::configure(int). It then depends on the
184 multithreading backend if this backend allows you to set the thread
185 count manually. Many backends (such as OpenMP) do not allow this,
186 but require users to use environment variables (or scheduler options)
194 """! Set orchestration
196 The orchestration accepts one value which is a C++ statement. This
197 value has to be a string which creates an orchestration object,
198 i.e. an object of the type tarch::multicore::orchestration::Orchestration,
201 You can either create it directly (in this case you need to add a new),
202 or you can use a factory method such as
203 tarch::multicore::orchestration::StrategyFactory::createDefaultStrategy().
205 Depending on where you come from, you might have to add the strategy's
206 header file to the project explicitly. By default, the ExaHyPE 2
207 project only is aware of very few strategies. Here's an example:
209 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
210 project.add_mainfile_include( "tarch/multicore/orchestration/Hardcoded.h")
211 project.set_multicore_orchestration(
212 "new benchmarks::exahype2::ccz4::MulticoreOrchestration()"
214 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
216 @see exahype2.Project.add_mainfile_include()
217 @param value C++ expression delivering a new orchestration object on the heap
225 value has to be a number greater or equal to zero, this then sets the
226 timeout in seconds after which a node waiting for an MPI message shall
227 quit an shutdown the whole application with an error report.
228 If zero is passed, this feature is switched off and nodes will wait
232 raise Exception(
"Timeout has to be greater or equal to 0")
237 """! Set the C++ class the generated main instantiates to report on steps
240 Fully qualified C++ class name (e.g. "peano4::DefaultStepReport",
241 the default) of a peano4::RunMultipleSteps::Report subclass. The
242 generated main creates exactly one instance of it, so the class
243 has to be default-constructible. If you pass in anything other
244 than the default, its header is not included automatically - you
245 have to make it visible to the generated main yourself.
251 """! Set GPUs to be used
252 value is a list of integers or the empty list if you want the code to
253 use all GPUs that are visible to a rank.
259 The standard extensions that I use for both Peano and ExaHyPE.
261 LibraryDebug =
"_debug"
263 LibraryTrace =
"_trace"
264 LibraryAsserts =
"_asserts"
265 LibraryStats =
"_stats"
270 Path (relative or absolute) to the src directory of Peano. This path
271 should hold both the headers (in subdirectories) and all the static
274 mode: peano4.api.output.CompileMode
282 Add a solver, or a host of several coupled solvers
284 @param solver: exahype2.api.Solver or a coupling
285 A coupling (e.g. exagrype.api.FOSOSolver) brings its solvers along,
286 i.e. it has an attribute solvers. The project registers each of them
287 with its solver repository and README, but lets the coupling realise
288 them (generate_solver_realisation()), so it can couple the task
289 graphs of its solvers.
292 if hasattr(solver,
"solvers"):
293 self.
_solvers.extend(solver.solvers)
301 self._peano_project.cleanup()
305 We export ExaHyPE's constants. Besides the constants from ExaHyPE,
306 we also export some parameters from Peano onto the ExaHyPE constants
307 file. Therefore, it is important that you parse the configure output
308 before we export the constants.
310 peano_project: peano4.api.Project
311 The Peano 4 project that generate_Peano4_project() is currently
312 assembling. It is a local variable there, not an attribute -
313 merely passed through here, so this routine can export onto it.
315 peano_project.constants.clear()
325 peano_project.constants.add_include(
"""#include <bitset>""")
326 peano_project.constants.add_include(
"""#include "tarch/la/Vector.h" """)
327 peano_project.constants.add_include(
"""#include "peano4/utils/Globals.h" """)
328 peano_project.constants.export_const_with_type(
329 "DomainOffset", offset_string,
"tarch::la::Vector<Dimensions,double>"
331 peano_project.constants.export_const_with_type(
332 "DomainSize", size_string,
"tarch::la::Vector<Dimensions,double>"
336 peano_project.constants.export(
340 peano_project.constants.export(
341 "MaxTerminalTime",
"std::numeric_limits<double>::max()"
344 peano_project.constants.export_boolean_sequence(
"PeriodicBC", self.
_periodic_BC)
346 build_string =
"python3 "
350 peano_project.constants.export_string(
"BuildInformation", build_string)
351 peano_project.constants.export_string(
352 "ConfigureInformation", peano_project.output.makefile.configure_call
357 if readme_descriptor
is not None:
358 peano_project.output.readme.add_entry(readme_descriptor)
366 periodic_BC=[False, False, False],
370 ! Set the global simulation parameters
372 @param dimensions: 2 or 3
374 @param offset: [Float]
375 Has to have dimension number of entries.
378 Has to have dimension number of entries and all of them have to be
379 positive. At this point, we strongly suggest that all size entries
380 are exactly the same. While Peano and ExaHyPE do support anisotropic
381 meshes, most compute kernels do not, so working with something else
382 than a square or cube will likely break all numerics.
384 @param max_end_time: Float
385 If you set it zero (or actually any value smaller than min_end_time), then
386 the code will run until the cell that lags behind the most hits the min time.
387 If you specify a valid max time however, you can stop the sim as soon as the
388 most advanced cell exceeds this threshold.
390 There are no plot settings here: when and how often to plot is
391 configured per solver on its plotter, e.g.
392 exahype2.api.fv.PlotAsVTKFile.
400 ),
"domain offset vector and dimensions don't match"
403 ),
"domain offset vector and dimensions don't match"
409 for d
in range(0, dimensions):
418 print(
"Couldn't create the defined output path, please ensure that this path exists")
423 _EXAHYPE_PACKAGE_DESCRIPTION =
"""
427This code uses ExaHyPE in its second generation. The first generation of the
428code was developed through an EU FET HPC project called ExaHyPE. This first
429generation was built on top of Peano in its third generation. The present
430code uses ExaHyPE 2 which is a complete rewrite built on top of Peano 4. We
431do not yet have a release paper for this second generation of ExaHyPE, and
432thus appreciate any citation of the original release paper
434 @article{Reinarz:2020:ExaHyPE,
435 title = {ExaHyPE: An engine for parallel dynamically adaptive simulations of wave problems},
436 journal = {Computer Physics Communications},
441 doi = {https://doi.org/10.1016/j.cpc.2020.107251},
442 url = {https://www.sciencedirect.com/science/article/pii/S001046552030076X},
443 author = {Anne Reinarz and Dominic E. Charrier and Michael Bader and Luke Bovard and Michael Dumbser and Kenneth Duru and Francesco Fambri and Alice-Agnes Gabriel and Jean-Matthieu Gallard and Sven K\"oppel and Lukas Krenz and Leonhard Rannabauer and Luciano Rezzolla and Philipp Samfass and Maurizio Tavelli and Tobias Weinzierl},
444 keywords = {Hyperbolic, PDE, ADER-DG, Finite volumes, AMR, MPI, TBB, MPI+X},
445 abstract = {ExaHyPE (An Exascale Hyperbolic PDE Engine) is a software engine for solving systems of first-order hyperbolic partial differential equations (PDEs). Hyperbolic PDEs are typically derived from the conservation laws of physics and are useful in a wide range of application areas. Applications powered by ExaHyPE can be run on a student's laptop, but are also able to exploit thousands of processor cores on state-of-the-art supercomputers. The engine is able to dynamically increase the accuracy of the simulation using adaptive mesh refinement where required. Due to the robustness and shock capturing abilities of ExaHyPE's numerical methods, users of the engine can simulate linear and non-linear hyperbolic PDEs with very high accuracy. Users can tailor the engine to their particular PDE by specifying evolved quantities, fluxes, and source terms. A complete simulation code for a new hyperbolic PDE can often be realised within a few hours - a task that, traditionally, can take weeks, months, often years for researchers starting from scratch. In this paper, we showcase ExaHyPE's workflow and capabilities through real-world scenarios from our two main application areas: seismology and astrophysics.
447 Program title: ExaHyPE-Engine Program Files doi: http://dx.doi.org/10.17632/6sz8h6hnpz.1 Licensing provisions: BSD 3-clause Programming languages: C++, Python, Fortran Nature of Problem: The ExaHyPE PDE engine offers robust algorithms to solve linear and non-linear hyperbolic systems of PDEs written in first order form. The systems may contain both conservative and non-conservative terms. Solution method: ExaHyPE employs the discontinuous Galerkin (DG) method combined with explicit one-step ADER (arbitrary high-order derivative) time-stepping. An a-posteriori limiting approach is applied to the ADER-DG solution, whereby spurious solutions are discarded and recomputed with a robust, patch-based finite volume scheme. ExaHyPE uses dynamical adaptive mesh refinement to enhance the accuracy of the solution around shock waves, complex geometries, and interesting features.
455 Construct a Peano 4 project and return it
457 Build the Peano 4 project, i.e., all the action sets et al that you require
458 to run this ExaHyPE 2 application. The Peano 4 project is a local variable
459 here - a fresh peano4.api.Project - that is populated over the course of
460 this call and eventually returned.
462 This routine generates a Peano project, i.e. the domain-specific ExaHyPE
463 view is translated into a Peano model. As the Peano project is not kept
464 around as an attribute, calling generate_Peano4_project() again after you
465 have altered the ExaHyPE setup gives you an independent, fresh snapshot of
466 the Peano setup rather than an accumulation on top of a stale one.
475 peano_project.output.makefile.set_dimension(self.
_dimensions)
477 peano_project.output.makefile.set_mode(self.
_build_mode)
494 solver.generate_solver_realisation(
495 self, peano_project, setup_simulation, time_step, plot, mesh_adaptation
503 peano4.api.taskgraph.wait_for_visualisations()
510 setup_simulation_steps = self.
compiler(setup_simulation,
"SetupSimulation", peano_project)
511 time_step_steps = self.
compiler(time_step,
"TimeStep", peano_project)
512 plot_steps = self.
compiler(plot,
"Plot", peano_project)
513 mesh_adaptation_steps = self.
compiler(mesh_adaptation,
"MeshAdaptation", peano_project)
531 sequences = [setup_simulation_steps, time_step_steps, plot_steps]
533 (setup_simulation_steps, time_step_steps),
534 (setup_simulation_steps, plot_steps),
535 (time_step_steps, plot_steps),
536 (plot_steps, time_step_steps),
537 (time_step_steps, time_step_steps),
538 (plot_steps, plot_steps),
540 if mesh_adaptation_steps:
541 sequences.append(mesh_adaptation_steps)
543 (time_step_steps, mesh_adaptation_steps),
544 (mesh_adaptation_steps, time_step_steps),
545 (mesh_adaptation_steps, plot_steps),
547 propagate_use_statements(sequences, edges=edges)
554 derive_load_store_compute_flag(
555 setup_simulation_steps + time_step_steps + plot_steps + mesh_adaptation_steps
562 peano4.api.taskgraph.wait_for_visualisations()
568 for step
in setup_simulation_steps + time_step_steps + plot_steps + mesh_adaptation_steps:
569 peano_project.solversteps.add_step(step)
576 peano4.api.taskgraph.create_runner(peano_project,
"SetupSimulation", setup_simulation_steps)
577 peano4.api.taskgraph.create_runner(peano_project,
"TimeStep", time_step_steps)
578 peano4.api.taskgraph.create_runner(peano_project,
"Plot", plot_steps)
579 peano4.api.taskgraph.create_runner(peano_project,
"MeshAdaptation", mesh_adaptation_steps)
590 One boolean per axis (dimensions entries) telling whether the domain
591 is periodic along this axis. Read-only copy - @see
592 set_global_simulation_parameters() to change it.
Base class for the code generation steps that turn an ExaHyPE 2 Project's configuration into actual g...
__init__(self, "Project" project)
construct_output(self, peano_project)
Add this generator's output to peano_project (a peano4.api.Project-compatible object,...
set_output_path(self, path)
set_step_report_class(self, class_name)
Set the C++ class the generated main instantiates to report on steps.
list _gpus
Set GPUs to be used value is a list of integers or the empty list if you want the code to use all GPU...
list _periodic_BC
One boolean per axis (dimensions entries) telling whether the domain is periodic along this axis.
set_multicore_orchestration(self, value)
Set orchestration.
str _Peano_src_directory
src_path: string Path (relative or absolute) to the src directory of Peano.
set_global_simulation_parameters(self, dimensions, offset, size, min_end_time, periodic_BC=[False, False, False], max_end_time=0.0)
!
__export_constants(self, peano_project)
We export ExaHyPE's constants.
str _log_filter_file
Set a log filter file name.
set_timeout(self, value)
Set timeout value has to be a number greater or equal to zero, this then sets the timeout in seconds ...
set_log_filter_file(self, file_name)
Set a log filter file name.
__init__(self, namespace, project_name, executable, directory=".", subdirectory="", abstract_overwrite=True)
generate_Peano4_project(self, verbosity=peano4.api.LoggerVerbosity.OFF)
Construct a Peano 4 project and return it.
str _load_balancer_arguments
Set load balancing scheme.
str _step_report_class
Set the C++ class the generated main instantiates to report on steps.
solver_repository_generator
set_gpus(self, value)
Set GPUs to be used value is a list of integers or the empty list if you want the code to use all GPU...
str _EXAHYPE_PACKAGE_DESCRIPTION
_build_mode
src_path: string Path (relative or absolute) to the src directory of Peano.
add_solver(self, solver)
Add a solver, or a host of several coupled solvers.
set_load_balancing(self, load_balancer_name, load_balancer_arguments="")
Set load balancing scheme.
set_number_of_threads(self, value)
Set number of threads to use.
int _timeout
Set timeout value has to be a number greater or equal to zero, this then sets the timeout in seconds ...
list _additional_includes
set_Peano4_installation(self, src_path, mode=peano4.api.output.CompileMode.RELEASE)
src_path: string Path (relative or absolute) to the src directory of Peano.
additional_includes(self)
str _load_balancer_name
Set load balancing scheme.
str _number_of_threads
Set number of threads to use.
str _multicore_orchestration
Set orchestration.
periodic_BC(self)
One boolean per axis (dimensions entries) telling whether the domain is periodic along this axis.
float _min_terminal_time
include <bitset>
Singleton logger for the Peano 4 Python API.
Represents a Peano 4 project.
Holds a sequence of Task instances.