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