2 * This file is part of the GROMACS molecular simulation package.
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.
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 #include "gromacs/gpu_utils/cuda_arch_utils.cuh"
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).
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).
48 * NOTE: No include fence as it is meant to be included multiple times.
50 * \author Szilárd Páll <pall.szilard@gmail.com>
51 * \author Berk Hess <hess@kth.se>
52 * \ingroup module_mdlib
55 #if GMX_PTX_ARCH >= 300
56 #define FLAVOR_LEVEL_GENERATOR "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
58 #define FLAVOR_LEVEL_GENERATOR "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel_fermi.cuh"
61 /* Analytical plain cut-off electrostatics kernels
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 */
71 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJCombGeom ## __VA_ARGS__
72 #include FLAVOR_LEVEL_GENERATOR
74 #undef NB_KERNEL_FUNC_NAME
75 /* cut-off + V shift LJ w LB combination rules */
77 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJCombLB ## __VA_ARGS__
78 #include FLAVOR_LEVEL_GENERATOR
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
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
100 #define LJ_POT_SWITCH
101 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJPsw ## __VA_ARGS__
102 #include FLAVOR_LEVEL_GENERATOR
104 #undef NB_KERNEL_FUNC_NAME
109 /* Analytical reaction-field kernels
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 */
119 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJCombGeom ## __VA_ARGS__
120 #include FLAVOR_LEVEL_GENERATOR
122 #undef NB_KERNEL_FUNC_NAME
123 /* cut-off + V shift LJ w LB combination rules */
125 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJCombLB ## __VA_ARGS__
126 #include FLAVOR_LEVEL_GENERATOR
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
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
148 #define LJ_POT_SWITCH
149 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJPsw ## __VA_ARGS__
150 #include FLAVOR_LEVEL_GENERATOR
152 #undef NB_KERNEL_FUNC_NAME
157 /* Analytical Ewald interaction kernels
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 */
167 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJCombGeom ## __VA_ARGS__
168 #include FLAVOR_LEVEL_GENERATOR
170 #undef NB_KERNEL_FUNC_NAME
171 /* cut-off + V shift LJ w LB combination rules */
173 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJCombLB ## __VA_ARGS__
174 #include FLAVOR_LEVEL_GENERATOR
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
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
196 #define LJ_POT_SWITCH
197 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJPsw ## __VA_ARGS__
198 #include FLAVOR_LEVEL_GENERATOR
200 #undef NB_KERNEL_FUNC_NAME
205 /* Analytical Ewald interaction kernels with twin-range cut-off
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 */
216 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJCombGeom ## __VA_ARGS__
217 #include FLAVOR_LEVEL_GENERATOR
219 #undef NB_KERNEL_FUNC_NAME
220 /* cut-off + V shift LJ w LB combination rules */
222 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJCombLB ## __VA_ARGS__
223 #include FLAVOR_LEVEL_GENERATOR
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
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
245 #define LJ_POT_SWITCH
246 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJPsw ## __VA_ARGS__
247 #include FLAVOR_LEVEL_GENERATOR
249 #undef NB_KERNEL_FUNC_NAME
252 #undef VDW_CUTOFF_CHECK
255 /* Tabulated Ewald interaction kernels */
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 */
264 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJCombGeom ## __VA_ARGS__
265 #include FLAVOR_LEVEL_GENERATOR
267 #undef NB_KERNEL_FUNC_NAME
268 /* cut-off + V shift LJ w LB combination rules */
270 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJCombLB ## __VA_ARGS__
271 #include FLAVOR_LEVEL_GENERATOR
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
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
293 #define LJ_POT_SWITCH
294 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJPsw ## __VA_ARGS__
295 #include FLAVOR_LEVEL_GENERATOR
297 #undef NB_KERNEL_FUNC_NAME
302 /* Tabulated Ewald interaction kernels with twin-range cut-off */
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 */
312 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJCombGeom ## __VA_ARGS__
313 #include FLAVOR_LEVEL_GENERATOR
315 #undef NB_KERNEL_FUNC_NAME
316 /* cut-off + V shift LJ w LB combination rules */
318 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJCombLB ## __VA_ARGS__
319 #include FLAVOR_LEVEL_GENERATOR
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
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
341 #define LJ_POT_SWITCH
342 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJPsw ## __VA_ARGS__
343 #include FLAVOR_LEVEL_GENERATOR
345 #undef NB_KERNEL_FUNC_NAME
348 #undef VDW_CUTOFF_CHECK