128-bit AVX2 SIMD for AMD Ryzen
[gromacs.git] / src / gromacs / simd / support.h
blob5e223804ee893d8c9183db6a8a7003a78b0b31aa
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2015,2016,2017, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
35 #ifndef GMX_SIMD_SUPPORT_H
36 #define GMX_SIMD_SUPPORT_H
39 /*! \libinternal \file
41 * \brief Functions to query compiled and supported SIMD architectures
43 * \author Erik Lindahl <erik.lindahl@scilifelab.se>
45 * \inlibraryapi
46 * \ingroup module_simd
49 #include "gromacs/hardware/cpuinfo.h"
51 namespace gmx
54 /*! \cond libapi */
56 /*! \brief Enumerated options for SIMD architectures */
57 enum class SimdType
59 None, //!< Disable all SIMD support
60 Reference, //!< Gromacs reference software SIMD
61 Generic, //!< Placeholder for future support for gcc generic SIMD
62 X86_Sse2, //!< SSE2
63 X86_Sse4_1, //!< SSE4.1
64 X86_Avx128Fma, //!< 128-bit Avx with FMA (Amd)
65 X86_Avx, //!< 256-bit Avx
66 X86_Avx2, //!< AVX2
67 X86_Avx2_128, //!< 128-bit AVX2, better than 256-bit for AMD Ryzen
68 X86_Avx512, //!< AVX_512
69 X86_Avx512Knl, //!< AVX_512_KNL
70 X86_Mic, //!< Knight's corner
71 Arm_Neon, //!< 32-bit ARM NEON
72 Arm_NeonAsimd, //!< 64-bit ARM AArch64 Advanced SIMD
73 Ibm_Qpx, //!< IBM QPX SIMD (BlueGene/Q and later)
74 Ibm_Vmx, //!< IBM VMX SIMD (Altivec on Power6 and later)
75 Ibm_Vsx, //!< IBM VSX SIMD (Power7 and later)
76 Fujitsu_HpcAce //!< Fujitsu K-computer
79 /*! \libinternal \brief Return a string with the name of a SIMD type
81 * \param s SIMD type to turn into string
83 const std::string &
84 simdString(SimdType s);
86 /*! \libinternal \brief Return the SIMD type that would fit this hardware best */
87 SimdType
88 simdSuggested(const CpuInfo &c);
90 /*! \libinternal \brief Return the SIMD type the library was compiled with */
91 SimdType
92 simdCompiled();
94 /*! \libinternal \brief Check if binary was compiled with the provided SIMD type
96 * \param s SIMD type to query. If this matches the suggested type
97 * for this cpu, the routine returns quietly.
98 * \param log If not nullptr, statistics will be printed to the file.
99 * If we do not have a match there will also be a warning.
100 * \param warnToStdErr If true, warnings will also be printed to stderr.
102 bool
103 simdCheck(SimdType s,
104 FILE * log,
105 bool warnToStdErr);
107 /*! \endcond */
109 } // namespace gmx
112 #endif // GMX_SIMD_SUPPORT_H