원시데이터 수집 시스템
선정목록으로

mpi4py: Status Update After 12 Years of Development

관련 필름·전자재료 · (16) CPI(투명 폴리이미드)

기본 정보

저자
  1. Lisandro Dalcín — King Abdullah University of Science and Technology (KAUST), Thuwal, Saudi Arabia
  2. Yao-Lung L. Fang — Brookhaven National Laboratory, Upton, NY, USA
DOI
10.1109/mcse.2021.3083216
저널
Computing in Science & Engineering
발행년도
2021
발행기관
AIP Publishing
피인용수
262
라이선스
cc-by
논문 유형
–
언어
–
원문 페이지
https://doi.org/10.1109/mcse.2021.3083216
토픽
Advancements in Photolithography Techniques
OpenAlex ID
W3164436820

평가 내용

관련도
관련
사업분야
필름·전자재료 · (16) CPI(투명 폴리이미드)
부 분야
–
R&D 측면
–
확신도
–
근거 용어
–
판단 근거
임베딩 유사도 기반 평가로 '필름·전자재료 > CPI(투명 폴리이미드)' 분야에 선정된 논문입니다.
R&D 활용 포인트
–
평가 입력
–

초록

MPI for Python (mpi4py) has evolved to become the most used Python binding for the message passing interface (MPI). We report on various improvements and features that mpi4py gradually accumulated over the past decade, including support up to the MPI-3.1 specification, support for CUDA-aware MPI implementations, and other utilities at the intersection of MPI-based parallel distributed computing and Python application development.

본문 39,404자

