Use ArrayRef in compute_globals
[alexxy/gromacs.git] / src / gromacs / domdec / partition.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
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.
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  *
37  * \brief This file declares functions for mdrun to call to make a new
38  * domain decomposition, and check it.
39  *
40  * \author Berk Hess <hess@kth.se>
41  * \inlibraryapi
42  * \ingroup module_domdec
43  */
44
45 #ifndef GMX_DOMDEC_PARTITION_H
46 #define GMX_DOMDEC_PARTITION_H
47
48 #include "gromacs/gpu_utils/hostallocator.h"
49 #include "gromacs/math/vectypes.h"
50 #include "gromacs/utility/basedefinitions.h"
51 #include "gromacs/utility/real.h"
52
53 struct gmx_ddbox_t;
54 struct gmx_domdec_t;
55 struct gmx_localtop_t;
56 struct gmx_mtop_t;
57 struct gmx_vsite_t;
58 struct gmx_wallcycle;
59 struct pull_t;
60 struct t_commrec;
61 struct t_forcerec;
62 struct t_inputrec;
63 struct t_nrnb;
64 class t_state;
65
66 namespace gmx
67 {
68 class Constraints;
69 class ImdSession;
70 class MDAtoms;
71 class MDLogger;
72 } // namespace gmx
73
74 //! Check whether the DD grid has moved too far for correctness.
75 bool check_grid_jump(int64_t step, const gmx_domdec_t* dd, real cutoff, const gmx_ddbox_t* ddbox, gmx_bool bFatal);
76
77 /*! \brief Print statistics for domain decomposition communication */
78 void print_dd_statistics(const t_commrec* cr, const t_inputrec* ir, FILE* fplog);
79
80 /*! \brief Partition the system over the nodes.
81  *
82  * step is only used for printing error messages.
83  * If bMasterState==TRUE then state_global from the master node is used,
84  * else state_local is redistributed between the nodes.
85  * When f!=NULL, *f will be reallocated to the size of state_local.
86  *
87  * \param[in] fplog         Pointer to the log file
88  * \param[in] mdlog         MD file logger
89  * \param[in] step          Current step
90  * \param[in] cr            Communication record
91  * \param[in] bMasterState  Is it a master state
92  * \param[in] nstglobalcomm Will globals be computed on this step
93  * \param[in] state_global  Global state
94  * \param[in] top_global    Global topology
95  * \param[in] ir            Input record
96  * \param[in] imdSession    IMD handle
97  * \param[in] pull_work     Pulling data
98  * \param[in] state_local   Local state
99  * \param[in] f             Force buffer
100  * \param[in] mdatoms       MD atoms
101  * \param[in] top_local     Local topology
102  * \param[in] fr            Force record
103  * \param[in] vsite         Virtual sites
104  * \param[in] constr        Constraints
105  * \param[in] nrnb          Cycle counters
106  * \param[in] wcycle        Timers
107  * \param[in] bVerbose      Be verbose
108  */
109 void dd_partition_system(FILE*                             fplog,
110                          const gmx::MDLogger&              mdlog,
111                          int64_t                           step,
112                          const t_commrec*                  cr,
113                          gmx_bool                          bMasterState,
114                          int                               nstglobalcomm,
115                          t_state*                          state_global,
116                          const gmx_mtop_t&                 top_global,
117                          const t_inputrec*                 ir,
118                          gmx::ImdSession*                  imdSession,
119                          pull_t*                           pull_work,
120                          t_state*                          state_local,
121                          gmx::PaddedHostVector<gmx::RVec>* f,
122                          gmx::MDAtoms*                     mdatoms,
123                          gmx_localtop_t*                   top_local,
124                          t_forcerec*                       fr,
125                          gmx_vsite_t*                      vsite,
126                          gmx::Constraints*                 constr,
127                          t_nrnb*                           nrnb,
128                          gmx_wallcycle*                    wcycle,
129                          gmx_bool                          bVerbose);
130
131 /*! \brief Check whether bonded interactions are missing, if appropriate
132  *
133  * \param[in]    mdlog                                  Logger
134  * \param[in]    cr                                     Communication object
135  * \param[in]    totalNumberOfBondedInteractions        Result of the global reduction over the number of bonds treated in each domain
136  * \param[in]    top_global                             Global topology for the error message
137  * \param[in]    top_local                              Local topology for the error message
138  * \param[in]    x                                      Position vector for the error message
139  * \param[in]    box                                    Box matrix for the error message
140  * \param[in,out] shouldCheckNumberOfBondedInteractions Whether we should do the check. Always set to false.
141  */
142 void checkNumberOfBondedInteractions(const gmx::MDLogger&           mdlog,
143                                      t_commrec*                     cr,
144                                      int                            totalNumberOfBondedInteractions,
145                                      const gmx_mtop_t*              top_global,
146                                      const gmx_localtop_t*          top_local,
147                                      gmx::ArrayRef<const gmx::RVec> x,
148                                      const matrix                   box,
149                                      bool* shouldCheckNumberOfBondedInteractions);
150
151 #endif