Implement changes for CMake policy 0068
[alexxy/gromacs.git] / src / gromacs / simd / impl_reference / impl_reference_definitions.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2014,2015,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.
8  *
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.
13  *
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.
18  *
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.
23  *
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.
31  *
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.
34  */
35
36 #ifndef GMX_SIMD_IMPL_REFERENCE_DEFINITIONS_H
37 #define GMX_SIMD_IMPL_REFERENCE_DEFINITIONS_H
38
39 /*! \libinternal \file
40  *
41  * \brief Reference SIMD implementation, including SIMD documentation.
42  *
43  * \author Erik Lindahl <erik.lindahl@scilifelab.se>
44  *
45  * \ingroup module_simd
46  */
47 namespace gmx
48 {
49
50 /*! \cond libapi */
51 /*! \addtogroup module_simd */
52 /*! \{ */
53
54 /*! \name SIMD implementation capability definitions
55  *  \{
56  */
57
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.
61  */
62
63 //! \brief 1 if any SIMD support is present, otherwise 0.
64 #define GMX_SIMD                                                 1
65
66 /*! \brief 1 when SIMD float support is present, otherwise 0
67  *
68  * You should only use this to specifically check for single precision SIMD,
69  * support, even when the rest of Gromacs uses double precision.
70  */
71 #define GMX_SIMD_HAVE_FLOAT                                      1
72
73 //! \brief 1 if SIMD double support is present, otherwise 0
74 #define GMX_SIMD_HAVE_DOUBLE                                     1
75
76 //! \brief 1 if the SIMD implementation supports unaligned loads, otherwise 0
77 #define GMX_SIMD_HAVE_LOADU                                      1
78
79 //! \brief 1 if the SIMD implementation supports unaligned stores, otherwise 0
80 #define GMX_SIMD_HAVE_STOREU                                     1
81
82 /*! \brief 1 if the SIMD implementation has fused-multiply add hardware
83  *
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.
88  */
89 #define GMX_SIMD_HAVE_FMA                                        0
90
91 //! \brief 1 if SIMD impl has logical operations on floating-point data, otherwise 0
92 #define GMX_SIMD_HAVE_LOGICAL                                    1
93
94 //! \brief Support for extracting integers from \ref gmx::SimdFInt32 (1/0 for present/absent)
95 #define GMX_SIMD_HAVE_FINT32_EXTRACT                             1
96
97 //! \brief 1 if SIMD logical ops are supported for \ref gmx::SimdFInt32, otherwise 0
98 #define GMX_SIMD_HAVE_FINT32_LOGICAL                             1
99
100 //! \brief 1 if SIMD arithmetic ops are supported for \ref gmx::SimdFInt32, otherwise 0
101 #define GMX_SIMD_HAVE_FINT32_ARITHMETICS                         1
102
103 //! \brief Support for extracting integer from \ref gmx::SimdDInt32 (1/0 for present/absent)
104 #define GMX_SIMD_HAVE_DINT32_EXTRACT                             1
105
106 //! \brief 1 if logical operations are supported for \ref gmx::SimdDInt32, otherwise 0
107 #define GMX_SIMD_HAVE_DINT32_LOGICAL                             1
108
109 //! \brief 1 if SIMD arithmetic ops are supported for \ref gmx::SimdDInt32, otherwise 0
110 #define GMX_SIMD_HAVE_DINT32_ARITHMETICS                         1
111
112 /*! \brief 1 if implementation provides single precision copysign()
113  *
114  *  Only used in simd_math.h to selectively override the generic implementation.
115  */
116 #define GMX_SIMD_HAVE_NATIVE_COPYSIGN_FLOAT                      0
117
118 /*! \brief 1 if implementation provides single precision 1/sqrt(x) N-R iterations faster than simd_math.h
119  *
120  *  Only used in simd_math.h to selectively override the generic implementation.
121  */
122 #define GMX_SIMD_HAVE_NATIVE_RSQRT_ITER_FLOAT                    0
123
124 /*! \brief 1 if implementation provides single precision 1/x N-R iterations faster than simd_math.h
125  *
126  *  Only used in simd_math.h to selectively override the generic implementation.
127  */
128 #define GMX_SIMD_HAVE_NATIVE_RCP_ITER_FLOAT                      0
129
130 /*! \brief 1 if implementation provides single precision log() faster than simd_math.h
131  *
132  *  Only used in simd_math.h to selectively override the generic implementation.
133  */
134 #define GMX_SIMD_HAVE_NATIVE_LOG_FLOAT                           0
135
136 /*! \brief 1 if implementation provides single precision exp2() faster than simd_math.h
137  *
138  *  Only used in simd_math.h to selectively override the generic implementation.
139  */
140 #define GMX_SIMD_HAVE_NATIVE_EXP2_FLOAT                          0
141
142 /*! \brief 1 if implementation provides single precision exp() faster than simd_math.h
143  *
144  *  Only used in simd_math.h to selectively override the generic implementation.
145  */
146 #define GMX_SIMD_HAVE_NATIVE_EXP_FLOAT                           0
147
148 /*! \brief 1 if implementation provides double precision copysign()
149  *
150  *  Only used in simd_math.h to selectively override the generic implementation.
151  */
152 #define GMX_SIMD_HAVE_NATIVE_COPYSIGN_DOUBLE                     0
153
154 /*! \brief 1 if implementation provides double precision 1/sqrt(x) N-R iterations faster than simd_math.h
155  *
156  *  Only used in simd_math.h to selectively override the generic implementation.
157  */
158 #define GMX_SIMD_HAVE_NATIVE_RSQRT_ITER_DOUBLE                   0
159
160 /*! \brief 1 if implementation provides double precision 1/x N-R iterations faster than simd_math.h
161  *
162  *  Only used in simd_math.h to selectively override the generic implementation.
163  */
164 #define GMX_SIMD_HAVE_NATIVE_RCP_ITER_DOUBLE                     0
165
166 /*! \brief 1 if implementation provides double precision log() faster than simd_math.h
167  *
168  *  Only used in simd_math.h to selectively override the generic implementation.
169  */
170 #define GMX_SIMD_HAVE_NATIVE_LOG_DOUBLE                          0
171
172 /*! \brief 1 if implementation provides double precision exp2() faster than simd_math.h
173  *
174  *  Only used in simd_math.h to selectively override the generic implementation.
175  */
176 #define GMX_SIMD_HAVE_NATIVE_EXP2_DOUBLE                         0
177
178 /*! \brief 1 if implementation provides double precision exp() faster than simd_math.h
179  *
180  *  Only used in simd_math.h to selectively override the generic implementation.
181  */
182 #define GMX_SIMD_HAVE_NATIVE_EXP_DOUBLE                          0
183
184 //! \brief 1 if \ref gmx::gatherLoadUBySimdIntTranspose is present, otherwise 0
185 #define GMX_SIMD_HAVE_GATHER_LOADU_BYSIMDINT_TRANSPOSE_FLOAT     1
186
187 //! \brief 1 if \ref gmx::gatherLoadUBySimdIntTranspose is present, otherwise 0
188 #define GMX_SIMD_HAVE_GATHER_LOADU_BYSIMDINT_TRANSPOSE_DOUBLE    1
189
190 //! \brief 1 if float half-register load/store/reduce utils present, otherwise 0
191 #define GMX_SIMD_HAVE_HSIMD_UTIL_FLOAT                           1
192
193 //! \brief 1 if double half-register load/store/reduce utils present, otherwise 0
194 #define GMX_SIMD_HAVE_HSIMD_UTIL_DOUBLE                          1
195
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
202
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
209
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
214
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
219
220 //! \brief 1 if implementation provides \ref gmx::Simd4Float, otherwise 0.
221 #define GMX_SIMD4_HAVE_FLOAT                                     1
222
223 //! \brief 1 if the implementation provides \ref gmx::Simd4Double, otherwise 0.
224 #define GMX_SIMD4_HAVE_DOUBLE                                    1
225
226 //! \brief Width of the \ref gmx::SimdFInt32 datatype.
227 #define GMX_SIMD_FINT32_WIDTH                                    GMX_SIMD_FLOAT_WIDTH
228
229 //! \brief Width of the \ref gmx::SimdDInt32 datatype.
230 #define GMX_SIMD_DINT32_WIDTH                                    GMX_SIMD_DOUBLE_WIDTH
231
232 //! \brief The SIMD4 type is always four units wide, but this makes code more explicit
233 #define GMX_SIMD4_WIDTH                                          4
234
235 //! \brief Required alignment in bytes for aligned load/store (always defined, even without SIMD)
236 #define GMX_SIMD_ALIGNMENT                                       8 // 8 (1*double)
237
238 //! \brief Accuracy of SIMD 1/sqrt(x) lookup. Used to determine number of iterations.
239 #define GMX_SIMD_RSQRT_BITS                                      23
240
241 //! \brief Accuracy of SIMD 1/x lookup. Used to determine number of iterations.
242 #define GMX_SIMD_RCP_BITS                                        23
243
244 //! \}
245
246 //! \}
247
248 //! \endcond
249
250 }
251 #endif // GMX_SIMD_IMPL_REFERENCE_DEFINITIONS_H