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):
94 "tarch/accelerator/Device.h"
106 from .generators.DefaultSimulationMain
import DefaultSimulationMain
112 from .generators.SolverRepositoryGenerator
import SolverRepositoryGenerator
121 self.
compiler = peano4.api.taskgraph.compiler.Sequential.translate
125 """! Set load balancing scheme
127 The load balancing scheme controls how subtress are distributed both
128 among ranks and threads, i.e. the instance is important for MPI but
129 also whenever you use any multithreading strategy.
131 Similar to set_multicore_orchestration(), you have to let the project
132 know about where the load balancing is held. If you rely on the
133 load balancing toolbox and if you have configured Peano with the
134 load balancing toolbox, then simply adding the right eader is
137 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
138 project.add_mainfile_include( "toolbox/loadbalancing/strategies/Hardcoded.h)
139 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
141 If you use a bespoke load balancing, you also have to add the
142 implementation file or hosting library to the project.
144 @param load_balancer_name: string
145 Should be full-qualified name of the load balancer.
146 By default, I recommend to pass "toolbox::loadbalancing::strategies::RecursiveSubdivision".
148 @param load_balancer_arguments: string
149 If your load balancing requires parameters, add them
150 here. It is a string that will be copied into the C++ class instantiation.
151 Please add the brackets yourself, i.e. "(3,4,5)" is fine, but "3,4,5" is not.
152 The only exception is the empty parameter list. Here, you can/should simply
153 add the empty string.
160 """! Set a log filter file name
162 Pass in the empty string, if you don't want the code to use the
163 hard-coded defaults. That is, by default an ExaHyPE2 application
164 searches for a file exahype2.log-filter. Through this call, you can
165 instruct the project to use another filter file.
167 @param file_name String
168 Name of the log filter file that the application should load on
176 """! Set number of threads to use
178 Pass in number of threads (positive integer) or a string such as
179 "tarch::multicore::Core::UseDefaultNumberOfThreads". Please note that
180 this value is handed through to Peano which in turn passes it on the
181 tarch::multicore::Core::configure(int). It then depends on the
182 multithreading backend if this backend allows you to set the thread
183 count manually. Many backends (such as OpenMP) do not allow this,
184 but require users to use environment variables (or scheduler options)
192 """! Set orchestration
194 The orchestration accepts one value which is a C++ statement. This
195 value has to be a string which creates an orchestration object,
196 i.e. an object of the type tarch::multicore::orchestration::Orchestration,
199 You can either create it directly (in this case you need to add a new),
200 or you can use a factory method such as
201 tarch::multicore::orchestration::StrategyFactory::createDefaultStrategy().
203 Depending on where you come from, you might have to add the strategy's
204 header file to the project explicitly. By default, the ExaHyPE 2
205 project only is aware of very few strategies. Here's an example:
207 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
208 project.add_mainfile_include( "tarch/multicore/orchestration/Hardcoded.h")
209 project.set_multicore_orchestration(
210 "new benchmarks::exahype2::ccz4::MulticoreOrchestration()"
212 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
214 @see exahype2.Project.add_mainfile_include()
215 @param value C++ expression delivering a new orchestration object on the heap
223 value has to be a number greater or equal to zero, this then sets the
224 timeout in seconds after which a node waiting for an MPI message shall
225 quit an shutdown the whole application with an error report.
226 If zero is passed, this feature is switched off and nodes will wait
230 raise Exception(
"Timeout has to be greater or equal to 0")
235 """! Set the C++ class the generated main instantiates to report on steps
238 Fully qualified C++ class name (e.g. "peano4::DefaultStepReport",
239 the default) of a peano4::RunMultipleSteps::Report subclass. The
240 generated main creates exactly one instance of it, so the class
241 has to be default-constructible. If you pass in anything other
242 than the default, its header is not included automatically - you
243 have to make it visible to the generated main yourself.
249 """! Set GPUs to be used
250 value is a list of integers or the empty list if you want the code to
251 use all GPUs that are visible to a rank.
257 The standard extensions that I use for both Peano and ExaHyPE.
259 LibraryDebug =
"_debug"
261 LibraryTrace =
"_trace"
262 LibraryAsserts =
"_asserts"
263 LibraryStats =
"_stats"
268 Path (relative or absolute) to the src directory of Peano. This path
269 should hold both the headers (in subdirectories) and all the static
272 mode: peano4.api.output.CompileMode
282 self._peano_project.cleanup()
286 We export ExaHyPE's constants. Besides the constants from ExaHyPE,
287 we also export some parameters from Peano onto the ExaHyPE constants
288 file. Therefore, it is important that you parse the configure output
289 before we export the constants.
291 peano_project: peano4.api.Project
292 The Peano 4 project that generate_Peano4_project() is currently
293 assembling. It is a local variable there, not an attribute -
294 merely passed through here, so this routine can export onto it.
296 peano_project.constants.clear()
306 peano_project.constants.add_include(
"""#include <bitset>""")
307 peano_project.constants.add_include(
"""#include "tarch/la/Vector.h" """)
308 peano_project.constants.add_include(
"""#include "peano4/utils/Globals.h" """)
309 peano_project.constants.export_const_with_type(
310 "DomainOffset", offset_string,
"tarch::la::Vector<Dimensions,double>"
312 peano_project.constants.export_const_with_type(
313 "DomainSize", size_string,
"tarch::la::Vector<Dimensions,double>"
317 peano_project.constants.export(
321 peano_project.constants.export(
322 "MaxTerminalTime",
"std::numeric_limits<double>::max()"
325 peano_project.constants.export_boolean_sequence(
"PeriodicBC", self.
_periodic_BC)
327 build_string =
"python3 "
331 peano_project.constants.export_string(
"BuildInformation", build_string)
332 peano_project.constants.export_string(
333 "ConfigureInformation", peano_project.output.makefile.configure_call
338 if readme_descriptor
is not None:
339 peano_project.output.readme.add_entry(readme_descriptor)
347 periodic_BC=[False, False, False],
351 ! Set the global simulation parameters
353 @param dimensions: 2 or 3
355 @param offset: [Float]
356 Has to have dimension number of entries.
359 Has to have dimension number of entries and all of them have to be
360 positive. At this point, we strongly suggest that all size entries
361 are exactly the same. While Peano and ExaHyPE do support anisotropic
362 meshes, most compute kernels do not, so working with something else
363 than a square or cube will likely break all numerics.
365 @param max_end_time: Float
366 If you set it zero (or actually any value smaller than min_end_time), then
367 the code will run until the cell that lags behind the most hits the min time.
368 If you specify a valid max time however, you can stop the sim as soon as the
369 most advanced cell exceeds this threshold.
371 There are no plot settings here: when and how often to plot is
372 configured per solver on its plotter, e.g.
373 exahype2.api.fv.PlotAsVTKFile.
381 ),
"domain offset vector and dimensions don't match"
384 ),
"domain offset vector and dimensions don't match"
390 for d
in range(0, dimensions):
399 print(
"Couldn't create the defined output path, please ensure that this path exists")
404 _EXAHYPE_PACKAGE_DESCRIPTION =
"""
408This code uses ExaHyPE in its second generation. The first generation of the
409code was developed through an EU FET HPC project called ExaHyPE. This first
410generation was built on top of Peano in its third generation. The present
411code uses ExaHyPE 2 which is a complete rewrite built on top of Peano 4. We
412do not yet have a release paper for this second generation of ExaHyPE, and
413thus appreciate any citation of the original release paper
415 @article{Reinarz:2020:ExaHyPE,
416 title = {ExaHyPE: An engine for parallel dynamically adaptive simulations of wave problems},
417 journal = {Computer Physics Communications},
422 doi = {https://doi.org/10.1016/j.cpc.2020.107251},
423 url = {https://www.sciencedirect.com/science/article/pii/S001046552030076X},
424 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},
425 keywords = {Hyperbolic, PDE, ADER-DG, Finite volumes, AMR, MPI, TBB, MPI+X},
426 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.
428 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.
436 Construct a Peano 4 project and return it
438 Build the Peano 4 project, i.e., all the action sets et al that you require
439 to run this ExaHyPE 2 application. The Peano 4 project is a local variable
440 here - a fresh peano4.api.Project - that is populated over the course of
441 this call and eventually returned.
443 This routine generates a Peano project, i.e. the domain-specific ExaHyPE
444 view is translated into a Peano model. As the Peano project is not kept
445 around as an attribute, calling generate_Peano4_project() again after you
446 have altered the ExaHyPE setup gives you an independent, fresh snapshot of
447 the Peano setup rather than an accumulation on top of a stale one.
456 peano_project.output.makefile.set_dimension(self.
_dimensions)
458 peano_project.output.makefile.set_mode(self.
_build_mode)
475 solver.generate_solver_realisation(
476 self, peano_project, setup_simulation, time_step, plot, mesh_adaptation
484 peano4.api.taskgraph.wait_for_visualisations()
491 setup_simulation_steps = self.
compiler(setup_simulation,
"SetupSimulation", peano_project)
492 time_step_steps = self.
compiler(time_step,
"TimeStep", peano_project)
493 plot_steps = self.
compiler(plot,
"Plot", peano_project)
494 mesh_adaptation_steps = self.
compiler(mesh_adaptation,
"MeshAdaptation", peano_project)
512 sequences = [setup_simulation_steps, time_step_steps, plot_steps]
514 (setup_simulation_steps, time_step_steps),
515 (setup_simulation_steps, plot_steps),
516 (time_step_steps, plot_steps),
517 (plot_steps, time_step_steps),
518 (time_step_steps, time_step_steps),
519 (plot_steps, plot_steps),
521 if mesh_adaptation_steps:
522 sequences.append(mesh_adaptation_steps)
524 (time_step_steps, mesh_adaptation_steps),
525 (mesh_adaptation_steps, time_step_steps),
526 (mesh_adaptation_steps, plot_steps),
528 propagate_use_statements(sequences, edges=edges)
535 derive_load_store_compute_flag(
536 setup_simulation_steps + time_step_steps + plot_steps + mesh_adaptation_steps
543 peano4.api.taskgraph.wait_for_visualisations()
549 for step
in setup_simulation_steps + time_step_steps + plot_steps + mesh_adaptation_steps:
550 peano_project.solversteps.add_step(step)
557 peano4.api.taskgraph.create_runner(peano_project,
"SetupSimulation", setup_simulation_steps)
558 peano4.api.taskgraph.create_runner(peano_project,
"TimeStep", time_step_steps)
559 peano4.api.taskgraph.create_runner(peano_project,
"Plot", plot_steps)
560 peano4.api.taskgraph.create_runner(peano_project,
"MeshAdaptation", mesh_adaptation_steps)
571 One boolean per axis (dimensions entries) telling whether the domain
572 is periodic along this axis. Read-only copy - @see
573 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.
_periodic_BC
One boolean per axis (dimensions entries) telling whether the domain is periodic along this axis.
set_multicore_orchestration(self, value)
Set orchestration.
_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)
! Set the global simulation parameters
__export_constants(self, peano_project)
We export ExaHyPE's constants.
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.
_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...
_log_filter_file
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.
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...
_timeout
Set timeout value has to be a number greater or equal to zero, this then sets the timeout in seconds ...
_EXAHYPE_PACKAGE_DESCRIPTION
_domain_offset
! Set the global simulation parameters
str _EXAHYPE_PACKAGE_DESCRIPTION
_multicore_orchestration
Set orchestration.
_number_of_threads
Set number of threads to use.
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.
_load_balancer_name
Set load balancing scheme.
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)
_step_report_class
Set the C++ class the generated main instantiates to report on steps.
periodic_BC(self)
One boolean per axis (dimensions entries) telling whether the domain is periodic along this axis.
_min_terminal_time
include <bitset>
Singleton logger for the Peano 4 Python API.
Represents a Peano 4 project.
Holds a sequence of Task instances.