16977d73d2540e5bf3db4c179f90e6957b5778ae
[alexxy/gromacs.git] / src / gromacs / mdlib / nbnxn_cuda / nbnxn_cuda_kernels.cuh
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
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.
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 #include "gromacs/gpu_utils/cuda_arch_utils.cuh"
37
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  */
54
55 /* Analytical plain cut-off electrostatics kernels
56  */
57 #define EL_CUTOFF
58
59 /* cut-off + V shift LJ */
60 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJ ## __VA_ARGS__
61 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
62 #undef NB_KERNEL_FUNC_NAME
63 /* cut-off + V shift LJ w geometric combination rules */
64 #define LJ_COMB_GEOM
65 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJCombGeom ## __VA_ARGS__
66 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
67 #undef LJ_COMB_GEOM
68 #undef NB_KERNEL_FUNC_NAME
69 /* cut-off + V shift LJ w LB combination rules */
70 #define LJ_COMB_LB
71 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJCombLB ## __VA_ARGS__
72 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
73 #undef LJ_COMB_LB
74 #undef NB_KERNEL_FUNC_NAME
75 /* LJ-Ewald w geometric combination rules */
76 #define LJ_EWALD_COMB_GEOM
77 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJEwCombGeom ## __VA_ARGS__
78 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
79 #undef LJ_EWALD_COMB_GEOM
80 #undef NB_KERNEL_FUNC_NAME
81 /* LJ-Ewald w LB combination rules */
82 #define LJ_EWALD_COMB_LB
83 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJEwCombLB ## __VA_ARGS__
84 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
85 #undef LJ_EWALD_COMB_LB
86 #undef NB_KERNEL_FUNC_NAME
87 /* F switch LJ */
88 #define LJ_FORCE_SWITCH
89 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJFsw ## __VA_ARGS__
90 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
91 #undef LJ_FORCE_SWITCH
92 #undef NB_KERNEL_FUNC_NAME
93 /* V switch LJ */
94 #define LJ_POT_SWITCH
95 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecCut_VdwLJPsw ## __VA_ARGS__
96 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
97 #undef LJ_POT_SWITCH
98 #undef NB_KERNEL_FUNC_NAME
99
100 #undef EL_CUTOFF
101
102
103 /* Analytical reaction-field kernels
104  */
105 #define EL_RF
106
107 /* cut-off + V shift LJ */
108 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJ ## __VA_ARGS__
109 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
110 #undef NB_KERNEL_FUNC_NAME
111 /* cut-off + V shift LJ w geometric combination rules */
112 #define LJ_COMB_GEOM
113 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJCombGeom ## __VA_ARGS__
114 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
115 #undef LJ_COMB_GEOM
116 #undef NB_KERNEL_FUNC_NAME
117 /* cut-off + V shift LJ w LB combination rules */
118 #define LJ_COMB_LB
119 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJCombLB ## __VA_ARGS__
120 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
121 #undef LJ_COMB_LB
122 #undef NB_KERNEL_FUNC_NAME
123 /* LJ-Ewald w geometric combination rules */
124 #define LJ_EWALD_COMB_GEOM
125 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJEwCombGeom ## __VA_ARGS__
126 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
127 #undef LJ_EWALD_COMB_GEOM
128 #undef NB_KERNEL_FUNC_NAME
129 /* LJ-Ewald w LB combination rules */
130 #define LJ_EWALD_COMB_LB
131 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJEwCombLB ## __VA_ARGS__
132 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
133 #undef LJ_EWALD_COMB_LB
134 #undef NB_KERNEL_FUNC_NAME
135 /* F switch LJ */
136 #define LJ_FORCE_SWITCH
137 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJFsw ## __VA_ARGS__
138 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
139 #undef LJ_FORCE_SWITCH
140 #undef NB_KERNEL_FUNC_NAME
141 /* V switch LJ */
142 #define LJ_POT_SWITCH
143 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecRF_VdwLJPsw ## __VA_ARGS__
144 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
145 #undef LJ_POT_SWITCH
146 #undef NB_KERNEL_FUNC_NAME
147
148 #undef EL_RF
149
150
151 /* Analytical Ewald interaction kernels
152  */
153 #define EL_EWALD_ANA
154
155 /* cut-off + V shift LJ */
156 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJ ## __VA_ARGS__
157 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
158 #undef NB_KERNEL_FUNC_NAME
159 /* cut-off + V shift LJ w geometric combination rules */
160 #define LJ_COMB_GEOM
161 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJCombGeom ## __VA_ARGS__
162 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
163 #undef LJ_COMB_GEOM
164 #undef NB_KERNEL_FUNC_NAME
165 /* cut-off + V shift LJ w LB combination rules */
166 #define LJ_COMB_LB
167 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJCombLB ## __VA_ARGS__
168 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
169 #undef LJ_COMB_LB
170 #undef NB_KERNEL_FUNC_NAME
171 /* LJ-Ewald w geometric combination rules */
172 #define LJ_EWALD_COMB_GEOM
173 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJEwCombGeom ## __VA_ARGS__
174 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
175 #undef LJ_EWALD_COMB_GEOM
176 #undef NB_KERNEL_FUNC_NAME
177 /* LJ-Ewald w LB combination rules */
178 #define LJ_EWALD_COMB_LB
179 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJEwCombLB ## __VA_ARGS__
180 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
181 #undef LJ_EWALD_COMB_LB
182 #undef NB_KERNEL_FUNC_NAME
183 /* F switch LJ */
184 #define LJ_FORCE_SWITCH
185 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJFsw ## __VA_ARGS__
186 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
187 #undef LJ_FORCE_SWITCH
188 #undef NB_KERNEL_FUNC_NAME
189 /* V switch LJ */
190 #define LJ_POT_SWITCH
191 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEw_VdwLJPsw ## __VA_ARGS__
192 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
193 #undef LJ_POT_SWITCH
194 #undef NB_KERNEL_FUNC_NAME
195
196 #undef EL_EWALD_ANA
197
198
199 /* Analytical Ewald interaction kernels with twin-range cut-off
200  */
201 #define EL_EWALD_ANA
202 #define VDW_CUTOFF_CHECK
203
204 /* cut-off + V shift LJ */
205 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJ ## __VA_ARGS__
206 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
207 #undef NB_KERNEL_FUNC_NAME
208 /* cut-off + V shift LJ w geometric combination rules */
209 #define LJ_COMB_GEOM
210 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJCombGeom ## __VA_ARGS__
211 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
212 #undef LJ_COMB_GEOM
213 #undef NB_KERNEL_FUNC_NAME
214 /* cut-off + V shift LJ w LB combination rules */
215 #define LJ_COMB_LB
216 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJCombLB ## __VA_ARGS__
217 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
218 #undef LJ_COMB_LB
219 #undef NB_KERNEL_FUNC_NAME
220 /* LJ-Ewald w geometric combination rules */
221 #define LJ_EWALD_COMB_GEOM
222 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJEwCombGeom ## __VA_ARGS__
223 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
224 #undef LJ_EWALD_COMB_GEOM
225 #undef NB_KERNEL_FUNC_NAME
226 /* LJ-Ewald w LB combination rules */
227 #define LJ_EWALD_COMB_LB
228 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJEwCombLB ## __VA_ARGS__
229 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
230 #undef LJ_EWALD_COMB_LB
231 #undef NB_KERNEL_FUNC_NAME
232 /* F switch LJ */
233 #define LJ_FORCE_SWITCH
234 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJFsw ## __VA_ARGS__
235 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
236 #undef LJ_FORCE_SWITCH
237 #undef NB_KERNEL_FUNC_NAME
238 /* V switch LJ */
239 #define LJ_POT_SWITCH
240 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwTwinCut_VdwLJPsw ## __VA_ARGS__
241 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
242 #undef LJ_POT_SWITCH
243 #undef NB_KERNEL_FUNC_NAME
244
245 #undef EL_EWALD_ANA
246 #undef VDW_CUTOFF_CHECK
247
248
249 /* Tabulated Ewald interaction kernels */
250 #define EL_EWALD_TAB
251
252 /* cut-off + V shift LJ */
253 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJ ## __VA_ARGS__
254 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
255 #undef NB_KERNEL_FUNC_NAME
256 /* cut-off + V shift LJ w geometric combination rules */
257 #define LJ_COMB_GEOM
258 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJCombGeom ## __VA_ARGS__
259 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
260 #undef LJ_COMB_GEOM
261 #undef NB_KERNEL_FUNC_NAME
262 /* cut-off + V shift LJ w LB combination rules */
263 #define LJ_COMB_LB
264 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJCombLB ## __VA_ARGS__
265 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
266 #undef LJ_COMB_LB
267 #undef NB_KERNEL_FUNC_NAME
268 /* LJ-Ewald w geometric combination rules */
269 #define LJ_EWALD_COMB_GEOM
270 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJEwCombGeom ## __VA_ARGS__
271 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
272 #undef LJ_EWALD_COMB_GEOM
273 #undef NB_KERNEL_FUNC_NAME
274 /* LJ-Ewald w LB combination rules */
275 #define LJ_EWALD_COMB_LB
276 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJEwCombLB ## __VA_ARGS__
277 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
278 #undef LJ_EWALD_COMB_LB
279 #undef NB_KERNEL_FUNC_NAME
280 /* F switch LJ */
281 #define LJ_FORCE_SWITCH
282 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJFsw ## __VA_ARGS__
283 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
284 #undef LJ_FORCE_SWITCH
285 #undef NB_KERNEL_FUNC_NAME
286 /* V switch LJ */
287 #define LJ_POT_SWITCH
288 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTab_VdwLJPsw ## __VA_ARGS__
289 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
290 #undef LJ_POT_SWITCH
291 #undef NB_KERNEL_FUNC_NAME
292
293 #undef EL_EWALD_TAB
294
295
296 /* Tabulated Ewald interaction kernels with twin-range cut-off */
297 #define EL_EWALD_TAB
298 #define VDW_CUTOFF_CHECK
299
300 /* cut-off + V shift LJ */
301 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJ ## __VA_ARGS__
302 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
303 #undef NB_KERNEL_FUNC_NAME
304 /* cut-off + V shift LJ w geometric combination rules */
305 #define LJ_COMB_GEOM
306 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJCombGeom ## __VA_ARGS__
307 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
308 #undef LJ_COMB_GEOM
309 #undef NB_KERNEL_FUNC_NAME
310 /* cut-off + V shift LJ w LB combination rules */
311 #define LJ_COMB_LB
312 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJCombLB ## __VA_ARGS__
313 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
314 #undef LJ_COMB_LB
315 #undef NB_KERNEL_FUNC_NAME
316 /* LJ-Ewald w geometric combination rules */
317 #define LJ_EWALD_COMB_GEOM
318 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJEwCombGeom ## __VA_ARGS__
319 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
320 #undef LJ_EWALD_COMB_GEOM
321 #undef NB_KERNEL_FUNC_NAME
322 /* LJ-Ewald w LB combination rules */
323 #define LJ_EWALD_COMB_LB
324 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJEwCombLB ## __VA_ARGS__
325 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
326 #undef LJ_EWALD_COMB_LB
327 #undef NB_KERNEL_FUNC_NAME
328 /* F switch LJ */
329 #define LJ_FORCE_SWITCH
330 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJFsw ## __VA_ARGS__
331 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
332 #undef LJ_FORCE_SWITCH
333 #undef NB_KERNEL_FUNC_NAME
334 /* V switch LJ */
335 #define LJ_POT_SWITCH
336 #define NB_KERNEL_FUNC_NAME(x, ...) x ## _ElecEwQSTabTwinCut_VdwLJPsw ## __VA_ARGS__
337 #include "gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh"
338 #undef LJ_POT_SWITCH
339 #undef NB_KERNEL_FUNC_NAME
340
341 #undef EL_EWALD_TAB
342 #undef VDW_CUTOFF_CHECK