SYCL: Avoid using no_init read accessor in rocFFT
[alexxy/gromacs.git] / src / gromacs / domdec / dlb.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  *
37  * \brief This file declares functions to interact with the dynamic load
38  * balancing machinery.
39  *
40  * \author Berk Hess <hess@kth.se>
41  * \inlibraryapi
42  * \ingroup module_domdec
43  */
44
45 #ifndef GMX_DOMDEC_DLB_H
46 #define GMX_DOMDEC_DLB_H
47
48 #include "gromacs/utility/real.h"
49
50 struct gmx_domdec_t;
51 struct t_commrec;
52
53
54 /*! \brief We check if to turn on DLB at the first and every 100 DD partitionings.
55  * With large imbalance DLB will turn on at the first step, so we can
56  * make the interval so large that the MPI overhead of the check is negligible.
57  */
58 constexpr int c_checkTurnDlbOnInterval = 100;
59 /*! \brief We need to check if DLB results in worse performance and then turn it off.
60  * We check this more often then for turning DLB on, because the DLB can scale
61  * the domains very rapidly, so if unlucky the load imbalance can go up quickly
62  * and furthermore, we are already synchronizing often with DLB, so
63  * the overhead of the MPI Bcast is not that high.
64  */
65 constexpr int c_checkTurnDlbOffInterval = 20;
66
67
68 /*! \brief Return the PME/PP force load ratio, or -1 if nothing was measured.
69  *
70  * Should only be called on the DD master node.
71  */
72 float dd_pme_f_ratio(const gmx_domdec_t* dd);
73
74 //! Sets the cell size limits for DD to suit dynamic load balancing.
75 void set_dlb_limits(gmx_domdec_t* dd);
76
77 /*! \brief Limit DLB to preserve the option of returning to the current cut-off.
78  *
79  * Domain boundary changes due to the DD dynamic load balancing can limit
80  * the cut-off distance that can be set in change_dd_cutoff. This function
81  * sets/changes the DLB limit such that using the passed (pair-list) cut-off
82  * should still be possible after subsequently setting a shorter cut-off
83  * with change_dd_cutoff.
84  */
85 void set_dd_dlb_max_cutoff(struct t_commrec* cr, real cutoff);
86
87 /*! \brief Sets whether we should later check the load imbalance data, so that
88  * we can trigger dynamic load balancing if enough imbalance has
89  * arisen.
90  *
91  * Used after PME load balancing unlocks DLB, so that the check
92  * whether DLB will be useful can happen immediately.
93  */
94 void dd_dlb_set_should_check_whether_to_turn_dlb_on(gmx_domdec_t* dd, bool bValue);
95
96 /*! \brief Returns if we should check whether there has been enough
97  * load imbalance to trigger dynamic load balancing.
98  *
99  * We need to check whether we check because it might be always off.
100  */
101 bool dd_dlb_get_should_check_whether_to_turn_dlb_on(gmx_domdec_t* dd);
102
103 /*! \brief Return if we are currently using dynamic load balancing */
104 bool dd_dlb_is_on(const gmx_domdec_t* dd);
105
106 /*! \brief Return if the DLB lock is set */
107 bool dd_dlb_is_locked(const gmx_domdec_t* dd);
108
109 /*! \brief Set a lock such that with DLB=auto DLB cannot get turned on */
110 void dd_dlb_lock(struct gmx_domdec_t* dd);
111
112 /*! \brief Clear a lock such that with DLB=auto DLB may get turned on later */
113 void dd_dlb_unlock(struct gmx_domdec_t* dd);
114
115 #endif