Fix random typos
[alexxy/gromacs.git] / src / gromacs / mdlib / gpuforcereduction_impl_internal.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2020,2021, 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 /*! \internal \file
36  *
37  * \brief Declares vendor-specific function to launch force reduction kernel
38  *
39  * \author Andrey Alekseenko <al42and@gmail.com>
40  *
41  * \ingroup module_mdlib
42  */
43
44 #include "gromacs/gpu_utils/devicebuffer_datatype.h"
45 #include "gromacs/gpu_utils/gputraits.h"
46
47 class DeviceStream;
48
49 namespace gmx
50 {
51
52 /*! \brief Backend-specific function to launch GPU Force Reduction kernel.
53  *
54  * In pseudocode:
55  *
56  * \code{.cpp}
57  * for (int i = 0; i < numAtoms; i++) {
58  *     totalForce = d_nbnxmForceToAdd[d_cell[i]]
59  *     if (accumulate)
60  *         totalForce += d_baseForce[atomStart + i]
61  *     if (addRvecForce)
62  *         totalForce += d_rvecForceToAdd[atomStart + i]
63  *     d_baseForce[atomStart + i] = totalForce[i]
64  * }
65  * \endcode
66  *
67  * \param numAtoms Number of atoms subject to reduction.
68  * \param atomStart First atom index (for \p d_rvecForceToAdd and \p d_baseForce).
69  * \param addRvecForce When \c false, \p d_rvecForceToAdd is ignored.
70  * \param accumulate When \c false, the previous values of \p d_baseForce are discarded.
71  * \param d_nbnxmForceToAdd Buffer containing Nbnxm forces in Nbnxm layout.
72  * \param d_rvecForceToAdd Optional buffer containing arbitrary forces in linear layout.
73  * \param d_baseForce Destination buffer for forces in linear layout.
74  * \param d_cell Atom index to Nbnxm cell index.
75  * \param deviceStream Device stream for kernel submission.
76  */
77 void launchForceReductionKernel(int                  numAtoms,
78                                 int                  atomStart,
79                                 bool                 addRvecForce,
80                                 bool                 accumulate,
81                                 DeviceBuffer<Float3> d_nbnxmForceToAdd,
82                                 DeviceBuffer<Float3> d_rvecForceToAdd,
83                                 DeviceBuffer<Float3> d_baseForce,
84                                 DeviceBuffer<int>    d_cell,
85                                 const DeviceStream&  deviceStream);
86
87 } // namespace gmx