Apply clang-format to source tree
[alexxy/gromacs.git] / src / gromacs / ewald / pme_program.cl
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 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  *  \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.
42  *
43  * This file specifically expects the following work size definitions:
44  *
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.
48  *
49  *  \author Aleksei Iupinov <a.yupinov@gmail.com>
50  */
51
52 // Assert placeholders, to not rip them out from OpenCL implementation - hopefully they come in handy some day with OpenCL 2
53 #define static_assert(a, b)
54 #define assert(a)
55
56 #define PmeOpenCLKernelParams PmeGpuKernelParamsBase
57
58 /* SPREAD/SPLINE */
59
60 #define atomsPerBlock (c_spreadWorkGroupSize / threadsPerAtom)
61
62 // spline/spread fused
63 #define computeSplines 1
64 #define spreadCharges 1
65 #define CUSTOMIZED_KERNEL_NAME(x) pmeSplineAndSpreadKernel
66 #include "pme_spread.clh"
67 #undef computeSplines
68 #undef spreadCharges
69 #undef CUSTOMIZED_KERNEL_NAME
70
71 // spline
72 #define computeSplines 1
73 #define spreadCharges 0
74 #define CUSTOMIZED_KERNEL_NAME(x) pmeSplineKernel
75 #include "pme_spread.clh"
76 #undef computeSplines
77 #undef spreadCharges
78 #undef CUSTOMIZED_KERNEL_NAME
79
80 // spread
81 #define computeSplines 0
82 #define spreadCharges 1
83 #define CUSTOMIZED_KERNEL_NAME(x) pmeSpreadKernel
84 #include "pme_spread.clh"
85 #undef computeSplines
86 #undef spreadCharges
87 #undef CUSTOMIZED_KERNEL_NAME
88
89
90 #undef atomsPerBlock
91
92
93 /* GATHER */
94
95 #define atomsPerBlock (c_gatherWorkGroupSize / threadsPerAtom)
96
97 // gather
98 #define overwriteForces 1
99 #define CUSTOMIZED_KERNEL_NAME(x) pmeGatherKernel
100 #include "pme_gather.clh"
101 #undef overwriteForces
102 #undef CUSTOMIZED_KERNEL_NAME
103
104 // gather with reduction
105 #define overwriteForces 0
106 #define CUSTOMIZED_KERNEL_NAME(x) pmeGatherReduceWithInputKernel
107 #include "pme_gather.clh"
108 #undef overwriteForces
109 #undef CUSTOMIZED_KERNEL_NAME
110
111
112 #undef atomsPerBlock
113
114 /* SOLVE */
115
116 // GridOrdering enum replacement
117 #define YZX 1
118 #define XYZ 2
119
120 // solve, YZX dimension order
121 #define gridOrdering YZX
122 #define computeEnergyAndVirial 0
123 #define CUSTOMIZED_KERNEL_NAME(x) pmeSolveYZXKernel
124 #include "pme_solve.clh"
125 #undef gridOrdering
126 #undef computeEnergyAndVirial
127 #undef CUSTOMIZED_KERNEL_NAME
128
129 // solve with reduction, YZX dimension order
130 #define gridOrdering YZX
131 #define computeEnergyAndVirial 1
132 #define CUSTOMIZED_KERNEL_NAME(x) pmeSolveYZXEnergyKernel
133 #include "pme_solve.clh"
134 #undef gridOrdering
135 #undef computeEnergyAndVirial
136 #undef CUSTOMIZED_KERNEL_NAME
137
138 // solve, XYZ dimension order
139 #define gridOrdering XYZ
140 #define computeEnergyAndVirial 0
141 #define CUSTOMIZED_KERNEL_NAME(x) pmeSolveXYZKernel
142 #include "pme_solve.clh"
143 #undef gridOrdering
144 #undef computeEnergyAndVirial
145 #undef CUSTOMIZED_KERNEL_NAME
146
147 // solve with reduction, XYZ dimension order
148 #define gridOrdering XYZ
149 #define computeEnergyAndVirial 1
150 #define CUSTOMIZED_KERNEL_NAME(x) pmeSolveXYZEnergyKernel
151 #include "pme_solve.clh"
152 #undef gridOrdering
153 #undef computeEnergyAndVirial
154 #undef CUSTOMIZED_KERNEL_NAME