system testing for pde frameworks - tools and …...gitlab ci uses configuration files under...

1
System testing for PDE frameworks - tools and experiences Dominic Kempf 1 , Peter Bastian 1 , Timo Koch 2 , Bernd Flemisch 2 [1] IWR, Heidelberg University, Germany, [2] LH2, University of Stuttgart, Germany Dune: A flexible framework for the solution of PDEs The Distributed and Unified Numerics Environment is a flexible open source framework for the numerical solution of partial differential equations with grid-based methods. Dune is currently developed at roughly 10 universities in Europe and has an even wider user base. The underlying idea of Dune is to cre- ate slim interfaces allowing an efficient use of legacy and/or new li- braries. Modern C++ programming techniques enable very different implementations of the same concept (i.e. grids, solvers, ...) using a common interface at a very low overhead. Thus Dune ensures efficiency in scientific computations and supports high-performance computing applications. Dune is also used as a basic building block of domain specific application frameworks like DuMuX. This work is carried out in collaboration with the DuMuX development team. System testing for PDE models Testing is a proven key concept for the development of sustainable, high quality research software. In contrast to unit testing, where soft- ware components are tested individually, system testing is about the complex interplay of many such components. In the context of nu- merical frameworks for the solution of PDEs, system testing refers to the combination of framework components into a full simulation executable. Some problems in defining these tests systematically arise: The combinatoric product of framework features is unfeasibly large. The mathematical input to a framework is by definition infinite- dimensional. Definition of test samples needs expert knowledge. We therefore aim for an approach, where one systemtest is one hand-written simulation executable with a description of the reason- able variability for this model. Simulation Dimen- sion 1 2 3 4+ Grids (non-) over- lapping (non-) conforming (un) structured globally/ locally refined simplices/ quadri- laterals (non-) conforming (non-) manifold Discreti- zation CG/DG cell/vertex- centered FVM time dis- cretization polynomial degree Solver pre- conditioner dof ordering blocking iterative / direct grid (in-) dependent parallel / sequential Model (non-) linear (in) stationary scalar/ system coefficient functions boundary conditions Another problem in system testing arises from actually determining test failure for a PDE problem. We employ a flexible strategy to wrap the actual run of the simulation executable by a python script. That allows us to do postprocessing, that C++ is not suitable for: Executable Python wrapper Exit code CTest This includes testing tools as complicated as regression testing with VTK data and testing for expected convergence rates (time or space) on a series of runs. As many developers do not feel proficient with build systems, we strongly believe that the addition of any test should involve only one line of CMake code which follows a well-defined interface. We doc- ument our CMake build system with Sphinx for that purpose. Describing variability in configuration files Our goal is to describe a set of system tests taking into account variability of some variation points. To keep the testing code base maintainable, we want to avoid code duplication and have the vari- ability description as compact as possible. We extend the syntax of the configuration file, that usually accompanies a simulation executable, to describe variability: timestep = 0.5, 1.0 | expand refinementlevel = 3 Meta Ini File under version control, describes a subset of the variability model Python script from dune-testtools, interacting with CMake Set of ini files generated in the build tree at config- ure time, one file refers to one test From this enhanced meta ini file, the test suite generates a set of reg- ular ini files at config- ure time. This expansion process is controlled by Dunes CMake build sys- tem. The relevant code is provided in the module dune-testtools. Having implemented a syntax that applies commands (preceded by a pipe symbol) to key/value pairs in configuration files, some extension come natural: timestep = 0.5, 1.0 | expand refine refinementlevel = 2, 3 | expand refine Any expansion processes with the same parameter are expanded together instead of generating the combinatoric product of variants. refinementlevel = 2, 3 | expand output = level{refinementlevel}.output Curly brackets may be used to reference the actual value of a key after expansion. These curly brackets are resolved iteratively, allowing even nested usage of curly brackets. Other implemented commands target string manipulation, simple arithmetic and exclusion constraints on the combinatoric product of variants etc. Dune is a C++ framework making excessive use of templates, hence many variation points will be of compile-time nature. We support this by adding a special group, that is parsed by CMake and turned into a set of executables with the key/value pairs becoming preprocessor variables. [__static] SOLVERTYPE = Solver1, Solver2 | expand Compile-time and run-time variations can be mixed in an ar- bitrary fashion, leading to a two stage expansion procedure: Meta Ini File + Source File Executable Executable Executable CTest CTest CTest CTest CTest CTest CTest CTest CTest Automated testing of multi-module applications (WIP) The Dune ecosystem relies heavily on modularization. User applications typically build on a stack of approximately five to twelve Dune modules. All these modules are separate git repositories. These intermodular dependencies create additional problems in continuous integration, such as: Choice of remote repositories for upstream modules Choice of a compatible set of upstream branches/revisions Distribution of build triggers towards downstream modules Error feedback from selected downstream modules Interoperability with CI systems of downstream frameworks Dune has moved all of its development to a central GitLab instance, which is also used for CI. GitLab CI uses configuration files under version control. We add a Dune-specific CI config file, that allows additional customization, such as upstream remote repositories. feature/A master releases/2.5 feature/A master releases/2.5 feature/B feature/C Upstream module Tested module Find a suitable upstream branch by applying the fol- lowing strategies: Look for manually con- figured branch in CI configuration Look for manually con- figured branch in CI configuration of other upstream modules Find the most suitable branch: Make a list of all heads in the tested repository Order them by distance of the fork-point (with heuristics as tie breakers) Look for first match of a branch of the same name in upstream repository Distributing build triggers and results between modules managed on the same GitLab instance, requires a server application that runs within the GitLab docker container implements any additional logic uses the GitLab API for build triggers etc. Additional logic is specified in the Dune-specific CI configuration file: dune-common dune-geometry dune-grid ... Tested module CI configuration Trigger from upstream Accept failures f. downstream dune-pdelab dune-alugrid User module ... This approach can be extended to bridge multiple GitLab instances to satisfy the needs of downstream frameworks like DuMuX. [1] P. Bastian, M. Blatt, A. Dedner, C. Engwer, R. Klöfkorn, M. Ohlberger, O. Sander. A generic grid interface for parallel and adaptive scientific computing. Part I: abstract framework. Computing, 2008. [2] B. Flemisch, R. Helmig et al. DuMux: DUNE for Multi-Phase, Component, Scale, Physics, ... Flow and Transport in Porous Media. Advances in Water Resources, 2011 [3] D. Kempf, T. Koch. System testing in scientific numerical software frameworks using the example of Dune. Proceedings of the Dune User Meeting 2015, accepted.

