arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 1602.03638cs.MScs.DC
收藏

用于湍流直接数值模拟的高性能Python

High performance Python for direct numerical simulations of turbulent flows

Mikael Mortensen, Hans Petter Langtangen

摘要:

Navier-Stokes方程的直接数值模拟(DNS)是流体动力学中一个非常有价值的研究工具。尽管如此,仍然很少有公开的研究代码,由于隐含的大量数字运算,可用的代码通常是用低级语言编写的,如C/C++或Fortran。在本文中,我们描述了一个纯科学的Python伪谱DNS代码,它在数千个处理器和数十亿个未知数的情况下几乎与C++的性能相匹配。我们还描述了一个通过Cython优化的版本,该版本被发现与C++的速度相匹配。求解器是用Python从头开始编写的,包括网格、MPI域分解和时间积分器。求解器已经在KAUST超级计算实验室的Shaheen超级计算机上进行了验证和基准测试,我们能够很好地扩展到数千个核心。实现的一个非常重要的部分是网格分解(我们实现了板和铅笔分解)和3D并行快速傅立叶变换(FFT)。网格分解和FFT例程已在Python中使用串行FFT例程(NumPy,pyFFTW或任何其他串行FFT模块),NumPy数组操作以及MPI for Python(mpi 4py)处理的MPI通信来实现。我们展示了如何使用4行紧凑的Python代码在Python中执行3D并行FFT以进行平板网格分解,发现Shaheen上的并行性能略好于FFTW库提供的类似例程。对于铅笔网格分解,需要7行代码来执行变换。

英文摘要:

Direct Numerical Simulations (DNS) of the Navier Stokes equations is an invaluable research tool in fluid dynamics. Still, there are few publicly available research codes and, due to the heavy number crunching implied, available codes are usually written in low-level languages such as C/C++ or Fortran. In this paper we describe a pure scientific Python pseudo-spectral DNS code that nearly matches the performance of C++ for thousands of processors and billions of unknowns. We also describe a version optimized through Cython, that is found to match the speed of C++. The solvers are written from scratch in Python, both the mesh, the MPI domain decomposition, and the temporal integrators. The solvers have been verified and benchmarked on the Shaheen supercomputer at the KAUST supercomputing laboratory, and we are able to show very good scaling up to several thousand cores. A very important part of the implementation is the mesh decomposition (we implement both slab and pencil decompositions) and 3D parallel Fast Fourier Transforms (FFT). The mesh decomposition and FFT routines have been implemented in Python using serial FFT routines (either NumPy, pyFFTW or any other serial FFT module), NumPy array manipulations and with MPI communications handled by MPI for Python (mpi4py). We show how we are able to execute a 3D parallel FFT in Python for a slab mesh decomposition using 4 lines of compact Python code, for which the parallel performance on Shaheen is found to be slightly better than similar routines provided through the FFTW library. For a pencil mesh decomposition 7 lines of code is required to execute a transform.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