본문 펼치기
### THEME ARTICLE: SCIENTIFIC COMPUTING WITH PYTHON ON HIGH-PERFORMANCE HETEROGENEOUS SYSTEMS ## mpi4py: Status Update After 12 Years of Development Lisandro Dalcin [, King Abdullah University of Science and Technology (KAUST), Thuwal, 23955, Saudi Arabia](https://orcid.org/0000-0001-8086-0155) Yao-Lung L. Fang [,](https://orcid.org/0000-0001-7191-1651) Brookhaven National Laboratory, Upton, NY, 11973, USA MPI for Python (mpi4py) has evolved to become the most used Python binding for the message passing interface (MPI). We report on various improvements and features that mpi4py gradually accumulated over the past decade, including support up to the MPI-3.1 specification, support for CUDA-aware MPI implementations, and other utilities at the intersection of MPI-based parallel distributed computing and Python application development. he message passing interface (MPI) is a stan- Although performance remains a dardized application program interface (API) tar- put programmer productivity in the spotlight as industry geting parallel distributed computing and demanded faster prototype-to-production cycles. During # T he message passing interface (MPI) is a standardized application program interface (API) targeting parallel distributed computing and # T featuring a message-passing paradigm for interprocess communication. The MPI standard defines the syntax and semantics of library routines and allows users to write portable parallel applications in the mainstream scientific programming languages (C/C++ and Fortran). Since its initial release in 1994, the MPI specification took parallel distributed application development by storm to quickly become the leading paradigm for largescale high-performance computing (HPC). We regard MPI dominance as still uncontested. Quality implementations are available from leading open-source projects such as MPICH <sup>a</sup> and Open MPI, <sup>b</sup> as well as from software and hardware vendors of HPC systems. In the quest for raw performance, HPC is traditionally associated with software development using compiled languages, such as C/C++ and Fortran. These languages are relatively lower level, stay close to the bare metal, and have years of accumulated experience in code optimization. Since the inception of MPI, scientific computing has experienced a gradual paradigm shift. Although performance remains a must, market forces put programmer productivity in the spotlight as industry demanded faster prototype-to-production cycles. During that time, the Python programming language grew its user base slowly but steadily and eventually became one of the most popular programming languages. Much of Python’s popularity is due to the seminal NumPy project <sup>c</sup> and its multidimensional array data structure, which fueled Python’s success in a wide variety of applications in data science, machine learning, scientific computing, and data visualization. Since its onset, Python was designed to interoperate with C codes and libraries using extension modules. This feature spurred the development of Python wrappers to popular libraries and specialized tools to ease such wrapping process. MPI for Python (mpi4py) <sup>d</sup> was not the first attempt to bring MPI and Python together. However, since its humble beginnings, mpi4py strove to provide Python bindings to MPI following two main principles: a) being feature-complete and exposing to Python as much of MPI as possible, and b) staying close to the MPI standard in both syntax and semantics, without reinventing the wheel with new or foreign APIs, and maximizing user convenience by following common Python idioms and practice. and its multidimensional array data structure, which fueled Python’s success in a wide variety of applications in data science, machine learning, scientific computing, and data visualization. Since its onset, Python was designed to interoperate with C codes and libraries using extension modules. This feature spurred the development of Python wrappers to popular libraries and specialized tools to ease such wrapping process. [ahttps://www.mpich.org](https://www.mpich.org) This article presents improvements and new fea[bhttps://www.open-mpi.org](https://www.open-mpi.org) tures added to mpi4py since the last report in the litera ture in 2008. <sup>1</sup> The material is organized as follows. First, we review some generalities about mpi4py to set the This work is licensed under a Creative Commons Attribution stage for subsequent discussions. Next, we comment 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ Digital Object Identifier 10.1109/MCSE.2021.3083216 Date of publication 24 May 2021; date of current version [chttps://numpy.org](https://numpy.org) 23 July 2021. [dhttps://mpi4py.github.io](https://mpi4py.github.io) [ahttps://www.mpich.org](https://www.mpich.org) [bhttps://www.open-mpi.org](https://www.open-mpi.org) [chttps://numpy.org](https://numpy.org) [dhttps://mpi4py.github.io](https://mpi4py.github.io) SCIENTIFIC COMPUTING WITH PYTHON ON HIGH-PERFORMANCE HETEROGENEOUS SYSTEMS on the codebase modernization mpi4py underwent before its 1.0 release. Afterward, we present our support for the latest revision of the MPI-3 standard. <sup>e</sup> With the rise of GPU (graphic processing unit) programming and CUDA-aware MPI implementations, we discuss how this model is supported in mpi4py. Following that, we present some recent mpi4py features, such as a new package for asynchronous task execution and support for efficient pickle-based communication of large-size buffer-like Python objects. Finally, we mention a few applications using mpi4py and close with conclusions and plans for future work. <mark>OVERVIEW</mark> mpi4py adopts an object-oriented API, which is natural in Python. This API is based on the MPI C++ bindings, focusing on staying as close as possible to MPI syntax and semantics. The MPI-1 standard introduced core concepts such as process groups, communication domains, and pointto-point and collective communication. The MPI-2 standard extended the feature set with one-sided operations, dynamic process management, and parallel I/O. The MPI-3 standard contributed refinements and extensions to the repertoire. mpi4py supports almost all MPI features and targets complete MPI-3.1 implementations. Nonetheless, the Python bindings can also work with legacy MPI-1 or MPI-2 implementations. mpi4py supports point-to-point and collective communication of generic Python objects by taking advantage of Python’s pickle protocol. <sup>f</sup> This approach involves serialization (deserialization) before (after) issuing any MPI communication operation. Obviously, the pickle-based communication mode necessarily involves CPU and memory overheads. However, its simplicity and convenience may offset any performance penalty, particularly when Python objects with small memory footprints are involved. mpi4py also features efficient communication of arraylike Python objects via Python’s buffer protocol. <sup>g</sup> This buffer-based communication mode has negligible overhead. As the implementation involves forwarding memory buffers to the MPI routines, the performance of user codes is on par with equivalent C/C++ or Fortran codes. Besides point-to-point and collective communication operations, Python’s buffer protocol is the primary mechanism behind mpi4py’s support for onesided operations and parallel I/O. [ehttps://www.mpi-forum.org/docs/mpi-3.1/mpi31-report.pdf](https://www.mpi-forum.org/docs/mpi-3.1/mpi31-report.pdf) [fhttps://docs.python.org/3/library/pickle.html](https://docs.python.org/3/library/pickle.html) [ghttps://docs.python.org/3/c-api/buffer.html](https://docs.python.org/3/c-api/buffer.html) Codes using mpi4py usually start with a from mpi4py import MPI import statement. The MPI module exposes many functions, classes, and methods giving access to the MPI API. The most important components in the MPI module are the Comm, Win, and File classes, whose various methods support point-to-point and collective communication, one-sided operations, and parallel I/O, respectively. <mark>CYTHON IMPLEMENTATION</mark> In its early days, before release 1.0 in 2009, mpi4py featured a dual-language implementation. A low-level extension module provided a bridge between the Python language and the MPI library, using hand-written C code calling into the Python C API and the MPI C bindings. Higher level pure Python code used the low-level C extension module to define and implement the various attributes, functions, classes, and methods that mpi4py exposed to users. Such an implementation approach was cumbersome to extend and maintain, thus hindering evolution. In 2007, the Cython project <sup>2</sup> emerged, featuring a static Python-to-C compiler with extra language extensions. Besides the obvious potential for speeding up Python code via C translation, Cython allowed for singlelanguage development of object-oriented, pythonic module interfaces with the ability to perform direct invocations to external C functions. This distinctive feature aligned perfectly with mpi4py’s needs. As a result, mpi4py’s main author joined the Cython project in its initial development stages, focusing on improving the Cython language and compiler’s feature set in aspects related to the development of Python wrappers for external C APIs. Eventually, mpi4py was rewritten in Cython from scratch. The new Cython-based implementation was released in 2009 as version 1.0. This rewrite made the codebase far easier to extend and maintain, thus lowering the bar for external contributions and enhancements to come. <mark>MPI-3 FEATURES</mark> mpi4py release 2.0 in late 2015 brought an update addressing the new features added in the MPI-3 specification. These features include matched probe and receive, nonblocking and neighborhood collective operations, and revamped one-sided operations. Matched Probe and Receive The MPI-1 standard defined a probe mechanism, allowing for inquiring incoming messages without actually receiving them. In mpi4py, users would call the Probe() or Iprobe() methods of the Comm class and, then, act on the information returned in a Status instance. For SCIENTIFIC COMPUTING WITH PYTHON ON HIGH-PERFORMANCE HETEROGENEOUS SYSTEMS example, users could query the size of the incoming message and then perform buffer allocation accordingly to prepare for the subsequent Recv() operation. In fact, this probe-and-receive approach allowed mpi4py to implement its support for point-to-point communication of generic Python objects via pickle serialization with a single MPI message. Unfortunately, the MPI-1 probe mechanism is not thread-safe. The MPI-3 standard acknowledged this deficiency and introduced a new matching mechanism to ensure race-free probe-and-receive, even when multiple threads operating on the same communicator context execute concurrently. In mpi4py, users would call Mprobe() method of the Comm class, which returns a Message instance. Afterward, the Mrecv() method of the Message class should be invoked to receive the actual message content. A nonblocking version named with an “I” prefix is also available. This MPI-3 enhancement was instrumental to mpi4py in reimplementing picklebased communication, allowing for thread-safe receive operations of generic Python objects while maintaining the efficiency of a single MPI message implementation. Nonblocking Collectives MPI-3 introduced nonblocking collective operations to allow for the overlap of computation and communication. The set of conventional blocking collectives were augmented with a new set of sibling operations named with an “I” prefix, such as Ibarrier(), Ibcast(), Iallgather(), Ialltoall(), and Ireduce(). Like other nonblocking operations in MPI, they return a Request instance to be used for subsequent completion with calls to the Wait() or Test() methods. Neighborhood Collectives The MPI-3 standard introduced a new kind of collective operation called neighborhood collectives. These new operations simplify data exchange in stencil-like computation patterns common in partial differential equation (PDE) solvers. The sparse communication pattern is expressed via “topology-aware” (Cartesian or graph) communicators. Only two collective operations have a neighborhood counterpart: all-to-all and all-gather. mpi4py supports both blocking (Neighbor_alltoall() and Neighbor_allgather()) and nonblocking (with an “I” prefix) neighborhood collectives, as well as variable-count versions (with a “v” suffix). Additionally, a generalized neighborhood all-to-all (with a “w” suffix) operation is also available. Improved One-Sided Operations The MPI-3 standard added three new atomic onesided operations, allowing for more flexibility and optimization opportunities. mpi4py exposes these new features as methods Get_accumulate(), Fetch_and_op(), and Compare_and_swap() of the Win class. Another new feature introduced in MPI-3 is the request-based one-sided operations. Some one-sided operations have a new counterpart with an “R” prefix, indicating that a Request object is returned after the call; these operations include Rput(), Rget(), Raccumulate(), and Rget_accumulate() as methods of the Win class. These request-based one-sided operations allow for an operate-and-query/wait pattern similar to nonblocking point-to-point and collective communication. Finally, there are three new window types: MPIallocated windows (created with the factory method Allocate() of the Win class), shared-memory windows (created with Allocate_shared()), and dynamic windows (created with Create_dynamic()). Memory for dynamic windows can be attached or detached by the Attach() and Detach() methods, respectively. <mark>CUDA-AWARE MPI</mark> In recent years, GPU programming—in particular, CUDA programming for NVIDIA GPUs—has become indispensable in many HPC and machine learning applications. While the MPI standard does not cover concepts like device offloading, nor does it specify the semantics of interacting with GPUs, CUDA-aware MPI has become a de facto extension of the standard. In a nutshell, most of the MPI communication routines accept pointers to device memory such that users do not have to copy data back and forth between GPU and CPU. Besides the minor coding convenience of eliminating data copy steps, direct device-to-device communication can offer substantial speedups, as shown in Figure 1. Several major MPI implementations, including MPICH, Open MPI, MVAPICH, <sup>h</sup> and Spectrum MPI, <sup>i</sup> already feature CUDA awareness. To facilitate API interoperability and zero-copy GPU data exchange, several Python GPU libraries jointly define and implement the CUDA Array Interface (CAI) protocol, <sup>j</sup> an effort that originated after the initiative of the Numba project. <sup>k</sup> The CAI largely follows the NumPy array interface protocol <sup>l</sup> and requires that all compliant objects add a new Python attribute __cuda_array_interface__, containing the raw GPU buffer address and additional metadata. This way, the [hhttp://mvapich.cse.ohio-state.edu](http://mvapich.cse.ohio-state.edu) [ihttps://www.ibm.com/products/spectrum-mpi](https://www.ibm.com/products/spectrum-mpi) [jhttps://numba.readthedocs.io/en/stable/cuda/](https://numba.readthedocs.io/en/stable/cuda/cuda_array_interface.html) [cuda_array_interface.html](https://numba.readthedocs.io/en/stable/cuda/cuda_array_interface.html) [khttps://numba.pydata.org](https://numba.pydata.org) [lhttps://numpy.org/doc/stable/reference/arrays.interface.](https://numpy.org/doc/stable/reference/arrays.interface.html) [html](https://numpy.org/doc/stable/reference/arrays.interface.html) SCIENTIFIC COMPUTING WITH PYTHON ON HIGH-PERFORMANCE HETEROGENEOUS SYSTEMS such as Numba, CuPy, <sup>m</sup> PyTorch, <sup>n</sup> cuDF, <sup>o</sup> PyArrow, <sup>p</sup> and PyCUDA. <sup>q</sup> FIGURE 1. Performance of mpi4py with CUDA-aware MPI. Two Python MPI processes send to and receive from each other a series of CuPy arrays (GPU), with sizes ranging from 1 KiB (1024 B) to 4 GiB (4 � 1024 <sup>3</sup> B), and using mpi4py buffer-based com munication with either CUDA-aware MPI or standard MPI with host-device memory copies. To establish a baseline for compar ison, we also consider a CPU version of this test using NumPy arrays. We determine the effective throughput (gigabytes per second) for each case from wall-clock time measurements (mean value of 10,000 samples for sizes less than 16 KiB, 1000 samples for sizes between 16 KiB and 1 MiB, and 10 samples for sizes larger than 1 MiB, with standard deviation less than 1% of the mean for the large array size cases). The gray line shows the baseline throughput for CPU buffer communication. The blue line shows the significant penalty from the additional host-to device and device-to-host data transfers required when using a standard MPI. The red line shows the substantial speedup achievable with CUDA-aware MPI for device-to-device data transfers (up to �15� for large data sizes). We executed these performance tests on a workstation running Ubuntu 18.04.4, with Python 3.8.8, Open MPI 4.1.1, CUDA 11.0, CuPy 9.0.0, and all [other software components installed from https://conda-forge.](https://conda-forge.org) [org. We used the in-development version of mpi4py. The hard-](https://conda-forge.org) ware consisted of a 10-core Intel Core i9-9820X 3.30 GHz CPU, 64 GiB 2666 MT/s DDR4 RAM, and two NVIDIA GeForce RTX 2080 Ti interconnected with an NVIDIA NVLink Bridge providing a nominal maximum bidirectional bandwidth of 50 GB/s. Each MPI process is bound to a different GPU. attribute filled by a producer can be correctly interpreted by a consumer. The CAI has been implemented by many Python libraries featuring GPU computing, We have collaborated with the community in the revisions of this protocol and implemented its support in mpi4py, making it straightforward to perform “MPI +CUDA programming” in Python. The use of this feature requires that a) mpi4py is built with a CUDA-aware MPI library and b) Python GPU array objects involved in MPI communication are compliant with the CAI protocol. We note, in particular, that mpi4py is by itself CUDAunaware. Whether an MPI routine can handle GPU arrays depends entirely on the underlying MPI implementation; mpi4py simply follows the CAI protocol and forwards device pointers to the MPI implementation. CUDA-unawareness in mpi4py has an important consequence: to comply with the usual MPI semantics, a GPU array must be ready (by synchronizing over the CUDA stream on which the array is being prepared/processed) before performing any MPI operation with it. <mark>ADDITIONAL FEATURES</mark> Asynchronous Task Execution Implementing the master–worker pattern within embarrassingly parallel task-based applications has been a recurrent matter among mpi4py users. Despite its conceptual simplicity, a production-ready MPI-based master–worker implementation poses some difficulties, particularly for users with limited exposure to MPI programming. mpi4py release 3.0 in late 2017 featured a new mpi4py.futures package providing a framework for the asynchronous execution of tasks on a pool of worker processes using MPI for interprocess communication. The mpi4py.futures API is high-level and user-friendly, without requiring the explicit use of any MPI primitives. mpi4py.futures is heavily based on the concurrent.futures module <sup>r</sup> from the Python standard library. More precisely, mpi4py.futures provides the MPIPoolExecutor class as a concrete implementation of the abstract concurrent. futures.Executor class. The submit() method schedules a Python callable (and any companion arguments) to be executed asynchronously and returns a Future object representing the outcome of the execution of the callable. At a later time, the Future object is queried for the execution result (in case of success) or exception (in case of failure). A set of Future objects can be passed to [mhttps://cupy.dev](https://cupy.dev) [nhttps://pytorch.org](https://pytorch.org) [ohttps://docs.rapids.ai/api/cudf/stable/](https://docs.rapids.ai/api/cudf/stable/) [phttps://arrow.apache.org](https://arrow.apache.org) [qhttps://documen.tician.de/pycuda/](https://documen.tician.de/pycuda/) [rhttps://docs.python.org/3/library/concurrent.futures.html](https://docs.python.org/3/library/concurrent.futures.html) SCIENTIFIC COMPUTING WITH PYTHON ON HIGH-PERFORMANCE HETEROGENEOUS SYSTEMS the wait() and as_completed() functions. The map() interface is also supported. By performing computations in separate processes, mpi4py.futures allows to sidestep Python’s infamous global interpreter lock (GIL). By relying on MPI for the wire-up between processes, mpi4py.futures provides a simple and convenient alternative for scaling up applications using concurrent.futures: MPI is a preconfigured and ready-to-use framework in almost all supercomputing facilities. The implementation of mpi4py.futures takes advantage of MPI dynamic process management, particularly the capabilities to spawn new MPI processes at runtime. After spawning a new set of worker processes, the master process uses a separate thread to communicate back and forth with the workers. Worker processes dedicate exclusively to execute the tasks submitted by the master until they are signaled for completion. Legacy MPI-1 implementations and some vendor MPI-2 (or even MPI-3) implementations do not support the dynamic process management features introduced in the MPI-2 standard. Additionally, job schedulers and batch systems in supercomputing facilities may pose additional restrictions or cumbersome extra configuration steps to applications requiring MPI process spawning at runtime. With these issues in mind, mpi4py.futures supports an additional, more traditional, SPMD-like (single program, multiple data) usage pattern that makes use of MPI-1 features only. User code is launched in parallel the usual way, e.g., using the mpiexec command. Afterward, MPI processes collectively enter a Python context manager set up by the MPICommExecutor class. This context manager partitions the set of processes within an existing MPI communicator (usually COMM_WORLD) into one master process and many worker processes. The master process is given access to an MPIPoolExecutor instance to submit tasks. Meanwhile, the worker processes follow a different execution path and team up to execute the tasks submitted by the master. Besides sidestepping the lack of dynamic process management features in legacy or incomplete MPI implementations, the MPICommExecutor context manager may also be useful in classic MPIbased Python applications that can take advantage of the simple master–worker approach available through the mpi4py.futures module. Support for Large-Size Objects The in-development version of mpi4py, <sup>s</sup> scheduled to be released as version 3.1 shortly, includes new facilities for efficient pickle-based communication of large-size Python objects. As mentioned earlier, mpi4py support for the communication of generic Python objects relies on pickling. The pickle protocol dates back to 1995, and its original and primary concern was supporting on-disk persistence of arbitrary Python objects. Over time, the pickle protocol evolved in successive new versions and found uses in applications related to multiprocess parallelism and distributed computing as an essential ingredient for message exchange. Many of these applications, particularly those related to data science, suffered from a longstanding issue: The pickle protocol required multiple and redundant memory copies, thus degrading performance when communicating arraylike objects with large memory footprints. As a result, PEP 574 proposed a new pickle protocol version 5, <sup>t</sup> which introduces support for out-of-band buffers, allowing for more efficient handling of objects with large memory footprints. mpi4py uses the traditional in-band handling of buffers. This approach is appropriate for communicating nonbuffer Python objects or buffer-like objects with small memory footprints. For point-to-point communication, in-band buffer handling allows for the communication of a pickled stream with a single MPI message at the expense of additional CPU and memory overhead in the pickling and unpickling steps. Communicating pickled streams with out-of-band buffers necessarily involves multiple MPI messages, thus increasing latency and hurting performance for smallsize data. However, the zero-copy savings of out-ofband buffer handling can easily outweigh the extra latency costs for large-size data. The new mpi4py.util.pkl5 module provides communicator wrapper classes reimplementing the picklebased point-to-point communication methods using pickle protocol version 5. Using this feature is as simple as wrapping an existing communicator object, either MPI.Intracomm or MPI.Intercomm, using the pkl5.Intracomm or pkl5.Intercomm wrapper classes, respectively. These wrapper classes redefine most pickle-based point-to-point communication methods to use pickle protocol 5 and out-of-band buffers. Moreover, these wrapper methods can overcome the infamous 2 <sup>31</sup> - 1 (� 2 billion) MPI message count limit by following the approaches described by Hammond et al. <sup>3</sup> Figure 2 shows the substantial performance improvement of using out-of-band buffers versus the traditional in-band approach. [shttps://github.com/mpi4py/mpi4py](https://github.com/mpi4py/mpi4py) [thttps://www.python.org/dev/peps/pep-0574/](https://www.python.org/dev/peps/pep-0574/) SCIENTIFIC COMPUTING WITH PYTHON ON HIGH-PERFORMANCE HETEROGENEOUS SYSTEMS FIGURE 2. Performance of mpi4py pickle-based communica tion. Two Python MPI processes send to and receive from each other NumPy arrays with a fixed size of 1 GiB using mpi4py pickle-based communication. We determine the effective throughput (gigabytes per second) from wall-clock time meas urements (mean value of 10 samples, with standard deviation less than 1% of the mean). mpi4py pickle-based communication uses either pickle protocol version 4 or 5 with the traditional in band handling buffers (gray-colored columns at the left and center). Even with in-band buffers, the newer protocol version 5 allows for faster (� 40%) inter-process data transfers compared to the older protocol version 4. The new mpi4py.util.pkl5 module uses protocol version 5 with out-of-band buffers (red-colored column at the right). The use of out-of-band buffers allows for a substantial speedup (� 3.5�) in effective throughput. Software and hardware are the same as described in Figure 1. The Linux kernel was configured at runtime with transparent hugepage support (THP) enabled to “always.” <mark>APPLICATIONS</mark> Over the years, mpi4py has become the de facto standard choice for creating MPI-based applications in Python. In the following, we mention a few out of the many applications that depend on mpi4py. HDF5 for Python (h5py) <sup>u</sup> is the Python wrapper for the HDF5 library, allowing reading and writing HDF5 files with a convenient and pythonic interface. HDF5 optionally supports parallel MPI I/O. At the Python level, mpi4py provides the bridge for h5py to interact with the MPI environment. [uhttps://www.h5py.org](https://www.h5py.org) The Visualization Toolkit (VTK) <sup>v</sup> is an open-source library for image processing and visualization. It includes mpi4py as one of the many third-party libraries exposed as VTK modules for internal use. VTK defines a vtkMPI4PyCommunicator class exposing a couple of routines able to convert back and forth between mpi4py and VTK communicator instances and enabling seamless interaction between mpi4py and other VTK components. yt <sup>w</sup> is an open-source toolkit for analyzing and visualizing simulation data in science and engineering. It provides a high-level abstraction to enable MPI parallelism over the built-in data structures and algorithms by simply calling yt.enable_parallelism() at the start of a script. Dask <sup>x</sup> is a flexible library for parallel computing in Python, which is widely used in data science and HPC projects. It consists of a dynamic task scheduler and parallel data structures and algorithms. The dask.distributed module provides a way to configure the distributed worker processes. The dask_mpi module <sup>y</sup> builds on top of mpi4py and dask.distributed, and provides a bridge for the Dask scheduler (running on MPI rank 0) to interact with the rest of the MPI processes acting as Dask workers. MPI4Dask <sup>4</sup> is planned to replace dask_mpi and to be integrated into dask.distributed as a communication backend. mpi4py-fft <sup>5</sup> is a Python package for distributed, multidimensional fast Fourier transforms (FFTs), <sup>6</sup> which is used in shenfun <sup>7</sup> to solve PDEs using the spectral Galerkin method and in FluidFFT <sup>8</sup> as a backend option to support a unified API for parallel FFT computations. A challenging aspect of 2-D (ptychographic) and 3-D (tomographic or ptycho-tomographic) image reconstruction is that these applications are data- and computation-intensive. MPI parallelization is critical in reducing memory stress and time to solution. Several image reconstruction packages developed in the computational microscopy community depend on mpi4py for parallel computing, including nsls2ptycho, <sup>9</sup> Adorym, <sup>10</sup> Tike, <sup>z</sup> PyNX, <sup>11</sup> and XPACK. <sup>12</sup> In a recent version of nsls2ptycho, <sup>9</sup> the GPU support is changed from PyCUDA to CuPy, allowing a unified CPU/GPU codebase thanks to CuPy’s high compatibility with NumPy, including the support for the __array_function__ protocol. <sup>aa</sup> However, if a performance bottleneck on the GPU code path is identified, the hotspot can be easily [vhttps://vtk.org](https://vtk.org) [whttps://yt-project.org/](https://yt-project.org/) [xhttps://dask.org/](https://dask.org/) [yhttps://mpi.dask.org/en/latest/](https://mpi.dask.org/en/latest/) [zhttps://tike.readthedocs.io](https://tike.readthedocs.io) [aahttps://numpy.org/neps/nep-0018-array-function-protocol.](https://numpy.org/neps/nep-0018-array-function-protocol.html) [html](https://numpy.org/neps/nep-0018-array-function-protocol.html) SCIENTIFIC COMPUTING WITH PYTHON ON HIGH-PERFORMANCE HETEROGENEOUS SYSTEMS reimplemented using cupy.ElementwiseKernel or cupy.RawKernel (depending on the type of operations needed) to reach native CUDA C++ speed. For CPU (NumPy) arrays, a simple MPI collective call (depending on the algorithm of choice) to Comm.Allreduce() is sufficient. For GPU (CuPy) arrays, there are multiple choices of communication paths: The slowest one is to copy the GPU data to and from CPU for communication, but it is usually faster to launch the MPI collective directly on a GPU array if a CUDA-aware MPI is available. <mark>CONCLUSIONS</mark> mpi4py has evolved over the years, following the footsteps of upstream efforts closely. To date, mpi4py provides MPI coverage up to the latest MPI-3.1 standard, including matched probe-and-receive, nonblocking collectives, neighborhood collectives, and new onesided operations. mpi4py has also kept a close watch on Python evolution, providing the new mpi4py.futures package for easing task-based computations, and the recent support for pickle protocol version 5 and efficient communication of arraylike objects with large memory footprints. Following industry trends such as CUDA-aware MPI and the CAI protocol, mpi4py supports current and future applications in the never-ending quest for performance. Following community guidelines, <sup>bb</sup> we plan on dropping support for Python 2 and early Python 3 releases. We also strive to keep providing prebuilt binary packages for easier installation. With the ongoing community endeavor to standardize the Python array API, <sup>cc</sup> we plan to support the new DLPack-based data exchange protocol, <sup>dd</sup> allowing for vendor-neutral GPU-aware MPI. The upcoming MPI-4.0 standard will be a major and welcome update adding new features and fixing longstanding issues like the 2 billion message count limit. We plan on supporting new MPI-4 features once this new version of the standard is implemented in major MPI implementations. <mark>ACKNOWLEDGMENTS</mark> We would like to thank all the feedback, comments, and contributions received from users over the years. We also acknowledge the collaboration with upstream MPI developers and maintainers: We thank Hui Zhou from MPICH, Jeff Squyres from Open MPI, and Hari Subramoni and Ching-Hsiang Chu from MVAPICH. We [bbhttps://numpy.org/neps/nep-0029-deprecation_policy.html](https://numpy.org/neps/nep-0029-deprecation_policy.html) [cchttps://data-apis.org/array-api/latest/](https://data-apis.org/array-api/latest/) ddThe DLPack data structure is specified in [https://github.](https://github.com/dmlc/dlpack) [com/dmlc/dlpackand](https://github.com/dmlc/dlpack) the __dlpack__ protocol based on the DLPack struct is defined as part of the Python array API v1. also thank Graham Markall for leading the community effort to revise and improve the CAI protocol. Lisandro Dalcin acknowledges the KAUST Supercomputing Laboratory for the use of its resources and the continuous help and assistance from Bilel Hadri. Yao-Lung L. Fang acknowledges ATPESC 2018 for the intensive exposure to modern HPC tools and practices, and the Advanced Computing Lab <sup>ee</sup> for providing access to the NVIDIA DGX-2 and DGX-A100 Artificial Intelligence Cluster for testing. The work of Lisandro Dalcin was supported by ECRC at KAUST. The work of Yao-Lung L. Fang was supported in part by BNL under LDRD 17029 and LDRD 20-024 and in part by DOE under Grant BES-FWP-PS001. <mark>REFERENCES</mark> 1. L. Dalcin, R. Paz, M. Storti, and J. D’Elia, “MPI for Python: Performance improvements and MPI-2 extensions,” J. Parallel Distrib. Comput., vol. 68, no. 5, pp. 655–662, [2008, doi: 10.1016/j.jpdc.2007.09.005.](http://dx.doi.org/10.1016/j.jpdc.2007.09.005) 2. S. Behnel, R. Bradshaw, C. Citro, L. Dalcin, D. S. Seljebotn, and K. Smith, “Cython: The best of both worlds,” Comput. Sci. Eng., vol. 13, no. 2, pp. 31–39, 2011, [doi: 10.1109/MCSE.2010.118.](http://dx.doi.org/10.1109/MCSE.2010.118) 3. J. R. Hammond, A. Schafer, and R. Latham,€ “To INT_MAX... and beyond! Exploring large-count support in MPI,” in Proc. Workshop Exascale MPI [Supercomputing Conf., 2014, pp. 1–8, doi: 10.1109/](http://dx.doi.org/10.1109/ExaMPI.2014.5) [ExaMPI.2014.5.](http://dx.doi.org/10.1109/ExaMPI.2014.5) 4. A. Shafi, J. M. Hashmi, H. Subramoni, and D. K. Panda, “Efficient MPI-based communication for GPU accelerated Dask applications,” 2021, arXiv:2101.08878. 5. M. Mortensen, L. Dalcin, and D. E. Keyes, “mpi4py-fft: Parallel fast Fourier transforms with MPI for Python,” J. Open Source Softw., vol. 4, no. 36, 2019, Art no. 1340, [doi: 10.21105/joss.01340.](http://dx.doi.org/10.21105/joss.01340) 6. L. Dalcin, M. Mortensen, and D. E. Keyes, “Fast parallel multidimensional FFT using advanced MPI,” J. Parallel Distrib. Comput., vol. 128, pp. 137–150, 2019, [doi: 10.1016/j.jpdc.2019.02.006.](http://dx.doi.org/10.1016/j.jpdc.2019.02.006) 7. M. Mortensen, “Shenfun: High performance spectral Galerkin computing platform,” J. Open Source Softw., [vol. 3, no. 31, 2018, Art. no. 1071, doi: 10.21105/joss.01071.](http://dx.doi.org/10.21105/joss.01071) 8. A. V. Mohanan, C. Bonamy, and P. Augier, “FluidFFT: Common API (C and Python) for fast Fourier transform HPC libraries,” J. Open Res. Softw., vol. 7, no. 1, p. 10, [2019, doi: 10.5334/jors.238.](http://dx.doi.org/10.5334/jors.238) eeThe Advanced Computing Lab is a component of the Computational Science Initiative at Brookhaven National Laboratory, supported by the U.S. Department of Energy’s Office of Science under Contract No. DE-SC0012704. SCIENTIFIC COMPUTING WITH PYTHON ON HIGH-PERFORMANCE HETEROGENEOUS SYSTEMS 9. Z. Dong et al., “High-performance multi-mode ptychography reconstruction on distributed GPUs,” in Proc. New York Sci. Data Summit, 2018, pp. 1–5, [doi: 10.1109/NYSDS.2018.8538964.](http://dx.doi.org/10.1109/NYSDS.2018.8538964) 10. M. Du et al., “Adorym: A multi-platform generic X-ray image reconstruction framework based on automatic differentiation,” Opt. Exp., vol. 29, no. 7, [pp. 10000–10035, 2021, doi: 10.1364/OE.418296.](http://dx.doi.org/10.1364/OE.418296) 11. V. Favre-Nicolin et al., “PyNX: High-performance computing toolkit for coherent X-ray imaging based on operators,” J. Appl. Crystallogr., vol. 53, no. 5, [pp. 1404–1413, Oct. 2020, doi: 10.1107/S1600576720010985.](http://dx.doi.org/10.1107/S1600576720010985) 12. S. Marchesini, A. Trivedi, P. Enfedaque, T. Perciano, and D. Parkinson, “Sparse matrix-based HPC tomography,” in Computational Science - ICCS 2020, V. V. G. Krzhizhanovskaya, M. H. ZavodszkyLees, J. J. Dongarra,� P. M. A. Sloot, S. Brissos, and J. Teixeira, Eds. Cham: [Springer, 2020, pp. 248–261, doi: 10.1007/978-3-030-](http://dx.doi.org/10.1007/978-3-030-50371-0_18) [50371-0_18.](http://dx.doi.org/10.1007/978-3-030-50371-0_18) LISANDRO DALCIN is currently a senior research scientist with King Abdullah University of Science and Technology (KAUST), Thuwal, Saudi Arabia. He held an Adjunct Research Associate position with National Scientific and Technical Research Council (CONICET), Argentina, from 2010 to 2017. He received the Ph.D. degree in engineering sciences and computational mechanics from the National University of the Littoral (UNL), Santa Fe, Argentina in 2008. He is the main author and maintainer of various Python packages related to high-performance parallel distributed computing [(mpi4py,](https://mpi4py.github.io/) [petsc4py, slepc4py) and a member of the development team](https://gitlab.com/petsc/petsc/) of [PETSc.](https://www.mcs.anl.gov/petsc/) His research interests include numerical methods in computational fluid mechanics, scalable solution methods for PDEs, and parallel computing on distributed memory architectures. Contact him at dalcinl@gmail.com. YAO-LUNG (LEO) FANG is currently an assistant scientist with Brookhaven National Laboratory (BNL), Upton, NY, USA. He is a theoretical physicist by training, specialized in quan tum optics and open quantum systems. After joining BNL, his research interests gradually shifted toward high-performance computing and quantum computing. He is best known for his works in waveguide quantum electrodynamics in the non Markovian regime and GPU acceleration for ptychography. He is a regular contributor to several efforts within the Python scientific computing ecosystem and the CuPy proj ect. He received the B.S. degree in physics from National Tai wan University, Taipei, Taiwan, in 2009, and the Ph.D. degree in physics from Duke University, Durham, NC, USA, in 2017. He has mentored several GPU Hackathon teams for Python GPU programming and is a member of the Consortium for Python Data API Standards. He is the corresponding author of this article. Contact him at leofang@bnl.gov.

