2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014,2016,2017,2018, 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 /* Use the standard (non-Fermi) kernel in host pass too. */
56 #if GMX_PTX_ARCH >= 300 || GMX_PTX_ARCH == 0
57 #define FLAVOR_LEVEL_GENERATOR "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
59 #define FLAVOR_LEVEL_GENERATOR "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel_fermi.cuh"
62 /* Analytical plain cut-off electrostatics kernels
66 /* cut-off + V shift LJ */
67 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJ ## __VA_ARGS__
68 #include FLAVOR_LEVEL_GENERATOR
69 #undef NB_KERNEL_FUNC_NAME
70 /* cut-off + V shift LJ w geometric combination rules */
72 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJCombGeom ## __VA_ARGS__
73 #include FLAVOR_LEVEL_GENERATOR
75 #undef NB_KERNEL_FUNC_NAME
76 /* cut-off + V shift LJ w LB combination rules */
78 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJCombLB ## __VA_ARGS__
79 #include FLAVOR_LEVEL_GENERATOR
81 #undef NB_KERNEL_FUNC_NAME
82 /* LJ-Ewald w geometric combination rules */
83 #define LJ_EWALD_COMB_GEOM
84 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJEwCombGeom ## __VA_ARGS__
85 #include FLAVOR_LEVEL_GENERATOR
86 #undef LJ_EWALD_COMB_GEOM
87 #undef NB_KERNEL_FUNC_NAME
88 /* LJ-Ewald w LB combination rules */
89 #define LJ_EWALD_COMB_LB
90 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJEwCombLB ## __VA_ARGS__
91 #include FLAVOR_LEVEL_GENERATOR
92 #undef LJ_EWALD_COMB_LB
93 #undef NB_KERNEL_FUNC_NAME
95 #define LJ_FORCE_SWITCH
96 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJFsw ## __VA_ARGS__
97 #include FLAVOR_LEVEL_GENERATOR
98 #undef LJ_FORCE_SWITCH
99 #undef NB_KERNEL_FUNC_NAME
101 #define LJ_POT_SWITCH
102 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJPsw ## __VA_ARGS__
103 #include FLAVOR_LEVEL_GENERATOR
105 #undef NB_KERNEL_FUNC_NAME
110 /* Analytical reaction-field kernels
114 /* cut-off + V shift LJ */
115 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJ ## __VA_ARGS__
116 #include FLAVOR_LEVEL_GENERATOR
117 #undef NB_KERNEL_FUNC_NAME
118 /* cut-off + V shift LJ w geometric combination rules */
120 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJCombGeom ## __VA_ARGS__
121 #include FLAVOR_LEVEL_GENERATOR
123 #undef NB_KERNEL_FUNC_NAME
124 /* cut-off + V shift LJ w LB combination rules */
126 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJCombLB ## __VA_ARGS__
127 #include FLAVOR_LEVEL_GENERATOR
129 #undef NB_KERNEL_FUNC_NAME
130 /* LJ-Ewald w geometric combination rules */
131 #define LJ_EWALD_COMB_GEOM
132 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJEwCombGeom ## __VA_ARGS__
133 #include FLAVOR_LEVEL_GENERATOR
134 #undef LJ_EWALD_COMB_GEOM
135 #undef NB_KERNEL_FUNC_NAME
136 /* LJ-Ewald w LB combination rules */
137 #define LJ_EWALD_COMB_LB
138 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJEwCombLB ## __VA_ARGS__
139 #include FLAVOR_LEVEL_GENERATOR
140 #undef LJ_EWALD_COMB_LB
141 #undef NB_KERNEL_FUNC_NAME
143 #define LJ_FORCE_SWITCH
144 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJFsw ## __VA_ARGS__
145 #include FLAVOR_LEVEL_GENERATOR
146 #undef LJ_FORCE_SWITCH
147 #undef NB_KERNEL_FUNC_NAME
149 #define LJ_POT_SWITCH
150 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJPsw ## __VA_ARGS__
151 #include FLAVOR_LEVEL_GENERATOR
153 #undef NB_KERNEL_FUNC_NAME
158 /* Analytical Ewald interaction kernels
162 /* cut-off + V shift LJ */
163 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJ ## __VA_ARGS__
164 #include FLAVOR_LEVEL_GENERATOR
165 #undef NB_KERNEL_FUNC_NAME
166 /* cut-off + V shift LJ w geometric combination rules */
168 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJCombGeom ## __VA_ARGS__
169 #include FLAVOR_LEVEL_GENERATOR
171 #undef NB_KERNEL_FUNC_NAME
172 /* cut-off + V shift LJ w LB combination rules */
174 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJCombLB ## __VA_ARGS__
175 #include FLAVOR_LEVEL_GENERATOR
177 #undef NB_KERNEL_FUNC_NAME
178 /* LJ-Ewald w geometric combination rules */
179 #define LJ_EWALD_COMB_GEOM
180 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJEwCombGeom ## __VA_ARGS__
181 #include FLAVOR_LEVEL_GENERATOR
182 #undef LJ_EWALD_COMB_GEOM
183 #undef NB_KERNEL_FUNC_NAME
184 /* LJ-Ewald w LB combination rules */
185 #define LJ_EWALD_COMB_LB
186 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJEwCombLB ## __VA_ARGS__
187 #include FLAVOR_LEVEL_GENERATOR
188 #undef LJ_EWALD_COMB_LB
189 #undef NB_KERNEL_FUNC_NAME
191 #define LJ_FORCE_SWITCH
192 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJFsw ## __VA_ARGS__
193 #include FLAVOR_LEVEL_GENERATOR
194 #undef LJ_FORCE_SWITCH
195 #undef NB_KERNEL_FUNC_NAME
197 #define LJ_POT_SWITCH
198 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJPsw ## __VA_ARGS__
199 #include FLAVOR_LEVEL_GENERATOR
201 #undef NB_KERNEL_FUNC_NAME
206 /* Analytical Ewald interaction kernels with twin-range cut-off
209 #define VDW_CUTOFF_CHECK
211 /* cut-off + V shift LJ */
212 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJ ## __VA_ARGS__
213 #include FLAVOR_LEVEL_GENERATOR
214 #undef NB_KERNEL_FUNC_NAME
215 /* cut-off + V shift LJ w geometric combination rules */
217 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJCombGeom ## __VA_ARGS__
218 #include FLAVOR_LEVEL_GENERATOR
220 #undef NB_KERNEL_FUNC_NAME
221 /* cut-off + V shift LJ w LB combination rules */
223 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJCombLB ## __VA_ARGS__
224 #include FLAVOR_LEVEL_GENERATOR
226 #undef NB_KERNEL_FUNC_NAME
227 /* LJ-Ewald w geometric combination rules */
228 #define LJ_EWALD_COMB_GEOM
229 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJEwCombGeom ## __VA_ARGS__
230 #include FLAVOR_LEVEL_GENERATOR
231 #undef LJ_EWALD_COMB_GEOM
232 #undef NB_KERNEL_FUNC_NAME
233 /* LJ-Ewald w LB combination rules */
234 #define LJ_EWALD_COMB_LB
235 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJEwCombLB ## __VA_ARGS__
236 #include FLAVOR_LEVEL_GENERATOR
237 #undef LJ_EWALD_COMB_LB
238 #undef NB_KERNEL_FUNC_NAME
240 #define LJ_FORCE_SWITCH
241 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJFsw ## __VA_ARGS__
242 #include FLAVOR_LEVEL_GENERATOR
243 #undef LJ_FORCE_SWITCH
244 #undef NB_KERNEL_FUNC_NAME
246 #define LJ_POT_SWITCH
247 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJPsw ## __VA_ARGS__
248 #include FLAVOR_LEVEL_GENERATOR
250 #undef NB_KERNEL_FUNC_NAME
253 #undef VDW_CUTOFF_CHECK
256 /* Tabulated Ewald interaction kernels */
259 /* cut-off + V shift LJ */
260 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJ ## __VA_ARGS__
261 #include FLAVOR_LEVEL_GENERATOR
262 #undef NB_KERNEL_FUNC_NAME
263 /* cut-off + V shift LJ w geometric combination rules */
265 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJCombGeom ## __VA_ARGS__
266 #include FLAVOR_LEVEL_GENERATOR
268 #undef NB_KERNEL_FUNC_NAME
269 /* cut-off + V shift LJ w LB combination rules */
271 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJCombLB ## __VA_ARGS__
272 #include FLAVOR_LEVEL_GENERATOR
274 #undef NB_KERNEL_FUNC_NAME
275 /* LJ-Ewald w geometric combination rules */
276 #define LJ_EWALD_COMB_GEOM
277 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJEwCombGeom ## __VA_ARGS__
278 #include FLAVOR_LEVEL_GENERATOR
279 #undef LJ_EWALD_COMB_GEOM
280 #undef NB_KERNEL_FUNC_NAME
281 /* LJ-Ewald w LB combination rules */
282 #define LJ_EWALD_COMB_LB
283 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJEwCombLB ## __VA_ARGS__
284 #include FLAVOR_LEVEL_GENERATOR
285 #undef LJ_EWALD_COMB_LB
286 #undef NB_KERNEL_FUNC_NAME
288 #define LJ_FORCE_SWITCH
289 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJFsw ## __VA_ARGS__
290 #include FLAVOR_LEVEL_GENERATOR
291 #undef LJ_FORCE_SWITCH
292 #undef NB_KERNEL_FUNC_NAME
294 #define LJ_POT_SWITCH
295 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJPsw ## __VA_ARGS__
296 #include FLAVOR_LEVEL_GENERATOR
298 #undef NB_KERNEL_FUNC_NAME
303 /* Tabulated Ewald interaction kernels with twin-range cut-off */
305 #define VDW_CUTOFF_CHECK
307 /* cut-off + V shift LJ */
308 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJ ## __VA_ARGS__
309 #include FLAVOR_LEVEL_GENERATOR
310 #undef NB_KERNEL_FUNC_NAME
311 /* cut-off + V shift LJ w geometric combination rules */
313 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJCombGeom ## __VA_ARGS__
314 #include FLAVOR_LEVEL_GENERATOR
316 #undef NB_KERNEL_FUNC_NAME
317 /* cut-off + V shift LJ w LB combination rules */
319 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJCombLB ## __VA_ARGS__
320 #include FLAVOR_LEVEL_GENERATOR
322 #undef NB_KERNEL_FUNC_NAME
323 /* LJ-Ewald w geometric combination rules */
324 #define LJ_EWALD_COMB_GEOM
325 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJEwCombGeom ## __VA_ARGS__
326 #include FLAVOR_LEVEL_GENERATOR
327 #undef LJ_EWALD_COMB_GEOM
328 #undef NB_KERNEL_FUNC_NAME
329 /* LJ-Ewald w LB combination rules */
330 #define LJ_EWALD_COMB_LB
331 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJEwCombLB ## __VA_ARGS__
332 #include FLAVOR_LEVEL_GENERATOR
333 #undef LJ_EWALD_COMB_LB
334 #undef NB_KERNEL_FUNC_NAME
336 #define LJ_FORCE_SWITCH
337 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJFsw ## __VA_ARGS__
338 #include FLAVOR_LEVEL_GENERATOR
339 #undef LJ_FORCE_SWITCH
340 #undef NB_KERNEL_FUNC_NAME
342 #define LJ_POT_SWITCH
343 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJPsw ## __VA_ARGS__
344 #include FLAVOR_LEVEL_GENERATOR
346 #undef NB_KERNEL_FUNC_NAME
349 #undef VDW_CUTOFF_CHECK