CORRFUNC: Blazing Fast Correlation Functions with AVX512FSIMD Intrinsics

  • Manodeep SinhaEmail author
  • Lehman Garrison
Conference paper
Part of the Communications in Computer and Information Science book series (CCIS, volume 964)


Correlation functions are widely used in extra-galactic astrophysics to extract insights into how galaxies occupy dark matter halos and in cosmology to place stringent constraints on cosmological parameters. A correlation function fundamentally requires computing pair-wise separations between two sets of points and then computing a histogram of the separations. Corrfunc is an existing open-source, high-performance software package for efficiently computing a multitude of correlation functions. In this paper, we will discuss the SIMD AVX512F kernels within Corrfunc, capable of processing 16 floats or 8 doubles at a time. The latest manually implemented Corrfunc AVX512F kernels show a speedup of up to \(\sim \)4\(\times \) relative to compiler-generated code for double-precision calculations. The AVX512F kernels show \(\sim \)1.6\(\times \) speedup relative to the AVX kernels and compares favorably to a theoretical maximum of \(2\times \). In addition, by pruning pairs with too large of a minimum possible separation, we achieve a \(\sim \)5–10% speedup across all the SIMD kernels. Such speedups highlight the importance of programming explicitly with SIMD vector intrinsics for complex calculations that can not be efficiently vectorized by compilers. Corrfunc is publicly available at


Correlation functions AVX512 SIMD intrinsics Molecular dynamics Spatial distance histograms Applications 



MS was primarily supported by NSF Career Award (AST-1151650) during main Corrfunc design and development. MS was also supported by the by the Australian Research Council Laureate Fellowship (FL110100072) awarded to Stuart Wyithe and by funds for the Theoretical Astrophysical Observatory (TAO). TAO is part of the All-Sky Virtual Observatory and is funded and supported by Astronomy Australia Limited, Swinburne University of Technology, and the Australian Government. The latter is provided though the Commonwealth’s Education Investment Fund and National Collaborative Research Infrastructure Strategy (NCRIS), particularly the National eResearch Collaboration Tools and Resources (NeCTAR) project. Parts of this research were conducted by the Australian Research Council Centre of Excellence for All Sky Astrophysics in 3 Dimensions (ASTRO 3D), through project number CE170100013.


  1. 1.
    Chhugani, J., et al.: Billion-particle SIMD-friendly two-point correlation on large-scale HPC cluster systems. In: Proceedings of the International Conference on High Performance Computing, Networking, Storage and Analysis, SC 2012, pp. 1:1–1:11. IEEE Computer Society Press, Los Alamitos (2012).
  2. 2.
    Gonnet, P.: A simple algorithm to accelerate the computation of non-bonded interactions in cell-based molecular dynamics simulations. J. Comput. Chem. 28(2), 570–573 (2007). Scholar
  3. 3.
    Hockney, R., Goel, S., Eastwood, J.: Quiet high-resolution computer models of a plasma. J. Comput. Phys. 14(2), 148–158 (1974). Scholar
  4. 4.
    Lindahl, E., Hess, B., van der Spoel, D.: GROMACS 3.0: a package for molecular simulation and trajectory analysis. Mol. Model. Annu. 7, 306–317 (2001). Scholar
  5. 5.
    Peebles, P.J.E.: The Large-Scale Structure of the Universe. Princeton University Press, Princeton (1980)Google Scholar
  6. 6.
    Quentrec, B., Brot, C.: New method for searching for neighbors in molecular dynamics computations. J. Comput. Phys. 13(3), 430–432 (1973). Scholar
  7. 7.
    Sinha, M., Berlind, A.A., McBride, C.K., Scoccimarro, R., Piscionere, J.A., Wibking, B.D.: Towards accurate modelling of galaxy clustering on small scales: testing the standard \(\varLambda \)CDM + halo model. MNRAS 478, 1042–1064 (2018). Scholar
  8. 8.
    Sinha, M., Lehman, G.: Corrfunc—a suite of blazing fast correlation functions on the CPU. MNRAS (2019). (Submitted to MNRAS)Google Scholar
  9. 9.
    Willis, J.S., Schaller, M., Gonnet, P., Bower, R.G., Draper, P.W.: An efficient SIMD implementation of pseudo-Verlet lists for neighbour interactions in particle-based codes. ArXiv e-prints, April 2018Google Scholar

Copyright information

© Springer Nature Singapore Pte Ltd. 2019

Authors and Affiliations

  1. 1.SA 101, Centre for Astrophysics and SupercomputingSwinburne University of TechnologyHawthornAustralia
  2. 2.Harvard-Smithsonian Center for AstrophysicsCambridgeUSA
  3. 3.ARC Centre of Excellence for All Sky Astrophysics in 3 Dimensions (ASTRO 3D), Research School for Astronomy & AstrophysicsAustralian National UniversityWeston CreekAustralia

Personalised recommendations