Upload: others

Post on 13-Jul-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: System testing for PDE frameworks - tools and …...GitLab CI uses configuration files under version control. We add a Dune-specific CI config file, that allows additional customization,

System testing for PDE frameworks - tools and experiences

Dominic Kempf1, Peter Bastian1, Timo Koch2, Bernd Flemisch2

[1] IWR, Heidelberg University, Germany, [2] LH2, University of Stuttgart, Germany

Dune: A flexible framework for the solution of PDEsThe Distributed and Unified Numerics Environment is a flexible opensource framework for the numerical solution of partial differentialequations with grid-based methods.

Dune is currently developed at roughly 10 universities in Europe andhas an even wider user base. The underlying idea of Dune is to cre-ate slim interfaces allowing an efficient use of legacy and/or new li-braries. Modern C++ programming techniques enable very differentimplementations of the same concept (i.e. grids, solvers, ...) usinga common interface at a very low overhead. Thus Dune ensuresefficiency in scientific computations and supports high-performancecomputing applications.

Dune is also used as a basic building block of domain specificapplication frameworks like DuMuX. This work is carried out incollaboration with the DuMuX development team.

System testing for PDE modelsTesting is a proven key concept for the development of sustainable,high quality research software. In contrast to unit testing, where soft-ware components are tested individually, system testing is about thecomplex interplay of many such components. In the context of nu-merical frameworks for the solution of PDEs, system testing refersto the combination of framework components into a full simulationexecutable. Some problems in defining these tests systematicallyarise:• The combinatoric product of framework features is unfeasibly

large.• The mathematical input to a framework is by definition infinite-

dimensional.• Definition of test samples needs expert knowledge.

We therefore aim for an approach, where one systemtest is onehand-written simulation executable with a description of the reason-able variability for this model.

Simulation

Dimen-sion

1

2 3

4+

Grids(non-)over-

lapping

(non-)conforming

(un)structured

globally/locallyrefined

simplices/quadri-laterals (non-)

conforming

(non-)manifold

Discreti-zation

CG/DG

cell/vertex-centered

FVM

time dis-cretization

polynomialdegree

Solverpre-

conditioner

dofordering

blocking

iterative/ direct

grid (in-)dependent

parallel /sequential

Model

(non-)linear

(in)stationary

scalar/system

coefficientfunctions

boundaryconditions

Another problem in system testing arises from actually determiningtest failure for a PDE problem. We employ a flexible strategy to wrapthe actual run of the simulation executable by a python script. Thatallows us to do postprocessing, that C++ is not suitable for:

Executable

Pythonwrapper

Exit code CTest