섹션 본문

섹션 본문이 없습니다.

참고문헌 14건

  1. To INT_MAX... and Beyond! Exploring Large-Count Support in MPI 2014 10.1109/exampi.2014.5
  2. MPI for Python: Performance improvements and MPI-2 extensions Journal of Parallel and Distributed Computing · Elsevier BV · 2007 10.1016/j.jpdc.2007.09.005
  3. Cython: The Best of Both Worlds Computing in Science & Engineering · AIP Publishing · 2010 10.1109/mcse.2010.118
  4. FluidFFT: Common API (C++ and Python) for Fast Fourier Transform HPC Libraries Journal of Open Research Software · Ubiquity Press · 2019 10.5334/jors.238
  5. Shenfun: High performance spectral Galerkin computing platform The Journal of Open Source Software · Open Journals · 2018 10.21105/joss.01071
  6. mpi4py-fft: Parallel Fast Fourier Transforms with MPI for Python The Journal of Open Source Software · Open Journals · 2019 10.21105/joss.01340
  7. High-Performance Multi-Mode Ptychography Reconstruction on Distributed GPUs 2018 10.1109/nysds.2018.8538964
  8. Fast parallel multidimensional FFT using advanced MPI Journal of Parallel and Distributed Computing · Elsevier BV · 2019 10.1016/j.jpdc.2019.02.006
  9. Sparse Matrix-Based HPC Tomography Lecture notes in computer science · Springer Science+Business Media · 2020 10.1007/978-3-030-50371-0_18
  10. <i>PyNX</i>: high-performance computing toolkit for coherent X-ray imaging based on operators Journal of Applied Crystallography · Wiley · 2020 10.1107/s1600576720010985
  11. <i>PyNX</i>: high-performance computing toolkit for coherent X-ray imaging based on operators Journal of Applied Crystallography · Wiley · 2020 10.1107/s1600576720010985
  12. High-Performance Multi-Mode Ptychography Reconstruction on Distributed GPUs 2018 10.1109/nysds.2018.8538964
  13. Adorym: a multi-platform generic X-ray image reconstruction framework based on automatic differentiation Optics Express · Optica Publishing Group · 2021 10.1364/oe.418296
  14. Efficient MPI-based Communication for GPU-Accelerated Dask Applications 2021 10.1109/ccgrid51090.2021.00037