NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Sailfish: A flexible multi-GPU implementation of the lattice Boltzmann method

Michal Januszewski, M. KosturComput. Phys. Commun 2014 · DOI

TL;DR

This paper introduces Sailfish, a highly flexible and performant open-source Lattice Boltzmann Method (LBM) simulation package designed for modern GPUs. By leveraging runtime code generation and a Python-based high-level interface, Sailfish achieves state-of-the-art performance across various LBM models and hardware, while simplifying experimentation and customization.

What Problem Does This Paper Address?

Simulating fluid dynamics, especially complex phenomena, requires significant computational power. Traditional methods often struggle with the massive parallelism offered by modern Graphics Processing Units (GPUs). While the Lattice Boltzmann Method (LBM) is well-suited for parallel architectures due to its local nature, efficiently implementing diverse LBM models and achieving high performance on GPUs remains a challenge. Existing solutions often lack flexibility, are difficult to maintain, or require deep low-level programming expertise. This paper addresses the need for a versatile, high-performance LBM framework that can easily adapt to new models, hardware generations, and distributed computing environments.

Methods

Sailfish employs a novel approach to GPU code implementation by using runtime code generation. The core idea is to use a high-level Python interface to define simulations, LBM models, and parameters. This information is then fed into a template-based code generation system (using Mako) and a computer algebra system (Sympy) to dynamically generate optimized CUDA C or OpenCL code for the GPU. This approach offers several advantages:

  • Flexibility: Easily experiment with different LBM models (single and multi-component), boundary conditions, and numerical schemes without rewriting low-level code.
  • Performance: Generates highly optimized, hardware-specific code, achieving performance comparable to hand-tuned kernels.
  • Maintainability: The high-level Python code is more readable and easier to manage than large, low-level GPU codebases.
  • Extensibility: New LBM models and features can be added by extending the Python framework.

The paper also details strategies for distributed simulations across multiple GPUs and nodes, utilizing libraries like ZeroMQ for communication. It discusses various memory access patterns (AB, AA, indirect addressing) and their impact on performance, as well as optimization techniques for GPU architectures, including the use of intrinsic functions and careful memory management.

Datasets

The paper does not describe training datasets. Instead, it focuses on validation using established computational fluid dynamics test cases:

  • Taylor-Green decaying vortex flow: Used to study the impact of single vs. double precision and round-off minimization.
  • Lid-driven cavity flow: A standard benchmark for validating LBM implementations.
  • Binary Poiseuille flow: Used to test binary fluid models.
  • Capillary wave decay: Used to validate binary fluid models in a dynamic scenario.

These test cases are compared against analytical solutions or results from previously published literature.

Key Insights and Ideas

  • Runtime code generation is key to flexibility and performance: By generating GPU code on-the-fly from high-level descriptions, Sailfish achieves a sweet spot between ease of use and computational efficiency, outperforming monolithic, hand-coded solutions for complex models.
  • Python as a powerful front-end for GPU computing: The paper demonstrates that Python, combined with templating and symbolic math libraries, can effectively manage complex GPU simulations, abstracting away much of the low-level CUDA/OpenCL complexity.
  • Memory access patterns significantly impact GPU performance: The choice of memory layout (AB vs. AA) and access strategy can lead to noticeable performance differences, especially on older GPU architectures.
  • Single precision can be tricky but offers significant speedups: While single precision can introduce numerical errors, especially at low velocities, techniques like round-off minimization can mitigate these issues, making it a viable option for performance-critical simulations.
  • Modern GPUs are complex beasts: Achieving optimal performance requires careful consideration of memory hierarchy, thread synchronization, and hardware-specific optimizations.

Key Results

  • Sailfish demonstrates state-of-the-art performance across various LBM models and GPU generations (Tesla, Fermi, Kepler).
  • Weak scaling results show excellent performance up to 64 GPUs, with only a minor efficiency loss (1.5%).
  • Strong scaling also shows good performance, with a 3.5% efficiency loss when scaling to 8 GPUs.
  • The entropic LBM (ELBM) model, when optimized with intrinsic functions, achieves a ~43% speedup with no noticeable impact on correctness.
  • Single precision simulations can achieve significantly higher performance (up to 2x) than double precision, with careful parameter selection and model choice being crucial for accuracy.
  • The Shan-Chen model shows 17-20% speedups with nonlinear pseudopotentials.
  • Validation against standard CFD test cases shows excellent agreement with analytical solutions and published results.

Limitations and Future Work

  • Low Mach number restriction: The Lattice Boltzmann Method inherently works for low Mach number flows only.
  • Single precision accuracy: While offering performance benefits, single precision can lead to accuracy issues, particularly in the slow velocity regime. The paper suggests using round-off minimizing models to mitigate this.
  • Future work: The authors mention ongoing efforts to implement hierarchical lattices for local grid refinement and a fluid-structure interaction model using the immersed boundary method. They also invite community contributions to further develop the framework.

Summary updated

BibTeX
@article{januszewski2014sailfish,
  author = {Michal Januszewski and M. Kostur},
  title = {{Sailfish: A flexible multi-GPU implementation of the lattice Boltzmann method}},
  journal = {Comput. Phys. Commun.},
  year = {2014},
  doi = {10.1016/j.cpc.2014.04.018},
}
Figure