This includes testing tools as complicated as regression testingwith VTK data and testing for expected convergence rates (time orspace) on a series of runs.

As many developers do not feel proficient with build systems, westrongly believe that the addition of any test should involve only oneline of CMake code which follows a well-defined interface. We doc-ument our CMake build system with Sphinx for that purpose.

Describing variability in configuration filesOur goal is to describe a set of system tests taking into accountvariability of some variation points. To keep the testing code basemaintainable, we want to avoid code duplication and have the vari-ability description as compact as possible. We extend the syntaxof the configuration file, that usually accompanies a simulationexecutable, to describe variability:

timestep = 0.5, 1.0 | expand

refinementlevel = 3

Meta Ini Fileunder version control, describes

a subset of the variability model

Python scriptfrom dune-testtools, interacting with CMake

Set of ini filesgenerated in the build tree at config-

ure time, one file refers to one test

From this enhanced metaini file, the test suitegenerates a set of reg-ular ini files at config-ure time. This expansionprocess is controlled byDunes CMake build sys-tem. The relevant codeis provided in the moduledune-testtools.

Having implemented a syntax that applies commands (precededby a pipe symbol) to key/value pairs in configuration files, someextension come natural:

timestep = 0.5, 1.0 | expand refine

refinementlevel = 2, 3 | expand refine

Any expansion processes with the same parameter are expandedtogether instead of generating the combinatoric product of variants.

refinementlevel = 2, 3 | expand

output = level{refinementlevel}.output

Curly brackets may be used to reference the actual value of akey after expansion. These curly brackets are resolved iteratively,allowing even nested usage of curly brackets.

Other implemented commands target string manipulation, simplearithmetic and exclusion constraints on the combinatoric product ofvariants etc.

Dune is a C++ framework making excessive use of templates,hence many variation points will be of compile-time nature. Wesupport this by adding a special group, that is parsed by CMake andturned into a set of executables with the key/value pairs becomingpreprocessor variables.

[__static]

SOLVERTYPE = Solver1, Solver2 | expand

Compile-time and run-time variations can be mixed in an ar-bitrary fashion, leading to a two stage expansion procedure:

Meta Ini File+ Source File

Executable

Executable

Executable

CTest

CTest

CTest

CTest

CTest

CTest

CTest

CTest

CTest

Automated testing of multi-module applications (WIP)The Dune ecosystem reliesheavily on modularization. Userapplications typically build ona stack of approximately fiveto twelve Dune modules. Allthese modules are separate gitrepositories. These intermodular dependencies create additionalproblems in continuous integration, such as:

• Choice of remote repositories for upstream modules• Choice of a compatible set of upstream branches/revisions• Distribution of build triggers towards downstream modules• Error feedback from selected downstream modules• Interoperability with CI systems of downstream frameworks

Dune has moved all of its development to a central GitLab instance,which is also used for CI. GitLab CI uses configuration files underversion control. We add a Dune-specific CI config file, that allowsadditional customization, such as upstream remote repositories.

featu

re/A

master

release

s/2.5

featu

re/A

master

release

s/2.5

featu

re/B

featu

re/C

Upstream

module

Testedmodule

Find a suitable upstreambranch by applying the fol-lowing strategies:• Look for manually con-

figured branch in CIconfiguration

• Look for manually con-figured branch in CIconfiguration of otherupstream modules

• Find the most suitablebranch:– Make a list of all heads in the tested repository– Order them by distance of the fork-point (with heuristics as tie

breakers)– Look for first match of a branch of the same name in upstream

repository

Distributing build triggers and results between modules managed onthe same GitLab instance, requires a server application that• runs within the GitLab docker container• implements any additional logic• uses the GitLab API for build triggers etc.

Additional logic is specified in the Dune-specific CI configuration file:

dune-common

dune-geometry

dune-grid

...

Tested module

CI configuration

Trigger from

upstream

Accept failures

f. downstream

dune-pdelab

dune-alugrid

User module

...

This approach can be extended to bridge multiple GitLab instancesto satisfy the needs of downstream frameworks like DuMuX.

[1] P. Bastian, M. Blatt, A. Dedner, C. Engwer, R. Klöfkorn, M. Ohlberger, O. Sander. A generic grid interface for parallel and adaptive scientific computing. Part I: abstract framework. Computing, 2008.[2] B. Flemisch, R. Helmig et al. DuMux: DUNE for Multi-Phase, Component, Scale, Physics, ... Flow and Transport in Porous Media. Advances in Water Resources, 2011[3] D. Kempf, T. Koch. System testing in scientific numerical software frameworks using the example of Dune. Proceedings of the Dune User Meeting 2015, accepted.