PECOS Predictive Engineering and Computational Sciences C++14 Generic Programming as a Domain-Specific Language for PDEs Roy H. Stogner 1 1 Institute for Computational Engineering and Sciences The University of Texas at Austin May 12, 2014 ICES R. H. Stogner C++14 PDEs May 12, 2014 1 / 14
22
Embed
C++14 Generic Programming as a Domain-Specific Language ...roystgnr/2014_roystgnr-talk.pdf · Demands C++1y (gcc 4.8.2+, clang 3.4+) return type deduction Opaque ContextType for forward
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
PECOSPredictive Engineering and Computational Sciences
C++14 Generic Programming as a Domain-SpecificLanguage for PDEs
Roy H. Stogner1
1Institute for Computational Engineering and SciencesThe University of Texas at Austin
May 12, 2014ICES
R. H. Stogner C++14 PDEs May 12, 2014 1 / 14
Goals of Multiphysics PackageWhat we would like?• Leverage preexisting kernels for various “physics” with minimal code
rewritingI Not as fine-grained as “dial-an-operator”I Trustworthy common code for different applications
• Still want to retain generality and extensibility
• Don’t sacrifice performance (too much)
• Interfaces to benefits of libMesh andunderlying libraries
I Hybrid meshingI Adaptive meshing, time steppingI Adjoint analysisI SolversI Hybrid parallelism
R. H. Stogner C++14 PDEs May 12, 2014 2 / 14
Object-Oriented Path to Multiphysics
(One) Object-Oriented Approach• Still cling to loop over elements, then quadrature, then DoF paradigm
I Can parallelize (both distributed and threaded) element loopindependent of physics kernel
• Use polymorphic functions within loop for “element” routineI vtable cost amortized by cost of residual/Jacobian calculationI May not be true if polymorphic at the quadrature level
Another Object-Oriented Approach∗
• Build graph of physics operators
• Each operator works on large blocks of quadrature points
• Fewer vtable lookups, but more loops over quadrature points
∗P. K. Notz, R. P. Pawlowski, J. C. Sutherland, “Graph-Based Software Design for Managing Complexity and Enabling Concurrency in
Multiphysics PDE Software”, ACM TOMS, 39(1), 2012
R. H. Stogner C++14 PDEs May 12, 2014 3 / 14
libMesh and FEMSystem
Highlights• Designed using first OO approach discussed
• User subclasses FEMSystem (or FEMPhysics, DifferentiableQoI)to implement (multi-)physics element routine
• Automatically access existing libMesh infrastructure without requiringuser code
I MPI+threaded parallelismI Interfaces to important packages, e.g. PETSc, Trilinos, etc.I AMR
• Lots of flexibility, but no physics repository→ no reuse of physicskernels