Johann Rudi, Youngjun Lee, Aidan H. Chadha, Mohamed Wahib, Klaus Weide, Jared P. O'Neal, Anshu Dubey
{"title":"CG-Kit:适用于 Flash-X 流体动力学模拟的代码生成工具包,用于源代码的性能和可维护变量","authors":"Johann Rudi, Youngjun Lee, Aidan H. Chadha, Mohamed Wahib, Klaus Weide, Jared P. O'Neal, Anshu Dubey","doi":"arxiv-2401.03378","DOIUrl":null,"url":null,"abstract":"CG-Kit is a new code generation toolkit that we propose as a solution for\nportability and maintainability for scientific computing applications. The\ndevelopment of CG-Kit is rooted in the urgent need created by the shifting\nlandscape of high-performance computing platforms and the algorithmic\ncomplexities of a particular large-scale multiphysics application: Flash-X.\nThis combination leads to unique challenges including handling an existing\nlarge code base in Fortran and/or C/C++, subdivision of code into a great\nvariety of units supporting a wide range of physics and numerical methods,\ndifferent parallelization techniques for distributed- and shared-memory systems\nand accelerator devices, and heterogeneity of computing platforms requiring\ncoexisting variants of parallel algorithms. The challenges demand that\ndevelopers determine custom abstractions and granularity for code generation.\nCG-Kit tackles this with standalone tools that can be combined into highly\nspecific and, we argue, highly effective portability and maintainability tool\nchains. Here we present the design of our new tools: parametrized source trees,\ncontrol flow graphs, and recipes. The tools are implemented in Python. Although\nthe tools are agnostic to the programming language of the source code, we focus\non C/C++ and Fortran. Code generation experiments demonstrate the generation of\nvariants of parallel algorithms: first, multithreaded variants of the basic\nAXPY operation (scalar-vector addition and vector-vector multiplication) to\nintroduce the application of CG-Kit tool chains; and second, variants of\nparallel algorithms within a hydrodynamics solver, called Spark, from Flash-X\nthat operates on block-structured adaptive meshes. In summary, code generated\nby CG-Kit achieves a reduction by over 60% of the original C/C++/Fortran source\ncode.","PeriodicalId":501061,"journal":{"name":"arXiv - CS - Numerical Analysis","volume":"37 1","pages":""},"PeriodicalIF":0.0000,"publicationDate":"2024-01-07","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":"{\"title\":\"CG-Kit: Code Generation Toolkit for Performant and Maintainable Variants of Source Code Applied to Flash-X Hydrodynamics Simulations\",\"authors\":\"Johann Rudi, Youngjun Lee, Aidan H. Chadha, Mohamed Wahib, Klaus Weide, Jared P. O'Neal, Anshu Dubey\",\"doi\":\"arxiv-2401.03378\",\"DOIUrl\":null,\"url\":null,\"abstract\":\"CG-Kit is a new code generation toolkit that we propose as a solution for\\nportability and maintainability for scientific computing applications. The\\ndevelopment of CG-Kit is rooted in the urgent need created by the shifting\\nlandscape of high-performance computing platforms and the algorithmic\\ncomplexities of a particular large-scale multiphysics application: Flash-X.\\nThis combination leads to unique challenges including handling an existing\\nlarge code base in Fortran and/or C/C++, subdivision of code into a great\\nvariety of units supporting a wide range of physics and numerical methods,\\ndifferent parallelization techniques for distributed- and shared-memory systems\\nand accelerator devices, and heterogeneity of computing platforms requiring\\ncoexisting variants of parallel algorithms. The challenges demand that\\ndevelopers determine custom abstractions and granularity for code generation.\\nCG-Kit tackles this with standalone tools that can be combined into highly\\nspecific and, we argue, highly effective portability and maintainability tool\\nchains. Here we present the design of our new tools: parametrized source trees,\\ncontrol flow graphs, and recipes. The tools are implemented in Python. Although\\nthe tools are agnostic to the programming language of the source code, we focus\\non C/C++ and Fortran. Code generation experiments demonstrate the generation of\\nvariants of parallel algorithms: first, multithreaded variants of the basic\\nAXPY operation (scalar-vector addition and vector-vector multiplication) to\\nintroduce the application of CG-Kit tool chains; and second, variants of\\nparallel algorithms within a hydrodynamics solver, called Spark, from Flash-X\\nthat operates on block-structured adaptive meshes. In summary, code generated\\nby CG-Kit achieves a reduction by over 60% of the original C/C++/Fortran source\\ncode.\",\"PeriodicalId\":501061,\"journal\":{\"name\":\"arXiv - CS - Numerical Analysis\",\"volume\":\"37 1\",\"pages\":\"\"},\"PeriodicalIF\":0.0000,\"publicationDate\":\"2024-01-07\",\"publicationTypes\":\"Journal Article\",\"fieldsOfStudy\":null,\"isOpenAccess\":false,\"openAccessPdf\":\"\",\"citationCount\":\"0\",\"resultStr\":null,\"platform\":\"Semanticscholar\",\"paperid\":null,\"PeriodicalName\":\"arXiv - CS - Numerical Analysis\",\"FirstCategoryId\":\"1085\",\"ListUrlMain\":\"https://doi.org/arxiv-2401.03378\",\"RegionNum\":0,\"RegionCategory\":null,\"ArticlePicture\":[],\"TitleCN\":null,\"AbstractTextCN\":null,\"PMCID\":null,\"EPubDate\":\"\",\"PubModel\":\"\",\"JCR\":\"\",\"JCRName\":\"\",\"Score\":null,\"Total\":0}","platform":"Semanticscholar","paperid":null,"PeriodicalName":"arXiv - CS - Numerical Analysis","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/arxiv-2401.03378","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
CG-Kit: Code Generation Toolkit for Performant and Maintainable Variants of Source Code Applied to Flash-X Hydrodynamics Simulations
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.