Pass gmx::ForceFlags to CPU nbnxm dispatch code
[alexxy/gromacs.git] / src / gromacs / mdlib / ppforceworkload.h
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 /*! \libinternal \file
36  * \brief Declares force calculation workload manager.
37  *
38  * \author Mark Abraham <mark.j.abraham@gmail.com>
39  * \ingroup module_mdlib
40  * \inlibraryapi
41  */
42 #ifndef GMX_MDLIB_PPFORCEWORKLOAD_H
43 #define GMX_MDLIB_PPFORCEWORKLOAD_H
44
45 namespace gmx
46 {
47
48 /*! \libinternal
49  * \brief Data structure to map force flags to booleans that have the role of
50  *  directing per-step tasks undertaken by a PP rank.
51  *
52  * Note that the contents of this class have a lifetime of a single step and
53  * are expected to be set every step.
54  *
55  */
56 class ForceFlags
57 {
58     public:
59         //! Whether the state has changed, always set unless TPI is used.
60         bool stateChanged = false;
61         //! Whether the box might have changed
62         bool haveDynamicBox = false;
63         //! Whether neighbor searching needs to be done this step
64         bool doNeighborSearch = false;
65         //! Whether virial needs to be computed this step
66         bool computeVirial = false;
67         //! Whether energies need to be computed this step this step
68         bool computeEnergy = false;
69         //! Whether (any) forces need to be computed this step, not only energies
70         bool computeForces = false;
71         //! Whether nonbonded forces need to be computed this step
72         bool computeNonbondedForces = false;
73         //! Whether listed forces need to be computed this step
74         bool computeListedForces = false;
75         //! Whether this step DHDL needs to be computed
76         bool computeDhdl = false;
77 };
78
79 /*! \libinternal
80  * \brief Manage what force calculation work is required each step.
81  *
82  * An object of this type is updated every neighbour search stage to
83  * reflect what work is required during normal MD steps, e.g. whether
84  * there are bonded interactions in this PP task.
85  *
86  * This will remove the desire for inline getters from modules that
87  * describe whether they have work to do, because that can be set up
88  * once per simulation or neighborlist lifetime and not changed
89  * thereafter.
90  *
91  * \todo Add more responsibilities, including whether GPUs are in use,
92  * whether there is PME work, whether DD is active, whether NB
93  * local/nonlocal regions have work, whether forces/virial/energy are
94  * required.
95  *
96  * TODO rename
97  */
98 class PpForceWorkload
99 {
100     public:
101         //! Whether this MD step has bonded work to run on a GPU.
102         bool haveGpuBondedWork = false;
103         //! Whether this MD step has bonded work to run on he CPU.
104         bool haveCpuBondedWork = false;
105         //! Whether this MD step has restraints work to run on he CPU.
106         bool haveRestraintsWork = false;
107         //! Whether this MD step has listed forces work to run on he CPU.
108         //  Note: currently this is haveCpuBondedWork | haveRestraintsWork
109         bool haveCpuListedForceWork = false;
110         //! Whether this MD step has special forces on the CPU.
111         bool haveSpecialForces = false;
112 };
113
114 class MdScheduleWorkload
115 {
116     public:
117         //! Force schedule workload descriptor constant for an nstlist range
118         gmx::PpForceWorkload forceWork;
119         //! Force flags changing per-step
120         gmx::ForceFlags      forceFlags;
121 };
122
123 } // namespace gmx
124
125 #endif