2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2018,2019,2020, 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.
37 * \brief Top-level file for generating PME OpenCL kernels.
38 * This file includes all the PME OpenCL kernel files multiple times, with additional defines.
39 * Plenty of common constants/macros are also expected to be already defined by the compiler
40 * (such as "order" which is PME interpolation order).
41 * For details, please see how pme_program.cl is compiled in pme_gpu_program_impl_ocl.cpp.
43 * This file specifically expects the following work size definitions:
45 * - c_spreadWorkGroupSize is a spline/spread kernels work group size.
46 * - c_solveMaxWorkGroupSize is a solve kernels maximum work group size.
47 * - c_gatherWorkGroupSize is a gather kernels work group size.
49 * \author Aleksei Iupinov <a.yupinov@gmail.com>
52 // Assert placeholders, to not rip them out from OpenCL implementation - hopefully they come in handy some day with OpenCL 2
55 #define PmeOpenCLKernelParams PmeGpuKernelParamsBase
59 #define atomsPerBlock (c_spreadWorkGroupSize / threadsPerAtom)
60 #define atomsPerWarp (warp_size / threadsPerAtom)
62 // spline/spread fused single grid (without FEP or FEP without energy and virial calculation at this step)
63 #define computeSplines 1
64 #define spreadCharges 1
65 #define numGrids 1 /* Using define to avoid a conditional inside the function. */
66 #define CUSTOMIZED_KERNEL_NAME(x) pmeSplineAndSpreadKernelSingle
67 #include "pme_spread.clh"
71 #undef CUSTOMIZED_KERNEL_NAME
73 // spline on single grid (without FEP or FEP without energy and virial calculation at this step)
74 #define computeSplines 1
75 #define spreadCharges 0
76 #define numGrids 1 /* Using define to avoid a conditional inside the function. */
77 #define CUSTOMIZED_KERNEL_NAME(x) pmeSplineKernelSingle
78 #include "pme_spread.clh"
82 #undef CUSTOMIZED_KERNEL_NAME
84 // spread on single grid (without FEP or FEP without energy and virial calculation at this step)
85 #define computeSplines 0
86 #define spreadCharges 1
87 #define numGrids 1 /* Using define to avoid a conditional inside the function. */
88 #define CUSTOMIZED_KERNEL_NAME(x) pmeSpreadKernelSingle
89 #include "pme_spread.clh"
93 #undef CUSTOMIZED_KERNEL_NAME
95 // spline/spread fused on two grids (FEP with energy and virial calculation at this step)
96 #define computeSplines 1
97 #define spreadCharges 1
98 #define numGrids 2 /* Using define to avoid a conditional inside the function. */
99 #define CUSTOMIZED_KERNEL_NAME(x) pmeSplineAndSpreadKernelDual
100 #include "pme_spread.clh"
101 #undef computeSplines
104 #undef CUSTOMIZED_KERNEL_NAME
106 // spline on two grids (FEP with energy and virial calculation at this step)
107 #define computeSplines 1
108 #define spreadCharges 0
109 #define numGrids 2 /* Using define to avoid a conditional inside the function. */
110 #define CUSTOMIZED_KERNEL_NAME(x) pmeSplineKernelDual
111 #include "pme_spread.clh"
112 #undef computeSplines
115 #undef CUSTOMIZED_KERNEL_NAME
117 // spread on two grids (FEP with energy and virial calculation at this step)
118 #define computeSplines 0
119 #define spreadCharges 1
120 #define numGrids 2 /* Using define to avoid a conditional inside the function. */
121 #define CUSTOMIZED_KERNEL_NAME(x) pmeSpreadKernelDual
122 #include "pme_spread.clh"
123 #undef computeSplines
126 #undef CUSTOMIZED_KERNEL_NAME
134 #define atomsPerBlock (c_gatherWorkGroupSize / threadsPerAtom)
136 // gather using single grid
137 #define numGrids 1 /* Using define to avoid a conditional inside the function. */
138 #define CUSTOMIZED_KERNEL_NAME(x) pmeGatherKernelSingle
139 #include "pme_gather.clh"
141 #undef CUSTOMIZED_KERNEL_NAME
143 // gather using two grids
144 #define numGrids 2 /* Using define to avoid a conditional inside the function. */
145 #define CUSTOMIZED_KERNEL_NAME(x) pmeGatherKernelDual
146 #include "pme_gather.clh"
148 #undef CUSTOMIZED_KERNEL_NAME
154 // GridOrdering enum replacement
158 // solve, YZX dimension order state A
159 #define gridOrdering YZX
160 #define computeEnergyAndVirial 0
161 #define CUSTOMIZED_KERNEL_NAME(x) pmeSolveYZXKernelA
162 #include "pme_solve.clh"
164 #undef computeEnergyAndVirial
165 #undef CUSTOMIZED_KERNEL_NAME
167 // solve with reduction, YZX dimension order state A
168 #define gridOrdering YZX
169 #define computeEnergyAndVirial 1
170 #define CUSTOMIZED_KERNEL_NAME(x) pmeSolveYZXEnergyKernelA
171 #include "pme_solve.clh"
173 #undef computeEnergyAndVirial
174 #undef CUSTOMIZED_KERNEL_NAME
176 // solve, XYZ dimension order state A
177 #define gridOrdering XYZ
178 #define computeEnergyAndVirial 0
179 #define CUSTOMIZED_KERNEL_NAME(x) pmeSolveXYZKernelA
180 #include "pme_solve.clh"
182 #undef computeEnergyAndVirial
183 #undef CUSTOMIZED_KERNEL_NAME
185 // solve with reduction, XYZ dimension order state A
186 #define gridOrdering XYZ
187 #define computeEnergyAndVirial 1
188 #define CUSTOMIZED_KERNEL_NAME(x) pmeSolveXYZEnergyKernelA
189 #include "pme_solve.clh"
191 #undef computeEnergyAndVirial
192 #undef CUSTOMIZED_KERNEL_NAME
194 // solve, YZX dimension order state B
195 #define gridOrdering YZX
196 #define computeEnergyAndVirial 0
197 #define CUSTOMIZED_KERNEL_NAME(x) pmeSolveYZXKernelB
198 #include "pme_solve.clh"
200 #undef computeEnergyAndVirial
201 #undef CUSTOMIZED_KERNEL_NAME
203 // solve with reduction, YZX dimension order state B
204 #define gridOrdering YZX
205 #define computeEnergyAndVirial 1
206 #define CUSTOMIZED_KERNEL_NAME(x) pmeSolveYZXEnergyKernelB
207 #include "pme_solve.clh"
209 #undef computeEnergyAndVirial
210 #undef CUSTOMIZED_KERNEL_NAME
212 // solve, XYZ dimension order state B
213 #define gridOrdering XYZ
214 #define computeEnergyAndVirial 0
215 #define CUSTOMIZED_KERNEL_NAME(x) pmeSolveXYZKernelB
216 #include "pme_solve.clh"
218 #undef computeEnergyAndVirial
219 #undef CUSTOMIZED_KERNEL_NAME
221 // solve with reduction, XYZ dimension order state B
222 #define gridOrdering XYZ
223 #define computeEnergyAndVirial 1
224 #define CUSTOMIZED_KERNEL_NAME(x) pmeSolveXYZEnergyKernelB
225 #include "pme_solve.clh"
227 #undef computeEnergyAndVirial
228 #undef CUSTOMIZED_KERNEL_NAME