CG-Kit: Code Generation Toolkit for Performant and Maintainable Variants of Source Code Applied to Flash-X Hydrodynamics Simulations
Preprint
Abstract
CG-Kit is a new code generation toolkit that we propose as a solution for portability and maintainability for scientific computing applications. The development of CG-Kit is rooted in the urgent need created by the shifting landscape of high-performance computing platforms and the algorithmic complexities of a particular large-scale multiphysics application: Flash-X. This combination leads to unique challenges including handling an existing large code base in Fortran and/or C/C++, subdivision of code into a great variety of units supporting a wide range of physics and numerical methods, different parallelization techniques for distributed- and shared-memory systems and accelerator devices, and heterogeneity of computing platforms requiring coexisting variants of parallel algorithms. The challenges demand that developers determine custom abstractions and granularity for code generation. CG-Kit tackles this with standalone tools that can be combined into highly specific and, we argue, highly effective portability and maintainability tool chains. Here we present the design of our new tools: parametrized source trees, control flow graphs, and recipes. The tools are implemented in Python. Although the tools are agnostic to the programming language of the source code, we focus on C/C++ and Fortran. Code generation experiments demonstrate the generation of variants of parallel algorithms: first, multithreaded variants of the basic AXPY operation (scalar-vector addition and vector-vector multiplication) to introduce the application of CG-Kit tool chains; and second, variants of parallel algorithms within a hydrodynamics solver, called Spark, from Flash-X that operates on block-structured adaptive meshes. In summary, code generated by CG-Kit achieves a reduction by over 60% of the original C/C++/Fortran source code.Keywords
All Related Versions
This publication has 26 references indexed in Scilit:
- A tool and a methodology to use macros for abstracting variations in code for different computational demandsFuture Generation Computer Systems, 2023
- Flash-X: A multiphysics simulation software instrumentSoftwareX, 2022
- Domain-Specific Runtime to Orchestrate Computation on Heterogeneous Platforms2022
- Towards performance portability in the Spark astrophysical magnetohydrodynamics solver in the Flash-X simulation frameworkParallel Computing, 2021
- Advanced Newton Methods for Geodynamical Models of Stokes Flow With Viscoplastic RheologiesGeochemistry, Geophysics, Geosystems, 2020
- Nebo: An efficient, parallel, and portable domain-specific language for numerically solving partial differential equationsJournal of Systems and Software, 2017
- Kokkos: Enabling manycore performance portability through polymorphic memory access patternsJournal of Parallel and Distributed Computing, 2014
- Extensible component-based architecture for FLASH, a massively parallel, multiphysics simulation codeParallel Computing, 2009
- PARAMESH: A parallel adaptive mesh refinement community toolkitComputer Physics Communications, 2000
- TXL: A rapid prototyping system for programming language dialectsComputer Languages, 1991