Introduce SimulatorBuilder
[gromacs.git] / src / gromacs / domdec / dlb.h
blobf5aa6924b77ec7ee5c28a8653c9d50201eef890d
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2018, 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.
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.
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.
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.
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.
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.
35 /*! \libinternal \file
37 * \brief This file declares functions to interact with the dynamic load
38 * balancing machinery.
40 * \author Berk Hess <hess@kth.se>
41 * \inlibraryapi
42 * \ingroup module_domdec
45 #ifndef GMX_DOMDEC_DLB_H
46 #define GMX_DOMDEC_DLB_H
48 #include "gromacs/utility/real.h"
50 struct gmx_domdec_t;
51 struct t_commrec;
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.
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.
65 constexpr int c_checkTurnDlbOffInterval = 20;
68 /*! \brief Return the PME/PP force load ratio, or -1 if nothing was measured.
70 * Should only be called on the DD master node.
72 float dd_pme_f_ratio(const gmx_domdec_t *dd);
74 //! Sets the cell size limits for DD to suit dynamic load balancing.
75 void set_dlb_limits(gmx_domdec_t *dd);
77 /*! \brief Limit DLB to preserve the option of returning to the current cut-off.
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.
85 void set_dd_dlb_max_cutoff(struct t_commrec *cr, real cutoff);
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.
91 * Used after PME load balancing unlocks DLB, so that the check
92 * whether DLB will be useful can happen immediately.
94 void dd_dlb_set_should_check_whether_to_turn_dlb_on(gmx_domdec_t *dd, bool bValue);
96 /*! \brief Returns if we should check whether there has been enough
97 * load imbalance to trigger dynamic load balancing.
99 * We need to check whether we check because it might be always off.
101 bool dd_dlb_get_should_check_whether_to_turn_dlb_on(gmx_domdec_t *dd);
103 /*! \brief Return if we are currently using dynamic load balancing */
104 bool dd_dlb_is_on(const gmx_domdec_t *dd);
106 /*! \brief Return if the DLB lock is set */
107 bool dd_dlb_is_locked(const gmx_domdec_t *dd);
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);
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);
115 #endif