Merge remote-tracking branch 'origin/release-2019'
[alexxy/gromacs.git] / src / gromacs / mdtypes / simulation_workload.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 step, domain-lifetime, and run workload managers.
37  *
38  * \author Mark Abraham <mark.j.abraham@gmail.com>
39  * \author Szilárd Páll <pall.szilard@gmail.com>
40  * \ingroup module_mdlib
41  * \inlibraryapi
42  */
43 #ifndef GMX_MDTYPES_SIMULATION_WORKLOAD_H
44 #define GMX_MDTYPES_SIMULATION_WORKLOAD_H
45
46 namespace gmx
47 {
48
49 /*! \libinternal
50  * \brief Data structure that describes work that can change per-step.
51  *
52  * Note that the contents of an object of this type has a lifetime
53  * of a single step and it is expected to be set at the beginning each step.
54  *
55  * The initial set of flags map the legacy force flags to boolean flags;
56  * these have the role of directing per-step compute tasks undertaken by a PP rank.
57  *
58  */
59 class StepWorkload
60 {
61     public:
62         //! Whether the state has changed, always set unless TPI is used.
63         bool stateChanged = false;
64         //! Whether the box might have changed
65         bool haveDynamicBox = false;
66         //! Whether neighbor searching needs to be done this step
67         bool doNeighborSearch = false;
68         //! Whether virial needs to be computed this step
69         bool computeVirial = false;
70         //! Whether energies need to be computed this step this step
71         bool computeEnergy = false;
72         //! Whether (any) forces need to be computed this step, not only energies
73         bool computeForces = false;
74         //! Whether nonbonded forces need to be computed this step
75         bool computeNonbondedForces = false;
76         //! Whether listed forces need to be computed this step
77         bool computeListedForces = false;
78         //! Whether this step DHDL needs to be computed
79         bool computeDhdl = false;
80 };
81
82 /*! \libinternal
83  * \brief Manage computational work that has the lifetime of decomposition.
84  *
85  * An object of this type is updated every decomposition step
86  * (i.e. domain decomposition / neighbour search)
87  * reflecting what work is required during the lifetime of a domain.
88  * e.g. whether there are bonded interactions in this PP task.
89  *
90  * This will remove the desire for inline getters from modules that
91  * describe whether they have work to do, because that can be set up
92  * once per simulation or neighborlist lifetime and not changed
93  * thereafter.
94  */
95 class DomainLifetimeWorkload
96 {
97     public:
98         //! Whether the current nstlist step-range has bonded work to run on a GPU.
99         bool haveGpuBondedWork = false;
100         //! Whether the current nstlist step-range has bonded work to run on he CPU.
101         bool haveCpuBondedWork = false;
102         //! Whether the current nstlist step-range has restraints work to run on he CPU.
103         bool haveRestraintsWork = false;
104         //! Whether the current nstlist step-range has listed forces work to run on he CPU.
105         //  Note: currently this is haveCpuBondedWork | haveRestraintsWork
106         bool haveCpuListedForceWork = false;
107         //! Whether the current nstlist step-range has special forces on the CPU.
108         bool haveSpecialForces = false;
109
110         // TODO
111         //! Whether the current nstlist step-range Free energy work on the CPU.
112         bool haveFreeEnergyWork = false;
113 };
114
115 /*! \libinternal
116  * \brief Manage what computation is required during the simulation.
117  *
118  * Holds information on the type of workload constant for the entire
119  * simulation.
120  *
121  * An object of this type is constructed at the beginning of the
122  * simulation and is expected to not change.
123  */
124 class SimulationWorkload
125 {
126 };
127
128 class MdrunScheduleWorkload
129 {
130     public:
131         //! Workload descriptor for information constant for an entire run
132         gmx::SimulationWorkload     simulationWork;
133
134         //! Workload descriptor for information constant for an nstlist range of steps
135         gmx::DomainLifetimeWorkload domainWork;
136
137         //! Workload descriptor for information that may change per-step
138         gmx::StepWorkload           stepWork;
139 };
140
141 }      // namespace gmx
142
143 #endif // GMX_MDTYPES_SIMULATION_WORKLOAD_H