Update instructions in containers.rst
[gromacs.git] / src / gromacs / simd / impl_reference / impl_reference_definitions.h
blob29dd4ae697fee7e30c826e6e58b68bc8a2af95bf
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2014,2015,2017,2018,2019,2020, 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.
36 #ifndef GMX_SIMD_IMPL_REFERENCE_DEFINITIONS_H
37 #define GMX_SIMD_IMPL_REFERENCE_DEFINITIONS_H
39 /*! \libinternal \file
41 * \brief Reference SIMD implementation, including SIMD documentation.
43 * \author Erik Lindahl <erik.lindahl@scilifelab.se>
45 * \ingroup module_simd
47 namespace gmx
50 /*! \cond libapi */
51 /*! \ingroup module_simd */
52 /*! \{ */
54 /*! \name SIMD implementation capability definitions
55 * \{
58 /* We list all the capability definitions in the main/wrapper SIMD header for
59 * each implementation, so we don't forget to set values for unsupported
60 * features to 0.
63 //! \brief 1 if any SIMD support is present, otherwise 0.
64 #define GMX_SIMD 1
66 /*! \brief 1 when SIMD float support is present, otherwise 0
68 * You should only use this to specifically check for single precision SIMD,
69 * support, even when the rest of Gromacs uses double precision.
71 #define GMX_SIMD_HAVE_FLOAT 1
73 //! \brief 1 if SIMD double support is present, otherwise 0
74 #define GMX_SIMD_HAVE_DOUBLE 1
76 //! \brief 1 if the SIMD implementation supports unaligned loads, otherwise 0
77 #define GMX_SIMD_HAVE_LOADU 1
79 //! \brief 1 if the SIMD implementation supports unaligned stores, otherwise 0
80 #define GMX_SIMD_HAVE_STOREU 1
82 /*! \brief 1 if the SIMD implementation has fused-multiply add hardware
84 * \note All the fused multiply-add functions are always available and can be
85 * used in any code (by executing separate multiply and add ops), but in
86 * a few very tight loops you might be able to save a few instructions
87 * with a separate non-FMA code path.
89 #define GMX_SIMD_HAVE_FMA 0
91 //! \brief 1 if SIMD impl has logical operations on floating-point data, otherwise 0
92 #define GMX_SIMD_HAVE_LOGICAL 1
94 //! \brief Support for extracting integers from \ref gmx::SimdFInt32 (1/0 for present/absent)
95 #define GMX_SIMD_HAVE_FINT32_EXTRACT 1
97 //! \brief 1 if SIMD logical ops are supported for \ref gmx::SimdFInt32, otherwise 0
98 #define GMX_SIMD_HAVE_FINT32_LOGICAL 1
100 //! \brief 1 if SIMD arithmetic ops are supported for \ref gmx::SimdFInt32, otherwise 0
101 #define GMX_SIMD_HAVE_FINT32_ARITHMETICS 1
103 //! \brief Support for extracting integer from \ref gmx::SimdDInt32 (1/0 for present/absent)
104 #define GMX_SIMD_HAVE_DINT32_EXTRACT 1
106 //! \brief 1 if logical operations are supported for \ref gmx::SimdDInt32, otherwise 0
107 #define GMX_SIMD_HAVE_DINT32_LOGICAL 1
109 //! \brief 1 if SIMD arithmetic ops are supported for \ref gmx::SimdDInt32, otherwise 0
110 #define GMX_SIMD_HAVE_DINT32_ARITHMETICS 1
112 /*! \brief 1 if implementation provides single precision copysign()
114 * Only used in simd_math.h to selectively override the generic implementation.
116 #define GMX_SIMD_HAVE_NATIVE_COPYSIGN_FLOAT 0
118 /*! \brief 1 if implementation provides single precision 1/sqrt(x) N-R iterations faster than simd_math.h
120 * Only used in simd_math.h to selectively override the generic implementation.
122 #define GMX_SIMD_HAVE_NATIVE_RSQRT_ITER_FLOAT 0
124 /*! \brief 1 if implementation provides single precision 1/x N-R iterations faster than simd_math.h
126 * Only used in simd_math.h to selectively override the generic implementation.
128 #define GMX_SIMD_HAVE_NATIVE_RCP_ITER_FLOAT 0
130 /*! \brief 1 if implementation provides single precision log() faster than simd_math.h
132 * Only used in simd_math.h to selectively override the generic implementation.
134 #define GMX_SIMD_HAVE_NATIVE_LOG_FLOAT 0
136 /*! \brief 1 if implementation provides single precision exp2() faster than simd_math.h
138 * Only used in simd_math.h to selectively override the generic implementation.
140 #define GMX_SIMD_HAVE_NATIVE_EXP2_FLOAT 0
142 /*! \brief 1 if implementation provides single precision exp() faster than simd_math.h
144 * Only used in simd_math.h to selectively override the generic implementation.
146 #define GMX_SIMD_HAVE_NATIVE_EXP_FLOAT 0
148 /*! \brief 1 if implementation provides double precision copysign()
150 * Only used in simd_math.h to selectively override the generic implementation.
152 #define GMX_SIMD_HAVE_NATIVE_COPYSIGN_DOUBLE 0
154 /*! \brief 1 if implementation provides double precision 1/sqrt(x) N-R iterations faster than simd_math.h
156 * Only used in simd_math.h to selectively override the generic implementation.
158 #define GMX_SIMD_HAVE_NATIVE_RSQRT_ITER_DOUBLE 0
160 /*! \brief 1 if implementation provides double precision 1/x N-R iterations faster than simd_math.h
162 * Only used in simd_math.h to selectively override the generic implementation.
164 #define GMX_SIMD_HAVE_NATIVE_RCP_ITER_DOUBLE 0
166 /*! \brief 1 if implementation provides double precision log() faster than simd_math.h
168 * Only used in simd_math.h to selectively override the generic implementation.
170 #define GMX_SIMD_HAVE_NATIVE_LOG_DOUBLE 0
172 /*! \brief 1 if implementation provides double precision exp2() faster than simd_math.h
174 * Only used in simd_math.h to selectively override the generic implementation.
176 #define GMX_SIMD_HAVE_NATIVE_EXP2_DOUBLE 0
178 /*! \brief 1 if implementation provides double precision exp() faster than simd_math.h
180 * Only used in simd_math.h to selectively override the generic implementation.
182 #define GMX_SIMD_HAVE_NATIVE_EXP_DOUBLE 0
184 //! \brief 1 if \ref gmx::gatherLoadUBySimdIntTranspose is present, otherwise 0
185 #define GMX_SIMD_HAVE_GATHER_LOADU_BYSIMDINT_TRANSPOSE_FLOAT 1
187 //! \brief 1 if \ref gmx::gatherLoadUBySimdIntTranspose is present, otherwise 0
188 #define GMX_SIMD_HAVE_GATHER_LOADU_BYSIMDINT_TRANSPOSE_DOUBLE 1
190 //! \brief 1 if float half-register load/store/reduce utils present, otherwise 0
191 #define GMX_SIMD_HAVE_HSIMD_UTIL_FLOAT 1
193 //! \brief 1 if double half-register load/store/reduce utils present, otherwise 0
194 #define GMX_SIMD_HAVE_HSIMD_UTIL_DOUBLE 1
196 #ifdef GMX_SIMD_REF_FLOAT_WIDTH
197 # define GMX_SIMD_FLOAT_WIDTH GMX_SIMD_REF_FLOAT_WIDTH
198 #else
199 //! \brief Width of the \ref gmx::SimdFloat datatype
200 # define GMX_SIMD_FLOAT_WIDTH 4
201 #endif
203 #ifdef GMX_SIMD_REF_DOUBLE_WIDTH
204 # define GMX_SIMD_DOUBLE_WIDTH GMX_SIMD_REF_DOUBLE_WIDTH
205 #else
206 //! \brief Width of the \ref gmx::SimdDouble datatype
207 # define GMX_SIMD_DOUBLE_WIDTH 4
208 #endif
210 #if GMX_SIMD_FLOAT_WIDTH >= 8 || defined DOXYGEN // set in simd.h for GMX_SIMD_FLOAT_WIDTH<=4
211 //! \brief 1 if float 4xN load utils present, otherwise 0
212 # define GMX_SIMD_HAVE_4NSIMD_UTIL_FLOAT 1
213 #endif
215 #if GMX_SIMD_DOUBLE_WIDTH >= 8 || defined DOXYGEN // set in simd.h for GMX_SIMD_DOUBLE_WIDTH<=4
216 //! \brief 1 if double 4xN load utils present, otherwise 0
217 # define GMX_SIMD_HAVE_4NSIMD_UTIL_DOUBLE 1
218 #endif
220 //! \brief 1 if implementation provides \ref gmx::Simd4Float, otherwise 0.
221 #define GMX_SIMD4_HAVE_FLOAT 1
223 //! \brief 1 if the implementation provides \ref gmx::Simd4Double, otherwise 0.
224 #define GMX_SIMD4_HAVE_DOUBLE 1
226 //! \brief Width of the \ref gmx::SimdFInt32 datatype.
227 #define GMX_SIMD_FINT32_WIDTH GMX_SIMD_FLOAT_WIDTH
229 //! \brief Width of the \ref gmx::SimdDInt32 datatype.
230 #define GMX_SIMD_DINT32_WIDTH GMX_SIMD_DOUBLE_WIDTH
232 //! \brief The SIMD4 type is always four units wide, but this makes code more explicit
233 #define GMX_SIMD4_WIDTH 4
235 /*! \brief Maximum required alignment in bytes for aligned load/store of multiple
236 * values (maximum required for either float or double). */
237 #if GMX_SIMD_DOUBLE_WIDTH >= 2 * GMX_SIMD_FLOAT_WIDTH
238 # define GMX_SIMD_ALIGNMENT (GMX_SIMD_DOUBLE_WIDTH * 8)
239 #else
240 # define GMX_SIMD_ALIGNMENT (GMX_SIMD_FLOAT_WIDTH * 4)
241 #endif
243 //! \brief Accuracy of SIMD 1/sqrt(x) lookup. Used to determine number of iterations.
244 #define GMX_SIMD_RSQRT_BITS 23
246 //! \brief Accuracy of SIMD 1/x lookup. Used to determine number of iterations.
247 #define GMX_SIMD_RCP_BITS 23
249 //! \}
251 //! \}
253 //! \endcond
255 } // namespace gmx
256 #endif // GMX_SIMD_IMPL_REFERENCE_DEFINITIONS_H