We present Sailfish, an open source fluid simulation package implementing the lattice Boltzmann method (LBM) on modern Graphics Processing Units (GPUs) using CUDA/OpenCL. We take a novel approach to GPU code implementation and use run-time code generation techniques and a high level programming language (Python) to achieve state of the art performance, while allowing easy experimentation with different LBM models and tuning for various types of hardware. We discuss the general design principles of the code, scaling to multiple GPUs in a distributed environment, as well as the GPU implementation and optimization of many different LBM models, both single component (BGK, MRT, ELBM) and multicomponent (Shan–Chen, free energy). The paper also presents results of performance benchmarks spanning the last three NVIDIA GPU generations (Tesla, Fermi, Kepler), which we hope will be useful for researchers working with this type of hardware and similar codes. Program SummaryProgram title: SailfishCatalogue identifier: AETA_v1_0Program summary URL:http://cpc.cs.qub.ac.uk/summaries/AETA_v1_0.htmlProgram obtainable from: CPC Program Library, Queen’s University, Belfast, N. IrelandLicensing provisions: GNU Lesser General Public License, version 3No. of lines in distributed program, including test data, etc.: 225864No. of bytes in distributed program, including test data, etc.: 46861049Distribution format: tar.gzProgramming language: Python, CUDA C, OpenCL.Computer: Any with an OpenCL or CUDA-compliant GPU.Operating system: No limits (tested on Linux and Mac OS X).RAM: Hundreds of megabytes to tens of gigabytes for typical cases.Classification: 12, 6.5.External routines: PyCUDA/PyOpenCL, Numpy, Mako, ZeroMQ (for multi-GPU simulations), scipy, sympyNature of problem:GPU-accelerated simulation of single- and multi-component fluid flows.Solution method:A wide range of relaxation models (LBGK, MRT, regularized LB, ELBM, Shan–Chen, free energy, free surface) and boundary conditions within the lattice Boltzmann method framework. Simulations can be run in single or double precision using one or more GPUs.Restrictions:The lattice Boltzmann method works for low Mach number flows only.Unusual features:The actual numerical calculations run exclusively on GPUs. The numerical code is built dynamically at run-time in CUDA C or OpenCL, using templates and symbolic formulas. The high-level control of the simulation is maintained by a Python process.Additional comments:!!!!! The distribution file for this program is over 45 Mbytes and therefore is not delivered directly when Download or Email is requested. Instead a html file giving details of how the program can be obtained is sent. !!!!!Running time:Problem-dependent, typically minutes (for small cases or short simulations) to hours (large cases or long simulations).