Abstract
PBBFMM3D is an open-source C++/Python library designed to reduce the computational complexity of kernel matrix-vector multiplications from $O(N^2)$ to $O(N)$. Utilizing a "black-box" approach based on Lagrange interpolation, it enables efficient large-scale simulations for non-oscillatory kernels without requiring complex analytical expansions. This paper details the parallel implementation using OpenMP and demonstrates linear scaling and high accuracy across various datasets.
Introduction
In many scientific fields—from machine learning and geostatistics to fluid dynamics—researchers need to compute the product of a large kernel matrix and a vector. Mathematically, this is expressed as $\phi = \mathbf{K}\sigma$, where $\mathbf{K}$ is an $N \times N$ matrix defined by a kernel function $K(x, y)$.
The "naive" approach requires $O(N^2)$ operations. For a million data points, this translates to a trillion operations and terabytes of memory. While the Fast Multipole Method (FMM) was developed to solve this in $O(N)$ time, traditional FMMs are difficult to implement because they require specific analytical expansions for every new kernel function. PBBFMM3D addresses this by introducing a parallelized "black-box" version that works for any smooth, non-oscillatory kernel simply by evaluating the function.
Methods
The PBBFMM3D framework replaces complex analytical expansions with Lagrange interpolation. The core algorithm follows a hierarchical approach:
- Hierarchical Decomposition: The 3D problem domain is partitioned into an octree.
- Low-Rank Approximation: When two subdomains are far apart, the kernel interaction is approximated using polynomial interpolation (Chebyshev or equally spaced nodes), converting dense interactions into low-rank ones.
- The "Black-Box" Interface: Users only need to provide a function for $K(x, y)$, eliminating the need for manual multipole expansion derivations.
The algorithm is parallelized using OpenMP for multi-core shared-memory machines, covering four standard FMM stages:
- Upward Pass: Computing "multipole coefficients" via parallel tree traversal.
- Far-field Interaction: Computing "local coefficients" via independent M2L (moment-to-local) translations.
- Downward Pass: Accumulating coefficients down to leaf nodes.
- Near-field Interaction: Exactly computing interactions between adjacent nodes in parallel.
Results and Discussion
The algorithm was evaluated using synthetic uniform distributions and unstructured meshes (e.g., a whale-shaped mesh with $N = 693,888$ points).
Key Insights
- Interpolation Efficiency: Lagrange interpolation serves as a robust surrogate for kernel-specific expansions, providing exponential error decay for smooth kernels like $1/r$ or Gaussian kernels.
- Memory Management: For $N=640,000$, a naive matrix requires 3.2 TB of RAM. PBBFMM3D avoids explicitly forming the full matrix, significantly reducing memory overhead.
- Task-Based Parallelism: Using OpenMP tasks for tree traversals manages data dependencies effectively, ensuring parent nodes wait for children without stalling the CPU.
Performance Metrics
- Linear Scaling: Empirical tests confirmed $O(N)$ complexity, with execution time growing linearly with the number of points.
- Parallel Speedup: The implementation achieved a 19x speedup on 32 cores for problems with $N \approx 4 \times 10^6$.
- Accuracy: Error decays exponentially with interpolation order $p$. A low order (e.g., $p=4$) typically yields a relative error of $10^{-5}$.
Conclusion
PBBFMM3D is a powerful tool for accelerating kernel matrix-vector multiplications in geostatistics and physics. While currently optimized for non-oscillatory kernels on shared-memory CPUs, it provides a scalable and user-friendly alternative to traditional FMM implementations. Future work may include extensions for high-frequency oscillatory kernels and distributed-memory (MPI) architectures.
Code Availability: https://github.com/ruoxi-wang/PBBFMM3D
Summary updated