Introduce ObservablesHistory container
[gromacs.git] / src / gromacs / mdlib / nbnxn_cuda / nbnxn_cuda_kernels.cuh
blobe56ce654115f66ce9325ae877c78d9737865b8e3
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013,2014,2016, 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  */
36 #include "gromacs/gpu_utils/cuda_arch_utils.cuh"
38 /*! \internal \file
39  *  This header has the sole purpose of generating kernels for the combinations of
40  *  supported electrostatics types (cut-off, reaction-field, analytical and
41  *  tabulated Ewald) and VDW types (cut-off + V shift, LJ-Ewald with
42  *  geometric or Lorentz-Berthelot combination rule, F switch, V switch).
43  *
44  *  The Ewald kernels have twin-range cut-off versions with rcoul != rvdw which
45  *  require an extra distance check to enable  PP-PME load balancing
46  *  (otherwise, by default rcoul == rvdw).
47  *
48  *  NOTE: No include fence as it is meant to be included multiple times.
49  *
50  *  \author Szilárd Páll <pall.szilard@gmail.com>
51  *  \author Berk Hess <hess@kth.se>
52  *  \ingroup module_mdlib
53  */
55 #if GMX_PTX_ARCH >= 300
56 #define FLAVOR_LEVEL_GENERATOR "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
57 #else
58 #define FLAVOR_LEVEL_GENERATOR "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel_fermi.cuh"
59 #endif
61 /* Analytical plain cut-off electrostatics kernels
62  */
63 #define EL_CUTOFF
65 /* cut-off + V shift LJ */
66 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJ ## __VA_ARGS__
67 #include FLAVOR_LEVEL_GENERATOR
68 #undef NB_KERNEL_FUNC_NAME
69 /* cut-off + V shift LJ w geometric combination rules */
70 #define LJ_COMB_GEOM
71 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJCombGeom ## __VA_ARGS__
72 #include FLAVOR_LEVEL_GENERATOR
73 #undef LJ_COMB_GEOM
74 #undef NB_KERNEL_FUNC_NAME
75 /* cut-off + V shift LJ w LB combination rules */
76 #define LJ_COMB_LB
77 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJCombLB ## __VA_ARGS__
78 #include FLAVOR_LEVEL_GENERATOR
79 #undef LJ_COMB_LB
80 #undef NB_KERNEL_FUNC_NAME
81 /* LJ-Ewald w geometric combination rules */
82 #define LJ_EWALD_COMB_GEOM
83 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJEwCombGeom ## __VA_ARGS__
84 #include FLAVOR_LEVEL_GENERATOR
85 #undef LJ_EWALD_COMB_GEOM
86 #undef NB_KERNEL_FUNC_NAME
87 /* LJ-Ewald w LB combination rules */
88 #define LJ_EWALD_COMB_LB
89 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJEwCombLB ## __VA_ARGS__
90 #include FLAVOR_LEVEL_GENERATOR
91 #undef LJ_EWALD_COMB_LB
92 #undef NB_KERNEL_FUNC_NAME
93 /* F switch LJ */
94 #define LJ_FORCE_SWITCH
95 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJFsw ## __VA_ARGS__
96 #include FLAVOR_LEVEL_GENERATOR
97 #undef LJ_FORCE_SWITCH
98 #undef NB_KERNEL_FUNC_NAME
99 /* V switch LJ */
100 #define LJ_POT_SWITCH
101 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJPsw ## __VA_ARGS__
102 #include FLAVOR_LEVEL_GENERATOR
103 #undef LJ_POT_SWITCH
104 #undef NB_KERNEL_FUNC_NAME
106 #undef EL_CUTOFF
109 /* Analytical reaction-field kernels
110  */
111 #define EL_RF
113 /* cut-off + V shift LJ */
114 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJ ## __VA_ARGS__
115 #include FLAVOR_LEVEL_GENERATOR
116 #undef NB_KERNEL_FUNC_NAME
117 /* cut-off + V shift LJ w geometric combination rules */
118 #define LJ_COMB_GEOM
119 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJCombGeom ## __VA_ARGS__
120 #include FLAVOR_LEVEL_GENERATOR
121 #undef LJ_COMB_GEOM
122 #undef NB_KERNEL_FUNC_NAME
123 /* cut-off + V shift LJ w LB combination rules */
124 #define LJ_COMB_LB
125 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJCombLB ## __VA_ARGS__
126 #include FLAVOR_LEVEL_GENERATOR
127 #undef LJ_COMB_LB
128 #undef NB_KERNEL_FUNC_NAME
129 /* LJ-Ewald w geometric combination rules */
130 #define LJ_EWALD_COMB_GEOM
131 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJEwCombGeom ## __VA_ARGS__
132 #include FLAVOR_LEVEL_GENERATOR
133 #undef LJ_EWALD_COMB_GEOM
134 #undef NB_KERNEL_FUNC_NAME
135 /* LJ-Ewald w LB combination rules */
136 #define LJ_EWALD_COMB_LB
137 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJEwCombLB ## __VA_ARGS__
138 #include FLAVOR_LEVEL_GENERATOR
139 #undef LJ_EWALD_COMB_LB
140 #undef NB_KERNEL_FUNC_NAME
141 /* F switch LJ */
142 #define LJ_FORCE_SWITCH
143 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJFsw ## __VA_ARGS__
144 #include FLAVOR_LEVEL_GENERATOR
145 #undef LJ_FORCE_SWITCH
146 #undef NB_KERNEL_FUNC_NAME
147 /* V switch LJ */
148 #define LJ_POT_SWITCH
149 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJPsw ## __VA_ARGS__
150 #include FLAVOR_LEVEL_GENERATOR
151 #undef LJ_POT_SWITCH
152 #undef NB_KERNEL_FUNC_NAME
154 #undef EL_RF
157 /* Analytical Ewald interaction kernels
158  */
159 #define EL_EWALD_ANA
161 /* cut-off + V shift LJ */
162 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJ ## __VA_ARGS__
163 #include FLAVOR_LEVEL_GENERATOR
164 #undef NB_KERNEL_FUNC_NAME
165 /* cut-off + V shift LJ w geometric combination rules */
166 #define LJ_COMB_GEOM
167 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJCombGeom ## __VA_ARGS__
168 #include FLAVOR_LEVEL_GENERATOR
169 #undef LJ_COMB_GEOM
170 #undef NB_KERNEL_FUNC_NAME
171 /* cut-off + V shift LJ w LB combination rules */
172 #define LJ_COMB_LB
173 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJCombLB ## __VA_ARGS__
174 #include FLAVOR_LEVEL_GENERATOR
175 #undef LJ_COMB_LB
176 #undef NB_KERNEL_FUNC_NAME
177 /* LJ-Ewald w geometric combination rules */
178 #define LJ_EWALD_COMB_GEOM
179 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJEwCombGeom ## __VA_ARGS__
180 #include FLAVOR_LEVEL_GENERATOR
181 #undef LJ_EWALD_COMB_GEOM
182 #undef NB_KERNEL_FUNC_NAME
183 /* LJ-Ewald w LB combination rules */
184 #define LJ_EWALD_COMB_LB
185 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJEwCombLB ## __VA_ARGS__
186 #include FLAVOR_LEVEL_GENERATOR
187 #undef LJ_EWALD_COMB_LB
188 #undef NB_KERNEL_FUNC_NAME
189 /* F switch LJ */
190 #define LJ_FORCE_SWITCH
191 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJFsw ## __VA_ARGS__
192 #include FLAVOR_LEVEL_GENERATOR
193 #undef LJ_FORCE_SWITCH
194 #undef NB_KERNEL_FUNC_NAME
195 /* V switch LJ */
196 #define LJ_POT_SWITCH
197 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJPsw ## __VA_ARGS__
198 #include FLAVOR_LEVEL_GENERATOR
199 #undef LJ_POT_SWITCH
200 #undef NB_KERNEL_FUNC_NAME
202 #undef EL_EWALD_ANA
205 /* Analytical Ewald interaction kernels with twin-range cut-off
206  */
207 #define EL_EWALD_ANA
208 #define VDW_CUTOFF_CHECK
210 /* cut-off + V shift LJ */
211 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJ ## __VA_ARGS__
212 #include FLAVOR_LEVEL_GENERATOR
213 #undef NB_KERNEL_FUNC_NAME
214 /* cut-off + V shift LJ w geometric combination rules */
215 #define LJ_COMB_GEOM
216 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJCombGeom ## __VA_ARGS__
217 #include FLAVOR_LEVEL_GENERATOR
218 #undef LJ_COMB_GEOM
219 #undef NB_KERNEL_FUNC_NAME
220 /* cut-off + V shift LJ w LB combination rules */
221 #define LJ_COMB_LB
222 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJCombLB ## __VA_ARGS__
223 #include FLAVOR_LEVEL_GENERATOR
224 #undef LJ_COMB_LB
225 #undef NB_KERNEL_FUNC_NAME
226 /* LJ-Ewald w geometric combination rules */
227 #define LJ_EWALD_COMB_GEOM
228 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJEwCombGeom ## __VA_ARGS__
229 #include FLAVOR_LEVEL_GENERATOR
230 #undef LJ_EWALD_COMB_GEOM
231 #undef NB_KERNEL_FUNC_NAME
232 /* LJ-Ewald w LB combination rules */
233 #define LJ_EWALD_COMB_LB
234 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJEwCombLB ## __VA_ARGS__
235 #include FLAVOR_LEVEL_GENERATOR
236 #undef LJ_EWALD_COMB_LB
237 #undef NB_KERNEL_FUNC_NAME
238 /* F switch LJ */
239 #define LJ_FORCE_SWITCH
240 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJFsw ## __VA_ARGS__
241 #include FLAVOR_LEVEL_GENERATOR
242 #undef LJ_FORCE_SWITCH
243 #undef NB_KERNEL_FUNC_NAME
244 /* V switch LJ */
245 #define LJ_POT_SWITCH
246 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJPsw ## __VA_ARGS__
247 #include FLAVOR_LEVEL_GENERATOR
248 #undef LJ_POT_SWITCH
249 #undef NB_KERNEL_FUNC_NAME
251 #undef EL_EWALD_ANA
252 #undef VDW_CUTOFF_CHECK
255 /* Tabulated Ewald interaction kernels */
256 #define EL_EWALD_TAB
258 /* cut-off + V shift LJ */
259 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJ ## __VA_ARGS__
260 #include FLAVOR_LEVEL_GENERATOR
261 #undef NB_KERNEL_FUNC_NAME
262 /* cut-off + V shift LJ w geometric combination rules */
263 #define LJ_COMB_GEOM
264 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJCombGeom ## __VA_ARGS__
265 #include FLAVOR_LEVEL_GENERATOR
266 #undef LJ_COMB_GEOM
267 #undef NB_KERNEL_FUNC_NAME
268 /* cut-off + V shift LJ w LB combination rules */
269 #define LJ_COMB_LB
270 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJCombLB ## __VA_ARGS__
271 #include FLAVOR_LEVEL_GENERATOR
272 #undef LJ_COMB_LB
273 #undef NB_KERNEL_FUNC_NAME
274 /* LJ-Ewald w geometric combination rules */
275 #define LJ_EWALD_COMB_GEOM
276 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJEwCombGeom ## __VA_ARGS__
277 #include FLAVOR_LEVEL_GENERATOR
278 #undef LJ_EWALD_COMB_GEOM
279 #undef NB_KERNEL_FUNC_NAME
280 /* LJ-Ewald w LB combination rules */
281 #define LJ_EWALD_COMB_LB
282 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJEwCombLB ## __VA_ARGS__
283 #include FLAVOR_LEVEL_GENERATOR
284 #undef LJ_EWALD_COMB_LB
285 #undef NB_KERNEL_FUNC_NAME
286 /* F switch LJ */
287 #define LJ_FORCE_SWITCH
288 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJFsw ## __VA_ARGS__
289 #include FLAVOR_LEVEL_GENERATOR
290 #undef LJ_FORCE_SWITCH
291 #undef NB_KERNEL_FUNC_NAME
292 /* V switch LJ */
293 #define LJ_POT_SWITCH
294 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJPsw ## __VA_ARGS__
295 #include FLAVOR_LEVEL_GENERATOR
296 #undef LJ_POT_SWITCH
297 #undef NB_KERNEL_FUNC_NAME
299 #undef EL_EWALD_TAB
302 /* Tabulated Ewald interaction kernels with twin-range cut-off */
303 #define EL_EWALD_TAB
304 #define VDW_CUTOFF_CHECK
306 /* cut-off + V shift LJ */
307 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJ ## __VA_ARGS__
308 #include FLAVOR_LEVEL_GENERATOR
309 #undef NB_KERNEL_FUNC_NAME
310 /* cut-off + V shift LJ w geometric combination rules */
311 #define LJ_COMB_GEOM
312 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJCombGeom ## __VA_ARGS__
313 #include FLAVOR_LEVEL_GENERATOR
314 #undef LJ_COMB_GEOM
315 #undef NB_KERNEL_FUNC_NAME
316 /* cut-off + V shift LJ w LB combination rules */
317 #define LJ_COMB_LB
318 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJCombLB ## __VA_ARGS__
319 #include FLAVOR_LEVEL_GENERATOR
320 #undef LJ_COMB_LB
321 #undef NB_KERNEL_FUNC_NAME
322 /* LJ-Ewald w geometric combination rules */
323 #define LJ_EWALD_COMB_GEOM
324 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJEwCombGeom ## __VA_ARGS__
325 #include FLAVOR_LEVEL_GENERATOR
326 #undef LJ_EWALD_COMB_GEOM
327 #undef NB_KERNEL_FUNC_NAME
328 /* LJ-Ewald w LB combination rules */
329 #define LJ_EWALD_COMB_LB
330 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJEwCombLB ## __VA_ARGS__
331 #include FLAVOR_LEVEL_GENERATOR
332 #undef LJ_EWALD_COMB_LB
333 #undef NB_KERNEL_FUNC_NAME
334 /* F switch LJ */
335 #define LJ_FORCE_SWITCH
336 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJFsw ## __VA_ARGS__
337 #include FLAVOR_LEVEL_GENERATOR
338 #undef LJ_FORCE_SWITCH
339 #undef NB_KERNEL_FUNC_NAME
340 /* V switch LJ */
341 #define LJ_POT_SWITCH
342 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJPsw ## __VA_ARGS__
343 #include FLAVOR_LEVEL_GENERATOR
344 #undef LJ_POT_SWITCH
345 #undef NB_KERNEL_FUNC_NAME
347 #undef EL_EWALD_TAB
348 #undef VDW_CUTOFF_CHECK